#picaxe 18m2 'version 2.A * 8 BIT SERIAL DRIVER OLED/LCD FRIENDLY 9600 baud * marks
#terminal off 'version 2.D * tested O.K. also *
' DB7 = B.7
' DB6 = B.6
' DB5 = B.5
' DB4 = B.4
' DB3 = B.3
' DB2 = B.2
' DB1 = B.1
' DB0 = B.0
SYMBOL Rx = C.5
SYMBOL E = C.6
SYMBOL RS = C.7
SYMBOL senddata = b0 SYMBOL sentdata = b0
SYMBOL index = b1
SYMBOL batV = b2
SYMBOL ADCval = b3
SYMBOL D1 = b4
SYMBOL D2 = b5
EEPROM 0 ,($38,$38,$38,$C,$1,$2,$6)'(Function 8bit/2line/5x8)(Display On)(Clear Display)(Return Home)(Entry Mode Set)
' 16 8 4 2 1
EEPROM 10,(6 ,9 ,9 ,6 ,0 ,0 ,0 ,0) ' load custom character (o) =0 * ' ' ' * 17
EEPROM 18,(14,17,17,31,17,17,0 ,0) ' load custom character (A) =1 * * ' * * 27
EEPROM 26,(30,17,17,30,16,16,0 ,0) ' load custom character (P) =2 * ' * ' * 21
EEPROM 34,(17,27,21,17,17,17,0 ,0) ' load custom character (M) =3 * ' ' ' * 17
EEPROM 42,(14,17,16,16,17,14,0 ,0) ' load custom character (C) =4 * ' ' ' * 17
EEPROM 50,(30,16,16,28,16,16,0 ,0) ' load custom character (F) =5 * ' ' ' * 17
EEPROM 58,(0 ,31,1 ,31,16,16,31,0) ' load custom character (2) =6 ' ' ' ' ' 0
EEPROM 66,(14,10,14,0 ,14,10,10,0) ' load custom character (on)=7 ' ' ' ' ' 0
' custom character example (M)=3
CALIBADC10 ADCval
SETFREQ M32
dirsB = %11111111
dirsC = %11001111
batV = 10475 / ADCval
BinToAscii batV,D2,D2,D1
Initialise:
FOR index = 0 to 6
READ index, senddata : pinsB = senddata : PULSOUT E,1 ' Initialise OLED/LCD
NEXT index : PAUSE 10
DisplaySupply:
HIGH RS
FOR index = 0 TO 15
LOOKUP index,(" Supply ",D2,".",D1,"V"),senddata
pinsB = senddata : PULSOUT E,1 ' sending characters to line one
NEXT index
LoadCustomCharactersFromEEPROM:
LOW RS : senddata = $40 : pinsB = senddata : PULSOUT E,1 : HIGH RS ' Load Characters to LCD
FOR index =10 TO 73
READ index, senddata : pinsB = senddata : PULSOUT E,1 ' sending characters to LCD
NEXT index
TestCustomCharacters:
LOW RS :senddata = 192 : pinsB = senddata : PULSOUT E,1 : HIGH RS '(192-211) Line 2 Cursor Position
FOR index = 0 TO 14
LOOKUP index,("Test ",0,1,2,3,4,5,6,7,32,223),senddata
pinsB = senddata : PULSOUT E,1 ' sending characters to line two
NEXT index
Main:
bptr=28
SERIN Rx,N9600_32,@bptr
IF @bptrinc = 254 THEN Commands
SERIN [10],Rx,N9600_32,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc
@bptr = 254
bptr = 28
do until @bptr = 254
pinsB = @bptrinc : PULSOUT E,1
loop
GOTO Main
Commands:
SERIN Rx,N9600_32,sentdata
pinsB = sentdata
index = sentdata / 16: IF index = $2 then Control
LOW RS
PULSOUT E,1
HIGH RS
GOTO Main
Control:
SELECT CASE sentdata
case $20 low c.0
case $21 high c.0
case $22 low c.1
case $23 high c.1
case $24 low c.2
case $25 high c.2
END SELECT
GOTO Main