-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
39,893 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include "keys.h" | ||
#include <vector> | ||
|
||
// @warning must match definitions of IRRecv library | ||
typedef enum infrared_protocol { | ||
IRPROTO_RC5 = 1, | ||
IRPROTO_RC6 = 2, | ||
IRPROTO_NEC = 3, | ||
IRPROTO_SONY = 4 | ||
} infrared_protocol_t; | ||
|
||
typedef struct infrared_identifier { | ||
infrared_protocol_t protocol; | ||
uint64_t value; | ||
uint32_t address; | ||
uint32_t command; | ||
} infrared_identifier_t; | ||
|
||
typedef std::vector<std::pair<const infrared_identifier_t, const key_id_t>> infrared_definition_t; | ||
void infrared_start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[common] | ||
build_flags = -DCORE_DEBUG_LEVEL=3 -DPDFB_PERF_LOGS -DPDFB_PERF_LOG_INTERVAL=1200 -DGP_NO_OTA -DGP_NO_DNS -DGP_NO_MDNS | ||
build_flags = -DCORE_DEBUG_LEVEL=3 -DPDFB_PERF_LOGS -DPDFB_PERF_LOG_INTERVAL=1200 -DGP_NO_OTA -DGP_NO_DNS -DGP_NO_MDNS -D_IR_ENABLE_DEFAULT_=false -DDECODE_NEC=true -DDECODE_RC5=true -DDECODE_RC6=true -DDECODE_SONY=true | ||
|
||
[env] | ||
platform = [email protected] | ||
|
@@ -22,6 +22,7 @@ lib_deps = | |
gyverlibs/GyverPortal@^3.6.6 | ||
h2zero/NimBLE-Arduino@^1.4.2 | ||
fortyseveneffects/MIDI Library@^5.0.2 | ||
crankyoldgit/IRremoteESP8266@^2.8.6 | ||
extra_scripts = | ||
pre:helper/env-extra.py | ||
pre:helper/aquestalk-detect.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "input/infrared.h" | ||
#include <device_config.h> | ||
#include <esp32-hal-log.h> | ||
#include <map> | ||
#include <os_config.h> | ||
|
||
#if HAS(IR_RECEIVER) | ||
// NB: disable all the stuff of no use in the platformio.ini file! | ||
#include <IRrecv.h> | ||
#endif | ||
|
||
static char LOG_TAG[] = "IRRC"; | ||
|
||
static TaskHandle_t hTask; | ||
|
||
static key_id_t last_pressed = KEY_MAX_INVALID; | ||
|
||
#if HAS(IR_RECEIVER) | ||
static IRrecv receiver(HWCONF_IR_RECV_GPIO); | ||
|
||
static void ir_task(void*) { | ||
static decode_results results; | ||
while(1) { | ||
if(receiver.decode(&results)) { | ||
ESP_LOGI(LOG_TAG, "IR code TYPE=%i, VALUE=%i, ADDRESS=%i, COMMAND=%i", results.decode_type, results.value, results.address, results.command); | ||
|
||
for(auto &mapping: HWCONF_IR_BUTTONS) { | ||
const infrared_identifier_t * id = &mapping.first; | ||
if(id->protocol == results.decode_type && | ||
id->address == results.address && | ||
id->command == results.command && | ||
id->value == results.value) { | ||
|
||
if(last_pressed != KEY_MAX_INVALID) { | ||
if(last_pressed == mapping.second) | ||
break; | ||
hid_set_key_state(last_pressed, false); | ||
} | ||
|
||
last_pressed = mapping.second; | ||
hid_set_key_state(mapping.second, true); | ||
} | ||
} | ||
} else { | ||
if(last_pressed != KEY_MAX_INVALID) { | ||
hid_set_key_state(last_pressed, false); | ||
last_pressed = KEY_MAX_INVALID; | ||
} | ||
} | ||
vTaskDelay(pdMS_TO_TICKS(10)); | ||
} | ||
} | ||
#endif | ||
|
||
void infrared_start() { | ||
#if HAS(IR_RECEIVER) | ||
receiver.enableIRIn(true); | ||
|
||
ESP_LOGI(LOG_TAG, "Creating task"); | ||
xTaskCreate( | ||
ir_task, | ||
"IRRC", | ||
4096, | ||
nullptr, | ||
pisosTASK_PRIORITY_KEYPAD, | ||
&hTask | ||
); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.