abstracting display, touch and sd
This commit is contained in:
62
display/low_level_display_factory.cpp
Normal file
62
display/low_level_display_factory.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "low_level_display.h"
|
||||
#include "board_config.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// Include display implementations based on what's available
|
||||
#include "low_level_display_st7796.h"
|
||||
#include "low_level_display_st7789.h"
|
||||
#include "low_level_display_epaper.h"
|
||||
|
||||
// Factory method - creates display with board-specific configuration
|
||||
LowLevelDisplay* LowLevelDisplay::create(DisplayType type, int width, int height) {
|
||||
switch (type) {
|
||||
case DISPLAY_TYPE_ST7796: {
|
||||
// Create ST7796 configuration from board_config.h
|
||||
static const st7796_config lcd_config = {
|
||||
.spi = DISPLAY_SPI_PORT,
|
||||
.gpio_din = DISPLAY_MOSI_PIN,
|
||||
.gpio_clk = DISPLAY_SCK_PIN,
|
||||
.gpio_cs = DISPLAY_CS_PIN,
|
||||
.gpio_dc = DISPLAY_DC_PIN,
|
||||
.gpio_rst = DISPLAY_RST_PIN,
|
||||
.gpio_bl = DISPLAY_BL_PIN,
|
||||
};
|
||||
printf("Creating ST7796 display (%dx%d)\n", width, height);
|
||||
return new LowLevelDisplayST7796(&lcd_config, width, height);
|
||||
}
|
||||
|
||||
case DISPLAY_TYPE_ST7789: {
|
||||
// Create ST7789 configuration from board_config.h
|
||||
static const st7789_config st7789_cfg = {
|
||||
.spi = DISPLAY_SPI_PORT,
|
||||
.gpio_din = DISPLAY_MOSI_PIN,
|
||||
.gpio_clk = DISPLAY_SCK_PIN,
|
||||
.gpio_cs = DISPLAY_CS_PIN,
|
||||
.gpio_dc = DISPLAY_DC_PIN,
|
||||
.gpio_rst = DISPLAY_RST_PIN,
|
||||
.gpio_bl = DISPLAY_BL_PIN,
|
||||
};
|
||||
printf("Creating ST7789 display (%dx%d) - STUB (driver not implemented)\n", width, height);
|
||||
return new LowLevelDisplayST7789(&st7789_cfg, width, height);
|
||||
}
|
||||
|
||||
case DISPLAY_TYPE_EPAPER: {
|
||||
// Create E-Paper configuration from board_config.h
|
||||
static const epaper_config epaper_cfg = {
|
||||
.spi = DISPLAY_SPI_PORT,
|
||||
.gpio_din = DISPLAY_MOSI_PIN,
|
||||
.gpio_clk = DISPLAY_SCK_PIN,
|
||||
.gpio_cs = DISPLAY_CS_PIN,
|
||||
.gpio_dc = DISPLAY_DC_PIN,
|
||||
.gpio_rst = DISPLAY_RST_PIN,
|
||||
.gpio_busy = DISPLAY_BUSY_PIN,
|
||||
};
|
||||
printf("Creating E-Paper display (%dx%d) - STUB (driver not implemented)\n", width, height);
|
||||
return new LowLevelDisplayEPaper(&epaper_cfg, width, height);
|
||||
}
|
||||
|
||||
default:
|
||||
printf("Error: Unknown display type %d\n", type);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user