create hmi and define component

This commit is contained in:
reaw55 2024-01-30 20:51:12 +07:00
parent 8a19674b0e
commit f2c0eb6bf1
86 changed files with 643 additions and 0 deletions

210
src/ise_display.hpp Normal file
View file

@ -0,0 +1,210 @@
#pragma once
#include <ESPMegaDisplay.hpp>
#include <TimeStructure.hpp>
#include <DigitalInputCard.hpp>
#include <DigitalOutputCard.hpp>
#include <ClimateCard.hpp>
// Touch Types
#define TOUCH_TYPE_PRESS 1
#define TOUCH_TYPE_RELEASE 0
// Page IDs
#define PAGE_BOOT 0
#define PAGE_STANDBY 1
#define PAGE_DASHBOARD 2
//boot page
//logo gmov boot
#define COMPONENT_LOGO_BOOT 1
#define COMPONENT_LOGO_BOOT_VID 1
//boot background
#define COMPONENT_BACKGROUND_BOOT_PIC 43
//standby page object id
#define COMPONENT_LOGO_STANDBY 1
#define COMPONENT_LOGO_STANDBY_VID 2
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE 2
#define COMPONENT_STANDBY_LIGHT_TOGGLE 3
#define COMPONENT_STANDBY_AC_TOGGLE 4
#define COMPONENT_STANDBY_PM_TOGGLE 5
//text
#define COMPONENT_STANDBY_TIME_TXT 6
#define COMPONENT_STANDBY_DATE_TXT 7
#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8
//standby page picture id
#define COMPONENT_BACKGROUND_PIC 44
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF 46
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF_PRESSED 47
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON 48
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49
#define COMPONENT_STANDBY_AC_PIC_OFF 50
#define COMPONENT_STANDBY_AC_PIC_OFF_PRESSED 51
#define COMPONENT_STANDBY_AC_PIC_ON 52
#define COMPONENT_STANDBY_AC_PIC_ON_PRESSED 53
#define COMPONENT_STANDBY_LIGHT_PIC_OFF 54
#define COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED 55
#define COMPONENT_STANDBY_LIGHT_PIC_ON 56
#define COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED 57
#define COMPONENT_STANDBY_PM_PIC_OFF 58
#define COMPONENT_STANDBY_PM_PIC_OFF_PRESSED 59
#define COMPONENT_STANDBY_PM_PIC_ON 60
#define COMPONENT_STANDBY_PM_PIC_ON_PRESSED 61
#define COMPONENT_REFERENCE_BACKGROUND_PIC 62
//dashboard page
//dashboard page object id
#define COMPONENT_AC_TOGGLE_BUTTON 3
#define COMPONENT_AC_MODE 4
#define COMPONENT_AC_FAN_SPEED 5
#define COMPONENT_AC_TEMP_DOWN_BUTTON 6
#define COMPONENT_AC_TEMP_UP_BUTTON 7
#define COMPONENT_PM_TOGGLE_BUTTON 8
#define COMPONENT_PM_FAN_SPEED_DECREASE 9
#define COMPONENT_PM_FAN_SPEED_INCREASE 10
#define COMPONENT_PM_INSIDE_TXT 11
#define COMPONENT_PM_OUTSIDE_TXT 12
#define COMPONENT_LIGHT_MASTER_BUTTON 13
#define COMPONENT_LIGHT_ROW1_PIC_PLACEHOLDER 14
#define COMPONENT_LIGHT_ROW2_PIC_PLACEHOLDER 15
#define COMPONENT_LIGHT_ROW3_PIC_PLACEHOLDER 16
#define COMPONENT_LIGHT_ROW4_PIC_PLACEHOLDER 17
#define COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT 18
#define COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19
#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20
#define COMPONENT_LIGHT_ROW1_LEVEL0_TOUCHPOINT 21
#define COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT 22
#define COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT 23
#define COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT 24
#define COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT 25
#define COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT 26
#define COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT 27
#define COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT 28
#define COMPONENT_LIGHT_ROW3_LEVEL0_TOUCHPOINT 29
#define COMPONENT_LIGHT_ROW3_LEVEL1_TOUCHPOINT 30
#define COMPONENT_LIGHT_ROW3_LEVEL2_TOUCHPOINT 31
#define COMPONENT_LIGHT_ROW3_LEVEL3_TOUCHPOINT 32
#define COMPONENT_LIGHT_ROW4_LEVEL0_TOUCHPOINT 33
#define COMPONENT_LIGHT_ROW4_LEVEL1_TOUCHPOINT 34
#define COMPONENT_LIGHT_ROW4_LEVEL2_TOUCHPOINT 35
#define COMPONENT_LIGHT_ROW4_LEVEL3_TOUCHPOINT 36
#define COMPONENT_DASHBOARD_TIME_TXT 37
#define COMPONENT_DASHBOARD_DATE_TXT 38
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 39
//dashboard page picture id
#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0
#define COMPONENT_DASHBOARD_BACKGROUND_PIC 1
#define COMPONENT_DASHBOARD_BACKGROUND_VARIANT_PIC 2
//AC on/off
#define COMPONENT_AC_TOGGLE_PIC_OFF 3
#define COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED 4
#define COMPONENT_AC_TOGGLE_PIC_ON 5
#define COMPONENT_AC_TOGGLE_PIC_ON_PRESSED 6
#define COMPONENT_AC_TEMP_DOWN_PIC 7
#define COMPONENT_AC_TEMP_DOWN_PIC_PRESSED 8
#define COMPONENT_AC_TEMP_UP_PIC 9
#define COMPONENT_AC_TEMP_UP_PIC_PRESSED 10
#define COMPONENT_AC_FAN_MODE_AUTO_PIC 11
#define COMPONENT_AC_FAN_MODE_AUTO_PIC_PRESSED 12
#define COMPONENT_AC_FAN_MODE_HIGH_PIC 13
#define COMPONENT_AC_FAN_MODE_HIGH_PIC_PRESSED 14
#define COMPONENT_AC_FAN_MODE_MID_PIC 15
#define COMPONENT_AC_FAN_MODE_MID_PIC_PRESSED 16
#define COMPONENT_AC_FAN_MODE_LOW_PIC 17
#define COMPONENT_AC_FAN_MODE_LOW_PIC_PRESSED 18
#define COMPONENT_AC_MODE_DRY_PIC 19
#define COMPONENT_AC_MODE_DRY_PIC_PRESSED 20
#define COMPONENT_AC_MODE_COOL_PIC 21
#define COMPONENT_AC_MODE_COOL_PIC_PRESSED 22
#define COMPONENT_AC_MODE_FAN_PIC 23
#define COMPONENT_AC_MODE_FAN_PIC_PRESSED 24
#define COMPONENT_PM_TOGGLE_PIC_OFF 25
#define COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED 26
#define COMPONENT_PM_TOGGLE_PIC_ON 27
#define COMPONENT_PM_TOGGLE_PIC_ON_PRESSED 28
#define COMPONENT_PM_FAN_SPEED_DECREASE_PIC 29
#define COMPONENT_PM_FAN_SPEED_DECREASE_PIC_PRESSED 30
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC 31
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32
#define COMPONENT_AC_STATUS_OFF 33
#define COMPONENT_AC_STATUS_ON 34
#define COMPONENT_LIGHT_MASTER_OFF 35
#define COMPONENT_LIGHT_MASTER_OFF_PRESSED 36
#define COMPONENT_LIGHT_MASTER_ON 37
#define COMPONENT_LIGHT_MASTER_ON_PRESSED 38
#define COMPONENT_LIGHT_LEVEL_1 39
#define COMPONENT_LIGHT_LEVEL_2 40
#define COMPONENT_LIGHT_LEVEL_3 41
#define COMPONENT_LIGHT_LEVEL_4 42
/**
* @brief A class for controlling the ESPMegaDisplay.
*
* Made for ISE building 2 room 303/2.
*/
class ISEDisplay : public ESPMegaDisplay {
public:
ISEDisplay(HardwareSerial* adapter);
void begin(std::function<rtctime_t()> getTime, DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
void handleTouch(uint8_t page, uint8_t component, uint8_t event);
void handlePWMChange(uint8_t pin, uint8_t value);
void handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
void handlePayload(uint8_t payload_type, uint8_t* payload, uint8_t length);
void sendClock();
void setACControlEnabled(bool enabled);
bool getACControlEnabled();
private:
bool ac_control_enabled = true;
std::function<rtctime_t()> getTime;
DigitalInputCard* inputCard;
DigitalOutputCard* outputCard;
uint8_t outputCallbackHandle;
ClimateCard* climateCard;
uint8_t climateCallbackHandle;
bool calculateLightGroupState();
bool calculateFanGroupState();
void setLightGrouptState(bool state);
void setFanGroupState(bool state);
void toggleLightGroupState();
void toggleFanGroupState();
void updateLightGroupState();
void updateFanGroupState();
void updateAirPurifierState();
void updateACState();
};