internal mutex
This commit is contained in:
parent
fdf32d8503
commit
0b1ca17351
|
@ -8,15 +8,17 @@
|
||||||
bool ESPMegaDisplay::recieveSerialCommand(bool process)
|
bool ESPMegaDisplay::recieveSerialCommand(bool process)
|
||||||
{
|
{
|
||||||
bool dataRecieved = false;
|
bool dataRecieved = false;
|
||||||
|
|
||||||
|
while (displayAdapter->available())
|
||||||
|
{
|
||||||
// Read the serial buffer if available
|
// Read the serial buffer if available
|
||||||
if (xSemaphoreTake(this->serialMutex, DISPLAY_MUTEX_TAKE_TIMEOUT) == pdFALSE)
|
if (xSemaphoreTake(this->serialMutex, DISPLAY_MUTEX_TAKE_TIMEOUT) == pdFALSE)
|
||||||
{
|
{
|
||||||
ESP_LOGI("ESPMegaDisplay", "Failed to take serial mutex");
|
ESP_LOGI("ESPMegaDisplay", "Failed to take serial mutex");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (displayAdapter->available())
|
|
||||||
{
|
|
||||||
rx_buffer[rx_buffer_index] = displayAdapter->read();
|
rx_buffer[rx_buffer_index] = displayAdapter->read();
|
||||||
|
xSemaphoreGive(this->serialMutex);
|
||||||
rx_buffer_index++;
|
rx_buffer_index++;
|
||||||
// Check for overflow
|
// Check for overflow
|
||||||
if (rx_buffer_index >= 256)
|
if (rx_buffer_index >= 256)
|
||||||
|
@ -27,7 +29,6 @@ bool ESPMegaDisplay::recieveSerialCommand(bool process)
|
||||||
this->processSerialCommand();
|
this->processSerialCommand();
|
||||||
dataRecieved = true;
|
dataRecieved = true;
|
||||||
}
|
}
|
||||||
xSemaphoreGive(this->serialMutex);
|
|
||||||
return dataRecieved;
|
return dataRecieved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,10 +606,17 @@ void ESPMegaDisplay::unregisterPayloadCallback(uint16_t handle)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Takes the serial mutex.
|
* @brief Takes the serial mutex.
|
||||||
|
*
|
||||||
|
* @note only neccessary if you are using the display adapter directly, otherwise the mutex is taken by the helper functions.
|
||||||
*/
|
*/
|
||||||
void ESPMegaDisplay::takeSerialMutex()
|
bool ESPMegaDisplay::takeSerialMutex()
|
||||||
{
|
{
|
||||||
xSemaphoreTake(this->serialMutex, DISPLAY_MUTEX_TAKE_TIMEOUT);
|
if (xSemaphoreTake(this->serialMutex, DISPLAY_MUTEX_TAKE_TIMEOUT) == pdFALSE)
|
||||||
|
{
|
||||||
|
ESP_LOGI("ESPMegaDisplay", "Failed to take serial mutex");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -616,6 +624,7 @@ void ESPMegaDisplay::takeSerialMutex()
|
||||||
*/
|
*/
|
||||||
void ESPMegaDisplay::giveSerialMutex()
|
void ESPMegaDisplay::giveSerialMutex()
|
||||||
{
|
{
|
||||||
|
ESP_LOGD("ESPMegaDisplay", "Giving serial mutex");
|
||||||
xSemaphoreGive(this->serialMutex);
|
xSemaphoreGive(this->serialMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,14 @@ class ESPMegaDisplay
|
||||||
void unregisterPageChangeCallback(uint16_t handle);
|
void unregisterPageChangeCallback(uint16_t handle);
|
||||||
uint16_t registerPayloadCallback(std::function<void(uint8_t, uint8_t*, uint8_t)> callback);
|
uint16_t registerPayloadCallback(std::function<void(uint8_t, uint8_t*, uint8_t)> callback);
|
||||||
void unregisterPayloadCallback(uint16_t handle);
|
void unregisterPayloadCallback(uint16_t handle);
|
||||||
void takeSerialMutex();
|
bool takeSerialMutex();
|
||||||
void giveSerialMutex();
|
void giveSerialMutex();
|
||||||
|
SemaphoreHandle_t serialMutex;
|
||||||
bool beginUpdate(size_t size);
|
bool beginUpdate(size_t size);
|
||||||
bool writeUpdate(uint8_t* data, size_t size);
|
bool writeUpdate(uint8_t* data, size_t size);
|
||||||
void endUpdate();
|
void endUpdate();
|
||||||
protected:
|
protected:
|
||||||
size_t otaBytesWritten;
|
size_t otaBytesWritten;
|
||||||
SemaphoreHandle_t serialMutex;
|
|
||||||
uint8_t currentPage;
|
uint8_t currentPage;
|
||||||
uint8_t rx_buffer_index;
|
uint8_t rx_buffer_index;
|
||||||
char rx_buffer[256];
|
char rx_buffer[256];
|
||||||
|
|
|
@ -56,19 +56,26 @@ void ESPMegaDisplayOTA::otaUpdateWriteHandler(AsyncWebServerRequest *request, Js
|
||||||
// - size: the size of the update in bytes
|
// - size: the size of the update in bytes
|
||||||
// - data: the data to write
|
// - data: the data to write
|
||||||
|
|
||||||
|
Serial.println("OTA Update Write Handler Begin");
|
||||||
|
Serial.println("Parsing JSON");
|
||||||
//Parse the JSON object
|
//Parse the JSON object
|
||||||
JsonObject content = json.as<JsonObject>();
|
JsonObject content = json.as<JsonObject>();
|
||||||
// Check if the size and data fields are present
|
// // Check if the size and data fields are present
|
||||||
if(!content.containsKey("size") || !content.containsKey("data"))
|
// Serial.println("Checking if size and data fields are present");
|
||||||
request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The size or data field is missing\"}");
|
// if(!content.containsKey("size") || !content.containsKey("data"))
|
||||||
return;
|
// Serial.println("Size or data field is missing");
|
||||||
|
// request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The size or data field is missing\"}");
|
||||||
|
// return;
|
||||||
|
// Serial.println("Size and data fields are present, getting size");
|
||||||
// Get the size field
|
// Get the size field
|
||||||
size_t size = content["size"].as<size_t>();
|
size_t size = content["size"].as<size_t>();
|
||||||
|
Serial.printf("Size: %d\n", size);
|
||||||
if(size>4096) {
|
if(size>4096) {
|
||||||
// If the size is greater than 4096 bytes, return an error
|
// If the size is greater than 4096 bytes, return an error
|
||||||
request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The size of the update is too big\"}");
|
request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The size of the update is too big\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Serial.println("Getting data field");
|
||||||
// Get the data field
|
// Get the data field
|
||||||
JsonArray data = content["data"].as<JsonArray>();
|
JsonArray data = content["data"].as<JsonArray>();
|
||||||
if(this->updateProgress+size>this->updateSize) {
|
if(this->updateProgress+size>this->updateSize) {
|
||||||
|
@ -76,17 +83,21 @@ void ESPMegaDisplayOTA::otaUpdateWriteHandler(AsyncWebServerRequest *request, Js
|
||||||
request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The update chunk is too big\"}");
|
request->send(500, "application/json", "{\"status\": \"error\", \"message\": \"The update chunk is too big\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Serial.println("Converting JsonArray to uint8_t*");
|
||||||
// Convert JsonArray to uint8_t*
|
// Convert JsonArray to uint8_t*
|
||||||
uint8_t data_array[4096];
|
uint8_t data_array[4096];
|
||||||
for(size_t i=0; i<size; i++) {
|
for(size_t i=0; i<size; i++) {
|
||||||
data_array[i] = data[i].as<uint8_t>();
|
data_array[i] = data[i].as<uint8_t>();
|
||||||
}
|
}
|
||||||
|
Serial.println("Writing data to display");
|
||||||
// Write the data to the display
|
// Write the data to the display
|
||||||
display->writeUpdate(data_array, size);
|
display->writeUpdate(data_array, size);
|
||||||
|
request->send(200, "application/json", "{\"status\": \"success\"}");
|
||||||
}
|
}
|
||||||
void ESPMegaDisplayOTA::otaUpdateEndHandler(AsyncWebServerRequest *request, JsonVariant &json) {
|
void ESPMegaDisplayOTA::otaUpdateEndHandler(AsyncWebServerRequest *request, JsonVariant &json) {
|
||||||
this->webServer->checkAuthentication(request);
|
this->webServer->checkAuthentication(request);
|
||||||
display->endUpdate();
|
display->endUpdate();
|
||||||
|
request->send(200, "application/json", "{\"status\": \"success\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESPMegaDisplayOTA::displayWebPageHandler(AsyncWebServerRequest *request) {
|
void ESPMegaDisplayOTA::displayWebPageHandler(AsyncWebServerRequest *request) {
|
||||||
|
|
|
@ -20,9 +20,11 @@ void InternalDisplay::begin(ESPMegaIoT *iot, std::function<rtctime_t()> getRtcTi
|
||||||
auto bindedTouchCallback = std::bind(&InternalDisplay::handleTouch, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
auto bindedTouchCallback = std::bind(&InternalDisplay::handleTouch, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
this->registerTouchCallback(bindedTouchCallback);
|
this->registerTouchCallback(bindedTouchCallback);
|
||||||
// Initialize the display
|
// Initialize the display
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->begin(115200);
|
this->displayAdapter->begin(115200);
|
||||||
this->displayAdapter->setTimeout(100);
|
this->displayAdapter->setTimeout(100);
|
||||||
this->displayAdapter->flush();
|
this->displayAdapter->flush();
|
||||||
|
this->giveSerialMutex();
|
||||||
this->reset();
|
this->reset();
|
||||||
delay(500);
|
delay(500);
|
||||||
this->jumpToPage(1);
|
this->jumpToPage(1);
|
||||||
|
@ -83,7 +85,8 @@ void InternalDisplay::handlePwmStateChange(uint8_t pin, bool state, uint16_t val
|
||||||
// then update the respective output component
|
// then update the respective output component
|
||||||
if (this->outputCard == nullptr)
|
if (this->outputCard == nullptr)
|
||||||
return;
|
return;
|
||||||
if(this->currentPage == INTERNAL_DISPLAY_OUTPUT_PAGE) {
|
if (this->currentPage == INTERNAL_DISPLAY_OUTPUT_PAGE)
|
||||||
|
{
|
||||||
// Update the output state
|
// Update the output state
|
||||||
this->setOutputBar(pin, value);
|
this->setOutputBar(pin, value);
|
||||||
this->setOutputStateColor(pin, state);
|
this->setOutputStateColor(pin, state);
|
||||||
|
@ -128,27 +131,32 @@ void InternalDisplay::saveNetworkConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the ip address
|
// Validate the ip address
|
||||||
if (!ip.fromString(ip_buffer)) {
|
if (!ip.fromString(ip_buffer))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the netmask
|
// Save the netmask
|
||||||
IPAddress netmask;
|
IPAddress netmask;
|
||||||
if (!this->getStringToBuffer("netmask_set.txt", ip_buffer, 30)) {
|
if (!this->getStringToBuffer("netmask_set.txt", ip_buffer, 30))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Validate the netmask
|
// Validate the netmask
|
||||||
if (!netmask.fromString(ip_buffer)) {
|
if (!netmask.fromString(ip_buffer))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the gateway
|
// Save the gateway
|
||||||
IPAddress gateway;
|
IPAddress gateway;
|
||||||
if (!this->getStringToBuffer("gateway_set.txt", ip_buffer, 30)) {
|
if (!this->getStringToBuffer("gateway_set.txt", ip_buffer, 30))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Validate the gateway
|
// Validate the gateway
|
||||||
if (!gateway.fromString(ip_buffer)) {
|
if (!gateway.fromString(ip_buffer))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +245,10 @@ void InternalDisplay::updateStatusIcons(bool networkStatus, bool mqttStatus)
|
||||||
void InternalDisplay::updateClock()
|
void InternalDisplay::updateClock()
|
||||||
{
|
{
|
||||||
rtctime_t time = this->getRtcTime();
|
rtctime_t time = this->getRtcTime();
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->printf("time.txt=\"%02d:%02d %s\"", time.hours % 12, time.minutes, time.hours / 12 ? "PM" : "AM");
|
this->displayAdapter->printf("time.txt=\"%02d:%02d %s\"", time.hours % 12, time.minutes, time.hours / 12 ? "PM" : "AM");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,10 +327,12 @@ void InternalDisplay::refreshDashboard()
|
||||||
sprintf(ip_address, "%d.%d.%d.%d", this->networkConfig->ip[0], this->networkConfig->ip[1], this->networkConfig->ip[2], this->networkConfig->ip[3]);
|
sprintf(ip_address, "%d.%d.%d.%d", this->networkConfig->ip[0], this->networkConfig->ip[1], this->networkConfig->ip[2], this->networkConfig->ip[3]);
|
||||||
this->setString("ip_address.txt", ip_address);
|
this->setString("ip_address.txt", ip_address);
|
||||||
// Send the MQTT server and port
|
// Send the MQTT server and port
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("server_address.txt=\"");
|
this->displayAdapter->print("server_address.txt=\"");
|
||||||
this->displayAdapter->print(this->mqttConfig->mqtt_server);
|
this->displayAdapter->print(this->mqttConfig->mqtt_server);
|
||||||
this->displayAdapter->print("\"");
|
this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
// Send the MQTT connection status
|
// Send the MQTT connection status
|
||||||
this->setString("status_txt.txt", this->iot->mqttConnected() ? MSG_MQTT_CONNECTED : MSG_MQTT_DISCONNECTED);
|
this->setString("status_txt.txt", this->iot->mqttConnected() ? MSG_MQTT_CONNECTED : MSG_MQTT_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
@ -353,6 +365,7 @@ void InternalDisplay::refreshOutput()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshAC()
|
void InternalDisplay::refreshAC()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("temp.txt=\"");
|
this->displayAdapter->print("temp.txt=\"");
|
||||||
this->displayAdapter->print(this->climateCard->getTemperature());
|
this->displayAdapter->print(this->climateCard->getTemperature());
|
||||||
this->displayAdapter->print("C\"");
|
this->displayAdapter->print("C\"");
|
||||||
|
@ -378,8 +391,10 @@ void InternalDisplay::refreshAC()
|
||||||
this->displayAdapter->print("mode_cool.pic=");
|
this->displayAdapter->print("mode_cool.pic=");
|
||||||
this->displayAdapter->print(this->climateCard->getMode() == AC_MODE_COOL ? PIC_AC_MODE_COOL_ACTIVE : PIC_AC_MODE_COOL_INACTIVE);
|
this->displayAdapter->print(this->climateCard->getMode() == AC_MODE_COOL ? PIC_AC_MODE_COOL_ACTIVE : PIC_AC_MODE_COOL_INACTIVE);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
if (this->climateCard->getSensorType() == AC_SENSOR_TYPE_DHT22)
|
if (this->climateCard->getSensorType() == AC_SENSOR_TYPE_DHT22)
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("roomtemp.txt=\"");
|
this->displayAdapter->print("roomtemp.txt=\"");
|
||||||
this->displayAdapter->print(this->climateCard->getRoomTemperature());
|
this->displayAdapter->print(this->climateCard->getRoomTemperature());
|
||||||
this->displayAdapter->print("C\"");
|
this->displayAdapter->print("C\"");
|
||||||
|
@ -388,13 +403,16 @@ void InternalDisplay::refreshAC()
|
||||||
this->displayAdapter->print(this->climateCard->getHumidity());
|
this->displayAdapter->print(this->climateCard->getHumidity());
|
||||||
this->displayAdapter->print("%\"");
|
this->displayAdapter->print("%\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
else if (this->climateCard->getSensorType() == AC_SENSOR_TYPE_DS18B20)
|
else if (this->climateCard->getSensorType() == AC_SENSOR_TYPE_DS18B20)
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("roomtemp.txt=\"");
|
this->displayAdapter->print("roomtemp.txt=\"");
|
||||||
this->displayAdapter->print(this->climateCard->getRoomTemperature());
|
this->displayAdapter->print(this->climateCard->getRoomTemperature());
|
||||||
this->displayAdapter->print("C\"");
|
this->displayAdapter->print("C\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
this->setString("roomhumid.txt", "N/A");
|
this->setString("roomhumid.txt", "N/A");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -412,12 +430,14 @@ void InternalDisplay::refreshAC()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::setOutputBar(uint8_t pin, uint16_t value)
|
void InternalDisplay::setOutputBar(uint8_t pin, uint16_t value)
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// Write the value to the output bar
|
// Write the value to the output bar
|
||||||
this->displayAdapter->print("j");
|
this->displayAdapter->print("j");
|
||||||
this->displayAdapter->print(pin);
|
this->displayAdapter->print(pin);
|
||||||
this->displayAdapter->print(".val=");
|
this->displayAdapter->print(".val=");
|
||||||
this->displayAdapter->print((int)(value * 100 / 4095));
|
this->displayAdapter->print((int)(value * 100 / 4095));
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -428,11 +448,13 @@ void InternalDisplay::setOutputBar(uint8_t pin, uint16_t value)
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::setOutputStateColor(uint8_t pin, bool state)
|
void InternalDisplay::setOutputStateColor(uint8_t pin, bool state)
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("j");
|
this->displayAdapter->print("j");
|
||||||
this->displayAdapter->print(pin);
|
this->displayAdapter->print(pin);
|
||||||
this->displayAdapter->print(".ppic=");
|
this->displayAdapter->print(".ppic=");
|
||||||
this->displayAdapter->print(state ? PIC_PWM_BAR_ON : PIC_PWM_BAR_OFF);
|
this->displayAdapter->print(state ? PIC_PWM_BAR_ON : PIC_PWM_BAR_OFF);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -443,11 +465,13 @@ void InternalDisplay::setOutputStateColor(uint8_t pin, bool state)
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::setInputMarker(uint8_t pin, bool state)
|
void InternalDisplay::setInputMarker(uint8_t pin, bool state)
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("I");
|
this->displayAdapter->print("I");
|
||||||
this->displayAdapter->print(pin);
|
this->displayAdapter->print(pin);
|
||||||
this->displayAdapter->print(".val=");
|
this->displayAdapter->print(".val=");
|
||||||
this->displayAdapter->print(state ? 1 : 0);
|
this->displayAdapter->print(state ? 1 : 0);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -578,6 +602,7 @@ void InternalDisplay::refreshPWMAdjustment()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshPWMAdjustmentId()
|
void InternalDisplay::refreshPWMAdjustmentId()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// Send the PWM pin
|
// Send the PWM pin
|
||||||
this->displayAdapter->print("pwm_id.txt=\"P");
|
this->displayAdapter->print("pwm_id.txt=\"P");
|
||||||
this->displayAdapter->print(pmwAdjustmentPin);
|
this->displayAdapter->print(pmwAdjustmentPin);
|
||||||
|
@ -590,10 +615,12 @@ void InternalDisplay::refreshPWMAdjustmentId()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshPWMAdjustmentSlider()
|
void InternalDisplay::refreshPWMAdjustmentSlider()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// Send the PWM value
|
// Send the PWM value
|
||||||
this->displayAdapter->print("pwm_value.val=");
|
this->displayAdapter->print("pwm_value.val=");
|
||||||
this->displayAdapter->print(this->outputCard->getValue(this->pmwAdjustmentPin));
|
this->displayAdapter->print(this->outputCard->getValue(this->pmwAdjustmentPin));
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -601,11 +628,13 @@ void InternalDisplay::refreshPWMAdjustmentSlider()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshPWMAdjustmentState()
|
void InternalDisplay::refreshPWMAdjustmentState()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// Send the PWM state
|
// Send the PWM state
|
||||||
this->displayAdapter->print("pwm_state.txt=\"");
|
this->displayAdapter->print("pwm_state.txt=\"");
|
||||||
this->displayAdapter->print(this->outputCard->getState(this->pmwAdjustmentPin) ? MSG_PWM_ADJUSTMENT_STATE_ON : MSG_PWM_ADJUSTMENT_STATE_OFF);
|
this->displayAdapter->print(this->outputCard->getState(this->pmwAdjustmentPin) ? MSG_PWM_ADJUSTMENT_STATE_ON : MSG_PWM_ADJUSTMENT_STATE_OFF);
|
||||||
this->displayAdapter->print("\"");
|
this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -757,13 +786,13 @@ void InternalDisplay::handlePWMAdjustmentTouch(uint8_t type, uint8_t component)
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshNetworkConfig()
|
void InternalDisplay::refreshNetworkConfig()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// The network config page have the following components:
|
// The network config page have the following components:
|
||||||
// ip_set -> a text input to set the ip address
|
// ip_set -> a text input to set the ip address
|
||||||
// netmask_set -> a text input to set the netmask
|
// netmask_set -> a text input to set the netmask
|
||||||
// gateway_set -> a text input to set the gateway
|
// gateway_set -> a text input to set the gateway
|
||||||
// dns_set -> a text input to set the dns
|
// dns_set -> a text input to set the dns
|
||||||
// host_set -> a text input to set the hostname
|
// host_set -> a text input to set the hostname
|
||||||
|
|
||||||
// Refresh the ip address
|
// Refresh the ip address
|
||||||
this->displayAdapter->print("ip_set.txt=\"");
|
this->displayAdapter->print("ip_set.txt=\"");
|
||||||
this->sendIpToDisplay(this->networkConfig->ip);
|
this->sendIpToDisplay(this->networkConfig->ip);
|
||||||
|
@ -789,6 +818,7 @@ void InternalDisplay::refreshNetworkConfig()
|
||||||
this->displayAdapter->print(this->networkConfig->hostname);
|
this->displayAdapter->print(this->networkConfig->hostname);
|
||||||
this->displayAdapter->print("\"");
|
this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -796,6 +826,7 @@ void InternalDisplay::refreshNetworkConfig()
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::refreshMQTTConfig()
|
void InternalDisplay::refreshMQTTConfig()
|
||||||
{
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
// The MQTT config page have the following components:
|
// The MQTT config page have the following components:
|
||||||
// mqttsv_set -> a text input to set the mqtt server
|
// mqttsv_set -> a text input to set the mqtt server
|
||||||
// port_set -> a text input to set the mqtt port
|
// port_set -> a text input to set the mqtt port
|
||||||
|
@ -832,12 +863,14 @@ void InternalDisplay::refreshMQTTConfig()
|
||||||
this->displayAdapter->print("use_auth.val=");
|
this->displayAdapter->print("use_auth.val=");
|
||||||
this->displayAdapter->print(this->mqttConfig->mqtt_useauth ? 1 : 0);
|
this->displayAdapter->print(this->mqttConfig->mqtt_useauth ? 1 : 0);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write an ip address to the display
|
* @brief Write an ip address to the display
|
||||||
*
|
*
|
||||||
* @note This function only writes the ip address to the display, you need to send the prefix and suffix yourself
|
* @note This function only writes the ip address to the display, you need to send the prefix and suffix yourself
|
||||||
|
* @warning This function does not take the serial mutex, you need to take it yourself
|
||||||
*
|
*
|
||||||
* @param ip The ip address to send
|
* @param ip The ip address to send
|
||||||
*/
|
*/
|
||||||
|
@ -878,9 +911,12 @@ void InternalDisplay::handleACStateChange(uint8_t mode, uint8_t fan_speed, uint8
|
||||||
*
|
*
|
||||||
* @param text The text to set
|
* @param text The text to set
|
||||||
*/
|
*/
|
||||||
void InternalDisplay::setBootStatus(const char *text) {
|
void InternalDisplay::setBootStatus(const char *text)
|
||||||
|
{
|
||||||
|
if(!this->takeSerialMutex()) return;
|
||||||
this->displayAdapter->print("boot_state.txt=\"");
|
this->displayAdapter->print("boot_state.txt=\"");
|
||||||
this->displayAdapter->print(text);
|
this->displayAdapter->print(text);
|
||||||
this->displayAdapter->print("\"");
|
this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
this->giveSerialMutex();
|
||||||
}
|
}
|
Loading…
Reference in New Issue