Skip to content

Commit

Permalink
fixed config show and select, and automaticly go to c0 when cc has ch…
Browse files Browse the repository at this point in the history
…anged config
  • Loading branch information
Anton-Augustsson committed May 22, 2023
1 parent 893d0eb commit 3b75f12
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions base-station/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,19 @@ void led_selected_mode_on(base_station_mode_t mode) {
void leds_show_config() {
leds_show_off();

if ((config.val1 & DISABLE_CLIMATE) == 0) {
if ((config.val1 & DISABLE_MOTION) == 0) {
gpio_pin_set_dt(&led_show0, 1);
}

if ((config.val1 & DISABLE_SOUND) == 0) {
if ((config.val1 & DISABLE_CLIMATE) == 0) {
gpio_pin_set_dt(&led_show1, 1);
}

if ((config.val1 & DISABLE_MOTION) == 0) {
if ((config.val1 & DISABLE_SOUND) == 0) {
gpio_pin_set_dt(&led_show2, 1);
}


}

/* Turn on show LEDs that correspond to each visual_select.
Expand Down Expand Up @@ -494,7 +496,7 @@ void enter_state_c1(void) {
void exit_state_c1(void) {
printk("Exiting Toggle climate\n");
leds_off();
set_get_prev_config_state(sound_state);
set_get_prev_config_state(climate_state);
}

const state_t state_c1 = {
Expand Down Expand Up @@ -540,21 +542,24 @@ void do_state_cc(void) {
led_selected_mode_on(config_mode);
prev_config_state_t prev_config_state = set_get_prev_config_state(configure_state);

if (prev_config_state == sound_state) {
if (prev_config_state == motion_state) {
k_mutex_lock(&config_lock, K_FOREVER);
config.val1 ^= DISABLE_CLIMATE;
config.val1 ^= DISABLE_MOTION;
update_conf = 1;
k_mutex_unlock(&config_lock);
k_sem_give(&select_btn_sem);
} else if (prev_config_state == climate_state) {
k_mutex_lock(&config_lock, K_FOREVER);
config.val1 ^= DISABLE_SOUND;
config.val1 ^= DISABLE_CLIMATE;
update_conf = 1;
k_mutex_unlock(&config_lock);
} else if (prev_config_state == motion_state) {
k_sem_give(&select_btn_sem);
} else if (prev_config_state == sound_state) {
k_mutex_lock(&config_lock, K_FOREVER);
config.val1 ^= DISABLE_MOTION;
config.val1 ^= DISABLE_SOUND;
update_conf = 1;
k_mutex_unlock(&config_lock);
k_sem_give(&select_btn_sem);
}

leds_show_config();
Expand Down

0 comments on commit 3b75f12

Please sign in to comment.