Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4bf05b1
ili948x: Remove duplicate UNUSED macro
bettio Apr 8, 2026
2efb410
sdl: Fix register_font for libAtomVM 0.7 API
bettio Apr 8, 2026
26781c1
font_data: Add shared font data module
bettio Apr 8, 2026
b163c36
display_items: Refactor into compiled module
bettio Apr 8, 2026
70fa8eb
display_message: Add shared message module
bettio Apr 8, 2026
c3d6cba
display_task: Add shared dispatch module
bettio Apr 8, 2026
d174bb5
ssd1306: Add stderr warning for unknown commands
bettio Apr 8, 2026
6d09617
spi_dc_driver: Add shared SPI+DC transport
bettio Apr 8, 2026
da2c14e
dcs_lcd_color: Add shared RGB565 color helpers
bettio Apr 8, 2026
42d80c7
dcs_lcd_screen: Add shared DCSLCDScreen type
bettio Apr 8, 2026
bd76e2b
dcs_lcd_commands: Add shared DCS LCD commands
bettio Apr 9, 2026
931febb
dcs_lcd_draw: Add shared DCS LCD draw pipeline
bettio Apr 9, 2026
9ed1a40
gdep073e01: Add 7.3" 7-color e-paper driver
bettio Apr 10, 2026
369876a
Add shared e-paper modules and migrate drivers
bettio Apr 10, 2026
2ddc525
mono_draw: Add shared monochrome draw module
bettio Apr 10, 2026
7ebd2d1
Fix off-by-one in draw_scaled_cropped_img_x
bettio Apr 10, 2026
c5c5de8
Fix memory leaks in e-paper do_update
bettio Apr 10, 2026
83cdcbc
epaper_color: Change gdep073e01 palette
bettio Apr 10, 2026
13d3aa7
Remove dead draw_common.h and monochrome.h
bettio Apr 10, 2026
aac13c2
Add uFontLib support for all ESP32 drivers
bettio Apr 10, 2026
052d3f0
Refactor names to follow AVMCCS conventions
bettio Apr 11, 2026
0ca1ce6
font_data: Document style exception
bettio Apr 12, 2026
3b69a6e
Refactor array lengths to use size_t
bettio Apr 12, 2026
b5f9df0
sdl: Add uFontLib custom font support
bettio Apr 12, 2026
e77553b
Fix ufont text ignoring background color
bettio Apr 12, 2026
cf556f9
Rename struct SPI to family-specific types
bettio Apr 13, 2026
d06e282
font_data: Refactor CHAR_WIDTH to shared header
bettio Apr 13, 2026
36042fd
Fix ufont text crash on allocation failure
bettio Apr 13, 2026
ba2e31d
Add DCS LCD init sequence tables
bettio Apr 13, 2026
3772e4b
DCS LCD: Use init sequence tables
bettio Apr 13, 2026
ffc6742
Add DCS LCD controller descriptors
bettio Apr 14, 2026
0d84c32
spi_display: Add clock_speed_hz opt
bettio Apr 14, 2026
5002fc8
dcs_lcd: Move reset and power-on into init seqs
bettio Apr 14, 2026
ac3f09a
DCS LCD: Embed DCSLCDScreen in driver
bettio Apr 14, 2026
40364db
Rename st7789 driver to unified DCS LCD name
bettio Apr 14, 2026
1b6e524
Refactor DCS LCD driver to use descriptor table
bettio Apr 14, 2026
a0666bc
Remove legacy DCS LCD drivers
bettio Apr 14, 2026
5fe657b
Add e-paper init sequence infrastructure
bettio Apr 14, 2026
b79866f
E-paper: Use init sequence tables
bettio Apr 14, 2026
b1519a9
Add e-paper controller descriptors
bettio Apr 14, 2026
206231a
E-paper: Embed EpaperScreen in driver
bettio Apr 14, 2026
05e3ae7
Rename gdep073e01 driver to unified e-paper name
bettio Apr 14, 2026
57ba1cf
Refactor e-paper driver to use descriptor table
bettio Apr 14, 2026
8680c21
Remove legacy 5in65 acep driver
bettio Apr 14, 2026
fea6a9e
Add OLED init sequence infrastructure
bettio Apr 15, 2026
c634572
ssd1306: Use init sequence tables
bettio Apr 15, 2026
11eb088
Add OLED controller descriptors
bettio Apr 15, 2026
84a99dd
memory_lcd: Embed MonoScreen in driver
bettio Apr 15, 2026
b5e701f
memory_lcd: Embed DMA buffers and VCOM in driver
bettio Apr 15, 2026
b4a766c
ssd1306: Embed MonoScreen in driver
bettio Apr 15, 2026
c914c01
Refactor SSD1306 driver to use descriptors
bettio Apr 15, 2026
a2bd599
Rename SSD1306 driver to unified OLED name
bettio Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
732 changes: 0 additions & 732 deletions 5in65_acep_7c_display_driver.c

This file was deleted.

23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,26 @@ else()
endif()

idf_component_register(SRCS
"dcs_lcd_commands.c"
"dcs_lcd_display_driver.c"
"dcs_lcd_draw.c"
"display_common.c"
"display_driver.c"
"5in65_acep_7c_display_driver.c"
"ili934x_display_driver.c"
"ili948x_display_driver.c"
"display_items.c"
"display_message.c"
"display_task.c"
"epaper_color.c"
"epaper_commands.c"
"epaper_draw.c"
"mono_draw.c"
"epaper_display_driver.c"
"font_data.c"
"memory_display_driver.c"
"ssd1306_display_driver.c"
"st7789_display_driver.c"
"oled_commands.c"
"oled_display_driver.c"
"spi_dc_driver.c"
"spi_display.c"
"ufontlib.c"
"backlight_gpio.c"
"image_helpers.c"
"spng.c"
Expand All @@ -44,7 +55,7 @@ idf_component_register(SRCS
${OPTIONAL_WHOLE_ARCHIVE}
)

target_compile_definitions(${COMPONENT_TARGET} PRIVATE "-DSPNG_USE_MINIZ=1")
target_compile_definitions(${COMPONENT_TARGET} PRIVATE "-DSPNG_USE_MINIZ=1" "-DENABLE_UFONT")

if (IDF_VERSION_MAJOR EQUAL 4)
idf_build_set_property(
Expand Down
65 changes: 65 additions & 0 deletions dcs_lcd_color.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of AtomGL.
*
* Copyright 2020-2026 Davide Bettio <davide@uninstall.it>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _DCS_LCD_COLOR_H_
#define _DCS_LCD_COLOR_H_

#include <stdint.h>

#include <driver/spi_master.h>

// This functions is taken from:
// https://stackoverflow.com/questions/18937701/combining-two-16-bits-rgb-colors-with-alpha-blending
static inline uint16_t alpha_blend_rgb565(uint32_t fg, uint32_t bg, uint8_t alpha)
{
alpha = (alpha + 4) >> 3;
bg = (bg | (bg << 16)) & 0b00000111111000001111100000011111;
fg = (fg | (fg << 16)) & 0b00000111111000001111100000011111;
uint32_t result = ((((fg - bg) * alpha) >> 5) + bg) & 0b00000111111000001111100000011111;
return (uint16_t) ((result >> 16) | result);
}

static inline uint8_t rgba8888_get_alpha(uint32_t color)
{
return color & 0xFF;
}

static inline uint16_t rgba8888_color_to_rgb565(uint32_t color)
{
uint8_t r = color >> 24;
uint8_t g = (color >> 16) & 0xFF;
uint8_t b = (color >> 8) & 0xFF;

return (((uint16_t) (r >> 3)) << 11) | (((uint16_t) (g >> 2)) << 5) | ((uint16_t) b >> 3);
}

static inline uint16_t rgb565_color_to_surface(uint16_t color16)
{
return (uint16_t) SPI_SWAP_DATA_TX(color16, 16);
}

static inline uint16_t uint32_color_to_surface(uint32_t color)
{
uint16_t color16 = rgba8888_color_to_rgb565(color);

return rgb565_color_to_surface(color16);
}

#endif
406 changes: 406 additions & 0 deletions dcs_lcd_commands.c

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions dcs_lcd_commands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* This file is part of AtomGL.
*
* Copyright 2020-2026 Davide Bettio <davide@uninstall.it>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _DCS_LCD_COMMANDS_H_
#define _DCS_LCD_COMMANDS_H_

#include <stdbool.h>
#include <stddef.h>

#include "dcs_lcd_screen.h"
#include "spi_dc_driver.h"

// Generic MIPI DCS command set (subset used by AtomGL DCS LCD drivers).
// Vendor-specific init sequence bytes (ILI9341_FRMCTR1, ST7789_PORCTRL,
// ILI948X_HS_LANES_CTRL, etc.) stay in each driver's header block.
#define DCS_LCD_SWRESET 0x01
#define DCS_LCD_SLPIN 0x10
#define DCS_LCD_SLPOUT 0x11
#define DCS_LCD_NORON 0x13
#define DCS_LCD_INVOFF 0x20
#define DCS_LCD_INVON 0x21
#define DCS_LCD_DISPOFF 0x28
#define DCS_LCD_DISPON 0x29
#define DCS_LCD_CASET 0x2A
#define DCS_LCD_PASET 0x2B
#define DCS_LCD_RAMWR 0x2C
#define DCS_LCD_MADCTL 0x36
#define DCS_LCD_COLMOD 0x3A

// MADCTL bit positions.
#define DCS_LCD_MAD_MY 0x80
#define DCS_LCD_MAD_MX 0x40
#define DCS_LCD_MAD_MV 0x20
#define DCS_LCD_MAD_ML 0x10
#define DCS_LCD_MAD_BGR 0x08

void dcs_lcd_set_paint_area(struct SPIDCBus *bus, const struct DCSLCDScreen *screen,
int x, int y, int width, int height);

void dcs_lcd_draw_buffer(struct SPIDCBus *bus, const struct DCSLCDScreen *screen,
int pixel_bytes, int x, int y, int width, int height, const void *imgdata);

// --- Init sequence byte-array format ---
//
// Each entry: [CMD] [FLAGS_LEN] [DATA_0 ... DATA_N] [DELAY_MS]
// CMD: command byte (0x01-0xFF)
// FLAGS_LEN: bits 6:0 = data byte count (0-127)
// bit 7 = delay flag (DELAY_MS byte follows data)
// DELAY_MS: delay in milliseconds (0-255), present only if flag set
//
// End marker: single DCS_LCD_INIT_SEQ_END (0x00) byte.

#define DCS_LCD_INIT_SEQ_END 0x00
#define DCS_LCD_INIT_SEQ_DELAY 0x80

void dcs_lcd_execute_init_seq(struct SPIDCBus *bus, const uint8_t *seq);

// Built-in init sequences.
extern const uint8_t dcs_lcd_init_seq_ili9341[];
extern const uint8_t dcs_lcd_init_seq_ili9342c[];
extern const uint8_t dcs_lcd_init_seq_ili9486[];
extern const uint8_t dcs_lcd_init_seq_ili9488[];
extern const uint8_t dcs_lcd_init_seq_st7789_std[];
extern const uint8_t dcs_lcd_init_seq_st7789_alt[];

// --- Per-controller descriptor ---
//
// Describes a DCS LCD controller variant so a unified driver can dispatch
// on compatible string. madctl[4] holds per-rotation MADCTL values (0xFF
// for rotations not validated on the current hardware). init_fn is a
// fallback when a byte-array init sequence is insufficient; NULL for all
// current controllers.

struct DCSLCDDriver; // forward declaration for init_fn

struct DCSLCDDesc
{
const char *name;
int native_width;
int native_height;
int spi_clock_hz;
uint8_t pixel_bytes;
uint8_t colmod_value;
uint8_t madctl[4];
bool default_bgr;
const uint8_t *default_init_seq;
void (*init_fn)(struct DCSLCDDriver *);
};

extern const struct DCSLCDDesc dcs_lcd_desc_ili9341;
extern const struct DCSLCDDesc dcs_lcd_desc_ili9342c;
extern const struct DCSLCDDesc dcs_lcd_desc_ili9486;
extern const struct DCSLCDDesc dcs_lcd_desc_ili9488;
extern const struct DCSLCDDesc dcs_lcd_desc_st7789;
extern const struct DCSLCDDesc dcs_lcd_desc_st7796;

#endif
Loading
Loading