mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
finish remapping
- actrls_brd config renamed actrls_config - get rid of static board definitions - allow JSON config string to only initialize what it needs - add control_hook
This commit is contained in:
@@ -78,6 +78,7 @@ static void * malloc_fn(size_t sz){
|
|||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static void * free_fn(void * ptr){
|
static void * free_fn(void * ptr){
|
||||||
if(ptr!=NULL){
|
if(ptr!=NULL){
|
||||||
heap_caps_free(ptr);
|
heap_caps_free(ptr);
|
||||||
@@ -87,6 +88,7 @@ static void * free_fn(void * ptr){
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
void init_cJSON(){
|
void init_cJSON(){
|
||||||
static cJSON_Hooks hooks;
|
static cJSON_Hooks hooks;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ const static actrls_t controls = {
|
|||||||
|
|
||||||
/* taking/giving audio system's control */
|
/* taking/giving audio system's control */
|
||||||
void bt_master(bool on) {
|
void bt_master(bool on) {
|
||||||
if (on) actrls_set(controls);
|
if (on) actrls_set(controls, NULL);
|
||||||
else actrls_unset();
|
else actrls_unset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ const static actrls_t controls = {
|
|||||||
* Airplay taking/giving audio system's control
|
* Airplay taking/giving audio system's control
|
||||||
*/
|
*/
|
||||||
void raop_master(bool on) {
|
void raop_master(bool on) {
|
||||||
if (on) actrls_set(controls);
|
if (on) actrls_set(controls, NULL);
|
||||||
else actrls_unset();
|
else actrls_unset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
//#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "audio_controls.h"
|
#include "audio_controls.h"
|
||||||
|
|
||||||
|
|
||||||
typedef esp_err_t (actrls_config_map_handler) (const cJSON * member, actrls_config_t *cur_config,uint32_t offset);
|
typedef esp_err_t (actrls_config_map_handler) (const cJSON * member, actrls_config_t *cur_config,uint32_t offset);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char * member;
|
char * member;
|
||||||
@@ -37,8 +36,6 @@ typedef struct {
|
|||||||
actrls_config_map_handler * handler;
|
actrls_config_map_handler * handler;
|
||||||
} actrls_config_map_t;
|
} actrls_config_map_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static esp_err_t actrls_process_member(const cJSON * member, actrls_config_t *cur_config);
|
static esp_err_t actrls_process_member(const cJSON * member, actrls_config_t *cur_config);
|
||||||
static esp_err_t actrls_process_button(const cJSON * button, actrls_config_t *cur_config);
|
static esp_err_t actrls_process_button(const cJSON * button, actrls_config_t *cur_config);
|
||||||
static esp_err_t actrls_process_int (const cJSON * member, actrls_config_t *cur_config, uint32_t offset);
|
static esp_err_t actrls_process_int (const cJSON * member, actrls_config_t *cur_config, uint32_t offset);
|
||||||
@@ -71,6 +68,7 @@ static const char * TAG = "audio controls";
|
|||||||
static actrls_config_t *json_config;
|
static actrls_config_t *json_config;
|
||||||
cJSON * control_profiles = NULL;
|
cJSON * control_profiles = NULL;
|
||||||
static actrls_t default_controls, current_controls;
|
static actrls_t default_controls, current_controls;
|
||||||
|
static actrls_hook_t *default_hook, *current_hook;
|
||||||
|
|
||||||
static void control_handler(void *client, button_event_e event, button_press_e press, bool long_press) {
|
static void control_handler(void *client, button_event_e event, button_press_e press, bool long_press) {
|
||||||
actrls_config_t *key = (actrls_config_t*) client;
|
actrls_config_t *key = (actrls_config_t*) client;
|
||||||
@@ -92,30 +90,29 @@ static void control_handler(void *client, button_event_e event, button_press_e p
|
|||||||
|
|
||||||
ESP_LOGD(TAG, "control gpio:%u press:%u long:%u event:%u action:%u", key->gpio, press, long_press, event,action_detail.action);
|
ESP_LOGD(TAG, "control gpio:%u press:%u long:%u event:%u action:%u", key->gpio, press, long_press, event,action_detail.action);
|
||||||
|
|
||||||
|
// stop here if control hook served the request
|
||||||
|
if (current_hook && (*current_hook)(key->gpio, action_detail.action, event, press, long_press)) return;
|
||||||
|
|
||||||
|
// otherwise process using configuration
|
||||||
if (action_detail.action == ACTRLS_REMAP) {
|
if (action_detail.action == ACTRLS_REMAP) {
|
||||||
// remap requested
|
// remap requested
|
||||||
ESP_LOGD(TAG, "remapping buttons to profile %s",action_detail.name);
|
ESP_LOGD(TAG, "remapping buttons to profile %s",action_detail.name);
|
||||||
cJSON * profile_obj = cJSON_GetObjectItem(control_profiles,action_detail.name);
|
cJSON * profile_obj = cJSON_GetObjectItem(control_profiles,action_detail.name);
|
||||||
if (profile_obj) {
|
if (profile_obj) {
|
||||||
actrls_config_t * profile = (actrls_config_t *) cJSON_GetStringValue(profile_obj);
|
actrls_config_t *cur_config = (actrls_config_t *) cJSON_GetStringValue(profile_obj);
|
||||||
if(profile){
|
if (cur_config) {
|
||||||
actrls_config_t *cur_config =profile;
|
|
||||||
ESP_LOGD(TAG,"Remapping all the buttons that are found in the new profile");
|
ESP_LOGD(TAG,"Remapping all the buttons that are found in the new profile");
|
||||||
while(cur_config){
|
while (cur_config->gpio != -1) {
|
||||||
ESP_LOGD(TAG,"Remapping button with gpio %u", cur_config->gpio);
|
ESP_LOGD(TAG,"Remapping button with gpio %u", cur_config->gpio);
|
||||||
button_remap((void*) cur_config, cur_config->gpio, control_handler, cur_config->long_press, cur_config->shifter_gpio);
|
button_remap((void*) cur_config, cur_config->gpio, control_handler, cur_config->long_press, cur_config->shifter_gpio);
|
||||||
cur_config++;
|
cur_config++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"Profile %s exists, but is empty. Cannot remap buttons",action_detail.name);
|
ESP_LOGE(TAG,"Profile %s exists, but is empty. Cannot remap buttons",action_detail.name);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"Invalid profile name %s. Cannot remap buttons",action_detail.name);
|
ESP_LOGE(TAG,"Invalid profile name %s. Cannot remap buttons",action_detail.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (action_detail.action != ACTRLS_NONE) {
|
} else if (action_detail.action != ACTRLS_NONE) {
|
||||||
ESP_LOGD(TAG, "calling action %u", action_detail.action);
|
ESP_LOGD(TAG, "calling action %u", action_detail.action);
|
||||||
if (current_controls[action_detail.action]) (*current_controls[action_detail.action])();
|
if (current_controls[action_detail.action]) (*current_controls[action_detail.action])();
|
||||||
@@ -163,7 +160,8 @@ esp_err_t actrls_init(int n, const actrls_config_t *config) {
|
|||||||
*/
|
*/
|
||||||
static actrls_action_e actrls_parse_action_json(const char * name){
|
static actrls_action_e actrls_parse_action_json(const char * name){
|
||||||
actrls_action_e action = ACTRLS_NONE;
|
actrls_action_e action = ACTRLS_NONE;
|
||||||
if(!strcmp("ACTRLS_NONE",name)) return ACTRLS_NONE;
|
|
||||||
|
if(!strcasecmp("ACTRLS_NONE",name)) return ACTRLS_NONE;
|
||||||
for(int i=0;i<ACTRLS_MAX && actrls_action_s[i][0]!='\0' ;i++){
|
for(int i=0;i<ACTRLS_MAX && actrls_action_s[i][0]!='\0' ;i++){
|
||||||
if(!strcmp(actrls_action_s[i], name)){
|
if(!strcmp(actrls_action_s[i], name)){
|
||||||
return (actrls_action_e) i;
|
return (actrls_action_e) i;
|
||||||
@@ -176,13 +174,12 @@ static actrls_action_e actrls_parse_action_json(const char * name){
|
|||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
ESP_LOGD(TAG,"Loading new audio control profile with name: %s", name);
|
ESP_LOGD(TAG,"Loading new audio control profile with name: %s", name);
|
||||||
if(actrls_init_json(name)==ESP_OK){
|
if (actrls_init_json(name, false) == ESP_OK) {
|
||||||
action = ACTRLS_REMAP;
|
action = ACTRLS_REMAP;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else{
|
|
||||||
ESP_LOGD(TAG,"Existing profile %s was referenced", name);
|
ESP_LOGD(TAG,"Existing profile %s was referenced", name);
|
||||||
|
action = ACTRLS_REMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
@@ -227,14 +224,12 @@ static esp_err_t actrls_process_bool (const cJSON * member, actrls_config_t *cur
|
|||||||
if (!member) {
|
if (!member) {
|
||||||
ESP_LOGE(TAG,"Null json member pointer!");
|
ESP_LOGE(TAG,"Null json member pointer!");
|
||||||
err = ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGD(TAG,"Processing bool member ");
|
ESP_LOGD(TAG,"Processing bool member ");
|
||||||
if (cJSON_IsBool(member)) {
|
if (cJSON_IsBool(member)) {
|
||||||
bool*value = (bool*)((char*) cur_config + offset);
|
bool*value = (bool*)((char*) cur_config + offset);
|
||||||
*value = cJSON_IsTrue(member);
|
*value = cJSON_IsTrue(member);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"Member %s is not a boolean", member->string?member->string:"unknown");
|
ESP_LOGE(TAG,"Member %s is not a boolean", member->string?member->string:"unknown");
|
||||||
err = ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
}
|
}
|
||||||
@@ -256,10 +251,6 @@ static esp_err_t actrls_process_action (const cJSON * member, actrls_config_t *c
|
|||||||
value[0].name = strdup(button_action->valuestring);
|
value[0].name = strdup(button_action->valuestring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
ESP_LOGW(TAG,"Action pressed not found in json structure");
|
|
||||||
err = ESP_FAIL;
|
|
||||||
}
|
|
||||||
button_action = cJSON_GetObjectItemCaseSensitive(member, "released");
|
button_action = cJSON_GetObjectItemCaseSensitive(member, "released");
|
||||||
if (button_action != NULL) {
|
if (button_action != NULL) {
|
||||||
value[1].action = actrls_parse_action_json( button_action->valuestring);
|
value[1].action = actrls_parse_action_json( button_action->valuestring);
|
||||||
@@ -267,10 +258,6 @@ static esp_err_t actrls_process_action (const cJSON * member, actrls_config_t *c
|
|||||||
value[1].name = strdup(button_action->valuestring);
|
value[1].name = strdup(button_action->valuestring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
ESP_LOGW(TAG,"Action released not found in json structure");
|
|
||||||
err = ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -327,25 +314,20 @@ static actrls_config_t * actrls_init_alloc_structure(const cJSON *buttons, const
|
|||||||
control_profiles = cJSON_CreateObject();
|
control_profiles = cJSON_CreateObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Counting the number of buttons definition");
|
ESP_LOGD(TAG,"Counting the number of buttons definition");
|
||||||
cJSON_ArrayForEach(button, buttons) {
|
cJSON_ArrayForEach(button, buttons) {
|
||||||
member_count++;
|
member_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "config contains %u button definitions",
|
ESP_LOGD(TAG, "config contains %u button definitions", member_count);
|
||||||
member_count);
|
|
||||||
if (member_count != 0) {
|
if (member_count != 0) {
|
||||||
json_config = malloc(sizeof(actrls_config_t) * member_count+1);
|
json_config = calloc(sizeof(actrls_config_t) * (member_count + 1), 1);
|
||||||
if (json_config){
|
if (json_config){
|
||||||
memset(json_config, 0x00, sizeof(actrls_config_t) * member_count+1);
|
json_config[member_count].gpio = -1;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"Unable to allocate memory to hold configuration for %u buttons ",member_count);
|
ESP_LOGE(TAG,"Unable to allocate memory to hold configuration for %u buttons ",member_count);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"No button found in configuration structure");
|
ESP_LOGE(TAG,"No button found in configuration structure");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,21 +337,34 @@ static actrls_config_t * actrls_init_alloc_structure(const cJSON *buttons, const
|
|||||||
cJSON * new_profile = cJSON_CreateStringReference((const char *)json_config);
|
cJSON * new_profile = cJSON_CreateStringReference((const char *)json_config);
|
||||||
cJSON_AddItemToObject(control_profiles, name, new_profile);
|
cJSON_AddItemToObject(control_profiles, name, new_profile);
|
||||||
|
|
||||||
|
|
||||||
return json_config;
|
return json_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void actrls_defaults(actrls_config_t *config) {
|
||||||
|
config->type = BUTTON_LOW;
|
||||||
|
config->pull = false;
|
||||||
|
config->debounce = 0;
|
||||||
|
config->long_press = 0;
|
||||||
|
config->shifter_gpio = -1;
|
||||||
|
config->normal[0].action = config->normal[1].action = ACTRLS_NONE;
|
||||||
|
config->longpress[0].action = config->longpress[1].action = ACTRLS_NONE;
|
||||||
|
config->shifted[0].action = config->shifted[1].action = ACTRLS_NONE;
|
||||||
|
config->longshifted[0].action = config->longshifted[1].action = ACTRLS_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
esp_err_t actrls_init_json(const char *profile_name) {
|
esp_err_t actrls_init_json(const char *profile_name, bool create) {
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
actrls_config_t *cur_config = NULL;
|
actrls_config_t *cur_config = NULL;
|
||||||
actrls_config_t *config_root = NULL;
|
actrls_config_t *config_root = NULL;
|
||||||
const cJSON *button;
|
const cJSON *button;
|
||||||
|
|
||||||
|
|
||||||
char *config = config_alloc_get_default(NVS_TYPE_STR, profile_name, NULL, 0);
|
char *config = config_alloc_get_default(NVS_TYPE_STR, profile_name, NULL, 0);
|
||||||
if(!config) return ESP_FAIL;
|
if(!config) return ESP_FAIL;
|
||||||
|
|
||||||
@@ -378,8 +373,7 @@ esp_err_t actrls_init_json(const char *profile_name) {
|
|||||||
if (buttons == NULL) {
|
if (buttons == NULL) {
|
||||||
ESP_LOGE(TAG,"JSON Parsing failed for %s", config);
|
ESP_LOGE(TAG,"JSON Parsing failed for %s", config);
|
||||||
err = ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGD(TAG,"Json parsing completed");
|
ESP_LOGD(TAG,"Json parsing completed");
|
||||||
if (cJSON_IsArray(buttons)) {
|
if (cJSON_IsArray(buttons)) {
|
||||||
ESP_LOGD(TAG,"configuration is an array as expected");
|
ESP_LOGD(TAG,"configuration is an array as expected");
|
||||||
@@ -396,20 +390,19 @@ esp_err_t actrls_init_json(const char *profile_name) {
|
|||||||
if(str){
|
if(str){
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
actrls_defaults(cur_config);
|
||||||
esp_err_t loc_err = actrls_process_button(button, cur_config);
|
esp_err_t loc_err = actrls_process_button(button, cur_config);
|
||||||
err = (err == ESP_OK) ? loc_err : err;
|
err = (err == ESP_OK) ? loc_err : err;
|
||||||
if (loc_err == ESP_OK) {
|
if (loc_err == ESP_OK) {
|
||||||
button_create((void*) cur_config, cur_config->gpio,cur_config->type, cur_config->pull,cur_config->debounce,
|
if (create) button_create((void*) cur_config, cur_config->gpio,cur_config->type, cur_config->pull,cur_config->debounce,
|
||||||
control_handler, cur_config->long_press, cur_config->shifter_gpio);
|
control_handler, cur_config->long_press, cur_config->shifter_gpio);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
ESP_LOGE(TAG,"Error parsing button structure. Button will not be registered.");
|
ESP_LOGE(TAG,"Error parsing button structure. Button will not be registered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_config++;
|
cur_config++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGE(TAG,"Invalid configuration; array is expected and none received in %s ", config);
|
ESP_LOGE(TAG,"Invalid configuration; array is expected and none received in %s ", config);
|
||||||
}
|
}
|
||||||
cJSON_Delete(buttons);
|
cJSON_Delete(buttons);
|
||||||
@@ -424,16 +417,18 @@ esp_err_t actrls_init_json(const char *profile_name) {
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void actrls_set_default(const actrls_t controls) {
|
void actrls_set_default(const actrls_t controls, actrls_hook_t *hook) {
|
||||||
memcpy(default_controls, controls, sizeof(actrls_t));
|
memcpy(default_controls, controls, sizeof(actrls_t));
|
||||||
memcpy(current_controls, default_controls, sizeof(actrls_t));
|
memcpy(current_controls, default_controls, sizeof(actrls_t));
|
||||||
|
default_hook = current_hook = hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void actrls_set(const actrls_t controls) {
|
void actrls_set(const actrls_t controls, actrls_hook_t *hook) {
|
||||||
memcpy(current_controls, controls, sizeof(actrls_t));
|
memcpy(current_controls, controls, sizeof(actrls_t));
|
||||||
|
current_hook = hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
@@ -441,4 +436,5 @@ void actrls_set(const actrls_t controls) {
|
|||||||
*/
|
*/
|
||||||
void actrls_unset(void) {
|
void actrls_unset(void) {
|
||||||
memcpy(current_controls, default_controls, sizeof(actrls_t));
|
memcpy(current_controls, default_controls, sizeof(actrls_t));
|
||||||
|
current_hook = default_hook;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ typedef enum { ACTRLS_NONE = -1, ACTRLS_VOLUP, ACTRLS_VOLDOWN, ACTRLS_TOGGLE, A
|
|||||||
|
|
||||||
typedef void (*actrls_handler)(void);
|
typedef void (*actrls_handler)(void);
|
||||||
typedef actrls_handler actrls_t[ACTRLS_MAX - ACTRLS_NONE - 1];
|
typedef actrls_handler actrls_t[ACTRLS_MAX - ACTRLS_NONE - 1];
|
||||||
|
typedef bool actrls_hook_t(int gpio, actrls_action_e action, button_event_e event, button_press_e press, bool long_press);
|
||||||
|
|
||||||
// BEWARE any change to struct below must be mapped to actrls_config_map
|
// BEWARE any change to struct below must be mapped to actrls_config_map
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -46,7 +47,13 @@ typedef struct actrl_config_s {
|
|||||||
} actrls_config_t;
|
} actrls_config_t;
|
||||||
|
|
||||||
esp_err_t actrls_init(int n, const actrls_config_t *config);
|
esp_err_t actrls_init(int n, const actrls_config_t *config);
|
||||||
esp_err_t actrls_init_json(const char *profile_name);
|
esp_err_t actrls_init_json(const char *profile_name, bool create);
|
||||||
void actrls_set_default(const actrls_t controls);
|
|
||||||
void actrls_set(const actrls_t controls);
|
/*
|
||||||
|
Set hook function to non-null to be set your own direct managemet function,
|
||||||
|
which should return true if it managed the control request, false if the
|
||||||
|
normal handling should be done
|
||||||
|
*/
|
||||||
|
void actrls_set_default(const actrls_t controls, actrls_hook_t *hook);
|
||||||
|
void actrls_set(const actrls_t controls, actrls_hook_t *hook);
|
||||||
void actrls_unset(void);
|
void actrls_unset(void);
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ static void notify(in_addr_t ip, u16_t hport, u16_t cport) {
|
|||||||
void cli_controls_init(void) {
|
void cli_controls_init(void) {
|
||||||
LOG_INFO("initializing CLI controls");
|
LOG_INFO("initializing CLI controls");
|
||||||
get_mac(mac);
|
get_mac(mac);
|
||||||
actrls_set_default(LMS_controls);
|
actrls_set_default(LMS_controls, NULL);
|
||||||
chained_notify = server_notify;
|
chained_notify = server_notify;
|
||||||
server_notify = notify;
|
server_notify = notify;
|
||||||
}
|
}
|
||||||
@@ -48,10 +48,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "audio_controls.h"
|
#include "audio_controls.h"
|
||||||
|
|
||||||
// todo: this should be moved to the build scripts definitions
|
|
||||||
static const char * actrls_brd1 = "[{\"gpio\":4,\"type\":\"BUTTON_LOW\",\"pull\":true,\"long_press\":1000, \"debounce\":0,\"shifter_gpio\":-1,\"normal\":{\"pressed\":\"ACTRLS_VOLUP\",\"released\":\"ACTRLS_NONE\"},\"longpress\":{\"pressed\":\"ACTRLS_PREV\",\"released\":\"ACTRLS_NONE\"},\"shifted\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"},\"longshifted\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"}},{\"gpio\":5,\"type\":\"BUTTON_LOW\",\"pull\":true,\"long_press\":1000, \"debounce\":0,\"shifter_gpio\":4,\"normal\":{\"pressed\":\"ACTRLS_VOLDOWN\",\"released\":\"ACTRLS_NONE\"},\"longpress\":{\"pressed\":\"ACTRLS_NEXT\",\"released\":\"ACTRLS_NONE\"},\"shifted\":{\"pressed\":\"ACTRLS_TOGGLE\",\"released\":\"ACTRLS_NONE\"},\"longshifted\":{\"pressed\":\"BCTRLS_DOWN\",\"released\":\"ACTRLS_NONE\"}}]";
|
|
||||||
static const char * actrls_brd2 ="[{\"gpio\":21,\"type\":\"BUTTON_LOW\",\"pull\":true,\"long_press\":1000, \"debounce\":0,\"shifter_gpio\":-1,\"normal\":{\"pressed\":\"ACTRLS_TOGGLE\",\"released\":\"ACTRLS_NONE\"},\"longpress\":{\"pressed\":\"ACTRLS_STOP\",\"released\":\"ACTRLS_NONE\"},\"shifted\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"},\"longshifted\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"}},{\"gpio\":18,\"type\":\"BUTTON_LOW\",\"pull\":true,\"long_press\":1000, \"debounce\":0,\"shifter_gpio\":21,\"normal\":{\"pressed\":\"ACTRLS_VOLUP\",\"released\":\"ACTRLS_NONE\"},\"longpress\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"},\"shifted\":{\"pressed\":\"ACTRLS_NEXT\",\"released\":\"ACTRLS_NONE\"},\"longshifted\":{\"pressed\":\"ACTRLS_FWD\",\"released\":\"ACTRLS_PLAY\"}},{\"gpio\":19,\"type\":\"BUTTON_LOW\",\"pull\":true,\"long_press\":1000, \"debounce\":0,\"shifter_gpio\":21,\"normal\":{\"pressed\":\"ACTRLS_VOLDOWN\",\"released\":\"ACTRLS_NONE\"},\"longpress\":{\"pressed\":\"ACTRLS_NONE\",\"released\":\"ACTRLS_NONE\"},\"shifted\":{\"pressed\":\"ACTRLS_PREV\",\"released\":\"ACTRLS_NONE\"},\"longshifted\":{\"pressed\":\"ACTRLS_REW\",\"released\":\"ACTRLS_PLAY\"}}]";
|
|
||||||
|
|
||||||
static const char certs_namespace[] = "certificates";
|
static const char certs_namespace[] = "certificates";
|
||||||
static const char certs_key[] = "blob";
|
static const char certs_key[] = "blob";
|
||||||
static const char certs_version[] = "version";
|
static const char certs_version[] = "version";
|
||||||
@@ -282,14 +278,8 @@ void register_default_nvs(){
|
|||||||
ESP_LOGD(TAG,"Registering default value for key %s, value %s", "bypass_wm", "0");
|
ESP_LOGD(TAG,"Registering default value for key %s, value %s", "bypass_wm", "0");
|
||||||
config_set_default(NVS_TYPE_STR, "bypass_wm", "0", 0);
|
config_set_default(NVS_TYPE_STR, "bypass_wm", "0", 0);
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Registering Audio control board type %s, value %s","actrls_brd1",actrls_brd1);
|
ESP_LOGD(TAG,"Registering default Audio control board type %s, value ","actrls_config");
|
||||||
config_set_default(NVS_TYPE_STR, "actrls_brd1",(void *) actrls_brd1, 0);
|
config_set_default(NVS_TYPE_STR, "actrls_config", "", 0);
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Registering Audio control board type %s, value %s","actrls_brd2", actrls_brd1);
|
|
||||||
config_set_default(NVS_TYPE_STR, "actrls_brd2",(void *) actrls_brd2, 0);
|
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Registering default Audio control board type %s, value ","actrls_brd");
|
|
||||||
config_set_default(NVS_TYPE_STR, "actrls_brd", "", 0);
|
|
||||||
|
|
||||||
char number_buffer[101] = {};
|
char number_buffer[101] = {};
|
||||||
snprintf(number_buffer,sizeof(number_buffer)-1,"%u",OTA_FLASH_ERASE_BLOCK);
|
snprintf(number_buffer,sizeof(number_buffer)-1,"%u",OTA_FLASH_ERASE_BLOCK);
|
||||||
@@ -363,13 +353,13 @@ void app_main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Getting audio control mapping ");
|
ESP_LOGD(TAG,"Getting audio control mapping ");
|
||||||
char *actrls_brd = config_alloc_get_default(NVS_TYPE_STR, "actrls_brd", NULL, 0);
|
char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", NULL, 0);
|
||||||
if (actrls_brd) {
|
if (actrls_config) {
|
||||||
if(actrls_brd[0] !='\0'){
|
if(actrls_config[0] !='\0'){
|
||||||
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_brd);
|
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
|
||||||
actrls_init_json(actrls_brd);
|
actrls_init_json(actrls_config, true);
|
||||||
}
|
}
|
||||||
free(actrls_brd);
|
free(actrls_config);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG,"No audio control buttons");
|
ESP_LOGD(TAG,"No audio control buttons");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,3 @@ PLUGIN_SQUEEZEESP32_DESC
|
|||||||
|
|
||||||
PLUGIN_SQUEEZEESP32_WIDTH
|
PLUGIN_SQUEEZEESP32_WIDTH
|
||||||
EN Screen width
|
EN Screen width
|
||||||
|
|
||||||
Reference in New Issue
Block a user