ESPMegaPRO-v3-SDK/Template Project/lib/ESPMegaPRO/ESPMegaDisplay.hpp

47 lines
1.8 KiB
C++
Raw Normal View History

2023-12-28 19:36:18 +00:00
#include <Arduino.h>
#include <ESPMegaPRO_OOP.hpp>
2023-12-29 04:55:59 +00:00
2023-12-29 13:04:25 +00:00
#define DISPLAY_FETCH_TIMEOUT 100 // ms
2023-12-29 04:55:59 +00:00
2023-12-28 19:36:18 +00:00
class ESPMegaDisplay
{
public:
2023-12-29 13:04:25 +00:00
ESPMegaDisplay(HardwareSerial *displayAdapter);
2023-12-28 19:36:18 +00:00
void begin();
void loop();
void reset();
void setBrightness(int value);
2023-12-29 13:04:25 +00:00
void setVolume(int value);
2023-12-28 19:36:18 +00:00
void jumpToPage(int page);
void setString(char* component, char* value);
void setNumber(char* component, int value);
char* getString(char* component);
2023-12-29 13:04:25 +00:00
bool getStringToBuffer(char* component, char* buffer, uint8_t buffer_size);
uint32_t getNumber(char* component);
2023-12-28 19:36:18 +00:00
void handlePwmStateChange(uint8_t pin, uint16_t value);
void handleInputStateChange(uint8_t pin, bool state);
void registerPushCallback(std::function<void(uint8_t, uint8_t)> callback);
void registerPopCallback(std::function<void(uint8_t, uint8_t)> callback);
void registerPageChangeCallback(std::function<void(uint8_t)> callback);
void unregisterPushCallback();
void unregisterPopCallback();
void unregisterPageChangeCallback();
2023-12-29 13:04:25 +00:00
protected:
2023-12-28 19:36:18 +00:00
uint8_t currentPage;
uint8_t rx_buffer_index;
char rx_buffer[256];
char tx_buffer[256];
2023-12-29 04:55:59 +00:00
bool recieveSerialCommand();
bool recieveSerialCommand(bool process);
2023-12-28 19:36:18 +00:00
void processSerialCommand();
void processTouchPayload();
void processPageReportPayload();
void sendStopBytes();
void sendCommand(char* command);
2023-12-29 04:55:59 +00:00
bool payloadIsValid();
bool waitForValidPayload(uint32_t timeout);
2023-12-28 19:36:18 +00:00
HardwareSerial *displayAdapter;
std::function<void(uint8_t, uint8_t)> pushCallback;
std::function<void(uint8_t, uint8_t)> popCallback;
std::function<void(uint8_t)> pageChangeCallback;
};