cleanup debug prints

This commit is contained in:
Siwat Sirichai 2023-11-30 19:46:58 +07:00
parent 62f774964d
commit ef43526d2c
1 changed files with 24 additions and 23 deletions

View File

@ -579,9 +579,12 @@ void mqtt_connect()
publish_ac_state(); publish_ac_state();
#endif #endif
mqtt_connected_user_callback(); mqtt_connected_user_callback();
#ifdef ENABLE_ANALOG_MODULE
publish_dac_states(); publish_dac_states();
publish_dac_values(); publish_dac_values();
publish_adc_values(); publish_adc_values();
publish_adc_states();
#endif
standalone = false; standalone = false;
ESPMega_updateTimeFromNTP(); ESPMega_updateTimeFromNTP();
} }
@ -1007,9 +1010,12 @@ void state_request_callback()
publish_env_state(); publish_env_state();
#endif #endif
user_state_request_callback(); user_state_request_callback();
#ifdef ENABLE_ANALOG_MODULE
publish_adc_states();
publish_adc_values(); publish_adc_values();
publish_dac_states(); publish_dac_states();
publish_dac_values(); publish_dac_values();
#endif
} }
#ifdef ENABLE_IR_MODULE #ifdef ENABLE_IR_MODULE
@ -1846,7 +1852,6 @@ void enable_adc(int id)
adc_report_enable[id] = true; adc_report_enable[id] = true;
ESPMega_FRAM.write8(EEPROM_ADDRESS_ADC_REPORT_STATE + id, 1); ESPMega_FRAM.write8(EEPROM_ADDRESS_ADC_REPORT_STATE + id, 1);
publish_adc_state(id); publish_adc_state(id);
Serial.println("ADC " + String(id) + " enabled.");
} }
/** /**
* @brief Disables the ADC reporting for the specified ID. * @brief Disables the ADC reporting for the specified ID.
@ -1860,7 +1865,6 @@ void disable_adc(int id)
adc_report_enable[id] = false; adc_report_enable[id] = false;
ESPMega_FRAM.write8(EEPROM_ADDRESS_ADC_REPORT_STATE + id, 0); ESPMega_FRAM.write8(EEPROM_ADDRESS_ADC_REPORT_STATE + id, 0);
publish_adc_state(id); publish_adc_state(id);
Serial.println("ADC " + String(id) + " disabled.");
} }
void publish_adc_state(int id) void publish_adc_state(int id)
@ -1889,7 +1893,6 @@ void adc_update(int id)
{ {
adc_values[id] = ESPMega_analogRead(id); adc_values[id] = ESPMega_analogRead(id);
} }
} }
/** /**
@ -1902,7 +1905,6 @@ void adc_update_force(int id)
adc_values[id] = ESPMega_analogRead(id); adc_values[id] = ESPMega_analogRead(id);
} }
/** /**
* @brief Updates all ADC channels. * @brief Updates all ADC channels.
* *
@ -1964,7 +1966,8 @@ void publish_dac_state(int id)
mqtt.publish(DAC_STATE_TOPIC, dac_states[id] ? "on" : "off"); mqtt.publish(DAC_STATE_TOPIC, dac_states[id] ? "on" : "off");
} }
void publish_dac_value(int id) { void publish_dac_value(int id)
{
DAC_VALUE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0'; DAC_VALUE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0';
DAC_VALUE_TOPIC[base_topic_length + 5] = (id % 10) + '0'; DAC_VALUE_TOPIC[base_topic_length + 5] = (id % 10) + '0';
char temp[6]; char temp[6];
@ -2001,11 +2004,9 @@ uint16_t get_adc_value(int id)
*/ */
void adc_set_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) void adc_set_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length)
{ {
Serial.println(topic);
int a = topic[5] - '0'; int a = topic[5] - '0';
int b = topic[6] - '0'; int b = topic[6] - '0';
int id = 10 * a + b; int id = 10 * a + b;
Serial.println("ID = "+String(id));
if (!strcmp(payload, "on")) if (!strcmp(payload, "on"))
{ {
enable_adc(id); enable_adc(id);