mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
fix some buttons snafu & power off led on suspend
This commit is contained in:
@@ -192,8 +192,9 @@ static void control_handler(void *client, button_event_e event, button_press_e p
|
|||||||
|
|
||||||
// in raw mode, we just do normal action press *and* release, there is no longpress nor shift
|
// in raw mode, we just do normal action press *and* release, there is no longpress nor shift
|
||||||
if (current_raw_controls && action_detail.action != ACTRLS_SLEEP) {
|
if (current_raw_controls && action_detail.action != ACTRLS_SLEEP) {
|
||||||
ESP_LOGD(TAG, "calling action %u in raw mode", key->normal[0].action);
|
actrls_action_e action = key->normal[0].action != ACTRLS_NONE ? key->normal[0].action : key->normal[1].action;
|
||||||
if (current_controls[key->normal[0].action]) (*current_controls[key->normal[0].action])(event == BUTTON_PRESSED);
|
ESP_LOGD(TAG, "calling action %u in raw mode", action);
|
||||||
|
if (action != ACTRLS_NONE && current_controls[action]) current_controls[action](event == BUTTON_PRESSED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +219,7 @@ static void control_handler(void *client, button_event_e event, button_press_e p
|
|||||||
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_SLEEP) {
|
} else if (action_detail.action == ACTRLS_SLEEP) {
|
||||||
ESP_LOGI(TAG, "Sleep button pressed");
|
ESP_LOGI(TAG, "special sleep button pressed");
|
||||||
services_sleep_activate(SLEEP_ONKEY);
|
services_sleep_activate(SLEEP_ONKEY);
|
||||||
} 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);
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ typedef enum { ACTRLS_NONE = -1, ACTRLS_POWER, ACTRLS_VOLUP, ACTRLS_VOLDOWN, AC
|
|||||||
BCTRLS_UP, BCTRLS_DOWN, BCTRLS_LEFT, BCTRLS_RIGHT,
|
BCTRLS_UP, BCTRLS_DOWN, BCTRLS_LEFT, BCTRLS_RIGHT,
|
||||||
BCTRLS_PS0,BCTRLS_PS1,BCTRLS_PS2,BCTRLS_PS3,BCTRLS_PS4,BCTRLS_PS5,BCTRLS_PS6,BCTRLS_PS7,BCTRLS_PS8,BCTRLS_PS9,
|
BCTRLS_PS0,BCTRLS_PS1,BCTRLS_PS2,BCTRLS_PS3,BCTRLS_PS4,BCTRLS_PS5,BCTRLS_PS6,BCTRLS_PS7,BCTRLS_PS8,BCTRLS_PS9,
|
||||||
KNOB_LEFT, KNOB_RIGHT, KNOB_PUSH,
|
KNOB_LEFT, KNOB_RIGHT, KNOB_PUSH,
|
||||||
ACTRLS_REMAP, ACTRLS_SLEEP, ACTRLS_MAX
|
ACTRLS_SLEEP,
|
||||||
|
ACTRLS_REMAP, ACTRLS_MAX
|
||||||
} actrls_action_e;
|
} actrls_action_e;
|
||||||
|
|
||||||
typedef void (*actrls_handler)(bool pressed);
|
typedef void (*actrls_handler)(bool pressed);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "globdefs.h"
|
#include "globdefs.h"
|
||||||
#include "accessors.h"
|
#include "accessors.h"
|
||||||
|
#include "services.h"
|
||||||
|
|
||||||
#define MAX_LED 8
|
#define MAX_LED 8
|
||||||
#define BLOCKTIME 10 // up to portMAX_DELAY
|
#define BLOCKTIME 10 // up to portMAX_DELAY
|
||||||
@@ -276,6 +277,14 @@ bool led_config(int idx, gpio_num_t gpio, int color, int bright, led_type_t type
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void led_suspend(void) {
|
||||||
|
led_off(LED_GREEN);
|
||||||
|
led_off(LED_RED);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -327,6 +336,9 @@ void led_svc_init(void) {
|
|||||||
led_config(LED_GREEN, green.gpio, green.color, green.bright, green.type);
|
led_config(LED_GREEN, green.gpio, green.color, green.bright, green.type);
|
||||||
led_config(LED_RED, red.gpio, red.color, red.bright, red.type);
|
led_config(LED_RED, red.gpio, red.color, red.bright, red.type);
|
||||||
|
|
||||||
|
// make sure we switch off all leds (useful for gpio expanders)
|
||||||
|
services_sleep_setsuspend(led_suspend);
|
||||||
|
|
||||||
ESP_LOGI(TAG,"Configuring LEDs green:%d (on:%d rmt:%d %d%% ), red:%d (on:%d rmt:%d %d%% )",
|
ESP_LOGI(TAG,"Configuring LEDs green:%d (on:%d rmt:%d %d%% ), red:%d (on:%d rmt:%d %d%% )",
|
||||||
green.gpio, green.color, green.type, green.bright,
|
green.gpio, green.color, green.type, green.bright,
|
||||||
red.gpio, red.color, red.type, red.bright);
|
red.gpio, red.color, red.type, red.bright);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ static void sendBUTN(int code, bool pressed) {
|
|||||||
pkt_header.jiffies = htonl(gettime_ms());
|
pkt_header.jiffies = htonl(gettime_ms());
|
||||||
pkt_header.button = htonl(code + (pressed ? DOWN_OFS : UP_OFS));
|
pkt_header.button = htonl(code + (pressed ? DOWN_OFS : UP_OFS));
|
||||||
|
|
||||||
LOG_INFO("sending BUTN code %04x %s", code, pressed ? "down" : "up");
|
LOG_DEBUG("sending BUTN code %04x %s", code, pressed ? "down" : "up");
|
||||||
|
|
||||||
LOCK_P;
|
LOCK_P;
|
||||||
send_packet((uint8_t *) &pkt_header, sizeof(pkt_header));
|
send_packet((uint8_t *) &pkt_header, sizeof(pkt_header));
|
||||||
|
|||||||
Reference in New Issue
Block a user