Nextion - Standardizing log messages (#5837)

This commit is contained in:
Edward Firmo 2023-11-27 22:09:57 +01:00 committed by GitHub
parent 019315afa0
commit 460362b11f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -433,8 +433,10 @@ void Nextion::process_nextion_commands_() {
uint8_t page_id = to_process[0]; uint8_t page_id = to_process[0];
uint8_t component_id = to_process[1]; uint8_t component_id = to_process[1];
uint8_t touch_event = to_process[2]; // 0 -> release, 1 -> press uint8_t touch_event = to_process[2]; // 0 -> release, 1 -> press
ESP_LOGD(TAG, "Got touch page=%u component=%u type=%s", page_id, component_id, ESP_LOGD(TAG, "Got touch event:");
touch_event ? "PRESS" : "RELEASE"); ESP_LOGD(TAG, " page_id: %u", page_id);
ESP_LOGD(TAG, " component_id: %u", component_id);
ESP_LOGD(TAG, " event type: %s", touch_event ? "PRESS" : "RELEASE");
for (auto *touch : this->touch_) { for (auto *touch : this->touch_) {
touch->process_touch(page_id, component_id, touch_event != 0); touch->process_touch(page_id, component_id, touch_event != 0);
} }
@ -448,7 +450,7 @@ void Nextion::process_nextion_commands_() {
} }
uint8_t page_id = to_process[0]; uint8_t page_id = to_process[0];
ESP_LOGD(TAG, "Got new page=%u", page_id); ESP_LOGD(TAG, "Got new page: %u", page_id);
this->page_callback_.call(page_id); this->page_callback_.call(page_id);
break; break;
} }
@ -466,7 +468,10 @@ void Nextion::process_nextion_commands_() {
uint16_t x = (uint16_t(to_process[0]) << 8) | to_process[1]; uint16_t x = (uint16_t(to_process[0]) << 8) | to_process[1];
uint16_t y = (uint16_t(to_process[2]) << 8) | to_process[3]; uint16_t y = (uint16_t(to_process[2]) << 8) | to_process[3];
uint8_t touch_event = to_process[4]; // 0 -> release, 1 -> press uint8_t touch_event = to_process[4]; // 0 -> release, 1 -> press
ESP_LOGD(TAG, "Got touch at x=%u y=%u type=%s", x, y, touch_event ? "PRESS" : "RELEASE"); ESP_LOGD(TAG, "Got touch event:");
ESP_LOGD(TAG, " x: %u", x);
ESP_LOGD(TAG, " y: %u", y);
ESP_LOGD(TAG, " type: %s", touch_event ? "PRESS" : "RELEASE");
break; break;
} }
@ -588,7 +593,9 @@ void Nextion::process_nextion_commands_() {
variable_name = to_process.substr(0, index); variable_name = to_process.substr(0, index);
++index; ++index;
ESP_LOGN(TAG, "Got Switch variable_name=%s value=%d", variable_name.c_str(), to_process[0] != 0); ESP_LOGN(TAG, "Got Switch:");
ESP_LOGN(TAG, " variable_name: %s", variable_name.c_str());
ESP_LOGN(TAG, " value: %d", to_process[0] != 0);
for (auto *switchtype : this->switchtype_) { for (auto *switchtype : this->switchtype_) {
switchtype->process_bool(variable_name, to_process[index] != 0); switchtype->process_bool(variable_name, to_process[index] != 0);
@ -619,7 +626,9 @@ void Nextion::process_nextion_commands_() {
value += to_process[i + index + 1] << (8 * i); value += to_process[i + index + 1] << (8 * i);
} }
ESP_LOGN(TAG, "Got sensor variable_name=%s value=%d", variable_name.c_str(), value); ESP_LOGN(TAG, "Got sensor:");
ESP_LOGN(TAG, " variable_name: %s", variable_name.c_str());
ESP_LOGN(TAG, " value: %d", value);
for (auto *sensor : this->sensortype_) { for (auto *sensor : this->sensortype_) {
sensor->process_sensor(variable_name, value); sensor->process_sensor(variable_name, value);
@ -651,7 +660,9 @@ void Nextion::process_nextion_commands_() {
text_value = to_process.substr(index); text_value = to_process.substr(index);
ESP_LOGN(TAG, "Got Text Sensor variable_name=%s value=%s", variable_name.c_str(), text_value.c_str()); ESP_LOGN(TAG, "Got Text Sensor:");
ESP_LOGN(TAG, " variable_name: %s", variable_name.c_str());
ESP_LOGN(TAG, " value: %s", text_value.c_str());
// NextionTextSensorResponseQueue *nq = new NextionTextSensorResponseQueue; // NextionTextSensorResponseQueue *nq = new NextionTextSensorResponseQueue;
// nq->variable_name = variable_name; // nq->variable_name = variable_name;
@ -682,7 +693,9 @@ void Nextion::process_nextion_commands_() {
variable_name = to_process.substr(0, index); variable_name = to_process.substr(0, index);
++index; ++index;
ESP_LOGN(TAG, "Got Binary Sensor variable_name=%s value=%d", variable_name.c_str(), to_process[index] != 0); ESP_LOGN(TAG, "Got Binary Sensor:");
ESP_LOGN(TAG, " variable_name: %s", variable_name.c_str());
ESP_LOGN(TAG, " value: %d", to_process[index] != 0);
for (auto *binarysensortype : this->binarysensortype_) { for (auto *binarysensortype : this->binarysensortype_) {
binarysensortype->process_bool(&variable_name[0], to_process[index] != 0); binarysensortype->process_bool(&variable_name[0], to_process[index] != 0);
@ -772,7 +785,10 @@ void Nextion::set_nextion_sensor_state(int queue_type, const std::string &name,
} }
void Nextion::set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state) { void Nextion::set_nextion_sensor_state(NextionQueueType queue_type, const std::string &name, float state) {
ESP_LOGN(TAG, "Received state for variable %s, state %lf for queue type %d", name.c_str(), state, queue_type); ESP_LOGN(TAG, "Received state:");
ESP_LOGN(TAG, " variable: %s", name.c_str());
ESP_LOGN(TAG, " state: %lf", state);
ESP_LOGN(TAG, " queue type: %d", queue_type);
switch (queue_type) { switch (queue_type) {
case NextionQueueType::SENSOR: { case NextionQueueType::SENSOR: {
@ -809,7 +825,9 @@ void Nextion::set_nextion_sensor_state(NextionQueueType queue_type, const std::s
} }
void Nextion::set_nextion_text_state(const std::string &name, const std::string &state) { void Nextion::set_nextion_text_state(const std::string &name, const std::string &state) {
ESP_LOGD(TAG, "Received state for variable %s, state %s", name.c_str(), state.c_str()); ESP_LOGD(TAG, "Received state:");
ESP_LOGD(TAG, " variable: %s", name.c_str());
ESP_LOGD(TAG, " state: %s", state.c_str());
for (auto *sensor : this->textsensortype_) { for (auto *sensor : this->textsensortype_) {
if (name == sensor->get_variable_name()) { if (name == sensor->get_variable_name()) {