' OLED Commands bX (Eg b0:, b3:) refers to the bit rather than the PICAXE byte
Symbol cOLEDDisplayClear= %00000001 ' 1 Clear Display (takes 1.7mS)
Symbol cOLEDCursorHome = %00000010 ' 2 Home (takes 1.7mS)
Symbol cOLEDEntryModeSet= %00000110 ' 6 Entry Mode Set b2:1 b1:1 move char position forward (b1:0 for backwards)
Symbol cOLEDDisplayOff = %00001000 ' 8 Display Off b3:1, b2:0(display off), b1:0(csr off), b0:0(csr flash off)
Symbol cOLEDDispCurOff = %00001100 '12 Display On b3:1, b2:1(display on), b1:1(csr on), b0:1(csr flash)
Symbol cOLEDDispCurOn = %00001110 '14 Display On b3:1, b2:1(display on), b1:1(csr on), b0:1(csr flash)
Symbol cOLEDCursorShift = %00010000 '16 b4:1, b3:0 (move cursor)/1(move display), b2:0 (sh left)/1(sh right)
Symbol cOLEDFunctionSet = %00110010 '50 b5:1, b4:1(8-bit data), b3:1(2 line LCD) b2:0 (5x7 dots)/1 (5 x 10 dots)
'Symbol cOLEDCharGenAddr= %01cccrrr 'ccc: 8 CG chars; rrr: 8 rows of 5 bits (CG data byte follows: ...xxxxx)
Symbol cOLEDPosnRow0 = %10000000 '128 Position cursor to first row (b3-b0 = Column 0 to 15) %1000xxxx $8x
Symbol cOLEDPosnRow1 = %11000000 '192 Position cursor to second row (b3-b0 = Column 0 to 15) %1100xxxx $Cx
'ymbol cLCDCharGenAddr = %01cccrrr 'ccc: 8 CG chars; rrr: 8 rows of 5 bits (CG data byte follows: ...xxxxx)
Symbol cLCDCharGenAddr0 = %01000000 'Character 0, Pixel Row 0 (to 7 for 1 character)
Symbol cLCDPosnRow0 = %10000000 'Position cursor to first row (b3-b0 = Column 0 to 15) %1000xxxx $8x
Symbol cLCDPosnRow1 = %11000000 'Position cursor to second row (b3-b0 = Column 0 to 15) %1100xxxx $Cx
'
' **** Define and Write Special Characters to LCD RAM *****
'
'Sp Char 0: Up Arrow
' 00100 Byte 0 Value = 4
' 01110 1 14
' 10101 2 21
' 00100 3 4
' 00100 4 4
' 00000 5 0
' 00000 6 0
' 00000 7 0
'Sp Char 1: Right Arrow
' 00000 Byte 0 Value = 0
' 00100 1 4
' 00010 2 2
' 11111 3 31
' 00010 4 2
' 00100 5 4
' 00000 6 0
' 00000 7 0
'[/color]
LoadSpecialChars:
bLCDChar = cLCDCharGenAddr0 'Character 0 Row 0 (8 bytes per character; 6 characters to be defined here)
GoSub Cmd2LCD 'Position input start point
For bLoop = 0 To 39 'Pointer to LCD's character RAM locations 0 to 47 (first 6 characters)
' (Characters) Up Arrow Right Arrow Down Arrow Left Arrow Select Button
' (Define 5 characters) 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
' (8-bytes per character) 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
LookUp bLoop, (4,14,21,4,4,0,0,0, 0,4,2,31,2,4,0,0, 0,0,0,4,4,21,14,4, 0,4,8,31,8,4,0,0, 0,14,17,21,17,14,0,0), bLCDChar
GoSub Chr2LCD 'Position cursor (input point)
Next bLoop
bLCDChar = cLCDPosnRow1 'Bottom Row, 1st character position
GoSub Cmd2LCD 'Position cursor (input point) - This gets the LCD out of data entry mode
Return
DCB
$08-$0F %00001xxx
D : 0 = Display Off 1 = Display On
C : 0 = Cursor Off 1 = Cursor On
B : 0 = Cursor Steady 1 = Cursor Flash
$08 %000010xx Display Off
$0C %0000110x Display On, No Cursor
$0E %00001110 Display On, Steady Cursor
$0F %00001111 Display On, Flashing Cursor
Command $40 %01000000
Data $1B %11011 ##-##
Data $1B %11011 ##-##
Data $00 %00000 -----
Data $04 %00100 --#--
Data $11 %10001 #---#
Data $0E %01110 -###-
Data $00 %00000 -----
serout OLED("CGRAM test")
serout OLED(254,192) ' line 2 pos 1
' Make my character at CGRAM address 0
serout OLED(254, %01000000, $1B, $1B, $00, $04, $11, $0E, $00 )
' Make my character at CGRAM address 1
serout OLED(254, %01001000, $1B, $1B, $04, $04, $11, $0E, $00 )
' Make my character at CGRAM address 2
serout OLED(254, %01010000, $1B, $1B, $11, $04, $11, $0E, $00 )
Issue cursor positioning, eg SEROUT...(254,192), after you have programmed the CGRAM because doing that may have altered where it thinks the cursor is at.Now how do I display my creations, assuming they actually got into in the OLED ?.
The bits of code I didn't post .....PS : You'll need some baud rates in those SEROUT
symbol OLEDpin = A.1
#define OLEDbaud N2400_8
#define OLED OLEDpin, OLEDbaud,