Merge remote-tracking branch 'origin/master-v4.3' into master-v4.3

This commit is contained in:
Sebastien L
2022-01-27 20:57:14 -05:00
8 changed files with 45 additions and 57 deletions

View File

@@ -157,7 +157,7 @@ esp_err_t actrls_init(const char *profile_name) {
// set infrared GPIO if any
parse_set_GPIO(set_ir_gpio);
if (!err) return actrls_init_json(profile_name, true);
else return err;
}
@@ -508,11 +508,10 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
char *config;
const cJSON *button;
if (!profile_name || !*profile_name) return ESP_OK;
config = config_alloc_get_default(NVS_TYPE_STR, profile_name, NULL, 0);
if(!config) return ESP_FAIL;
if (!profile_name) return ESP_OK;
if ((config = config_alloc_get_str(profile_name, NULL, CONFIG_AUDIO_CONTROLS)) == NULL) return ESP_FAIL;
if (!*config) goto exit;
ESP_LOGD(TAG,"Parsing JSON structure %s", config);
cJSON *buttons = cJSON_Parse(config);
if (buttons == NULL) {
@@ -526,7 +525,8 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
if(!cur_config) {
ESP_LOGE(TAG,"Config buffer was empty. ");
cJSON_Delete(buttons);
return ESP_FAIL;
err = ESP_FAIL;
goto exit;
}
ESP_LOGD(TAG,"Processing button definitions. ");
cJSON_ArrayForEach(button, buttons){
@@ -557,6 +557,8 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
// the last init that completes will assigh the first json config object found, which will match
// the default config from nvs.
json_config = config_root;
exit:
free(config);
return err;
}

View File

@@ -316,7 +316,7 @@ static __inline Word64 xSAR64(Word64 x, int n)
}
//mw
#elif defined(__APPLE__) || defined(ESP_PLATFORM) || defined(__x86_64__)
#elif defined(__APPLE__) || defined(ESP_PLATFORM) || defined(__amd64__)
static __inline int FASTABS(int x)
{

View File

@@ -67,7 +67,9 @@
#
#elif defined(__GNUC__) && defined(__thumb__)
#
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#elif defined(__GNUC__) && defined(__i386__)
#
#elif defined(__amd64__)
#
#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
#

View File

@@ -46,58 +46,43 @@ static const char TAG[] = "muse";
static void (*battery_handler_chain)(float value);
static void battery_svc(float value);
static bool init(void);
static void set_battery_led(float value);
const struct target_s target_muse = { "muse", init };
const struct target_s target_muse = { .model = "muse", .init = init };
static bool init(void) {
battery_handler_chain = battery_handler_svc;
battery_handler_svc = battery_svc;
ESP_LOGI(TAG, "Initializing for Muse");
ws2812_control_init();
float value = battery_value_svc();
set_battery_led(value);
ESP_LOGI(TAG, "Initializing for Muse %f", value);
return true;
}
#define VGREEN 4.0
#define VRED 3.6
static void set_battery_led(float value) {
struct led_state new_state;
if (value > VGREEN) new_state.leds[0] = GREEN;
else if (value < VRED) new_state.leds[0] = RED;
else new_state.leds[0] = YELLOW;
ws2812_write_leds(new_state);
}
static void battery_svc(float value) {
set_battery_led(value);
ESP_LOGI(TAG, "Called for battery service with %f", value);
// put here your code for LED according to value
if (battery_handler_chain) battery_handler_chain(value);
}
// Battery monitoring
/*
static void battery(void *data)
{
#define VGREEN 2300
#define VRED 2000
#define NM 10
static int val;
static int V[NM];
static int I=0;
int S;
for(int i=0;i<NM;i++)V[i]=VGREEN;
vTaskDelay(1000 / portTICK_PERIOD_MS);
struct led_state new_state;
ws2812_control_init();
// init ADC interface for battery survey
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ADC1_GPIO33_CHANNEL, ADC_ATTEN_DB_11);
while(true)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
V[I++] = adc1_get_raw(ADC1_GPIO33_CHANNEL);
if(I >= NM)I = 0;
S = 0;
for(int i=0;i<NM;i++)S = S + V[i];
val = S / NM;
new_state.leds[0] = YELLOW;
if(val > VGREEN) new_state.leds[0] = GREEN;
if(val < VRED) new_state.leds[0] = RED;
printf("====> %d %6x\n", val, new_state.leds[0]);
ws2812_write_leds(new_state);
}
}
*/
// This is the buffer which the hw peripheral will access while pulsing the output pin
rmt_item32_t led_data_buffer[LED_BUFFER_ITEMS];
@@ -139,5 +124,5 @@ void setup_rmt_data_buffer(struct led_state new_state)
mask >>= 1;
}
}
}
}

View File

@@ -4,7 +4,7 @@
const struct target_s *target_set[] = { &target_muse, NULL };
void target_init(char *target) {
for (int i = 0; target_set[i]; i++) if (strcasestr(target_set[i]->model, target)) {
for (int i = 0; *target && target_set[i]; i++) if (strcasestr(target_set[i]->model, target)) {
target_set[i]->init();
break;
}