#include void InternalDisplay::begin() { } 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 if (!this->bindedInputCard || this->currentPage != INTERNAL_DISPLAY_INPUT_PAGE) return; // Update the input state this->setInputMarker(pin, state); } void InternalDisplay::handlePwmStateChange(uint8_t pin, bool state, uint16_t value) { // If the output card is binded to the display and the current page is the output page // then update the respective output component if (!this->bindedOutputCard || this->currentPage != INTERNAL_DISPLAY_OUTPUT_PAGE) return; // Update the output state this->setOutputBar(pin, value); this->setOutputStateColor(pin, state); } void InternalDisplay::handlePageChange(uint8_t page) { // Refresh the page this->refreshPage(page); } void InternalDisplay::saveNetworkConfig() { // TODO: implementation } void InternalDisplay::saveMQTTConfig() { // TODO: implementation } 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); } void InternalDisplay::updateClock() { 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(); } void InternalDisplay::refreshPage() { this->refreshPage(this->currentPage); } void InternalDisplay::refreshPage(uint8_t page) { 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; } } void InternalDisplay::refreshDashboard() { // The dashboard have the following components: // 1. Hostname // 2. IP Address // 3. MQTT Server with port // 4. MQTT Connection status this->iot-> } 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 } 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; }