Added RGB Led luminosity parameter

This commit is contained in:
Charles 2018-03-31 23:30:32 +02:00
parent 3a8a0dcb65
commit fb3d63483b

View File

@ -31,6 +31,8 @@ void defaultConfig() {
cfg.blescancycle = BLESCANTIME; // BLE scan cycle [seconds] cfg.blescancycle = BLESCANTIME; // BLE scan cycle [seconds]
cfg.blescan = 0; // 0=disabled, 1=enabled cfg.blescan = 0; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0 100%)
strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 ); strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 );
} }
@ -112,6 +114,9 @@ void saveConfig() {
if( nvs_get_i8(my_handle, "wifiant", &flash8) != ESP_OK || flash8 != cfg.wifiant ) if( nvs_get_i8(my_handle, "wifiant", &flash8) != ESP_OK || flash8 != cfg.wifiant )
nvs_set_i8(my_handle, "wifiant", cfg.wifiant); nvs_set_i8(my_handle, "wifiant", cfg.wifiant);
if( nvs_get_i8(my_handle, "rgblum", &flash8) != ESP_OK || flash8 != cfg.rgblum )
nvs_set_i8(my_handle, "rgblum", cfg.rgblum);
if( nvs_get_i16(my_handle, "rssilimit", &flash16) != ESP_OK || flash16 != cfg.rssilimit ) if( nvs_get_i16(my_handle, "rssilimit", &flash16) != ESP_OK || flash16 != cfg.rssilimit )
nvs_set_i16(my_handle, "rssilimit", cfg.rssilimit); nvs_set_i16(my_handle, "rssilimit", cfg.rssilimit);
@ -236,6 +241,14 @@ void loadConfig() {
saveConfig(); saveConfig();
} }
if( nvs_get_i8(my_handle, "rgblum", &flash8) == ESP_OK ) {
cfg.rgblum = flash8;
ESP_LOGI(TAG, "rgbluminosity = %i", flash8);
} else {
ESP_LOGI(TAG, "RGB luminosity set to default %i", cfg.rgblum);
saveConfig();
}
if( nvs_get_i8(my_handle, "blescancycle", &flash8) == ESP_OK ) { if( nvs_get_i8(my_handle, "blescancycle", &flash8) == ESP_OK ) {
cfg.blescancycle = flash8; cfg.blescancycle = flash8;
ESP_LOGI(TAG, "blescancycle = %i", flash8); ESP_LOGI(TAG, "blescancycle = %i", flash8);