MVP: Basic working clock and alarm

This commit is contained in:
ookami125 2025-05-27 02:40:50 +00:00
commit b6ac19a54d
18 changed files with 22909 additions and 0 deletions

120
main/epd7in5.h Normal file
View file

@ -0,0 +1,120 @@
// epd7in5_v3.h
#ifndef epd7in5_v3_H
#define epd7in5_v3_H
#include <stdint.h>
#include "driver/spi_master.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#ifdef __cplusplus
extern "C" {
#endif
#define EPD_WIDTH 800
#define EPD_HEIGHT 480
// Default pin assignments (override in your own board header or before init)
#ifndef EPD_RST_PIN
#define EPD_RST_PIN 8
#endif
#ifndef EPD_DC_PIN
#define EPD_DC_PIN 9
#endif
#ifndef EPD_CS_PIN
#define EPD_CS_PIN 10
#endif
#ifndef EPD_BUSY_PIN
#define EPD_BUSY_PIN 7
#endif
typedef enum {
CMD_PANEL_SETTING = 0x00,
CMD_POWER_SETTING = 0x01,
CMD_POWER_OFF = 0x02,
CMD_POWER_OFF_SEQUENCE_SETTING = 0x03,
CMD_POWER_ON = 0x04,
CMD_POWER_ON_MEASURE = 0x05,
CMD_BOOSTER_SOFT_START = 0x06,
CMD_DISPLAY_START_TRANSMISSION_1 = 0x10,
CMD_DISPLAY_REFRESH = 0x12,
CMD_DISPLAY_START_TRANSMISSION_2 = 0x13,
CMD_DUAL_SPI = 0x15,
CMD_VCOM_AND_DATA_INTERVAL_SETTING = 0x50,
CMD_TCON_SETTING = 0x60,
CMD_RESOLUTION_SETTING = 0x61,
CMD_PARTIAL_WINDOW = 0x90,
CMD_PARTIAL_IN = 0x91,
CMD_PARTIAL_OUT = 0x92,
CMD_CASCADE_SETTING = 0xE0,
CMD_FORCE_TEMPERATURE = 0xE5,
} epd_cmd_t;
typedef struct {
spi_device_handle_t spi;
spi_host_device_t spi_host;
int8_t pin_rst;
int8_t pin_dc;
int8_t pin_cs;
int8_t pin_busy;
uint16_t width;
uint16_t height;
} epd7in5_v3_t;
/**
* @brief Initialize the SPI bus, GPIOs and EPD hardware.
* @param epd Pointer to an epd7in5_v3_t struct (must be allocated by caller).
* @param host SPI host to use (e.g. VSPI_HOST).
* @return ESP_OK on success, or an error code.
*/
esp_err_t epd7in5_v3_create(epd7in5_v3_t *epd, spi_host_device_t host);
/**
* @brief Initialize the EPD panel with default settings.
* @param epd Pointer to an epd7in5_v3_t struct (must be allocated by caller).
* @return ESP_OK on success, or an error code.
*/
esp_err_t epd7in5_v3_init(epd7in5_v3_t *epd);
/**
* @brief Send a blocking command byte.
*/
esp_err_t epd7in5_v3_send_command(epd7in5_v3_t *epd, uint8_t cmd);
/**
* @brief Send a blocking data byte.
*/
esp_err_t epd7in5_v3_send_data(epd7in5_v3_t *epd, uint8_t data);
/**
* @brief Send a block of data.
*/
esp_err_t epd7in5_v3_send_data_block(epd7in5_v3_t *epd, const uint8_t *data, size_t len);
/**
* @brief Wait until BUSY line goes high (not busy).
*/
void epd7in5_v3_busy_wait(epd7in5_v3_t *epd);
/**
* @brief Full-screen update of a black/white image (size = width*height/8).
*/
esp_err_t epd7in5_v3_display(epd7in5_v3_t *epd, const uint8_t *image);
/**
* @brief Clear the display (white).
*/
esp_err_t epd7in5_v3_clear(epd7in5_v3_t *epd);
/**
* @brief Put the panel into deep sleep.
*/
esp_err_t epd7in5_v3_sleep(epd7in5_v3_t *epd);
#ifdef __cplusplus
}
#endif
#endif // epd7in5_v3_H