Skip to content

Commit ca1e157

Browse files
committed
ugfx: board: update CUBE0414 driver
1 parent 6cf7683 commit ca1e157

File tree

6 files changed

+71
-36
lines changed

6 files changed

+71
-36
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _CUBE0414_H
22
#define _CUBE0414_H
33

4-
#define CUBE0414_RAMWR 0xDA
4+
#define CUBE0414_ADDR_WR 0xCC
5+
#define CUBE0414_DATA_WR 0xDA
56

67
#endif

components/ugfx/drivers/gdisp/CUBE0414/gdisp_lld_CUBE0414.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@
4646

4747
#include "CUBE0414.h"
4848

49+
static uint8_t init_ram_addr[64] = {
50+
#ifdef CONFIG_CUBE0414_LINE_S_CURVE
51+
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0f,
52+
0x10, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
53+
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x1f,
54+
0x20, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
55+
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2f,
56+
0x30, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
57+
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3f,
58+
0x00, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
59+
#else
60+
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
61+
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
62+
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
63+
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
64+
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
65+
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
66+
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
67+
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00,
68+
#endif
69+
};
70+
4971
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
5072
g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH * 3);
5173
if (g->priv == NULL) {
@@ -59,8 +81,12 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
5981
// Initialise the board interface
6082
init_board(g);
6183

84+
// Write RAM Addr
85+
write_cmd(g, CUBE0414_ADDR_WR);
86+
write_buff(g, init_ram_addr, sizeof(init_ram_addr));
87+
6288
// Refresh GRAM
63-
write_cmd(g, CUBE0414_RAMWR);
89+
write_cmd(g, CUBE0414_DATA_WR);
6490
write_buff(g, (uint8_t *)g->priv, GDISP_SCREEN_HEIGHT*GDISP_SCREEN_WIDTH*3);
6591

6692
/* Initialise the GDISP structure */
@@ -96,8 +122,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
96122
}
97123
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
98124
LLDCOLOR_TYPE c = gdispColor2Native(g->p.color);
99-
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 3 + 0) = c >> 16;
100-
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 3 + 1) = c >> 8;
125+
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 3 + 0) = c >> 8;
126+
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 3 + 1) = c >> 16;
101127
*((uint8_t *)g->priv + (stream_write_x + stream_write_y * g->g.Width) * 3 + 2) = c;
102128
stream_write_x++;
103129
if (--stream_write_cx <= 0) {
@@ -131,8 +157,8 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
131157
stream_read_cy = g->p.cy;
132158
}
133159
LLDSPEC color_t gdisp_lld_read_color(GDisplay *g) {
134-
LLDCOLOR_TYPE c = (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 3 + 0) << 16)
135-
| (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 3 + 1) << 8)
160+
LLDCOLOR_TYPE c = (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 3 + 0) << 8)
161+
| (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 3 + 1) << 16)
136162
| (*((uint8_t *)g->priv + (stream_read_x + stream_read_y * g->g.Width) * 3 + 2));
137163
stream_read_x++;
138164
if (--stream_read_cx <= 0) {

main/Kconfig.projbuild

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,31 @@ choice AUDIO_INPUT_FFT_CHANNEL
210210
bool "Both Channel"
211211
endchoice
212212

213-
config LIGHT_CUBE_DC_PIN
214-
int "Light Cube DC Pin"
215-
default 23
213+
choice CUBE0414_LINE_TYPE
214+
prompt "CUBE0414 Line Type"
215+
default CUBE0414_LINE_S_CURVE
216216
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
217+
help
218+
Select CUBE0414 line type.
219+
220+
config CUBE0414_LINE_NORMAL
221+
bool "Normal"
222+
config CUBE0414_LINE_S_CURVE
223+
bool "S Curve"
224+
endchoice
217225

218-
config SCREEN_PANEL_RST_PIN
219-
int "Screen Panel RST Pin"
226+
config DEVICE_RST_PIN
227+
int "Device RST Pin"
220228
default 14
221229
depends on ENABLE_VFX && !VFX_OUTPUT_CUBE0414
222230

223-
config SCREEN_PANEL_DC_PIN
224-
int "Screen Panel DC Pin"
231+
config DEVICE_DC_PIN
232+
int "Device DC Pin"
225233
default 23
226-
depends on ENABLE_VFX && !VFX_OUTPUT_CUBE0414
234+
depends on ENABLE_VFX
227235

228-
config SCREEN_PANEL_BL_PIN
229-
int "Screen Panel BL Pin"
236+
config DEVICE_BL_PIN
237+
int "Device BL Pin"
230238
default 4
231239
depends on ENABLE_VFX && !VFX_OUTPUT_CUBE0414
232240

main/src/board/cube0414.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ void cube0414_init_board(void)
2525
{
2626
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2727

28-
gpio_set_direction(CONFIG_LIGHT_CUBE_DC_PIN, GPIO_MODE_OUTPUT);
29-
gpio_set_level(CONFIG_LIGHT_CUBE_DC_PIN, 0);
28+
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
29+
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
3030

31-
ESP_LOGI(TAG, "initialized, dc: %d", CONFIG_LIGHT_CUBE_DC_PIN);
31+
ESP_LOGI(TAG, "initialized, dc: %d", CONFIG_DEVICE_DC_PIN);
3232
}
3333

3434
void cube0414_setpin_dc(spi_transaction_t *t)
3535
{
3636
int dc = (int)t->user;
37-
gpio_set_level(CONFIG_LIGHT_CUBE_DC_PIN, dc);
37+
gpio_set_level(CONFIG_DEVICE_DC_PIN, dc);
3838
}
3939

4040
void cube0414_write_cmd(uint8_t cmd)

main/src/board/st7735.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ void st7735_init_board(void)
2626
{
2727
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2828

29-
gpio_set_direction(CONFIG_SCREEN_PANEL_DC_PIN, GPIO_MODE_OUTPUT);
30-
gpio_set_direction(CONFIG_SCREEN_PANEL_RST_PIN, GPIO_MODE_OUTPUT);
31-
gpio_set_level(CONFIG_SCREEN_PANEL_DC_PIN, 0);
32-
gpio_set_level(CONFIG_SCREEN_PANEL_RST_PIN, 0);
29+
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
30+
gpio_set_direction(CONFIG_DEVICE_RST_PIN, GPIO_MODE_OUTPUT);
31+
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
32+
gpio_set_level(CONFIG_DEVICE_RST_PIN, 0);
3333

3434
ledc_timer_config_t ledc_timer = {
3535
.duty_resolution = LEDC_TIMER_8_BIT,
@@ -43,7 +43,7 @@ void st7735_init_board(void)
4343
ledc_channel_config_t ledc_channel = {
4444
.channel = LEDC_CHANNEL_0,
4545
.duty = 0,
46-
.gpio_num = CONFIG_SCREEN_PANEL_BL_PIN,
46+
.gpio_num = CONFIG_DEVICE_BL_PIN,
4747
.speed_mode = LEDC_HIGH_SPEED_MODE,
4848
.hpoint = 0,
4949
.timer_sel = LEDC_TIMER_0,
@@ -52,7 +52,7 @@ void st7735_init_board(void)
5252

5353
ledc_fade_func_install(0);
5454

55-
ESP_LOGI(TAG, "initialized, bl: %d, dc: %d, rst: %d", CONFIG_SCREEN_PANEL_BL_PIN, CONFIG_SCREEN_PANEL_DC_PIN, CONFIG_SCREEN_PANEL_RST_PIN);
55+
ESP_LOGI(TAG, "initialized, bl: %d, dc: %d, rst: %d", CONFIG_DEVICE_BL_PIN, CONFIG_DEVICE_DC_PIN, CONFIG_DEVICE_RST_PIN);
5656
}
5757

5858
void st7735_set_backlight(uint8_t val)
@@ -64,12 +64,12 @@ void st7735_set_backlight(uint8_t val)
6464
void st7735_setpin_dc(spi_transaction_t *t)
6565
{
6666
int dc = (int)t->user;
67-
gpio_set_level(CONFIG_SCREEN_PANEL_DC_PIN, dc);
67+
gpio_set_level(CONFIG_DEVICE_DC_PIN, dc);
6868
}
6969

7070
void st7735_setpin_reset(uint8_t val)
7171
{
72-
gpio_set_level(CONFIG_SCREEN_PANEL_RST_PIN, val);
72+
gpio_set_level(CONFIG_DEVICE_RST_PIN, val);
7373
}
7474

7575
void st7735_write_cmd(uint8_t cmd)

main/src/board/st7789.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ void st7789_init_board(void)
2626
{
2727
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2828

29-
gpio_set_direction(CONFIG_SCREEN_PANEL_DC_PIN, GPIO_MODE_OUTPUT);
30-
gpio_set_direction(CONFIG_SCREEN_PANEL_RST_PIN, GPIO_MODE_OUTPUT);
31-
gpio_set_level(CONFIG_SCREEN_PANEL_DC_PIN, 0);
32-
gpio_set_level(CONFIG_SCREEN_PANEL_RST_PIN, 0);
29+
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
30+
gpio_set_direction(CONFIG_DEVICE_RST_PIN, GPIO_MODE_OUTPUT);
31+
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
32+
gpio_set_level(CONFIG_DEVICE_RST_PIN, 0);
3333

3434
ledc_timer_config_t ledc_timer = {
3535
.duty_resolution = LEDC_TIMER_8_BIT,
@@ -43,7 +43,7 @@ void st7789_init_board(void)
4343
ledc_channel_config_t ledc_channel = {
4444
.channel = LEDC_CHANNEL_0,
4545
.duty = 0,
46-
.gpio_num = CONFIG_SCREEN_PANEL_BL_PIN,
46+
.gpio_num = CONFIG_DEVICE_BL_PIN,
4747
.speed_mode = LEDC_HIGH_SPEED_MODE,
4848
.hpoint = 0,
4949
.timer_sel = LEDC_TIMER_0,
@@ -52,7 +52,7 @@ void st7789_init_board(void)
5252

5353
ledc_fade_func_install(0);
5454

55-
ESP_LOGI(TAG, "initialized, bl: %d, dc: %d, rst: %d", CONFIG_SCREEN_PANEL_BL_PIN, CONFIG_SCREEN_PANEL_DC_PIN, CONFIG_SCREEN_PANEL_RST_PIN);
55+
ESP_LOGI(TAG, "initialized, bl: %d, dc: %d, rst: %d", CONFIG_DEVICE_BL_PIN, CONFIG_DEVICE_DC_PIN, CONFIG_DEVICE_RST_PIN);
5656
}
5757

5858
void st7789_set_backlight(uint8_t val)
@@ -64,12 +64,12 @@ void st7789_set_backlight(uint8_t val)
6464
void st7789_setpin_dc(spi_transaction_t *t)
6565
{
6666
int dc = (int)t->user;
67-
gpio_set_level(CONFIG_SCREEN_PANEL_DC_PIN, dc);
67+
gpio_set_level(CONFIG_DEVICE_DC_PIN, dc);
6868
}
6969

7070
void st7789_setpin_reset(uint8_t val)
7171
{
72-
gpio_set_level(CONFIG_SCREEN_PANEL_RST_PIN, val);
72+
gpio_set_level(CONFIG_DEVICE_RST_PIN, val);
7373
}
7474

7575
void st7789_write_cmd(uint8_t cmd)

0 commit comments

Comments
 (0)