Skip to content

Commit

Permalink
Working on the driver
Browse files Browse the repository at this point in the history
  • Loading branch information
hnzlmnn committed Jun 5, 2024
1 parent 190ac8a commit 1514265
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
1 change: 0 additions & 1 deletion components/spi-st77xx/include/st77xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ typedef struct ST77XX {
// Configuration
uint8_t rotation;
bool color_mode;
bool reset_external_pullup;
uint32_t spi_speed;
uint32_t spi_max_transfer_size;
ST77XX_cb_t callback;
Expand Down
21 changes: 8 additions & 13 deletions components/spi-st77xx/st77xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ const uint8_t st77xx_init_data[] = {
ST77XX_RASET, 4, 0x00, 0x00, 0x01, 0x3F,
// Display on
ST77XX_DISPON, 0,
0x00
};

esp_err_t ST7789VI_send(ST77XX* device, const uint8_t *data, const int len,const bool dc_level) {
Expand Down Expand Up @@ -164,17 +163,18 @@ esp_err_t st77xx_reset(ST77XX* device) {
return ESP_OK;
}

esp_err_t st77xx_write_init_data(ST77XX* device, const uint8_t * data) {
esp_err_t st77xx_write_init_data(ST77XX* device, const uint8_t * data, size_t size) {
if (device->spi_device == NULL) return ESP_FAIL;
esp_err_t res;
uint8_t cmd, len;
while(true) {
for (int i = 0; i < size; i++) {
cmd = *data++;
if (!cmd) return ESP_OK; //END
len = *data++;
ESP_LOGD(TAG, "Sending command %x", cmd);
res = st77xx_send_command(device, cmd);
if (res != ESP_OK) break;
if (len > 0) {
ESP_LOGD(TAG, "Sending %d bytes of data", len);
res = st77xx_send_data(device, data, len);
if (res != ESP_OK) break;
}
Expand All @@ -189,6 +189,7 @@ esp_err_t st77xx_init(ST77XX* device) {

if (device->pin_dcx < 0) return ESP_FAIL;
if (device->pin_cs < 0) return ESP_FAIL;
if (device->pin_reset < 0) return ESP_FAIL;

/*if (device->mutex == NULL) {
device->mutex = xSemaphoreCreateMutex();
Expand All @@ -199,13 +200,8 @@ esp_err_t st77xx_init(ST77XX* device) {
res = gpio_set_direction(device->pin_dcx, GPIO_MODE_OUTPUT);
if (res != ESP_OK) return res;

if (!device->reset_external_pullup && device->pin_reset >= 0) {
res = gpio_hold_dis(device->pin_reset);
if (res != ESP_OK) return res;

res = gpio_set_direction(device->pin_reset, GPIO_MODE_OUTPUT);
if (res != ESP_OK) return res;
}
res = gpio_set_direction(device->pin_reset, GPIO_MODE_OUTPUT);
if (res != ESP_OK) return res;

res = gpio_set_level(device->pin_dcx, true);
if (res != ESP_OK) return res;
Expand Down Expand Up @@ -236,7 +232,6 @@ esp_err_t st77xx_init(ST77XX* device) {
device->callback(false);
}


ESP_LOGE(TAG, "IO Setup complete ");

//Reset the LCD display
Expand All @@ -246,7 +241,7 @@ esp_err_t st77xx_init(ST77XX* device) {
ESP_LOGE(TAG, "DC pin %d", device->pin_dcx);

//Send the initialization data to the LCD display
res = st77xx_write_init_data(device, st77xx_init_data);
res = st77xx_write_init_data(device, st77xx_init_data, sizeof(st77xx_init_data) / sizeof(st77xx_init_data[0]));
if (res != ESP_OK) return res;


Expand Down
2 changes: 1 addition & 1 deletion main/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void _audio_init(int i2s_num) {

i2s_driver_install(i2s_num, &i2s_config, 0, NULL);

i2s_pin_config_t pin_config = {.bck_io_num = GPIO_I2S_BCLK, .ws_io_num = GPIO_I2S_WS, .data_out_num = GPIO_I2S_DATA, .data_in_num = I2S_PIN_NO_CHANGE};
i2s_pin_config_t pin_config = {.mck_io_num = -1, .bck_io_num = GPIO_I2S_BCLK, .ws_io_num = GPIO_I2S_WS, .data_out_num = GPIO_I2S_DATA, .data_in_num = I2S_PIN_NO_CHANGE};

i2s_set_pin(i2s_num, &pin_config);
}
Expand Down
6 changes: 5 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void ntp_sync_task(void* pvParameters) {

static void audio_player_task(void* pvParameters) {
vTaskDelay(pdMS_TO_TICKS(500));
play_bootsound();
// play_bootsound();
uint8_t leds[AMOUNT_OF_LEDS * 3] = {0};
for (uint8_t led = 0; led < AMOUNT_OF_LEDS; led++) {
for (uint8_t part = 0; part <= 50; part++) {
Expand Down Expand Up @@ -187,6 +187,7 @@ _Noreturn void app_main(void) {
pca9555_set_gpio_value(io_expander, IO_AMP_GAIN1, 1);

/* Turning the backlight on */
#ifdef TR23
gpio_config_t io_conf = {
.intr_type = GPIO_INTR_DISABLE,
.mode = GPIO_MODE_OUTPUT,
Expand All @@ -207,6 +208,9 @@ _Noreturn void app_main(void) {
display_fatal_error(fatal_error_str, "Failed to turn on LCD backlight", "Flash may be corrupted", reset_board_str);
stop();
}
#else
st77xx_backlight(true);
#endif

/* Initialize LCD screen */
pax_buf_t* pax_buffer = get_pax_buffer();
Expand Down
2 changes: 1 addition & 1 deletion main/nametag.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ static void place_in_sleep(xQueueHandle button_queue) {
fflush(stdout);
fflush(stderr);
vTaskDelay(pdMS_TO_TICKS(100));
gpio_hold_en(GPIO_LCD_BL);
#ifdef TR23
gpio_hold_en(GPIO_LCD_BL);
ili9341_power_en(get_ili9341());
#endif
gpio_deep_sleep_hold_en();
Expand Down
9 changes: 4 additions & 5 deletions sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -834,14 +834,13 @@ CONFIG_HEAP_TRACING_OFF=y
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set
# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set
CONFIG_LOG_MAXIMUM_LEVEL=3
CONFIG_LOG_MAXIMUM_LEVEL=4
CONFIG_LOG_COLORS=y
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
Expand Down

0 comments on commit 1514265

Please sign in to comment.