mrburnette
Senior Member
Part 2
Continued in Part 3: http://www.picaxeforum.co.uk/entry.php?41-IR-set-18M2-Clock-Thermometer
Continued from Part 1: http://www.picaxeforum.co.uk/entry.php?38-IR-time-set-OLED-digital-clock-w-08M2-and-old-wall-clock-quartz-module
Pictures available: http://www.instructables.com/id/Oh-my-OLED-PICAXE-Digital-Clock-IR-set/
Porting the 08M2 code in the above link to the AXE133Y PICAXE 18M2 was a piece of cake; but I could not just do a port, I needed to do enhancements to prepare for the additions of requests from this forum thread: http://www.picaxeforum.co.uk/showthread.php?20045-OLED-real-time-clock-%28Group-Input%29
PINS C.1 and C.0 are used to support IR and Time pulses:
Key enhancements: I completely reworked the "serializer" routine, making changes to the RevEd driver routines which were included in the original AXE133Y code.
- Implemented two line buffers, one for the top 16 character line and one for the lower 16 character line. These two buffers were created from un-named variable RAM and have a flexible structure which allows flexibility in building 2-line displays. A third RAM buffer has not been implemented but will in the next release to support scrolling of either line.
- Modularized the display routines for displaying time in HH:MM:SS format
- Modularized the time-setting InfraRed routines
- Left only LCD_init and msg subroutines relatively unchanged.
In my opinion, the most significant change is the implementation of a flexible line buffer structure:
The structure, replicated in 2 separate buffers, allow for the inclusion of start/end pointers and embedded OLED control sequences, as well as an ESC short-circuit character. Here is the serializer code that spools the buffer:
With working 18M2 code embedded into the AXE133Y module, I'm ready to contemplate adding some of the forum requested options. However, because of the original design decision to use an external 1-second quartz time source, there will be no discussion regarding Low Feq, GPS, or power line clocking... at least not in this series... but I can see that a future endeavor would be fun.
- Ray
View attachment 9897
Continued in Part 3: http://www.picaxeforum.co.uk/entry.php?41-IR-set-18M2-Clock-Thermometer
Continued from Part 1: http://www.picaxeforum.co.uk/entry.php?38-IR-time-set-OLED-digital-clock-w-08M2-and-old-wall-clock-quartz-module
Pictures available: http://www.instructables.com/id/Oh-my-OLED-PICAXE-Digital-Clock-IR-set/
Porting the 08M2 code in the above link to the AXE133Y PICAXE 18M2 was a piece of cake; but I could not just do a port, I needed to do enhancements to prepare for the additions of requests from this forum thread: http://www.picaxeforum.co.uk/showthread.php?20045-OLED-real-time-clock-%28Group-Input%29
PINS C.1 and C.0 are used to support IR and Time pulses:
Code:
let dirsC = %11000000 ; PortC 6,7 outputs MODIFIED C.0, C.1, C.2 Inputs
...
IRIN C.1, InfraRed
...
Do while PINC.0 = 1 : Loop
- Implemented two line buffers, one for the top 16 character line and one for the lower 16 character line. These two buffers were created from un-named variable RAM and have a flexible structure which allows flexibility in building 2-line displays. A third RAM buffer has not been implemented but will in the next release to support scrolling of either line.
- Modularized the display routines for displaying time in HH:MM:SS format
- Modularized the time-setting InfraRed routines
- Left only LCD_init and msg subroutines relatively unchanged.
In my opinion, the most significant change is the implementation of a flexible line buffer structure:
Code:
; REMARKS ON DISPLAY RAM STRUCTURE
#rem
;RAM Buffer #1 starts at offset 28
;RAM Buffer #2 starts at offset 56
;RAM Buffer #3 starts at offset 84 (not currently used)
;
;RAM display buffer structure:
;
RAM bank #1:
2233333333334444444444555555
8901234567890123456789012345
FFCCD |XXXXXXXX RAM Not Used (Reserved)
IIOOI |
RNNNG |---> OLED off-screen 17-20= RAM 48-51
SATTI |
TLRRT |
..OO# 1 |
##LL1234567890123456 Visible 16 characters
RAM bank #2:
5555666666666677777777778888
6789012345678901234567890123
FFCCD |XXXXXXXX RAM Not Used (Reserved)
IIOOI |
RNNNG |---> OLED off-screen 17-20= RAM 76-79
SATTI |
TLRRT |
..OO# 1 |
##LL1234567890123456 Visible 16 characters
General notes:
bank #1 is for OLED line #1
bank #2 is for OLED line #2
byte 28/56 is the first character to display ... Normally= 30/58 (2 ctrl + 16)
byte 29/57 is the last character to display ... Normally= 47/75
byte 30+31 is control sequence line #1 ... 0 = null = not sent
byte 58+59 is control sequence line #2 ... 0 = null = not sent
byte 32-47 / 60-75 are character positions L1:1-16 and L2: 1-16
#endrem
Code:
DisplayRAM:
;[B] Line variable must be 0 or 1 for OLED display[/B]
;RAM bank #1/2:
;2233333333334444444444555555 ' RAM BAND 1 = Line Buffer #0
;8901234567890123456789012345
;
;5555666666666677777777778888 ' RAM BANK 2 = Line Buffer #1
;6789012345678901234567890123
If Line = 0 then
Peek 28, b3 : Peek 29, b4 ; Get Display range "begin" Line #0
Peek 30, b1 ; First Control byte if != 0
Else
Peek 56, b3 : Peek 57, b4 ; Get Display range "end" Line #1
Peek 58, b1 ; First Control byte if != 0
EndIf
If b1 < 253 then ; Nothing special if < 253
b3 = b3 + 2 ; No control codes - jump over 'em
For b2 = b3 to b4 ; FOR loops always execute once!
Peek b2, b1 ; serializer for/next loop
if b1 = 27 then ; [B]Is character ESC ?[/B]
EXIT ; jump out of loop if ESC
endif
let pinsB = b1 ; output the data on port_B
pulsout enable,1 ; pulse the enable pin to send data
Next
elseIf b1 = 254 then ; OLED Display Command
low rs ; Activate Command Mode
If Line = 0 then
Peek 31, b1 ; Get OLED command byte for first line
else
Peek 59, b1 ; Get OLED command byte for second line
EndIf
let pinsB = b1 ; Output OLED command
pulsout enable,1
high rs ; Return to Character Mode
elseIf b1 = 253 then ; User Command Mode - currently EEPROM messages
If Line = 0 then
Peek 31, b1 ; Get Message # for first line
else
Peek 59, b1 ; Get Message # for second line
EndIf
gosub msg ; Display EEPROM message
EndIf
Return
- Ray
View attachment 9897