ESPMegaPRO-v3-SDK/Template Project/lib/ESPMegaPRO/InternalDisplay.cpp

147 lines
4.1 KiB
C++
Raw Normal View History

2023-12-29 13:04:25 +00:00
#include <InternalDisplay.hpp>
2023-12-29 16:43:12 +00:00
void InternalDisplay::begin() {
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::loop() {
// TODO: implementation
}
void InternalDisplay::bindInputCard(uint8_t card_id) {
this->bindedInputCard = card_id;
if(currentPage == INTERNAL_DISPLAY_INPUT_PAGE) {
refreshInput();
}
}
void InternalDisplay::bindOutputCard(uint8_t card_id) {
this->bindedOutputCard = card_id;
if(currentPage == INTERNAL_DISPLAY_OUTPUT_PAGE) {
refreshOutput();
}
}
void InternalDisplay::handleInputStateChange(uint8_t pin, bool state) {
// If the input card is binded to the display and the current page is the input page
// then update the respective input component
2023-12-29 16:43:12 +00:00
if (!this->bindedInputCard || this->currentPage != INTERNAL_DISPLAY_INPUT_PAGE) return;
// Update the input state
this->setInputMarker(pin, state);
2023-12-29 13:04:25 +00:00
}
2023-12-29 16:43:12 +00:00
void InternalDisplay::handlePwmStateChange(uint8_t pin, bool state, uint16_t value) {
2023-12-29 13:04:25 +00:00
// If the output card is binded to the display and the current page is the output page
// then update the respective output component
2023-12-29 16:43:12 +00:00
if (!this->bindedOutputCard || this->currentPage != INTERNAL_DISPLAY_OUTPUT_PAGE) return;
// Update the output state
this->setOutputBar(pin, value);
this->setOutputStateColor(pin, state);
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::handlePageChange(uint8_t page) {
2023-12-29 16:43:12 +00:00
// Refresh the page
this->refreshPage(page);
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::saveNetworkConfig() {
// TODO: implementation
}
void InternalDisplay::saveMQTTConfig() {
// TODO: implementation
}
2023-12-29 16:43:12 +00:00
void InternalDisplay::updateStatusIcons(bool networkStatus, bool mqttStatus) {
this->setNumber("server.pic", mqttStatus ? PIC_MQTT_CONNECTED : PIC_MQTT_DISCONNECTED);
this->setNumber("lan.pic", networkStatus ? PIC_LAN_CONNECTED : PIC_LAN_DISCONNECTED);
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::updateClock() {
2023-12-29 16:43:12 +00:00
rtctime_t time = this->getRtcTime();
this->displayAdapter->print("time.txt=");
this->displayAdapter->print(time.hours%12);
this->displayAdapter->print(":");
this->displayAdapter->print(time.minutes);
this->displayAdapter->print(" ");
this->displayAdapter->print(time.hours/12 ? "PM" : "AM");
this->sendStopBytes();
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::refreshPage() {
2023-12-29 16:43:12 +00:00
this->refreshPage(this->currentPage);
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::refreshPage(uint8_t page) {
2023-12-29 16:43:12 +00:00
switch (page) {
case INTERNAL_DISPLAY_DASHBOARD_PAGE:
this->refreshDashboard();
break;
case INTERNAL_DISPLAY_INPUT_PAGE:
this->refreshInput();
break;
case INTERNAL_DISPLAY_OUTPUT_PAGE:
this->refreshOutput();
break;
case INTERNAL_DISPLAY_AC_PAGE:
this->refreshAC();
break;
}
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::refreshDashboard() {
2023-12-29 16:43:12 +00:00
// The dashboard have the following components:
// 1. Hostname
// 2. IP Address
// 3. MQTT Server with port
// 4. MQTT Connection status
this->iot->
2023-12-29 13:04:25 +00:00
}
void InternalDisplay::refreshInput() {
// TODO: implementation
}
void InternalDisplay::refreshOutput() {
// TODO: implementation
}
void InternalDisplay::refreshAC() {
// TODO: implementation
}
void InternalDisplay::setOutputBar(uint8_t pin, uint16_t value) {
// Write the value to the output bar
this->displayAdapter->print("j");
this->displayAdapter->print(pin);
this->displayAdapter->print(".val=");
this->displayAdapter->print(value);
this->sendStopBytes();
}
void InternalDisplay::setPWMAdjustmentSlider(uint16_t value) {
// TODO: implementation
}
void InternalDisplay::setPWMAdjustmentPin(uint8_t pin) {
// TODO: implementation
}
void InternalDisplay::setPWMAdjustmentButton(bool state) {
// TODO: implementation
}
2023-12-29 14:41:19 +00:00
void InternalDisplay::setOutputStateColor(uint8_t pin, bool state) {
// TODO: implementation
}
void InternalDisplay::setInputMarker(uint8_t pin, bool state) {
// TODO: implementation
}
InternalDisplay::InternalDisplay(HardwareSerial *displayAdapter) : ESPMegaDisplay(displayAdapter) {
this->currentPage = INTERNAL_DISPLAY_DASHBOARD_PAGE;
this->bindedInputCard = 0;
this->bindedOutputCard = 0;
}