oop output card display binding

This commit is contained in:
Siwat Sirichai 2023-12-30 22:50:19 +07:00
parent 59b1ade59d
commit 2d0d38ecf3
6 changed files with 355 additions and 124 deletions

View file

@ -4,12 +4,21 @@
#include <ESPMegaIoT.hpp>
#include <DigitalInputCard.hpp>
#include <DigitalOutputCard.hpp>
#include <ClimateCard.hpp>
// Page IDs
#define INTERNAL_DISPLAY_DASHBOARD_PAGE 0
#define INTERNAL_DISPLAY_INPUT_PAGE 1
#define INTERNAL_DISPLAY_OUTPUT_PAGE 2
#define INTERNAL_DISPLAY_AC_PAGE 3
#define INTERNAL_DISPLAY_BOOT_PAGE 0
#define INTERNAL_DISPLAY_DASHBOARD_PAGE 1
#define INTERNAL_DISPLAY_INPUT_PAGE 2
#define INTERNAL_DISPLAY_OUTPUT_PAGE 3
#define INTERNAL_DISPLAY_AC_PAGE 4
#define INTERNAL_DISPLAY_PWM_ADJUSTMENT_PAGE 5
#define INTERNAL_DISPLAY_NETWORK_CONFIG_PAGE 6
#define INTERNAL_DISPLAY_OTA_PAGE 9
#define INTERNAL_DISPLAY_CLIMATE_NULL_PTR_PAGE 10
#define INTERNAL_DISPLAY_MQTT_CONFIG_PAGE 11
#define INTERNAL_DISPLAY_INPUT_NULL_PTR_PAGE 12
#define INTERNAL_DISPLAY_OUTPUT_NULL_PTR_PAGE 13
// Picture IDs
#define PIC_LAN_DISCONNECTED 2
@ -22,11 +31,17 @@
// Messages
#define MSG_MQTT_CONNECTED "BMS Managed"
#define MSG_MQTT_DISCONNECTED "Standalone"
#define MSG_PWM_ADJUSTMENT_STATE_ON "ON"
#define MSG_PWM_ADJUSTMENT_STATE_OFF "OFF"
// Refresh Interval
#define INTERNAL_DISPLAY_CLOCK_REFRESH_INTERVAL 15000
#define INTERNAL_DISPLAY_TOP_BAR_REFRESH_INTERVAL 5000
// Touch Types
#define TOUCH_TYPE_PRESS 0x01
#define TOUCH_TYPE_RELEASE 0x0
class InternalDisplay : public ESPMegaDisplay {
public:
InternalDisplay(HardwareSerial *displayAdapter);
@ -34,10 +49,12 @@ class InternalDisplay : public ESPMegaDisplay {
void loop();
void bindInputCard(DigitalInputCard *inputCard);
void bindOutputCard(DigitalOutputCard *outputCard);
void bindClimateCard(ClimateCard *climateCard);
private:
DigitalInputCard *inputCard;
DigitalOutputCard *outputCard;
ClimateCard *climateCard;
void handleInputStateChange(uint8_t pin, bool state);
void handlePwmStateChange(uint8_t pin, bool state, uint16_t value);
void handlePageChange(uint8_t page);
@ -57,6 +74,15 @@ class InternalDisplay : public ESPMegaDisplay {
void refreshInput();
void refreshOutput();
void refreshAC();
void refreshPWMAdjustment();
void refreshPWMAdjustmentSlider();
void refreshPWMAdjustmentState();
void refreshPWMAdjustmentId();
uint8_t pmwAdjustmentPin;
// Touch handlers
void handleTouch(uint8_t page, uint8_t component, uint8_t type);
void handlePWMAdjustmentTouch(uint8_t component, uint8_t type);
void handleACTouch(uint8_t component, uint8_t type);
MqttConfig *mqttConfig;
NetworkConfig *networkConfig;
// Pointers to various data