Skip to content

Commit

Permalink
add locked state for led_vu
Browse files Browse the repository at this point in the history
  • Loading branch information
wizmo2 committed Sep 28, 2023
1 parent 580a9c6 commit 07f932a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
1 change: 0 additions & 1 deletion components/platform_console/app_recovery/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
extern void register_ledvu_config(void);

void register_optional_cmd(void) {
register_ledvu_config();
}

int main(int argc, char **argv){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ extern void register_ledvu_config(void);

void register_optional_cmd(void) {
register_rotary_config();
register_ledvu_config();
register_audio_config();
}

Expand Down
9 changes: 9 additions & 0 deletions components/platform_console/cmd_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,12 @@ static int do_cspot_config(int argc, char **argv){

static int do_ledvu_cmd(int argc, char **argv){
ledvu_struct_t ledvu={ .type = "WS2812", .gpio = -1, .length = 0, .clk = -1};

if(is_ledvu_config_locked()) {
cmd_send_messaging(argv[0],MESSAGING_ERROR,"LED Strip Configuration is locked on this platform\n");
return 1;
}

esp_err_t err=ESP_OK;
int nerrors = arg_parse(argc, argv,(void **)&ledvu_args);
if (ledvu_args.clear->count) {
Expand Down Expand Up @@ -1500,6 +1506,9 @@ void register_config_cmd(void){
if(!is_spdif_config_locked()){
register_spdif_config();
}
if (is_ledvu_config_locked()){
register_ledvu_config();
}
register_optional_cmd();
}

17 changes: 15 additions & 2 deletions components/services/accessors.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ bool is_spdif_config_locked(){
return false;
}

/****************************************************************************************
*
*/
bool is_ledvu_config_locked(){
#if ( defined CONFIG_LED_VU_CONFIG )
if(strlen(CONFIG_LED_VU_CONFIG) > 0){
return true;
}
#endif
return false;
}


/****************************************************************************************
* Set pin from config string
*/
Expand Down Expand Up @@ -983,9 +996,9 @@ cJSON * get_ledvu_GPIO(cJSON * list){
cJSON * llist = list?list:cJSON_CreateArray();

const ledvu_struct_t *ledvu= config_ledvu_get();
add_gpio_for_value(llist,"gpio",ledvu->gpio, "led_vu", false);
add_gpio_for_value(llist,"gpio",ledvu->gpio, "led_vu", is_ledvu_config_locked());
if (ledvu->clk >= 0)
add_gpio_for_value(llist,"clk",ledvu->clk, "led_vu", false);
add_gpio_for_value(llist,"clk",ledvu->clk, "led_vu", is_ledvu_config_locked());
return llist;
}

Expand Down
3 changes: 2 additions & 1 deletion components/services/accessors.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ bool are_statistics_enabled();
const rotary_struct_t * config_rotary_get();
esp_err_t config_rotary_set(rotary_struct_t * rotary);
const ledvu_struct_t * config_ledvu_get();
esp_err_t config_ledvu_set(ledvu_struct_t * ledvu);
esp_err_t config_ledvu_set(ledvu_struct_t * ledvu);
bool is_ledvu_config_locked();

0 comments on commit 07f932a

Please sign in to comment.