114 lines
3.2 KiB
Plaintext
114 lines
3.2 KiB
Plaintext
' ########### start ###########
|
|
' avr:mega168p
|
|
' ########### end ###########
|
|
'
|
|
' ******************************************************************
|
|
' Paulino 168p Microcontroller Board
|
|
' 2016-06-30 (c) Paolo Iocco
|
|
' ******************************************************************
|
|
'
|
|
' Circuit diagram
|
|
' ---------------
|
|
' ATtiny 88 / Mega 168 / Mega 328 Pin map
|
|
' +-\/-+
|
|
' +5V---| 100K |--->1|o |28 PC5 ADC5
|
|
' RXD PD0 2| |27 PC4 ADC4
|
|
' TXD PD1 3| |26 PC3 ADC3
|
|
' PD2 4| |25 PC2 ADC2
|
|
' GLCD_RESET<--PD3--5| |24 PC1 ADC1
|
|
' GLCD_CS<-----PD4--6| |23 PC0 ADC0
|
|
' VCC 7| |22 GND
|
|
' GND 8| |21 AREF
|
|
' OSC1------------->9| |20 VCC
|
|
' OSC2------------>10| |19 PB5 SCK
|
|
' GLCD_DC<-----PD5-11| |18 PB4 MISO
|
|
' GLCD_DO<-----PD6-12| |17 PB3 OC2A MOSI
|
|
' GLCD_SCK<----PD7-13| |16 PB2 OC1B
|
|
' PB0 14| |15 PB1 OC1A
|
|
' +----+
|
|
' -------------------------------------------------------------
|
|
' 16MHz:
|
|
' LFuse: 0xxx; HFuse: 0xxx;
|
|
' AVRDude: -U lfuse:w:0xxx:m -U hfuse:w:0xxx:m
|
|
'
|
|
' ******************************************************************
|
|
|
|
#chip mega168p,16
|
|
|
|
'#option explicit
|
|
#define GLCD_TYPE GLCD_TYPE_PCD8544
|
|
#include <glcd.h>
|
|
|
|
' Pin mapping
|
|
#define GLCD_DO portd.6
|
|
#define GLCD_SCK portd.7
|
|
#define GLCD_DC portd.5
|
|
#define GLCD_CS portd.4
|
|
#define GLCD_RESET portd.3
|
|
dim longNumber as long
|
|
dim wordNumber as word
|
|
dim byteNumber as byte
|
|
dim indexvalue as byte
|
|
dim CCount as byte
|
|
dim temp as byte
|
|
|
|
setup:
|
|
longNumber=0
|
|
wordNumber=0
|
|
byteNumber=0
|
|
Write_Command_PCD8544(0x21) 'Activate Chip and H=1.
|
|
Write_Command_PCD8544(0xC2) 'Set LCD Voltage
|
|
Write_Command_PCD8544(0x06) 'temperature correction
|
|
Write_Command_PCD8544(0x13) 'set bias system
|
|
Write_Command_PCD8544(0x20) 'set LCD mode:PDown=0, Vaddr=0, Hext=0
|
|
Write_Command_PCD8544(0x09) 'Activate all segments.
|
|
Clear_RAM_PCD8544() 'Erase all pixel on the DDRAM.
|
|
Write_Command_PCD8544(0x08) 'Blank the Display.
|
|
Write_Command_PCD8544(0x0C) 'Display Normal.
|
|
GLCDCLS
|
|
|
|
Table tabella as byte
|
|
0x01, 0x02, 0x03, 0x04
|
|
0x02, 0x03, 0x04, 0x05
|
|
0x03, 0x04, 0x05, 0x06
|
|
0x04, 0x05, 0x06, 0x07
|
|
end Table
|
|
|
|
loop:
|
|
DO forever
|
|
for CCount = 31 to 127
|
|
indexvalue = CCount/16
|
|
readtable Tabella,indexvalue,temp
|
|
GLCDPrint(0, 0, "PrintStr")
|
|
GLCDDrawString(0, 9, "DrawStr")
|
|
GLCDPrint(44, 21, " ")
|
|
GLCDPrint(44, 29, " ") ' word value
|
|
GLCDPrint(44, 37, " ") ' Byte value
|
|
GLCDPrint(44, 21, hex(longNumber_U))
|
|
GLCDPrint(56, 21, hex(longNumber_H))
|
|
GLCDPrint(68, 21, hex(longNumber))
|
|
GLCDPrint(44, 29, mid( str(wordNumber),1, 6))
|
|
GLCDPrint(44, 37, byteNumber)
|
|
|
|
box 46,9,57,19
|
|
GLCDDrawChar(48, 9, CCount )
|
|
FilledBox(58,9,GLCD_WIDTH-1,17,GLCDBackground ) 'draw a box to overwrite existing strings
|
|
GLCDPrint(58, 9, str( CCount ))
|
|
|
|
box 0,0,GLCD_WIDTH-1, GLCD_HEIGHT-1
|
|
box GLCD_WIDTH-5, GLCD_HEIGHT-5,GLCD_WIDTH- 1, GLCD_HEIGHT-1
|
|
|
|
Circle( 25,30,8,1)
|
|
'filledbox 2,30,6,38, wordNumber
|
|
'FilledCircle( 25,30,4,longNumber xor 1)
|
|
'line 0, GLCD_HEIGHT-1 , GLCD_WIDTH/2, (GLCD_HEIGHT /2) +1
|
|
'line GLCD_WIDTH/2, (GLCD_HEIGHT /2) +1 ,0, (GLCD_HEIGHT /2) +1
|
|
|
|
longNumber = longNumber + 7
|
|
wordNumber = wordNumber + 3
|
|
byteNumber++
|
|
NEXT
|
|
LOOP
|
|
|
|
end
|