- 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
53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
#ifndef LOW_LEVEL_DISPLAY_ST7796_H
|
|
#define LOW_LEVEL_DISPLAY_ST7796_H
|
|
|
|
#include "low_level_display.h"
|
|
#include "st7796.h"
|
|
|
|
class LowLevelDisplayST7796 : public LowLevelDisplay {
|
|
private:
|
|
const st7796_config* config;
|
|
int width;
|
|
int height;
|
|
bool initialized;
|
|
uint16_t* rgb_buffer; // Persistent buffer for 1-bit to RGB565 conversion
|
|
bool invert_color; // If true, swap black/white
|
|
|
|
public:
|
|
LowLevelDisplayST7796(const st7796_config* cfg, int w, int h, bool invert = false);
|
|
~LowLevelDisplayST7796() override;
|
|
|
|
// Core display operations - converts 1-bit to RGB565 internally
|
|
bool init() override;
|
|
void clear(bool white = true) override;
|
|
void draw_pixel(int x, int y, bool white) override;
|
|
void draw_buffer(const uint8_t* bit_buffer) override;
|
|
void refresh() override;
|
|
|
|
// Display properties
|
|
int get_width() const override { return width; }
|
|
int get_height() const override { return height; }
|
|
DisplayType get_type() const override { return DISPLAY_TYPE_ST7796; }
|
|
bool is_color() const override { return true; }
|
|
|
|
// Backlight control
|
|
void set_backlight(bool on) override;
|
|
|
|
// Brightness control (0-100)
|
|
void set_brightness(uint8_t brightness) override;
|
|
uint8_t get_brightness() const override;
|
|
|
|
// Power management
|
|
void sleep(); // Put display to sleep (low power, touch still active)
|
|
void wake(); // Wake display from sleep
|
|
|
|
// Orientation control
|
|
void set_rotation(uint8_t rotation) override;
|
|
|
|
// Color inversion control
|
|
void set_invert_color(bool inv) { invert_color = inv; }
|
|
bool get_invert_color() const { return invert_color; }
|
|
};
|
|
|
|
#endif // LOW_LEVEL_DISPLAY_ST7796_H
|