hardware button support

This commit is contained in:
Adolfo Reyna
2026-01-29 15:23:03 -05:00
parent 1684eb0198
commit 8d0bca691a
7 changed files with 204 additions and 40 deletions

View File

@@ -3,8 +3,13 @@
#include <stdlib.h>
#include <string.h>
// Note: This is a placeholder implementation
// You'll need to add the actual e-paper driver code to lib/epaper/
// Waveshare 4.2" e-Paper monochrome driver (supports partial refresh)
extern "C" {
#include "EPD_4in2_V2.h"
#include "DEV_Config.h"
}
// Note: EPD_4IN2_V2 is monochrome (black/white) and supports fast partial refresh
LowLevelDisplayEPaper::LowLevelDisplayEPaper(const epaper_config* cfg, int w, int h)
: config(cfg), width(w), height(h), initialized(false), framebuffer(nullptr), dirty(false) {
@@ -33,11 +38,15 @@ bool LowLevelDisplayEPaper::init() {
return false;
}
// TODO: Implement e-paper initialization
// epaper_init(config, width, height);
printf("E-paper display initialized: %dx%d (stub)\n", width, height);
printf("Initializing Waveshare 4.2\" e-Paper display (%dx%d)...\n", width, height);
// Initialize Waveshare driver (handles GPIO and SPI setup)
DEV_Module_Init();
EPD_4IN2_V2_Init();
printf("E-paper display initialized successfully (partial refresh enabled)\n");
initialized = true;
return false; // Return false until actual driver is implemented
return true;
}
void LowLevelDisplayEPaper::clear(bool white) {
@@ -79,19 +88,56 @@ void LowLevelDisplayEPaper::refresh() {
return;
}
// TODO: Implement actual e-paper refresh
// epaper_update(framebuffer);
printf("E-paper refresh (stub)\n");
if (!initialized) {
printf("E-paper not initialized, cannot refresh\n");
return;
}
printf("Refreshing e-paper display (partial refresh)...\n");
// Use partial refresh for fast updates (~1 second instead of ~15 seconds)
// Partial refresh updates only the changed pixels
EPD_4IN2_V2_PartialDisplay(framebuffer, 0, 0, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT);
printf("E-paper partial refresh complete\n");
dirty = false;
}
void LowLevelDisplayEPaper::clear_display() {
clear(true); // Fill with white
refresh();
if (!initialized) {
printf("E-paper not initialized, cannot clear\n");
return;
}
printf("Clearing e-paper display...\n");
EPD_4IN2_V2_Clear();
// Also clear framebuffer
clear(true);
dirty = false; // Already refreshed by EPD_4IN2_V2_Clear
}
void LowLevelDisplayEPaper::full_refresh() {
if (!framebuffer || !initialized) {
printf("E-paper not initialized or no framebuffer\n");
return;
}
printf("Performing full refresh (removes ghosting, ~15 seconds)...\n");
// Full refresh uses EPD_4IN2_V2_Display for complete screen update
// This is slower but removes any ghosting from partial refreshes
EPD_4IN2_V2_Display(framebuffer);
printf("Full refresh complete\n");
dirty = false;
}
void LowLevelDisplayEPaper::sleep() {
// TODO: Implement e-paper sleep mode
// epaper_sleep();
if (!initialized) {
return;
}
printf("Putting e-paper display to sleep...\n");
EPD_4IN2_V2_Sleep();
}

View File

@@ -41,8 +41,9 @@ public:
bool is_color() const override { return false; } // Most e-paper is monochrome
// E-paper specific
void clear_display();
void sleep(); // Put display in low power mode
void clear_display(); // Full clear with refresh
void full_refresh(); // Force full screen refresh (slower but removes ghosting)
void sleep(); // Put display in low power mode
};
#endif // LOW_LEVEL_DISPLAY_EPAPER_H