This commit is contained in:
cschwinne 2020-06-06 00:57:39 +02:00
commit 18a4a43f8a
5 changed files with 147 additions and 45 deletions

View File

@ -37,11 +37,24 @@ lib_deps =
...
```
Also, while in the `platformio.ini` file, you must change the environment setup to build for just the esp32dev platform as follows:
Comment out the line described below:
```ini
# Travis CI binaries (comment this out when building for single board)
; default_envs = travis_esp8266, esp01, esp01_1m_ota, travis_esp32
```
and UNCOMMENT the following line in the 'Single binaries' section:
```ini
default_envs = esp32dev
```
Save the `platformio.ini` file. Once this is saved, the required library files should be automatically downloaded for modifications in a later step.
### Platformio_overrides.ini (added)
Copy the `platformio_overrides.ini` file which is contained in the `usermods/TTGO-T-Display/` folder into the root of your project folder. This file contains an override that remaps the button pin of WLED to use the on-board button to the right of the USB-C connector (when viewed with the port oriented downward - see hardware photo).
### TFT_eSPI Library Adjustments (board selection)
NOTE: I am relatively new to Platformio and VS Code, but I find that in order to get the project populated with the TFT_eSPI library (so the following changes can be made), I need to attempt an initial build that I know will fail. There is probably a better way to accomplish this, but it worked for me. Once the first build fails, the `User_Setup_Select.h` file can be found in the `/.pio/libdeps/esp32dev/TFT_eSPI_ID1559` folder.
We need to modify a file in the `TFT_eSPI` library to select the correct board. If you followed the directions to modify and save the `platformio.ini` file above, the `User_Setup_Select.h` file can be found in the `/.pio/libdeps/esp32dev/TFT_eSPI_ID1559` folder.
Modify the `User_Setup_Select.h` file as follows:
* Comment out the following line (which is the 'default' setup file):
@ -53,7 +66,12 @@ Modify the `User_Setup_Select.h` file as follows:
#include <User_Setups/Setup25_TTGO_T_Display.h> // Setup file for ESP32 and TTGO T-Display ST7789V SPI bus TFT
```
Run the build again and it should complete correctly.
Run the build and it should complete correctly. If you see a failure like this:
```ini
xtensa-esp32-elf-g++: error: wled00\wled00.ino.cpp: No such file or directory
xtensa-esp32-elf-g++: fatal error: no input files
```
Just try building again - I find that sometimes this happens on the first build attempt and subsequent attempts will build correctly.
## Arduino IDE
- UNTESTED

View File

@ -57,8 +57,10 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len);
//ir.cpp
bool decodeIRCustom(uint32_t code);
void applyRepeatActions();
void relativeChange(byte* property, int8_t amount, byte lowerBoundary = 0, byte higherBoundary = 0xFF);
void changeEffectSpeed(int8_t amount);
void changeBrightness(int8_t amount);
void changeEffectIntensity(int8_t amount);
void decodeIR(uint32_t code);
void decodeIR24(uint32_t code);
@ -68,6 +70,7 @@ void decodeIR40(uint32_t code);
void decodeIR44(uint32_t code);
void decodeIR21(uint32_t code);
void decodeIR6(uint32_t code);
void decodeIR9(uint32_t code);
void initIR();
void handleIR();

View File

@ -273,6 +273,7 @@ Infrared remote:
<option value=4>44-key RGB</option>
<option value=5>21-key RGB</option>
<option value=6>6-key black</option>
<option value=7>9-key red</option>
</select><br>
<a href=https://github.com/Aircoookie/WLED/wiki/Infrared-Control target=_blank>IR info</a>
<h3>WLED Broadcast</h3>

View File

@ -15,6 +15,8 @@ decode_results results;
unsigned long irCheckedTime = 0;
uint32_t lastValidCode = 0;
byte lastRepeatableAction = ACTION_NONE;
uint8_t lastRepeatableValue = 0;
uint16_t irTimesRepeated = 0;
uint8_t lastIR6ColourIdx = 0;
@ -36,7 +38,7 @@ bool decodeIRCustom(uint32_t code)
}
//relatively change brightness, minumum A=5
void relativeChange(byte* property, int8_t amount, byte lowerBoundary, byte higherBoundary)
{
int16_t new_val = (int16_t) *property + amount;
@ -45,6 +47,16 @@ void relativeChange(byte* property, int8_t amount, byte lowerBoundary, byte high
*property = (byte)constrain(new_val,0.1,255.1);
}
void changeBrightness(int8_t amount)
{
int16_t new_val = bri + amount;
if (new_val < 5) new_val = 5; //minimum brightness A=5
bri = (byte)constrain(new_val,0.1,255.1);
if(amount > 0) lastRepeatableAction = ACTION_BRIGHT_UP;
if(amount < 0) lastRepeatableAction = ACTION_BRIGHT_DOWN;
lastRepeatableValue = amount;
}
void changeEffectSpeed(int8_t amount)
{
if (effectCurrent != 0) {
@ -65,6 +77,10 @@ void changeEffectSpeed(int8_t amount)
col[1] = fastled_col.green;
col[2] = fastled_col.blue;
}
if(amount > 0) lastRepeatableAction = ACTION_SPEED_UP;
if(amount < 0) lastRepeatableAction = ACTION_SPEED_DOWN;
lastRepeatableValue = amount;
}
void changeEffectIntensity(int8_t amount)
@ -85,6 +101,10 @@ void changeEffectIntensity(int8_t amount)
col[1] = fastled_col.green;
col[2] = fastled_col.blue;
}
if(amount > 0) lastRepeatableAction = ACTION_INTENSITY_UP;
if(amount < 0) lastRepeatableAction = ACTION_INTENSITY_DOWN;
lastRepeatableValue = amount;
}
void decodeIR(uint32_t code)
@ -92,14 +112,61 @@ void decodeIR(uint32_t code)
if (code == 0xFFFFFFFF) //repeated code, continue brightness up/down
{
irTimesRepeated++;
if (lastValidCode == IR24_BRIGHTER || lastValidCode == IR40_BPLUS )
applyRepeatActions();
return;
}
lastValidCode = 0; irTimesRepeated = 0;
if (decodeIRCustom(code)) return;
if (code > 0xFFFFFF) return; //invalid code
else if (code > 0xF70000 && code < 0xF80000) decodeIR24(code); //is in 24-key remote range
else if (code > 0xFF0000) {
switch (irEnabled) {
case 1: decodeIR24OLD(code); break; // white 24-key remote (old) - it sends 0xFF0000 values
case 2: decodeIR24CT(code); break; // white 24-key remote with CW, WW, CT+ and CT- keys
case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys
case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys
case 5: decodeIR21(code); break; // white 21-key remote
case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness,
// "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE"
// sets bright plain white
case 7: decodeIR9(code); break;
default: return;
}
}
if (nightlightActive && bri == 0) nightlightActive = false;
colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //for notifier, IR is considered a button input
//code <= 0xF70000 also invalid
}
void applyRepeatActions(){
if (lastRepeatableAction == ACTION_BRIGHT_UP)
{
relativeChange(&bri, 10); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeBrightness(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
else if (lastValidCode == IR24_DARKER || lastValidCode == IR40_BMINUS )
else if (lastRepeatableAction == ACTION_BRIGHT_DOWN )
{
relativeChange(&bri, -10, 5); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
changeBrightness(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_SPEED_UP)
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_SPEED_DOWN )
{
changeEffectSpeed(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
if (lastRepeatableAction == ACTION_INTENSITY_UP)
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
else if (lastRepeatableAction == ACTION_INTENSITY_DOWN )
{
changeEffectIntensity(lastRepeatableValue); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
if (lastValidCode == IR40_WPLUS)
{
relativeChangeWhite(10); colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
@ -114,37 +181,14 @@ void decodeIR(uint32_t code)
nightlightStartTime = millis();
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
}
return;
}
lastValidCode = 0; irTimesRepeated = 0;
if (decodeIRCustom(code)) return;
if (code > 0xFFFFFF) return; //invalid code
else if (code > 0xF70000 && code < 0xF80000) decodeIR24(code); //is in 24-key remote range
else if (code > 0xFF0000) {
switch (irEnabled) {
case 1: decodeIR24OLD(code); break; // white 24-key remote (old) - it sends 0xFF0000 values
case 2: decodeIR24CT(code); break; // white 24-key remote with CW, WW, CT+ and CT- keys
case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys
case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys
case 5: decodeIR21(code); break; // white 21-key remote
case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness,
// "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE"
// sets bright plain white
default: return;
}
}
if (nightlightActive && bri == 0) nightlightActive = false;
colorUpdated(NOTIFIER_CALL_MODE_BUTTON); //for notifier, IR is considered a button input
//code <= 0xF70000 also invalid
}
void decodeIR24(uint32_t code)
{
switch (code) {
case IR24_BRIGHTER : relativeChange(&bri, 10); break;
case IR24_DARKER : relativeChange(&bri, -10, 5); break;
case IR24_BRIGHTER : changeBrightness(10); break;
case IR24_DARKER : changeBrightness(-10); break;
case IR24_OFF : briLast = bri; bri = 0; break;
case IR24_ON : bri = briLast; break;
case IR24_RED : colorFromUint32(COLOR_RED); break;
@ -175,8 +219,8 @@ void decodeIR24(uint32_t code)
void decodeIR24OLD(uint32_t code)
{
switch (code) {
case IR24_OLD_BRIGHTER : relativeChange(&bri, 10); break;
case IR24_OLD_DARKER : relativeChange(&bri, -10, 5); break;
case IR24_OLD_BRIGHTER : changeBrightness(10); break;
case IR24_OLD_DARKER : changeBrightness(-10); break;
case IR24_OLD_OFF : briLast = bri; bri = 0; break;
case IR24_OLD_ON : bri = briLast; break;
case IR24_OLD_RED : colorFromUint32(COLOR_RED); break;
@ -208,8 +252,8 @@ void decodeIR24OLD(uint32_t code)
void decodeIR24CT(uint32_t code)
{
switch (code) {
case IR24_CT_BRIGHTER : relativeChange(&bri, 10); break;
case IR24_CT_DARKER : relativeChange(&bri, -10, 5); break;
case IR24_CT_BRIGHTER : changeBrightness(10); break;
case IR24_CT_DARKER : changeBrightness(-10); break;
case IR24_CT_OFF : briLast = bri; bri = 0; break;
case IR24_CT_ON : bri = briLast; break;
case IR24_CT_RED : colorFromUint32(COLOR_RED); break;
@ -243,8 +287,8 @@ void decodeIR24CT(uint32_t code)
void decodeIR40(uint32_t code)
{
switch (code) {
case IR40_BPLUS : relativeChange(&bri, 10); break;
case IR40_BMINUS : relativeChange(&bri, -10, 5); break;
case IR40_BPLUS : changeBrightness(10); break;
case IR40_BMINUS : changeBrightness(-10); break;
case IR40_OFF : briLast = bri; bri = 0; break;
case IR40_ON : bri = briLast; break;
case IR40_RED : colorFromUint24(COLOR_RED); break;
@ -300,8 +344,8 @@ void decodeIR40(uint32_t code)
void decodeIR44(uint32_t code)
{
switch (code) {
case IR44_BPLUS : relativeChange(&bri, 10); break;
case IR44_BMINUS : relativeChange(&bri, -10, 5); break;
case IR44_BPLUS : changeBrightness(10); break;
case IR44_BMINUS : changeBrightness(-10); break;
case IR44_OFF : briLast = bri; bri = 0; break;
case IR44_ON : bri = briLast; break;
case IR44_RED : colorFromUint24(COLOR_RED); break;
@ -363,8 +407,8 @@ void decodeIR44(uint32_t code)
void decodeIR21(uint32_t code)
{
switch (code) {
case IR21_BRIGHTER: relativeChange(&bri, 10); break;
case IR21_DARKER: relativeChange(&bri, -10, 5); break;
case IR21_BRIGHTER: changeBrightness(10); break;
case IR21_DARKER: changeBrightness(-10); break;
case IR21_OFF: briLast = bri; bri = 0; break;
case IR21_ON: bri = briLast; break;
case IR21_RED: colorFromUint32(COLOR_RED); break;
@ -392,9 +436,9 @@ void decodeIR21(uint32_t code)
void decodeIR6(uint32_t code)
{
switch (code) {
case IR6_POWER: toggleOnOff(); break;
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
case IR6_POWER: toggleOnOff(); break;
case IR6_CHANNEL_UP: changeBrightness(10); break;
case IR6_CHANNEL_DOWN: changeBrightness(-10); break;
case IR6_VOLUME_UP: relativeChange(&effectCurrent, 1, 0, MODE_COUNT); break; // next effect
case IR6_VOLUME_DOWN: // next palette
relativeChange(&effectPalette, 1, 0, strip.getPaletteCount() -1);
@ -421,6 +465,24 @@ void decodeIR6(uint32_t code)
lastValidCode = code;
}
void decodeIR9(uint32_t code)
{
switch (code) {
case IR9_POWER : toggleOnOff(); break;
case IR9_A : if (!applyPreset(1)) effectCurrent = FX_MODE_COLORTWINKLE; break;
case IR9_B : if (!applyPreset(2)) effectCurrent = FX_MODE_RAINBOW_CYCLE; break;
case IR9_C : if (!applyPreset(3)) effectCurrent = FX_MODE_BREATH; break;
case IR9_UP : changeBrightness(16); break;
case IR9_DOWN : changeBrightness(-16); break;
//case IR9_UP : changeEffectIntensity(16); break;
//case IR9_DOWN : changeEffectIntensity(-16); break;
case IR9_LEFT : changeEffectSpeed(-16); break;
case IR9_RIGHT : changeEffectSpeed(16); break;
case IR9_SELECT : relativeChange(&effectCurrent, 1, 0, MODE_COUNT); break;
default: return;
}
lastValidCode = code;
}
void initIR()
{

View File

@ -13,6 +13,15 @@
#define IR6_VOLUME_DOWN 0xFF2FD0
#define IR6_MUTE 0xFFAF50
#define IR9_POWER 0xFF629D
#define IR9_A 0xFF22DD
#define IR9_B 0xFF02FD
#define IR9_C 0xFFC23D
#define IR9_LEFT 0xFF30CF
#define IR9_RIGHT 0xFF7A85
#define IR9_UP 0xFF9867
#define IR9_DOWN 0xFF38C7
#define IR9_SELECT 0xFF18E7
//Infrared codes for 24-key remote from http://woodsgood.ca/projects/2015/02/13/rgb-led-strip-controllers-ir-codes/
#define IR24_BRIGHTER 0xF700FF
@ -229,3 +238,12 @@
#define COLOR2_NEUTRALWHITE 0xFF000000
#define COLOR2_COLDWHITE 0xFF7F7F7F
#define COLOR2_COLDWHITE2 0xFFFFFFFF
#define ACTION_NONE 0
#define ACTION_BRIGHT_UP 1
#define ACTION_BRIGHT_DOWN 2
#define ACTION_SPEED_UP 3
#define ACTION_SPEED_DOWN 4
#define ACTION_INTENSITY_UP 5
#define ACTION_INTENSITY_DOWN 6
#define ACTION_POWER 7