Skip to content

Commit

Permalink
ugfx: drivers: add CUBE0414 rev 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
redchenjs committed Nov 14, 2020
1 parent 5aed492 commit a5ad76c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
11 changes: 8 additions & 3 deletions components/ugfx/drivers/gdisp/CUBE0414/CUBE0414.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef _CUBE0414_H
#define _CUBE0414_H

#define CUBE0414_CONF_WR 0x2A
#define CUBE0414_ADDR_WR 0x2B
#define CUBE0414_DATA_WR 0x2C
#ifdef CONFIG_CUBE0414_REV_3
#define CUBE0414_CONF_WR 0x2A
#define CUBE0414_ADDR_WR 0x2B
#define CUBE0414_DATA_WR 0x2C
#else
#define CUBE0414_ADDR_WR 0xCC
#define CUBE0414_DATA_WR 0xDA
#endif

#endif
6 changes: 4 additions & 2 deletions components/ugfx/drivers/gdisp/CUBE0414/gdisp_lld_CUBE0414.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static const uint8_t ram_addr_table[64] = {
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2f,
0x30, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3f,
0x00, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
0x00, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e
#else
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
Expand All @@ -64,7 +64,7 @@ static const uint8_t ram_addr_table[64] = {
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00,
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00
#endif
};

Expand All @@ -79,6 +79,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
// initialise the board interface
init_board(g);

#ifdef CONFIG_CUBE0414_REV_3
// hardware reset
setpin_reset(g, 0);
gfxSleepMilliseconds(120);
Expand All @@ -90,6 +91,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
write_data(g, CONFIG_CUBE0414_LED_T0L); // T0L Time: val * 10 ns
write_data(g, CONFIG_CUBE0414_LED_T1H); // T1H Time: val * 10 ns
write_data(g, CONFIG_CUBE0414_LED_T1L); // T1L Time: val * 10 ns
#endif
write_cmd(g, CUBE0414_ADDR_WR); // 2: set write ram addr, 64 args, no delay:
write_buff(g, (uint8_t *)ram_addr_table, sizeof(ram_addr_table));
write_cmd(g, CUBE0414_DATA_WR); // 3: set write ram data, N args, no delay:
Expand Down
27 changes: 20 additions & 7 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ config LED_COLOR_GRB
bool "GRB"
endchoice

choice CUBE0414_REVISION
prompt "CUBE0414 Revision"
default CUBE0414_REV_3
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
help
Select CUBE0414 revision.

config CUBE0414_REV_2
bool "Rev 2"
config CUBE0414_REV_3
bool "Rev 3"
endchoice

choice CUBE0414_LINE_TYPE
prompt "CUBE0414 Line Type"
default CUBE0414_LINE_S_CURVE
Expand All @@ -256,34 +269,34 @@ config CUBE0414_LINE_S_CURVE
endchoice

comment "Limit: T0H + T0L <= 257"
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config CUBE0414_LED_T0H
int "CUBE0414 LED T0H Time (10 ns)"
default 35
range 1 255
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config CUBE0414_LED_T0L
int "CUBE0414 LED T0L Time (10 ns)"
default 136
range 1 255
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

comment "Limit: T1H + T1L <= 257"
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config CUBE0414_LED_T1H
int "CUBE0414 LED T1H Time (10 ns)"
default 136
range 1 255
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config CUBE0414_LED_T1L
int "CUBE0414 LED T1L Time (10 ns)"
default 35
range 1 255
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config WS2812_DIN_PIN
int "WS2812 DIN Pin"
Expand All @@ -293,7 +306,7 @@ config WS2812_DIN_PIN
config DEV_RST_PIN
int "DEV RST Pin"
default 14
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414 && CUBE0414_REV_3

config DEV_DC_PIN
int "DEV DC Pin"
Expand Down
10 changes: 10 additions & 0 deletions main/src/board/cube0414.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,36 @@ void cube0414_init_board(void)
memset(hspi_trans, 0x00, sizeof(hspi_trans));

gpio_config_t io_conf = {
#ifdef CONFIG_CUBE0414_REV_3
.pin_bit_mask = BIT64(CONFIG_DEV_DC_PIN) | BIT64(CONFIG_DEV_RST_PIN),
#else
.pin_bit_mask = BIT64(CONFIG_DEV_DC_PIN),
#endif
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = false,
.pull_down_en = false,
.intr_type = GPIO_INTR_DISABLE
};
gpio_config(&io_conf);

#ifdef CONFIG_CUBE0414_REV_3
ESP_LOGI(TAG, "initialized, dc: %d, rst: %d", CONFIG_DEV_DC_PIN, CONFIG_DEV_RST_PIN);
#else
ESP_LOGI(TAG, "initialized, dc: %d", CONFIG_DEV_DC_PIN);
#endif
}

void cube0414_setpin_dc(spi_transaction_t *t)
{
gpio_set_level(CONFIG_DEV_DC_PIN, (int)t->user);
}

#ifdef CONFIG_CUBE0414_REV_3
void cube0414_setpin_reset(uint8_t val)
{
gpio_set_level(CONFIG_DEV_RST_PIN, val);
}
#endif

void cube0414_write_cmd(uint8_t cmd)
{
Expand Down

0 comments on commit a5ad76c

Please sign in to comment.