85 esp_timer_create_args_t timerSecond = { |
85 esp_timer_create_args_t timerSecond = { |
86 .callback = &TimerCallback, |
86 .callback = &TimerCallback, |
87 .name = "SecondsTimer" |
87 .name = "SecondsTimer" |
88 }; |
88 }; |
89 |
89 |
90 ESP_LOGI(TAG, "Initialize TFT"); |
90 ESP_LOGD(TAG, "Initialize TFT"); |
91 |
91 |
92 max_rdclock = 8000000; |
92 max_rdclock = 8000000; |
93 TFT_PinsInit(); |
93 TFT_PinsInit(); |
94 |
94 |
95 spi_lobo_bus_config_t buscfg = { |
95 spi_lobo_bus_config_t buscfg = { |
124 ret = spi_lobo_device_select(spi, 1); |
124 ret = spi_lobo_device_select(spi, 1); |
125 assert(ret == ESP_OK); |
125 assert(ret == ESP_OK); |
126 ret = spi_lobo_device_deselect(spi); |
126 ret = spi_lobo_device_deselect(spi); |
127 assert(ret == ESP_OK); |
127 assert(ret == ESP_OK); |
128 |
128 |
129 ESP_LOGI(TAG, "SPI: attached display, spi bus: %d, speed: %u, bus uses native pins: %s", |
129 ESP_LOGD(TAG, "SPI: attached display, spi bus: %d, speed: %u, bus uses native pins: %s", |
130 SPI_BUS, spi_lobo_get_speed(spi), spi_lobo_uses_native_pins(spi) ? "true" : "false"); |
130 SPI_BUS, spi_lobo_get_speed(spi), spi_lobo_uses_native_pins(spi) ? "true" : "false"); |
131 |
131 |
132 ESP_LOGI(TAG, "TS pins : miso=%d, mosi=%d, sck=%d, cs=%d", PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, PIN_NUM_TCS); |
132 ESP_LOGI(TAG, "TS pins : miso=%d, mosi=%d, sck=%d, cs=%d", PIN_NUM_MISO, PIN_NUM_MOSI, PIN_NUM_CLK, PIN_NUM_TCS); |
133 |
133 |
134 ret=spi_lobo_bus_add_device(SPI_BUS, &buscfg, &tsdevcfg, &tsspi); |
134 ret=spi_lobo_bus_add_device(SPI_BUS, &buscfg, &tsdevcfg, &tsspi); |
139 ret = spi_lobo_device_select(tsspi, 1); |
139 ret = spi_lobo_device_select(tsspi, 1); |
140 assert(ret == ESP_OK); |
140 assert(ret == ESP_OK); |
141 ret = spi_lobo_device_deselect(tsspi); |
141 ret = spi_lobo_device_deselect(tsspi); |
142 assert(ret == ESP_OK); |
142 assert(ret == ESP_OK); |
143 |
143 |
144 ESP_LOGI(TAG, "SPI: attached TS device, spi bus: %d, speed: %u", SPI_BUS, spi_lobo_get_speed(tsspi)); |
144 ESP_LOGD(TAG, "SPI: attached TS device, spi bus: %d, speed: %u", SPI_BUS, spi_lobo_get_speed(tsspi)); |
145 |
145 |
146 // ==== Initialize the Display ==== |
146 // ==== Initialize the Display ==== |
147 TFT_display_init(); |
147 TFT_display_init(); |
148 |
148 |
149 // ---- Detect maximum read speed ---- |
149 // ---- Detect maximum read speed ---- |
150 max_rdclock = find_rd_speed(); |
150 max_rdclock = find_rd_speed(); |
151 |
151 |
152 // ==== Set SPI clock used for display operations ==== |
152 // ==== Set SPI clock used for display operations ==== |
153 spi_lobo_set_speed(spi, DEFAULT_SPI_CLOCK); |
153 spi_lobo_set_speed(spi, DEFAULT_SPI_CLOCK); |
154 ESP_LOGI(TAG, "SPI: Max rd speed: %u, changed speed to %u", max_rdclock, spi_lobo_get_speed(spi)); |
154 ESP_LOGD(TAG, "SPI: Max rd speed: %u, changed speed to %u", max_rdclock, spi_lobo_get_speed(spi)); |
155 |
155 |
156 font_rotate = 0; |
156 font_rotate = 0; |
157 text_wrap = 0; |
157 text_wrap = 0; |
158 font_transparent = 0; |
158 font_transparent = 0; |
159 font_forceFixed = 0; |
159 font_forceFixed = 0; |
490 |
490 |
491 void task_tft(void *pvParameter) |
491 void task_tft(void *pvParameter) |
492 { |
492 { |
493 char msg[96]; |
493 char msg[96]; |
494 |
494 |
495 ESP_LOGI(TAG, "Starting TFT/Touch"); |
495 ESP_LOGI(TAG, "Start TFT/Touch"); |
496 |
496 |
497 /* |
497 /* |
498 * Task loop. Read touchscreen events. |
498 * Task loop. Read touchscreen events. |
499 */ |
499 */ |
500 while (1) { |
500 while (1) { |
501 /* |
501 /* |
502 * Build new screen. |
502 * Build new screen. |
503 */ |
503 */ |
504 startover: |
|
505 |
|
506 updateRuntime = false; |
504 updateRuntime = false; |
507 if (_NewMinute) { |
505 if (_NewMinute) { |
508 _NewMinute = false; |
506 _NewMinute = false; |
509 NewMinute = true; |
507 NewMinute = true; |
510 } |
508 } |
|
509 startover: |
511 |
510 |
512 /* |
511 /* |
513 * Timekeeping. |
512 * Timekeeping. |
514 * In the WiFi task sntp is started and sets System_TimeOk if the |
513 * In the WiFi task sntp is started and sets System_TimeOk if the |
515 * clock is synced once. |
514 * clock is synced once. |