diff --git a/Controls.md b/Controls.md index fc06a98..4878033 100644 --- a/Controls.md +++ b/Controls.md @@ -51,14 +51,27 @@ You can connect one or two encoders to replace/complete the buttons. One encoder --- ### IR receiver -- IR_CODE_PLAY: start/stop playing -- IR_CODE_PREV: previous station -- IR_CODE_NEXT: next station -- IR_CODE_VOLUP: volume up, longpress - quick volume up -- IR_CODE_VOLDN: volume down, longpress - quick volume down -- IR_CODE_HASH: toggle between PLAYER/PLAYLIST mode -- IR_CODE_NUM0-NUM9:\ - Start entering the station number. To finish input and start playback, press the play button. To cancel, press hash. +Starting from version 0.6.450, adding an IR remote control has been moved to the web interface. Can be added for up to three remotes. +1. go to Settings - IR (fig.1) +2. press the button you need on the left to record the IR code (fig.2) + +
+ +3. select the slot on the right and press the button on the physical IR remote (fig.3). Avoid the inscription "UNKNOWN" (fig.4) + +
+ +4. repeat steps 2 and 3 for other buttons +5. select BACK, select DONE + +**Button assignment:** +- ⏯ - start/stop playing +- ⏪ - previous station +- ⏩ - next station +- ▲ - volume up, longpress - quick volume up +- ▼ - volume down, longpress - quick volume down +-  **\#**  - toggle between PLAYER/PLAYLIST mode +- **0-9** - Start entering the station number. To finish input and start playback, press the play button. To cancel, press hash. --- ### Joystick diff --git a/README.md b/README.md index df21ccb..8eeb314 100644 --- a/README.md +++ b/README.md @@ -295,6 +295,11 @@ Work is in progress... --- ## Version history +#### v0.6.450 +**!!! a [full update](#update-over-web-interface) with Sketch data upload is required. After updating please press CTRL+F5 in browser !!!** +- adding an IR remote control has been moved to the web-interface (more info in [Controls.md](Controls.md#ir-receiver)) +- fixed broken internal DAC on esp32 core 2.0.3 and highest + #### v0.6.400 - fixed compilation errors with esp32 core 2.0.4 diff --git a/exsamples/myoptions.h b/exsamples/myoptions.h index 9511597..7a21f83 100644 --- a/exsamples/myoptions.h +++ b/exsamples/myoptions.h @@ -115,27 +115,8 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti /* IR control */ //#define IR_PIN 255 -//#define IR_DEBUG 0 /* Set this to 1, capture ir codes from serial, insert the captured codes below and set this back to 0 */ //#define IR_TIMEOUT 80 /* see kTimeout description in IRremoteESP8266 exsample https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino */ //#define IR_TLP 40 /* see kTolerancePercentage description in IRremoteESP8266 exsample https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino */ -//#define IR_CODE_PLAY 0xFF02FD -//#define IR_CODE_PREV 0xFF22DD -//#define IR_CODE_NEXT 0xFFC23DP -//#define IR_CODE_VOLUP 0xFF629D -//#define IR_CODE_VOLDN 0xFFA857 -//#define IR_CODE_NUM0 0xFF4AB5 -//#define IR_CODE_NUM1 0xFF6897 -//#define IR_CODE_NUM2 0xFF9867 -//#define IR_CODE_NUM3 0xFFB04F -//#define IR_CODE_NUM4 0xFF30CF -//#define IR_CODE_NUM5 0xFF18E7 -//#define IR_CODE_NUM6 0xFF7A85 -//#define IR_CODE_NUM7 0xFF10EF -//#define IR_CODE_NUM8 0xFF38C7 -//#define IR_CODE_NUM9 0xFF5AA5 -//#define IR_CODE_HASH 0xFF52AD /* Toggle playlist mode */ -//#define IR_CODE_AST 0xFF42BD /* Not used */ - /******************************************/ diff --git a/images/irRecorder01.png b/images/irRecorder01.png new file mode 100644 index 0000000..33e0f61 Binary files /dev/null and b/images/irRecorder01.png differ diff --git a/images/irRecorder02.png b/images/irRecorder02.png new file mode 100644 index 0000000..fc45a36 Binary files /dev/null and b/images/irRecorder02.png differ diff --git a/yoRadio/config.cpp b/yoRadio/config.cpp index d5eaeed..8c9506f 100644 --- a/yoRadio/config.cpp +++ b/yoRadio/config.cpp @@ -7,6 +7,9 @@ Config config; void Config::init() { EEPROM.begin(EEPROM_SIZE); +#if IR_PIN!=255 + irindex=-1; +#endif eepromRead(EEPROM_START, store); if (store.tz_set != 57) { // update to v0.4.200 store.tz_set = 57; @@ -26,6 +29,13 @@ void Config::init() { save(); } loadStation(store.lastStation); +#if IR_PIN!=255 + eepromRead(EEPROM_START_IR, ircodes); + if(ircodes.ir_set!=4224){ + ircodes.ir_set=4224; + memset(ircodes.irVals, 0, sizeof(ircodes.irVals)); + } +#endif } template int Config::eepromWrite(int ee, const T& value) { @@ -82,6 +92,12 @@ void Config::save() { eepromWrite(EEPROM_START, store); } +#if IR_PIN!=255 +void Config::saveIR(){ + eepromWrite(EEPROM_START_IR, ircodes); +} +#endif + byte Config::setVolume(byte val, bool dosave) { store.volume = val; if (dosave) { diff --git a/yoRadio/config.h b/yoRadio/config.h index d0cc31c..a199b04 100644 --- a/yoRadio/config.h +++ b/yoRadio/config.h @@ -1,14 +1,16 @@ #ifndef config_h #define config_h #include "Arduino.h" +#include "options.h" -#define EEPROM_SIZE 32 -#define EEPROM_START 0 -#define BUFLEN 140 -#define PLAYLIST_PATH "/data/playlist.csv" -#define SSIDS_PATH "/data/wifi.csv" -#define TMP_PATH "/data/tmpfile.txt" -#define INDEX_PATH "/data/index.dat" +#define EEPROM_SIZE 768 +#define EEPROM_START 0 +#define EEPROM_START_IR 100 +#define BUFLEN 140 +#define PLAYLIST_PATH "/data/playlist.csv" +#define SSIDS_PATH "/data/wifi.csv" +#define TMP_PATH "/data/tmpfile.txt" +#define INDEX_PATH "/data/index.dat" struct config_t { @@ -29,6 +31,14 @@ struct config_t uint16_t timezoneOffset; }; +#if IR_PIN!=255 +struct ircodes_t +{ + unsigned int ir_set; //must be 4224 + uint64_t irVals[20][3]; +}; +#endif + struct station_t { char name[BUFLEN]; @@ -48,11 +58,19 @@ class Config { public: config_t store; station_t station; +#if IR_PIN!=255 + int irindex; + uint8_t irchck; + ircodes_t ircodes; +#endif neworkItem ssids[5]; byte ssidsCount; public: Config() {}; void save(); +#if IR_PIN!=255 + void saveIR(); +#endif void init(); byte setVolume(byte val, bool dosave); void setTone(int8_t bass, int8_t middle, int8_t trebble); diff --git a/yoRadio/controls.cpp b/yoRadio/controls.cpp index ebc2c87..e90f4e7 100644 --- a/yoRadio/controls.cpp +++ b/yoRadio/controls.cpp @@ -4,6 +4,7 @@ #include "config.h" #include "player.h" #include "display.h" +#include "netserver.h" long encOldPosition = 0; long enc2OldPosition = 0; @@ -210,8 +211,12 @@ void irNum(byte num) { void irLoop() { if (irrecv.decode(&irResults)) { - if (IR_DEBUG) { + if(irResults.value<256) return; + if (netserver.irRecordEnable) { Serial.print(resultToHumanReadableBasic(&irResults)); + Serial.println("--------------------------"); + config.ircodes.irVals[config.irindex][config.irchck]=irResults.value; + netserver.irToWs(typeToString(irResults.decode_type, irResults.repeat).c_str(), irResults.value); return; } if (!irResults.repeat/* && irResults.command!=0*/) { @@ -227,88 +232,99 @@ void irLoop() { break; } } - switch (irResults.value) { - case IR_CODE_PLAY: { - irBlink(); - if (display.mode == NUMBERS) { - display.putRequest({NEWMODE, PLAYER}); - player.play(display.numOfNextStation); - display.numOfNextStation = 0; - break; - } - onBtnClick(1); + for(int target=0; target<17; target++){ + for(int j=0; j<3; j++){ + if(config.ircodes.irVals[target][j]==irResults.value){ + switch (target){ + case IR_PLAY: { + irBlink(); + if (display.mode == NUMBERS) { + display.putRequest({NEWMODE, PLAYER}); + player.play(display.numOfNextStation); + display.numOfNextStation = 0; + break; + } + onBtnClick(1); + break; + } + case IR_PREV: { + player.prev(); + break; + } + case IR_NEXT: { + player.next(); + break; + } + case IR_UP: { + controlsEvent(display.mode == STATIONS ? false : true); + irVolRepeat = 1; + break; + } + case IR_DOWN: { + controlsEvent(display.mode == STATIONS ? true : false); + irVolRepeat = 2; + break; + } + case IR_HASH: { + if (display.mode == NUMBERS) { + display.putRequest({RETURNTITLE, 0}); + display.putRequest({NEWMODE, PLAYER}); + display.numOfNextStation = 0; + break; + } + display.putRequest({NEWMODE, display.mode == PLAYER ? STATIONS : PLAYER}); + break; + } + case IR_0: { + irNum(0); + break; + } + case IR_1: { + irNum(1); + break; + } + case IR_2: { + irNum(2); + break; + } + case IR_3: { + irNum(3); + break; + } + case IR_4: { + irNum(4); + break; + } + case IR_5: { + irNum(5); + break; + } + case IR_6: { + irNum(6); + break; + } + case IR_7: { + irNum(7); + break; + } + case IR_8: { + irNum(8); + break; + } + case IR_9: { + irNum(9); + break; + } + case IR_AST: { + break; + } + } /* switch (target) */ + target=17; break; - } - case IR_CODE_PREV: { - player.prev(); - break; - } - case IR_CODE_NEXT: { - player.next(); - break; - } - case IR_CODE_VOLUP: { - controlsEvent(display.mode == STATIONS ? false : true); - irVolRepeat = 1; - break; - } - case IR_CODE_VOLDN: { - controlsEvent(display.mode == STATIONS ? true : false); - irVolRepeat = 2; - break; - } - case IR_CODE_HASH: { - if (display.mode == NUMBERS) { - display.putRequest({RETURNTITLE, 0}); - display.putRequest({NEWMODE, PLAYER}); - display.numOfNextStation = 0; - break; - } - display.putRequest({NEWMODE, display.mode == PLAYER ? STATIONS : PLAYER}); - break; - } - case IR_CODE_NUM0: { - irNum(0); - break; - } - case IR_CODE_NUM1: { - irNum(1); - break; - } - case IR_CODE_NUM2: { - irNum(2); - break; - } - case IR_CODE_NUM3: { - irNum(3); - break; - } - case IR_CODE_NUM4: { - irNum(4); - break; - } - case IR_CODE_NUM5: { - irNum(5); - break; - } - case IR_CODE_NUM6: { - irNum(6); - break; - } - case IR_CODE_NUM7: { - irNum(7); - break; - } - case IR_CODE_NUM8: { - irNum(8); - break; - } - case IR_CODE_NUM9: { - irNum(9); - break; - } - } - } + } /* if(config.ircodes.irVals[target][j]==irResults.value) */ + } /* for(int j=0; j<3; j++) */ + } /* for(int target=0; target<16; target++) */ + } /* if (irrecv.decode(&irResults)) */ } #endif // if IR_PIN!=255 diff --git a/yoRadio/controls.h b/yoRadio/controls.h index 78c61c6..e0afdf0 100644 --- a/yoRadio/controls.h +++ b/yoRadio/controls.h @@ -1,10 +1,14 @@ #ifndef controls_h #define controls_h +#include "options.h" enum controlEvt_e { EVT_BTNLEFT, EVT_BTNCENTER, EVT_BTNRIGHT, EVT_ENCBTNB, EVT_BTNUP, EVT_BTNDOWN, EVT_ENC2BTNB }; enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST }; +#if IR_PIN!=255 +enum : uint8_t { IR_UP=0, IR_PREV=1, IR_PLAY=2, IR_NEXT=3, IR_DOWN=4, IR_1=5, IR_2=6, IR_3=7, IR_4=8, IR_5=9, IR_6=10, IR_7=11, IR_8=12, IR_9=13, IR_AST=14, IR_0=15, IR_HASH=16 }; +#endif boolean checklpdelay(int m, unsigned long &tstamp); diff --git a/yoRadio/data/www/index.html b/yoRadio/data/www/index.html index a2df871..dae5d1e 100644 --- a/yoRadio/data/www/index.html +++ b/yoRadio/data/www/index.html @@ -16,9 +16,10 @@