tic tac toe works on touch and eink

This commit is contained in:
Adolfo Reyna
2026-01-29 17:16:59 -05:00
parent 372895fa08
commit 435a5caa56
7 changed files with 450 additions and 145 deletions

View File

@@ -1,15 +1,19 @@
#include "low_level_display_st7789.h"
#include <stdio.h>
#include <stdlib.h>
// Note: This is a placeholder implementation
// You'll need to add the actual ST7789 driver code to lib/st7789/
LowLevelDisplayST7789::LowLevelDisplayST7789(const st7789_config* cfg, int w, int h)
: config(cfg), width(w), height(h), initialized(false) {
: config(cfg), width(w), height(h), initialized(false), rgb_buffer(nullptr) {
}
LowLevelDisplayST7789::~LowLevelDisplayST7789() {
// Cleanup if needed
if (rgb_buffer) {
free(rgb_buffer);
rgb_buffer = nullptr;
}
}
bool LowLevelDisplayST7789::init() {
@@ -19,6 +23,15 @@ bool LowLevelDisplayST7789::init() {
// TODO: Implement ST7789 initialization
// st7789_init(config, width, height);
//
// TODO: Allocate RGB565 buffer once (reused for all draw operations)
// size_t buffer_size = width * height * sizeof(uint16_t);
// rgb_buffer = (uint16_t *)malloc(buffer_size);
// if (!rgb_buffer) {
// printf("Error: Failed to allocate %zu bytes for RGB buffer\n", buffer_size);
// return false;
// }
printf("ST7789 display initialized: %dx%d (stub)\n", width, height);
initialized = true;
return false; // Return false until actual driver is implemented
@@ -36,6 +49,18 @@ void LowLevelDisplayST7789::draw_pixel(int x, int y, bool white) {
void LowLevelDisplayST7789::draw_buffer(const uint8_t* bit_buffer) {
// TODO: Implement - convert 1-bit to RGB565 and write
// IMPORTANT: Use the persistent rgb_buffer member, NOT malloc/free!
// Example:
// if (!bit_buffer || !rgb_buffer) return;
// for (int y = 0; y < height; y++) {
// for (int x = 0; x < width; x++) {
// int byte_index = (y * width + x) / 8;
// int bit_index = 7 - (x % 8);
// bool pixel_white = (bit_buffer[byte_index] >> bit_index) & 0x01;
// rgb_buffer[y * width + x] = pixel_white ? COLOR_WHITE : COLOR_BLACK;
// }
// }
// st7789_write(rgb_buffer, width * height);
(void)bit_buffer;
}