Tactility/Libraries/esp_epaper/src/epaper_common.c
Ken Van Hoeylandt 65ee223876
CL-32 drivers & more (#652)
- CL-32 features added:
  - Hardware revision detection
  - v0.3 and v0.4 keyboard 
  - v0.4 power supply
  - Inlined epd library (was a module) and made changes to the device definition (don't do full update after 5 small updates)
- Statusbar: add support for inverted colors
- e-paper driver improvements and warning fixes
- Implemented gpio_controller_get_level()
- Keyboard support improvements (unicode for tca drivers)
2026-09-14 00:06:55 +02:00

29 lines
881 B
C

#include "epaper_common.h"
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
static const char *TAG = "epd_common";
void epd_wait_busy_polarity(epd_spi_t *spi, uint32_t caps, uint32_t timeout_ms)
{
bool inverted = (caps & EPD_CAP_BUSY_INV);
uint32_t start = xTaskGetTickCount();
// For inverted: wait while LOW (busy), ready when HIGH
// For normal: wait while HIGH (busy), ready when LOW
int busy_level = inverted ? 0 : 1;
while (gpio_get_level(spi->pin_busy) == busy_level) {
if (timeout_ms > 0) {
uint32_t elapsed = (xTaskGetTickCount() - start) * portTICK_PERIOD_MS;
if (elapsed >= timeout_ms) {
ESP_LOGW(TAG, "Wait busy timeout (%lu ms)", timeout_ms);
return;
}
}
vTaskDelay(pdMS_TO_TICKS(5));
}
}