View previous topic :: View next topic |
Author |
Message |
O-Family
Joined: 23 May 2010 Posts: 338 Location: Japan

|
Posted: Tue Jun 18, 2024 2:14 pm Post subject: 3.12" 256x64 OLED with SSD1322 Controller SPI Mode |
|
|
Library and test code for 3.12" 256x64 OLED using SSD1322 controller SPI mode.
16 grayscales are available, allowing for character-by-character brightness adjustment and black-and-white pictures.
There are four types of OLED display colors: white, yellow, green, and blue.
SPI can be selected from 3-wire and 4-wire. The drawing speed will be slightly slower with 3-wire.
The connector position relative to the display screen can be selected on either the left or right.
In SPI mode, the G-RAM in the controller is write-only, so graphic commands such as LINE commands cannot be used.
In parallel mode, reading and writing are possible, so we plan to create a library that can use graphic commands.
Module size
https://drive.google.com/file/d/1a6RrUDQEoZceiI_GM7utmMFMd49oglFg/view?usp=drive_link
Test Circuit Diagram
https://drive.google.com/file/d/1B8tez6ug7UETKyszuatrrB79hResgz7_/view?usp=drive_link
Code: |
' ***************************************
' * 3.12inch 256x64 OLED test *
' * [SSD1322] 3-wire or 4-wire SPI *
' * O-Family 2024. 6.17 *
' ***************************************
'
$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 10
$framesize = 24
'
' * OLED Initial Settings *
'
Const Rotate_180 = 0 'OLED screen installation direction (180degree rotation).
' (Connector: 0 = Right side, 1 = Left side)
Const Spi_wire_selection = 4 'Select the number of lines for SPI connection.
' (3 = 3-wire: drawing spd low, 4 = 4-wire: drawing spd high)
'
$lib "glcdSSD1322-SPI.lib" 'Embedded SSD1322 3.12inch 256x64 SPI library.
' Specifies the connection port for OLED. Cs1 = [/CS] , Rst = [/RES] , A0 = [D/C] , Si = [SDIN] , Sclk = [SCLK]
Config Graphlcd = Color , Cs1 = Portc.0 , Rst = Portc.1 , A0 = Portc.2 , Si = Portc.3 , Sclk = Portc.4 '[Cs1]&[Rst] optional.
' Character drawing commands : [Lcdat Y , X , Character , FG , BG]
' Y = Y(row) address (0 - 63) , X = X(column) address (0 - 255) , Character = String or variable to display
' FG = Foreground Grayscale Value (0 - 15) , BG = Background Grayscale Value (0 - 15) / (0:dark - 15:bright)
' Note: Since the SSD1322 writes 4-bit grayscale data in word units, set the X address in 4-dot intervals. (ex. 0,4,8 - 248,252)
' Command to draw BGC image data in RLE compressed format : [Showpic X , Y , label]
' X = X(column) address (0 - 255), Y = Y (row)address (0 - 63), label = label of image data to display.
' See the help for SHOWPIC command.
' To create RLE compressed BGC image data from BMP images, use the LCD RGB-8 converter [LCDconvert.exe].
' Below is a table that maps 8-bit BGC format RGB8 code (RRRG_GGBB) to a 4-bit grayscale brightness value (0 - 15).
Const _bgc_r2 = &B0000_1000 'BGC RGB8 code [Red2]
Const _bgc_r1 = &B0000_0000 'BGC RGB8 code [Red1]
Const _bgc_r0 = &B0000_0000 'BGC RGB8 code [Red0]
Const _bgc_g2 = &B0000_0100 'BGC RGB8 code [Green2]
Const _bgc_g1 = &B0000_0000 'BGC RGB8 code [Green1]
Const _bgc_g0 = &B0000_0000 'BGC RGB8 code [Green0]
Const _bgc_b1 = &B0000_0010 'BGC RGB8 code [Blue1]
Const _bgc_b0 = &B0000_0000 'BGC RGB8 code [Blue0]
' By default, the intermediate luminance value for each of the colors R,G,B is the lower 4bits(0-15) of the grayscale luminance value.
' Adjust the grayscale to match the color scheme of the original image.
'
' *****************
' * Drawing Tests *
' *****************
'
Do
Setfont Color8x8
Lcdat 0 , 0 , "SSD1322 SPI 3.12in OLED 256x64" , 15 , 0
'
Setfont Color16x16
Lcdat 10 , 4 , "ABC" , 13 , 4
Lcdat 10 , 56 , "0123" , 4 , 10
'
Setfont Color_offont8x8
Lcdat 30 , 0 , "ORIGINAL Font 8x8" , 15 , 4
'
Setfont Color_offont16x16
Lcdat 44 , 0 , "16x16" , 0 , 15
'
Setfont Color_offont40x32
Lcdat 18 , 140 , "40" , 4 , 12
'
Showpic 212 , 10 , Plaatje 'Draw BGC files.
Wait 3
Glcdcmd &HC1 : Glcddata 64 'Contrast setting. (0-255)
Wait 3
Glcdcmd &HAE 'Sleep mode ON. (Display OFF)
Wait 2
Glcdcmd &HAF 'Sleep mode OFF. (Display ON)
Wait 3
Glcdcmd &HC1 : Glcddata 128 'Contrast setting. (0-255)
Glcdcmd &HA7 'Inverted display.
Wait 3
Glcdcmd &HA6 'Normal display.
Wait 3
Cls 'Clear all screens.
Glcdcmd &HC1 : Glcddata 255 'Contrast setting. (0-255)
Wait 2
Loop
End
'--------------------------------------------------------------------------------------------------
'
' * Font data *
'
$include "color8x8.font"
$include "Color16x16.font"
$include "Color_OFfont8x8.font"
$include "Color_OFfont16x16.font"
$include "Color_OFfont40x32.font"
'
' * Image data *
'
Plaatje:
$bgf "FL001-2.BGC" 'Incorporate BGC files. (Carnation) |
Last edited by O-Family on Wed Jun 26, 2024 2:37 am; edited 1 time in total |
|
Back to top |
|
 |
albertsm
Joined: 09 Apr 2004 Posts: 6198 Location: Holland

|
Posted: Tue Jun 18, 2024 2:51 pm Post subject: |
|
|
Hello O-Family,
Thanks for sharing. You are the man!
Wonderful work on this LCD.
As usual your contribution is complete : source, lib,description and circuit connection info.
 _________________ Mark |
|
Back to top |
|
 |
O-Family
Joined: 23 May 2010 Posts: 338 Location: Japan

|
Posted: Wed Jun 26, 2024 2:46 am Post subject: |
|
|
Next is a library and test code using the 8-bit parallel mode of the SSD1322 controller.
Graphics instructions such as LINE, BOX, and CIRCLE can also be used.
Although the number of wires increases, the advantage is the variation of screen configurations and the increase in drawing speed!
Test Circuit Diagram
https://drive.google.com/file/d/1B8tez6ug7UETKyszuatrrB79hResgz7_/view?usp=drive_link
Code: |
' ***************************************
' * 3.12inch 256x64 OLED test *
' * [SSD1322] 8-bit Parallel *
' * O-Family 2024. 6.25 *
' ***************************************
'
$regfile = "m328pdef.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 10
$framesize = 24
'
' * OLED Initial Settings *
'
Const Rotate_180 = 0 'OLED screen installation direction (180degree rotation).
'
$lib "glcdSSD1322-Para.lib" 'Embedded SSD1322 3.12inch 256x64 8-bit Parallel library.
' Specifies the connection port for OLED. Cs1 = [/CS] , Rst = [/RES] , A0 = [D/C] , Wr = [/WR] , Rd = [/RD] , Dataport = [D0-D7]
Config Graphlcd = Color , Cs1 = Portc.0 , Rst = Portc.1 , A0 = Portc.2 , Wr = Portc.3 , Rd = Portc.4 , Dataport = Portd '[Cs1]&[Rst] optional.
' Character drawing commands : [Lcdat Y , X , Character , FG , BG]
' Y = Y(row) address (0 - 63) , X = X(column) address (0 - 255) , Character = String or variable to display
' FG = Foreground Grayscale Value (0 - 15) , BG = Background Grayscale Value (0 - 15) / (0:dark - 15:bright)
' Note: Since the SSD1322 writes 4-bit grayscale data in word units, set the X address in 4-dot intervals. (ex. 0,4,8 - 248,252)
' Graphics drawing instructions(LINE, BOX, etc.) can be specified at any address on the screen.
' Command to draw BGC image data in RLE compressed format : [Showpic X , Y , label]
' X = X(column) address (0 - 255), Y = Y (row)address (0 - 63), label = label of image data to display.
' See the help for SHOWPIC command.
' To create RLE compressed BGC image data from BMP images, use the LCD RGB-8 converter [LCDconvert.exe].
' Below is a table that maps 8-bit BGC format RGB8 code (RRRG_GGBB) to a 4-bit grayscale brightness value (0 - 15).
Const _bgc_r2 = &B0000_1000 'BGC RGB8 code [Red2]
Const _bgc_r1 = &B0000_0000 'BGC RGB8 code [Red1]
Const _bgc_r0 = &B0000_0000 'BGC RGB8 code [Red0]
Const _bgc_g2 = &B0000_0100 'BGC RGB8 code [Green2]
Const _bgc_g1 = &B0000_0000 'BGC RGB8 code [Green1]
Const _bgc_g0 = &B0000_0000 'BGC RGB8 code [Green0]
Const _bgc_b1 = &B0000_0010 'BGC RGB8 code [Blue1]
Const _bgc_b0 = &B0000_0000 'BGC RGB8 code [Blue0]
' By default, the intermediate luminance value for each of the colors R,G,B is the lower 4bits(0-15) of the grayscale luminance value.
' Adjust the grayscale to match the color scheme of the original image.
'
' *****************
' * Drawing Tests *
' *****************
'
Dim Temp1 As Byte , Temp2 As Byte
Do
Setfont Color8x8
Lcdat 6 , 8 , "SSD1322 Para 3.12{034} OLED 256x64" , 8 , 4
'
Line(0 , 0) -(255 , 0) , 8 'Drawing the outer frame.
Line(0 , 63) -(255 , 63) , 8
Line(0 , 2) -(0 , 61) , 2
Line(255 , 2) -(255 , 61) , 2
Box(2 , 2) -(253 , 61) , 5
'
Temp2 = 15 'Test of LINE instruction.
For Temp1 = 0 To 44 Step 3
Line(8 , 58) -(56 , 58 -temp1) , Temp2
Temp2 = Temp2 - 1
Next Temp1
'
Circle(90 , 38) , 19 , 15 'Test of CIRCLE instruction.
Circle(90 , 38) , 10 , 3
Line(67 , 38) -(113 , 38) , 10
Pset 90 , 23 , 15
Pset 90 , 38 , 0
'
Boxfill(128 , 18) -(168 , 58) , 3 'Test of BOX instructions.
Boxfill(142 , 32) -(154 , 44) , 6
Box(134 , 24) -(162 , 52) , 15
'
Showpic 184 , 17 , Plaatje 'Draw BGC files.
Wait 3
Glcdcmd &HC1 : Glcddata 64 'Contrast setting. (0-255)
Wait 3
Glcdcmd &HAE 'Sleep mode ON. (Display OFF)
Wait 2
Glcdcmd &HAF 'Sleep mode OFF. (Display ON)
Wait 3
Glcdcmd &HC1 : Glcddata 128 'Contrast setting. (0-255)
Glcdcmd &HA7 'Inverted display.
Wait 3
Glcdcmd &HA6 'Normal display.
Wait 3
Cls 'Clear all screens.
Glcdcmd &HC1 : Glcddata 255 'Contrast setting. (0-255)
Wait 2
Loop
End
'--------------------------------------------------------------------------------------------------
'
' * Font data *
'
$include "color8x8.font"
'
' * Image data *
'
Plaatje:
$bgf "mcse3.BGC" 'Incorporate BGC files. (MCS) |
|
|
Back to top |
|
 |
albertsm
Joined: 09 Apr 2004 Posts: 6198 Location: Holland

|
Posted: Sat Jun 29, 2024 3:31 pm Post subject: |
|
|
thanks O-Family for this great extension. These are also great learning projects for others that like to create a driver. _________________ Mark |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|