144 lines
3.2 KiB
C++
144 lines
3.2 KiB
C++
/**
|
|
* Claude's Eyes - Display Module Header
|
|
*
|
|
* ST7789 240x320 TFT with CST816S touch on Waveshare ESP32-S3
|
|
*/
|
|
|
|
#ifndef DISPLAY_H
|
|
#define DISPLAY_H
|
|
|
|
#include <Arduino.h>
|
|
#include <TFT_eSPI.h>
|
|
#include <CST816S.h>
|
|
|
|
// Display modes
|
|
enum DisplayMode {
|
|
MODE_STATUS, // Show status information
|
|
MODE_EMOJI, // Show emoji/expression
|
|
MODE_MESSAGE, // Show text message
|
|
MODE_CONTROLS // Show touch controls
|
|
};
|
|
|
|
// Emoji types for expressions
|
|
enum EmojiType {
|
|
EMOJI_HAPPY,
|
|
EMOJI_THINKING,
|
|
EMOJI_SURPRISED,
|
|
EMOJI_SLEEPY,
|
|
EMOJI_CURIOUS,
|
|
EMOJI_CONFUSED
|
|
};
|
|
|
|
// Touch button IDs
|
|
enum TouchButton {
|
|
BTN_NONE = 0,
|
|
BTN_STOP, // Emergency stop
|
|
BTN_FORWARD,
|
|
BTN_BACKWARD,
|
|
BTN_LEFT,
|
|
BTN_RIGHT,
|
|
BTN_HOME // Return to base
|
|
};
|
|
|
|
class DisplayModule {
|
|
public:
|
|
DisplayModule();
|
|
|
|
/**
|
|
* Initialize display and touch
|
|
* @return true if successful
|
|
*/
|
|
bool begin();
|
|
|
|
/**
|
|
* Update display (call from loop)
|
|
*/
|
|
void update();
|
|
|
|
/**
|
|
* Set display mode
|
|
*/
|
|
void setMode(DisplayMode mode);
|
|
|
|
/**
|
|
* Show emoji expression
|
|
*/
|
|
void showEmoji(EmojiType emoji);
|
|
|
|
/**
|
|
* Show text message
|
|
* @param message Text to display
|
|
* @param color Text color (default white)
|
|
*/
|
|
void showMessage(const char* message, uint16_t color = TFT_WHITE);
|
|
|
|
/**
|
|
* Update status display
|
|
* @param action Current action string
|
|
* @param distance Distance to obstacle (cm)
|
|
* @param battery Battery percentage
|
|
* @param wifiRssi WiFi signal strength
|
|
*/
|
|
void updateStatus(const char* action, float distance,
|
|
int battery, int wifiRssi);
|
|
|
|
/**
|
|
* Set Claude's last message (scrolling text)
|
|
*/
|
|
void setClaudeText(const char* text);
|
|
|
|
/**
|
|
* Check for touch input
|
|
* @return Button ID or BTN_NONE
|
|
*/
|
|
TouchButton checkTouch();
|
|
|
|
/**
|
|
* Set backlight brightness
|
|
* @param brightness 0-255
|
|
*/
|
|
void setBrightness(uint8_t brightness);
|
|
|
|
/**
|
|
* Get display object for direct access
|
|
*/
|
|
TFT_eSPI& getTFT() { return _tft; }
|
|
|
|
private:
|
|
TFT_eSPI _tft;
|
|
CST816S _touch;
|
|
|
|
bool _initialized;
|
|
DisplayMode _currentMode;
|
|
unsigned long _lastUpdateTime;
|
|
int _scrollOffset;
|
|
String _claudeText;
|
|
|
|
// Status values
|
|
String _currentAction;
|
|
float _distance;
|
|
int _battery;
|
|
int _wifiRssi;
|
|
|
|
// Drawing functions
|
|
void drawStatusScreen();
|
|
void drawEmojiScreen(EmojiType emoji);
|
|
void drawMessageScreen(const char* message, uint16_t color);
|
|
void drawControlsScreen();
|
|
void drawWifiIcon(int x, int y, int rssi);
|
|
void drawBatteryIcon(int x, int y, int percent);
|
|
|
|
// Emoji drawing
|
|
void drawHappyFace(int centerX, int centerY, int radius);
|
|
void drawThinkingFace(int centerX, int centerY, int radius);
|
|
void drawSurprisedFace(int centerX, int centerY, int radius);
|
|
void drawSleepyFace(int centerX, int centerY, int radius);
|
|
void drawCuriousFace(int centerX, int centerY, int radius);
|
|
void drawConfusedFace(int centerX, int centerY, int radius);
|
|
};
|
|
|
|
// Global instance
|
|
extern DisplayModule Display;
|
|
|
|
#endif // DISPLAY_H
|