; .-----------------------------------------------------------------------------.
; | AXE133Y OLED Analogue Oscilloscope |
; `-----------------------------------------------------------------------------'
#Picaxe 18M2
#No_Data
; .-----------------------------------------------------------------------------.
; | Variables |
; `-----------------------------------------------------------------------------'
Symbol reserveW0 = w0 ; b1:b0
Symbol row = b2
; .-----------------------------------------------------------------------------.
; | LCD connections |
; `-----------------------------------------------------------------------------'
Symbol pinE = pinC.6 : Symbol dirE = dirC.6 ; 0 = Idle 1 = Active
Symbol pinRS = pinC.7 : Symbol dirRS = dirC.7 ; 0 = Command 1 = Data
Symbol pinD0 = pinB.0 : Symbol dirD0 = dirB.0 ; LCD Data Line 0
Symbol pinD1 = pinB.1 : Symbol dirD1 = dirB.1 ; LCD Data Line 1
Symbol pinD2 = pinB.2 : Symbol dirD2 = dirB.2 ; LCD Data Line 2
Symbol pinD3 = pinB.3 : Symbol dirD3 = dirB.3 ; LCD Data Line 3
Symbol pinD4 = pinB.4 : Symbol dirD4 = dirB.4 ; LCD Data Line 4
Symbol pinD5 = pinB.5 : Symbol dirD5 = dirB.5 ; LCD Data Line 5
Symbol pinD6 = pinB.6 : Symbol dirD6 = dirB.6 ; LCD Data Line 6
Symbol pinD7 = pinB.7 : Symbol dirD7 = dirB.7 ; LCD Data Line 7
; .-----------------------------------------------------------------------------.
; | Main Program |
; `-----------------------------------------------------------------------------'
PowerOnReset:
Gosub InitialiseLcd
SetFreq M32
; Populate EEPROM data
For b1 = 0 To 255
b2 = b1 / 37
LookUp b2, (1,2,4,8,16,32,64), b0
Read b1,b2
If b2 <> b0 Then
Write b1, b0
End If
Next
Do
b0 = %01000001 : Gosub SendCmdByte ; GYA 1
b0 = %10000000 : Gosub SendCmdByte ; GXA 0
; Include this to give a very crude trigger
; Do
; ReadAdc C.0, b0
; Read b0, b0
; Loop While b0 = 1
For row = 0 To 79
ReadAdc C.0, b0
Read b0, b0
Gosub SendDataByte
Next
; b0 = %01000000 : Gosub SendCmdByte ; GYA 0
; b0 = %10000000 : Gosub SendCmdByte ; GXA 0
; For row = 0 To 79
; ReadAdc C.0, b0
; Read b0, b0
; Gosub SendDataByte
; Next
Loop
; .-----------------------------------------------------------------------------.
; | LCD initialisation routine |
; `-----------------------------------------------------------------------------'
InitialiseLcd:
dirE = 1 ; Set LCD control lines as outputs
dirRS = 1
dirD0 = 1
dirD1 = 1
dirD2 = 1
dirD3 = 1
dirD4 = 1
dirD5 = 1
dirD6 = 1
dirD7 = 1
Pause 500
For b1 = 0 To 7
LookUp b1, ( $33,$33,$33, $3B,$0C,$06,$1F,$01 ), b0 : Gosub SendInitCmdByte
Next
; Nibble commands - To initialise 8-bit mode
;
; $33 %0011---- 8-bit
; $33 %0011---- 8-bit
; $33 %0011---- 8-bit
;
; Byte commands - To configure the LCD or OLED
;
; LNFff
; $3B %00111011 Display Format
;
; L : 0 = 4-bit Mode 1 = 8-bit Mode
; N : 0 = 1 Line 1 = 2 Lines
; F : 0 = 5x7 Pixels 1 = N/A
;
; f : OLED Font table 00 English-Japanese
; 01 Western European 1
; 10 English-Russian
; 11 Western European 2
;
; DCB
; $0C %00001100 Display Control
;
; D : 0 = Display Off 1 = Display On
; C : 0 = Cursor Off 1 = Cursor On
; B : 0 = Cursor Steady 1 = Cursor Flash
;
; IS
; $06 %00000110 Cursor Move
;
; I : 0 = Dec Cursor 1 = Inc Cursor
; S : 0 = Cursor Move 1 = Display Shift
;
; GP
; $1F %00011111 Graphics Mode
;
; G : 0 = Text Display 1 = Graphics Mode
; P : 0 = Int Power Off 1 = Int Power On
;
; $01 %00000001 Clear Screen
;
; Additional OLED Graphics commands
;
; $80 %1xxxxxxx GXA
;
; $40 %0100000y GYA
Return
; .-----------------------------------------------------------------------------.
; | LCD interfacing routines |
; `-----------------------------------------------------------------------------'
SendInitCmdByte:
Pause 15 ; Delay 15mS
SendCmdByte:
pinRS = 0 ; Send to Command register
Gosub SendDataByte
If b0 <= 3 Then ; Pause to allow Home or Clear to complete
Pause 10
End If
Return
SendDataByte:
pinD7 = bit7 ; Put out byte
pinD6 = bit6
pinD5 = bit5
pinD4 = bit4
pinD3 = bit3
pinD2 = bit2
pinD1 = bit1
pinD0 = bit0
pinE = 1 ; Give a pulse on E
pinE = 0
pinRS = 1 ; Send to Data register next
Return
; .-----------------------------------------------------------------------------.
; | End of program |
; `-----------------------------------------------------------------------------'