Merge branch 'main' into ise
This commit is contained in:
commit
0c0e4b6af7
|
@ -1866,6 +1866,11 @@ void disable_adc(int id)
|
||||||
publish_adc_state(id);
|
publish_adc_state(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publishes the state of an ADC (Analog-to-Digital Converter) to the MQTT broker.
|
||||||
|
*
|
||||||
|
* @param id The ID of the ADC.
|
||||||
|
*/
|
||||||
void publish_adc_state(int id)
|
void publish_adc_state(int id)
|
||||||
{
|
{
|
||||||
ADC_STATE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0';
|
ADC_STATE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0';
|
||||||
|
@ -1873,6 +1878,11 @@ void publish_adc_state(int id)
|
||||||
mqtt.publish(ADC_STATE_TOPIC, adc_report_enable[id] ? "on" : "off");
|
mqtt.publish(ADC_STATE_TOPIC, adc_report_enable[id] ? "on" : "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Publishes the ADC states.
|
||||||
|
*
|
||||||
|
* This function iterates over the ADC channels and publishes the state of each channel.
|
||||||
|
*/
|
||||||
void publish_adc_states()
|
void publish_adc_states()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ADC_COUNT; i++)
|
for (int i = 0; i < ADC_COUNT; i++)
|
||||||
|
@ -1958,6 +1968,11 @@ void publish_adc_values()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publishes the state of a DAC (Digital-to-Analog Converter) to the MQTT broker.
|
||||||
|
*
|
||||||
|
* @param id The ID of the DAC.
|
||||||
|
*/
|
||||||
void publish_dac_state(int id)
|
void publish_dac_state(int id)
|
||||||
{
|
{
|
||||||
DAC_STATE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0';
|
DAC_STATE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0';
|
||||||
|
@ -1965,6 +1980,11 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publishes the DAC value for a given ID.
|
||||||
|
*
|
||||||
|
* @param id The ID of the DAC value to publish.
|
||||||
|
*/
|
||||||
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';
|
||||||
|
@ -2052,6 +2072,13 @@ void dac_set_state(int id, bool state)
|
||||||
publish_dac_state(id);
|
publish_dac_state(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Publishes the states of all DACs.
|
||||||
|
*
|
||||||
|
* This function iterates through all DACs and publishes their states.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void publish_dac_states()
|
void publish_dac_states()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < DAC_COUNT; i++)
|
for (int i = 0; i < DAC_COUNT; i++)
|
||||||
|
@ -2060,6 +2087,13 @@ void publish_dac_states()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Publishes the DAC values.
|
||||||
|
*
|
||||||
|
* This function iterates through all the DAC channels and publishes their values.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void publish_dac_values()
|
void publish_dac_values()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < DAC_COUNT; i++)
|
for (int i = 0; i < DAC_COUNT; i++)
|
||||||
|
@ -2109,4 +2143,46 @@ void dac_set_state_callback(char *topic, uint8_t topic_length, char *payload, un
|
||||||
dac_set_state(id, false);
|
dac_set_state(id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ADC value for the specified ID.
|
||||||
|
*
|
||||||
|
* @param id The ID of the ADC channel.
|
||||||
|
* @return The ADC value.
|
||||||
|
*/
|
||||||
|
uint16_t adc_get_value(int id)
|
||||||
|
{
|
||||||
|
return adc_values[id];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the state of the ADC with the specified ID.
|
||||||
|
*
|
||||||
|
* @param id The ID of the ADC.
|
||||||
|
* @return true if the ADC is enabled, false otherwise.
|
||||||
|
*/
|
||||||
|
bool adc_get_state(int id)
|
||||||
|
{
|
||||||
|
return adc_report_enable[id];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value of a DAC channel.
|
||||||
|
*
|
||||||
|
* @param id The ID of the DAC channel.
|
||||||
|
* @return The value of the DAC channel.
|
||||||
|
*/
|
||||||
|
uint16_t dac_get_value(int id)
|
||||||
|
{
|
||||||
|
return dac_values[id];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the state of the DAC with the specified ID.
|
||||||
|
*
|
||||||
|
* @param id The ID of the DAC.
|
||||||
|
* @return The state of the DAC.
|
||||||
|
*/
|
||||||
|
bool dac_get_state(int id)
|
||||||
|
{
|
||||||
|
return dac_states[id];
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -152,4 +152,8 @@ void publish_dac_state(int id);
|
||||||
void publish_dac_values();
|
void publish_dac_values();
|
||||||
void publish_dac_states();
|
void publish_dac_states();
|
||||||
void publish_adc_state(int id);
|
void publish_adc_state(int id);
|
||||||
void publish_adc_states();
|
void publish_adc_states();
|
||||||
|
uint16_t adc_get_value(int id);
|
||||||
|
bool adc_get_state(int id);
|
||||||
|
uint16_t dac_get_value(int id);
|
||||||
|
bool dac_get_state(int id);
|
|
@ -41,18 +41,20 @@
|
||||||
#define ANALOG_REPORTING_INTERVAL 500
|
#define ANALOG_REPORTING_INTERVAL 500
|
||||||
|
|
||||||
// User Defined Functions
|
// User Defined Functions
|
||||||
|
void timer1_callback();
|
||||||
|
void bt0PopCallback(void *ptr);
|
||||||
|
|
||||||
|
// User Defined IoT Core Callback Functions (Required)
|
||||||
|
void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
||||||
|
void user_state_request_callback();
|
||||||
|
void mqtt_connected_user_callback();
|
||||||
void user_pre_init();
|
void user_pre_init();
|
||||||
void user_init();
|
void user_init();
|
||||||
void user_loop();
|
void user_loop();
|
||||||
void virtual_interrupt_user_callback(int pin, int state);
|
|
||||||
void pwm_changed_user_callback(int pin);
|
void pwm_changed_user_callback(int pin);
|
||||||
void ac_changed_user_callback(int mode, int temperature, int fan_speed);
|
void ac_changed_user_callback(int mode, int temperature, int fan_speed);
|
||||||
void timer_tick_callback();
|
void timer_tick_callback();
|
||||||
void timer1_callback();
|
void virtual_interrupt_user_callback(int pin, int state);
|
||||||
void mqtt_connected_user_callback();
|
|
||||||
void bt0PopCallback(void *ptr);
|
|
||||||
void user_state_request_callback();
|
|
||||||
void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
|
||||||
|
|
||||||
// ESPMega IoT Core Build-in Functions
|
// ESPMega IoT Core Build-in Functions
|
||||||
extern void pwm_set_state(int id, int state);
|
extern void pwm_set_state(int id, int state);
|
||||||
|
@ -64,9 +66,26 @@ extern bool pwm_get_state(int id);
|
||||||
extern uint16_t pwm_get_value(int id);
|
extern uint16_t pwm_get_value(int id);
|
||||||
extern boolean pwm_group_state(int id1, int id2);
|
extern boolean pwm_group_state(int id1, int id2);
|
||||||
extern bool input_get_state(int id);
|
extern bool input_get_state(int id);
|
||||||
|
extern bool standalone;
|
||||||
|
extern PubSubClient mqtt;
|
||||||
|
|
||||||
|
// IR Kit Build-in Functions
|
||||||
|
#ifdef ENABLE_IR_MODULE
|
||||||
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
||||||
extern uint8_t ac_get_temperature();
|
extern uint8_t ac_get_temperature();
|
||||||
extern uint8_t ac_get_mode();
|
extern uint8_t ac_get_mode();
|
||||||
extern uint8_t ac_get_fan_speed();
|
extern uint8_t ac_get_fan_speed();
|
||||||
extern bool standalone;
|
#endif
|
||||||
extern PubSubClient mqtt;
|
|
||||||
|
//Analog Expansion Card Build-in Functions
|
||||||
|
#ifdef ENABLE_ANALOG_MODULE
|
||||||
|
extern void dac_set_value(int id, int value);
|
||||||
|
extern void dac_set_state(int id, bool state);
|
||||||
|
extern void enable_adc(int id);
|
||||||
|
extern void disable_adc(int id);
|
||||||
|
extern void enable_dac(int id);
|
||||||
|
extern uint16_t adc_get_value(int id);
|
||||||
|
extern bool adc_get_state(int id);
|
||||||
|
extern uint16_t dac_get_value(int id);
|
||||||
|
extern bool dac_get_state(int id);
|
||||||
|
#endif
|
Loading…
Reference in New Issue