Start of 5.X work

This commit is contained in:
Sebastien L
2025-03-18 17:38:34 -04:00
parent c0ddf0a997
commit 73bd096f37
442 changed files with 227862 additions and 21075 deletions

View File

@@ -3,7 +3,7 @@ set(TJPGD tjpgd)
idf_component_register(SRC_DIRS . core core/ifaces
INCLUDE_DIRS . core
REQUIRES platform_config tools esp_common spiffs
REQUIRES tools platform_config esp_common spiffs
PRIV_REQUIRES services freertos driver ${TJPGD}
EMBED_FILES note.jpg )

View File

@@ -319,12 +319,12 @@ static const struct GDS_Device ILI9341_X = {
.Mode = GDS_RGB565, .Depth = 16,
};
struct GDS_Device* ILI9341_Detect(sys_Display * Driver, struct GDS_Device* Device) {
struct GDS_Device* ILI9341_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
uint8_t Model;
int Depth=16; // 16bit colordepth
if(Driver->common.driver == sys_DisplayDriverEnum_ILI9341) Model = ILI9341;
else if(Driver->common.driver == sys_DisplayDriverEnum_ILI9341_24) Model = ILI9341_24;
if(Driver->common.driver == sys_display_drivers_ILI9341) Model = ILI9341;
else if(Driver->common.driver == sys_display_drivers_ILI9341_24) Model = ILI9341_24;
else return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));

View File

@@ -152,9 +152,9 @@ static const struct GDS_Device SH1106 = {
#endif
};
struct GDS_Device* SH1106_Detect(sys_Display * Driver, struct GDS_Device* Device) {
struct GDS_Device* SH1106_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
// if (!strcasestr(Driver, "SH1106")) return NULL;
if(Driver->common.driver != sys_DisplayDriverEnum_SH1106) return NULL;
if(Driver->common.driver != sys_display_drivers_SH1106) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));
*Device = SH1106;

View File

@@ -162,8 +162,8 @@ static const struct GDS_Device SSD1306 = {
#endif
};
struct GDS_Device* SSD1306_Detect(sys_Display * Driver, struct GDS_Device* Device) {
if(Driver->common.driver != sys_DisplayDriverEnum_SSD1306) return NULL;
struct GDS_Device* SSD1306_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
if(Driver->common.driver != sys_display_drivers_SSD1306) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));
*Device = SSD1306;

View File

@@ -191,8 +191,8 @@ static const struct GDS_Device SSD1322 = {
.Mode = GDS_GRAYSCALE, .Depth = 4,
};
struct GDS_Device* SSD1322_Detect(sys_Display * Driver, struct GDS_Device* Device) {
if(Driver->common.driver != sys_DisplayDriverEnum_SSD1322) return NULL;
struct GDS_Device* SSD1322_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
if(Driver->common.driver != sys_display_drivers_SSD1322) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));

View File

@@ -319,12 +319,12 @@ static const struct GDS_Device SSD132x = {
.Mode = GDS_GRAYSCALE, .Depth = 4,
};
struct GDS_Device* SSD132x_Detect(sys_Display * Driver, struct GDS_Device* Device) {
struct GDS_Device* SSD132x_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
uint8_t Model;
int Depth;
if(Driver->common.driver == sys_DisplayDriverEnum_SSD1326) Model = SSD1326;
else if(Driver->common.driver == sys_DisplayDriverEnum_SSD1327) Model = SSD1327;
if(Driver->common.driver == sys_display_drivers_SSD1326) Model = SSD1326;
else if(Driver->common.driver == sys_display_drivers_SSD1327) Model = SSD1327;
return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));

View File

@@ -268,10 +268,10 @@ static const struct GDS_Device SSD1351 = {
.Mode = GDS_RGB565, .Depth = 16,
};
struct GDS_Device* SSD1351_Detect(sys_Display * Driver, struct GDS_Device* Device) {
struct GDS_Device* SSD1351_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
int Depth;
if(Driver->common.driver != sys_DisplayDriverEnum_SSD1351) return NULL;
if(Driver->common.driver != sys_display_drivers_SSD1351) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));

View File

@@ -224,30 +224,31 @@ static bool Init( struct GDS_Device* Device ) {
Update( Device );
return true;
}
}
static const struct GDS_Device SSD1675 = {
.DrawBitmapCBR = DrawBitmapCBR, .ClearWindow = ClearWindow,
.DrawPixelFast = _DrawPixel,
.Update = Update, .Init = Init,
.Mode = GDS_MONO, .Depth = 1,
.Alloc = GDS_ALLOC_NONE,
};
.DrawBitmapCBR = DrawBitmapCBR,
.ClearWindow = ClearWindow,
.DrawPixelFast = _DrawPixel,
.Update = Update,
.Init = Init,
.Mode = GDS_MONO,
.Depth = 1,
.Alloc = GDS_ALLOC_NONE,
};
struct GDS_Device* SSD1675_Detect(sys_Display * Driver, struct GDS_Device* Device) {
if(Driver->common.driver != sys_DisplayDriverEnum_SSD1675) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));
*Device = SSD1675;
char *p;
struct PrivateSpace* Private = (struct PrivateSpace*) Device->Private;
Private->ReadyPin = -1;
if(Driver->common.has_ready && Driver->common.ready.pin >=0){
Private->ReadyPin = Driver->common.ready.pin;
}
ESP_LOGI(TAG, "SSD1675 driver with ready GPIO %d", Private->ReadyPin);
return Device;
struct GDS_Device* SSD1675_Detect(sys_display_config* Driver, struct GDS_Device* Device) {
if (Driver->common.driver != sys_display_drivers_SSD1675) return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));
*Device = SSD1675;
struct PrivateSpace* Private = (struct PrivateSpace*)Device->Private;
Private->ReadyPin = -1;
if (Driver->common.ready >= 0) {
Private->ReadyPin = Driver->common.ready;
}
ESP_LOGI(TAG, "SSD1675 driver with ready GPIO %d", Private->ReadyPin);
return Device;
}

View File

@@ -273,11 +273,11 @@ static const struct GDS_Device ST77xx = {
.Mode = GDS_RGB565, .Depth = 16,
};
struct GDS_Device* ST77xx_Detect(sys_Display * Driver, struct GDS_Device* Device) {
struct GDS_Device* ST77xx_Detect(sys_display_config * Driver, struct GDS_Device* Device) {
uint8_t Model;
int Depth;
if(Driver->common.driver == sys_DisplayDriverEnum_ST7735) Model = ST7735;
else if(Driver->common.driver == sys_DisplayDriverEnum_ST7789) Model = ST7789;
if(Driver->common.driver == sys_display_drivers_ST7735) Model = ST7735;
else if(Driver->common.driver == sys_display_drivers_ST7789) Model = ST7789;
else return NULL;
if (!Device) Device = calloc(1, sizeof(struct GDS_Device));

View File

@@ -15,7 +15,7 @@
#include "driver/gpio.h"
#include "driver/ledc.h"
#include "esp_log.h"
#include "Configurator.h"
#include "Config.h"
#include "gds.h"
#include "gds_private.h"
@@ -30,8 +30,8 @@ static struct GDS_BacklightPWM PWMConfig;
static char TAG[] = "gds";
struct GDS_Device* GDS_AutoDetect( sys_Display * Driver, GDS_DetectFunc* DetectFunc[], struct GDS_BacklightPWM* PWM ) {
if (!Driver->has_common || Driver->common.driver == sys_DisplayDriverEnum_UNSPECIFIED_DRIVER) return NULL;
struct GDS_Device* GDS_AutoDetect( sys_display_config * Driver, GDS_DetectFunc* DetectFunc[], struct GDS_BacklightPWM* PWM ) {
if (!Driver->has_common || Driver->common.driver == sys_display_drivers_UNSPECIFIED) return NULL;
if (PWM) PWMConfig = *PWM;
for (int i = 0; DetectFunc[i]; i++) {

View File

@@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "Configurator.h"
#include "Config.h"
/* NOTE for drivers:
The build-in DrawPixel(Fast), DrawCBR and ClearWindow have optimized for 1 bit
@@ -34,9 +34,9 @@ struct GDS_Layout {
bool ColorSwap;
};
typedef struct GDS_Device* GDS_DetectFunc(sys_Display * Driver, struct GDS_Device *Device);
typedef struct GDS_Device* GDS_DetectFunc(sys_display_config * Driver, struct GDS_Device *Device);
struct GDS_Device* GDS_AutoDetect( sys_Display * Driver, GDS_DetectFunc* DetectFunc[], struct GDS_BacklightPWM *PWM );
struct GDS_Device* GDS_AutoDetect( sys_display_config * Driver, GDS_DetectFunc* DetectFunc[], struct GDS_BacklightPWM *PWM );
void GDS_SetContrast( struct GDS_Device* Device, uint8_t Contrast );
void GDS_DisplayOn( struct GDS_Device* Device );

View File

@@ -40,9 +40,10 @@ static bool LoadFont(struct GDS_FontDef ** fontPtr, const char * fileName){
ESP_LOGE(TAG, "Invalid pointer for LoadFont");
return false;
}
char font_file_name[CONFIG_SPIFFS_OBJ_NAME_LEN+1]={0};
snprintf(font_file_name,sizeof(font_file_name),"/spiffs/fonts/%s",fileName);
// Allocate DMA-capable memory for the font
struct GDS_FontDef* loadedFont = load_file_dma(NULL,"fonts",fileName);
struct GDS_FontDef* loadedFont = load_file_dma(NULL,font_file_name);
// Check if allocation succeeded
if (loadedFont == NULL) {

View File

@@ -22,7 +22,7 @@
#include "gds_text.h"
#include "gds_font.h"
#include "gds_image.h"
#include "Configurator.h"
#include "Config.h"
static const char *TAG = "display";
#define min(a,b) (((a) < (b)) ? (a) : (b))
@@ -44,7 +44,7 @@ static EXT_RAM_ATTR struct {
char header[HEADER_SIZE + 1];
char string[SCROLLABLE_SIZE + 1];
int offset, boundary;
sys_Metadata *metadata_config;
sys_metadata_config *metadata_config;
bool timer, refresh;
uint32_t elapsed;
struct {
@@ -76,10 +76,11 @@ GDS_DetectFunc *drivers[] = { SH1106_Detect, SSD1306_Detect, SSD132x_Detect, SSD
void display_init(char *welcome) {
bool init = false;
int width = -1, height = -1, backlight_pin = -1, RST_pin = -1;
sys_Display * sys_display;
sys_DispCommon * common;
sys_display_config * sys_display;
sys_display_common * common;
if(!SYS_DISPLAY(sys_display) || !SYS_DISPLAY_COMMON(common)){
if(!SYS_DISPLAY(sys_display) || !SYS_DISPLAY_COMMON(common) || common->driver == sys_display_drivers_UNSPECIFIED){
ESP_LOGI(TAG,"No display configuration");
return;
}
// // so far so good
@@ -87,11 +88,10 @@ void display_init(char *welcome) {
ESP_LOGE(TAG,"Misconfigured display missing data");
return;
}
ESP_LOGI(TAG, "Trying to configure display type %s, driver: %s",
sys_DeviceTypeEnum_name(sys_display->type),
sys_DisplayDriverEnum_name(common->driver));
if (common->has_back && common->back.pin >= 0) {
ESP_LOGI(TAG, "Initializing display type %s, driver: %s",
sys_dev_common_types_name(sys_display->type),
sys_display_drivers_name(common->driver));
if (common->back >= 0) {
struct GDS_BacklightPWM PWMConfig = { .Channel = pwm_system.base_channel++, .Timer = pwm_system.timer, .Max = pwm_system.max, .Init = false };
display = GDS_AutoDetect(sys_display, drivers, &PWMConfig);
} else {
@@ -99,38 +99,27 @@ void display_init(char *welcome) {
}
if (display) {
if(common->has_reset){
RST_pin = common->reset.pin;
}
if(common->has_back){
backlight_pin = common->back.pin;
}
RST_pin = common->reset;
backlight_pin = common->back;
width = common->width;
height = common->height;
// Detect driver interface
if (sys_display->which_dispType == sys_Display_i2c_tag && i2c_system_port != -1){
if (sys_display->which_dispType == sys_display_config_i2c_tag && platform->dev.i2c.port != sys_i2c_port_UNSPECIFIED){
int address = 0x3C;
address = sys_display->dispType.i2c.address;
init = true;
GDS_I2CInit( i2c_system_port, -1, -1, i2c_system_speed ) ;
GDS_I2CInit( platform->dev.i2c.port-sys_i2c_port_PORT0, -1, -1, platform->dev.i2c.speed ) ;
GDS_I2CAttachDevice( display, width, height, address, RST_pin, backlight_pin );
ESP_LOGI(TAG, "Display is I2C on port %u", address);
} else if (sys_display->which_dispType == sys_Display_spi_tag && spi_system_host != -1) {
} else if (sys_display->which_dispType == sys_display_config_spi_tag && spi_system_host != -1) {
int CS_pin = -1, speed = 0, mode = 0;
if(sys_display->dispType.spi.has_cs){
CS_pin = sys_display->dispType.spi.cs.pin;
}
CS_pin = sys_display->dispType.spi.cs;
speed = sys_display->dispType.spi.speed;
mode = sys_display->dispType.spi.mode;
//todo: what is mode?
// PARSE_PARAM(config, "mode", '=', mode);
// todo: need to handle display offsets
init = true;
GDS_SPIInit( spi_system_host, spi_system_dc_gpio );
GDS_SPIAttachDevice( display, width, height, CS_pin, RST_pin, backlight_pin, speed, mode );
@@ -174,7 +163,7 @@ void display_init(char *welcome) {
// leave room for artwork is display is horizontal-style
if (displayer.metadata_config->has_artwork && displayer.metadata_config->artwork.enabled) {
// todo : check for resize flag
#pragma message("todo: check for resize flag and possibly offsets?")
displayer.artwork.enable = true;
displayer.artwork.fit = true;
if (height <= 64 && width > height * 2)