Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [E³] SB6432 LCD key driver #1180

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions cppsrc/U8g2lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class U8G2 : public Print
void setContrast(uint8_t value) {
u8g2_SetContrast(&u8g2, value); }

void setBacklightColor(uint32_t value) {
u8g2_SetBacklightColor(&u8g2, value); }

void setDisplayRotation(const u8g2_cb_t *u8g2_cb) {
u8g2_SetDisplayRotation(&u8g2, u8g2_cb); }

Expand Down Expand Up @@ -17168,6 +17171,60 @@ class U8G2_MAX7219_8X8_F_2ND_4W_HW_SPI : public U8G2 {
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_1_4W_SW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_1_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_1(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_1_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_1_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_1(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_1_2ND_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_1_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_1(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_2_4W_SW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_2_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_2(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_2_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_2_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_2(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_2_2ND_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_2_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_2(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_F_4W_SW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_F_4W_SW_SPI(const u8g2_cb_t *rotation, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_f(&u8g2, rotation, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_F_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_F_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_f(&u8g2, rotation, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8G2_E3KEYS_SB6432_F_2ND_4W_HW_SPI : public U8G2 {
public: U8G2_E3KEYS_SB6432_F_2ND_4W_HW_SPI(const u8g2_cb_t *rotation, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8G2() {
u8g2_Setup_e3keys_sb6432_f(&u8g2, rotation, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};

/* Arduino constructor list end */

Expand Down
21 changes: 21 additions & 0 deletions cppsrc/U8x8lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ class U8X8 : public Print
void setContrast(uint8_t value) {
u8x8_SetContrast(&u8x8, value); }

void setBacklightColor(uint32_t value) {
u8x8_SetBacklightColor(&u8x8, value); }

void setInverseFont(uint8_t value) {
u8x8_SetInverseFont(&u8x8, value); }

Expand Down Expand Up @@ -5967,6 +5970,24 @@ class U8X8_MAX7219_8X8_2ND_4W_HW_SPI : public U8X8 {
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8X8_E3KEYS_SB6432_4W_SW_SPI : public U8X8 {
public: U8X8_E3KEYS_SB6432_4W_SW_SPI(uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_e3keys_sb6432, u8x8_cad_empty, u8x8_byte_arduino_4wire_sw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_SW_SPI(getU8x8(), clock, data, cs, dc, reset);
}
};
class U8X8_E3KEYS_SB6432_4W_HW_SPI : public U8X8 {
public: U8X8_E3KEYS_SB6432_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_e3keys_sb6432, u8x8_cad_empty, u8x8_byte_arduino_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};
class U8X8_E3KEYS_SB6432_2ND_4W_HW_SPI : public U8X8 {
public: U8X8_E3KEYS_SB6432_2ND_4W_HW_SPI(uint8_t cs, uint8_t dc, uint8_t reset = U8X8_PIN_NONE) : U8X8() {
u8x8_Setup(getU8x8(), u8x8_d_e3keys_sb6432, u8x8_cad_empty, u8x8_byte_arduino_2nd_hw_spi, u8x8_gpio_and_delay_arduino);
u8x8_SetPin_4Wire_HW_SPI(getU8x8(), cs, dc, reset);
}
};

// constructor list end

Expand Down
4 changes: 4 additions & 0 deletions csrc/u8g2.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ struct u8g2_struct
#define u8g2_SetPowerSave(u8g2, is_enable) u8x8_SetPowerSave(u8g2_GetU8x8(u8g2), (is_enable))
#define u8g2_SetFlipMode(u8g2, mode) u8x8_SetFlipMode(u8g2_GetU8x8(u8g2), (mode))
#define u8g2_SetContrast(u8g2, value) u8x8_SetContrast(u8g2_GetU8x8(u8g2), (value))
#define u8g2_SetBacklightColor(u8g2, value) u8x8_SetBacklightColor(u8g2_GetU8x8(u8g2), (value))
//#define u8g2_ClearDisplay(u8g2) u8x8_ClearDisplay(u8g2_GetU8x8(u8g2)) obsolete, can not be used in all cases
void u8g2_ClearDisplay(u8g2_t *u8g2);

Expand Down Expand Up @@ -1183,6 +1184,9 @@ void u8g2_Setup_max7219_8x8_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_
void u8g2_Setup_a2printer_384x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_a2printer_384x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_e3keys_sb6432_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_e3keys_sb6432_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
void u8g2_Setup_e3keys_sb6432_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);

/* u8g2_d_setup.c generated code end */

Expand Down
28 changes: 28 additions & 0 deletions csrc/u8g2_d_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -5515,4 +5515,32 @@ void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x
buf = u8g2_m_48_30_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation);
}
/* e3keys */
/* e3keys 1 */
void u8g2_Setup_e3keys_sb6432_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_e3keys_sb6432, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_8_4_1(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
/* e3keys 2 */
void u8g2_Setup_e3keys_sb6432_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_e3keys_sb6432, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_8_4_2(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
/* e3keys f */
void u8g2_Setup_e3keys_sb6432_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_e3keys_sb6432, u8x8_cad_empty, byte_cb, gpio_and_delay_cb);
buf = u8g2_m_8_4_f(&tile_buf_height);
u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation);
}
/* end of generated code */
19 changes: 17 additions & 2 deletions csrc/u8x8.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
U8X8_MSG_DISPLAY_SET_FLIP_MODE
U8X8_MSG_DISPLAY_SET_POWER_SAVE
U8X8_MSG_DISPLAY_SET_CONTRAST
U8X8_MSG_DISPLAY_SET_BACKLIGHT_COLOR
U8X8_MSG_DISPLAY_DRAW_TILE

A display driver may decided to breakdown these messages to a lower level interface or
Expand Down Expand Up @@ -91,6 +92,9 @@
/* Undefine this to remove u8x8_SetContrast function */
#define U8X8_WITH_SET_CONTRAST

/* Undefine this to remove u8x8_SetBacklightColor function */
#define U8X8_WITH_SET_BACKLIGHT_COLOR

/* Define this for an additional user pointer inside the u8x8 data struct */
//#define U8X8_WITH_USER_PTR

Expand Down Expand Up @@ -471,6 +475,15 @@ void u8x8_d_helper_display_init(u8x8_t *u8g2);
/* arg_int: 0..255 contrast value */
#define U8X8_MSG_DISPLAY_SET_CONTRAST 14

/*
Name: U8X8_MSG_DISPLAY_SET_BACKLIGHT_COLOR
Args: arg_ptr: color: 24-bit RGB
Tasks:
Set the color of the backlight. The dsplay driver might transform the given
24-bit RGB color into the more limited color space of the backlight.
*/
#define U8X8_MSG_DISPLAY_SET_BACKLIGHT_COLOR 15

/*
Name: U8X8_MSG_DISPLAY_DRAW_TILE
Args:
Expand Down Expand Up @@ -498,7 +511,7 @@ void u8x8_d_helper_display_init(u8x8_t *u8g2);
ABABAB. Totally, cnt*arg_int tiles will be drawn.

*/
#define U8X8_MSG_DISPLAY_DRAW_TILE 15
#define U8X8_MSG_DISPLAY_DRAW_TILE 16


/*
Expand All @@ -515,7 +528,7 @@ void u8x8_d_helper_display_init(u8x8_t *u8g2);
void u8x8_RefreshDisplay(u8x8_t *u8x8)
to send the message to the display handler.
*/
#define U8X8_MSG_DISPLAY_REFRESH 16
#define U8X8_MSG_DISPLAY_REFRESH 17

/*==========================================*/
/* u8x8_setup.c */
Expand Down Expand Up @@ -555,6 +568,7 @@ void u8x8_InitDisplay(u8x8_t *u8x8);
void u8x8_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable);
void u8x8_SetFlipMode(u8x8_t *u8x8, uint8_t mode);
void u8x8_SetContrast(u8x8_t *u8x8, uint8_t value);
void u8x8_SetBacklightColor(u8x8_t *u8x8, uint32_t color);
void u8x8_ClearDisplayWithTile(u8x8_t *u8x8, const uint8_t *buf) U8X8_NOINLINE;
void u8x8_ClearDisplay(u8x8_t *u8x8); // this does not work for u8g2 in some cases
void u8x8_FillDisplay(u8x8_t *u8x8);
Expand Down Expand Up @@ -934,6 +948,7 @@ uint8_t u8x8_d_max7219_64x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
uint8_t u8x8_d_max7219_32x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_max7219_16x16(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_max7219_8x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_e3keys_sb6432(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);



Expand Down