mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
don't count failed IR as activity
This commit is contained in:
@@ -176,13 +176,11 @@ static void buttons_task(void* arg) {
|
||||
|
||||
while (1) {
|
||||
QueueSetMemberHandle_t xActivatedMember;
|
||||
bool active = true;
|
||||
|
||||
// wait on button, rotary and infrared queues
|
||||
if ((xActivatedMember = xQueueSelectFromSet( common_queue_set, portMAX_DELAY )) == NULL) continue;
|
||||
|
||||
// mark the last activity
|
||||
buttons_idle_since = pdTICKS_TO_MS(xTaskGetTickCount());
|
||||
|
||||
|
||||
if (xActivatedMember == button_queue) {
|
||||
struct button_s button;
|
||||
button_event_e event;
|
||||
@@ -236,8 +234,11 @@ static void buttons_task(void* arg) {
|
||||
ROTARY_RIGHT : ROTARY_LEFT, false);
|
||||
} else {
|
||||
// this is IR
|
||||
infrared_receive(infrared.rb, infrared.handler);
|
||||
active = infrared_receive(infrared.rb, infrared.handler);
|
||||
}
|
||||
|
||||
// mark the last activity
|
||||
if (active) buttons_idle_since = pdTICKS_TO_MS(xTaskGetTickCount());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -446,14 +446,14 @@ err:
|
||||
/****************************************************************************************
|
||||
*
|
||||
*/
|
||||
void infrared_receive(RingbufHandle_t rb, infrared_handler handler) {
|
||||
bool infrared_receive(RingbufHandle_t rb, infrared_handler handler) {
|
||||
size_t rx_size = 0;
|
||||
rmt_item32_t* item = (rmt_item32_t*) xRingbufferReceive(rb, &rx_size, 10 / portTICK_RATE_MS);
|
||||
bool decoded = false;
|
||||
|
||||
if (item) {
|
||||
uint32_t addr, cmd;
|
||||
bool repeat = false;
|
||||
bool decoded = false;
|
||||
|
||||
rx_size /= 4; // one RMT = 4 Bytes
|
||||
|
||||
@@ -474,6 +474,8 @@ void infrared_receive(RingbufHandle_t rb, infrared_handler handler) {
|
||||
// after parsing the data, return spaces to ringbuffer.
|
||||
vRingbufferReturnItem(rb, (void*) item);
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
typedef enum {IR_NEC, IR_RC5} infrared_mode_t;
|
||||
typedef void (*infrared_handler)(uint16_t addr, uint16_t cmd);
|
||||
|
||||
void infrared_receive(RingbufHandle_t rb, infrared_handler handler);
|
||||
bool infrared_receive(RingbufHandle_t rb, infrared_handler handler);
|
||||
void infrared_init(RingbufHandle_t *rb, int gpio, infrared_mode_t mode);
|
||||
|
||||
|
||||
@@ -253,6 +253,10 @@ void services_sleep_activate(sleep_cause_e cause) {
|
||||
// is there just one GPIO
|
||||
if (sleep_context.wake_gpio & (sleep_context.wake_gpio - 1)) {
|
||||
ESP_LOGI(TAG, "going to sleep cause %d, wake-up on multiple GPIO, any '1' wakes up 0x%llx", cause, sleep_context.wake_gpio);
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S3) && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
|
||||
if (!sleep_context.wake_level) esp_sleep_enable_ext1_wakeup(sleep_context.wake_gpio, ESP_EXT1_WAKEUP_ANY_LOW);
|
||||
else
|
||||
#endif
|
||||
esp_sleep_enable_ext1_wakeup(sleep_context.wake_gpio, ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
} else if (sleep_context.wake_gpio) {
|
||||
int gpio = __builtin_ctz(sleep_context.wake_gpio);
|
||||
|
||||
Reference in New Issue
Block a user