Skip to content

Commit

Permalink
Merge pull request #2492 from saviourxx/master
Browse files Browse the repository at this point in the history
Thanks for the PR, however some extra work will be required...
Add JLX12864 support
  • Loading branch information
olikraus authored Aug 30, 2024
2 parents ce0e1aa + 7b53e5c commit 8c9aebf
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 0 deletions.
24 changes: 24 additions & 0 deletions csrc/u8g2_d_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -3973,6 +3973,14 @@ void u8g2_Setup_hx1230_96x68_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg
}
/* uc1604 */
/* uc1604 1 */
void u8g2_Setup_uc1604_jlx12864_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_uc1604_jlx12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_16_8_1(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
void u8g2_Setup_uc1604_jlx19264_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
Expand All @@ -3982,6 +3990,14 @@ void u8g2_Setup_uc1604_jlx19264_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
/* uc1604 2 */
void u8g2_Setup_uc1604_jlx12864_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_uc1604_jlx12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_16_8_2(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
void u8g2_Setup_uc1604_jlx19264_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
Expand All @@ -3991,6 +4007,14 @@ void u8g2_Setup_uc1604_jlx19264_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
/* uc1604 f */
void u8g2_Setup_uc1604_jlx12864_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
uint8_t *buf;
u8g2_SetupDisplay(u8g2, u8x8_d_uc1604_jlx12864, u8x8_cad_001, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_16_8_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
void u8g2_Setup_uc1604_jlx19264_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
{
uint8_t tile_buf_height;
Expand Down
1 change: 1 addition & 0 deletions csrc/u8x8.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ uint8_t u8x8_d_ssd1329_128x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
uint8_t u8x8_d_ssd1329_96x96_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1601_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1601_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1604_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1604_jlx19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1608_erc24064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1608_dem240064(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
Expand Down
93 changes: 93 additions & 0 deletions csrc/u8x8_d_uc1604.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,99 @@ uint8_t u8x8_d_uc1604_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
return 1;
}

/*================================================*/
/* JLX12864 */

/*
timings from uc1604
UC1604 has two chip select inputs (CS0 and CS1).
CS0 is low active, CS1 is high active. It will depend on the display
module whether the display has a is low or high active chip select.
*/
static const u8x8_display_info_t u8x8_uc1604_128x64_display_info =
{
/* chip_enable_level = */ 0, /* JLX12864G uses CS0, which is low active CS*/
/* chip_disable_level = */ 1,

/* post_chip_enable_wait_ns = */ 20,
/* pre_chip_disable_wait_ns = */ 20,
/* reset_pulse_width_ms = */ 1,
/* post_reset_wait_ms = */ 10,
/* sda_setup_time_ns = */ 30,
/* sck_pulse_width_ns = */ 65, /* half of cycle time */
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30,
/* write_pulse_width_ns = */ 35,
/* tile_width = */ 16, /* width of 24*8=192 pixel */
/* tile_height = */ 8,
/* default_x_offset = */ 0, /* reused as y page offset */
/* flipmode_x_offset = */ 0, /* reused as y page offset */
/* pixel_width = */ 128,
/* pixel_height = */ 64
};

static const uint8_t u8x8_d_uc1604_jlx12864_init_seq[] = {

U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */

U8X8_C(0x0e2), /* soft reset */
U8X8_DLY(200),
U8X8_DLY(200),

U8X8_C(0x02f), /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
U8X8_DLY(200),
U8X8_DLY(200),

U8X8_CA(0x081, 0x038), /* set contrast, JLX19264G suggestion: 0x045 */
U8X8_C(0x0eb), /* LCD bias Bits 0/1: 00=6 01=7, 10=8, 11=9 */


//U8X8_C(0x023), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
//U8X8_C(0x027), /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */

U8X8_C(0x0c2), /* Map control, Bit 2: MY=1, Bit 1: MX=0 */
U8X8_C(0x0a0), /* 0xa0: 76Hz FPS, controller default: 0x0a1: 95Hz FPS */


U8X8_C(0x040), /* set scroll line to 0 */
U8X8_C(0x089), /* RAM access control (controller default: 0x089)*/


U8X8_C(0x000), /* column low nibble */
U8X8_C(0x010), /* column high nibble */
U8X8_C(0x0b0), /* page adr */


U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};

uint8_t u8x8_d_uc1604_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
/* call common procedure first and handle messages there */
if ( u8x8_d_uc1604_common(u8x8, msg, arg_int, arg_ptr) == 0 )
{
/* msg not handled, then try here */
switch(msg)
{
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1604_128x64_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_jlx12864_init_seq);
break;
default:
return 0; /* msg unknown */
}
}
return 1;
}

/*================================================*/
/* JLX19264 */

Expand Down
39 changes: 39 additions & 0 deletions sys/rt-thread/examples/uc1604_12864_4wire_hw_spi_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <u8g2_port.h>

// You may reference Drivers/drv_gpio.c for pinout
// In u8x8.h #define U8X8_USE_PINS

#define LCD_SPI_PIN_RES 33 // PB12
#define LCD_SPI_PIN_DC 27 // PB14
#define LCD_SPI_PIN_CS 32 // PB11

static void u8g2_uc1604_12864_4wire_hw_spi_example(int argc,char *argv[])
{
u8g2_t u8g2;

// Initialization
u8g2_Setup_uc1604_jlx12864_f( &u8g2, U8G2_R0, u8x8_byte_rtthread_4wire_hw_spi, u8x8_gpio_and_delay_rtthread);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, LCD_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, LCD_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, LCD_SPI_PIN_RES);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SetFont(&u8g2, u8g2_font_5x7_tf); // choose a suitable font
u8g2_DrawStr(&u8g2, 1, 36, "github.com/olikraus/u8g2"); // write something to the internal memory
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(u8g2_uc1604_12864_4wire_hw_spi_example, hardware 4 wire spi uc1604 sample);
43 changes: 43 additions & 0 deletions sys/rt-thread/examples/uc1604_12864_4wire_sw_spi_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <u8g2_port.h>

// You may reference Drivers/drv_gpio.c for pinout
// In u8x8.h #define U8X8_USE_PINS

#define LCD_SPI_PIN_CLK 26 // PB12
#define LCD_SPI_PIN_MOSI 28 // PB15
#define LCD_SPI_PIN_RES 33 // PB12
#define LCD_SPI_PIN_DC 27 // PB14
#define LCD_SPI_PIN_CS 32 // PB11

static void u8g2_uc1604_12864_4wire_sw_spi_example(int argc,char *argv[])
{
u8g2_t u8g2;

// Initialization
u8g2_Setup_uc1604_jlx12864_f( &u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_rtthread);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_CLOCK, LCD_SPI_PIN_CLK);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_SPI_DATA, LCD_SPI_PIN_MOSI);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_CS, LCD_SPI_PIN_CS);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_DC, LCD_SPI_PIN_DC);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, LCD_SPI_PIN_RES);

u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

// Draw Graphics
/* full buffer example, setup procedure ends in _f */
u8g2_ClearBuffer(&u8g2);
u8g2_SetFont(&u8g2, u8g2_font_ncenB08_tr);
u8g2_DrawStr(&u8g2, 1, 18, "U8g2 on RT-Thread");
u8g2_SetFont(&u8g2, u8g2_font_5x7_tf); // choose a suitable font
u8g2_DrawStr(&u8g2, 1, 36, "github.com/olikraus/u8g2"); // write something to the internal memory
u8g2_SendBuffer(&u8g2);

u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
u8g2_DrawGlyph(&u8g2, 112, 56, 0x2603 );
u8g2_SendBuffer(&u8g2);
}
MSH_CMD_EXPORT(u8g2_uc1604_12864_4wire_sw_spi_example, sw 4wire spi uc1604 sample);

0 comments on commit 8c9aebf

Please sign in to comment.