s/led_green/led_status/g because not all status leds are green :)

This commit is contained in:
Pim van Pelt
2018-01-22 23:23:43 +01:00
parent 3327a561f9
commit f0fa04dc26
4 changed files with 12 additions and 12 deletions

View File

@ -19,7 +19,7 @@ struct channel_t {
double button_last_change; double button_last_change;
}; };
void led_green_blink(); void led_status_blink();
bool channel_init(const char *fn); bool channel_init(const char *fn);
uint8_t channel_gpio_by_idx(int idx); uint8_t channel_gpio_by_idx(int idx);

View File

@ -138,7 +138,7 @@ void channel_report(int idx, char *msg, int msg_len) {
if (idx<0 || idx>=channel_get_total()) if (idx<0 || idx>=channel_get_total())
return; return;
snprintf(msg, msg_len-1, "{\"idx\": %d, \"button_gpio\": %d, \"led_gpio\": %d, \"relay_gpio\": %d, \"relay_state\": %d}", snprintf(msg, msg_len-1, "{idx: %d, button_gpio: %d, led_gpio: %d, relay_gpio: %d, relay_state: %d}",
idx, s_channels[idx].button_gpio, s_channels[idx].led_gpio, s_channels[idx].relay_gpio, s_channels[idx].relay_state); idx, s_channels[idx].button_gpio, s_channels[idx].led_gpio, s_channels[idx].relay_gpio, s_channels[idx].relay_state);
} }

View File

@ -1,20 +1,20 @@
#include "main.h" #include "main.h"
static mgos_timer_id led_green_timer_id = 0; static mgos_timer_id led_status_timer_id = 0;
static void led_green_off_cb(void *arg) { static void led_status_off_cb(void *arg) {
mgos_gpio_write(GREEN_LED_GPIO, 0); mgos_gpio_write(GREEN_LED_GPIO, 0);
led_green_timer_id=0; led_status_timer_id=0;
(void) arg; (void) arg;
} }
void led_green_blink() { void led_status_blink() {
mgos_gpio_write(GREEN_LED_GPIO, 1); mgos_gpio_write(GREEN_LED_GPIO, 1);
if (led_green_timer_id) { if (led_status_timer_id) {
mgos_clear_timer(led_green_timer_id); mgos_clear_timer(led_status_timer_id);
led_green_timer_id=0; led_status_timer_id=0;
} }
led_green_timer_id = mgos_set_timer(100, false, led_green_off_cb, NULL); led_status_timer_id = mgos_set_timer(100, false, led_status_off_cb, NULL);
} }

View File

@ -7,7 +7,7 @@
static void mqtt_publish_broadcast_stat(const char *stat, const char *msg) { static void mqtt_publish_broadcast_stat(const char *stat, const char *msg) {
char topic[80]; char topic[80];
led_green_blink(); led_status_blink();
snprintf(topic, sizeof(topic)-1, "%s/%s", MQTT_TOPIC_BROADCAST_STAT, stat); snprintf(topic, sizeof(topic)-1, "%s/%s", MQTT_TOPIC_BROADCAST_STAT, stat);
mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false); mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false);
@ -62,7 +62,7 @@ static void mqtt_ev(struct mg_connection *nc, int ev, void *ev_data, void *user_
void mqtt_publish_stat(const char *stat, const char *msg) { void mqtt_publish_stat(const char *stat, const char *msg) {
char topic[80]; char topic[80];
led_green_blink(); led_status_blink();
snprintf(topic, sizeof(topic)-1, "%s%s/stat/%s", MQTT_TOPIC_PREFIX, mgos_sys_config_get_device_id(), stat); snprintf(topic, sizeof(topic)-1, "%s%s/stat/%s", MQTT_TOPIC_PREFIX, mgos_sys_config_get_device_id(), stat);
mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false); mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false);