Skip to content

Commit 3efbebc

Browse files
committed
ugfx/CUBE0414: update driver
1 parent 50d68a8 commit 3efbebc

File tree

6 files changed

+65
-9
lines changed

6 files changed

+65
-9
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#ifndef _CUBE0414_H
22
#define _CUBE0414_H
33

4-
#define CUBE0414_ADDR_WR 0xCC
5-
#define CUBE0414_DATA_WR 0xDA
4+
#define CUBE0414_CONF_WR 0x2A
5+
#define CUBE0414_ADDR_WR 0x2B
6+
#define CUBE0414_DATA_WR 0x2C
67

78
#endif

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,22 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
7979
// Initialise the board interface
8080
init_board(g);
8181

82-
write_cmd(g, CUBE0414_ADDR_WR); // 1: Set write ram addr, 64 args, no delay:
82+
// Hardware reset
83+
setpin_reset(g, 0);
84+
gfxSleepMilliseconds(120);
85+
setpin_reset(g, 1);
86+
gfxSleepMilliseconds(120);
87+
88+
write_cmd(g, CUBE0414_CONF_WR); // 1: Set write reg conf, 6 args, no delay:
89+
write_data(g, CONFIG_CUBE0414_LED_T1H / 10); // T1H Time (ns)
90+
write_data(g, CONFIG_CUBE0414_LED_T1L / 10); // T1L Time (ns)
91+
write_data(g, CONFIG_CUBE0414_LED_T0H / 10); // T0H Time (ns)
92+
write_data(g, CONFIG_CUBE0414_LED_T0L / 10); // T0L Time (ns)
93+
write_data(g, CONFIG_CUBE0414_LED_RST * 100 >> 8); // RST Time H (us)
94+
write_data(g, CONFIG_CUBE0414_LED_RST * 100 & 0xff); // RST Time L (us)
95+
write_cmd(g, CUBE0414_ADDR_WR); // 2: Set write ram addr, 64 args, no delay:
8396
write_buff(g, (uint8_t *)ram_addr_table, sizeof(ram_addr_table));
84-
write_cmd(g, CUBE0414_DATA_WR); // 2: Set write ram data, N args, no delay:
97+
write_cmd(g, CUBE0414_DATA_WR); // 3: Set write ram data, N args, no delay:
8598
write_buff(g, (uint8_t *)g->priv, GDISP_SCREEN_WIDTH*GDISP_SCREEN_HEIGHT*3);
8699

87100
/* Initialise the GDISP structure */

components/ugfx/drivers/gdisp/CUBE0414/gdisp_lld_board.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "board/cube0414.h"
1212

1313
#define init_board(g) cube0414_init_board()
14+
#define setpin_reset(g, val) cube0414_setpin_reset(val)
1415
#define write_cmd(g, cmd) cube0414_write_cmd(cmd)
1516
#define write_data(g, data) cube0414_write_data(data)
1617
#define write_buff(g, buff, n) cube0414_write_buff(buff, n)

main/Kconfig.projbuild

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,40 @@ config CUBE0414_COLOR_GRB
244244
bool "GRB"
245245
endchoice
246246

247+
config CUBE0414_LED_T1H
248+
int "CUBE0414 LED T1H Time (ns)"
249+
default 1360
250+
range 10 2500
251+
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
252+
253+
config CUBE0414_LED_T1L
254+
int "CUBE0414 LED T1L Time (ns)"
255+
default 350
256+
range 10 2500
257+
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
258+
259+
config CUBE0414_LED_T0H
260+
int "CUBE0414 LED T0H Time (ns)"
261+
default 350
262+
range 10 2500
263+
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
264+
265+
config CUBE0414_LED_T0L
266+
int "CUBE0414 LED T0L Time (ns)"
267+
default 1360
268+
range 10 2500
269+
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
270+
271+
config CUBE0414_LED_RST
272+
int "CUBE0414 LED RST Time (us)"
273+
default 280
274+
range 10 650
275+
depends on ENABLE_VFX && VFX_OUTPUT_CUBE0414
276+
247277
config DEVICE_RST_PIN
248278
int "Device RST Pin"
249279
default 14
250-
depends on ENABLE_VFX && !VFX_OUTPUT_CUBE0414
280+
depends on ENABLE_VFX
251281

252282
config DEVICE_DC_PIN
253283
int "Device DC Pin"

main/inc/board/cube0414.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
extern void cube0414_init_board(void);
2020

2121
extern void cube0414_setpin_dc(spi_transaction_t *);
22+
extern void cube0414_setpin_reset(uint8_t val);
2223

2324
extern void cube0414_write_cmd(uint8_t cmd);
2425
extern void cube0414_write_data(uint8_t data);

main/src/board/cube0414.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "driver/gpio.h"
1313
#include "driver/spi_master.h"
1414

15+
#include "drivers/gdisp/CUBE0414/CUBE0414.h"
16+
1517
#include "chip/spi.h"
1618
#include "board/cube0414.h"
1719

@@ -25,10 +27,13 @@ void cube0414_init_board(void)
2527
{
2628
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2729

28-
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
29-
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
30+
gpio_config_t io_conf = {
31+
.mode = GPIO_MODE_OUTPUT,
32+
.pin_bit_mask = BIT64(CONFIG_DEVICE_DC_PIN) | BIT64(CONFIG_DEVICE_RST_PIN),
33+
};
34+
gpio_config(&io_conf);
3035

31-
ESP_LOGI(TAG, "initialized, dc: %d", CONFIG_DEVICE_DC_PIN);
36+
ESP_LOGI(TAG, "initialized, dc: %d, rst: %d", CONFIG_DEVICE_DC_PIN, CONFIG_DEVICE_RST_PIN);
3237
}
3338

3439
void cube0414_setpin_dc(spi_transaction_t *t)
@@ -38,6 +43,11 @@ void cube0414_setpin_dc(spi_transaction_t *t)
3843
gpio_set_level(CONFIG_DEVICE_DC_PIN, dc);
3944
}
4045

46+
void cube0414_setpin_reset(uint8_t val)
47+
{
48+
gpio_set_level(CONFIG_DEVICE_RST_PIN, val);
49+
}
50+
4151
void cube0414_write_cmd(uint8_t cmd)
4252
{
4353
hspi_trans[0].length = 8;
@@ -68,7 +78,7 @@ void cube0414_write_buff(uint8_t *buff, uint32_t n)
6878
void cube0414_refresh_gram(uint8_t *gram)
6979
{
7080
hspi_trans[0].length = 8,
71-
hspi_trans[0].tx_data[0] = 0xDA; // Write Frame Data
81+
hspi_trans[0].tx_data[0] = CUBE0414_DATA_WR;
7282
hspi_trans[0].user = (void*)0;
7383
hspi_trans[0].flags = SPI_TRANS_USE_TXDATA;
7484

0 commit comments

Comments
 (0)