Files
basic1/display/low_level_display.h
Adolfo Reyna 8cbb95b181 Add auto-sleep/wake functionality with timer-based dimming
- Added PWM brightness control to ST7796 driver (0-100%)
- Implemented hardware sleep mode for ST7796 (saves ~150mA)
- Added sleep/wake functions preserving framebuffer and settings
- Implemented timer-based inactivity detection (checks every 10s)
- Auto-sleep after 5 minutes of no user input
- Touch controller remains active during TFT sleep for instant wake
- E-ink display also sleeps after timeout, requires re-init on wake
- Added hardware_pwm library dependency to CMakeLists.txt
- Brightness and sleep/wake methods exposed through display abstraction layer
2026-02-10 20:29:10 -05:00

48 lines
1.7 KiB
C++

#ifndef LOW_LEVEL_DISPLAY_H
#define LOW_LEVEL_DISPLAY_H
#include <stdint.h>
#include <stdbool.h>
// Display type enumeration
typedef enum {
DISPLAY_TYPE_ST7796,
DISPLAY_TYPE_ST7789,
DISPLAY_TYPE_EPAPER
} DisplayType;
// Abstract display interface
class LowLevelDisplay {
public:
virtual ~LowLevelDisplay() {}
// Core display operations - all work with 1-bit monochrome buffers
virtual bool init() = 0;
virtual void clear(bool white = true) = 0; // Clear to white or black
virtual void draw_pixel(int x, int y, bool white) = 0;
virtual void draw_buffer(const uint8_t* bit_buffer) = 0; // 1-bit buffer (width*height/8 bytes)
virtual void refresh() = 0; // Update display (converts 1-bit to native format)
// Display properties
virtual int get_width() const = 0;
virtual int get_height() const = 0;
virtual DisplayType get_type() const = 0;
virtual bool is_color() const = 0;
// Optional: Backlight control (if supported)
virtual void set_backlight(bool on) { (void)on; }
// Optional: Brightness control (if supported)
// brightness: 0-100 (percentage), 0=off, 100=full brightness
virtual void set_brightness(uint8_t brightness) { (void)brightness; }
virtual uint8_t get_brightness() const { return 100; } // Default to full brightness
// Optional: Orientation control (not commonly needed for bitmap displays)
virtual void set_rotation(uint8_t rotation) { (void)rotation; }
// Factory method - creates display based on type, using board_config.h for pins
static LowLevelDisplay* create(DisplayType type, int width, int height);
};
#endif // LOW_LEVEL_DISPLAY_H