DirectSendCmd:
' Commands are preceeded by a 0 filled byte
hi2cout (0,abyte)
return
;SEND INIT CMD BYTE - SEND CMD BYTE - SEND DATA BYTE
SetPosition:
'20 line x 4 rows is accompished by wrapping the text on each line past 20 characters to two lines down (not next line down). Position 20 (dec) is row 3, col 1
abyte= SSD1306_PAGEADDR
hi2cout (0,abyte)
abyte = row
hi2cout (0,abyte)
abyte = 7
hi2cout (0,abyte)
abyte= SSD1306_COLUMNADDR
col = col * 5 ;columns per character
hi2cout (0,abyte)
abyte = col
hi2cout (0,abyte)
abyte = 127
hi2cout (0,abyte)
return
' STANDARD FONT
' This is the ASCII Font table 0 starting at space and ending at Z -- lower case is not included (not enough memory)
' The first 8 are in program direct writes
'table (0x00, 0x00, 0x00, 0x00, 0x00) ' Space
'table (0x00, 0x00, 0x5F, 0x00, 0x00) ' !
'table (0x00, 0x07, 0x00, 0x07, 0x00) ' "
'table (0x14, 0x7F, 0x14, 0x7F, 0x14) ' #
'table (0x24, 0x2A, 0x7F, 0x2A, 0x12) ' $
'table (0x23, 0x13, 0x08, 0x64, 0x62) ' %
'table (0x36, 0x49, 0x56, 0x20, 0x50) ' &
'table (0x00, 0x08, 0x07, 0x03, 0x00) ' '
table (0x00, 0x1C, 0x22, 0x41, 0x00) ' (
table (0x00, 0x41, 0x22, 0x1C, 0x00) ' )
table (0x2A, 0x1C, 0x7F, 0x1C, 0x2A) ' *
table (0x08, 0x08, 0x3E, 0x08, 0x08) ' +
table (0x00, 0x80, 0x70, 0x30, 0x00) ' ,
table (0x08, 0x08, 0x08, 0x08, 0x08) ' -
table (0x00, 0x00, 0x5F, 0x00, 0x0) ' .
table (0x20, 0x10, 0x08, 0x04, 0x02) ' /
table (0x3E, 0x51, 0x49, 0x45, 0x3E) ' 0
table (0x00, 0x42, 0x7F, 0x40, 0x00) ; 1
table (0x72, 0x49, 0x49, 0x49, 0x46)
table (0x21, 0x41, 0x49, 0x4D, 0x33)
table (0x18, 0x14, 0x12, 0x7F, 0x10)
table (0x27, 0x45, 0x45, 0x45, 0x39)
table (0x3C, 0x4A, 0x49, 0x49, 0x31)
table (0x41, 0x21, 0x11, 0x09, 0x07)
table (0x36, 0x49, 0x49, 0x49, 0x36)
table (0x46, 0x49, 0x49, 0x29, 0x1E)
table (0x00, 0x00, 0x14, 0x00, 0x00)
table (0x00, 0x40, 0x34, 0x00, 0x00)
table (0x00, 0x08, 0x14, 0x22, 0x41)
table (0x14, 0x14, 0x14, 0x14, 0x14)
table (0x00, 0x41, 0x22, 0x14, 0x08)
table (0x02, 0x01, 0x59, 0x09, 0x06)
table (0x3E, 0x41, 0x5D, 0x59, 0x4E)
table (0x7C, 0x12, 0x11, 0x12, 0x7C)
table (0x7F, 0x49, 0x49, 0x49, 0x36)
table (0x3E, 0x41, 0x41, 0x41, 0x22)
table (0x7F, 0x41, 0x41, 0x41, 0x3E)
table (0x7F, 0x49, 0x49, 0x49, 0x41)
table (0x7F, 0x09, 0x09, 0x09, 0x01)
table (0x3E, 0x41, 0x41, 0x51, 0x73)
table (0x7F, 0x08, 0x08, 0x08, 0x7F)
table (0x00, 0x41, 0x7F, 0x41, 0x00)
table (0x20, 0x40, 0x41, 0x3F, 0x01)
table (0x7F, 0x08, 0x14, 0x22, 0x41)
table (0x7F, 0x40, 0x40, 0x40, 0x40)
table (0x7F, 0x02, 0x1C, 0x02, 0x7F)
table (0x7F, 0x04, 0x08, 0x10, 0x7F)
table (0x3E, 0x41, 0x41, 0x41, 0x3E)
table (0x7F, 0x09, 0x09, 0x09, 0x06)
table (0x3E, 0x41, 0x51, 0x21, 0x5E)
table (0x7F, 0x09, 0x19, 0x29, 0x46)
table (0x26, 0x49, 0x49, 0x49, 0x32)
table (0x03, 0x01, 0x7F, 0x01, 0x03)
table (0x3F, 0x40, 0x40, 0x40, 0x3F)
table (0x1F, 0x20, 0x40, 0x20, 0x1F)
table (0x3F, 0x40, 0x38, 0x40, 0x3F)
table (0x63, 0x14, 0x08, 0x14, 0x63)
table (0x03, 0x04, 0x78, 0x04, 0x03)
table (0x61, 0x59, 0x49, 0x4D, 0x43) ; Z
DISPLAY_FONT:
gosub cleardisplay
eeprom 25, (SSD1306_COLUMNADDR)
eeprom 26, (0) ; ;Column start address (0 = reset)
eeprom 27, (127) ;Column end address (127 = reset)
eeprom 28, (SSD1306_PAGEADDR)
eeprom 29, (0) ;Page start address (0 = reset)
eeprom 30, (7) ;Page end address
for index = 25 TO 30
read index,aByte
hi2cout (0,abyte)
next
Writei2c (0x40, 0x00, 0x07, 0x00, 0x07, 0x00)
Writei2c (0x40, 0x14, 0x7F, 0x14, 0x7F, 0x14)
Writei2c (0x40, 0x24, 0x2A, 0x7F, 0x2A, 0x12)
Writei2c (0x40, 0x23, 0x13, 0x08, 0x64, 0x62)
Writei2c (0x40, 0x36, 0x49, 0x56, 0x20, 0x50)
Writei2c (0x40, 0x00, 0x08, 0x07, 0x03, 0x00)
Writei2c (0x40, 0x00, 0x1C, 0x22, 0x41, 0x00)
Writei2c (0x40, 0x00, 0x41, 0x22, 0x1C, 0x00)
Writei2c (0x40, 0x2A, 0x1C, 0x7F, 0x1C, 0x2A)
Writei2c (0x40, 0x08, 0x08, 0x3E, 0x08, 0x08)
Writei2c (0x40, 0x00, 0x80, 0x70, 0x30, 0x00)
Writei2c (0x40, 0x08, 0x08, 0x08, 0x08, 0x08)
Writei2c (0x40, 0x00, 0x00, 0x60, 0x60, 0x00)
Writei2c (0x40, 0x20, 0x10, 0x08, 0x04, 0x02)
Writei2c (0x40, 0x3E, 0x51, 0x49, 0x45, 0x3E)
Writei2c (0x40, 0x00, 0x42, 0x7F, 0x40, 0x00) ; 00
Writei2c (0x40, 0x72, 0x49, 0x49, 0x49, 0x46)
Writei2c (0x40, 0x21, 0x41, 0x49, 0x4D, 0x33)
Writei2c (0x40, 0x18, 0x14, 0x12, 0x7F, 0x10)
Writei2c (0x40, 0x27, 0x45, 0x45, 0x45, 0x39)
Writei2c (0x40, 0x3C, 0x4A, 0x49, 0x49, 0x31)
Writei2c (0x40, 0x41, 0x21, 0x11, 0x09, 0x07)
Writei2c (0x40, 0x36, 0x49, 0x49, 0x49, 0x36)
Writei2c (0x40, 0x46, 0x49, 0x49, 0x29, 0x1E)
Writei2c (0x40, 0x00, 0x00, 0x14, 0x00, 0x00)
Writei2c (0x40, 0x00, 0x40, 0x34, 0x00, 0x00)
Writei2c (0x40, 0x00, 0x08, 0x14, 0x22, 0x41)
Writei2c (0x40, 0x14, 0x14, 0x14, 0x14, 0x14)
Writei2c (0x40, 0x00, 0x41, 0x22, 0x14, 0x08)
Writei2c (0x40, 0x02, 0x01, 0x59, 0x09, 0x06)
Writei2c (0x40, 0x3E, 0x41, 0x5D, 0x59, 0x4E)
Writei2c (0x40, 0x7C, 0x12, 0x11, 0x12, 0x7C)
Writei2c (0x40, 0x7F, 0x49, 0x49, 0x49, 0x36)
Writei2c (0x40, 0x3E, 0x41, 0x41, 0x41, 0x22)
Writei2c (0x40, 0x7F, 0x41, 0x41, 0x41, 0x3E)
Writei2c (0x40, 0x7F, 0x49, 0x49, 0x49, 0x41)
Writei2c (0x40, 0x7F, 0x09, 0x09, 0x09, 0x01)
Writei2c (0x40, 0x3E, 0x41, 0x41, 0x51, 0x73)
Writei2c (0x40, 0x7F, 0x08, 0x08, 0x08, 0x7F)
Writei2c (0x40, 0x00, 0x41, 0x7F, 0x41, 0x00)
Writei2c (0x40, 0x20, 0x40, 0x41, 0x3F, 0x01)
Writei2c (0x40, 0x7F, 0x08, 0x14, 0x22, 0x41)
Writei2c (0x40, 0x7F, 0x40, 0x40, 0x40, 0x40)
Writei2c (0x40, 0x7F, 0x02, 0x1C, 0x02, 0x7F)
Writei2c (0x40, 0x7F, 0x04, 0x08, 0x10, 0x7F)
Writei2c (0x40, 0x3E, 0x41, 0x41, 0x41, 0x3E)
Writei2c (0x40, 0x7F, 0x09, 0x09, 0x09, 0x06)
Writei2c (0x40, 0x3E, 0x41, 0x51, 0x21, 0x5E)
Writei2c (0x40, 0x7F, 0x09, 0x19, 0x29, 0x46)
Writei2c (0x40, 0x26, 0x49, 0x49, 0x49, 0x32)
Writei2c (0x40, 0x03, 0x01, 0x7F, 0x01, 0x03)
Writei2c (0x40, 0x3F, 0x40, 0x40, 0x40, 0x3F)
Writei2c (0x40, 0x1F, 0x20, 0x40, 0x20, 0x1F)
Writei2c (0x40, 0x3F, 0x40, 0x38, 0x40, 0x3F)
Writei2c (0x40, 0x63, 0x14, 0x08, 0x14, 0x63)
Writei2c (0x40, 0x03, 0x04, 0x78, 0x04, 0x03)
Writei2c (0x40, 0x61, 0x59, 0x49, 0x4D, 0x43) ; Z
Writei2c (0x40, 0x00, 0x7F, 0x41, 0x41, 0x41)
Writei2c (0x40, 0x02, 0x04, 0x08, 0x10, 0x20)
Writei2c (0x40, 0x00, 0x41, 0x41, 0x41, 0x7F)
Writei2c (0x40, 0x04, 0x02, 0x01, 0x02, 0x04)
Writei2c (0x40, 0x40, 0x40, 0x40, 0x40, 0x40)
Writei2c (0x40, 0x00, 0x03, 0x07, 0x08, 0x00)
Writei2c (0x40, 0x20, 0x54, 0x54, 0x78, 0x40)
Writei2c (0x40, 0x7F, 0x28, 0x44, 0x44, 0x38)
Writei2c (0x40, 0x38, 0x44, 0x44, 0x44, 0x28)
Writei2c (0x40, 0x38, 0x44, 0x44, 0x28, 0x7F)
Writei2c (0x40, 0x38, 0x54, 0x54, 0x54, 0x18)
Writei2c (0x40, 0x00, 0x08, 0x7E, 0x09, 0x02)
Writei2c (0x40, 0x18, 0xA4, 0xA4, 0x9C, 0x78)
Writei2c (0x40, 0x7F, 0x08, 0x04, 0x04, 0x78)
Writei2c (0x40, 0x00, 0x44, 0x7D, 0x40, 0x00)
Writei2c (0x40, 0x20, 0x40, 0x40, 0x3D, 0x00)
Writei2c (0x40, 0x7F, 0x10, 0x28, 0x44, 0x00)
Writei2c (0x40, 0x00, 0x41, 0x7F, 0x40, 0x00)
Writei2c (0x40, 0x7C, 0x04, 0x78, 0x04, 0x78)
Writei2c (0x40, 0x7C, 0x08, 0x04, 0x04, 0x78)
Writei2c (0x40, 0x38, 0x44, 0x44, 0x44, 0x38)
Writei2c (0x40, 0xFC, 0x18, 0x24, 0x24, 0x18)
Writei2c (0x40, 0x18, 0x24, 0x24, 0x18, 0xFC)
Writei2c (0x40, 0x7C, 0x08, 0x04, 0x04, 0x08)
Writei2c (0x40, 0x48, 0x54, 0x54, 0x54, 0x24)
Writei2c (0x40, 0x04, 0x04, 0x3F, 0x44, 0x24)
Writei2c (0x40, 0x3C, 0x40, 0x40, 0x20, 0x7C)
Writei2c (0x40, 0x1C, 0x20, 0x40, 0x20, 0x1C)
Writei2c (0x40, 0x3C, 0x40, 0x30, 0x40, 0x3C)
Writei2c (0x40, 0x44, 0x28, 0x10, 0x28, 0x44)
Writei2c (0x40, 0x4C, 0x90, 0x90, 0x90, 0x7C)
Writei2c (0x40, 0x44, 0x64, 0x54, 0x4C, 0x44)
Writei2c (0x40, 0x00, 0x08, 0x36, 0x41, 0x00)
Writei2c (0x40, 0x00, 0x00, 0x77, 0x00, 0x00)
Writei2c (0x40, 0x00, 0x41, 0x36, 0x08, 0x00)
Writei2c (0x40, 0x02, 0x01, 0x02, 0x04, 0x02)
Writei2c (0x40, 0x3C, 0x26, 0x23, 0x26, 0x3C)
Writei2c (0x40, 0x1E, 0xA1, 0xA1, 0x61, 0x12)
Writei2c (0x40, 0x3A, 0x40, 0x40, 0x20, 0x7A)
Writei2c (0x40, 0x38, 0x54, 0x54, 0x55, 0x59)
Writei2c (0x40, 0x21, 0x55, 0x55, 0x79, 0x41)
return
DisplayChar:
let temp = abyte - " "
if temp< 8 then
if temp=0 then
writei2c(0x40, 0x00, 0x00, 0x00, 0x00, 0x00) ' space
elseif temp=1 then
writei2c(0x40, 0x00, 0x00, 0x5F, 0x00, 0x00) ' !
elseif temp=2 then
writei2c(0x40, 0x00, 0x07, 0x00, 0x07, 0x00) ' "
elseif temp=3 then
writei2c(0x40, 0x14, 0x7F, 0x14, 0x7F, 0x14) ' #
elseif temp=4 then
writei2c(0x40, 0x24, 0x2A, 0x7F, 0x2A, 0x12) ' $
elseif temp=5 then
writei2c(0x40, 0x23, 0x13, 0x08, 0x64, 0x62) ' %
elseif temp=6 then
writei2c(0x40, 0x36, 0x49, 0x56, 0x20, 0x50) ' &
elseif temp=7 then
writei2c(0x40, 0x00, 0x08, 0x07, 0x03, 0x00) ' '
endif
return
endif
temp = temp - 8
temp = temp * 5
b55 = temp + 4
for b54 = temp to b55
readtable b54, aByte
hi2cout (0x40,abyte)
next b54
return
DisplayNum:
;Words are always 5 chars long, but may be zero led.
b52= 1
for b53 = 0 to 4
temp = 4-b53
aByte = DispNum DIG temp + "0"
if aByte="0" and b52=1 then
goto DisplayNumCont ;Don't show leading spaces
elseif abyte<>"0" and b52=1 then
b52=0
endif
GOSUB DisplayChar
DisplayNumCont:
next b53
return
;----- demo code -----
;
;let row = 3
;let col = 10
;gosub setposition
;
;
;eeprom 31, ("0123456789 TEST")
;eeprom 46, ("HELLO WORLD")
;for index = 31 TO 45
; read index,aByte
; gosub displayChar;
;next index
;
;let row = 5
;let col = 2
;gosub setposition
;
;for index = 46 to 56
; read index,aByte
; gosub displayChar;
;next index
;
;let DispNum = 32016 ' Display any word sized number.
;let row = 6
;let col = 8
;gosub setposition
;gosub displayNum
;
;
;
;let row = 1 ' Display in top yellow section.
;let col = 1
;gosub setposition
;
;eeprom 57, ("HIGH TEMP - ")
;for index = 57 to 68
; read index,aByte
; gosub displayChar;
;next index
;
;
;DispNum = 180
;
;gosub displayNum
;
;let abyte = "C"
;gosub displayChar