From 96b2c8010e421733c7d72b73e6410b9df86f58cf Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 11:45:58 +0200 Subject: [PATCH 01/17] Change ``Status`` command output for disabled status types Change ``Status`` command output for disabled status types --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/support_command.ino | 49 +++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 23475d38a..f64ccf4d3 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -67,6 +67,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Change MAX31865 driver to support up to 6 thermocouples selected by ``MX31865 CS`` instead of ``SSPI CS`` (#9103) - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) +- Change ``Status`` command output for disabled status types - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index d9577e758..96f85c32a 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -8,6 +8,7 @@ - Change MAX31865 driver to support up to 6 thermocouples selected by ``MX31865 CS`` instead of ``SSPI CS`` (#9103) - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) +- Change ``Status`` command output for disabled status types - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index f38ec82ed..180ee5b79 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -378,21 +378,18 @@ void CmndPower(void) void CmndStatus(void) { - uint32_t payload = ((XdrvMailbox.payload < 0) || (XdrvMailbox.payload > MAX_STATUS)) ? 99 : XdrvMailbox.payload; + uint32_t payload = XdrvMailbox.payload; + + if (payload > MAX_STATUS) { return; } // {"Command":"Error"} + if (!Settings.flag.mqtt_enabled && (6 == payload)) { return; } // SetOption3 - Enable MQTT + if (!energy_flg && (9 == payload)) { return; } + if (!CrashFlag() && (12 == payload)) { return; } + if (!Settings.flag3.shutter_mode && (13 == payload)) { return; } - uint32_t option = STAT; char stemp[200]; char stemp2[TOPSZ]; - // Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX - // Commented on 20200118 as it seems to be no longer needed -// if (!strcmp(SettingsText(SET_MQTTPREFIX1), SettingsText(SET_MQTTPREFIX2)) && (!payload)) { option++; } // TELE - - if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } // SetOption3 - Enable MQTT - if (!energy_flg && (9 == payload)) { payload = 99; } - if (!CrashFlag() && (12 == payload)) { payload = 99; } - - if ((0 == payload) || (99 == payload)) { + if (0 == payload) { uint32_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present; #ifdef USE_SONOFF_IFAN if (IsModuleIfan()) { maxfn = 1; } @@ -419,7 +416,7 @@ void CmndStatus(void) Settings.flag.mqtt_switch_retain, // CMND_SWITCHRETAIN Settings.flag.mqtt_sensor_retain, // CMND_SENSORRETAIN Settings.flag.mqtt_power_retain); // CMND_POWERRETAIN - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS)); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS)); } if ((0 == payload) || (1 == payload)) { @@ -437,7 +434,7 @@ void CmndStatus(void) , GetSettingsAddress() #endif ); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "1")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "1")); } if ((0 == payload) || (2 == payload)) { @@ -455,7 +452,7 @@ void CmndStatus(void) , ESP.getSdkVersion(), ESP.getCpuFreqMHz(), GetDeviceHardware().c_str(), GetStatistics().c_str()); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "2")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "2")); } if ((0 == payload) || (3 == payload)) { @@ -466,7 +463,7 @@ void CmndStatus(void) SettingsText(SET_SYSLOG_HOST), Settings.syslog_port, EscapeJSONString(SettingsText(SET_STASSID1)).c_str(), EscapeJSONString(SettingsText(SET_STASSID2)).c_str(), Settings.tele_period, Settings.flag2.data, Settings.flag.data, ToHex_P((unsigned char*)Settings.param, PARAM8_SIZE, stemp2, sizeof(stemp2)), Settings.flag3.data, Settings.flag4.data, Settings.flag5.data); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "3")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "3")); } if ((0 == payload) || (4 == payload)) { @@ -494,7 +491,7 @@ void CmndStatus(void) ResponseAppend_P(PSTR(",\"Sensors\":")); XsnsSensorState(); ResponseJsonEndEnd(); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "4")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "4")); } if ((0 == payload) || (5 == payload)) { @@ -504,7 +501,7 @@ void CmndStatus(void) NetworkHostname(), NetworkAddress().toString().c_str(), IPAddress(Settings.ip_address[1]).toString().c_str(), IPAddress(Settings.ip_address[2]).toString().c_str(), IPAddress(Settings.ip_address[3]).toString().c_str(), NetworkMacAddress().c_str(), Settings.webserver, Settings.sta_config, WifiGetOutputPower().c_str()); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "5")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "5")); } if (((0 == payload) || (6 == payload)) && Settings.flag.mqtt_enabled) { // SetOption3 - Enable MQTT @@ -512,7 +509,7 @@ void CmndStatus(void) D_CMND_MQTTCLIENT "\":\"%s\",\"" D_CMND_MQTTUSER "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,\"MAX_PACKET_SIZE\":%d,\"KEEPALIVE\":%d}}"), SettingsText(SET_MQTT_HOST), Settings.mqtt_port, EscapeJSONString(SettingsText(SET_MQTT_CLIENT)).c_str(), mqtt_client, EscapeJSONString(SettingsText(SET_MQTT_USER)).c_str(), MqttConnectCount(), MQTT_MAX_PACKET_SIZE, MQTT_KEEPALIVE); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "6")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "6")); } if ((0 == payload) || (7 == payload)) { @@ -532,7 +529,7 @@ void CmndStatus(void) GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_LOCALNOTZ).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str(), stemp); #endif // USE_TIMERS and USE_SUNRISE - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "7")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "7")); } #if defined(USE_ENERGY_SENSOR) && defined(USE_ENERGY_MARGIN_DETECTION) @@ -542,7 +539,7 @@ void CmndStatus(void) D_CMND_VOLTAGELOW "\":%d,\"" D_CMND_VOLTAGEHIGH "\":%d,\"" D_CMND_CURRENTLOW "\":%d,\"" D_CMND_CURRENTHIGH "\":%d}}"), Settings.energy_power_delta[0], Settings.energy_power_delta[1], Settings.energy_power_delta[2], Settings.energy_min_power, Settings.energy_max_power, Settings.energy_min_voltage, Settings.energy_max_voltage, Settings.energy_min_current, Settings.energy_max_current); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "9")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "9")); } } #endif // USE_ENERGY_MARGIN_DETECTION @@ -552,9 +549,9 @@ void CmndStatus(void) MqttShowSensor(); ResponseJsonEnd(); if (8 == payload) { - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "8")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "8")); } else { - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "10")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "10")); } } @@ -562,7 +559,7 @@ void CmndStatus(void) Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS11_STATUS "\":")); MqttShowState(); ResponseJsonEnd(); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "11")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "11")); } if (CrashFlag()) { @@ -570,7 +567,7 @@ void CmndStatus(void) Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS12_STATUS "\":")); CrashDump(); ResponseJsonEnd(); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "12")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "12")); } } @@ -583,7 +580,7 @@ void CmndStatus(void) if (i > 0) { ResponseAppend_P(PSTR(",")); } ResponseAppend_P(PSTR("{\"" D_STATUS13_SHUTTER "%d\":{\"Relay1\":%d,\"Relay2\":%d,\"Open\":%d,\"Close\":%d," "\"50perc\":%d,\"Delay\":%d,\"Opt\":\"%s\"," - "\"Calib\":\"%d:%d:%d:%d:%d\"," + "\"Calib\":[%d,%d,%d,%d,%d]," "\"Mode\":\"%d\"}}"), i, Settings.shutter_startrelay[i], Settings.shutter_startrelay[i] +1, Settings.shutter_opentime[i], Settings.shutter_closetime[i], Settings.shutter_set50percent[i], Settings.shutter_motordelay[i], GetBinary8(Settings.shutter_options[i], 4).c_str(), @@ -591,7 +588,7 @@ void CmndStatus(void) Settings.shutter_mode); } ResponseJsonEnd(); - MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "13")); + MqttPublishPrefixTopic_P(STAT, PSTR(D_CMND_STATUS "13")); } } #endif From 08cf425e150114c7eb16cfedc9c9cf95477420b4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:01:58 +0200 Subject: [PATCH 02/17] Build Tasmota artifact on PR --- .github/workflows/CI_github.yml | 138 +++++++++++++++++++++++++++++--- 1 file changed, 128 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI_github.yml b/.github/workflows/CI_github.yml index 1f4f79f38..d93a59331 100644 --- a/.github/workflows/CI_github.yml +++ b/.github/workflows/CI_github.yml @@ -18,6 +18,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-minimal: runs-on: ubuntu-latest @@ -33,6 +37,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-minimal + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-lite: runs-on: ubuntu-latest @@ -48,6 +56,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-lite + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-knx: runs-on: ubuntu-latest @@ -63,7 +75,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-knx - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-sensors: runs-on: ubuntu-latest steps: @@ -78,7 +94,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-sensors - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-display: runs-on: ubuntu-latest @@ -94,6 +113,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-display + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-ir: runs-on: ubuntu-latest @@ -109,6 +132,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-ir + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-zbbridge: runs-on: ubuntu-latest @@ -124,6 +151,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-zbbridge + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-BG: runs-on: ubuntu-latest @@ -139,7 +170,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-BG - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-BR: runs-on: ubuntu-latest steps: @@ -154,6 +189,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-BR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-CN: runs-on: ubuntu-latest @@ -169,6 +208,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-CN + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-CZ: runs-on: ubuntu-latest @@ -184,6 +227,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-CZ + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-DE: runs-on: ubuntu-latest @@ -199,7 +246,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-DE - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-ES: runs-on: ubuntu-latest steps: @@ -214,8 +265,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-ES - - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-FR: runs-on: ubuntu-latest steps: @@ -230,6 +284,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-FR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-GR: runs-on: ubuntu-latest @@ -245,6 +303,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-GR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-HE: runs-on: ubuntu-latest @@ -260,7 +322,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-HE - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-HU: runs-on: ubuntu-latest steps: @@ -275,6 +341,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-HU + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-IT: runs-on: ubuntu-latest @@ -290,6 +360,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-IT + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-KO: runs-on: ubuntu-latest @@ -305,6 +379,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-KO + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-NL: runs-on: ubuntu-latest @@ -320,7 +398,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-NL - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-PL: runs-on: ubuntu-latest steps: @@ -335,6 +417,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-PL + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-PT: runs-on: ubuntu-latest @@ -350,6 +436,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-PT + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-RO: runs-on: ubuntu-latest @@ -365,6 +455,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-RO + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-RU: runs-on: ubuntu-latest @@ -380,7 +474,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-RU - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-SE: runs-on: ubuntu-latest steps: @@ -395,6 +493,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-SE + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-SK: runs-on: ubuntu-latest @@ -410,6 +512,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-SK + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-TR: runs-on: ubuntu-latest @@ -425,6 +531,10 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-TR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota-TW: runs-on: ubuntu-latest @@ -440,7 +550,11 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-TW - + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota-UK: runs-on: ubuntu-latest steps: @@ -455,3 +569,7 @@ jobs: platformio update - name: Run PlatformIO run: platformio run -e tasmota-UK + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware From de7ce53fb8d091178da877a7b9e93b9bd74f9cd5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:03:39 +0200 Subject: [PATCH 03/17] Build Tasmota32 artifacts on PR --- .github/workflows/CI_github_ESP32.yml | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/.github/workflows/CI_github_ESP32.yml b/.github/workflows/CI_github_ESP32.yml index 64fbd39b2..519604bde 100644 --- a/.github/workflows/CI_github_ESP32.yml +++ b/.github/workflows/CI_github_ESP32.yml @@ -19,6 +19,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32 + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-webcam: runs-on: ubuntu-latest @@ -35,6 +39,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-webcam + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-minimal: runs-on: ubuntu-latest @@ -51,6 +59,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-minimal + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-lite: runs-on: ubuntu-latest steps: @@ -66,6 +79,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-lite + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-knx: runs-on: ubuntu-latest steps: @@ -81,6 +99,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-knx + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-sensors: runs-on: ubuntu-latest @@ -97,6 +119,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-sensors + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-display: runs-on: ubuntu-latest steps: @@ -112,6 +139,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-display + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-ir: runs-on: ubuntu-latest steps: @@ -127,6 +159,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-ir + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-BG: runs-on: ubuntu-latest steps: @@ -142,6 +179,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-BG + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-BR: runs-on: ubuntu-latest @@ -158,6 +199,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-BR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-CN: runs-on: ubuntu-latest steps: @@ -173,6 +219,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-CN + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-CZ: runs-on: ubuntu-latest steps: @@ -188,6 +239,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-CZ + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-DE: runs-on: ubuntu-latest steps: @@ -203,6 +259,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-DE + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-ES: runs-on: ubuntu-latest @@ -219,6 +279,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-ES + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-FR: runs-on: ubuntu-latest steps: @@ -234,6 +299,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-FR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-GR: runs-on: ubuntu-latest steps: @@ -249,6 +319,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-GR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-HE: runs-on: ubuntu-latest steps: @@ -264,6 +339,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-HE + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-HU: runs-on: ubuntu-latest @@ -280,6 +359,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-HU + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-IT: runs-on: ubuntu-latest steps: @@ -295,6 +379,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-IT + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-KO: runs-on: ubuntu-latest steps: @@ -310,6 +399,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-KO + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-NL: runs-on: ubuntu-latest steps: @@ -325,6 +419,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-NL + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-PL: runs-on: ubuntu-latest @@ -341,6 +439,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-PL + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-PT: runs-on: ubuntu-latest steps: @@ -356,6 +459,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-PT + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-RO: runs-on: ubuntu-latest steps: @@ -371,6 +479,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-RO + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-RU: runs-on: ubuntu-latest steps: @@ -386,6 +499,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-RU + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-SE: runs-on: ubuntu-latest @@ -402,6 +519,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-SE + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-SK: runs-on: ubuntu-latest steps: @@ -417,6 +539,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-SK + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-TR: runs-on: ubuntu-latest steps: @@ -432,6 +559,11 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-TR + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware + tasmota32-TW: runs-on: ubuntu-latest steps: @@ -447,6 +579,10 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-TW + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware tasmota32-UK: runs-on: ubuntu-latest @@ -463,3 +599,7 @@ jobs: - name: Run PlatformIO run: | platformio run -e tasmota32-UK + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output/firmware From d13b4c84482719903c6b44b62f0f5156473bc6e9 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:23:07 +0200 Subject: [PATCH 04/17] Add some thoughts --- tasmota/support_command.ino | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 180ee5b79..2bad15eb3 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -288,7 +288,19 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) } if (mqtt_data[0] != '\0') { - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, type); +/* + // Add "Command":"POWERONSTATE", like: + // 12:15:37 MQT: stat/wemos4/RESULT = {"Command":"POWERONSTATE","PowerOnState":3} + char json_command[TOPSZ]; + snprintf_P(json_command, sizeof(json_command), PSTR("{\"" D_JSON_COMMAND "\":\"%s\","), type); + uint32_t jc_len = strlen(json_command); + uint32_t mq_len = strlen(mqtt_data) +1; + if (mq_len < sizeof(mqtt_data) - jc_len) { + memmove(mqtt_data +jc_len -1, mqtt_data, mq_len); + memmove(mqtt_data, json_command, jc_len); + } +*/ + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, type); } fallback_topic_flag = false; } From b8d4bce2136c958839d527aaeb408be8cf4e889d Mon Sep 17 00:00:00 2001 From: stefanbode Date: Mon, 5 Oct 2020 12:45:08 +0200 Subject: [PATCH 05/17] Update xdrv_27_shutter.ino #9458 fix int16 overflow in calibration matrix --- tasmota/xdrv_27_shutter.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index 44bbb5429..fecfea22d 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -158,7 +158,7 @@ void ShutterRtc50mS(void) int32_t ShutterPercentToRealPosition(uint32_t percent, uint32_t index) { if (Settings.shutter_set50percent[index] != 50) { - return (percent <= 5) ? Settings.shuttercoeff[2][index] * percent : Settings.shuttercoeff[1][index] * percent + Settings.shuttercoeff[0][index]; + return (percent <= 5) ? Settings.shuttercoeff[2][index] * percent*10 : (Settings.shuttercoeff[1][index] * percent + (Settings.shuttercoeff[0][index]*10))*10; } else { uint32_t realpos; // check against DIV 0 @@ -192,7 +192,7 @@ int32_t ShutterPercentToRealPosition(uint32_t percent, uint32_t index) uint8_t ShutterRealToPercentPosition(int32_t realpos, uint32_t index) { if (Settings.shutter_set50percent[index] != 50) { - return (Settings.shuttercoeff[2][index] * 5 > realpos) ? SHT_DIV_ROUND(realpos, Settings.shuttercoeff[2][index]) : SHT_DIV_ROUND(realpos-Settings.shuttercoeff[0][index], Settings.shuttercoeff[1][index]); + return (Settings.shuttercoeff[2][index] * 5 > realpos) ? SHT_DIV_ROUND(realpos/10, Settings.shuttercoeff[2][index]) : SHT_DIV_ROUND(realpos/10-Settings.shuttercoeff[0][index]*10, Settings.shuttercoeff[1][index]); } else { uint16_t realpercent; @@ -288,10 +288,11 @@ void ShutterInit(void) // calculate a ramp slope at the first 5 percent to compensate that shutters move with down part later than the upper part if (Settings.shutter_set50percent[i] != 50) { - Settings.shuttercoeff[1][i] = Shutter[i].open_max * (100 - Settings.shutter_set50percent[i] ) / 5000; - Settings.shuttercoeff[0][i] = Shutter[i].open_max - (Settings.shuttercoeff[1][i] * 100); - Settings.shuttercoeff[2][i] = (Settings.shuttercoeff[0][i] + 5 * Settings.shuttercoeff[1][i]) / 5; - } + Settings.shuttercoeff[1][i] = Shutter[i].open_max/10 * (100 - Settings.shutter_set50percent[i] ) / 5000 ; + Settings.shuttercoeff[0][i] = Shutter[i].open_max/100 - (Settings.shuttercoeff[1][i] * 10); + Settings.shuttercoeff[2][i] = (int32_t)(Settings.shuttercoeff[0][i]*10 + 5 * Settings.shuttercoeff[1][i]) / 5; + //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SHT%d: Shutter[i].open_max %d, 50perc:%d, 0:%d, 1:%d 2:%d"), i, Shutter[i].open_max, Settings.shutter_set50percent[i], Settings.shuttercoeff[0][i],Settings.shuttercoeff[1][i],Settings.shuttercoeff[2][i]); + } ShutterGlobal.RelayShutterMask |= 3 << (Settings.shutter_startrelay[i] -1); Shutter[i].real_position = ShutterPercentToRealPosition(Settings.shutter_position[i], i); From d442b64d9028b1178a13c2a6b2f44052e6ca3148 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:56:12 +0200 Subject: [PATCH 06/17] Fix shutter timing problem Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f64ccf4d3..61e481c90 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -71,6 +71,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) +- Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 96f85c32a..be54c8e09 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -12,6 +12,7 @@ - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) +- Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) From 669176cba0957130c9516c08cc67b30912d1e723 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 5 Oct 2020 14:09:00 +0200 Subject: [PATCH 07/17] Delete dead link to support.md --- .github/issue-close-app.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/issue-close-app.yml b/.github/issue-close-app.yml index 6a6947a9c..aa8c4b638 100644 --- a/.github/issue-close-app.yml +++ b/.github/issue-close-app.yml @@ -16,8 +16,6 @@ comment: >- Please, could you be so kind on completing the [issue template](https://github.com/arendst/Tasmota/issues/new/choose) in order to have more information so as to properly help you? Thank you for taking the time to report, hopefully it can be resolved soon. - - [Support Information](https://github.com/arendst/Sonoff-Tasmota/blob/development/SUPPORT.md) [Wiki](https://tasmota.github.io/docs/) for more information. @@ -25,9 +23,9 @@ comment: >- [Community](https://groups.google.com/d/forum/sonoffusers) for forum. - [Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md) + [Code of Conduct](https://github.com/arendst/Tasmota/blob/development/CODE_OF_CONDUCT.md) - [Contributing Guideline and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) + [Contributing Guideline and Policy](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md) issueConfigs: # There can be several configs for different kind of issues. From 1f49daacd305aac0fc65af9c5a67e63a2283cf98 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 15:16:43 +0200 Subject: [PATCH 08/17] Fix light wakeup exception 0 Fix light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 61e481c90..be1435d25 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -72,6 +72,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) - Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) +- Fix light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index be54c8e09..8899ce12f 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) - Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) +- Fix light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index e0e3a7e66..ffe346f5d 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -278,7 +278,7 @@ struct LIGHT { uint8_t fixed_color_index = 1; uint8_t pwm_offset = 0; // Offset in color buffer uint8_t max_scheme = LS_MAX -1; - + uint32_t wakeup_start_time = 0; bool update = true; @@ -1395,6 +1395,9 @@ void LightInit(void) Light.power = 0; Light.update = true; Light.wakeup_active = 0; + if (0 == Settings.light_wakeup) { + Settings.light_wakeup = 60; // Fix divide by zero exception 0 in Animate + } if (Settings.flag4.fade_at_startup) { Light.fade_initialized = true; // consider fade intialized starting from black } From f0ab0d274d77c0ec3c498754287d0491f1ad57c5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 17:32:30 +0200 Subject: [PATCH 09/17] Change NeoPixelBus library from v2.5.0.09 to v2.6.0 --- RELEASENOTES.md | 1 + lib/NeoPixelBus-2.5.0.09/keywords.txt | 275 ------- lib/NeoPixelBus-2.5.0.09/library.json | 14 - lib/NeoPixelBus-2.5.0.09/library.properties | 9 - .../src/internal/DotStarSpiMethod.h | 133 ---- .../src/internal/NeoEsp32I2sMethod.h | 217 ------ .../src/internal/NeoEsp32RmtMethod.h | 369 ---------- .../src/internal/NeoEsp8266UartMethod.h | 434 ------------ .../src/internal/NeoEspBitBangMethod.h | 195 ----- .../src/internal/NeoPixelEsp.c | 169 ----- .../.gitattributes | 0 lib/NeoPixelBus-2.6.0/.github/FUNDING.yml | 4 + .../.github/ISSUE_TEMPLATE/all-others.md | 14 + .../.github/ISSUE_TEMPLATE/bug_report.md | 3 + .../.github/ISSUE_TEMPLATE/feature_request.md | 3 + .../.gitignore | 0 .../COPYING | 0 .../ReadMe.md | 6 +- .../examples/DotStarTest/DotStarTest.ino | 0 .../NeoPixelBrightness/NeoPixelBrightness.ino | 0 .../examples/NeoPixelGamma/NeoPixelGamma.ino | 0 .../examples/NeoPixelTest/NeoPixelTest.ino | 0 .../NeoPixelAnimation/NeoPixelAnimation.ino | 4 +- .../NeoPixelCylon/NeoPixelCylon.ino | 0 .../NeoPixelFunFadeInOut.ino | 0 .../NeoPixelFunLoop/NeoPixelFunLoop.ino | 0 .../NeoPixelFunRandomChange.ino | 0 .../NeoPixelRotateLoop/NeoPixelRotateLoop.ino | 0 .../bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino | 0 .../bitmaps/NeoPixelBitmap/Strings.bmp | Bin .../bitmaps/NeoPixelBitmap/StringsW.bmp | Bin .../bitmaps/NeoPixelBufferCylon/Cylon.pdn | Bin .../bitmaps/NeoPixelBufferCylon/CylonGrb.h | 0 .../bitmaps/NeoPixelBufferCylon/CylonGrbw.h | 0 .../NeoPixelBufferCylon.ino | 0 .../NeoPixelBufferShader.ino | 0 .../NeoPixelDibTest/NeoPixelDibTest.ino | 0 .../NeoSegmentBus/NeoSegmentBus.ino | 36 + .../NeoSegmentFade/NeoSegmentFade.ino | 144 ++++ .../NeoPixelMosaicDump/NeoPixelMosaicDump.ino | 0 .../NeoPixelMosaicTest/NeoPixelMosaicTest.ino | 0 .../NeoPixelRingTopologyTest.ino | 0 .../NeoPixelTilesDump/NeoPixelTilesDump.ino | 0 .../NeoPixelTilesTest/NeoPixelTilesTest.ino | 0 .../NeoPixelTopologyDump.ino | 0 .../NeoPixelTopologyTest.ino | 0 .../extras/curves/circular.png | Bin .../extras/curves/cubic.png | Bin .../extras/curves/different.png | Bin .../extras/curves/exponential.png | Bin .../extras/curves/gamma.png | Bin .../extras/curves/pronounced.png | Bin .../extras/curves/quadratic.png | Bin .../extras/curves/quintic.png | Bin .../extras/curves/sinusoidal.png | Bin lib/NeoPixelBus-2.6.0/keywords.txt | 539 ++++++++++++++ lib/NeoPixelBus-2.6.0/library.json | 14 + lib/NeoPixelBus-2.6.0/library.properties | 9 + .../src/NeoPixelAnimator.h | 3 +- .../src/NeoPixelBrightnessBus.h | 91 +-- .../src/NeoPixelBus.h | 95 ++- .../src/NeoPixelSegmentBus.h | 67 ++ .../src/internal/DotStarColorFeatures.h | 115 ++- .../src/internal/DotStarGenericMethod.h | 135 ++++ .../src/internal/Esp32_i2s.c | 212 +++--- .../src/internal/Esp32_i2s.h | 4 +- .../src/internal/HsbColor.cpp | 0 .../src/internal/HsbColor.h | 0 .../src/internal/HslColor.cpp | 0 .../src/internal/HslColor.h | 0 .../src/internal/HtmlColor.cpp | 0 .../src/internal/HtmlColor.h | 0 .../src/internal/HtmlColorNameStrings.cpp | 0 .../src/internal/HtmlColorNameStrings.h | 0 .../src/internal/HtmlColorNames.cpp | 0 .../src/internal/HtmlColorShortNames.cpp | 0 .../src/internal/Layouts.h | 0 .../src/internal/Lpd8806ColorFeatures.h | 189 +++++ .../src/internal/Lpd8806GenericMethod.h | 130 ++++ .../src/internal/NeoArmMethod.h | 101 ++- .../src/internal/NeoAvrMethod.h | 76 +- .../src/internal/NeoBitmapFile.h | 2 +- .../src/internal/NeoBuffer.h | 0 .../src/internal/NeoBufferContext.h | 0 .../src/internal/NeoBufferMethods.h | 2 +- .../src/internal/NeoColorFeatures.h | 94 ++- .../src/internal/NeoDib.h | 25 +- .../src/internal/NeoEase.h | 29 +- .../src/internal/NeoEsp32I2sMethod.h | 276 ++++++++ .../src/internal/NeoEsp32RmtMethod.cpp | 262 +++++++ .../src/internal/NeoEsp32RmtMethod.h | 668 ++++++++++++++++++ .../src/internal/NeoEsp8266DmaMethod.h | 189 ++++- .../src/internal/NeoEsp8266UartMethod.cpp | 12 +- .../src/internal/NeoEsp8266UartMethod.h | 514 ++++++++++++++ .../src/internal/NeoEspBitBangMethod.h | 401 +++++++++++ .../src/internal/NeoGamma.cpp | 5 +- .../src/internal/NeoGamma.h | 0 .../src/internal/NeoHueBlend.h | 0 .../src/internal/NeoMosaic.h | 0 .../src/internal/NeoNrf52xMethod.h | 490 +++++++++++++ .../src/internal/NeoPixelAnimator.cpp | 1 + .../src/internal/NeoPixelAvr.c | 50 +- .../src/internal/NeoRingTopology.h | 0 .../src/internal/NeoSegmentFeatures.h | 130 ++++ .../src/internal/NeoSettings.h | 62 ++ .../src/internal/NeoSpriteSheet.h | 0 .../src/internal/NeoTiles.h | 0 .../src/internal/NeoTm1814ColorFeatures.h | 131 ++++ .../src/internal/NeoTopology.h | 0 .../src/internal/P9813ColorFeatures.h | 162 +++++ .../src/internal/P9813GenericMethod.h | 126 ++++ .../src/internal/RgbColor.cpp | 116 +-- .../src/internal/RgbColor.h | 51 ++ .../src/internal/RgbwColor.cpp | 12 + .../src/internal/RgbwColor.h | 51 ++ .../src/internal/SegmentDigit.cpp | 153 ++++ .../src/internal/SegmentDigit.h | 202 ++++++ .../src/internal/TwoWireBitBangImple.h} | 86 +-- .../src/internal/TwoWireBitBangImpleAvr.h} | 99 +-- .../src/internal/TwoWireSpiImple.h | 115 +++ .../src/internal/Ws2801GenericMethod.h | 130 ++++ tasmota/CHANGELOG.md | 1 + 122 files changed, 6052 insertions(+), 2405 deletions(-) delete mode 100644 lib/NeoPixelBus-2.5.0.09/keywords.txt delete mode 100644 lib/NeoPixelBus-2.5.0.09/library.json delete mode 100644 lib/NeoPixelBus-2.5.0.09/library.properties delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/DotStarSpiMethod.h delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32I2sMethod.h delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32RmtMethod.h delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.h delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/NeoEspBitBangMethod.h delete mode 100644 lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelEsp.c rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/.gitattributes (100%) create mode 100644 lib/NeoPixelBus-2.6.0/.github/FUNDING.yml create mode 100644 lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/all-others.md rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/.github/ISSUE_TEMPLATE/bug_report.md (97%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/.github/ISSUE_TEMPLATE/feature_request.md (96%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/.gitignore (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/COPYING (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/ReadMe.md (76%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/DotStarTest/DotStarTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/NeoPixelBrightness/NeoPixelBrightness.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/NeoPixelGamma/NeoPixelGamma.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/NeoPixelTest/NeoPixelTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino (99%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelCylon/NeoPixelCylon.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelFunLoop/NeoPixelFunLoop.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/animations/NeoPixelRotateLoop/NeoPixelRotateLoop.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBitmap/Strings.bmp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBitmap/StringsW.bmp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBufferCylon/Cylon.pdn (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBufferCylon/CylonGrb.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBufferCylon/CylonGrbw.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelBufferShader/NeoPixelBufferShader.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/bitmaps/NeoPixelDibTest/NeoPixelDibTest.ino (100%) create mode 100644 lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentBus/NeoSegmentBus.ino create mode 100644 lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentFade/NeoSegmentFade.ino rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelMosaicTest/NeoPixelMosaicTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelRingTopologyTest/NeoPixelRingTopologyTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelTilesTest/NeoPixelTilesTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/examples/topologies/NeoPixelTopologyTest/NeoPixelTopologyTest.ino (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/circular.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/cubic.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/different.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/exponential.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/gamma.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/pronounced.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/quadratic.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/quintic.png (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/extras/curves/sinusoidal.png (100%) create mode 100644 lib/NeoPixelBus-2.6.0/keywords.txt create mode 100644 lib/NeoPixelBus-2.6.0/library.json create mode 100644 lib/NeoPixelBus-2.6.0/library.properties rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/NeoPixelAnimator.h (99%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/NeoPixelBrightnessBus.h (64%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/NeoPixelBus.h (78%) create mode 100644 lib/NeoPixelBus-2.6.0/src/NeoPixelSegmentBus.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/DotStarColorFeatures.h (83%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/DotStarGenericMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/Esp32_i2s.c (72%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/Esp32_i2s.h (86%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HsbColor.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HsbColor.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HslColor.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HslColor.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColor.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColor.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColorNameStrings.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColorNameStrings.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColorNames.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/HtmlColorShortNames.cpp (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/Layouts.h (100%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/Lpd8806ColorFeatures.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/Lpd8806GenericMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoArmMethod.h (88%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoAvrMethod.h (66%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoBitmapFile.h (99%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoBuffer.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoBufferContext.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoBufferMethods.h (99%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoColorFeatures.h (80%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoDib.h (85%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoEase.h (94%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32I2sMethod.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.cpp create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoEsp8266DmaMethod.h (71%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoEsp8266UartMethod.cpp (96%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoEspBitBangMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoGamma.cpp (96%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoGamma.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoHueBlend.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoMosaic.h (100%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoNrf52xMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoPixelAnimator.cpp (99%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoPixelAvr.c (94%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoRingTopology.h (100%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoSegmentFeatures.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoSettings.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoSpriteSheet.h (100%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoTiles.h (100%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/NeoTm1814ColorFeatures.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/NeoTopology.h (100%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/P9813ColorFeatures.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/P9813GenericMethod.h rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/RgbColor.cpp (79%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/RgbColor.h (78%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/RgbwColor.cpp (89%) rename lib/{NeoPixelBus-2.5.0.09 => NeoPixelBus-2.6.0}/src/internal/RgbwColor.h (81%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.cpp create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.h rename lib/{NeoPixelBus-2.5.0.09/src/internal/DotStarGenericMethod.h => NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImple.h} (58%) rename lib/{NeoPixelBus-2.5.0.09/src/internal/DotStarAvrMethod.h => NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImpleAvr.h} (61%) create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/TwoWireSpiImple.h create mode 100644 lib/NeoPixelBus-2.6.0/src/internal/Ws2801GenericMethod.h diff --git a/RELEASENOTES.md b/RELEASENOTES.md index be1435d25..f8179f3d2 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -68,6 +68,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Change ``Status`` command output for disabled status types +- Change NeoPixelBus library from v2.5.0.09 to v2.6.0 - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) diff --git a/lib/NeoPixelBus-2.5.0.09/keywords.txt b/lib/NeoPixelBus-2.5.0.09/keywords.txt deleted file mode 100644 index 4734aca32..000000000 --- a/lib/NeoPixelBus-2.5.0.09/keywords.txt +++ /dev/null @@ -1,275 +0,0 @@ -####################################### -# Syntax Coloring Map NeoPixelBus -####################################### - -####################################### -# Datatypes (KEYWORD1) -####################################### - -NeoPixelBus KEYWORD1 -RgbwColor KEYWORD1 -RgbColor KEYWORD1 -HslColor KEYWORD1 -HsbColor KEYWORD1 -HtmlColor KEYWORD1 -NeoGrbFeature KEYWORD1 -NeoGrbwFeature KEYWORD1 -NeoRgbwFeature KEYWORD1 -NeoRgbFeature KEYWORD1 -NeoBrgFeature KEYWORD1 -NeoRbgFeature KEYWORD1 -DotStarBgrFeature KEYWORD1 -DotStarLbgrFeature KEYWORD1 -Neo800KbpsMethod KEYWORD1 -Neo400KbpsMethod KEYWORD1 -NeoWs2813Method KEYWORD1 -NeoWs2812xMethod KEYWORD1 -NeoWs2812Method KEYWORD1 -NeoSk6812Method KEYWORD1 -NeoLc8812Method KEYWORD1 -NeoApa106Method KEYWORD1 -NeoEsp8266DmaWs2812xMethod KEYWORD1 -NeoEsp8266DmaSk6812Method KEYWORD1 -NeoEsp8266DmaApa106Method KEYWORD1 -NeoEsp8266Dma800KbpsMethod KEYWORD1 -NeoEsp8266Dma400KbpsMethod KEYWORD1 -NeoEsp8266Uart0Ws2813Method KEYWORD1 -NeoEsp8266Uart0Ws2812xMethod KEYWORD1 -NeoEsp8266Uart0Ws2812Method KEYWORD1 -NeoEsp8266Uart0Sk6812Method KEYWORD1 -NeoEsp8266Uart0Lc8812Method KEYWORD1 -NeoEsp8266Uart0Apa106Method KEYWORD1 -NeoEsp8266Uart0800KbpsMethod KEYWORD1 -NeoEsp8266Uart0400KbpsMethod KEYWORD1 -NeoEsp8266AsyncUart0Ws2813Method KEYWORD1 -NeoEsp8266AsyncUart0Ws2812xMethod KEYWORD1 -NeoEsp8266AsyncUart0Ws2812Method KEYWORD1 -NeoEsp8266AsyncUart0Sk6812Method KEYWORD1 -NeoEsp8266AsyncUart0Lc8812Method KEYWORD1 -NeoEsp8266AsyncUart0Apa106Method KEYWORD1 -NeoEsp8266AsyncUart0800KbpsMethod KEYWORD1 -NeoEsp8266AsyncUart0400KbpsMethod KEYWORD1 -NeoEsp8266Uart1Ws2813Method KEYWORD1 -NeoEsp8266Uart1Ws2812xMethod KEYWORD1 -NeoEsp8266Uart1Ws2812Method KEYWORD1 -NeoEsp8266Uart1Sk6812Method KEYWORD1 -NeoEsp8266Uart1Lc8812Method KEYWORD1 -NeoEsp8266Uart1Apa106Method KEYWORD1 -NeoEsp8266Uart1800KbpsMethod KEYWORD1 -NeoEsp8266Uart1400KbpsMethod KEYWORD1 -NeoEsp8266AsyncUart1Ws2813Method KEYWORD1 -NeoEsp8266AsyncUart1Ws2812xMethod KEYWORD1 -NeoEsp8266AsyncUart1Ws2812Method KEYWORD1 -NeoEsp8266AsyncUart1Sk6812Method KEYWORD1 -NeoEsp8266AsyncUart1Lc8812Method KEYWORD1 -NeoEsp8266AsyncUart1Apa106Method KEYWORD1 -NeoEsp8266AsyncUart1800KbpsMethod KEYWORD1 -NeoEsp8266AsyncUart1400KbpsMethod KEYWORD1 -NeoEsp8266BitBangWs2813Method KEYWORD1 -NeoEsp8266BitBangWs2812xMethod KEYWORD1 -NeoEsp8266BitBangWs2812Method KEYWORD1 -NeoEsp8266BitBangSk6812Method KEYWORD1 -NeoEsp8266BitBangLc8812Method KEYWORD1 -NeoEsp8266BitBangApa106Method KEYWORD1 -NeoEsp8266BitBang800KbpsMethod KEYWORD1 -NeoEsp8266BitBang400KbpsMethod KEYWORD1 -NeoEsp32Rmt0Ws2812xMethod KEYWORD1 -NeoEsp32Rmt0Sk6812Method KEYWORD1 -NeoEsp32Rmt0Apa106Method KEYWORD1 -NeoEsp32Rmt0800KbpsMethod KEYWORD1 -NeoEsp32Rmt0400KbpsMethod KEYWORD1 -NeoEsp32Rmt1Ws2812xMethod KEYWORD1 -NeoEsp32Rmt1Sk6812Method KEYWORD1 -NeoEsp32Rmt1Apa106Method KEYWORD1 -NeoEsp32Rmt1800KbpsMethod KEYWORD1 -NeoEsp32Rmt1400KbpsMethod KEYWORD1 -NeoEsp32Rmt2Ws2812xMethod KEYWORD1 -NeoEsp32Rmt2Sk6812Method KEYWORD1 -NeoEsp32Rmt2Apa106Method KEYWORD1 -NeoEsp32Rmt2800KbpsMethod KEYWORD1 -NeoEsp32Rmt2400KbpsMethod KEYWORD1 -NeoEsp32Rmt3Ws2812xMethod KEYWORD1 -NeoEsp32Rmt3Sk6812Method KEYWORD1 -NeoEsp32Rmt3Apa106Method KEYWORD1 -NeoEsp32Rmt3800KbpsMethod KEYWORD1 -NeoEsp32Rmt3400KbpsMethod KEYWORD1 -NeoEsp32Rmt4Ws2812xMethod KEYWORD1 -NeoEsp32Rmt4Sk6812Method KEYWORD1 -NeoEsp32Rmt4Apa106Method KEYWORD1 -NeoEsp32Rmt4800KbpsMethod KEYWORD1 -NeoEsp32Rmt4400KbpsMethod KEYWORD1 -NeoEsp32Rmt5Ws2812xMethod KEYWORD1 -NeoEsp32Rmt5Sk6812Method KEYWORD1 -NeoEsp32Rmt5Apa106Method KEYWORD1 -NeoEsp32Rmt5800KbpsMethod KEYWORD1 -NeoEsp32Rmt5400KbpsMethod KEYWORD1 -NeoEsp32Rmt6Ws2812xMethod KEYWORD1 -NeoEsp32Rmt6Sk6812Method KEYWORD1 -NeoEsp32Rmt6Apa106Method KEYWORD1 -NeoEsp32Rmt6800KbpsMethod KEYWORD1 -NeoEsp32Rmt6400KbpsMethod KEYWORD1 -NeoEsp32Rmt7Ws2812xMethod KEYWORD1 -NeoEsp32Rmt7Sk6812Method KEYWORD1 -NeoEsp32Rmt7Apa106Method KEYWORD1 -NeoEsp32Rmt7800KbpsMethod KEYWORD1 -NeoEsp32Rmt7400KbpsMethod KEYWORD1 -NeoEsp32BitBangWs2813Method KEYWORD1 -NeoEsp32BitBangWs2812xMethod KEYWORD1 -NeoEsp32BitBangWs2812Method KEYWORD1 -NeoEsp32BitBangSk6812Method KEYWORD1 -NeoEsp32BitBangLc8812Method KEYWORD1 -NeoEsp32BitBangApa106Method KEYWORD1 -NeoEsp32BitBang800KbpsMethod KEYWORD1 -NeoEsp32BitBang400KbpsMethod KEYWORD1 -DotStarMethod KEYWORD1 -DotStarSpiMethod KEYWORD1 -NeoPixelAnimator KEYWORD1 -AnimUpdateCallback KEYWORD1 -AnimationParam KEYWORD1 -NeoEase KEYWORD1 -AnimEaseFunction KEYWORD1 -RowMajorLayout KEYWORD1 -RowMajor90Layout KEYWORD1 -RowMajor180Layout KEYWORD1 -RowMajor270Layout KEYWORD1 -RowMajorAlternatingLayout KEYWORD1 -RowMajorAlternating90Layout KEYWORD1 -RowMajorAlternating180Layout KEYWORD1 -RowMajorAlternating270Layout KEYWORD1 -ColumnMajorLayout KEYWORD1 -ColumnMajor90Layout KEYWORD1 -ColumnMajor180Layout KEYWORD1 -ColumnMajor270Layout KEYWORD1 -ColumnMajorAlternatingLayout KEYWORD1 -ColumnMajorAlternating90Layout KEYWORD1 -ColumnMajorAlternating180Layout KEYWORD1 -ColumnMajorAlternating270Layout KEYWORD1 -NeoTopology KEYWORD1 -NeoRingTopology KEYWORD1 -NeoTiles KEYWORD1 -NeoMosaic KEYWORD1 -NeoGammaEquationMethod KEYWORD1 -NeoGammaTableMethod KEYWORD1 -NeoGamma KEYWORD1 -NeoHueBlendShortestDistance KEYWORD1 -NeoHueBlendLongestDistance KEYWORD1 -NeoHueBlendClockwiseDirection KEYWORD1 -NeoHueBlendCounterClockwiseDirection KEYWORD1 -NeoBufferContext KEYWORD1 -LayoutMapCallback KEYWORD1 -NeoBufferMethod KEYWORD1 -NeoBufferProgmemMethod KEYWORD1 -NeoBuffer KEYWORD1 -NeoVerticalSpriteSheet KEYWORD1 -NeoBitmapFile KEYWORD1 -HtmlShortColorNames KEYWORD1 -HtmlColorNames KEYWORD1 - -####################################### -# Methods and Functions (KEYWORD2) -####################################### - -Begin KEYWORD2 -Show KEYWORD2 -CanShow KEYWORD2 -ClearTo KEYWORD2 -RotateLeft KEYWORD2 -ShiftLeft KEYWORD2 -RotateRight KEYWORD2 -ShiftRight KEYWORD2 -IsDirty KEYWORD2 -Dirty KEYWORD2 -ResetDirty KEYWORD2 -Pixels KEYWORD2 -PixelsSize KEYWORD2 -PixelCount KEYWORD2 -SetPixelColor KEYWORD2 -GetPixelColor KEYWORD2 -SwapPixelColor KEYWORD2 -CalculateBrightness KEYWORD2 -Darken KEYWORD2 -Lighten KEYWORD2 -LinearBlend KEYWORD2 -BilinearBlend KEYWORD2 -IsAnimating KEYWORD2 -NextAvailableAnimation KEYWORD2 -StartAnimation KEYWORD2 -StopAnimation KEYWORD2 -RestartAnimation KEYWORD2 -IsAnimationActive KEYWORD2 -AnimationDuration KEYWORD2 -ChangeAnimationDuration KEYWORD2 -UpdateAnimations KEYWORD2 -IsPaused KEYWORD2 -Pause KEYWORD2 -Resume KEYWORD2 -getTimeScale KEYWORD2 -setTimeScale KEYWORD2 -QuadraticIn KEYWORD2 -QuadraticOut KEYWORD2 -QuadraticInOut KEYWORD2 -QuadraticCenter KEYWORD2 -CubicIn KEYWORD2 -CubicOut KEYWORD2 -CubicInOut KEYWORD2 -CubicCenter KEYWORD2 -QuarticIn KEYWORD2 -QuarticOut KEYWORD2 -QuarticInOut KEYWORD2 -QuarticCenter KEYWORD2 -QuinticIn KEYWORD2 -QuinticOut KEYWORD2 -QuinticInOut KEYWORD2 -QuinticCenter KEYWORD2 -SinusoidalIn KEYWORD2 -SinusoidalOut KEYWORD2 -SinusoidalInOut KEYWORD2 -SinusoidalCenter KEYWORD2 -ExponentialIn KEYWORD2 -ExponentialOut KEYWORD2 -ExponentialInOut KEYWORD2 -ExponentialCenter KEYWORD2 -CircularIn KEYWORD2 -CircularOut KEYWORD2 -CircularInOut KEYWORD2 -CircularCenter KEYWORD2 -Gamma KEYWORD2 -Map KEYWORD2 -MapProbe KEYWORD2 -getWidth KEYWORD2 -getHeight KEYWORD2 -RingPixelShift KEYWORD2 -RingPixelRotate KEYWORD2 -getCountOfRings KEYWORD2 -getPixelCountAtRing KEYWORD2 -getPixelCount KEYWORD2 -TopologyHint KEYWORD2 -Correct KEYWORD2 -SpriteWidth KEYWORD2 -SpriteHeight KEYWORD2 -SpriteCount KEYWORD2 -Blt KEYWORD2 -Width KEYWORD2 -Height KEYWORD2 -Parse KEYWORD2 -ToString KEYWORD2 -ToNumericalString KEYWORD2 - - -####################################### -# Constants (LITERAL1) -####################################### - -NEO_MILLISECONDS LITERAL1 -NEO_CENTISECONDS LITERAL1 -NEO_DECISECONDS LITERAL1 -NEO_SECONDS LITERAL1 -NEO_DECASECONDS LITERAL1 -AnimationState_Started LITERAL1 -AnimationState_Progress LITERAL1 -AnimationState_Completed LITERAL1 -NeoTopologyHint_FirstOnPanel LITERAL1 -NeoTopologyHint_InPanel LITERAL1 -NeoTopologyHint_LastOnPanel LITERAL1 -NeoTopologyHint_OutOfBounds LITERAL1 -PixelIndex_OutOfBounds LITERAL1 \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/library.json b/lib/NeoPixelBus-2.5.0.09/library.json deleted file mode 100644 index 76cb53848..000000000 --- a/lib/NeoPixelBus-2.5.0.09/library.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "NeoPixelBus", - "keywords": "NeoPixel, WS2811, WS2812, WS2813, SK6812, DotStar, APA102, RGB, RGBW", - "description": "A library that makes controlling NeoPixels (WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102) easy. Supports most Arduino platforms. Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. For Esp8266 it has three methods of sending NeoPixel data, DMA, UART, and Bit Bang. For Esp32 it has two base methods of sending NeoPixel data, i2s and RMT. For all platforms, there are two methods of sending DotStar data, hardware SPI and software SPI.", - "homepage": "https://github.com/Makuna/NeoPixelBus/wiki", - "repository": { - "type": "git", - "url": "https://github.com/Makuna/NeoPixelBus" - }, - "version": "2.5.0", - "frameworks": "arduino", - "platforms": "*" -} - diff --git a/lib/NeoPixelBus-2.5.0.09/library.properties b/lib/NeoPixelBus-2.5.0.09/library.properties deleted file mode 100644 index 5cac2ca18..000000000 --- a/lib/NeoPixelBus-2.5.0.09/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=NeoPixelBus by Makuna -version=2.5.0 -author=Michael C. Miller (makuna@live.com) -maintainer=Michael C. Miller (makuna@live.com) -sentence=A library that makes controlling NeoPixels (WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102) easy. -paragraph=Supports most Arduino platforms, including Esp8266 and Esp32. Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. Supports Matrix layout of pixels. Includes Gamma corretion object. For Esp8266 it has three methods of sending NeoPixel data, DMA, UART, and Bit Bang. For Esp32 it has two base methods of sending NeoPixel data, i2s and RMT. For all platforms, there are two methods of sending DotStar data, hardware SPI and software SPI. -category=Display -url=https://github.com/Makuna/NeoPixelBus/wiki -architectures=* \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarSpiMethod.h b/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarSpiMethod.h deleted file mode 100644 index 7c51816a1..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarSpiMethod.h +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for DotStars using SPI hardware (APA102). - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#include - -class DotStarSpiMethod -{ -public: - DotStarSpiMethod(uint16_t pixelCount, size_t elementSize) : - _sizeData(pixelCount * elementSize), - _sizeSendBuffer(calcBufferSize(pixelCount * elementSize)) - { - _sendBuffer = (uint8_t*)malloc(_sizeSendBuffer); - memset(_sendBuffer, 0, _sizeSendBuffer); - setEndFrameBytes(); - } - - ~DotStarSpiMethod() - { - SPI.end(); - free(_sendBuffer); - } - - bool IsReadyToUpdate() const - { - return true; // dot stars don't have a required delay - } - -#if defined(ARDUINO_ARCH_ESP32) - void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) - { - SPI.begin(sck, miso, mosi, ss); - } -#endif - - void Initialize() - { - SPI.begin(); - } - - void Update(bool) - { - SPI.beginTransaction(SPISettings(20000000L, MSBFIRST, SPI_MODE0)); -#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) - // ESPs have a method to write without inplace overwriting the send buffer - // since we don't care what gets received, use it for performance - SPI.writeBytes(_sendBuffer, _sizeSendBuffer); - -#else - // default ARDUINO transfer inplace overwrites the send buffer - // which is bad, so we have to send one byte at a time - uint8_t* out = _sendBuffer; - uint8_t* end = out + _sizeSendBuffer; - while (out < end) - { - SPI.transfer(*out++); - } -#endif - SPI.endTransaction(); - } - - uint8_t* getPixels() const - { - return _sendBuffer + _countStartFrame; - }; - - size_t getPixelsSize() const - { - return _sizeData; - }; - -private: - const size_t _countStartFrame = 4; - const size_t _sizeData; // size of actuall pixel data within _sendBuffer - const size_t _sizeSendBuffer; // Size of '_sendBuffer' buffer below - - uint8_t* _sendBuffer; // Holds SPI send Buffer, including LED color values - - size_t calcBufferSize(size_t sizePixels) const - { - const size_t countEndFrameBytes = calcEndFrameSize(sizePixels); - - // start frame + data + end frame - const size_t bufferSize = _countStartFrame + sizePixels + countEndFrameBytes; - return bufferSize; - } - - size_t calcEndFrameSize(size_t sizePixels) const - { - // end frame - // one bit for every two pixels with no less than 1 byte - return ((sizePixels / 4) + 15) / 16; - } - - void setEndFrameBytes() - { - uint8_t* pEndFrame = _sendBuffer + _countStartFrame + _sizeData; - uint8_t* pEndFrameStop = pEndFrame + calcEndFrameSize(_sizeData); - while (pEndFrame != pEndFrameStop) - { - *pEndFrame++ = 0xff; - } - } -}; - - - - diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32I2sMethod.h b/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32I2sMethod.h deleted file mode 100644 index d7856a1ef..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32I2sMethod.h +++ /dev/null @@ -1,217 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp32. - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#ifdef ARDUINO_ARCH_ESP32 - -extern "C" -{ -#include -#include "Esp32_i2s.h" -} - -const uint16_t c_dmaBytesPerPixelBytes = 4; - -class NeoEsp32I2sSpeedWs2812x -{ -public: - const static uint32_t I2sSampleRate = 100000; - const static uint16_t ByteSendTimeUs = 10; - const static uint16_t ResetTimeUs = 300; -}; - -class NeoEsp32I2sSpeedSk6812 -{ -public: - const static uint32_t I2sSampleRate = 100000; - const static uint16_t ByteSendTimeUs = 10; - const static uint16_t ResetTimeUs = 80; -}; - -class NeoEsp32I2sSpeed800Kbps -{ -public: - const static uint32_t I2sSampleRate = 100000; - const static uint16_t ByteSendTimeUs = 10; - const static uint16_t ResetTimeUs = 50; -}; - -class NeoEsp32I2sSpeed400Kbps -{ -public: - const static uint32_t I2sSampleRate = 50000; - const static uint16_t ByteSendTimeUs = 20; - const static uint16_t ResetTimeUs = 50; -}; - -class NeoEsp32I2sSpeedApa106 -{ -public: - const static uint32_t I2sSampleRate = 76000; - const static uint16_t ByteSendTimeUs = 14; - const static uint16_t ResetTimeUs = 50; -}; - -class NeoEsp32I2sBusZero -{ -public: - const static uint8_t I2sBusNumber = 0; -}; - -class NeoEsp32I2sBusOne -{ -public: - const static uint8_t I2sBusNumber = 1; -}; - -template class NeoEsp32I2sMethodBase -{ -public: - NeoEsp32I2sMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : - _pin(pin) - { - uint16_t dmaPixelSize = c_dmaBytesPerPixelBytes * elementSize; - uint16_t resetSize = c_dmaBytesPerPixelBytes * T_SPEED::ResetTimeUs / T_SPEED::ByteSendTimeUs; - - _pixelsSize = pixelCount * elementSize; - _i2sBufferSize = pixelCount * dmaPixelSize + resetSize; - - // must have a 4 byte aligned buffer for i2s - uint32_t alignment = _i2sBufferSize % 4; - if (alignment) - { - _i2sBufferSize += 4 - alignment; - } - - _pixels = static_cast(malloc(_pixelsSize)); - memset(_pixels, 0x00, _pixelsSize); - - _i2sBuffer = static_cast(malloc(_i2sBufferSize)); - memset(_i2sBuffer, 0x00, _i2sBufferSize); - } - - ~NeoEsp32I2sMethodBase() - { - while (!IsReadyToUpdate()) - { - yield(); - } - - pinMode(_pin, INPUT); - - free(_pixels); - free(_i2sBuffer); - } - - bool IsReadyToUpdate() const - { - return (i2sWriteDone(T_BUS::I2sBusNumber)); - } - - void Initialize() - { - size_t dmaCount = (_i2sBufferSize + I2S_DMA_MAX_DATA_LEN - 1) / I2S_DMA_MAX_DATA_LEN; - i2sInit(T_BUS::I2sBusNumber, 16, T_SPEED::I2sSampleRate, I2S_CHAN_STEREO, I2S_FIFO_16BIT_DUAL, dmaCount, 0); - i2sSetPins(T_BUS::I2sBusNumber, _pin, -1, -1, -1); - } - - void Update(bool) - { - // wait for not actively sending data - while (!IsReadyToUpdate()) - { - yield(); - } - - FillBuffers(); - - i2sWrite(T_BUS::I2sBusNumber, _i2sBuffer, _i2sBufferSize, false, false); - } - - uint8_t* getPixels() const - { - return _pixels; - }; - - size_t getPixelsSize() const - { - return _pixelsSize; - } - -private: - const uint8_t _pin; // output pin number - - size_t _pixelsSize; // Size of '_pixels' buffer - uint8_t* _pixels; // Holds LED color values - - uint32_t _i2sBufferSize; // total size of _i2sBuffer - uint8_t* _i2sBuffer; // holds the DMA buffer that is referenced by _i2sBufDesc - - void FillBuffers() - { - const uint16_t bitpatterns[16] = - { - 0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110, - 0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110, - 0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110, - 0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110, - }; - - uint16_t* pDma = reinterpret_cast(_i2sBuffer); - uint8_t* pPixelsEnd = _pixels + _pixelsSize; - for (uint8_t* pPixel = _pixels; pPixel < pPixelsEnd; pPixel++) - { - *(pDma++) = bitpatterns[((*pPixel) & 0x0f)]; - *(pDma++) = bitpatterns[((*pPixel) >> 4) & 0x0f]; - } - } -}; - -typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Ws2812xMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Sk6812Method; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s0800KbpsMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s0400KbpsMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Apa106Method; - -typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Ws2812xMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Sk6812Method; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s1800KbpsMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s1400KbpsMethod; -typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Apa106Method; - -// I2s Bus 1 method is the default method for Esp32 -typedef NeoEsp32I2s1Ws2812xMethod NeoWs2813Method; -typedef NeoEsp32I2s1Ws2812xMethod NeoWs2812xMethod; -typedef NeoEsp32I2s1800KbpsMethod NeoWs2812Method; -typedef NeoEsp32I2s1Sk6812Method NeoSk6812Method; -typedef NeoEsp32I2s1Sk6812Method NeoLc8812Method; -typedef NeoEsp32I2s1Apa106Method NeoApa106Method; - -typedef NeoEsp32I2s1Ws2812xMethod Neo800KbpsMethod; -typedef NeoEsp32I2s1400KbpsMethod Neo400KbpsMethod; - -#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32RmtMethod.h b/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32RmtMethod.h deleted file mode 100644 index 86669e509..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp32RmtMethod.h +++ /dev/null @@ -1,369 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp32. - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#ifdef ARDUINO_ARCH_ESP32 - -/* General Reference documentation for the APIs used in this implementation -LOW LEVEL: (what is actually used) -DOCS: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/rmt.html -EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c -HIGHER LEVEL: -NO TRANSLATE SUPPORT so this was not used -NOTE: https://github.com/espressif/arduino-esp32/commit/50d142950d229b8fabca9b749dc4a5f2533bc426 -Esp32-hal-rmt.h -Esp32-hal-rmt.c -*/ - -extern "C" -{ -#include -#include -} - -class NeoEsp32RmtSpeedBase -{ -public: - // ClkDiv of 2 provides for good resolution and plenty of reset resolution; but - // a ClkDiv of 1 will provide enough space for the longest reset and does show - // little better pulse accuracy - const static uint8_t RmtClockDivider = 2; - - inline constexpr static uint32_t FromNs(uint32_t ns) - { - return ns / NsPerRmtTick; - } - // this is used rather than the rmt_item32_t as you can't correctly initialize - // it as a static constexpr within the template - inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) - { - return (FromNs(nsLow) << 16) | (1 << 15) | (FromNs(nsHigh)); - } - -public: - const static uint32_t RmtCpu = 80000000L; // 80 mhz RMT clock - const static uint32_t NsPerSecond = 1000000000L; - const static uint32_t RmtTicksPerSecond = (RmtCpu / RmtClockDivider); - const static uint32_t NsPerRmtTick = (NsPerSecond / RmtTicksPerSecond); // about 25 -}; - -class NeoEsp32RmtSpeedWs2812x : public NeoEsp32RmtSpeedBase -{ -public: - const static uint32_t RmtBit0 = Item32Val(400, 850); - const static uint32_t RmtBit1 = Item32Val(800, 450); - const static uint16_t RmtDurationReset = FromNs(300000); // 300us -}; - -class NeoEsp32RmtSpeedSk6812 : public NeoEsp32RmtSpeedBase -{ -public: - const static uint32_t RmtBit0 = Item32Val(400, 850); - const static uint32_t RmtBit1 = Item32Val(800, 450); - const static uint16_t RmtDurationReset = FromNs(80000); // 80us -}; - -class NeoEsp32RmtSpeed800Kbps : public NeoEsp32RmtSpeedBase -{ -public: - const static uint32_t RmtBit0 = Item32Val(400, 850); - const static uint32_t RmtBit1 = Item32Val(800, 450); - const static uint16_t RmtDurationReset = FromNs(50000); // 50us -}; - -class NeoEsp32RmtSpeed400Kbps : public NeoEsp32RmtSpeedBase -{ -public: - const static uint32_t RmtBit0 = Item32Val(800, 1700); - const static uint32_t RmtBit1 = Item32Val(1600, 900); - const static uint16_t RmtDurationReset = FromNs(50000); // 50us -}; - -class NeoEsp32RmtSpeedApa106 : public NeoEsp32RmtSpeedBase -{ -public: - const static uint32_t RmtBit0 = Item32Val(400, 1250); - const static uint32_t RmtBit1 = Item32Val(1250, 400); - const static uint16_t RmtDurationReset = FromNs(50000); // 50us -}; - -class NeoEsp32RmtChannel0 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_0; -}; - -class NeoEsp32RmtChannel1 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_1; -}; - -class NeoEsp32RmtChannel2 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_2; -}; - -class NeoEsp32RmtChannel3 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3; -}; - -class NeoEsp32RmtChannel4 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_4; -}; - -class NeoEsp32RmtChannel5 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_5; -}; - -class NeoEsp32RmtChannel6 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_6; -}; - -class NeoEsp32RmtChannel7 -{ -public: - const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_7; -}; - -template class NeoEsp32RmtMethodBase -{ -public: - NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : - _pin(pin) - { - _pixelsSize = pixelCount * elementSize; - - _pixelsEditing = static_cast(malloc(_pixelsSize)); - memset(_pixelsEditing, 0x00, _pixelsSize); - - _pixelsSending = static_cast(malloc(_pixelsSize)); - // no need to initialize it, it gets overwritten on every send - } - - ~NeoEsp32RmtMethodBase() - { - // wait until the last send finishes before destructing everything - // arbitrary time out of 10 seconds - rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS); - - rmt_driver_uninstall(T_CHANNEL::RmtChannelNumber); - - free(_pixelsEditing); - free(_pixelsSending); - } - - - bool IsReadyToUpdate() const - { - return (ESP_OK == rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 0)); - } - - void Initialize() - { - rmt_config_t config; - - config.rmt_mode = RMT_MODE_TX; - config.channel = T_CHANNEL::RmtChannelNumber; - config.gpio_num = static_cast(_pin); - config.mem_block_num = 1; - config.tx_config.loop_en = false; - - config.tx_config.idle_output_en = true; - config.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; - - config.tx_config.carrier_en = false; - config.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; - - config.clk_div = T_SPEED::RmtClockDivider; - - rmt_config(&config); - rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, 0); - rmt_translator_init(T_CHANNEL::RmtChannelNumber, _translate); - } - - void Update(bool maintainBufferConsistency) - { - // wait for not actively sending data - // this will time out at 10 seconds, an arbitrarily long period of time - // and do nothing if this happens - if (ESP_OK == rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS)) - { - // now start the RMT transmit with the editing buffer before we swap - rmt_write_sample(T_CHANNEL::RmtChannelNumber, _pixelsEditing, _pixelsSize, false); - - if (maintainBufferConsistency) - { - // copy editing to sending, - // this maintains the contract that "colors present before will - // be the same after", otherwise GetPixelColor will be inconsistent - memcpy(_pixelsSending, _pixelsEditing, _pixelsSize); - } - - // swap so the user can modify without affecting the async operation - std::swap(_pixelsSending, _pixelsEditing); - } - } - - uint8_t* getPixels() const - { - return _pixelsEditing; - }; - - size_t getPixelsSize() const - { - return _pixelsSize; - } - -private: - const uint8_t _pin; // output pin number - - size_t _pixelsSize; // Size of '_pixels' buffer - uint8_t* _pixelsEditing; // Holds LED color values exposed for get and set - uint8_t* _pixelsSending; // Holds LED color values used to async send using RMT - - - // stranslate NeoPixelBuffer into RMT buffer - // this is done on the fly so we don't require a send buffer in raw RMT format - // which would be 32x larger than the primary buffer - static void IRAM_ATTR _translate(const void* src, - rmt_item32_t* dest, - size_t src_size, - size_t wanted_num, - size_t* translated_size, - size_t* item_num) - { - if (src == NULL || dest == NULL) - { - *translated_size = 0; - *item_num = 0; - return; - } - - size_t size = 0; - size_t num = 0; - const uint8_t* psrc = static_cast(src); - rmt_item32_t* pdest = dest; - - for (;;) - { - uint8_t data = *psrc; - - for (uint8_t bit = 0; bit < 8; bit++) - { - pdest->val = (data & 0x80) ? T_SPEED::RmtBit1 : T_SPEED::RmtBit0; - pdest++; - data <<= 1; - } - num += 8; - size++; - - // if this is the last byte we need to adjust the length of the last pulse - if (size >= src_size) - { - // extend the last bits LOW value to include the full reset signal length - pdest--; - pdest->duration1 = T_SPEED::RmtDurationReset; - // and stop updating data to send - break; - } - - if (num >= wanted_num) - { - // stop updating data to send - break; - } - - psrc++; - } - - *translated_size = size; - *item_num = num; - } -}; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsMethod; - -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106Method; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsMethod; -typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsMethod; - -// RMT is NOT the default method for Esp32, -// you are required to use a specific channel listed above - -#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.h b/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.h deleted file mode 100644 index 42c4c63bb..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.h +++ /dev/null @@ -1,434 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp8266 UART hardware - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#ifdef ARDUINO_ARCH_ESP8266 -#include - -// this template method class is used to track the data being sent on the uart -// when using the default serial ISR installed by the core -// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes -// -class NeoEsp8266UartContext -{ -public: - // Gets the number of bytes waiting in the TX FIFO - static inline uint8_t ICACHE_RAM_ATTR GetTxFifoLength(uint8_t uartNum) - { - return (USS(uartNum) >> USTXC) & 0xff; - } - // Append a byte to the TX FIFO - static inline void ICACHE_RAM_ATTR Enqueue(uint8_t uartNum, uint8_t value) - { - USF(uartNum) = value; - } - - static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum, - const volatile uint8_t* pixels, - const volatile uint8_t* end); -}; - -// this template method class is used to track the data being sent on the uart -// when using our own UART ISR -// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes -// -class NeoEsp8266UartInterruptContext : NeoEsp8266UartContext -{ -public: - NeoEsp8266UartInterruptContext() : - _asyncBuff(nullptr), - _asyncBuffEnd(nullptr) - { - } - - bool IsSending() - { - return (_asyncBuff != _asyncBuffEnd); - } - - void StartSending(uint8_t uartNum, uint8_t* start, uint8_t* end); - void Attach(uint8_t uartNum); - void Detach(uint8_t uartNum); - -private: - volatile const uint8_t* _asyncBuff; - volatile const uint8_t* _asyncBuffEnd; - volatile static NeoEsp8266UartInterruptContext* s_uartInteruptContext[2]; - - static void ICACHE_RAM_ATTR Isr(void* param); -}; - -// this template feature class is used a base for all others and contains -// common methods -// -class UartFeatureBase -{ -protected: - static void ConfigUart(uint8_t uartNum) - { - // clear all invert bits - USC0(uartNum) &= ~((1 << UCDTRI) | (1 << UCRTSI) | (1 << UCTXI) | (1 << UCDSRI) | (1 << UCCTSI) | (1 << UCRXI)); - // Invert the TX voltage associated with logic level so: - // - A logic level 0 will generate a Vcc signal - // - A logic level 1 will generate a Gnd signal - USC0(uartNum) |= (1 << UCTXI); - } -}; - -// this template feature class is used to define the specifics for uart0 -// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes -// -class UartFeature0 : UartFeatureBase -{ -public: - static const uint32_t Index = 0; - static void Init(uint32_t baud) - { - // Configure the serial line with 1 start bit (0), 6 data bits and 1 stop bit (1) - Serial.begin(baud, SERIAL_6N1, SERIAL_TX_ONLY); - ConfigUart(Index); - } -}; - -// this template feature class is used to define the specifics for uart1 -// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes -// -class UartFeature1 : UartFeatureBase -{ -public: - static const uint32_t Index = 1; - static void Init(uint32_t baud) - { - // Configure the serial line with 1 start bit (0), 6 data bits and 1 stop bit (1) - Serial1.begin(baud, SERIAL_6N1, SERIAL_TX_ONLY); - ConfigUart(Index); - } -}; - -// this template method class is used a base for all others and contains -// common properties and methods -// -// used by NeoEsp8266Uart and NeoEsp8266AsyncUart -// -class NeoEsp8266UartBase -{ -protected: - size_t _sizePixels; // Size of '_pixels' buffer below - uint8_t* _pixels; // Holds LED color values - uint32_t _startTime; // Microsecond count when last update started - - NeoEsp8266UartBase(uint16_t pixelCount, size_t elementSize) - { - _sizePixels = pixelCount * elementSize; - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0x00, _sizePixels); - } - - ~NeoEsp8266UartBase() - { - free(_pixels); - } - -}; - -// this template method class is used to glue uart feature and context for -// synchronous uart method -// -// used by NeoEsp8266UartMethodBase -// -template class NeoEsp8266Uart : public NeoEsp8266UartBase -{ -protected: - - NeoEsp8266Uart(uint16_t pixelCount, size_t elementSize) : - NeoEsp8266UartBase(pixelCount, elementSize) - { - } - - ~NeoEsp8266Uart() - { - // Wait until the TX fifo is empty. This way we avoid broken frames - // when destroying & creating a NeoPixelBus to change its length. - while (T_UARTCONTEXT::GetTxFifoLength(T_UARTFEATURE::Index) > 0) - { - yield(); - } - } - - void InitializeUart(uint32_t uartBaud) - { - T_UARTFEATURE::Init(uartBaud); - } - - void UpdateUart(bool) - { - // Since the UART can finish sending queued bytes in the FIFO in - // the background, instead of waiting for the FIFO to flush - // we annotate the start time of the frame so we can calculate - // when it will finish. - _startTime = micros(); - - // Then keep filling the FIFO until done - const uint8_t* ptr = _pixels; - const uint8_t* end = ptr + _sizePixels; - while (ptr != end) - { - ptr = const_cast(T_UARTCONTEXT::FillUartFifo(T_UARTFEATURE::Index, ptr, end)); - } - } -}; - -// this template method class is used to glue uart feature and context for -// asynchronously uart method -// -// This UART controller uses two buffers that are swapped in every call to -// NeoPixelBus.Show(). One buffer contains the data that is being sent -// asynchronosly and another buffer contains the data that will be send -// in the next call to NeoPixelBus.Show(). -// -// Therefore, the result of NeoPixelBus.Pixels() is invalidated after -// every call to NeoPixelBus.Show() and must not be cached. -// -// used by NeoEsp8266UartMethodBase -// -template class NeoEsp8266AsyncUart : public NeoEsp8266UartBase -{ -protected: - NeoEsp8266AsyncUart(uint16_t pixelCount, size_t elementSize) : - NeoEsp8266UartBase(pixelCount, elementSize) - { - _pixelsSending = (uint8_t*)malloc(_sizePixels); - } - - ~NeoEsp8266AsyncUart() - { - // Remember: the UART interrupt can be sending data from _pixelsSending in the background - while (_context.IsSending()) - { - yield(); - } - // detach context, which will disable intr, may disable ISR - _context.Detach(T_UARTFEATURE::Index); - - free(_pixelsSending); - } - - void ICACHE_RAM_ATTR InitializeUart(uint32_t uartBaud) - { - T_UARTFEATURE::Init(uartBaud); - - // attach the context, which will enable the ISR - _context.Attach(T_UARTFEATURE::Index); - } - - void UpdateUart(bool maintainBufferConsistency) - { - // Instruct ESP8266 hardware uart to send the pixels asynchronously - _context.StartSending(T_UARTFEATURE::Index, - _pixels, - _pixels + _sizePixels); - - // Annotate when we started to send bytes, so we can calculate when we are ready to send again - _startTime = micros(); - - if (maintainBufferConsistency) - { - // copy editing to sending, - // this maintains the contract that "colors present before will - // be the same after", otherwise GetPixelColor will be inconsistent - memcpy(_pixelsSending, _pixels, _sizePixels); - } - - // swap so the user can modify without affecting the async operation -// std::swap(_pixelsSending, _pixels); - uint8_t *temp = _pixelsSending; - _pixelsSending = _pixels; - _pixels = temp; - } - -private: - T_UARTCONTEXT _context; - - uint8_t* _pixelsSending; // Holds a copy of LED color values taken when UpdateUart began -}; - -class NeoEsp8266UartSpeed800KbpsBase -{ -public: - static const uint32_t ByteSendTimeUs = 10; // us it takes to send a single pixel element at 800khz speed - static const uint32_t UartBaud = 3200000; // 800mhz, 4 serial bytes per NeoByte -}; - -// NeoEsp8266UartSpeedWs2813 contains the timing constants used to get NeoPixelBus running with the Ws2813 -class NeoEsp8266UartSpeedWs2812x : public NeoEsp8266UartSpeed800KbpsBase -{ -public: - static const uint32_t ResetTimeUs = 300; // us between data send bursts to reset for next update -}; - -class NeoEsp8266UartSpeedSk6812 : public NeoEsp8266UartSpeed800KbpsBase -{ -public: - static const uint32_t ResetTimeUs = 80; // us between data send bursts to reset for next update -}; - -// NeoEsp8266UartSpeed800Kbps contains the timing constant used to get NeoPixelBus running at 800Khz -class NeoEsp8266UartSpeed800Kbps : public NeoEsp8266UartSpeed800KbpsBase -{ -public: - static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update -}; - -// NeoEsp8266UartSpeed400Kbps contains the timing constant used to get NeoPixelBus running at 400Khz -class NeoEsp8266UartSpeed400Kbps -{ -public: - static const uint32_t ByteSendTimeUs = 20; // us it takes to send a single pixel element at 400khz speed - static const uint32_t UartBaud = 1600000; // 400mhz, 4 serial bytes per NeoByte - static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update -}; - -// NeoEsp8266UartSpeedApa106 contains the timing constant used to get NeoPixelBus running for Apa106 -// Pulse cycle = 1.71 = 1.368 longer than normal, 0.731 slower, NeoEsp8266UartSpeedApa1066 -class NeoEsp8266UartSpeedApa106 -{ -public: - static const uint32_t ByteSendTimeUs = 14; // us it takes to send a single pixel element at 400khz speed - static const uint32_t UartBaud = 2339181; // APA106 pulse cycle of 1.71us, 4 serial bytes per NeoByte - static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update -}; - -// NeoEsp8266UartMethodBase is a light shell arround NeoEsp8266Uart or NeoEsp8266AsyncUart that -// implements the methods needed to operate as a NeoPixelBus method. -template -class NeoEsp8266UartMethodBase: public T_BASE -{ -public: - NeoEsp8266UartMethodBase(uint16_t pixelCount, size_t elementSize) - : T_BASE(pixelCount, elementSize) - { - } - NeoEsp8266UartMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) - : T_BASE(pixelCount, elementSize) - { - } - - bool IsReadyToUpdate() const - { - uint32_t delta = micros() - this->_startTime; - return delta >= getPixelTime() + T_SPEED::ResetTimeUs; - } - - void Initialize() - { - this->InitializeUart(T_SPEED::UartBaud); - - // Inverting logic levels can generate a phantom bit in the led strip bus - // We need to delay 50+ microseconds the output stream to force a data - // latch and discard this bit. Otherwise, that bit would be prepended to - // the first frame corrupting it. - this->_startTime = micros() - getPixelTime(); - } - - void Update(bool maintainBufferConsistency) - { - // Data latch = 50+ microsecond pause in the output stream. Rather than - // put a delay at the end of the function, the ending time is noted and - // the function will simply hold off (if needed) on issuing the - // subsequent round of data until the latch time has elapsed. This - // allows the mainline code to start generating the next frame of data - // rather than stalling for the latch. - while (!this->IsReadyToUpdate()) - { - yield(); - } - this->UpdateUart(maintainBufferConsistency); - } - - uint8_t* getPixels() const - { - return this->_pixels; - }; - - size_t getPixelsSize() const - { - return this->_sizePixels; - }; - -private: - uint32_t getPixelTime() const - { - return (T_SPEED::ByteSendTimeUs * this->_sizePixels); - }; -}; - -// uart 0 -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart0Ws2812xMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart0Sk6812Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart0Apa106Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart0800KbpsMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart0400KbpsMethod; - -typedef NeoEsp8266Uart0Ws2812xMethod NeoEsp8266Uart0Ws2813Method; -typedef NeoEsp8266Uart0800KbpsMethod NeoEsp8266Uart0Ws2812Method; -typedef NeoEsp8266Uart0Sk6812Method NeoEsp8266Uart0Lc8812Method; - -// uart 1 -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart1Ws2812xMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart1Sk6812Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart1Apa106Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart1800KbpsMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266Uart1400KbpsMethod; - -typedef NeoEsp8266Uart1Ws2812xMethod NeoEsp8266Uart1Ws2813Method; -typedef NeoEsp8266Uart1800KbpsMethod NeoEsp8266Uart1Ws2812Method; -typedef NeoEsp8266Uart1Sk6812Method NeoEsp8266Uart1Lc8812Method; - -// uart 0 async -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart0Ws2812xMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart0Sk6812Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart0Apa106Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart0800KbpsMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart0400KbpsMethod; - -typedef NeoEsp8266AsyncUart0Ws2812xMethod NeoEsp8266AsyncUart0Ws2813Method; -typedef NeoEsp8266AsyncUart0800KbpsMethod NeoEsp8266AsyncUart0Ws2812Method; -typedef NeoEsp8266AsyncUart0Sk6812Method NeoEsp8266AsyncUart0Lc8812Method; - -// uart 1 async -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart1Ws2812xMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart1Sk6812Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart1Apa106Method; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart1800KbpsMethod; -typedef NeoEsp8266UartMethodBase> NeoEsp8266AsyncUart1400KbpsMethod; - -typedef NeoEsp8266AsyncUart1Ws2812xMethod NeoEsp8266AsyncUart1Ws2813Method; -typedef NeoEsp8266AsyncUart1800KbpsMethod NeoEsp8266AsyncUart1Ws2812Method; -typedef NeoEsp8266AsyncUart1Sk6812Method NeoEsp8266AsyncUart1Lc8812Method; - -#endif - diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEspBitBangMethod.h b/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEspBitBangMethod.h deleted file mode 100644 index 361560213..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEspBitBangMethod.h +++ /dev/null @@ -1,195 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp8266 and Esp32 - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#pragma once - -#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) - -// ESP32 doesn't define ICACHE_RAM_ATTR -#ifndef ICACHE_RAM_ATTR -#define ICACHE_RAM_ATTR IRAM_ATTR -#endif - -// for esp8266, due to linker overriding the ICACHE_RAM_ATTR for cpp files, these methods are -// moved into a C file so the attribute will be applied correctly -// >> this may have been fixed and is no longer a requirement << -extern "C" void ICACHE_RAM_ATTR bitbang_send_pixels_800(uint8_t* pixels, uint8_t* end, uint8_t pin); -extern "C" void ICACHE_RAM_ATTR bitbang_send_pixels_400(uint8_t* pixels, uint8_t* end, uint8_t pin); - -class NeoEspBitBangSpeedWs2812x -{ -public: - static void send_pixels(uint8_t* pixels, uint8_t* end, uint8_t pin) - { - bitbang_send_pixels_800(pixels, end, pin); - } - static const uint32_t ResetTimeUs = 300; -}; - -class NeoEspBitBangSpeedSk6812 -{ -public: - static void send_pixels(uint8_t* pixels, uint8_t* end, uint8_t pin) - { - bitbang_send_pixels_800(pixels, end, pin); - } - static const uint32_t ResetTimeUs = 80; -}; - -class NeoEspBitBangSpeed800Kbps -{ -public: - static void send_pixels(uint8_t* pixels, uint8_t* end, uint8_t pin) - { - bitbang_send_pixels_800(pixels, end, pin); - } - static const uint32_t ResetTimeUs = 50; -}; - -class NeoEspBitBangSpeed400Kbps -{ -public: - static void send_pixels(uint8_t* pixels, uint8_t* end, uint8_t pin) - { - bitbang_send_pixels_400(pixels, end, pin); - } - static const uint32_t ResetTimeUs = 50; -}; - -template class NeoEspBitBangMethodBase -{ -public: - NeoEspBitBangMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : - _pin(pin) - { - pinMode(pin, OUTPUT); - - _sizePixels = pixelCount * elementSize; - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0, _sizePixels); - } - - ~NeoEspBitBangMethodBase() - { - pinMode(_pin, INPUT); - - free(_pixels); - } - - bool IsReadyToUpdate() const - { - uint32_t delta = micros() - _endTime; - - return (delta >= T_SPEED::ResetTimeUs); - } - - void Initialize() - { - digitalWrite(_pin, LOW); - - _endTime = micros(); - } - - void Update(bool) - { - // Data latch = 50+ microsecond pause in the output stream. Rather than - // put a delay at the end of the function, the ending time is noted and - // the function will simply hold off (if needed) on issuing the - // subsequent round of data until the latch time has elapsed. This - // allows the mainline code to start generating the next frame of data - // rather than stalling for the latch. - while (!IsReadyToUpdate()) - { - yield(); // allows for system yield if needed - } - - // Need 100% focus on instruction timing -#if defined(ARDUINO_ARCH_ESP32) - delay(1); // required - portMUX_TYPE updateMux = portMUX_INITIALIZER_UNLOCKED; - - portENTER_CRITICAL(&updateMux); -#else - noInterrupts(); -#endif - - T_SPEED::send_pixels(_pixels, _pixels + _sizePixels, _pin); - -#if defined(ARDUINO_ARCH_ESP32) - portEXIT_CRITICAL(&updateMux); -#else - interrupts(); -#endif - - // save EOD time for latch on next call - _endTime = micros(); - } - - uint8_t* getPixels() const - { - return _pixels; - }; - - size_t getPixelsSize() const - { - return _sizePixels; - }; - -private: - uint32_t _endTime; // Latch timing reference - size_t _sizePixels; // Size of '_pixels' buffer below - uint8_t* _pixels; // Holds LED color values - uint8_t _pin; // output pin number -}; - - -#if defined(ARDUINO_ARCH_ESP32) - -typedef NeoEspBitBangMethodBase NeoEsp32BitBangWs2812xMethod; -typedef NeoEspBitBangMethodBase NeoEsp32BitBangSk6812Method; -typedef NeoEspBitBangMethodBase NeoEsp32BitBang800KbpsMethod; -typedef NeoEspBitBangMethodBase NeoEsp32BitBang400KbpsMethod; - -typedef NeoEsp32BitBangWs2812xMethod NeoEsp32BitBangWs2813Method; -typedef NeoEsp32BitBang800KbpsMethod NeoEsp32BitBangWs2812Method; -typedef NeoEsp32BitBangSk6812Method NeoEsp32BitBangLc8812Method; -typedef NeoEsp32BitBang400KbpsMethod NeoEsp32BitBangApa106Method; - -#else - -typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2812xMethod; -typedef NeoEspBitBangMethodBase NeoEsp8266BitBangSk6812Method; -typedef NeoEspBitBangMethodBase NeoEsp8266BitBang800KbpsMethod; -typedef NeoEspBitBangMethodBase NeoEsp8266BitBang400KbpsMethod; - -typedef NeoEsp8266BitBangWs2812xMethod NeoEsp8266BitBangWs2813Method; -typedef NeoEsp8266BitBang800KbpsMethod NeoEsp8266BitBangWs2812Method; -typedef NeoEsp8266BitBangSk6812Method NeoEsp8266BitBangLc8812Method; -typedef NeoEsp8266BitBang400KbpsMethod NeoEsp8266BitBangApa106Method; -#endif - -// ESP bitbang doesn't have defaults and should avoided except for testing -#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelEsp.c b/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelEsp.c deleted file mode 100644 index f28a5755e..000000000 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelEsp.c +++ /dev/null @@ -1,169 +0,0 @@ -/*------------------------------------------------------------------------- -NeoPixel library helper functions for Esp8266 and Esp32. - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ - -#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) - -#include -#if defined(ARDUINO_ARCH_ESP8266) -#include -#endif - -// ESP32 doesn't define ICACHE_RAM_ATTR -#ifndef ICACHE_RAM_ATTR -#define ICACHE_RAM_ATTR IRAM_ATTR -#endif - -static uint32_t _getCycleCount(void) __attribute__((always_inline)); - -static inline uint32_t _getCycleCount(void) -{ - uint32_t ccount; - __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); - return ccount; -} - -#define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us -#define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us -#define CYCLES_800 (F_CPU / 800000) // 1.25us per bit -#define CYCLES_400_T0H (F_CPU / 2000000) -#define CYCLES_400_T1H (F_CPU / 833333) -#define CYCLES_400 (F_CPU / 400000) - -void ICACHE_RAM_ATTR bitbang_send_pixels_800(uint8_t* pixels, uint8_t* end, uint8_t pin) -{ - const uint32_t pinRegister = _BV(pin); - uint8_t mask = 0x80; - uint8_t subpix = *pixels++; - uint32_t cyclesStart = 0; // trigger emediately - uint32_t cyclesNext = 0; - - for (;;) - { - // do the checks here while we are waiting on time to pass - uint32_t cyclesBit = CYCLES_800_T0H; - if (subpix & mask) - { - cyclesBit = CYCLES_800_T1H; - } - - // after we have done as much work as needed for this next bit - // now wait for the HIGH - while (((cyclesStart = _getCycleCount()) - cyclesNext) < CYCLES_800); - - // set high -#if defined(ARDUINO_ARCH_ESP32) - GPIO.out_w1ts = pinRegister; -#else - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); -#endif - - // wait for the LOW - while ((_getCycleCount() - cyclesStart) < cyclesBit); - - // set low -#if defined(ARDUINO_ARCH_ESP32) - GPIO.out_w1tc = pinRegister; -#else - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); -#endif - cyclesNext = cyclesStart; - - // next bit - mask >>= 1; - if (mask == 0) - { - // no more bits to send in this byte - // check for another byte - if (pixels >= end) - { - // no more bytes to send so stop - break; - } - // reset mask to first bit and get the next byte - mask = 0x80; - subpix = *pixels++; - } - } -} - -void ICACHE_RAM_ATTR bitbang_send_pixels_400(uint8_t* pixels, uint8_t* end, uint8_t pin) -{ - const uint32_t pinRegister = _BV(pin); - uint8_t mask = 0x80; - uint8_t subpix = *pixels++; - uint32_t cyclesStart = 0; // trigger emediately - uint32_t cyclesNext = 0; - - for (;;) - { - // do the checks here while we are waiting on time to pass - uint32_t cyclesBit = CYCLES_400_T0H; - if (subpix & mask) - { - cyclesBit = CYCLES_400_T1H; - } - - // after we have done as much work as needed for this next bit - // now wait for the HIGH - while (((cyclesStart = _getCycleCount()) - cyclesNext) < CYCLES_400); - - // set high -#if defined(ARDUINO_ARCH_ESP32) - GPIO.out_w1ts = pinRegister; -#else - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); -#endif - - // wait for the LOW - while ((_getCycleCount() - cyclesStart) < cyclesBit); - - // set low -#if defined(ARDUINO_ARCH_ESP32) - GPIO.out_w1tc = pinRegister; -#else - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); -#endif - cyclesNext = cyclesStart; - - // next bit - mask >>= 1; - if (mask == 0) - { - // no more bits to send in this byte - // check for another byte - if (pixels >= end) - { - // no more bytes to send so stop - break; - } - // reset mask to first bit and get the next byte - mask = 0x80; - subpix = *pixels++; - } - } -} - -#endif diff --git a/lib/NeoPixelBus-2.5.0.09/.gitattributes b/lib/NeoPixelBus-2.6.0/.gitattributes similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/.gitattributes rename to lib/NeoPixelBus-2.6.0/.gitattributes diff --git a/lib/NeoPixelBus-2.6.0/.github/FUNDING.yml b/lib/NeoPixelBus-2.6.0/.github/FUNDING.yml new file mode 100644 index 000000000..459096e65 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: [makuna] +custom: ["https://paypal.me/MakunaGithub"] diff --git a/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/all-others.md b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/all-others.md new file mode 100644 index 000000000..1e4e000b9 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/all-others.md @@ -0,0 +1,14 @@ +--- +name: All others +about: If your issue doesn't fit the other two, this will guide you to support. +title: "[DELETE ME]" +labels: NOT AN ISSUE +assignees: '' + +--- + +### STOP +If you are seeking support, then please use the gitter channel by following this link. +[NeoPixelBus Gitter Channel](https://gitter.im/Makuna/NeoPixelBus) + +If you submit issues that are not traceable bugs or feature requests, it will get closed and you will be directed to the gitter channel. diff --git a/lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/bug_report.md b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/bug_report.md similarity index 97% rename from lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/bug_report.md rename to lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/bug_report.md index 9680fde4d..b042e6b67 100644 --- a/lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/bug_report.md +++ b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,6 +1,9 @@ --- name: Bug report about: Create a report to help us improve +title: '' +labels: '' +assignees: '' --- diff --git a/lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/feature_request.md b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/feature_request.md similarity index 96% rename from lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/feature_request.md rename to lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/feature_request.md index 6daf08040..c57bd0e6b 100644 --- a/lib/NeoPixelBus-2.5.0.09/.github/ISSUE_TEMPLATE/feature_request.md +++ b/lib/NeoPixelBus-2.6.0/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,6 +1,9 @@ --- name: Feature request about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' --- diff --git a/lib/NeoPixelBus-2.5.0.09/.gitignore b/lib/NeoPixelBus-2.6.0/.gitignore similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/.gitignore rename to lib/NeoPixelBus-2.6.0/.gitignore diff --git a/lib/NeoPixelBus-2.5.0.09/COPYING b/lib/NeoPixelBus-2.6.0/COPYING similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/COPYING rename to lib/NeoPixelBus-2.6.0/COPYING diff --git a/lib/NeoPixelBus-2.5.0.09/ReadMe.md b/lib/NeoPixelBus-2.6.0/ReadMe.md similarity index 76% rename from lib/NeoPixelBus-2.5.0.09/ReadMe.md rename to lib/NeoPixelBus-2.6.0/ReadMe.md index a3ff660be..7e76411f6 100644 --- a/lib/NeoPixelBus-2.5.0.09/ReadMe.md +++ b/lib/NeoPixelBus-2.6.0/ReadMe.md @@ -4,15 +4,13 @@ Arduino NeoPixel library -A library to control one wire protocol RGB and RGBW leds like SK6812, WS2811, WS2812 and WS2813 that are commonly refered to as NeoPixels and two wire protocol RGB like APA102 commonly refered to as DotStars. +A library to control one wire protocol RGB and RGBW leds like APA106, SK6812, WS2811, WS2812 and WS2813 that are commonly refered to as NeoPixels and two wire protocol RGB like Lpd8806, APA102 and SK9822 commonly refered to as DotStars. Supports most Arduino platforms. -This is the most functional library for the Esp8266 as it provides solutions for all Esp8266 module types even when WiFi is used. - Please read this best practices link before connecting your NeoPixels, it will save you a lot of time and effort. [Adafruit NeoPixel Best Practices](https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices) -For quick questions jump on Gitter and ask away. +For quick questions and support jump on Gitter and ask away. [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Makuna/NeoPixelBus?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) For bugs, make sure there isn't an active issue and then create one. diff --git a/lib/NeoPixelBus-2.5.0.09/examples/DotStarTest/DotStarTest.ino b/lib/NeoPixelBus-2.6.0/examples/DotStarTest/DotStarTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/DotStarTest/DotStarTest.ino rename to lib/NeoPixelBus-2.6.0/examples/DotStarTest/DotStarTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/NeoPixelBrightness/NeoPixelBrightness.ino b/lib/NeoPixelBus-2.6.0/examples/NeoPixelBrightness/NeoPixelBrightness.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/NeoPixelBrightness/NeoPixelBrightness.ino rename to lib/NeoPixelBus-2.6.0/examples/NeoPixelBrightness/NeoPixelBrightness.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/NeoPixelGamma/NeoPixelGamma.ino b/lib/NeoPixelBus-2.6.0/examples/NeoPixelGamma/NeoPixelGamma.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/NeoPixelGamma/NeoPixelGamma.ino rename to lib/NeoPixelBus-2.6.0/examples/NeoPixelGamma/NeoPixelGamma.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/NeoPixelTest/NeoPixelTest.ino b/lib/NeoPixelBus-2.6.0/examples/NeoPixelTest/NeoPixelTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/NeoPixelTest/NeoPixelTest.ino rename to lib/NeoPixelBus-2.6.0/examples/NeoPixelTest/NeoPixelTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino similarity index 99% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino index 4f0386abe..fc3a372f9 100644 --- a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino +++ b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelAnimation/NeoPixelAnimation.ino @@ -53,7 +53,7 @@ NeoPixelAnimator animations(PixelCount, NEO_CENTISECONDS); // NEO_DECASECONDS 10000 // ~7.5 days, 10 second updates // -#ifdef ARDUINO_ARCH_AVR +#if defined(NEOPIXEBUS_NO_STL) // for AVR, you need to manage the state due to lack of STL/compiler support // for Esp8266 you can define the function using a lambda and state is created for you // see below for an example @@ -158,7 +158,7 @@ void SetupAnimationSet() break; } -#ifdef ARDUINO_ARCH_AVR +#if defined(NEOPIXEBUS_NO_STL) // each animation starts with the color that was present animationState[pixel].StartingColor = originalColor; // and ends with a random color diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelCylon/NeoPixelCylon.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelCylon/NeoPixelCylon.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelCylon/NeoPixelCylon.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelCylon/NeoPixelCylon.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunFadeInOut/NeoPixelFunFadeInOut.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunLoop/NeoPixelFunLoop.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunLoop/NeoPixelFunLoop.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunLoop/NeoPixelFunLoop.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunLoop/NeoPixelFunLoop.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelFunRandomChange/NeoPixelFunRandomChange.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelRotateLoop/NeoPixelRotateLoop.ino b/lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelRotateLoop/NeoPixelRotateLoop.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/animations/NeoPixelRotateLoop/NeoPixelRotateLoop.ino rename to lib/NeoPixelBus-2.6.0/examples/animations/NeoPixelRotateLoop/NeoPixelRotateLoop.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/NeoPixelBitmap.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/Strings.bmp b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/Strings.bmp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/Strings.bmp rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/Strings.bmp diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/StringsW.bmp b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/StringsW.bmp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBitmap/StringsW.bmp rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBitmap/StringsW.bmp diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/Cylon.pdn b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/Cylon.pdn similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/Cylon.pdn rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/Cylon.pdn diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/CylonGrb.h b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/CylonGrb.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/CylonGrb.h rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/CylonGrb.h diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/CylonGrbw.h b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/CylonGrbw.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/CylonGrbw.h rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/CylonGrbw.h diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferCylon/NeoPixelBufferCylon.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferShader/NeoPixelBufferShader.ino b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferShader/NeoPixelBufferShader.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelBufferShader/NeoPixelBufferShader.ino rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelBufferShader/NeoPixelBufferShader.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelDibTest/NeoPixelDibTest.ino b/lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelDibTest/NeoPixelDibTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/bitmaps/NeoPixelDibTest/NeoPixelDibTest.ino rename to lib/NeoPixelBus-2.6.0/examples/bitmaps/NeoPixelDibTest/NeoPixelDibTest.ino diff --git a/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentBus/NeoSegmentBus.ino b/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentBus/NeoSegmentBus.ino new file mode 100644 index 000000000..7ee1beb25 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentBus/NeoSegmentBus.ino @@ -0,0 +1,36 @@ +// NeoSegmentBus +// This example will demonstrate using the NeoSegmentBus which provides support for a +// seven segment LED digit driven by three WS2811; connected in series with other digits +// +// See https://shop.idlehandsdev.com/products/addressable-7-segment-display for a hardware example +// +// This example will print the string "3.14" and then rotate it through the available digits +// + +#include + +const uint16_t DigitCount = 4; // Max Digits, not segments, not pixels +const uint8_t BusPin = 2; // make sure to set this to the correct pin, ignored for Esp8266 + +#define brightness 128 + +NeoPixelSegmentBus strip(DigitCount, BusPin); + +void setup() +{ + strip.Begin(); + strip.Show(); // clears all digits by default + + delay(500); + strip.SetString(0, "3.14", brightness); + strip.Show(); +} + +void loop() +{ + delay(2000); + + strip.RotateLeft(1); + strip.Show(); +} + diff --git a/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentFade/NeoSegmentFade.ino b/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentFade/NeoSegmentFade.ino new file mode 100644 index 000000000..98d9e591a --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/examples/sevensegment/NeoSegmentFade/NeoSegmentFade.ino @@ -0,0 +1,144 @@ +// NeoSegmentBus +// This example will demonstrate using the NeoSegmentBus which provides support for a +// seven segment LED digit driven by three WS2811; connected in series with other digits +// +// See https://shop.idlehandsdev.com/products/addressable-7-segment-display for a hardware example +// +// This example will print current seconds since start of the Arduino +// with a digit animating a circling path for each second +// + +#include +#include + +const uint16_t DigitCount = 5; // Max Digits, not segments, not pixels +const uint8_t BusPin = 2; // make sure to set this to the correct pin, ignored for Esp8266 +const uint16_t CycleDigit = 0; +const uint16_t SecondsDigit = 1; + +#define brightness 128 + +NeoPixelSegmentBus strip(DigitCount, BusPin); + +enum Animation +{ + Animation_Cycle, // animation for the cycle indicator + Animation_Fade, // animation for fade of seconds + Animation_COUNT +}; + +NeoPixelAnimator animations(Animation_COUNT); + +void CycleAnimation(const AnimationParam& param) +{ + // calculate which segment should be on using the animation progress + uint8_t bitfield = 1 << (uint8_t)(param.progress * LedSegment_F); + // instant a digit with that segment on + SevenSegDigit digit(bitfield, brightness); + // apply it to the strip + strip.SetPixelColor(CycleDigit, digit); +} + +// for the animation of fading the new number in, we use +// two digit DIBs (Device Independant Bitmaps) of SevenSegDigit to blend with; +// each sized one less than the strip due to the first is a used for the cycle +// animation. +typedef NeoDib SevenSegDib; + +SevenSegDib StartingDigits(DigitCount - 1); +SevenSegDib EndingDigits(DigitCount - 1); + +// shader class that will do the "string" blending +// +class DigitBlendShader +{ +public: + // this shader always renders and doesn't track a dirty state + bool IsDirty() const + { + return true; + } + + void ResetDirty() + { + } + + SevenSegDigit Apply(uint16_t indexDigit, SevenSegDigit digit) + { + // since we call EndingDigits.Render below, the digit argument is + // from the EndingDigits so no need to call GetPixelColor to get it + // create a digit that is a blend between the last seconds + // value and the next seconds value using the BlendAmount + SevenSegDigit blendDigit = SevenSegDigit::LinearBlend( + StartingDigits.GetPixelColor(indexDigit), + digit, + BlendAmount); + + return blendDigit; + } + + float BlendAmount; +}; + +// the instance of our shader class +DigitBlendShader blendShader; + +void FadeAnimation(const AnimationParam& param) +{ + // set the shader property BlendAmount to the animation progress + blendShader.BlendAmount = param.progress; + // apply it to the strip at the SecondsDigit location + EndingDigits.Render(strip, + blendShader, + SecondsDigit); +} + +uint32_t lastSeconds; + +void setup() +{ + lastSeconds = millis() / 1000; + + strip.Begin(); + strip.Show(); + + // init animation Dibs as cleared + StartingDigits.ClearTo(0); + EndingDigits.ClearTo(0); +} + +void loop() +{ + uint32_t seconds = millis() / 1000; + + // when the seconds change, start animations for the update + // + if (seconds != lastSeconds) + { + // copy last animation ending digits as starting digits + StartingDigits = EndingDigits; + + // format and display new value in ending digits dib + String display(seconds); + SevenSegDigit::SetString(EndingDigits, + 0, + display.c_str(), + brightness); + + // start the seconds fade animation + animations.StartAnimation(Animation_Fade, 1000, FadeAnimation); + + // start the cycle animation for the next second + animations.StartAnimation(Animation_Cycle, 1000, CycleAnimation); + + lastSeconds = seconds; + } + + if (animations.IsAnimating()) + { + // the normal loop just needs these two to run the active animations + animations.UpdateAnimations(); + strip.Show(); + } +} + diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelMosaicTest/NeoPixelMosaicTest.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelMosaicTest/NeoPixelMosaicTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelMosaicTest/NeoPixelMosaicTest.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelMosaicTest/NeoPixelMosaicTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelRingTopologyTest/NeoPixelRingTopologyTest.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelRingTopologyTest/NeoPixelRingTopologyTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelRingTopologyTest/NeoPixelRingTopologyTest.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelRingTopologyTest/NeoPixelRingTopologyTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTilesTest/NeoPixelTilesTest.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTilesTest/NeoPixelTilesTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTilesTest/NeoPixelTilesTest.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTilesTest/NeoPixelTilesTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino diff --git a/lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTopologyTest/NeoPixelTopologyTest.ino b/lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTopologyTest/NeoPixelTopologyTest.ino similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/examples/topologies/NeoPixelTopologyTest/NeoPixelTopologyTest.ino rename to lib/NeoPixelBus-2.6.0/examples/topologies/NeoPixelTopologyTest/NeoPixelTopologyTest.ino diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/circular.png b/lib/NeoPixelBus-2.6.0/extras/curves/circular.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/circular.png rename to lib/NeoPixelBus-2.6.0/extras/curves/circular.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/cubic.png b/lib/NeoPixelBus-2.6.0/extras/curves/cubic.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/cubic.png rename to lib/NeoPixelBus-2.6.0/extras/curves/cubic.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/different.png b/lib/NeoPixelBus-2.6.0/extras/curves/different.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/different.png rename to lib/NeoPixelBus-2.6.0/extras/curves/different.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/exponential.png b/lib/NeoPixelBus-2.6.0/extras/curves/exponential.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/exponential.png rename to lib/NeoPixelBus-2.6.0/extras/curves/exponential.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/gamma.png b/lib/NeoPixelBus-2.6.0/extras/curves/gamma.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/gamma.png rename to lib/NeoPixelBus-2.6.0/extras/curves/gamma.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/pronounced.png b/lib/NeoPixelBus-2.6.0/extras/curves/pronounced.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/pronounced.png rename to lib/NeoPixelBus-2.6.0/extras/curves/pronounced.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/quadratic.png b/lib/NeoPixelBus-2.6.0/extras/curves/quadratic.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/quadratic.png rename to lib/NeoPixelBus-2.6.0/extras/curves/quadratic.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/quintic.png b/lib/NeoPixelBus-2.6.0/extras/curves/quintic.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/quintic.png rename to lib/NeoPixelBus-2.6.0/extras/curves/quintic.png diff --git a/lib/NeoPixelBus-2.5.0.09/extras/curves/sinusoidal.png b/lib/NeoPixelBus-2.6.0/extras/curves/sinusoidal.png similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/extras/curves/sinusoidal.png rename to lib/NeoPixelBus-2.6.0/extras/curves/sinusoidal.png diff --git a/lib/NeoPixelBus-2.6.0/keywords.txt b/lib/NeoPixelBus-2.6.0/keywords.txt new file mode 100644 index 000000000..ca68e0715 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/keywords.txt @@ -0,0 +1,539 @@ +####################################### +# Syntax Coloring Map NeoPixelBus +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +NeoPixelBus KEYWORD1 +NeoPixelSegmentBus KEYWORD1 +RgbwColor KEYWORD1 +RgbColor KEYWORD1 +HslColor KEYWORD1 +HsbColor KEYWORD1 +HtmlColor KEYWORD1 +NeoNoSettings KEYWORD1 +NeoTm1814Settings KEYWORD1 +NeoGrbFeature KEYWORD1 +NeoGrbwFeature KEYWORD1 +NeoRgbwFeature KEYWORD1 +NeoRgbFeature KEYWORD1 +NeoBrgFeature KEYWORD1 +NeoRbgFeature KEYWORD1 +NeoWrgbTm1814Feature KEYWORD1 +DotStarBgrFeature KEYWORD1 +DotStarLbgrFeature KEYWORD1 +Lpd8806GrbFeature KEYWORD1 +P9813BgrFeature KEYWORD1 +SevenSegmentFeature KEYWORD1 +Neo800KbpsMethod KEYWORD1 +Neo400KbpsMethod KEYWORD1 +NeoWs2813Method KEYWORD1 +NeoWs2812xMethod KEYWORD1 +NeoWs2812Method KEYWORD1 +NeoWs2811Method KEYWORD1 +NeoSk6812Method KEYWORD1 +NeoTm1814Method KEYWORD1 +NeoLc8812Method KEYWORD1 +NeoApa106Method KEYWORD1 +Neo800KbpsInvertedMethod KEYWORD1 +Neo400KbpsInvertedMethod KEYWORD1 +NeoWs2813InvertedMethod KEYWORD1 +NeoWs2812xInvertedMethod KEYWORD1 +NeoWs2812InvertedMethod KEYWORD1 +NeoWs2811InvertedMethod KEYWORD1 +NeoSk6812InvertedMethod KEYWORD1 +NeoTm1814InvertedMethod KEYWORD1 +NeoLc8812InvertedMethod KEYWORD1 +NeoApa106InvertedMethod KEYWORD1 +NeoEsp8266DmaWs2812xMethod KEYWORD1 +NeoEsp8266DmaSk6812Method KEYWORD1 +NeoEsp8266DmaTm1814Method KEYWORD1 +NeoEsp8266DmaApa106Method KEYWORD1 +NeoEsp8266Dma800KbpsMethod KEYWORD1 +NeoEsp8266Dma400KbpsMethod KEYWORD1 +NeoEsp8266DmaInvertedWs2812xMethod KEYWORD1 +NeoEsp8266DmaInvertedSk6812Method KEYWORD1 +NeoEsp8266DmaInvertedTm1814Method KEYWORD1 +NeoEsp8266DmaInvertedApa106Method KEYWORD1 +NeoEsp8266DmaInverted800KbpsMethod KEYWORD1 +NeoEsp8266DmaInverted400KbpsMethod KEYWORD1 +NeoEsp8266Uart0Ws2813Method KEYWORD1 +NeoEsp8266Uart0Ws2812xMethod KEYWORD1 +NeoEsp8266Uart0Ws2812Method KEYWORD1 +NeoEsp8266Uart0Ws2811Method KEYWORD1 +NeoEsp8266Uart0Sk6812Method KEYWORD1 +NeoEsp8266Uart0Tm1814Method KEYWORD1 +NeoEsp8266Uart0Lc8812Method KEYWORD1 +NeoEsp8266Uart0Apa106Method KEYWORD1 +NeoEsp8266Uart0800KbpsMethod KEYWORD1 +NeoEsp8266Uart0400KbpsMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2813Method KEYWORD1 +NeoEsp8266AsyncUart0Ws2812xMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2812Method KEYWORD1 +NeoEsp8266AsyncUart0Ws2811Method KEYWORD1 +NeoEsp8266AsyncUart0Sk6812Method KEYWORD1 +NeoEsp8266AsyncUart0Tm1814Method KEYWORD1 +NeoEsp8266AsyncUart0Lc8812Method KEYWORD1 +NeoEsp8266AsyncUart0Apa106Method KEYWORD1 +NeoEsp8266AsyncUart0800KbpsMethod KEYWORD1 +NeoEsp8266AsyncUart0400KbpsMethod KEYWORD1 +NeoEsp8266Uart1Ws2813Method KEYWORD1 +NeoEsp8266Uart1Ws2812xMethod KEYWORD1 +NeoEsp8266Uart1Ws2812Method KEYWORD1 +NeoEsp8266Uart1Ws2811Method KEYWORD1 +NeoEsp8266Uart1Sk6812Method KEYWORD1 +NeoEsp8266Uart1Tm1814 KEYWORD1 +NeoEsp8266Uart1Lc8812Method KEYWORD1 +NeoEsp8266Uart1Apa106Method KEYWORD1 +NeoEsp8266Uart1800KbpsMethod KEYWORD1 +NeoEsp8266Uart1400KbpsMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2813Method KEYWORD1 +NeoEsp8266AsyncUart1Ws2812xMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2812Method KEYWORD1 +NeoEsp8266AsyncUart1Ws2811Method KEYWORD1 +NeoEsp8266AsyncUart1Sk6812Method KEYWORD1 +NeoEsp8266AsyncUart1Tm1814 KEYWORD1 +NeoEsp8266AsyncUart1Lc8812Method KEYWORD1 +NeoEsp8266AsyncUart1Apa106Method KEYWORD1 +NeoEsp8266AsyncUart1800KbpsMethod KEYWORD1 +NeoEsp8266AsyncUart1400KbpsMethod KEYWORD1 +NeoEsp8266Uart0Ws2813InvertedMethod KEYWORD1 +NeoEsp8266Uart0Ws2812xInvertedMethod KEYWORD1 +NeoEsp8266Uart0Ws2812InvertedMethod KEYWORD1 +NeoEsp8266Uart0Ws2811InvertedMethod KEYWORD1 +NeoEsp8266Uart0Sk6812InvertedMethod KEYWORD1 +NeoEsp8266Uart0Tm1814InvertedMethod KEYWORD1 +NeoEsp8266Uart0Lc8812InvertedMethod KEYWORD1 +NeoEsp8266Uart0Apa106InvertedMethod KEYWORD1 +NeoEsp8266Uart0800KbpsInvertedMethod KEYWORD1 +NeoEsp8266Uart0400KbpsInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2813InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2812xInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Ws2811InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Sk6812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Tm1814InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Lc8812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0Apa106InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0800KbpsInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart0400KbpsInvertedMethod KEYWORD1 +NeoEsp8266Uart1Ws2813InvertedMethod KEYWORD1 +NeoEsp8266Uart1Ws2812xInvertedMethod KEYWORD1 +NeoEsp8266Uart1Ws2812InvertedMethod KEYWORD1 +NeoEsp8266Uart1Ws2811InvertedMethod KEYWORD1 +NeoEsp8266Uart1Sk6812InvertedMethod KEYWORD1 +NeoEsp8266Uart1Tm1814InvertedMethod KEYWORD1 +NeoEsp8266Uart1Lc8812InvertedMethod KEYWORD1 +NeoEsp8266Uart1Apa106InvertedMethod KEYWORD1 +NeoEsp8266Uart1800KbpsInvertedMethod KEYWORD1 +NeoEsp8266Uart1400KbpsInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2813InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2812xInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Ws2811InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Sk6812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Tm1814InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Lc8812InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1Apa106InvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1800KbpsInvertedMethod KEYWORD1 +NeoEsp8266AsyncUart1400KbpsInvertedMethod KEYWORD1 +NeoEsp8266BitBangWs2813Method KEYWORD1 +NeoEsp8266BitBangWs2812xMethod KEYWORD1 +NeoEsp8266BitBangWs2812Method KEYWORD1 +NeoEsp8266BitBangWs2811Method KEYWORD1 +NeoEsp8266BitBangSk6812Method KEYWORD1 +NeoEsp8266BitBangTm1814Method KEYWORD1 +NeoEsp8266BitBangLc8812Method KEYWORD1 +NeoEsp8266BitBangApa106Method KEYWORD1 +NeoEsp8266BitBang800KbpsMethod KEYWORD1 +NeoEsp8266BitBang400KbpsMethod KEYWORD1 +NeoEsp8266BitBangWs2813InvertedMethod KEYWORD1 +NeoEsp8266BitBangWs2812xInvertedMethod KEYWORD1 +NeoEsp8266BitBangWs2812InvertedMethod KEYWORD1 +NeoEsp8266BitBangWs2811InvertedMethod KEYWORD1 +NeoEsp8266BitBangSk6812InvertedMethod KEYWORD1 +NeoEsp8266BitBangTm1814InvertedMethod KEYWORD1 +NeoEsp8266BitBangLc8812InvertedMethod KEYWORD1 +NeoEsp8266BitBangApa106InvertedMethod KEYWORD1 +NeoEsp8266BitBang800KbpsInvertedMethod KEYWORD1 +NeoEsp8266BitBang400KbpsInvertedMethod KEYWORD1 +NeoEsp32I2s0Ws2812xMethod KEYWORD1 +NeoEsp32I2s0Sk6812Method KEYWORD1 +NeoEsp32I2s0Tm1814Method KEYWORD1 +NeoEsp32I2s0800KbpsMethod KEYWORD1 +NeoEsp32I2s0400KbpsMethod KEYWORD1 +NeoEsp32I2s0Apa106Method KEYWORD1 +NeoEsp32I2s1Ws2812xMethod KEYWORD1 +NeoEsp32I2s1Sk6812Method KEYWORD1 +NeoEsp32I2s1Tm1814Method KEYWORD1 +NeoEsp32I2s1800KbpsMethod KEYWORD1 +NeoEsp32I2s1400KbpsMethod KEYWORD1 +NeoEsp32I2s1Apa106Method KEYWORD1 +NeoEsp32I2s0Ws2812xInvertedMethod KEYWORD1 +NeoEsp32I2s0Sk6812InvertedMethod KEYWORD1 +NeoEsp32I2s0Tm1814InvertedMethod KEYWORD1 +NeoEsp32I2s0800KbpsInvertedMethod KEYWORD1 +NeoEsp32I2s0400KbpsInvertedMethod KEYWORD1 +NeoEsp32I2s0Apa106InvertedMethod KEYWORD1 +NeoEsp32I2s1Ws2812xInvertedMethod KEYWORD1 +NeoEsp32I2s1Sk6812InvertedMethod KEYWORD1 +NeoEsp32I2s1Tm1814InvertedMethod KEYWORD1 +NeoEsp32I2s1800KbpsInvertedMethod KEYWORD1 +NeoEsp32I2s1400KbpsInvertedMethod KEYWORD1 +NeoEsp32I2s1Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt0Ws2811Method KEYWORD1 +NeoEsp32Rmt0Ws2812xMethod KEYWORD1 +NeoEsp32Rmt0Sk6812Method KEYWORD1 +NeoEsp32Rmt0Tm1814Method KEYWORD1 +NeoEsp32Rmt0Apa106Method KEYWORD1 +NeoEsp32Rmt0800KbpsMethod KEYWORD1 +NeoEsp32Rmt0400KbpsMethod KEYWORD1 +NeoEsp32Rmt1Ws2811Method KEYWORD1 +NeoEsp32Rmt1Ws2812xMethod KEYWORD1 +NeoEsp32Rmt1Sk6812Method KEYWORD1 +NeoEsp32Rmt1Tm1814Method KEYWORD1 +NeoEsp32Rmt1Apa106Method KEYWORD1 +NeoEsp32Rmt1800KbpsMethod KEYWORD1 +NeoEsp32Rmt1400KbpsMethod KEYWORD1 +NeoEsp32Rmt2Ws2811Method KEYWORD1 +NeoEsp32Rmt2Ws2812xMethod KEYWORD1 +NeoEsp32Rmt2Sk6812Method KEYWORD1 +NeoEsp32Rmt2Tm1814Method KEYWORD1 +NeoEsp32Rmt2Apa106Method KEYWORD1 +NeoEsp32Rmt2800KbpsMethod KEYWORD1 +NeoEsp32Rmt2400KbpsMethod KEYWORD1 +NeoEsp32Rmt3Ws2811Method KEYWORD1 +NeoEsp32Rmt3Ws2812xMethod KEYWORD1 +NeoEsp32Rmt3Sk6812Method KEYWORD1 +NeoEsp32Rmt3Tm1814Method KEYWORD1 +NeoEsp32Rmt3Apa106Method KEYWORD1 +NeoEsp32Rmt3800KbpsMethod KEYWORD1 +NeoEsp32Rmt3400KbpsMethod KEYWORD1 +NeoEsp32Rmt4Ws2811Method KEYWORD1 +NeoEsp32Rmt4Ws2812xMethod KEYWORD1 +NeoEsp32Rmt4Sk6812Method KEYWORD1 +NeoEsp32Rmt4Tm1814Method KEYWORD1 +NeoEsp32Rmt4Apa106Method KEYWORD1 +NeoEsp32Rmt4800KbpsMethod KEYWORD1 +NeoEsp32Rmt4400KbpsMethod KEYWORD1 +NeoEsp32Rmt5Ws2811Method KEYWORD1 +NeoEsp32Rmt5Ws2812xMethod KEYWORD1 +NeoEsp32Rmt5Sk6812Method KEYWORD1 +NeoEsp32Rmt5Tm1814Method KEYWORD1 +NeoEsp32Rmt5Apa106Method KEYWORD1 +NeoEsp32Rmt5800KbpsMethod KEYWORD1 +NeoEsp32Rmt5400KbpsMethod KEYWORD1 +NeoEsp32Rmt6Ws2811Method KEYWORD1 +NeoEsp32Rmt6Ws2812xMethod KEYWORD1 +NeoEsp32Rmt6Sk6812Method KEYWORD1 +NeoEsp32Rmt6Tm1814Method KEYWORD1 +NeoEsp32Rmt6Apa106Method KEYWORD1 +NeoEsp32Rmt6800KbpsMethod KEYWORD1 +NeoEsp32Rmt6400KbpsMethod KEYWORD1 +NeoEsp32Rmt7Ws2811Method KEYWORD1 +NeoEsp32Rmt7Ws2812xMethod KEYWORD1 +NeoEsp32Rmt7Sk6812Method KEYWORD1 +NeoEsp32Rmt7Tm1814Method KEYWORD1 +NeoEsp32Rmt7Apa106Method KEYWORD1 +NeoEsp32Rmt7800KbpsMethod KEYWORD1 +NeoEsp32Rmt7400KbpsMethod KEYWORD1 +NeoEsp32Rmt0Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt0Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt0Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt0Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt0Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt0800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt0400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt1Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt1Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt1Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt1Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt1Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt1800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt1400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt2Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt2Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt2Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt2Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt2Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt2800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt2400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt3Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt3Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt3Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt3Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt3Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt3800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt3400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt4Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt4Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt4Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt4Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt4Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt4800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt4400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt5Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt5Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt5Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt5Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt5Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt5800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt5400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt6Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt6Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt6Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt6Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt6Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt6800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt6400KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt7Ws2811InvertedMethod KEYWORD1 +NeoEsp32Rmt7Ws2812xInvertedMethod KEYWORD1 +NeoEsp32Rmt7Sk6812InvertedMethod KEYWORD1 +NeoEsp32Rmt7Tm1814InvertedMethod KEYWORD1 +NeoEsp32Rmt7Apa106InvertedMethod KEYWORD1 +NeoEsp32Rmt7800KbpsInvertedMethod KEYWORD1 +NeoEsp32Rmt7400KbpsInvertedMethod KEYWORD1 +NeoEsp32BitBangWs2813Method KEYWORD1 +NeoEsp32BitBangWs2812xMethod KEYWORD1 +NeoEsp32BitBangWs2812Method KEYWORD1 +NeoEsp32BitBangWs2811Method KEYWORD1 +NeoEsp32BitBangSk6812Method KEYWORD1 +NeoEsp32BitBangTm1814Method KEYWORD1 +NeoEsp32BitBangLc8812Method KEYWORD1 +NeoEsp32BitBangApa106Method KEYWORD1 +NeoEsp32BitBang800KbpsMethod KEYWORD1 +NeoEsp32BitBang400KbpsMethod KEYWORD1 +NeoEsp32BitBangWs2813InvertedMethod KEYWORD1 +NeoEsp32BitBangWs2812xInvertedMethod KEYWORD1 +NeoEsp32BitBangWs2812InvertedMethod KEYWORD1 +NeoEsp32BitBangWs2811InvertedMethod KEYWORD1 +NeoEsp32BitBangSk6812InvertedMethod KEYWORD1 +NeoEsp32BitBangTm1814InvertedMethod KEYWORD1 +NeoEsp32BitBangLc8812InvertedMethod KEYWORD1 +NeoEsp32BitBangApa106InvertedMethod KEYWORD1 +NeoEsp32BitBang800KbpsInvertedMethod KEYWORD1 +NeoEsp32BitBang400KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm0Ws2812xMethod KEYWORD1 +NeoNrf52xPwm0Sk6812Method KEYWORD1 +NeoNrf52xPwm0Tm1814Method KEYWORD1 +NeoNrf52xPwm0800KbpsMethod KEYWORD1 +NeoNrf52xPwm0400KbpsMethod KEYWORD1 +NeoNrf52xPwm0Apa106Method KEYWORD1 +NeoNrf52xPwm1Ws2812xMethod KEYWORD1 +NeoNrf52xPwm1Sk6812Method KEYWORD1 +NeoNrf52xPwm1Tm1814Method KEYWORD1 +NeoNrf52xPwm1800KbpsMethod KEYWORD1 +NeoNrf52xPwm1400KbpsMethod KEYWORD1 +NeoNrf52xPwm1Apa106Method KEYWORD1 +NeoNrf52xPwm2Ws2812xMethod KEYWORD1 +NeoNrf52xPwm2Sk6812Method KEYWORD1 +NeoNrf52xPwm2Tm1814Method KEYWORD1 +NeoNrf52xPwm2800KbpsMethod KEYWORD1 +NeoNrf52xPwm2400KbpsMethod KEYWORD1 +NeoNrf52xPwm2Apa106Method KEYWORD1 +NeoNrf52xPwm3Ws2812xMethod KEYWORD1 +NeoNrf52xPwm3Sk6812Method KEYWORD1 +NeoNrf52xPwm3Tm1814Method KEYWORD1 +NeoNrf52xPwm3800KbpsMethod KEYWORD1 +NeoNrf52xPwm3400KbpsMethod KEYWORD1 +NeoNrf52xPwm3Apa106Method KEYWORD1 +NeoNrf52xPwm0Ws2812xInvertedMethod KEYWORD1 +NeoNrf52xPwm0Sk6812InvertedMethod KEYWORD1 +NeoNrf52xPwm0Tm1814InvertedMethod KEYWORD1 +NeoNrf52xPwm0800KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm0400KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm0Apa106InvertedMethod KEYWORD1 +NeoNrf52xPwm1Ws2812xInvertedMethod KEYWORD1 +NeoNrf52xPwm1Sk6812InvertedMethod KEYWORD1 +NeoNrf52xPwm1Tm1814InvertedMethod KEYWORD1 +NeoNrf52xPwm1800KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm1400KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm1Apa106InvertedMethod KEYWORD1 +NeoNrf52xPwm2Ws2812xInvertedMethod KEYWORD1 +NeoNrf52xPwm2Sk6812InvertedMethod KEYWORD1 +NeoNrf52xPwm2Tm1814InvertedMethod KEYWORD1 +NeoNrf52xPwm2800KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm2400KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm2Apa106InvertedMethod KEYWORD1 +NeoNrf52xPwm3Ws2812xInvertedMethod KEYWORD1 +NeoNrf52xPwm3Sk6812InvertedMethod KEYWORD1 +NeoNrf52xPwm3Tm1814InvertedMethod KEYWORD1 +NeoNrf52xPwm3800KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm3400KbpsInvertedMethod KEYWORD1 +NeoNrf52xPwm3Apa106InvertedMethod KEYWORD1 +DotStarMethod KEYWORD1 +DotStarSpiMethod KEYWORD1 +DotStarSpi20MhzMethod KEYWORD1 +DotStarSpi10MhzMethod KEYWORD1 +DotStarSpi2MhzMethod KEYWORD1 +NeoWs2801Method KEYWORD1 +NeoWs2801SpiMethod KEYWORD1 +NeoWs2801Spi20MhzMethod KEYWORD1 +NeoWs2801Spi10MhzMethod KEYWORD1 +NeoWs2801Spi2MhzMethod KEYWORD1 +Lpd8806Method KEYWORD1 +Lpd8806SpiMethod KEYWORD1 +Lpd8806Spi20MhzMethod KEYWORD1 +Lpd8806Spi10MhzMethod KEYWORD1 +Lpd8806Spi2MhzMethod KEYWORD1 +P9813Method KEYWORD1 +P9813SpiMethod KEYWORD1 +P9813Spi20MhzMethod KEYWORD1 +P9813Spi10MhzMethod KEYWORD1 +P9813Spi2MhzMethod KEYWORD1 +NeoPixelAnimator KEYWORD1 +AnimUpdateCallback KEYWORD1 +AnimationParam KEYWORD1 +NeoEase KEYWORD1 +AnimEaseFunction KEYWORD1 +RowMajorLayout KEYWORD1 +RowMajor90Layout KEYWORD1 +RowMajor180Layout KEYWORD1 +RowMajor270Layout KEYWORD1 +RowMajorAlternatingLayout KEYWORD1 +RowMajorAlternating90Layout KEYWORD1 +RowMajorAlternating180Layout KEYWORD1 +RowMajorAlternating270Layout KEYWORD1 +ColumnMajorLayout KEYWORD1 +ColumnMajor90Layout KEYWORD1 +ColumnMajor180Layout KEYWORD1 +ColumnMajor270Layout KEYWORD1 +ColumnMajorAlternatingLayout KEYWORD1 +ColumnMajorAlternating90Layout KEYWORD1 +ColumnMajorAlternating180Layout KEYWORD1 +ColumnMajorAlternating270Layout KEYWORD1 +NeoTopology KEYWORD1 +NeoRingTopology KEYWORD1 +NeoTiles KEYWORD1 +NeoMosaic KEYWORD1 +NeoGammaEquationMethod KEYWORD1 +NeoGammaTableMethod KEYWORD1 +NeoGamma KEYWORD1 +NeoHueBlendShortestDistance KEYWORD1 +NeoHueBlendLongestDistance KEYWORD1 +NeoHueBlendClockwiseDirection KEYWORD1 +NeoHueBlendCounterClockwiseDirection KEYWORD1 +NeoBufferContext KEYWORD1 +LayoutMapCallback KEYWORD1 +NeoBufferMethod KEYWORD1 +NeoBufferProgmemMethod KEYWORD1 +NeoBuffer KEYWORD1 +NeoVerticalSpriteSheet KEYWORD1 +NeoBitmapFile KEYWORD1 +HtmlShortColorNames KEYWORD1 +HtmlColorNames KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +Begin KEYWORD2 +Show KEYWORD2 +CanShow KEYWORD2 +ClearTo KEYWORD2 +RotateLeft KEYWORD2 +ShiftLeft KEYWORD2 +RotateRight KEYWORD2 +ShiftRight KEYWORD2 +IsDirty KEYWORD2 +Dirty KEYWORD2 +ResetDirty KEYWORD2 +Pixels KEYWORD2 +PixelSize KEYWORD2 +PixelsSize KEYWORD2 +PixelCount KEYWORD2 +SetPixelColor KEYWORD2 +GetPixelColor KEYWORD2 +SwapPixelColor KEYWORD2 +CalculateBrightness KEYWORD2 +Dim KEYWORD2 +Brighten KEYWORD2 +Darken KEYWORD2 +Lighten KEYWORD2 +SetPixelSettings KEYWORD2 +LinearBlend KEYWORD2 +BilinearBlend KEYWORD2 +IsAnimating KEYWORD2 +NextAvailableAnimation KEYWORD2 +StartAnimation KEYWORD2 +StopAnimation KEYWORD2 +RestartAnimation KEYWORD2 +IsAnimationActive KEYWORD2 +AnimationDuration KEYWORD2 +ChangeAnimationDuration KEYWORD2 +UpdateAnimations KEYWORD2 +IsPaused KEYWORD2 +Pause KEYWORD2 +Resume KEYWORD2 +getTimeScale KEYWORD2 +setTimeScale KEYWORD2 +QuadraticIn KEYWORD2 +QuadraticOut KEYWORD2 +QuadraticInOut KEYWORD2 +QuadraticCenter KEYWORD2 +CubicIn KEYWORD2 +CubicOut KEYWORD2 +CubicInOut KEYWORD2 +CubicCenter KEYWORD2 +QuarticIn KEYWORD2 +QuarticOut KEYWORD2 +QuarticInOut KEYWORD2 +QuarticCenter KEYWORD2 +QuinticIn KEYWORD2 +QuinticOut KEYWORD2 +QuinticInOut KEYWORD2 +QuinticCenter KEYWORD2 +SinusoidalIn KEYWORD2 +SinusoidalOut KEYWORD2 +SinusoidalInOut KEYWORD2 +SinusoidalCenter KEYWORD2 +ExponentialIn KEYWORD2 +ExponentialOut KEYWORD2 +ExponentialInOut KEYWORD2 +ExponentialCenter KEYWORD2 +CircularIn KEYWORD2 +CircularOut KEYWORD2 +CircularInOut KEYWORD2 +CircularCenter KEYWORD2 +Gamma KEYWORD2 +Map KEYWORD2 +MapProbe KEYWORD2 +getWidth KEYWORD2 +getHeight KEYWORD2 +RingPixelShift KEYWORD2 +RingPixelRotate KEYWORD2 +getCountOfRings KEYWORD2 +getPixelCountAtRing KEYWORD2 +getPixelCount KEYWORD2 +TopologyHint KEYWORD2 +Correct KEYWORD2 +SpriteWidth KEYWORD2 +SpriteHeight KEYWORD2 +SpriteCount KEYWORD2 +Blt KEYWORD2 +Width KEYWORD2 +Height KEYWORD2 +Parse KEYWORD2 +ToString KEYWORD2 +ToNumericalString KEYWORD2 + + +####################################### +# Constants (LITERAL1) +####################################### + +NEO_MILLISECONDS LITERAL1 +NEO_CENTISECONDS LITERAL1 +NEO_DECISECONDS LITERAL1 +NEO_SECONDS LITERAL1 +NEO_DECASECONDS LITERAL1 +AnimationState_Started LITERAL1 +AnimationState_Progress LITERAL1 +AnimationState_Completed LITERAL1 +NeoTopologyHint_FirstOnPanel LITERAL1 +NeoTopologyHint_InPanel LITERAL1 +NeoTopologyHint_LastOnPanel LITERAL1 +NeoTopologyHint_OutOfBounds LITERAL1 +PixelIndex_OutOfBounds LITERAL1 \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/library.json b/lib/NeoPixelBus-2.6.0/library.json new file mode 100644 index 000000000..e50ebd242 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/library.json @@ -0,0 +1,14 @@ +{ + "name": "NeoPixelBus", + "keywords": "NeoPixel, WS2811, WS2812, WS2813, SK6812, DotStar, APA102, SK9822, APA106, LPD8806, P9813, WS2801 RGB, RGBW", + "description": "A library that makes controlling NeoPixels (APA106, WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102, LPD8806, SK9822, WS2801, P9813) easy. Supports most Arduino platforms, including async hardware support for Esp8266, Esp32, and Nrf52 (Nano 33 BLE). Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. For Esp8266 it has three methods of sending NeoPixel data, DMA, UART, and Bit Bang. For Esp32 it has two base methods of sending NeoPixel data, i2s and RMT. For all platforms, there are two methods of sending DotStar data, hardware SPI and software SPI.", + "homepage": "https://github.com/Makuna/NeoPixelBus/wiki", + "repository": { + "type": "git", + "url": "https://github.com/Makuna/NeoPixelBus" + }, + "version": "2.6.0", + "frameworks": "arduino", + "platforms": "*" +} + diff --git a/lib/NeoPixelBus-2.6.0/library.properties b/lib/NeoPixelBus-2.6.0/library.properties new file mode 100644 index 000000000..718202639 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/library.properties @@ -0,0 +1,9 @@ +name=NeoPixelBus by Makuna +version=2.6.0 +author=Michael C. Miller (makuna@live.com) +maintainer=Michael C. Miller (makuna@live.com) +sentence=A library that makes controlling NeoPixels (APA106, WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102, LPD8806, SK9822, WS2801, P9813) easy. +paragraph=Supports most Arduino platforms, including async hardware support for Esp8266, Esp32, and Nrf52 (Nano 33 BLE). Support for RGBW pixels. Includes seperate RgbColor, RgbwColor, HslColor, and HsbColor objects. Includes an animator class that helps create asyncronous animations. Supports Matrix layout of pixels. Includes Gamma corretion object. For Esp8266 it has three methods of sending NeoPixel data, DMA, UART, and Bit Bang. For Esp32 it has two base methods of sending NeoPixel data, i2s and RMT. For all platforms, there are two methods of sending DotStar data, hardware SPI and software SPI. +category=Display +url=https://github.com/Makuna/NeoPixelBus/wiki +architectures=* \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelAnimator.h b/lib/NeoPixelBus-2.6.0/src/NeoPixelAnimator.h similarity index 99% rename from lib/NeoPixelBus-2.5.0.09/src/NeoPixelAnimator.h rename to lib/NeoPixelBus-2.6.0/src/NeoPixelAnimator.h index c49d9ec48..d990599a4 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelAnimator.h +++ b/lib/NeoPixelBus-2.6.0/src/NeoPixelAnimator.h @@ -43,7 +43,7 @@ struct AnimationParam AnimationState state; }; -#ifdef ARDUINO_ARCH_AVR +#if defined(NEOPIXEBUS_NO_STL) typedef void(*AnimUpdateCallback)(const AnimationParam& param); @@ -153,7 +153,6 @@ private: _duration = duration; _remaining = duration; _fnCallback = animUpdate; - } void StopAnimation() diff --git a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelBrightnessBus.h b/lib/NeoPixelBus-2.6.0/src/NeoPixelBrightnessBus.h similarity index 64% rename from lib/NeoPixelBus-2.5.0.09/src/NeoPixelBrightnessBus.h rename to lib/NeoPixelBus-2.6.0/src/NeoPixelBrightnessBus.h index 0ff1d5221..3bea54bdf 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelBrightnessBus.h +++ b/lib/NeoPixelBus-2.6.0/src/NeoPixelBrightnessBus.h @@ -32,100 +32,81 @@ template class NeoPixelBrightnessBu public NeoPixelBus { private: + + void ScaleColor(uint16_t scale, typename T_COLOR_FEATURE::ColorObject* color) + { + uint8_t* ptr = (uint8_t*)color; + uint8_t* ptrEnd = ptr + sizeof(typename T_COLOR_FEATURE::ColorObject); + + while (ptr != ptrEnd) + { + uint16_t value = *ptr; + *ptr++ = (value * scale) >> 8; + } + } + void ConvertColor(typename T_COLOR_FEATURE::ColorObject* color) { - if (_brightness) - { - uint8_t* ptr = (uint8_t*) color; - uint8_t* ptrEnd = ptr + T_COLOR_FEATURE::PixelSize; - - while (ptr != ptrEnd) - { - uint16_t value = *ptr; - *ptr++ = (value * _brightness) >> 8; - } - } + uint16_t scale = _brightness + 1; + ScaleColor(scale, color); } void RecoverColor(typename T_COLOR_FEATURE::ColorObject* color) const { - if (_brightness) - { - uint8_t* ptr = (uint8_t*) color; - uint8_t* ptrEnd = ptr + T_COLOR_FEATURE::PixelSize; + uint8_t* ptr = (uint8_t*)color; + uint8_t* ptrEnd = ptr + sizeof(typename T_COLOR_FEATURE::ColorObject); + uint16_t scale = _brightness + 1; - while (ptr != ptrEnd) - { - uint16_t value = *ptr; - *ptr++ = (value << 8) / _brightness; - } + while (ptr != ptrEnd) + { + uint16_t value = *ptr; + *ptr++ = (value << 8) / scale; } } public: NeoPixelBrightnessBus(uint16_t countPixels, uint8_t pin) : NeoPixelBus(countPixels, pin), - _brightness(0) + _brightness(255) { } NeoPixelBrightnessBus(uint16_t countPixels, uint8_t pinClock, uint8_t pinData) : NeoPixelBus(countPixels, pinClock, pinData), - _brightness(0) + _brightness(255) { } NeoPixelBrightnessBus(uint16_t countPixels) : NeoPixelBus(countPixels), - _brightness(0) + _brightness(255) { } void SetBrightness(uint8_t brightness) { - // Due to using fixed point math, we modifiy the brightness - // before storing making the math faster - uint8_t newBrightness = brightness + 1; - // Only update if there is a change - if (newBrightness != _brightness) + if (brightness != _brightness) { - // calculate a scale to modify from old brightness to new brightness + uint16_t scale = (((uint16_t)brightness + 1) << 8) / ((uint16_t)_brightness + 1); + + // scale existing pixels // - uint8_t oldBrightness = _brightness - 1; // unmodify brightness value - uint16_t scale; - - if (oldBrightness == 0) + for (uint16_t indexPixel = 0; indexPixel < NeoPixelBus::PixelCount(); indexPixel++) { - scale = 0; // Avoid divide by 0 + typename T_COLOR_FEATURE::ColorObject color = NeoPixelBus::GetPixelColor(indexPixel); + ScaleColor(scale, &color); + NeoPixelBus::SetPixelColor(indexPixel, color); } - else if (brightness == 255) - { - scale = 65535 / oldBrightness; - } - else - { - scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness; - } - - // re-scale existing pixels - // - uint8_t* ptr = this->Pixels(); - uint8_t* ptrEnd = ptr + this->PixelsSize(); - while (ptr != ptrEnd) - { - uint16_t value = *ptr; - *ptr++ = (value * scale) >> 8; - } - - _brightness = newBrightness; + + _brightness = brightness; this->Dirty(); } } uint8_t GetBrightness() const { - return _brightness - 1; + return _brightness; } void SetPixelColor(uint16_t indexPixel, typename T_COLOR_FEATURE::ColorObject color) diff --git a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelBus.h b/lib/NeoPixelBus-2.6.0/src/NeoPixelBus.h similarity index 78% rename from lib/NeoPixelBus-2.5.0.09/src/NeoPixelBus.h rename to lib/NeoPixelBus-2.6.0/src/NeoPixelBus.h index 3c08f83f6..a9ec86565 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/NeoPixelBus.h +++ b/lib/NeoPixelBus-2.6.0/src/NeoPixelBus.h @@ -27,6 +27,16 @@ License along with NeoPixel. If not, see #include +// some platforms do not come with STL or properly defined one, specifically functional +// if you see... +// undefined reference to `std::__throw_bad_function_call()' +// ...then you can either add the platform symbol to the list so NEOPIXEBUS_NO_STL gets defined or +// go to boards.txt and enable c++ by adding (teensy31.build.flags.libs=-lstdc++) and set to "smallest code" option in Arduino +// +#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(STM32L432xx) || defined(STM32L476xx) || defined(ARDUINO_ARCH_SAM) +#define NEOPIXEBUS_NO_STL 1 +#endif + // some platforms do not define this standard progmem type for some reason // #ifndef PGM_VOID_P @@ -38,14 +48,21 @@ License along with NeoPixel. If not, see #include "internal/NeoHueBlend.h" +#include "internal/NeoSettings.h" + #include "internal/RgbColor.h" #include "internal/HslColor.h" #include "internal/HsbColor.h" #include "internal/HtmlColor.h" #include "internal/RgbwColor.h" +#include "internal/SegmentDigit.h" #include "internal/NeoColorFeatures.h" +#include "internal/NeoTm1814ColorFeatures.h" #include "internal/DotStarColorFeatures.h" +#include "internal/Lpd8806ColorFeatures.h" +#include "internal/P9813ColorFeatures.h" +#include "internal/NeoSegmentFeatures.h" #include "internal/Layouts.h" #include "internal/NeoTopology.h" @@ -63,37 +80,40 @@ License along with NeoPixel. If not, see #include "internal/NeoEase.h" #include "internal/NeoGamma.h" +#include "internal/DotStarGenericMethod.h" +#include "internal/Lpd8806GenericMethod.h" +#include "internal/Ws2801GenericMethod.h" +#include "internal/P9813GenericMethod.h" + #if defined(ARDUINO_ARCH_ESP8266) #include "internal/NeoEsp8266DmaMethod.h" #include "internal/NeoEsp8266UartMethod.h" #include "internal/NeoEspBitBangMethod.h" -#include "internal/DotStarGenericMethod.h" #elif defined(ARDUINO_ARCH_ESP32) #include "internal/NeoEsp32I2sMethod.h" #include "internal/NeoEsp32RmtMethod.h" #include "internal/NeoEspBitBangMethod.h" -#include "internal/DotStarGenericMethod.h" + +#elif defined(ARDUINO_ARCH_NRF52840) // must be before __arm__ + +#include "internal/NeoNrf52xMethod.h" #elif defined(__arm__) // must be before ARDUINO_ARCH_AVR due to Teensy incorrectly having it set #include "internal/NeoArmMethod.h" -#include "internal/DotStarGenericMethod.h" -#elif defined(ARDUINO_ARCH_AVR) +#elif defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) #include "internal/NeoAvrMethod.h" -#include "internal/DotStarAvrMethod.h" #else #error "Platform Currently Not Supported, please add an Issue at Github/Makuna/NeoPixelBus" #endif -#if !defined(__AVR_ATtiny85__) -#include "internal/DotStarSpiMethod.h" -#endif + template class NeoPixelBus @@ -105,21 +125,21 @@ public: NeoPixelBus(uint16_t countPixels, uint8_t pin) : _countPixels(countPixels), _state(0), - _method(pin, countPixels, T_COLOR_FEATURE::PixelSize) + _method(pin, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize) { } NeoPixelBus(uint16_t countPixels, uint8_t pinClock, uint8_t pinData) : _countPixels(countPixels), _state(0), - _method(pinClock, pinData, countPixels, T_COLOR_FEATURE::PixelSize) + _method(pinClock, pinData, countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize) { } NeoPixelBus(uint16_t countPixels) : _countPixels(countPixels), _state(0), - _method(countPixels, T_COLOR_FEATURE::PixelSize) + _method(countPixels, T_COLOR_FEATURE::PixelSize, T_COLOR_FEATURE::SettingsSize) { } @@ -130,7 +150,7 @@ public: operator NeoBufferContext() { Dirty(); // we assume you are playing with bits - return NeoBufferContext(_method.getPixels(), _method.getPixelsSize()); + return NeoBufferContext(_pixels(), PixelsSize()); } void Begin() @@ -180,12 +200,12 @@ public: uint8_t* Pixels() { - return _method.getPixels(); + return _pixels(); }; size_t PixelsSize() const { - return _method.getPixelsSize(); + return _method.getDataSize() - T_COLOR_FEATURE::SettingsSize; }; size_t PixelSize() const @@ -202,7 +222,7 @@ public: { if (indexPixel < _countPixels) { - T_COLOR_FEATURE::applyPixelColor(_method.getPixels(), indexPixel, color); + T_COLOR_FEATURE::applyPixelColor(_pixels(), indexPixel, color); Dirty(); } }; @@ -211,7 +231,7 @@ public: { if (indexPixel < _countPixels) { - return T_COLOR_FEATURE::retrievePixelColor(_method.getPixels(), indexPixel); + return T_COLOR_FEATURE::retrievePixelColor(_pixels(), indexPixel); } else { @@ -224,7 +244,7 @@ public: void ClearTo(typename T_COLOR_FEATURE::ColorObject color) { uint8_t temp[T_COLOR_FEATURE::PixelSize]; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); T_COLOR_FEATURE::applyPixelColor(temp, 0, color); @@ -240,7 +260,7 @@ public: first <= last) { uint8_t temp[T_COLOR_FEATURE::PixelSize]; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); uint8_t* pFront = T_COLOR_FEATURE::getPixelAddress(pixels, first); T_COLOR_FEATURE::applyPixelColor(temp, 0, color); @@ -339,18 +359,49 @@ public: SetPixelColor(indexPixelOne, colorTwo); SetPixelColor(indexPixelTwo, colorOne); }; + + void SetPixelSettings(const typename T_COLOR_FEATURE::SettingsObject& settings) + { + T_COLOR_FEATURE::applySettings(_method.getData(), settings); + Dirty(); + }; + uint32_t CalcTotalMilliAmpere(const typename T_COLOR_FEATURE::ColorObject::SettingsObject& settings) + { + uint32_t total = 0; // in 1/10th milliamps + + for (uint16_t index = 0; index < _countPixels; index++) + { + auto color = GetPixelColor(index); + total += color.CalcTotalTenthMilliAmpere(settings); + } + + return total / 10; // return millamps + } + protected: const uint16_t _countPixels; // Number of RGB LEDs in strip uint8_t _state; // internal state T_METHOD _method; + uint8_t* _pixels() + { + // get pixels data within the data stream + return T_COLOR_FEATURE::pixels(_method.getData()); + } + + const uint8_t* _pixels() const + { + // get pixels data within the data stream + return T_COLOR_FEATURE::pixels(_method.getData()); + } + void _rotateLeft(uint16_t rotationCount, uint16_t first, uint16_t last) { // store in temp uint8_t temp[rotationCount * T_COLOR_FEATURE::PixelSize]; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); uint8_t* pFront = T_COLOR_FEATURE::getPixelAddress(pixels, first); @@ -371,7 +422,7 @@ protected: uint16_t front = first + shiftCount; uint16_t count = last - front + 1; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); uint8_t* pFirst = T_COLOR_FEATURE::getPixelAddress(pixels, first); uint8_t* pFront = T_COLOR_FEATURE::getPixelAddress(pixels, front); @@ -384,7 +435,7 @@ protected: { // store in temp uint8_t temp[rotationCount * T_COLOR_FEATURE::PixelSize]; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); uint8_t* pFront = T_COLOR_FEATURE::getPixelAddress(pixels, last - (rotationCount - 1)); @@ -405,7 +456,7 @@ protected: uint16_t front = first + shiftCount; uint16_t count = last - front + 1; - uint8_t* pixels = _method.getPixels(); + uint8_t* pixels = _pixels(); uint8_t* pFirst = T_COLOR_FEATURE::getPixelAddress(pixels, first); uint8_t* pFront = T_COLOR_FEATURE::getPixelAddress(pixels, front); diff --git a/lib/NeoPixelBus-2.6.0/src/NeoPixelSegmentBus.h b/lib/NeoPixelBus-2.6.0/src/NeoPixelSegmentBus.h new file mode 100644 index 000000000..ebe16ce70 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/NeoPixelSegmentBus.h @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------- +NeoPixelBus library wrapper template class that provides enhanced methods +for writing to segment based strips + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#include "NeoPixelBus.h" + +template class NeoPixelSegmentBus : + public NeoPixelBus +{ +public: + NeoPixelSegmentBus(uint16_t countPixels, uint8_t pin) : + NeoPixelBus(countPixels, pin) + { + } + + NeoPixelSegmentBus(uint16_t countPixels) : + NeoPixelBus(countPixels) + { + } + + void SetString(uint16_t indexDigit, + const char* str, + uint8_t brightness, + uint8_t defaultBrightness = 0) + { + T_COLOR_FEATURE::ColorObject::SetString(*this, + indexDigit, + str, + brightness, + defaultBrightness); + } + + void SetString(uint16_t indexDigit, + const String& str, + uint8_t brightness, + uint8_t defaultBrightness = 0) + { + SetString(indexDigit, str.c_str(), brightness, defaultBrightness); + } +}; + + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarColorFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/DotStarColorFeatures.h similarity index 83% rename from lib/NeoPixelBus-2.5.0.09/src/internal/DotStarColorFeatures.h rename to lib/NeoPixelBus-2.6.0/src/internal/DotStarColorFeatures.h index 50a33e248..918a12e14 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarColorFeatures.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/DotStarColorFeatures.h @@ -160,7 +160,50 @@ public: typedef RgbwColor ColorObject; }; -class DotStarBgrFeature : public DotStar3Elements + +class DotStar3ElementsNoSettings : public DotStar3Elements +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class DotStar4ElementsNoSettings : public DotStar4Elements +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class DotStarBgrFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -173,10 +216,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.B = *p++; @@ -201,7 +244,7 @@ public: }; -class DotStarLbgrFeature : public DotStar4Elements +class DotStarLbgrFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -214,10 +257,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.B = *p++; @@ -242,7 +285,7 @@ public: }; -class DotStarGrbFeature : public DotStar3Elements +class DotStarGrbFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -255,10 +298,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.G = *p++; @@ -283,7 +326,7 @@ public: }; -class DotStarLgrbFeature : public DotStar4Elements +class DotStarLgrbFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -296,10 +339,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.G = *p++; @@ -325,7 +368,7 @@ public: }; /* RGB Feature -- Some APA102s ship in RGB order */ -class DotStarRgbFeature : public DotStar3Elements +class DotStarRgbFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -338,10 +381,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.R = *p++; @@ -366,7 +409,7 @@ public: }; -class DotStarLrgbFeature : public DotStar4Elements +class DotStarLrgbFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -379,10 +422,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.R = *p++; @@ -407,7 +450,7 @@ public: }; /* RBG Feature -- Some APA102s ship in RBG order */ -class DotStarRbgFeature : public DotStar3Elements +class DotStarRbgFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -420,10 +463,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.R = *p++; @@ -448,7 +491,7 @@ public: }; -class DotStarLrbgFeature : public DotStar4Elements +class DotStarLrbgFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -461,10 +504,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.R = *p++; @@ -490,7 +533,7 @@ public: }; /* GBR Feature -- Some APA102s ship in GBR order */ -class DotStarGbrFeature : public DotStar3Elements +class DotStarGbrFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -503,10 +546,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.G = *p++; @@ -531,7 +574,7 @@ public: }; -class DotStarLgbrFeature : public DotStar4Elements +class DotStarLgbrFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -544,10 +587,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.G = *p++; @@ -572,7 +615,7 @@ public: }; /* BRG Feature -- Some APA102s ship in BRG order */ -class DotStarBrgFeature : public DotStar3Elements +class DotStarBrgFeature : public DotStar3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -585,10 +628,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.B = *p++; @@ -613,7 +656,7 @@ public: }; -class DotStarLbrgFeature : public DotStar4Elements +class DotStarLbrgFeature : public DotStar4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -626,10 +669,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.B = *p++; diff --git a/lib/NeoPixelBus-2.6.0/src/internal/DotStarGenericMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/DotStarGenericMethod.h new file mode 100644 index 000000000..64c8f9a57 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/DotStarGenericMethod.h @@ -0,0 +1,135 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for DotStars using general Pins (APA102). + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set +#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) +#include "TwoWireBitBangImpleAvr.h" +#else +#include "TwoWireBitBangImple.h" +#endif + + +template class DotStarMethodBase +{ +public: + DotStarMethodBase(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _sizeEndFrame((pixelCount + 15) / 16), // 16 = div 2 (bit for every two pixels) div 8 (bits to bytes) + _wire(pinClock, pinData) + { + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + } + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) + DotStarMethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + DotStarMethodBase(SCK, MOSI, pixelCount, elementSize, settingsSize) + { + } +#endif + + ~DotStarMethodBase() + { + free(_data); + } + + bool IsReadyToUpdate() const + { + return true; // dot stars don't have a required delay + } + +#if defined(ARDUINO_ARCH_ESP32) + void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) + { + _wire.begin(sck, miso, mosi, ss); + } +#endif + + void Initialize() + { + _wire.begin(); + } + + void Update(bool) + { + const uint8_t startFrame[4] = { 0x00 }; + const uint8_t resetFrame[4] = { 0x00 }; + + _wire.beginTransaction(); + + // start frame + _wire.transmitBytes(startFrame, sizeof(startFrame)); + + // data + _wire.transmitBytes(_data, _sizeData); + + // reset frame + _wire.transmitBytes(resetFrame, sizeof(resetFrame)); + + // end frame + + // one bit for every two pixels with no less than 1 byte + for (size_t endFrameByte = 0; endFrameByte < _sizeEndFrame; endFrameByte++) + { + _wire.transmitByte(0x00); + } + + _wire.endTransaction(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + const size_t _sizeEndFrame; + + T_TWOWIRE _wire; + uint8_t* _data; // Holds LED color values +}; + +typedef DotStarMethodBase DotStarMethod; + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) +#include "TwoWireSpiImple.h" +typedef DotStarMethodBase> DotStarSpi40MhzMethod; +typedef DotStarMethodBase> DotStarSpi20MhzMethod; +typedef DotStarMethodBase> DotStarSpi10MhzMethod; +typedef DotStarMethodBase> DotStarSpi2MhzMethod; +typedef DotStarSpi10MhzMethod DotStarSpiMethod; +#endif + + + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.c b/lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.c similarity index 72% rename from lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.c rename to lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.c index 092170e20..6f6b73089 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.c +++ b/lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.c @@ -26,8 +26,13 @@ #include "freertos/semphr.h" #include "freertos/queue.h" + +#if ESP_IDF_VERSION_MAJOR>=4 +#include "esp_intr_alloc.h" +#else #include "esp_intr.h" -#include "rom/ets_sys.h" +#endif + #include "soc/gpio_reg.h" #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" @@ -41,7 +46,10 @@ #include "Esp32_i2s.h" #include "esp32-hal.h" +#if ESP_IDF_VERSION_MAJOR<4 #define I2S_BASE_CLK (160000000L) +#endif + #define ESP32_REG(addr) (*((volatile uint32_t*)(0x3FF00000+(addr)))) #define I2S_DMA_QUEUE_SIZE 16 @@ -87,16 +95,23 @@ typedef struct { static uint8_t i2s_silence_buf[I2S_DMA_SILENCE_LEN]; -static i2s_bus_t I2S[2] = { +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (I2S_NUM_MAX == 2) +static i2s_bus_t I2S[I2S_NUM_MAX] = { {&I2S0, -1, -1, -1, -1, 0, NULL, NULL, i2s_silence_buf, I2S_DMA_SILENCE_LEN, NULL, I2S_DMA_QUEUE_SIZE, 0, 0}, {&I2S1, -1, -1, -1, -1, 0, NULL, NULL, i2s_silence_buf, I2S_DMA_SILENCE_LEN, NULL, I2S_DMA_QUEUE_SIZE, 0, 0} }; +#else +static i2s_bus_t I2S[I2S_NUM_MAX] = { + {&I2S0, -1, -1, -1, -1, 0, NULL, NULL, i2s_silence_buf, I2S_DMA_SILENCE_LEN, NULL, I2S_DMA_QUEUE_SIZE, 0, 0} +}; +#endif void IRAM_ATTR i2sDmaISR(void* arg); bool i2sInitDmaItems(uint8_t bus_num); bool i2sInitDmaItems(uint8_t bus_num) { - if (bus_num > 1) { + if (bus_num >= I2S_NUM_MAX) { return false; } if (I2S[bus_num].tx_queue) {// already set @@ -153,7 +168,7 @@ bool i2sInitDmaItems(uint8_t bus_num) { } void i2sSetSilenceBuf(uint8_t bus_num, uint8_t* data, size_t len) { - if (bus_num > 1 || !data || !len) { + if (bus_num >= I2S_NUM_MAX || !data || !len) { return; } I2S[bus_num].silence_buf = data; @@ -161,38 +176,43 @@ void i2sSetSilenceBuf(uint8_t bus_num, uint8_t* data, size_t len) { } esp_err_t i2sSetClock(uint8_t bus_num, uint8_t div_num, uint8_t div_b, uint8_t div_a, uint8_t bck, uint8_t bits) { - if (bus_num > 1 || div_a > 63 || div_b > 63 || bck > 63) { + if (bus_num >= I2S_NUM_MAX || div_a > 63 || div_b > 63 || bck > 63) { return ESP_FAIL; } i2s_dev_t* i2s = I2S[bus_num].bus; - i2s->clkm_conf.clka_en = 0; - i2s->clkm_conf.clkm_div_a = div_a; - i2s->clkm_conf.clkm_div_b = div_b; - i2s->clkm_conf.clkm_div_num = div_num; - i2s->sample_rate_conf.tx_bck_div_num = bck; - i2s->sample_rate_conf.rx_bck_div_num = bck; - i2s->sample_rate_conf.tx_bits_mod = bits; - i2s->sample_rate_conf.rx_bits_mod = bits; + + typeof(i2s->clkm_conf) clkm_conf; + + clkm_conf.val = 0; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) + clkm_conf.clka_en = 0; +#else + clkm_conf.clk_sel = 2; +#endif + + clkm_conf.clkm_div_a = div_a; + clkm_conf.clkm_div_b = div_b; + clkm_conf.clkm_div_num = div_num; + i2s->clkm_conf.val = clkm_conf.val; + + typeof(i2s->sample_rate_conf) sample_rate_conf; + sample_rate_conf.val = 0; + sample_rate_conf.tx_bck_div_num = bck; + sample_rate_conf.rx_bck_div_num = bck; + sample_rate_conf.tx_bits_mod = bits; + sample_rate_conf.rx_bits_mod = bits; + i2s->sample_rate_conf.val = sample_rate_conf.val; return ESP_OK; } -void i2sSetTxDataMode(uint8_t bus_num, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod) { - if (bus_num > 1) { - return; - } - - I2S[bus_num].bus->conf_chan.tx_chan_mod = chan_mod; // 0:dual channel; 1:right channel; 2:left channel; 3:left channel constant; 4:right channel constant; (channels flipped if tx_msb_right == 1) - I2S[bus_num].bus->fifo_conf.tx_fifo_mod = fifo_mod; // 0:16-bit dual channel; 1:16-bit single channel; 2:32-bit dual channel; 3:32-bit single channel data -} - void i2sSetDac(uint8_t bus_num, bool right, bool left) { - if (bus_num > 1) { + if (bus_num >= I2S_NUM_MAX) { return; } if (!right && !left) { - dac_output_disable(1); - dac_output_disable(2); + dac_output_disable(DAC_CHANNEL_1); + dac_output_disable(DAC_CHANNEL_2); dac_i2s_disable(); I2S[bus_num].bus->conf2.lcd_en = 0; I2S[bus_num].bus->conf.tx_right_first = 0; @@ -201,7 +221,7 @@ void i2sSetDac(uint8_t bus_num, bool right, bool left) { return; } - i2sSetPins(bus_num, -1, -1, -1, -1); + i2sSetPins(bus_num, -1, false); I2S[bus_num].bus->conf2.lcd_en = 1; I2S[bus_num].bus->conf.tx_right_first = 0; I2S[bus_num].bus->conf2.camera_en = 0; @@ -209,75 +229,56 @@ void i2sSetDac(uint8_t bus_num, bool right, bool left) { dac_i2s_enable(); if (right) {// DAC1, right channel, GPIO25 - dac_output_enable(1); + dac_output_enable(DAC_CHANNEL_1); } if (left) { // DAC2, left channel, GPIO26 - dac_output_enable(2); + dac_output_enable(DAC_CHANNEL_2); } } -void i2sSetPins(uint8_t bus_num, int8_t out, int8_t ws, int8_t bck, int8_t in) { - if (bus_num > 1) { +void i2sSetPins(uint8_t bus_num, int8_t out, bool invert) { + if (bus_num >= I2S_NUM_MAX) { return; } - if ((ws >= 0 && I2S[bus_num].ws == -1) || (bck >= 0 && I2S[bus_num].bck == -1) || (out >= 0 && I2S[bus_num].out == -1)) { - i2sSetDac(bus_num, false, false); - } - - if (ws >= 0) { - if (I2S[bus_num].ws != ws) { - if (I2S[bus_num].ws >= 0) { - gpio_matrix_out(I2S[bus_num].ws, 0x100, false, false); - } - I2S[bus_num].ws = ws; - pinMode(ws, OUTPUT); - gpio_matrix_out(ws, bus_num?I2S1O_WS_OUT_IDX:I2S0O_WS_OUT_IDX, false, false); - } - } else if (I2S[bus_num].ws >= 0) { - gpio_matrix_out(I2S[bus_num].ws, 0x100, false, false); - I2S[bus_num].ws = -1; - } - - if (bck >= 0) { - if (I2S[bus_num].bck != bck) { - if (I2S[bus_num].bck >= 0) { - gpio_matrix_out(I2S[bus_num].bck, 0x100, false, false); - } - I2S[bus_num].bck = bck; - pinMode(bck, OUTPUT); - gpio_matrix_out(bck, bus_num?I2S1O_BCK_OUT_IDX:I2S0O_BCK_OUT_IDX, false, false); - } - } else if (I2S[bus_num].bck >= 0) { - gpio_matrix_out(I2S[bus_num].bck, 0x100, false, false); - I2S[bus_num].bck = -1; - } - if (out >= 0) { if (I2S[bus_num].out != out) { if (I2S[bus_num].out >= 0) { - gpio_matrix_out(I2S[bus_num].out, 0x100, false, false); + gpio_matrix_out(I2S[bus_num].out, 0x100, invert, false); } I2S[bus_num].out = out; pinMode(out, OUTPUT); - gpio_matrix_out(out, bus_num?I2S1O_DATA_OUT23_IDX:I2S0O_DATA_OUT23_IDX, false, false); + + int i2sSignal; +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (I2S_NUM_MAX == 2) + if (bus_num == 1) { + i2sSignal = I2S1O_DATA_OUT23_IDX; + } + else +#endif + { + i2sSignal = I2S0O_DATA_OUT23_IDX; + } + + gpio_matrix_out(out, i2sSignal, invert, false); } } else if (I2S[bus_num].out >= 0) { - gpio_matrix_out(I2S[bus_num].out, 0x100, false, false); + gpio_matrix_out(I2S[bus_num].out, 0x100, invert, false); I2S[bus_num].out = -1; } } bool i2sWriteDone(uint8_t bus_num) { - if (bus_num > 1) { + if (bus_num >= I2S_NUM_MAX) { return false; } return (I2S[bus_num].dma_items[I2S[bus_num].dma_count - 1].data == I2S[bus_num].silence_buf); } void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod, size_t dma_count, size_t dma_len) { - if (bus_num > 1) { + if (bus_num >= I2S_NUM_MAX) { return; } @@ -288,9 +289,13 @@ void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2 return; } +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (I2S_NUM_MAX == 2) if (bus_num) { periph_module_enable(PERIPH_I2S1_MODULE); - } else { + } else +#endif + { periph_module_enable(PERIPH_I2S0_MODULE); } @@ -321,42 +326,37 @@ void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2 i2s->lc_conf.out_rst = 0; // Enable and configure DMA - i2s->lc_conf.check_owner = 0; - i2s->lc_conf.out_loop_test = 0; - i2s->lc_conf.out_auto_wrback = 0; - i2s->lc_conf.out_data_burst_en = 0; - i2s->lc_conf.outdscr_burst_en = 0; - i2s->lc_conf.out_no_restart_clr = 0; - i2s->lc_conf.indscr_burst_en = 0; - i2s->lc_conf.out_eof_mode = 1; + typeof(i2s->lc_conf) lc_conf; + lc_conf.val = 0; + lc_conf.out_eof_mode = 1; + i2s->lc_conf.val = lc_conf.val; i2s->pdm_conf.pcm2pdm_conv_en = 0; i2s->pdm_conf.pdm2pcm_conv_en = 0; // SET_PERI_REG_BITS(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_SOC_CLK_SEL, 0x1, RTC_CNTL_SOC_CLK_SEL_S); + typeof(i2s->conf_chan) conf_chan; + conf_chan.val = 0; + conf_chan.tx_chan_mod = chan_mod; // 0-two channel;1-right;2-left;3-righ;4-left + conf_chan.rx_chan_mod = chan_mod; // 0-two channel;1-right;2-left;3-righ;4-left + i2s->conf_chan.val = conf_chan.val; - i2s->conf_chan.tx_chan_mod = chan_mod; // 0-two channel;1-right;2-left;3-righ;4-left - i2s->conf_chan.rx_chan_mod = chan_mod; // 0-two channel;1-right;2-left;3-righ;4-left - i2s->fifo_conf.tx_fifo_mod = fifo_mod; // 0-right&left channel;1-one channel - i2s->fifo_conf.rx_fifo_mod = fifo_mod; // 0-right&left channel;1-one channel + typeof(i2s->fifo_conf) fifo_conf; + fifo_conf.val = 0; + fifo_conf.tx_fifo_mod = fifo_mod; // 0-right&left channel;1-one channel + fifo_conf.rx_fifo_mod = fifo_mod; // 0-right&left channel;1-one channel + i2s->fifo_conf.val = fifo_conf.val; - i2s->conf.tx_mono = 0; - i2s->conf.rx_mono = 0; + typeof(i2s->conf) conf; + conf.val = 0; + conf.tx_msb_shift = (bits_per_sample != 8);// 0:DAC/PCM, 1:I2S + conf.tx_right_first = (bits_per_sample == 8); + i2s->conf.val = conf.val; - i2s->conf.tx_start = 0; - i2s->conf.rx_start = 0; - - i2s->conf.tx_short_sync = 0; - i2s->conf.rx_short_sync = 0; - i2s->conf.tx_msb_shift = (bits_per_sample != 8);// 0:DAC/PCM, 1:I2S - i2s->conf.rx_msb_shift = 0; - - i2s->conf.tx_slave_mod = 0; // Master - - i2s->conf.tx_msb_right = 0; - i2s->conf.tx_right_first = (bits_per_sample == 8); - i2s->conf2.lcd_en = (bits_per_sample == 8); - i2s->conf2.camera_en = 0; + typeof(i2s->conf2) conf2; + conf2.val = 0; + conf2.lcd_en = (bits_per_sample == 8); + i2s->conf2.val = conf2.val; i2s->fifo_conf.tx_fifo_mod_force_en = 1; @@ -366,7 +366,21 @@ void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2 i2sSetSampleRate(bus_num, sample_rate, bits_per_sample); // enable intr in cpu // - esp_intr_alloc(bus_num?ETS_I2S1_INTR_SOURCE:ETS_I2S0_INTR_SOURCE, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1, &i2sDmaISR, &I2S[bus_num], &I2S[bus_num].isr_handle); + int i2sIntSource; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (I2S_NUM_MAX == 2) + if (bus_num == 1) { + i2sIntSource = ETS_I2S1_INTR_SOURCE; + } + else +#endif + { + i2sIntSource = ETS_I2S0_INTR_SOURCE; + } + + + esp_intr_alloc(i2sIntSource, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1, &i2sDmaISR, &I2S[bus_num], &I2S[bus_num].isr_handle); // enable send intr i2s->int_ena.out_eof = 1; i2s->int_ena.out_dscr_err = 1; @@ -381,7 +395,7 @@ void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2 } esp_err_t i2sSetSampleRate(uint8_t bus_num, uint32_t rate, uint8_t bits) { - if (bus_num > 1) { + if (bus_num >= I2S_NUM_MAX) { return ESP_FAIL; } @@ -451,7 +465,7 @@ void IRAM_ATTR i2sDmaISR(void* arg) } size_t i2sWrite(uint8_t bus_num, uint8_t* data, size_t len, bool copy, bool free_when_sent) { - if (bus_num > 1 || !I2S[bus_num].tx_queue) { + if (bus_num >= I2S_NUM_MAX || !I2S[bus_num].tx_queue) { return 0; } size_t index = 0; diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.h b/lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.h similarity index 86% rename from lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.h rename to lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.h index 0027369cf..a95e7c5a6 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/Esp32_i2s.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/Esp32_i2s.h @@ -20,14 +20,12 @@ typedef enum { void i2sInit(uint8_t bus_num, uint32_t bits_per_sample, uint32_t sample_rate, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod, size_t dma_count, size_t dma_len); -void i2sSetPins(uint8_t bus_num, int8_t out, int8_t ws, int8_t bck, int8_t in); +void i2sSetPins(uint8_t bus_num, int8_t out, bool invert); void i2sSetDac(uint8_t bus_num, bool right, bool left); esp_err_t i2sSetClock(uint8_t bus_num, uint8_t div_num, uint8_t div_b, uint8_t div_a, uint8_t bck, uint8_t bits_per_sample); esp_err_t i2sSetSampleRate(uint8_t bus_num, uint32_t sample_rate, uint8_t bits_per_sample); -void i2sSetTxDataMode(uint8_t bus_num, i2s_tx_chan_mod_t chan_mod, i2s_tx_fifo_mod_t fifo_mod); - void i2sSetSilenceBuf(uint8_t bus_num, uint8_t* data, size_t len); size_t i2sWrite(uint8_t bus_num, uint8_t* data, size_t len, bool copy, bool free_when_sent); diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HsbColor.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HsbColor.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HsbColor.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HsbColor.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HsbColor.h b/lib/NeoPixelBus-2.6.0/src/internal/HsbColor.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HsbColor.h rename to lib/NeoPixelBus-2.6.0/src/internal/HsbColor.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HslColor.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HslColor.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HslColor.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HslColor.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HslColor.h b/lib/NeoPixelBus-2.6.0/src/internal/HslColor.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HslColor.h rename to lib/NeoPixelBus-2.6.0/src/internal/HslColor.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColor.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColor.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColor.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColor.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColor.h b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColor.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColor.h rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColor.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNameStrings.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNameStrings.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNameStrings.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNameStrings.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNameStrings.h b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNameStrings.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNameStrings.h rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNameStrings.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNames.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNames.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorNames.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColorNames.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorShortNames.cpp b/lib/NeoPixelBus-2.6.0/src/internal/HtmlColorShortNames.cpp similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/HtmlColorShortNames.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/HtmlColorShortNames.cpp diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/Layouts.h b/lib/NeoPixelBus-2.6.0/src/internal/Layouts.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/Layouts.h rename to lib/NeoPixelBus-2.6.0/src/internal/Layouts.h diff --git a/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806ColorFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806ColorFeatures.h new file mode 100644 index 000000000..6ffb4d0d9 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806ColorFeatures.h @@ -0,0 +1,189 @@ +/*------------------------------------------------------------------------- +Lpd8806ColorFeatures provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class Lpd88063ElementsNoSettings +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class Lpd88063Elements : public Lpd88063ElementsNoSettings +{ +public: + static const size_t PixelSize = 3; + + + static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + + static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + *pPixelDest++ = pPixelSrc[0]; + *pPixelDest++ = pPixelSrc[1]; + *pPixelDest++ = pPixelSrc[2]; + } + } + + static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + *pPixelDest++ = *pPixelSrc++; + *pPixelDest++ = *pPixelSrc++; + *pPixelDest++ = *pPixelSrc++; + } + } + + static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + const uint8_t* pSrc = (const uint8_t*)pPixelSrc; + while (pPixelDest < pEnd) + { + *pPixelDest++ = pgm_read_byte(pSrc++); + *pPixelDest++ = pgm_read_byte(pSrc++); + *pPixelDest++ = pgm_read_byte(pSrc++); + } + } + + static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pDestBack = pPixelDest + (count * PixelSize); + const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); + while (pDestBack > pPixelDest) + { + *--pDestBack = *--pSrcBack; + *--pDestBack = *--pSrcBack; + *--pDestBack = *--pSrcBack; + } + } + + typedef RgbColor ColorObject; +}; + +class Lpd8806BrgFeature : public Lpd88063Elements +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = (color.B >> 1) | 0x80; + *p++ = (color.R >> 1) | 0x80; + *p = (color.G >> 1) | 0x80; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.B = (*p++) << 1; + color.R = (*p++) << 1; + color.G = (*p) << 1; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.B = (pgm_read_byte(p++)) << 1; + color.R = (pgm_read_byte(p++)) << 1; + color.G = (pgm_read_byte(p)) << 1; + + return color; + } + +}; + +class Lpd8806GrbFeature : public Lpd88063Elements +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = (color.G >> 1) | 0x80; + *p++ = (color.R >> 1) | 0x80; + *p = (color.B >> 1) | 0x80; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.G = (*p++) << 1; + color.R = (*p++) << 1; + color.B = (*p) << 1; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.G = (pgm_read_byte(p++)) << 1; + color.R = (pgm_read_byte(p++)) << 1; + color.B = (pgm_read_byte(p)) << 1; + + return color; + } + +}; + diff --git a/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806GenericMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806GenericMethod.h new file mode 100644 index 000000000..2a741f991 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/Lpd8806GenericMethod.h @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for LPD8806 using general Pins + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set +#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) +#include "TwoWireBitBangImpleAvr.h" +#else +#include "TwoWireBitBangImple.h" +#endif + + +template class Lpd8806MethodBase +{ +public: + Lpd8806MethodBase(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _sizeFrame((pixelCount + 31) / 32), + _wire(pinClock, pinData) + { + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + } + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) + Lpd8806MethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + Lpd8806MethodBase(SCK, MOSI, pixelCount, elementSize, settingsSize) + { + } +#endif + + + ~Lpd8806MethodBase() + { + free(_data); + } + + bool IsReadyToUpdate() const + { + return true; // dot stars don't have a required delay + } + +#if defined(ARDUINO_ARCH_ESP32) + void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) + { + _wire.begin(sck, miso, mosi, ss); + } +#endif + + void Initialize() + { + _wire.begin(); + } + + void Update(bool) + { + _wire.beginTransaction(); + + // start frame + for (size_t frameByte = 0; frameByte < _sizeFrame; frameByte++) + { + _wire.transmitByte(0x00); + } + + // data + _wire.transmitBytes(_data, _sizeData); + + // end frame + for (size_t frameByte = 0; frameByte < _sizeFrame; frameByte++) + { + _wire.transmitByte(0xff); + } + + _wire.endTransaction(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + const size_t _sizeFrame; + + T_TWOWIRE _wire; + uint8_t* _data; // Holds LED color values +}; + +typedef Lpd8806MethodBase Lpd8806Method; + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) +#include "TwoWireSpiImple.h" +typedef Lpd8806MethodBase> Lpd8806Spi20MhzMethod; +typedef Lpd8806MethodBase> Lpd8806Spi10MhzMethod; +typedef Lpd8806MethodBase> Lpd8806Spi2MhzMethod; +typedef Lpd8806Spi10MhzMethod Lpd8806SpiMethod; +#endif + + + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoArmMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoArmMethod.h similarity index 88% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoArmMethod.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoArmMethod.h index 9cfce8874..34f111604 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoArmMethod.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoArmMethod.h @@ -30,26 +30,26 @@ License along with NeoPixel. If not, see #pragma once -#if defined(__arm__) +#if defined(__arm__) && !defined(ARDUINO_ARCH_NRF52840) template class NeoArmMethodBase { public: - NeoArmMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : + NeoArmMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), _pin(pin) { pinMode(pin, OUTPUT); - _sizePixels = pixelCount * elementSize; - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0, _sizePixels); + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); } ~NeoArmMethodBase() { pinMode(_pin, INPUT); - free(_pixels); + free(_data); } bool IsReadyToUpdate() const @@ -81,7 +81,7 @@ public: noInterrupts(); // Need 100% focus on instruction timing - T_SPEED::send_pixels(_pixels, _sizePixels, _pin); + T_SPEED::send_pixels(_data, _sizeData, _pin); interrupts(); @@ -89,20 +89,21 @@ public: _endTime = micros(); } - uint8_t* getPixels() const + uint8_t* getData() const { - return _pixels; + return _data; }; - size_t getPixelsSize() const + size_t getDataSize() const { - return _sizePixels; + return _sizeData; }; private: + const size_t _sizeData; // Size of '_data' buffer below + uint32_t _endTime; // Latch timing reference - size_t _sizePixels; // Size of '_pixels' buffer below - uint8_t* _pixels; // Holds LED color values + uint8_t* _data; // Holds LED color values uint8_t _pin; // output pin number }; @@ -129,6 +130,12 @@ public: static const uint32_t ResetTimeUs = 80; }; +class NeoArmMk20dxSpeedPropsTm1814 : public NeoArmMk20dxSpeedProps800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + class NeoArmMk20dxSpeedProps800Kbps : public NeoArmMk20dxSpeedProps800KbpsBase { public: @@ -147,10 +154,10 @@ public: class NeoArmMk20dxSpeedPropsApa106 { public: - static const uint32_t CyclesT0h = (F_CPU / 4000000); - static const uint32_t CyclesT1h = (F_CPU / 913750); - static const uint32_t Cycles = (F_CPU / 584800); - static const uint32_t ResetTimeUs = 50; + static const uint32_t CyclesT0h = (F_CPU / 4000000); + static const uint32_t CyclesT1h = (F_CPU / 913750); + static const uint32_t Cycles = (F_CPU / 584800); + static const uint32_t ResetTimeUs = 50; }; template class NeoArmMk20dxSpeedBase @@ -199,6 +206,7 @@ public: typedef NeoArmMethodBase> NeoArmWs2812xMethod; typedef NeoArmMethodBase> NeoArmSk6812Method; +typedef NeoArmMethodBase> NeoArmTm1814InvertedMethod; typedef NeoArmMethodBase> NeoArmApa106Method; typedef NeoArmMethodBase> NeoArm800KbpsMethod; typedef NeoArmMethodBase> NeoArm400KbpsMethod; @@ -310,6 +318,12 @@ public: const static uint32_t ResetTimeUs = 80; }; +class NeoArmMk26z64SpeedTm1814 : public NeoArmMk26z64Speed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 200; +}; + class NeoArmMk26z64Speed800Kbps : public NeoArmMk26z64Speed800KbpsBase { public: @@ -318,6 +332,7 @@ public: typedef NeoArmMethodBase NeoArmWs2812xMethod; typedef NeoArmMethodBase NeoArmSk6812Method; +typedef NeoArmMethodBase NeoArmTm1814InvertedMethod; typedef NeoArmMethodBase NeoArm800KbpsMethod; typedef NeoArm800KbpsMethod NeoArmApa106Method @@ -365,6 +380,12 @@ public: static const uint32_t ResetTimeUs = 80; }; +class NeoArmSamd21g18aSpeedPropsTm1814 : public NeoArmSamd21g18aSpeedProps800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + class NeoArmSamd21g18aSpeedProps800Kbps : public NeoArmSamd21g18aSpeedProps800KbpsBase { public: @@ -453,9 +474,10 @@ public: typedef NeoArmMethodBase> NeoArmWs2812xMethod; typedef NeoArmMethodBase> NeoArmSk6812Method; +typedef NeoArmMethodBase> NeoArmTm1814InvertedMethod; typedef NeoArmMethodBase> NeoArm800KbpsMethod; typedef NeoArmMethodBase> NeoArm400KbpsMethod; -typedef NeoArm400KbpsMethod NeoArmApa106Method +typedef NeoArm400KbpsMethod NeoArmApa106Method; #elif defined(ARDUINO_STM32_FEATHER) || defined(ARDUINO_ARCH_STM32L4) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32F1)// FEATHER WICED (120MHz) @@ -523,6 +545,12 @@ public: static const uint32_t ResetTimeUs = 80; }; +class NeoArmStm32SpeedPropsTm1814 : public NeoArmStm32SpeedProps800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + class NeoArmStm32SpeedProps800Kbps : public NeoArmStm32SpeedProps800KbpsBase { public: @@ -563,32 +591,32 @@ public: uint8_t bitMask = 0x80; #if defined(ARDUINO_STM32_FEATHER) - uint32_t pinMask = BIT(PIN_MAP[pin].gpio_bit); + uint32_t pinMask = BIT(PIN_MAP[pin].gpio_bit); - volatile uint16_t* set = &(PIN_MAP[pin].gpio_device->regs->BSRRL); - volatile uint16_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRRH); + volatile uint16_t* set = &(PIN_MAP[pin].gpio_device->regs->BSRRL); + volatile uint16_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRRH); #elif defined(ARDUINO_ARCH_STM32F4) - uint32_t pinMask = BIT(pin & 0x0f); + uint32_t pinMask = BIT(pin & 0x0f); - volatile uint16_t* set = &(PIN_MAP[pin].gpio_device->regs->BSRRL); - volatile uint16_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRRH); + volatile uint16_t* set = &(PIN_MAP[pin].gpio_device->regs->BSRRL); + volatile uint16_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRRH); #elif defined(ARDUINO_ARCH_STM32F1) - uint32_t pinMask = BIT(PIN_MAP[pin].gpio_bit); + uint32_t pinMask = BIT(PIN_MAP[pin].gpio_bit); - volatile uint32_t* set = &(PIN_MAP[pin].gpio_device->regs->BRR); - volatile uint32_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRR); + volatile uint32_t* set = &(PIN_MAP[pin].gpio_device->regs->BRR); + volatile uint32_t* clr = &(PIN_MAP[pin].gpio_device->regs->BSRR); #elif defined(ARDUINO_ARCH_STM32L4) - uint32_t pinMask = g_APinDescription[pin].bit; + uint32_t pinMask = g_APinDescription[pin].bit; - GPIO_TypeDef* GPIO = static_cast(g_APinDescription[pin].GPIO); + GPIO_TypeDef* GPIO = static_cast(g_APinDescription[pin].GPIO); - volatile uint32_t* set = &(GPIO->BRR); - volatile uint32_t* clr = &(GPIO->BSRR); + volatile uint32_t* set = &(GPIO->BRR); + volatile uint32_t* clr = &(GPIO->BSRR); #endif for (;;) @@ -634,6 +662,7 @@ public: typedef NeoArmMethodBase> NeoArmWs2812xMethod; typedef NeoArmMethodBase> NeoArmSk6812Method; +typedef NeoArmMethodBase> NeoArmTm1814InvertedMethod; typedef NeoArmMethodBase> NeoArm800KbpsMethod; typedef NeoArm800KbpsMethod NeoArmApa106Method; @@ -663,6 +692,12 @@ public: static const uint32_t ResetTimeUs = 80; }; +class NeoArmOtherSpeedPropsTm1814 : public NeoArmOtherSpeedProps800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + class NeoArmOtherSpeedProps800Kbps : public NeoArmOtherSpeedProps800KbpsBase { public: @@ -756,6 +791,7 @@ public: typedef NeoArmMethodBase> NeoArmWs2812xMethod; typedef NeoArmMethodBase> NeoArmSk6812Method; +typedef NeoArmMethodBase> NeoArmTm1814InvertedMethod; typedef NeoArmMethodBase> NeoArm800KbpsMethod; typedef NeoArmMethodBase> NeoArm400KbpsMethod; typedef NeoArm400KbpsMethod NeoArmApa106Method; @@ -766,6 +802,7 @@ typedef NeoArm400KbpsMethod NeoArmApa106Method; // Arm doesn't have alternatives methods yet, so only one to make the default typedef NeoArmWs2812xMethod NeoWs2813Method; typedef NeoArmWs2812xMethod NeoWs2812xMethod; +typedef NeoArmWs2812xMethod NeoWs2811Method; typedef NeoArmSk6812Method NeoSk6812Method; typedef NeoArmSk6812Method NeoLc8812Method; typedef NeoArm800KbpsMethod NeoWs2812Method; @@ -774,6 +811,8 @@ typedef NeoArmWs2812xMethod Neo800KbpsMethod; #ifdef NeoArm400KbpsMethod // this is needed due to missing 400Kbps for some platforms typedef NeoArm400KbpsMethod Neo400KbpsMethod; #endif +// there is no invert methods for arm, but the norm for TM1814 is inverted, so +typedef NeoArmTm1814InvertedMethod NeoTm1814InvertedMethod; #endif // defined(__arm__) diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoAvrMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoAvrMethod.h similarity index 66% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoAvrMethod.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoAvrMethod.h index b292cf48c..b638d7b32 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoAvrMethod.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoAvrMethod.h @@ -27,43 +27,43 @@ License along with NeoPixel. If not, see #pragma once -#ifdef ARDUINO_ARCH_AVR +#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) extern "C" { - void send_pixels_8mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pinMask); - void send_pixels_8mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pinMask); - void send_pixels_8mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask); - void send_pixels_12mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pinMask); - void send_pixels_12mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pinMask); - void send_pixels_12mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask); - void send_pixels_16mhz_800(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask); - void send_pixels_16mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask); + void send_data_8mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask); + void send_data_8mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask); + void send_data_8mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask); + void send_data_12mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask); + void send_data_12mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask); + void send_data_12mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask); + void send_data_16mhz_800(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask); + void send_data_16mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask); } class NeoAvrSpeed800KbpsBase { public: - static void send_pixels(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) + static void send_data(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) // 8Mhz CPU #ifdef PORTD // PORTD isn't present on ATtiny85, etc. if (port == &PORTD) - send_pixels_8mhz_800_PortD(pixels, sizePixels, pinMask); + send_data_8mhz_800_PortD(data, sizeData, pinMask); else if (port == &PORTB) #endif // PORTD - send_pixels_8mhz_800_PortB(pixels, sizePixels, pinMask); + send_data_8mhz_800_PortB(data, sizeData, pinMask); #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) // 12Mhz CPU #ifdef PORTD // PORTD if (port == &PORTD) - send_pixels_12mhz_800_PortD(pixels, sizePixels, pinMask); + send_data_12mhz_800_PortD(data, sizeData, pinMask); else if (port == &PORTB) #endif // PORTD - send_pixels_12mhz_800_PortB(pixels, sizePixels, pinMask); + send_data_12mhz_800_PortB(data, sizeData, pinMask); #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) // 16Mhz CPU - send_pixels_16mhz_800(pixels, sizePixels, port, pinMask); + send_data_16mhz_800(data, sizeData, port, pinMask); #else #error "CPU SPEED NOT SUPPORTED" #endif @@ -83,6 +83,12 @@ public: static const uint32_t ResetTimeUs = 80; }; +class NeoAvrSpeedTm1814 : public NeoAvrSpeed800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + class NeoAvrSpeed800Kbps: public NeoAvrSpeed800KbpsBase { public: @@ -92,16 +98,16 @@ public: class NeoAvrSpeed400Kbps { public: - static void send_pixels(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) + static void send_data(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) // 8Mhz CPU - send_pixels_8mhz_400(pixels, sizePixels, port, pinMask); + send_data_8mhz_400(data, sizeData, port, pinMask); #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) // 12Mhz CPU - send_pixels_12mhz_400(pixels, sizePixels, port, pinMask); + send_data_12mhz_400(data, sizeData, port, pinMask); #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) // 16Mhz CPU - send_pixels_16mhz_400(pixels, sizePixels, port, pinMask); + send_data_16mhz_400(data, sizeData, port, pinMask); #else #error "CPU SPEED NOT SUPPORTED" #endif @@ -112,16 +118,16 @@ public: template class NeoAvrMethodBase { public: - NeoAvrMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : + NeoAvrMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), _pin(pin), _port(NULL), _pinMask(0) { pinMode(pin, OUTPUT); - _sizePixels = pixelCount * elementSize; - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0, _sizePixels); + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); _port = portOutputRegister(digitalPinToPort(pin)); _pinMask = digitalPinToBitMask(pin); @@ -131,7 +137,7 @@ public: { pinMode(_pin, INPUT); - free(_pixels); + free(_data); } bool IsReadyToUpdate() const @@ -165,7 +171,7 @@ public: noInterrupts(); // Need 100% focus on instruction timing - T_SPEED::send_pixels(_pixels, _sizePixels, _port, _pinMask); + T_SPEED::send_data(_data, _sizeData, _port, _pinMask); interrupts(); @@ -173,22 +179,23 @@ public: _endTime = micros(); } - uint8_t* getPixels() const + uint8_t* getData() const { - return _pixels; + return _data; }; - size_t getPixelsSize() const + size_t getDataSize() const { - return _sizePixels; + return _sizeData; }; private: - uint32_t _endTime; // Latch timing reference - size_t _sizePixels; // Size of '_pixels' buffer below - uint8_t* _pixels; // Holds LED color values - uint8_t _pin; // output pin number + const size_t _sizeData; // size of _data below + const uint8_t _pin; // output pin number + uint32_t _endTime; // Latch timing reference + uint8_t* _data; // Holds data stream which include LED color values and other settings as needed + volatile uint8_t* _port; // Output PORT register uint8_t _pinMask; // Output PORT bitmask }; @@ -196,6 +203,7 @@ private: typedef NeoAvrMethodBase NeoAvrWs2812xMethod; typedef NeoAvrMethodBase NeoAvrSk6812Method; +typedef NeoAvrMethodBase NeoAvrTm1814InvertedMethod; typedef NeoAvrMethodBase NeoAvr800KbpsMethod; typedef NeoAvrMethodBase NeoAvr400KbpsMethod; @@ -204,11 +212,13 @@ typedef NeoAvrMethodBase NeoAvr400KbpsMethod; typedef NeoAvrWs2812xMethod NeoWs2813Method; typedef NeoAvrWs2812xMethod NeoWs2812xMethod; typedef NeoAvr800KbpsMethod NeoWs2812Method; +typedef NeoAvrWs2812xMethod NeoWs2811Method; typedef NeoAvrSk6812Method NeoSk6812Method; typedef NeoAvrSk6812Method NeoLc8812Method; typedef NeoAvr400KbpsMethod NeoApa106Method; typedef NeoAvrWs2812xMethod Neo800KbpsMethod; typedef NeoAvr400KbpsMethod Neo400KbpsMethod; +typedef NeoAvrTm1814InvertedMethod NeoTm1814InvertedMethod; #endif diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBitmapFile.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoBitmapFile.h similarity index 99% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoBitmapFile.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoBitmapFile.h index 870696f48..2f0718e19 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBitmapFile.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoBitmapFile.h @@ -282,7 +282,7 @@ public: int16_t hSrc, LayoutMapCallback layoutMap) { - NeoShaderNop shaderNop; + NeoShaderNop shaderNop; Render>(destBuffer, shaderNop, diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBuffer.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoBuffer.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoBuffer.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoBuffer.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBufferContext.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoBufferContext.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoBufferContext.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoBufferContext.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBufferMethods.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoBufferMethods.h similarity index 99% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoBufferMethods.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoBufferMethods.h index 4bd531ff3..79d354f57 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoBufferMethods.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoBufferMethods.h @@ -27,7 +27,7 @@ License along with NeoPixel. If not, see #pragma once -#ifdef ARDUINO_ARCH_AVR +#if defined(NEOPIXEBUS_NO_STL) typedef uint16_t(*LayoutMapCallback)(int16_t x, int16_t y); diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoColorFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoColorFeatures.h similarity index 80% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoColorFeatures.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoColorFeatures.h index 9922363eb..d1494a278 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoColorFeatures.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoColorFeatures.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixelFeatures provides feature classes to describe color order and +NeoColorFeatures provides feature classes to describe color order and color depth for NeoPixelBus template class Written by Michael C. Miller. @@ -45,9 +45,10 @@ public: uint8_t* pEnd = pPixelDest + (count * PixelSize); while (pPixelDest < pEnd) { - *pPixelDest++ = pPixelSrc[0]; - *pPixelDest++ = pPixelSrc[1]; - *pPixelDest++ = pPixelSrc[2]; + for (uint8_t iElement = 0; iElement < PixelSize; iElement++) + { + *pPixelDest++ = pPixelSrc[iElement]; + } } } @@ -57,8 +58,6 @@ public: while (pPixelDest < pEnd) { *pPixelDest++ = *pPixelSrc++; - *pPixelDest++ = *pPixelSrc++; - *pPixelDest++ = *pPixelSrc++; } } @@ -69,8 +68,6 @@ public: while (pPixelDest < pEnd) { *pPixelDest++ = pgm_read_byte(pSrc++); - *pPixelDest++ = pgm_read_byte(pSrc++); - *pPixelDest++ = pgm_read_byte(pSrc++); } } @@ -81,8 +78,6 @@ public: while (pDestBack > pPixelDest) { *--pDestBack = *--pSrcBack; - *--pDestBack = *--pSrcBack; - *--pDestBack = *--pSrcBack; } } @@ -152,7 +147,50 @@ public: typedef RgbwColor ColorObject; }; -class NeoGrbFeature : public Neo3Elements + +class Neo3ElementsNoSettings : public Neo3Elements +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class Neo4ElementsNoSettings : public Neo4Elements +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class NeoGrbFeature : public Neo3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -164,10 +202,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.G = *p++; color.R = *p++; @@ -190,7 +228,7 @@ public: }; -class NeoGrbwFeature : public Neo4Elements +class NeoGrbwFeature : public Neo4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -203,10 +241,10 @@ public: *p = color.W; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.G = *p++; color.R = *p++; @@ -232,7 +270,7 @@ public: }; -class NeoRgbwFeature : public Neo4Elements +class NeoRgbwFeature : public Neo4ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -245,10 +283,10 @@ public: *p = color.W; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.G = *p++; @@ -273,7 +311,7 @@ public: }; -class NeoRgbFeature : public Neo3Elements +class NeoRgbFeature : public Neo3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -285,10 +323,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.G = *p++; @@ -311,7 +349,7 @@ public: }; -class NeoBrgFeature : public Neo3Elements +class NeoBrgFeature : public Neo3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -323,10 +361,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.B = *p++; color.R = *p++; @@ -349,7 +387,7 @@ public: }; -class NeoRbgFeature : public Neo3Elements +class NeoRbgFeature : public Neo3ElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -361,10 +399,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.B = *p++; diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoDib.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoDib.h similarity index 85% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoDib.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoDib.h index 2ec93eb7b..9ede9b110 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoDib.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoDib.h @@ -94,6 +94,25 @@ public: free((uint8_t*)_pixels); } + NeoDib& operator=(const NeoDib& other) + { + // check for self-assignment + if (&other == this) + { + return *this; + } + + uint16_t copyCount = other.PixelCount() < PixelCount() ? other.PixelCount() : PixelCount(); + + for (uint16_t pixel = 0; pixel < copyCount; pixel++) + { + _pixels[pixel] = other.Pixels()[pixel]; + } + + Dirty(); + return *this; + } + T_COLOR_OBJECT* Pixels() const { return _pixels; @@ -144,8 +163,8 @@ public: Dirty(); }; - template void Render(NeoBufferContext destBuffer, - T_SHADER& shader) + template + void Render(NeoBufferContext destBuffer, T_SHADER& shader, uint16_t destIndexPixel = 0) { if (IsDirty() || shader.IsDirty()) { @@ -159,7 +178,7 @@ public: for (uint16_t indexPixel = 0; indexPixel < countPixels; indexPixel++) { T_COLOR_OBJECT color = shader.Apply(indexPixel, _pixels[indexPixel]); - T_COLOR_FEATURE::applyPixelColor(destBuffer.Pixels, indexPixel, color); + T_COLOR_FEATURE::applyPixelColor(destBuffer.Pixels, destIndexPixel + indexPixel, color); } shader.ResetDirty(); diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEase.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEase.h similarity index 94% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoEase.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoEase.h index b7b5df964..77a346075 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEase.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEase.h @@ -26,7 +26,7 @@ License along with NeoPixel. If not, see #pragma once -#ifdef ARDUINO_ARCH_AVR +#if defined(NEOPIXEBUS_NO_STL) typedef float(*AnimEaseFunction)(float unitValue); @@ -93,7 +93,7 @@ public: static float CubicOut(float unitValue) { unitValue -= 1.0f; - return (unitValue * unitValue * unitValue + 1); + return (unitValue * unitValue * unitValue + 1.0f); } static float CubicInOut(float unitValue) @@ -114,7 +114,7 @@ public: { unitValue *= 2.0f; unitValue -= 1.0f; - return (0.5f * (unitValue * unitValue * unitValue) + 1); + return (0.5f * (unitValue * unitValue * unitValue + 1.0f)); } static float QuarticIn(float unitValue) @@ -125,7 +125,7 @@ public: static float QuarticOut(float unitValue) { unitValue -= 1.0f; - return -(unitValue * unitValue * unitValue * unitValue - 1); + return -(unitValue * unitValue * unitValue * unitValue - 1.0f); } static float QuarticInOut(float unitValue) @@ -200,18 +200,18 @@ public: static float SinusoidalInOut(float unitValue) { - return -0.5 * (cos(PI * unitValue) - 1.0f); + return -0.5f * (cos(PI * unitValue) - 1.0f); } static float SinusoidalCenter(float unitValue) { if (unitValue < 0.5f) { - return (0.5 * sin(PI * unitValue)); + return (0.5f * sin(PI * unitValue)); } else { - return (-0.5 * (cos(PI * (unitValue-0.5f)) + 1.0f)); + return (-0.5f * (cos(PI * (unitValue-0.5f)) + 1.0f)); } } @@ -277,7 +277,7 @@ public: unitValue *= 2.0f; if (unitValue < 1.0f) { - return (-0.5f * (sqrt(1.0f - unitValue * unitValue) - 1)); + return (-0.5f * (sqrt(1.0f - unitValue * unitValue) - 1.0f)); } else { @@ -290,19 +290,20 @@ public: { unitValue *= 2.0f; unitValue -= 1.0f; - if (unitValue == 0.0f) - { - return 1.0f; - } - else if (unitValue < 0.0f) + + if (unitValue < 0.0f) { return (0.5f * sqrt(1.0f - unitValue * unitValue)); } - else + else if (unitValue > 0.0f) { unitValue -= 2.0f; return (-0.5f * (sqrt(1.0f - unitValue * unitValue) - 1.0f ) + 0.5f); } + else + { + return 1.0f; + } } static float Gamma(float unitValue) diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32I2sMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32I2sMethod.h new file mode 100644 index 000000000..b3b8ee144 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32I2sMethod.h @@ -0,0 +1,276 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp32. + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#ifdef ARDUINO_ARCH_ESP32 + +extern "C" +{ +#include +#include "Esp32_i2s.h" +} + +const uint16_t c_dmaBytesPerPixelBytes = 4; + +class NeoEsp32I2sSpeedWs2812x +{ +public: + const static uint32_t I2sSampleRate = 100000; + const static uint16_t ByteSendTimeUs = 10; + const static uint16_t ResetTimeUs = 300; +}; + +class NeoEsp32I2sSpeedSk6812 +{ +public: + const static uint32_t I2sSampleRate = 100000; + const static uint16_t ByteSendTimeUs = 10; + const static uint16_t ResetTimeUs = 80; +}; + +class NeoEsp32I2sSpeedTm1814 +{ +public: + const static uint32_t I2sSampleRate = 100000; + const static uint16_t ByteSendTimeUs = 10; + const static uint16_t ResetTimeUs = 200; +}; + +class NeoEsp32I2sSpeed800Kbps +{ +public: + const static uint32_t I2sSampleRate = 100000; + const static uint16_t ByteSendTimeUs = 10; + const static uint16_t ResetTimeUs = 50; +}; + +class NeoEsp32I2sSpeed400Kbps +{ +public: + const static uint32_t I2sSampleRate = 50000; + const static uint16_t ByteSendTimeUs = 20; + const static uint16_t ResetTimeUs = 50; +}; + +class NeoEsp32I2sSpeedApa106 +{ +public: + const static uint32_t I2sSampleRate = 76000; + const static uint16_t ByteSendTimeUs = 14; + const static uint16_t ResetTimeUs = 50; +}; + +class NeoEsp32I2sBusZero +{ +public: + const static uint8_t I2sBusNumber = 0; +}; + +class NeoEsp32I2sBusOne +{ +public: + const static uint8_t I2sBusNumber = 1; +}; + +class NeoEsp32I2sNotInverted +{ +public: + const static bool Inverted = false; +}; + +class NeoEsp32I2sInverted +{ +public: + const static bool Inverted = true; +}; + +template class NeoEsp32I2sMethodBase +{ +public: + NeoEsp32I2sMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _pin(pin) + { + uint16_t dmaSettingsSize = c_dmaBytesPerPixelBytes * settingsSize; + uint16_t dmaPixelSize = c_dmaBytesPerPixelBytes * elementSize; + uint16_t resetSize = c_dmaBytesPerPixelBytes * T_SPEED::ResetTimeUs / T_SPEED::ByteSendTimeUs; + + _i2sBufferSize = pixelCount * dmaPixelSize + dmaSettingsSize + resetSize; + + // must have a 4 byte aligned buffer for i2s + uint32_t alignment = _i2sBufferSize % 4; + if (alignment) + { + _i2sBufferSize += 4 - alignment; + } + + _data = static_cast(malloc(_sizeData)); + memset(_data, 0x00, _sizeData); + + _i2sBuffer = static_cast(malloc(_i2sBufferSize)); + memset(_i2sBuffer, 0x00, _i2sBufferSize); + } + + ~NeoEsp32I2sMethodBase() + { + while (!IsReadyToUpdate()) + { + yield(); + } + + pinMode(_pin, INPUT); + + free(_data); + free(_i2sBuffer); + } + + bool IsReadyToUpdate() const + { + return (i2sWriteDone(T_BUS::I2sBusNumber)); + } + + void Initialize() + { + size_t dmaCount = (_i2sBufferSize + I2S_DMA_MAX_DATA_LEN - 1) / I2S_DMA_MAX_DATA_LEN; + i2sInit(T_BUS::I2sBusNumber, 16, T_SPEED::I2sSampleRate, I2S_CHAN_STEREO, I2S_FIFO_16BIT_DUAL, dmaCount, 0); + i2sSetPins(T_BUS::I2sBusNumber, _pin, T_INVERT::Inverted); + } + + void Update(bool) + { + // wait for not actively sending data + while (!IsReadyToUpdate()) + { + yield(); + } + + FillBuffers(); + + i2sWrite(T_BUS::I2sBusNumber, _i2sBuffer, _i2sBufferSize, false, false); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + } + +private: + const size_t _sizeData; // Size of '_data' buffer + const uint8_t _pin; // output pin number + + uint8_t* _data; // Holds LED color values + + uint32_t _i2sBufferSize; // total size of _i2sBuffer + uint8_t* _i2sBuffer; // holds the DMA buffer that is referenced by _i2sBufDesc + + void FillBuffers() + { + const uint16_t bitpatterns[16] = + { + 0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110, + 0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110, + 0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110, + 0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110, + }; + + uint16_t* pDma = reinterpret_cast(_i2sBuffer); + uint8_t* pEnd = _data + _sizeData; + for (uint8_t* pPixel = _data; pPixel < pEnd; pPixel++) + { + *(pDma++) = bitpatterns[((*pPixel) & 0x0f)]; + *(pDma++) = bitpatterns[((*pPixel) >> 4) & 0x0f]; + } + } +}; + +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Ws2812xMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Sk6812Method; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Tm1814Method; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0800KbpsMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0400KbpsMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Apa106Method; + + +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Ws2812xInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Sk6812InvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Tm1814InvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0800KbpsInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0400KbpsInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s0Apa106InvertedMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (I2S_NUM_MAX == 2) + +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Ws2812xMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Sk6812Method; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Tm1814Method; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1800KbpsMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1400KbpsMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Apa106Method; + +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Ws2812xInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Sk6812InvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Tm1814InvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1800KbpsInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1400KbpsInvertedMethod; +typedef NeoEsp32I2sMethodBase NeoEsp32I2s1Apa106InvertedMethod; + +#endif + +/* due to a core issue where requests to send aren't consistent, I2s is no longer the default +// I2s Bus 1 method is the default method for Esp32 +typedef NeoEsp32I2s1Ws2812xMethod NeoWs2813Method; +typedef NeoEsp32I2s1Ws2812xMethod NeoWs2812xMethod; +typedef NeoEsp32I2s1800KbpsMethod NeoWs2812Method; +typedef NeoEsp32I2s1Ws2812xMethod NeoWs2811Method; +typedef NeoEsp32I2s1Sk6812Method NeoSk6812Method; +typedef NeoEsp32I2s1Tm1814Method NeoTm1814Method; +typedef NeoEsp32I2s1Sk6812Method NeoLc8812Method; +typedef NeoEsp32I2s1Apa106Method NeoApa106Method; + +typedef NeoEsp32I2s1Ws2812xMethod Neo800KbpsMethod; +typedef NeoEsp32I2s1400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32I2s1Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32I2s1800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32I2s1Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32I2s1Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32I2s1Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32I2s1Apa106InvertedMethod NeoApa106InvertedMethod; + +typedef NeoEsp32I2s1Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32I2s1400KbpsInvertedMethod Neo400KbpsInvertedMethod; +*/ + +#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.cpp b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.cpp new file mode 100644 index 000000000..278d56dce --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.cpp @@ -0,0 +1,262 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp32. + +A BIG thanks to Andreas Merkle for the investigation and implementation of +a workaround to the GCC bug that drops method attributes from template methods + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#include "NeoEsp32RmtMethod.h" + +#ifdef ARDUINO_ARCH_ESP32 + + +// translate NeoPixelBuffer into RMT buffer +// this is done on the fly so we don't require a send buffer in raw RMT format +// which would be 32x larger than the primary buffer +// +// NOTE: This was moved from the template below to here to workaround a GCC bug +// That bug is that the IRAM_ATTR attribute (any attributes) is lost on template classes. +// +// Further, it was removed from the header to support current Esp32 release +// which will need to be removed when the latest GitHub branchis released +// due to this method will not get inlined this way +// +void NeoEsp32RmtSpeed::_translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num, + const uint32_t rmtBit0, + const uint32_t rmtBit1, + const uint16_t rmtDurationReset) +{ + if (src == NULL || dest == NULL) + { + *translated_size = 0; + *item_num = 0; + return; + } + + size_t size = 0; + size_t num = 0; + const uint8_t* psrc = static_cast(src); + rmt_item32_t* pdest = dest; + + for (;;) + { + uint8_t data = *psrc; + + for (uint8_t bit = 0; bit < 8; bit++) + { + pdest->val = (data & 0x80) ? rmtBit1 : rmtBit0; + pdest++; + data <<= 1; + } + num += 8; + size++; + + // if this is the last byte we need to adjust the length of the last pulse + if (size >= src_size) + { + // extend the last bits LOW value to include the full reset signal length + pdest--; + pdest->duration1 = rmtDurationReset; + // and stop updating data to send + break; + } + + if (num >= wanted_num) + { + // stop updating data to send + break; + } + + psrc++; + } + + *translated_size = size; + *item_num = num; +} + + +// these are required due to the linker error with ISRs +// dangerous relocation: l32r: literal placed after use +// https://stackoverflow.com/questions/19532826/what-does-a-dangerous-relocation-error-mean +// +void NeoEsp32RmtSpeedWs2811::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeedWs2812x::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeedSk6812::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeedTm1814::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeed800Kbps::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeed400Kbps::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtSpeedApa106::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeedWs2811::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeedWs2812x::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeedSk6812::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeedTm1814::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeed800Kbps::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeed400Kbps::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} + +void NeoEsp32RmtInvertedSpeedApa106::Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num) +{ + _translate(src, dest, src_size, wanted_num, translated_size, item_num, + RmtBit0, RmtBit1, RmtDurationReset); +} +#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.h new file mode 100644 index 000000000..4d633ba3a --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp32RmtMethod.h @@ -0,0 +1,668 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp32. + +A BIG thanks to Andreas Merkle for the investigation and implementation of +a workaround to the GCC bug that drops method attributes from template methods + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#ifdef ARDUINO_ARCH_ESP32 + +/* General Reference documentation for the APIs used in this implementation +LOW LEVEL: (what is actually used) +DOCS: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/rmt.html +EXAMPLE: https://github.com/espressif/esp-idf/blob/826ff7186ae07dc81e960a8ea09ebfc5304bfb3b/examples/peripherals/rmt_tx/main/rmt_tx_main.c + +HIGHER LEVEL: +NO TRANSLATE SUPPORT so this was not used +NOTE: https://github.com/espressif/arduino-esp32/commit/50d142950d229b8fabca9b749dc4a5f2533bc426 +Esp32-hal-rmt.h +Esp32-hal-rmt.c +*/ + +#include + +extern "C" +{ +#include +} + +class NeoEsp32RmtSpeed +{ +public: + // ClkDiv of 2 provides for good resolution and plenty of reset resolution; but + // a ClkDiv of 1 will provide enough space for the longest reset and does show + // little better pulse accuracy + const static uint8_t RmtClockDivider = 2; + + inline constexpr static uint32_t FromNs(uint32_t ns) + { + return ns / NsPerRmtTick; + } + +protected: + const static uint32_t RmtCpu = 80000000L; // 80 mhz RMT clock + const static uint32_t NsPerSecond = 1000000000L; + const static uint32_t RmtTicksPerSecond = (RmtCpu / RmtClockDivider); + const static uint32_t NsPerRmtTick = (NsPerSecond / RmtTicksPerSecond); // about 25 + + static void IRAM_ATTR _translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num, + const uint32_t rmtBit0, + const uint32_t rmtBit1, + const uint16_t rmtDurationReset); + +}; + +class NeoEsp32RmtSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_item32_t as you can't correctly initialize + // it as a static constexpr within the template + inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) + { + return (FromNs(nsLow) << 16) | (1 << 15) | (FromNs(nsHigh)); + } + + const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_LOW; +}; + +class NeoEsp32RmtInvertedSpeedBase : public NeoEsp32RmtSpeed +{ +public: + // this is used rather than the rmt_item32_t as you can't correctly initialize + // it as a static constexpr within the template + inline constexpr static uint32_t Item32Val(uint16_t nsHigh, uint16_t nsLow) + { + return (FromNs(nsLow) << 16) | (1 << 31) | (FromNs(nsHigh)); + } + + const static rmt_idle_level_t IdleLevel = RMT_IDLE_LEVEL_HIGH; +}; + +class NeoEsp32RmtSpeedWs2811 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedWs2812x : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedSk6812 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtSpeedTm1814 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeed800Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeed400Kbps : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtSpeedApa106 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 1250); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1250, 400); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedWs2811 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(300, 950); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(900, 350); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedWs2812x : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(300000); // 300us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedSk6812 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(80000); // 80us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +// normal is inverted signal +class NeoEsp32RmtInvertedSpeedTm1814 : public NeoEsp32RmtSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(360, 890); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(720, 530); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(200000); // 200us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeed800Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 850); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(800, 450); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeed400Kbps : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(800, 1700); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1600, 900); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtInvertedSpeedApa106 : public NeoEsp32RmtInvertedSpeedBase +{ +public: + const static DRAM_ATTR uint32_t RmtBit0 = Item32Val(400, 1250); + const static DRAM_ATTR uint32_t RmtBit1 = Item32Val(1250, 400); + const static DRAM_ATTR uint16_t RmtDurationReset = FromNs(50000); // 50us + + static void IRAM_ATTR Translate(const void* src, + rmt_item32_t* dest, + size_t src_size, + size_t wanted_num, + size_t* translated_size, + size_t* item_num); +}; + +class NeoEsp32RmtChannel0 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_0; +}; + +class NeoEsp32RmtChannel1 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_1; +}; + +class NeoEsp32RmtChannel2 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_2; +}; + +class NeoEsp32RmtChannel3 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3; +}; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) + +class NeoEsp32RmtChannel4 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_4; +}; + +class NeoEsp32RmtChannel5 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_5; +}; + +class NeoEsp32RmtChannel6 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_6; +}; + +class NeoEsp32RmtChannel7 +{ +public: + const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_7; +}; + +#endif + +template class NeoEsp32RmtMethodBase +{ +public: + NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _pin(pin) + { + _dataEditing = static_cast(malloc(_sizeData)); + memset(_dataEditing, 0x00, _sizeData); + + _dataSending = static_cast(malloc(_sizeData)); + // no need to initialize it, it gets overwritten on every send + } + + ~NeoEsp32RmtMethodBase() + { + // wait until the last send finishes before destructing everything + // arbitrary time out of 10 seconds + ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS)); + + ESP_ERROR_CHECK(rmt_driver_uninstall(T_CHANNEL::RmtChannelNumber)); + + free(_dataEditing); + free(_dataSending); + } + + + bool IsReadyToUpdate() const + { + return (ESP_OK == rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 0)); + } + + void Initialize() + { + rmt_config_t config; + + config.rmt_mode = RMT_MODE_TX; + config.channel = T_CHANNEL::RmtChannelNumber; + config.gpio_num = static_cast(_pin); + config.mem_block_num = 1; + config.tx_config.loop_en = false; + + config.tx_config.idle_output_en = true; + config.tx_config.idle_level = T_SPEED::IdleLevel; + + config.tx_config.carrier_en = false; + config.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; + + config.clk_div = T_SPEED::RmtClockDivider; + + ESP_ERROR_CHECK(rmt_config(&config)); + ESP_ERROR_CHECK(rmt_driver_install(T_CHANNEL::RmtChannelNumber, 0, ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LEVEL1)); + ESP_ERROR_CHECK(rmt_translator_init(T_CHANNEL::RmtChannelNumber, T_SPEED::Translate)); + } + + void Update(bool maintainBufferConsistency) + { + // wait for not actively sending data + // this will time out at 10 seconds, an arbitrarily long period of time + // and do nothing if this happens + if (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(T_CHANNEL::RmtChannelNumber, 10000 / portTICK_PERIOD_MS))) + { + // now start the RMT transmit with the editing buffer before we swap + ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_write_sample(T_CHANNEL::RmtChannelNumber, _dataEditing, _sizeData, false)); + + if (maintainBufferConsistency) + { + // copy editing to sending, + // this maintains the contract that "colors present before will + // be the same after", otherwise GetPixelColor will be inconsistent + memcpy(_dataSending, _dataEditing, _sizeData); + } + + // swap so the user can modify without affecting the async operation + std::swap(_dataSending, _dataEditing); + } + } + + uint8_t* getData() const + { + return _dataEditing; + }; + + size_t getDataSize() const + { + return _sizeData; + } + +private: + const size_t _sizeData; // Size of '_data*' buffers + const uint8_t _pin; // output pin number + + // Holds data stream which include LED color values and other settings as needed + uint8_t* _dataEditing; // exposed for get and set + uint8_t* _dataSending; // used for async send using RMT +}; + +// normal +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (RMT_CHANNEL_MAX == 8) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106Method; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsMethod; + +#endif + +// inverted +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt0400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt1400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt2400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt3400KbpsInvertedMethod; + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (RMT_CHANNEL_MAX == 8) + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt4400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt5400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt6400KbpsInvertedMethod; + +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2811InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Ws2812xInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Sk6812InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Tm1814InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7Apa106InvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7800KbpsInvertedMethod; +typedef NeoEsp32RmtMethodBase NeoEsp32Rmt7400KbpsInvertedMethod; + +#endif + +#if !defined(CONFIG_IDF_TARGET_ESP32S2) +// (RMT_CHANNEL_MAX == 8) +// due to a core issue where requests to send aren't consistent with I2s, RMT ch6 is temporarily the default +// RMT channel 6 method is the default method for Esp32 +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2813Method; +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2812xMethod; +typedef NeoEsp32Rmt6800KbpsMethod NeoWs2812Method; +typedef NeoEsp32Rmt6Ws2812xMethod NeoWs2811Method; +typedef NeoEsp32Rmt6Sk6812Method NeoSk6812Method; +typedef NeoEsp32Rmt6Tm1814Method NeoTm1814Method; +typedef NeoEsp32Rmt6Sk6812Method NeoLc8812Method; +typedef NeoEsp32Rmt6Apa106Method NeoApa106Method; + +typedef NeoEsp32Rmt6Ws2812xMethod Neo800KbpsMethod; +typedef NeoEsp32Rmt6400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32Rmt6Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32Rmt6800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32Rmt6Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32Rmt6Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32Rmt6Apa106InvertedMethod NeoApa106InvertedMethod; + +typedef NeoEsp32Rmt6Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32Rmt6400KbpsInvertedMethod Neo400KbpsInvertedMethod; +#else + +// due to a core issue where requests to send aren't consistent with I2s, RMT ch3 is temporarily the default +// RMT channel 3 method is the default method for Esp32S2 +typedef NeoEsp32Rmt3Ws2812xMethod NeoWs2813Method; +typedef NeoEsp32Rmt3Ws2812xMethod NeoWs2812xMethod; +typedef NeoEsp32Rmt3800KbpsMethod NeoWs2812Method; +typedef NeoEsp32Rmt3Ws2812xMethod NeoWs2811Method; +typedef NeoEsp32Rmt3Sk6812Method NeoSk6812Method; +typedef NeoEsp32Rmt3Tm1814Method NeoTm1814Method; +typedef NeoEsp32Rmt3Sk6812Method NeoLc8812Method; +typedef NeoEsp32Rmt3Apa106Method NeoApa106Method; + +typedef NeoEsp32Rmt3Ws2812xMethod Neo800KbpsMethod; +typedef NeoEsp32Rmt3400KbpsMethod Neo400KbpsMethod; + +typedef NeoEsp32Rmt3Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoEsp32Rmt3Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoEsp32Rmt3Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoEsp32Rmt3800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoEsp32Rmt3Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoEsp32Rmt3Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoEsp32Rmt3Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoEsp32Rmt3Apa106InvertedMethod NeoApa106InvertedMethod; + +typedef NeoEsp32Rmt3Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoEsp32Rmt3400KbpsInvertedMethod Neo400KbpsInvertedMethod; + +#endif + +#endif diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266DmaMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266DmaMethod.h similarity index 71% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266DmaMethod.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266DmaMethod.h index 402c9ae85..be36eb346 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266DmaMethod.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266DmaMethod.h @@ -65,7 +65,43 @@ struct slc_queue_item uint32 next_link_ptr; }; -class NeoEsp8266DmaSpeed800KbpsBase +class NeoEsp8266DmaSpeedBase +{ +public: + static const uint8_t Level = 0x00; + static uint16_t Convert(uint8_t value) + { + const uint16_t bitpatterns[16] = + { + 0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110, + 0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110, + 0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110, + 0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110, + }; + + return bitpatterns[value]; + } +}; + +class NeoEsp8266DmaInvertedSpeedBase +{ +public: + static const uint8_t Level = 0xFF; + static uint16_t Convert(uint8_t value) + { + const uint16_t bitpatterns[16] = + { + 0b0111011101110111, 0b0111011101110001, 0b0111011100010111, 0b0111011100010001, + 0b0111000101110111, 0b0111000101110001, 0b0111000100010111, 0b0111000100010001, + 0b0001011101110111, 0b0001011101110001, 0b0001011100010111, 0b0001011100010001, + 0b0001000101110111, 0b0001000101110001, 0b0001000100010111, 0b0001000100010001, + }; + + return bitpatterns[value]; + } +}; + +class NeoEsp8266DmaSpeed800KbpsBase : public NeoEsp8266DmaSpeedBase { public: const static uint32_t I2sClockDivisor = 3; @@ -85,13 +121,19 @@ public: const static uint32_t ResetTimeUs = 80; }; +class NeoEsp8266DmaInvertedSpeedTm1814 : public NeoEsp8266DmaSpeed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 200; +}; + class NeoEsp8266DmaSpeed800Kbps : public NeoEsp8266DmaSpeed800KbpsBase { public: const static uint32_t ResetTimeUs = 50; }; -class NeoEsp8266DmaSpeed400Kbps +class NeoEsp8266DmaSpeed400Kbps : public NeoEsp8266DmaSpeedBase { public: const static uint32_t I2sClockDivisor = 6; @@ -100,13 +142,65 @@ public: const static uint32_t ResetTimeUs = 50; }; -class NeoEsp8266DmaSpeedApa106 +class NeoEsp8266DmaSpeedApa106 : public NeoEsp8266DmaSpeedBase { public: - const static uint32_t I2sClockDivisor = 4; - const static uint32_t I2sBaseClockDivisor = 16; - const static uint32_t ByteSendTimeUs = 17; // us it takes to send a single pixel element - const static uint32_t ResetTimeUs = 50; + const static uint32_t I2sClockDivisor = 4; + const static uint32_t I2sBaseClockDivisor = 16; + const static uint32_t ByteSendTimeUs = 17; // us it takes to send a single pixel element + const static uint32_t ResetTimeUs = 50; +}; + + + +class NeoEsp8266DmaInvertedSpeed800KbpsBase : public NeoEsp8266DmaInvertedSpeedBase +{ +public: + const static uint32_t I2sClockDivisor = 3; + const static uint32_t I2sBaseClockDivisor = 16; + const static uint32_t ByteSendTimeUs = 10; // us it takes to send a single pixel element at 800khz speed +}; + +class NeoEsp8266DmaInvertedSpeedWs2812x : public NeoEsp8266DmaInvertedSpeed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 300; +}; + +class NeoEsp8266DmaInvertedSpeedSk6812 : public NeoEsp8266DmaInvertedSpeed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 80; +}; + +class NeoEsp8266DmaSpeedTm1814 : public NeoEsp8266DmaInvertedSpeed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 200; +}; + +class NeoEsp8266DmaInvertedSpeed800Kbps : public NeoEsp8266DmaInvertedSpeed800KbpsBase +{ +public: + const static uint32_t ResetTimeUs = 50; +}; + +class NeoEsp8266DmaInvertedSpeed400Kbps : public NeoEsp8266DmaInvertedSpeedBase +{ +public: + const static uint32_t I2sClockDivisor = 6; + const static uint32_t I2sBaseClockDivisor = 16; + const static uint32_t ByteSendTimeUs = 20; // us it takes to send a single pixel element at 400khz speed + const static uint32_t ResetTimeUs = 50; +}; + +class NeoEsp8266DmaInvertedSpeedApa106 : public NeoEsp8266DmaInvertedSpeedBase +{ +public: + const static uint32_t I2sClockDivisor = 4; + const static uint32_t I2sBaseClockDivisor = 16; + const static uint32_t ByteSendTimeUs = 17; // us it takes to send a single pixel element + const static uint32_t ResetTimeUs = 50; }; enum NeoDmaState @@ -123,22 +217,23 @@ const uint8_t c_I2sPin = 3; // due to I2S hardware, the pin used is restricted t template class NeoEsp8266DmaMethodBase { public: - NeoEsp8266DmaMethodBase(uint16_t pixelCount, size_t elementSize) + NeoEsp8266DmaMethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize) { uint16_t dmaPixelSize = c_dmaBytesPerPixelBytes * elementSize; + uint16_t dmaSettingsSize = c_dmaBytesPerPixelBytes * settingsSize; - _pixelsSize = pixelCount * elementSize; - _i2sBufferSize = pixelCount * dmaPixelSize; + _i2sBufferSize = pixelCount * dmaPixelSize + dmaSettingsSize; - _pixels = (uint8_t*)malloc(_pixelsSize); - memset(_pixels, 0x00, _pixelsSize); + _data = static_cast(malloc(_sizeData)); + memset(_data, 0x00, _sizeData); - _i2sBuffer = (uint8_t*)malloc(_i2sBufferSize); - memset(_i2sBuffer, 0x00, _i2sBufferSize); + _i2sBuffer = static_cast(malloc(_i2sBufferSize)); + memset(_i2sBuffer, T_SPEED::Level, _i2sBufferSize); // _i2sBuffer[0] = 0b11101000; // debug, 1 bit then 0 bit - memset(_i2sZeroes, 0x00, sizeof(_i2sZeroes)); + memset(_i2sZeroes, T_SPEED::Level, sizeof(_i2sZeroes)); _is2BufMaxBlockSize = (c_maxDmaBlockSize / dmaPixelSize) * dmaPixelSize; @@ -148,7 +243,8 @@ public: s_this = this; // store this for the ISR } - NeoEsp8266DmaMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize) : NeoEsp8266DmaMethodBase(pixelCount, elementSize) + NeoEsp8266DmaMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + NeoEsp8266DmaMethodBase(pixelCount, elementSize, settingsSize) { } @@ -174,7 +270,7 @@ public: s_this = nullptr; pinMode(c_I2sPin, INPUT); - free(_pixels); + free(_data); free(_i2sBuffer); free(_i2sBufDesc); } @@ -307,23 +403,23 @@ public: _dmaState = NeoDmaState_Pending; } - uint8_t* getPixels() const + uint8_t* getData() const { - return _pixels; + return _data; }; - size_t getPixelsSize() const + size_t getDataSize() const { - return _pixelsSize; + return _sizeData; } private: static NeoEsp8266DmaMethodBase* s_this; // for the ISR - size_t _pixelsSize; // Size of '_pixels' buffer - uint8_t* _pixels; // Holds LED color values + const size_t _sizeData; // Size of '_data' buffer + uint8_t* _data; // Holds LED color values - uint32_t _i2sBufferSize; // total size of _i2sBuffer + size_t _i2sBufferSize; // total size of _i2sBuffer uint8_t* _i2sBuffer; // holds the DMA buffer that is referenced by _i2sBufDesc // normally 24 bytes creates the minimum 50us latch per spec, but @@ -341,7 +437,7 @@ private: // handle here is the RX_EOF_INT status, which indicate the DMA has sent a buffer whose // descriptor has the 'EOF' field set to 1. // in the case of this code, the second to last state descriptor - volatile static void ICACHE_RAM_ATTR i2s_slc_isr(void) + static void ICACHE_RAM_ATTR i2s_slc_isr(void) { ETS_SLC_INTR_DISABLE(); @@ -392,20 +488,12 @@ private: void FillBuffers() { - const uint16_t bitpatterns[16] = - { - 0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110, - 0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110, - 0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110, - 0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110, - }; - uint16_t* pDma = (uint16_t*)_i2sBuffer; - uint8_t* pPixelsEnd = _pixels + _pixelsSize; - for (uint8_t* pPixel = _pixels; pPixel < pPixelsEnd; pPixel++) + uint8_t* pEnd = _data + _sizeData; + for (uint8_t* pData = _data; pData < pEnd; pData++) { - *(pDma++) = bitpatterns[((*pPixel) & 0x0f)]; - *(pDma++) = bitpatterns[((*pPixel) >> 4) & 0x0f]; + *(pDma++) = T_SPEED::Convert(((*pData) & 0x0f)); + *(pDma++) = T_SPEED::Convert(((*pData) >> 4) & 0x0f); } } @@ -432,29 +520,54 @@ private: uint32_t getPixelTime() const { - return (T_SPEED::ByteSendTimeUs * this->_pixelsSize); + return (T_SPEED::ByteSendTimeUs * this->_sizeData); }; }; + template NeoEsp8266DmaMethodBase* NeoEsp8266DmaMethodBase::s_this; +// normal typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaWs2812xMethod; typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaSk6812Method; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaTm1814Method; typedef NeoEsp8266DmaMethodBase NeoEsp8266Dma800KbpsMethod; typedef NeoEsp8266DmaMethodBase NeoEsp8266Dma400KbpsMethod; typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaApa106Method; +// inverted +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInvertedWs2812xMethod; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInvertedSk6812Method; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInvertedTm1814Method; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInverted800KbpsMethod; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInverted400KbpsMethod; +typedef NeoEsp8266DmaMethodBase NeoEsp8266DmaInvertedApa106Method; + // Dma method is the default method for Esp8266 typedef NeoEsp8266DmaWs2812xMethod NeoWs2813Method; typedef NeoEsp8266DmaWs2812xMethod NeoWs2812xMethod; typedef NeoEsp8266Dma800KbpsMethod NeoWs2812Method; +typedef NeoEsp8266DmaWs2812xMethod NeoWs2811Method; typedef NeoEsp8266DmaSk6812Method NeoSk6812Method; +typedef NeoEsp8266DmaTm1814Method NeoTm1814Method; typedef NeoEsp8266DmaSk6812Method NeoLc8812Method; typedef NeoEsp8266DmaApa106Method NeoApa106Method; typedef NeoEsp8266DmaWs2812xMethod Neo800KbpsMethod; typedef NeoEsp8266Dma400KbpsMethod Neo400KbpsMethod; +// inverted +typedef NeoEsp8266DmaInvertedWs2812xMethod NeoWs2813InvertedMethod; +typedef NeoEsp8266DmaInvertedWs2812xMethod NeoWs2812xInvertedMethod; +typedef NeoEsp8266DmaInverted800KbpsMethod NeoWs2812InvertedMethod; +typedef NeoEsp8266DmaInvertedWs2812xMethod NeoWs2811InvertedMethod; +typedef NeoEsp8266DmaInvertedSk6812Method NeoSk6812InvertedMethod; +typedef NeoEsp8266DmaInvertedTm1814Method NeoTm1814InvertedMethod; +typedef NeoEsp8266DmaInvertedSk6812Method NeoLc8812InvertedMethod; +typedef NeoEsp8266DmaInvertedApa106Method NeoApa106InvertedMethod; + +typedef NeoEsp8266DmaInvertedWs2812xMethod Neo800KbpsInvertedMethod; +typedef NeoEsp8266DmaInverted400KbpsMethod Neo400KbpsInvertedMethod; #endif diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.cpp b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.cpp similarity index 96% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.cpp index eb06812e6..dab9a57d0 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoEsp8266UartMethod.cpp +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.cpp @@ -33,7 +33,7 @@ extern "C" } const volatile uint8_t* ICACHE_RAM_ATTR NeoEsp8266UartContext::FillUartFifo(uint8_t uartNum, - const volatile uint8_t* pixels, + const volatile uint8_t* start, const volatile uint8_t* end) { // Remember: UARTs send less significant bit (LSB) first so @@ -47,19 +47,19 @@ const volatile uint8_t* ICACHE_RAM_ATTR NeoEsp8266UartContext::FillUartFifo(uint 0b000100, // On wire: 1 110 111 0 [NeoPixel reads 11] }; uint8_t avail = (UART_TX_FIFO_SIZE - GetTxFifoLength(uartNum)) / 4; - if (end - pixels > avail) + if (end - start > avail) { - end = pixels + avail; + end = start + avail; } - while (pixels < end) + while (start < end) { - uint8_t subpix = *pixels++; + uint8_t subpix = *start++; Enqueue(uartNum, _uartData[(subpix >> 6) & 0x3]); Enqueue(uartNum, _uartData[(subpix >> 4) & 0x3]); Enqueue(uartNum, _uartData[(subpix >> 2) & 0x3]); Enqueue(uartNum, _uartData[subpix & 0x3]); } - return pixels; + return start; } volatile NeoEsp8266UartInterruptContext* NeoEsp8266UartInterruptContext::s_uartInteruptContext[] = { nullptr, nullptr }; diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.h new file mode 100644 index 000000000..3be17bace --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEsp8266UartMethod.h @@ -0,0 +1,514 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp8266 UART hardware + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#ifdef ARDUINO_ARCH_ESP8266 +#include + +// this template method class is used to track the data being sent on the uart +// when using the default serial ISR installed by the core +// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes +// +class NeoEsp8266UartContext +{ +public: + // Gets the number of bytes waiting in the TX FIFO + static inline uint8_t ICACHE_RAM_ATTR GetTxFifoLength(uint8_t uartNum) + { + return (USS(uartNum) >> USTXC) & 0xff; + } + // Append a byte to the TX FIFO + static inline void ICACHE_RAM_ATTR Enqueue(uint8_t uartNum, uint8_t value) + { + USF(uartNum) = value; + } + + static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum, + const volatile uint8_t* start, + const volatile uint8_t* end); +}; + +// this template method class is used to track the data being sent on the uart +// when using our own UART ISR +// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes +// +class NeoEsp8266UartInterruptContext : NeoEsp8266UartContext +{ +public: + NeoEsp8266UartInterruptContext() : + _asyncBuff(nullptr), + _asyncBuffEnd(nullptr) + { + } + + bool IsSending() + { + return (_asyncBuff != _asyncBuffEnd); + } + + void StartSending(uint8_t uartNum, uint8_t* start, uint8_t* end); + void Attach(uint8_t uartNum); + void Detach(uint8_t uartNum); + +private: + volatile const uint8_t* _asyncBuff; + volatile const uint8_t* _asyncBuffEnd; + volatile static NeoEsp8266UartInterruptContext* s_uartInteruptContext[2]; + + static void ICACHE_RAM_ATTR Isr(void* param); +}; + +// this template feature class is used a base for all others and contains +// common methods +// +class UartFeatureBase +{ +protected: + static void ConfigUart(uint8_t uartNum, bool invert) + { + // clear all invert bits + USC0(uartNum) &= ~((1 << UCDTRI) | (1 << UCRTSI) | (1 << UCTXI) | (1 << UCDSRI) | (1 << UCCTSI) | (1 << UCRXI)); + + if (!invert) + { + // For normal operations, + // Invert the TX voltage associated with logic level so: + // - A logic level 0 will generate a Vcc signal + // - A logic level 1 will generate a Gnd signal + USC0(uartNum) |= (1 << UCTXI); + } + } +}; + +// this template feature class is used to define the specifics for uart0 +// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes +// +class UartFeature0 : UartFeatureBase +{ +public: + static const uint32_t Index = 0; + static void Init(uint32_t baud, bool invert) + { + // Configure the serial line with 1 start bit (0), 6 data bits and 1 stop bit (1) + Serial.begin(baud, SERIAL_6N1, SERIAL_TX_ONLY); + ConfigUart(Index, invert); + } +}; + +// this template feature class is used to define the specifics for uart1 +// used with NeoEsp8266Uart and NeoEsp8266AsyncUart classes +// +class UartFeature1 : UartFeatureBase +{ +public: + static const uint32_t Index = 1; + static void Init(uint32_t baud, bool invert) + { + // Configure the serial line with 1 start bit (0), 6 data bits and 1 stop bit (1) + Serial1.begin(baud, SERIAL_6N1, SERIAL_TX_ONLY); + ConfigUart(Index, invert); + } +}; + +// this template method class is used a base for all others and contains +// common properties and methods +// +// used by NeoEsp8266Uart and NeoEsp8266AsyncUart +// +class NeoEsp8266UartBase +{ +protected: + const size_t _sizeData; // Size of '_data' buffer below + uint8_t* _data; // Holds LED color values + uint32_t _startTime; // Microsecond count when last update started + + NeoEsp8266UartBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize) + { + _data = static_cast(malloc(_sizeData)); + memset(_data, 0x00, _sizeData); + } + + ~NeoEsp8266UartBase() + { + free(_data); + } + +}; + +// this template method class is used to glue uart feature and context for +// synchronous uart method +// +// used by NeoEsp8266UartMethodBase +// +template class NeoEsp8266Uart : public NeoEsp8266UartBase +{ +protected: + NeoEsp8266Uart(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + NeoEsp8266UartBase(pixelCount, elementSize, settingsSize) + { + } + + ~NeoEsp8266Uart() + { + // Wait until the TX fifo is empty. This way we avoid broken frames + // when destroying & creating a NeoPixelBus to change its length. + while (T_UARTCONTEXT::GetTxFifoLength(T_UARTFEATURE::Index) > 0) + { + yield(); + } + } + + void InitializeUart(uint32_t uartBaud, bool invert) + { + T_UARTFEATURE::Init(uartBaud, invert); + } + + void UpdateUart(bool) + { + // Since the UART can finish sending queued bytes in the FIFO in + // the background, instead of waiting for the FIFO to flush + // we annotate the start time of the frame so we can calculate + // when it will finish. + _startTime = micros(); + + // Then keep filling the FIFO until done + const uint8_t* ptr = _data; + const uint8_t* end = ptr + _sizeData; + while (ptr != end) + { + ptr = const_cast(T_UARTCONTEXT::FillUartFifo(T_UARTFEATURE::Index, ptr, end)); + } + } +}; + +// this template method class is used to glue uart feature and context for +// asynchronously uart method +// +// This UART controller uses two buffers that are swapped in every call to +// NeoPixelBus.Show(). One buffer contains the data that is being sent +// asynchronosly and another buffer contains the data that will be send +// in the next call to NeoPixelBus.Show(). +// +// Therefore, the result of NeoPixelBus.Pixels() is invalidated after +// every call to NeoPixelBus.Show() and must not be cached. +// +// used by NeoEsp8266UartMethodBase +// +template class NeoEsp8266AsyncUart : public NeoEsp8266UartBase +{ +protected: + NeoEsp8266AsyncUart(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + NeoEsp8266UartBase(pixelCount, elementSize, settingsSize) + { + _dataSending = static_cast(malloc(_sizeData)); + } + + ~NeoEsp8266AsyncUart() + { + // Remember: the UART interrupt can be sending data from _dataSending in the background + while (_context.IsSending()) + { + yield(); + } + // detach context, which will disable intr, may disable ISR + _context.Detach(T_UARTFEATURE::Index); + + free(_dataSending); + } + + void ICACHE_RAM_ATTR InitializeUart(uint32_t uartBaud, bool invert) + { + T_UARTFEATURE::Init(uartBaud, invert); + + // attach the context, which will enable the ISR + _context.Attach(T_UARTFEATURE::Index); + } + + void UpdateUart(bool maintainBufferConsistency) + { + // Instruct ESP8266 hardware uart to send the pixels asynchronously + _context.StartSending(T_UARTFEATURE::Index, + _data, + _data + _sizeData); + + // Annotate when we started to send bytes, so we can calculate when we are ready to send again + _startTime = micros(); + + if (maintainBufferConsistency) + { + // copy editing to sending, + // this maintains the contract that "colors present before will + // be the same after", otherwise GetPixelColor will be inconsistent + memcpy(_dataSending, _data, _sizeData); + } + + // swap so the user can modify without affecting the async operation + std::swap(_dataSending, _data); + } + +private: + T_UARTCONTEXT _context; + + uint8_t* _dataSending; // Holds a copy of LED color values taken when UpdateUart began +}; + +class NeoEsp8266UartSpeed800KbpsBase +{ +public: + static const uint32_t ByteSendTimeUs = 10; // us it takes to send a single pixel element at 800khz speed + static const uint32_t UartBaud = 3200000; // 800mhz, 4 serial bytes per NeoByte +}; + +// NeoEsp8266UartSpeedWs2813 contains the timing constants used to get NeoPixelBus running with the Ws2813 +class NeoEsp8266UartSpeedWs2812x : public NeoEsp8266UartSpeed800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 300; // us between data send bursts to reset for next update +}; + +class NeoEsp8266UartSpeedSk6812 : public NeoEsp8266UartSpeed800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 80; // us between data send bursts to reset for next update +}; + +class NeoEsp8266UartSpeedTm1814 : public NeoEsp8266UartSpeed800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 200; // us between data send bursts to reset for next update +}; + +// NeoEsp8266UartSpeed800Kbps contains the timing constant used to get NeoPixelBus running at 800Khz +class NeoEsp8266UartSpeed800Kbps : public NeoEsp8266UartSpeed800KbpsBase +{ +public: + static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update +}; + +// NeoEsp8266UartSpeed400Kbps contains the timing constant used to get NeoPixelBus running at 400Khz +class NeoEsp8266UartSpeed400Kbps +{ +public: + static const uint32_t ByteSendTimeUs = 20; // us it takes to send a single pixel element at 400khz speed + static const uint32_t UartBaud = 1600000; // 400mhz, 4 serial bytes per NeoByte + static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update +}; + +// NeoEsp8266UartSpeedApa106 contains the timing constant used to get NeoPixelBus running for Apa106 +// Pulse cycle = 1.71 = 1.368 longer than normal, 0.731 slower, NeoEsp8266UartSpeedApa1066 +class NeoEsp8266UartSpeedApa106 +{ +public: + static const uint32_t ByteSendTimeUs = 14; // us it takes to send a single pixel element at 400khz speed + static const uint32_t UartBaud = 2339181; // APA106 pulse cycle of 1.71us, 4 serial bytes per NeoByte + static const uint32_t ResetTimeUs = 50; // us between data send bursts to reset for next update +}; + +class NeoEsp8266UartNotInverted +{ +public: + const static bool Inverted = false; +}; + +class NeoEsp8266UartInverted +{ +public: + const static bool Inverted = true; +}; + +// NeoEsp8266UartMethodBase is a light shell arround NeoEsp8266Uart or NeoEsp8266AsyncUart that +// implements the methods needed to operate as a NeoPixelBus method. +template +class NeoEsp8266UartMethodBase: public T_BASE +{ +public: + NeoEsp8266UartMethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) + : T_BASE(pixelCount, elementSize, settingsSize) + { + } + NeoEsp8266UartMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) + : T_BASE(pixelCount, elementSize, settingsSize) + { + } + + bool IsReadyToUpdate() const + { + uint32_t delta = micros() - this->_startTime; + return delta >= getPixelTime() + T_SPEED::ResetTimeUs; + } + + void Initialize() + { + this->InitializeUart(T_SPEED::UartBaud, T_INVERT::Inverted); + + // Inverting logic levels can generate a phantom bit in the led strip bus + // We need to delay 50+ microseconds the output stream to force a data + // latch and discard this bit. Otherwise, that bit would be prepended to + // the first frame corrupting it. + this->_startTime = micros() - getPixelTime(); + } + + void Update(bool maintainBufferConsistency) + { + // Data latch = 50+ microsecond pause in the output stream. Rather than + // put a delay at the end of the function, the ending time is noted and + // the function will simply hold off (if needed) on issuing the + // subsequent round of data until the latch time has elapsed. This + // allows the mainline code to start generating the next frame of data + // rather than stalling for the latch. + while (!this->IsReadyToUpdate()) + { + yield(); + } + this->UpdateUart(maintainBufferConsistency); + } + + uint8_t* getData() const + { + return this->_data; + }; + + size_t getDataSize() const + { + return this->_sizeData; + }; + +private: + uint32_t getPixelTime() const + { + return (T_SPEED::ByteSendTimeUs * this->_sizeData); + }; +}; + +// uart 0 +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0Ws2812xMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0Sk6812Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0Tm1814Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0Apa106Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0800KbpsMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0400KbpsMethod; + +typedef NeoEsp8266Uart0Ws2812xMethod NeoEsp8266Uart0Ws2813Method; +typedef NeoEsp8266Uart0800KbpsMethod NeoEsp8266Uart0Ws2812Method; +typedef NeoEsp8266Uart0Ws2812xMethod NeoEsp8266Uart0Ws2811Method; +typedef NeoEsp8266Uart0Sk6812Method NeoEsp8266Uart0Lc8812Method; + +// uart 1 +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1Ws2812xMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1Sk6812Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1Tm1814Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1Apa106Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1800KbpsMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1400KbpsMethod; + +typedef NeoEsp8266Uart1Ws2812xMethod NeoEsp8266Uart1Ws2813Method; +typedef NeoEsp8266Uart1800KbpsMethod NeoEsp8266Uart1Ws2812Method; +typedef NeoEsp8266Uart1Ws2812xMethod NeoEsp8266Uart1Ws2811Method; +typedef NeoEsp8266Uart1Sk6812Method NeoEsp8266Uart1Lc8812Method; + +// uart 0 async +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0Ws2812xMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0Sk6812Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0Tm1814Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0Apa106Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0800KbpsMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0400KbpsMethod; + +typedef NeoEsp8266AsyncUart0Ws2812xMethod NeoEsp8266AsyncUart0Ws2813Method; +typedef NeoEsp8266AsyncUart0800KbpsMethod NeoEsp8266AsyncUart0Ws2812Method; +typedef NeoEsp8266AsyncUart0Ws2812xMethod NeoEsp8266AsyncUart0Ws2811Method; +typedef NeoEsp8266AsyncUart0Sk6812Method NeoEsp8266AsyncUart0Lc8812Method; + +// uart 1 async +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1Ws2812xMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1Sk6812Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1Tm1814Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1Apa106Method; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1800KbpsMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1400KbpsMethod; + +typedef NeoEsp8266AsyncUart1Ws2812xMethod NeoEsp8266AsyncUart1Ws2813Method; +typedef NeoEsp8266AsyncUart1800KbpsMethod NeoEsp8266AsyncUart1Ws2812Method; +typedef NeoEsp8266AsyncUart1Ws2812xMethod NeoEsp8266AsyncUart1Ws2811Method; +typedef NeoEsp8266AsyncUart1Sk6812Method NeoEsp8266AsyncUart1Lc8812Method; + +// inverted +// +// uart 0 +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0Ws2812xInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0Sk6812InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart0Tm1814InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0Apa106InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0800KbpsInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart0400KbpsInvertedMethod; + +typedef NeoEsp8266Uart0Ws2812xInvertedMethod NeoEsp8266Uart0Ws2813InvertedMethod; +typedef NeoEsp8266Uart0800KbpsInvertedMethod NeoEsp8266Uart0Ws2812InvertedMethod; +typedef NeoEsp8266Uart0Ws2812xInvertedMethod NeoEsp8266Uart0Ws2811InvertedMethod; +typedef NeoEsp8266Uart0Sk6812InvertedMethod NeoEsp8266Uart0Lc8812InvertedMethod; + +// uart 1 +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1Ws2812xInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1Sk6812InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266Uart1Tm1814InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1Apa106InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1800KbpsInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266Uart1400KbpsInvertedMethod; + +typedef NeoEsp8266Uart1Ws2812xInvertedMethod NeoEsp8266Uart1Ws2813InvertedMethod; +typedef NeoEsp8266Uart1800KbpsInvertedMethod NeoEsp8266Uart1Ws2812InvertedMethod; +typedef NeoEsp8266Uart1Ws2812xInvertedMethod NeoEsp8266Uart1Ws2811InvertedMethod; +typedef NeoEsp8266Uart1Sk6812InvertedMethod NeoEsp8266Uart1Lc8812InvertedMethod; + +// uart 0 async +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0Ws2812xInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0Sk6812InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart0Tm1814InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0Apa106InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0800KbpsInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart0400KbpsInvertedMethod; + +typedef NeoEsp8266AsyncUart0Ws2812xInvertedMethod NeoEsp8266AsyncUart0Ws2813InvertedMethod; +typedef NeoEsp8266AsyncUart0800KbpsInvertedMethod NeoEsp8266AsyncUart0Ws2812InvertedMethod; +typedef NeoEsp8266AsyncUart0Ws2812xInvertedMethod NeoEsp8266AsyncUart0Ws2811InvertedMethod; +typedef NeoEsp8266AsyncUart0Sk6812InvertedMethod NeoEsp8266AsyncUart0Lc8812InvertedMethod; + +// uart 1 async +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1Ws2812xInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1Sk6812InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartNotInverted> NeoEsp8266AsyncUart1Tm1814InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1Apa106InvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1800KbpsInvertedMethod; +typedef NeoEsp8266UartMethodBase, NeoEsp8266UartInverted> NeoEsp8266AsyncUart1400KbpsInvertedMethod; + +typedef NeoEsp8266AsyncUart1Ws2812xInvertedMethod NeoEsp8266AsyncUart1Ws2813InvertedMethod; +typedef NeoEsp8266AsyncUart1800KbpsInvertedMethod NeoEsp8266AsyncUart1Ws2812InvertedMethod; +typedef NeoEsp8266AsyncUart1Ws2812xInvertedMethod NeoEsp8266AsyncUart1Ws2811InvertedMethod; +typedef NeoEsp8266AsyncUart1Sk6812InvertedMethod NeoEsp8266AsyncUart1Lc8812InvertedMethod; +#endif + diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoEspBitBangMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoEspBitBangMethod.h new file mode 100644 index 000000000..506adb70e --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoEspBitBangMethod.h @@ -0,0 +1,401 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for Esp8266 and Esp32 + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) + +#if defined(ARDUINO_ARCH_ESP8266) +#include +#endif + +// ESP32 doesn't define ICACHE_RAM_ATTR +#ifndef ICACHE_RAM_ATTR +#define ICACHE_RAM_ATTR IRAM_ATTR +#endif + +#define CYCLES_LOOPTEST (4) // adjustment due to loop exit test instruction cycles + +class NeoEspSpeedWs2811 +{ +public: + const static uint32_t T0H = (F_CPU / 3333333 - CYCLES_LOOPTEST); // 0.3us + const static uint32_t T1H = (F_CPU / 1052632 - CYCLES_LOOPTEST); // 0.95us + const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST); // 1.25us per bit +}; + +class NeoEspSpeedTm1814 +{ +public: + const static uint32_t T0H = (F_CPU / 2916666 - CYCLES_LOOPTEST); // 0.35us + const static uint32_t T1H = (F_CPU / 1666666 - CYCLES_LOOPTEST); // 0.75us + const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST); // 1.25us per bit +}; + +class NeoEspSpeed800Mhz +{ +public: + const static uint32_t T0H = (F_CPU / 2500000 - CYCLES_LOOPTEST); // 0.4us + const static uint32_t T1H = (F_CPU / 1250000 - CYCLES_LOOPTEST); // 0.8us + const static uint32_t Period = (F_CPU / 800000 - CYCLES_LOOPTEST); // 1.25us per bit +}; + +class NeoEspSpeed400Mhz +{ +public: + const static uint32_t T0H = (F_CPU / 2000000 - CYCLES_LOOPTEST); + const static uint32_t T1H = (F_CPU / 833333 - CYCLES_LOOPTEST); + const static uint32_t Period = (F_CPU / 400000 - CYCLES_LOOPTEST); +}; + +class NeoEspPinset +{ +public: + const static uint8_t IdleLevel = LOW; + + inline static void setPin(const uint32_t pinRegister) + { +#if defined(ARDUINO_ARCH_ESP32) + GPIO.out_w1ts = pinRegister; +#else + GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); +#endif + } + + inline static void resetPin(const uint32_t pinRegister) + { +#if defined(ARDUINO_ARCH_ESP32) + GPIO.out_w1tc = pinRegister; +#else + GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); +#endif + } +}; + +class NeoEspPinsetInverted +{ +public: + const static uint8_t IdleLevel = HIGH; + + inline static void setPin(const uint32_t pinRegister) + { +#if defined(ARDUINO_ARCH_ESP32) + GPIO.out_w1tc = pinRegister; +#else + GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister); +#endif + } + + inline static void resetPin(const uint32_t pinRegister) + { +#if defined(ARDUINO_ARCH_ESP32) + GPIO.out_w1ts = pinRegister; +#else + GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinRegister); +#endif + } +}; + +template class NeoEspBitBangBase +{ +public: + __attribute__((noinline)) static void ICACHE_RAM_ATTR send_pixels(uint8_t* pixels, uint8_t* end, uint8_t pin) + { + const uint32_t pinRegister = _BV(pin); + uint8_t mask = 0x80; + uint8_t subpix = *pixels++; + uint32_t cyclesStart = 0; // trigger emediately + uint32_t cyclesNext = 0; + + for (;;) + { + // do the checks here while we are waiting on time to pass + uint32_t cyclesBit = T_SPEED::T0H; + if (subpix & mask) + { + cyclesBit = T_SPEED::T1H; + } + + // after we have done as much work as needed for this next bit + // now wait for the HIGH + while (((cyclesStart = getCycleCount()) - cyclesNext) < T_SPEED::Period); + + // set pin state + T_PINSET::setPin(pinRegister); + + // wait for the LOW + while ((getCycleCount() - cyclesStart) < cyclesBit); + + // reset pin start + T_PINSET::resetPin(pinRegister); + + cyclesNext = cyclesStart; + + // next bit + mask >>= 1; + if (mask == 0) + { + // no more bits to send in this byte + // check for another byte + if (pixels >= end) + { + // no more bytes to send so stop + break; + } + // reset mask to first bit and get the next byte + mask = 0x80; + subpix = *pixels++; + } + } + } + +protected: + static inline uint32_t getCycleCount(void) + { + uint32_t ccount; + __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); + return ccount; + } +}; + +class NeoEspBitBangSpeedWs2811 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 300; +}; + +class NeoEspBitBangSpeedWs2812x : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 300; +}; + +class NeoEspBitBangSpeedSk6812 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 80; +}; + +// normal is inverted signal +class NeoEspBitBangSpeedTm1814 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + +class NeoEspBitBangSpeed800Kbps : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 50; +}; + +class NeoEspBitBangSpeed400Kbps : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 50; +}; + + +class NeoEspBitBangInvertedSpeedWs2811 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 300; +}; + +class NeoEspBitBangInvertedSpeedWs2812x : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 300; +}; + +class NeoEspBitBangInvertedSpeedSk6812 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 80; +}; + +// normal is inverted signal, so inverted is normal +class NeoEspBitBangInvertedSpeedTm1814 : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 200; +}; + +class NeoEspBitBangInvertedSpeed800Kbps : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 50; +}; + +class NeoEspBitBangInvertedSpeed400Kbps : public NeoEspBitBangBase +{ +public: + static const uint32_t ResetTimeUs = 50; +}; + +template class NeoEspBitBangMethodBase +{ +public: + NeoEspBitBangMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _pin(pin) + { + pinMode(pin, OUTPUT); + + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + } + + ~NeoEspBitBangMethodBase() + { + pinMode(_pin, INPUT); + + free(_data); + } + + bool IsReadyToUpdate() const + { + uint32_t delta = micros() - _endTime; + + return (delta >= T_SPEED::ResetTimeUs); + } + + void Initialize() + { + digitalWrite(_pin, T_PINSET::IdleLevel); + + _endTime = micros(); + } + + void Update(bool) + { + // Data latch = 50+ microsecond pause in the output stream. Rather than + // put a delay at the end of the function, the ending time is noted and + // the function will simply hold off (if needed) on issuing the + // subsequent round of data until the latch time has elapsed. This + // allows the mainline code to start generating the next frame of data + // rather than stalling for the latch. + while (!IsReadyToUpdate()) + { + yield(); // allows for system yield if needed + } + + // Need 100% focus on instruction timing +#if defined(ARDUINO_ARCH_ESP32) + delay(1); // required + portMUX_TYPE updateMux = portMUX_INITIALIZER_UNLOCKED; + + portENTER_CRITICAL(&updateMux); +#else + noInterrupts(); +#endif + + T_SPEED::send_pixels(_data, _data + _sizeData, _pin); + +#if defined(ARDUINO_ARCH_ESP32) + portEXIT_CRITICAL(&updateMux); +#else + interrupts(); +#endif + + // save EOD time for latch on next call + _endTime = micros(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + const uint8_t _pin; // output pin number + + uint32_t _endTime; // Latch timing reference + uint8_t* _data; // Holds LED color values +}; + + +#if defined(ARDUINO_ARCH_ESP32) + +typedef NeoEspBitBangMethodBase NeoEsp32BitBangWs2811Method; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangWs2812xMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangSk6812Method; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangTm1814Method; +typedef NeoEspBitBangMethodBase NeoEsp32BitBang800KbpsMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBang400KbpsMethod; + +typedef NeoEsp32BitBangWs2812xMethod NeoEsp32BitBangWs2813Method; +typedef NeoEsp32BitBang800KbpsMethod NeoEsp32BitBangWs2812Method; +typedef NeoEsp32BitBangSk6812Method NeoEsp32BitBangLc8812Method; +typedef NeoEsp32BitBang400KbpsMethod NeoEsp32BitBangApa106Method; + +typedef NeoEspBitBangMethodBase NeoEsp32BitBangWs2811InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangWs2812xInvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangSk6812InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBangTm1814InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBang800KbpsInvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp32BitBang400KbpsInvertedMethod; + +typedef NeoEsp32BitBangWs2812xInvertedMethod NeoEsp32BitBangWs2813InvertedMethod; +typedef NeoEsp32BitBang800KbpsInvertedMethod NeoEsp32BitBangWs2812InvertedMethod; +typedef NeoEsp32BitBangSk6812InvertedMethod NeoEsp32BitBangLc8812InvertedMethod; +typedef NeoEsp32BitBang400KbpsInvertedMethod NeoEsp32BitBangApa106InvertedMethod; + +#else + +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2811Method; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2812xMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangSk6812Method; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangTm1814Method; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBang800KbpsMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBang400KbpsMethod; + +typedef NeoEsp8266BitBangWs2812xMethod NeoEsp8266BitBangWs2813Method; +typedef NeoEsp8266BitBang800KbpsMethod NeoEsp8266BitBangWs2812Method; +typedef NeoEsp8266BitBangSk6812Method NeoEsp8266BitBangLc8812Method; +typedef NeoEsp8266BitBang400KbpsMethod NeoEsp8266BitBangApa106Method; + +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2811InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangWs2812xInvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangSk6812InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBangTm1814InvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBang800KbpsInvertedMethod; +typedef NeoEspBitBangMethodBase NeoEsp8266BitBang400KbpsInvertedMethod; + +typedef NeoEsp8266BitBangWs2812xInvertedMethod NeoEsp8266BitBangWs2813InvertedMethod; +typedef NeoEsp8266BitBang800KbpsInvertedMethod NeoEsp8266BitBangWs2812InvertedMethod; +typedef NeoEsp8266BitBangSk6812InvertedMethod NeoEsp8266BitBangLc8812InvertedMethod; +typedef NeoEsp8266BitBang400KbpsInvertedMethod NeoEsp8266BitBangApa106InvertedMethod; +#endif + +// ESP bitbang doesn't have defaults and should avoided except for testing +#endif \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoGamma.cpp b/lib/NeoPixelBus-2.6.0/src/internal/NeoGamma.cpp similarity index 96% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoGamma.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/NeoGamma.cpp index f33cbfbd9..fdff9e784 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoGamma.cpp +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoGamma.cpp @@ -25,10 +25,7 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #include -#include "RgbColor.h" -#include "RgbwColor.h" -#include "NeoEase.h" -#include "NeoGamma.h" +#include "NeoPixelBus.h" const uint8_t NeoGammaTableMethod::_table[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoGamma.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoGamma.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoGamma.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoGamma.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoHueBlend.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoHueBlend.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoHueBlend.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoHueBlend.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoMosaic.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoMosaic.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoMosaic.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoMosaic.h diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoNrf52xMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoNrf52xMethod.h new file mode 100644 index 000000000..b8810ea38 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoNrf52xMethod.h @@ -0,0 +1,490 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper classes for Nrf52* MCUs. +Nano 33 BLE + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. +The contents of this file were taken from the Adafruit NeoPixel library +and modified only to fit within individual calling functions. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#if defined(ARDUINO_ARCH_NRF52840) + +const uint16_t c_dmaBytesPerDataByte = 8 * sizeof(nrf_pwm_values_common_t); // bits * bytes to represent pulse + +// for Bit* variables +// count 1 = 0.0625us, so max count (32768) is 2048us + +class NeoNrf52xPwmSpeedWs2811 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 5 | 0x8000; // ~0.3us + const static nrf_pwm_values_common_t Bit1 = 14 | 0x8000; // ~0.9us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint16_t CountReset = 240; // 300 us / 1.25us + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmSpeedWs2812x +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6 | 0x8000; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13 | 0x8000; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint32_t CountReset = 240 ; // 300us / 1.25us pulse width + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmSpeedSk6812 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6 | 0x8000; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13 | 0x8000; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint32_t CountReset = 64; // 80us / 1.25us pulse width + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmSpeedTm1814 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 5; // ~0.3us + const static nrf_pwm_values_common_t Bit1 = 12; // ~0.7us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint32_t CountReset = 160; // 200us / 1.25us pulse width + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmSpeed800Kbps +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6 | 0x8000; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13 | 0x8000; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint32_t CountReset = 40; // 50us / 1.25us pulse width + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmSpeed400Kbps +{ +public: + const static uint32_t CountTop = 40UL; // 2.5us + const static nrf_pwm_values_common_t Bit0 = 13 | 0x8000; // ~0.8us + const static nrf_pwm_values_common_t Bit1 = 26 | 0x8000; // ~1.6us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint16_t CountReset = 20; // 50 us / 2.5us + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmSpeedApa106 +{ +public: + const static uint32_t CountTop = 26UL; // 1.65us + const static nrf_pwm_values_common_t Bit0 = 6 | 0x8000; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 20 | 0x8000; // ~1.25us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint32_t CountReset = 40; // 50us / 1.25us pulse width + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmInvertedSpeedWs2811 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 5; // ~0.3us + const static nrf_pwm_values_common_t Bit1 = 14; // ~0.9us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint16_t CountReset = 240; // 300 us / 1.25us + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmInvertedSpeedWs2812x +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint32_t CountReset = 240; // 300us / 1.25us pulse width + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmInvertedSpeedSk6812 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint32_t CountReset = 64; // 80us / 1.25us pulse width + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmInvertedSpeedTm1814 +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 5 | 0x8000; // ~0.3us + const static nrf_pwm_values_common_t Bit1 = 12 | 0x8000; // ~0.7us + const static nrf_pwm_values_common_t BitReset = 0x8000; // LOW + const static uint32_t CountReset = 160; // 200us / 1.25us pulse width + const static PinStatus IdleLevel = LOW; +}; + +class NeoNrf52xPwmInvertedSpeed800Kbps +{ +public: + const static uint32_t CountTop = 20UL; // 1.25us + const static nrf_pwm_values_common_t Bit0 = 6; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 13; // ~0.8us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint32_t CountReset = 40; // 50us / 1.25us pulse width + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmInvertedSpeed400Kbps +{ +public: + const static uint32_t CountTop = 40UL; // 2.5us + const static nrf_pwm_values_common_t Bit0 = 13; // ~0.8us + const static nrf_pwm_values_common_t Bit1 = 26; // ~1.6us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint16_t CountReset = 20; // 50 us / 2.5us + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwmInvertedSpeedApa106 +{ +public: + const static uint32_t CountTop = 26UL; // 1.65us + const static nrf_pwm_values_common_t Bit0 = 6; // ~0.4us + const static nrf_pwm_values_common_t Bit1 = 20; // ~1.25us + const static nrf_pwm_values_common_t BitReset = 0x0000; // HIGH + const static uint32_t CountReset = 40; // 50us / 1.25us pulse width + const static PinStatus IdleLevel = HIGH; +}; + +class NeoNrf52xPwm0 +{ +public: + inline static NRF_PWM_Type* Pwm() + { + return NRF_PWM0; + } +}; + +class NeoNrf52xPwm1 +{ +public: + inline static NRF_PWM_Type* Pwm() + { + return NRF_PWM1; + } +}; + +class NeoNrf52xPwm2 +{ +public: + inline static NRF_PWM_Type* Pwm() + { + return NRF_PWM2; + } +}; + +#if defined(NRF_PWM3) +class NeoNrf52xPwm3 +{ +public: + inline static NRF_PWM_Type* Pwm() + { + return NRF_PWM3; + } +}; +#endif + +template class NeoNrf52xMethodBase +{ +public: + NeoNrf52xMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _pin(pin) + { + pinMode(pin, OUTPUT); + + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + + _dmaBufferSize = c_dmaBytesPerDataByte * _sizeData + sizeof(nrf_pwm_values_common_t); + _dmaBuffer = static_cast(malloc(_dmaBufferSize)); + } + + ~NeoNrf52xMethodBase() + { + while (!IsReadyToUpdate()) + { + yield(); + } + + dmaDeinit(); + + pinMode(_pin, INPUT); + + free(_data); + free(_dmaBuffer); + } + + bool IsReadyToUpdate() const + { + return (T_BUS::Pwm()->EVENTS_STOPPED); + } + + void Initialize() + { + digitalWrite(_pin, T_SPEED::IdleLevel); + + dmaInit(); + + // must force a first update so the EVENTS_SEQEND gets set as + // you can't set it manually + FillBuffer(); + dmaStart(); + } + + void Update(bool) + { + // Data latch = 50+ microsecond pause in the output stream. Rather than + // put a delay at the end of the function, the ending time is noted and + // the function will simply hold off (if needed) on issuing the + // subsequent round of data until the latch time has elapsed. This + // allows the mainline code to start generating the next frame of data + // rather than stalling for the latch. + while (!IsReadyToUpdate()) + { + yield(); // allows for system yield if needed + } + + FillBuffer(); + dmaStart(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + const uint8_t _pin; // output pin number + + uint8_t* _data; // Holds LED color values + size_t _dmaBufferSize; // total size of _dmaBuffer + nrf_pwm_values_common_t* _dmaBuffer; // Holds pixel data in native format for PWM hardware + + void dmaInit() + { + // only use channel zero + T_BUS::Pwm()->PSEL.OUT[0] = digitalPinToPinName(_pin); + T_BUS::Pwm()->PSEL.OUT[1] = NC; + T_BUS::Pwm()->PSEL.OUT[2] = NC; + T_BUS::Pwm()->PSEL.OUT[3] = NC; + + T_BUS::Pwm()->ENABLE = 1; + T_BUS::Pwm()->MODE = NRF_PWM_MODE_UP; + T_BUS::Pwm()->PRESCALER = NRF_PWM_CLK_16MHz; + T_BUS::Pwm()->COUNTERTOP = T_SPEED::CountTop; + T_BUS::Pwm()->LOOP = 1; // single fire so events get set + T_BUS::Pwm()->DECODER = NRF_PWM_LOAD_COMMON; + + // sequence zero is the primary data with a BitReset entry on the end for + // the delay repeating + T_BUS::Pwm()->SEQ[0].PTR = reinterpret_cast(_dmaBuffer); + T_BUS::Pwm()->SEQ[0].CNT = _dmaBufferSize / sizeof(nrf_pwm_values_common_t); + T_BUS::Pwm()->SEQ[0].REFRESH = 0; // ignored + T_BUS::Pwm()->SEQ[0].ENDDELAY = T_SPEED::CountReset; // ignored still? + + // sequence one is pointing to the BitReset entry at the end of the primary data + T_BUS::Pwm()->SEQ[1].PTR = reinterpret_cast(_dmaBuffer + (T_BUS::Pwm()->SEQ[0].CNT - 1)); + T_BUS::Pwm()->SEQ[1].CNT = 1; + T_BUS::Pwm()->SEQ[1].REFRESH = 0; // ignored + T_BUS::Pwm()->SEQ[1].ENDDELAY = 0; // ignored + + // stop when the loop finishes + T_BUS::Pwm()->SHORTS = PWM_SHORTS_LOOPSDONE_STOP_Msk; + T_BUS::Pwm()->INTEN = 0; + + dmaResetEvents(); + } + + void dmaDeinit() + { + T_BUS::Pwm()->ENABLE = 0; + T_BUS::Pwm()->PSEL.OUT[0] = NC; + } + + void FillBuffer() + { + nrf_pwm_values_common_t* pDma = _dmaBuffer; + nrf_pwm_values_common_t* pDmaEnd = _dmaBuffer + (_dmaBufferSize / sizeof(nrf_pwm_values_common_t)); + uint8_t* pEnd = _data + _sizeData; + + for (uint8_t* pData = _data; pData < pEnd; pData++) + { + uint8_t data = *pData; + + for (uint8_t bit = 0; bit < 8; bit++) + { + *(pDma++) = (data & 0x80) ? T_SPEED::Bit1 : T_SPEED::Bit0; + data <<= 1; + } + } + + // fill the rest with BitReset as it will get repeated when delaying or + // at the end before being stopped + while (pDma < pDmaEnd) + { + *(pDma++) = T_SPEED::BitReset; + } + } + + void dmaResetEvents() + { + T_BUS::Pwm()->EVENTS_LOOPSDONE = 0; + T_BUS::Pwm()->EVENTS_SEQEND[0] = 0; + T_BUS::Pwm()->EVENTS_SEQEND[1] = 0; + T_BUS::Pwm()->EVENTS_STOPPED = 0; + } + + void dmaStart() + { + dmaResetEvents(); + T_BUS::Pwm()->TASKS_SEQSTART[0] = 1; + } +}; + +// normal +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Ws2811Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Ws2812xMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Sk6812Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Tm1814Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Apa106Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0800KbpsMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0400KbpsMethod; + +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Ws2811Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Ws2812xMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Sk6812Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Tm1814Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Apa106Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1800KbpsMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1400KbpsMethod; + +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Ws2811Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Ws2812xMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Sk6812Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Tm1814Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Apa106Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2800KbpsMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2400KbpsMethod; + +#if defined(NRF_PWM3) +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Ws2811Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Ws2812xMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Sk6812Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Tm1814Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Apa106Method; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3800KbpsMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3400KbpsMethod; +#endif + +// inverted +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Ws2811InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Ws2812xInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Sk6812InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Tm1814InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0Apa106InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0800KbpsInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm0400KbpsInvertedMethod; + +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Ws2811InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Ws2812xInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Sk6812InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Tm1814InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1Apa106InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1800KbpsInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm1400KbpsInvertedMethod; + +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Ws2811InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Ws2812xInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Sk6812InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Tm1814InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2Apa106InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2800KbpsInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm2400KbpsInvertedMethod; + +#if defined(NRF_PWM3) +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Ws2811InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Ws2812xInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Sk6812InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Tm1814InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3Apa106InvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3800KbpsInvertedMethod; +typedef NeoNrf52xMethodBase NeoNrf52xPwm3400KbpsInvertedMethod; +#endif + +// defaults +typedef NeoNrf52xPwm2Ws2812xMethod NeoWs2813Method; +typedef NeoNrf52xPwm2Ws2812xMethod NeoWs2812xMethod; +typedef NeoNrf52xPwm2800KbpsMethod NeoWs2812Method; +typedef NeoNrf52xPwm2Ws2812xMethod NeoWs2811Method; +typedef NeoNrf52xPwm2Sk6812Method NeoSk6812Method; +typedef NeoNrf52xPwm2Tm1814Method NeoTm1814Method; +typedef NeoNrf52xPwm2Sk6812Method NeoLc8812Method; +typedef NeoNrf52xPwm2Apa106Method NeoApa106Method; + +typedef NeoNrf52xPwm2Ws2812xMethod Neo800KbpsMethod; +typedef NeoNrf52xPwm2400KbpsMethod Neo400KbpsMethod; + +typedef NeoNrf52xPwm2Ws2812xInvertedMethod NeoWs2813InvertedMethod; +typedef NeoNrf52xPwm2Ws2812xInvertedMethod NeoWs2812xInvertedMethod; +typedef NeoNrf52xPwm2Ws2812xInvertedMethod NeoWs2811InvertedMethod; +typedef NeoNrf52xPwm2800KbpsInvertedMethod NeoWs2812InvertedMethod; +typedef NeoNrf52xPwm2Sk6812InvertedMethod NeoSk6812InvertedMethod; +typedef NeoNrf52xPwm2Tm1814InvertedMethod NeoTm1814InvertedMethod; +typedef NeoNrf52xPwm2Sk6812InvertedMethod NeoLc8812InvertedMethod; +typedef NeoNrf52xPwm2Apa106InvertedMethod NeoApa106InvertedMethod; + +typedef NeoNrf52xPwm2Ws2812xInvertedMethod Neo800KbpsInvertedMethod; +typedef NeoNrf52xPwm2400KbpsInvertedMethod Neo400KbpsInvertedMethod; + +#endif diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAnimator.cpp b/lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAnimator.cpp similarity index 99% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAnimator.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAnimator.cpp index d535316f6..55e74ae21 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAnimator.cpp +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAnimator.cpp @@ -24,6 +24,7 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ +#include "NeoPixelBus.h" #include "NeoPixelAnimator.h" NeoPixelAnimator::NeoPixelAnimator(uint16_t countAnimations, uint16_t timeScale) : diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAvr.c b/lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAvr.c similarity index 94% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAvr.c rename to lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAvr.c index 761fa7eb1..84e989388 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoPixelAvr.c +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoPixelAvr.c @@ -34,7 +34,7 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ // must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set -#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) +#if (defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)) && !defined(__arm__) #include @@ -55,10 +55,10 @@ License along with NeoPixel. If not, see #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) // 8Mhz CPU #ifdef PORTD // PORTD isn't present on ATtiny85, etc. -void send_pixels_8mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pinMask) +void send_data_8mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask) { - volatile size_t i = sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile size_t i = sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -180,10 +180,10 @@ void send_pixels_8mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pinM } #endif -void send_pixels_8mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pinMask) +void send_data_8mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask) { - volatile size_t i = sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile size_t i = sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -271,10 +271,10 @@ void send_pixels_8mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pinM [lo] "r" (lo)); } -void send_pixels_8mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) +void send_data_8mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { - volatile size_t i = sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile size_t i = sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -331,10 +331,10 @@ void send_pixels_8mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) // 12Mhz CPU #ifdef PORTD // PORTD isn't present on ATtiny85, etc. -void send_pixels_12mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pinMask) +void send_data_12mhz_800_PortD(uint8_t* data, size_t sizeData, uint8_t pinMask) { - volatile size_t i = sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile size_t i = sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -404,10 +404,10 @@ void send_pixels_12mhz_800_PortD(uint8_t* pixels, size_t sizePixels, uint8_t pin } #endif -void send_pixels_12mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pinMask) +void send_data_12mhz_800_PortB(uint8_t* data, size_t sizeData, uint8_t pinMask) { - volatile uint16_t i = (uint16_t)sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile uint16_t i = (uint16_t)sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -466,10 +466,10 @@ void send_pixels_12mhz_800_PortB(uint8_t* pixels, size_t sizePixels, uint8_t pin [lo] "r" (lo)); } -void send_pixels_12mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) +void send_data_12mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { - volatile uint16_t i = (uint16_t)sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile uint16_t i = (uint16_t)sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -522,10 +522,10 @@ void send_pixels_12mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) // 16Mhz CPU -void send_pixels_16mhz_800(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) +void send_data_16mhz_800(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { - volatile uint16_t i = (uint16_t)sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile uint16_t i = (uint16_t)sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low @@ -577,10 +577,10 @@ void send_pixels_16mhz_800(uint8_t* pixels, size_t sizePixels, volatile uint8_t* [lo] "r" (lo)); } -void send_pixels_16mhz_400(uint8_t* pixels, size_t sizePixels, volatile uint8_t* port, uint8_t pinMask) +void send_data_16mhz_400(uint8_t* data, size_t sizeData, volatile uint8_t* port, uint8_t pinMask) { - volatile size_t i = sizePixels; // Loop counter - volatile uint8_t* ptr = pixels; // Pointer to next byte + volatile size_t i = sizeData; // Loop counter + volatile uint8_t* ptr = data; // Pointer to next byte volatile uint8_t b = *ptr++; // Current byte value volatile uint8_t hi; // PORT w/output bit set high volatile uint8_t lo; // PORT w/output bit set low diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoRingTopology.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoRingTopology.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoRingTopology.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoRingTopology.h diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoSegmentFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoSegmentFeatures.h new file mode 100644 index 000000000..f0118f624 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoSegmentFeatures.h @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- +NeoSegmentFeatures provides feature classes to describe seven segment display +elements for NeoPixelBus template class + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class Neo9Elements +{ +public: + static const size_t PixelSize = 9; // three 3 element + + static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + + static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + for (uint8_t iElement = 0; iElement < PixelSize; iElement++) + { + *pPixelDest++ = pPixelSrc[iElement]; + } + } + } + + static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + *pPixelDest++ = *pPixelSrc++; + } + } + + static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + const uint8_t* pSrc = (const uint8_t*)pPixelSrc; + while (pPixelDest < pEnd) + { + *pPixelDest++ = pgm_read_byte(pSrc++); + } + } + + static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pDestBack = pPixelDest + (count * PixelSize); + const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); + while (pDestBack > pPixelDest) + { + *--pDestBack = *--pSrcBack; + } + } + + typedef SevenSegDigit ColorObject; +}; + +// Abcdefg byte order +class NeoAbcdefgSegmentFeature : public Neo9Elements +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.SegmentCount) ? PixelSize : color.SegmentCount; + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + *p++ = color.Segment[iSegment]; + } + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.SegmentCount) ? PixelSize : color.SegmentCount; + + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + color.Segment[iSegment] = *p++; + } + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.SegmentCount) ? PixelSize : color.SegmentCount; + + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + color.Segment[iSegment] = pgm_read_byte(p++); + } + + return color; + } + +}; + +typedef NeoAbcdefgSegmentFeature SevenSegmentFeature; // Abcdefg order is default \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoSettings.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoSettings.h new file mode 100644 index 000000000..1af9f82b1 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoSettings.h @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------- +NeoSettings provides settings classes to describe settings + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class NeoNoSettings +{ +}; + +class NeoRgbCurrentSettings +{ +public: + NeoRgbCurrentSettings(uint16_t red, uint16_t green, uint16_t blue) : + RedTenthMilliAmpere(red), + GreenTenthMilliAmpere(green), + BlueTenthMilliAmpere(blue) + { + } + + uint16_t RedTenthMilliAmpere; // in 1/10th ma + uint16_t GreenTenthMilliAmpere; // in 1/10th ma + uint16_t BlueTenthMilliAmpere; // in 1/10th ma +}; + +class NeoRgbwCurrentSettings +{ +public: + NeoRgbwCurrentSettings(uint16_t red, uint16_t green, uint16_t blue, uint16_t white) : + RedTenthMilliAmpere(red), + GreenTenthMilliAmpere(green), + BlueTenthMilliAmpere(blue), + WhiteCurrent(white) + { + } + + uint16_t RedTenthMilliAmpere; // in 1/10th ma + uint16_t GreenTenthMilliAmpere; // in 1/10th ma + uint16_t BlueTenthMilliAmpere; // in 1/10th ma + uint16_t WhiteCurrent; // in 1/10th ma +}; \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoSpriteSheet.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoSpriteSheet.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoSpriteSheet.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoSpriteSheet.h diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoTiles.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoTiles.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoTiles.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoTiles.h diff --git a/lib/NeoPixelBus-2.6.0/src/internal/NeoTm1814ColorFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoTm1814ColorFeatures.h new file mode 100644 index 000000000..bc5035f9f --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/NeoTm1814ColorFeatures.h @@ -0,0 +1,131 @@ +/*------------------------------------------------------------------------- +NeoTm1814ColorFeatures provides feature classes to describe color order and +color depth for NeoPixelBus template class specific to the TM1814 chip + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class NeoTm1814Settings : public NeoRgbwCurrentSettings +{ +public: + NeoTm1814Settings(uint16_t red, uint16_t green, uint16_t blue, uint16_t white) : + NeoRgbwCurrentSettings(red, green, blue, white) + { + } + + const static uint16_t MinCurrent = 65; + const static uint16_t MaxCurrent = 380; + + static uint16_t LimitCurrent(uint16_t value) + { + if (value < MinCurrent) + { + value = MinCurrent; + } + else if (value > MaxCurrent) + { + value = MaxCurrent; + } + return value; + } +}; + +class Neo4ElementsTm1814Settings : public Neo4Elements +{ +public: + typedef NeoTm1814Settings SettingsObject; + static const size_t SettingsSize = 8; + + static void applySettings(uint8_t* pData, const SettingsObject& settings) + { + uint8_t* pSet = pData; + + // C1 + *pSet++ = (SettingsObject::LimitCurrent(settings.WhiteCurrent) - SettingsObject::MinCurrent) / 5; + *pSet++ = (SettingsObject::LimitCurrent(settings.RedTenthMilliAmpere) - SettingsObject::MinCurrent) / 5; + *pSet++ = (SettingsObject::LimitCurrent(settings.GreenTenthMilliAmpere) - SettingsObject::MinCurrent) / 5; + *pSet++ = (SettingsObject::LimitCurrent(settings.BlueTenthMilliAmpere) - SettingsObject::MinCurrent) / 5; + + uint8_t* pC1 = pData; + + // C2 + for (uint8_t elem = 0; elem < 4; elem++) + { + *pSet++ = ~(*pC1++); + } + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData + SettingsSize; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + + +class NeoWrgbTm1814Feature : public Neo4ElementsTm1814Settings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.W; + *p++ = color.R; + *p++ = color.G; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = *p++; + color.R = *p++; + color.G = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } + +}; + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/NeoTopology.h b/lib/NeoPixelBus-2.6.0/src/internal/NeoTopology.h similarity index 100% rename from lib/NeoPixelBus-2.5.0.09/src/internal/NeoTopology.h rename to lib/NeoPixelBus-2.6.0/src/internal/NeoTopology.h diff --git a/lib/NeoPixelBus-2.6.0/src/internal/P9813ColorFeatures.h b/lib/NeoPixelBus-2.6.0/src/internal/P9813ColorFeatures.h new file mode 100644 index 000000000..2212e1f73 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/P9813ColorFeatures.h @@ -0,0 +1,162 @@ +/*------------------------------------------------------------------------- +P9813ColorFeatures provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with P9813s + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class P98133Elements +{ +public: + static const size_t PixelSize = 4; // still requires 4 to be sent + + static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + + static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + *pPixelDest++ = pPixelSrc[0]; + *pPixelDest++ = pPixelSrc[1]; + *pPixelDest++ = pPixelSrc[2]; + *pPixelDest++ = pPixelSrc[3]; + } + } + + static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + while (pPixelDest < pEnd) + { + *pPixelDest++ = *pPixelSrc++; + *pPixelDest++ = *pPixelSrc++; + *pPixelDest++ = *pPixelSrc++; + *pPixelDest++ = *pPixelSrc++; + } + } + + static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * PixelSize); + const uint8_t* pSrc = (const uint8_t*)pPixelSrc; + while (pPixelDest < pEnd) + { + *pPixelDest++ = pgm_read_byte(pSrc++); + *pPixelDest++ = pgm_read_byte(pSrc++); + *pPixelDest++ = pgm_read_byte(pSrc++); + *pPixelDest++ = pgm_read_byte(pSrc++); + } + } + + static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + uint8_t* pDestBack = pPixelDest + (count * PixelSize); + const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); + while (pDestBack > pPixelDest) + { + *--pDestBack = *--pSrcBack; + *--pDestBack = *--pSrcBack; + *--pDestBack = *--pSrcBack; + *--pDestBack = *--pSrcBack; + } + } + + typedef RgbColor ColorObject; +}; + +class P98133ElementsNoSettings : public P98133Elements +{ +public: + typedef NeoNoSettings SettingsObject; + static const size_t SettingsSize = 0; + + static void applySettings(uint8_t*, const SettingsObject&) + { + } + + static uint8_t* pixels(uint8_t* pData) + { + return pData; + } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } +}; + +class P9813BgrFeature : public P98133ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xC0 | ((~color.B & 0xC0) >> 2) | ((~color.G & 0xC0) >> 4) | ((~color.R & 0xC0) >> 6); + *p++ = color.B; + *p++ = color.G; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.B = *p++; + color.G = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; + + + + + + diff --git a/lib/NeoPixelBus-2.6.0/src/internal/P9813GenericMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/P9813GenericMethod.h new file mode 100644 index 000000000..37a15f6ad --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/P9813GenericMethod.h @@ -0,0 +1,126 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for P9813s using general Pins (APA102). + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set +#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) +#include "TwoWireBitBangImpleAvr.h" +#else +#include "TwoWireBitBangImple.h" +#endif + + +template class P9813MethodBase +{ +public: + P9813MethodBase(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _sizeEndFrame((pixelCount + 15) / 16), // 16 = div 2 (bit for every two pixels) div 8 (bits to bytes) + _wire(pinClock, pinData) + { + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + } + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) + P9813MethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + P9813MethodBase(SCK, MOSI, pixelCount, elementSize, settingsSize) + { + } +#endif + + ~P9813MethodBase() + { + free(_data); + } + + bool IsReadyToUpdate() const + { + return true; // dot stars don't have a required delay + } + +#if defined(ARDUINO_ARCH_ESP32) + void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) + { + _wire.begin(sck, miso, mosi, ss); + } +#endif + + void Initialize() + { + _wire.begin(); + } + + void Update(bool) + { + const uint8_t startFrame[4] = { 0x00 }; + const uint8_t endFrame[4] = { 0x00 }; + + _wire.beginTransaction(); + + // start frame + _wire.transmitBytes(startFrame, sizeof(startFrame)); + + // data + _wire.transmitBytes(_data, _sizeData); + + // end frame + _wire.transmitBytes(endFrame, sizeof(endFrame)); + + _wire.endTransaction(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + const size_t _sizeEndFrame; + + T_TWOWIRE _wire; + uint8_t* _data; // Holds LED color values +}; + +typedef P9813MethodBase P9813Method; + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) +#include "TwoWireSpiImple.h" +typedef P9813MethodBase> P9813Spi20MhzMethod; +typedef P9813MethodBase> P9813Spi10MhzMethod; +typedef P9813MethodBase> P9813Spi2MhzMethod; +typedef P9813Spi10MhzMethod P9813SpiMethod; +#endif + + + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.cpp b/lib/NeoPixelBus-2.6.0/src/internal/RgbColor.cpp similarity index 79% rename from lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/RgbColor.cpp index 29ae4343b..30a781195 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.cpp +++ b/lib/NeoPixelBus-2.6.0/src/internal/RgbColor.cpp @@ -160,74 +160,86 @@ RgbColor::RgbColor(const HsbColor& color) uint8_t RgbColor::CalculateBrightness() const { - return (uint8_t)(((uint16_t)R + (uint16_t)G + (uint16_t)B) / 3); + return (uint8_t)(((uint16_t)R + (uint16_t)G + (uint16_t)B) / 3); +} + +RgbColor RgbColor::Dim(uint8_t ratio) const +{ + // specifically avoids float math + return RgbColor(_elementDim(R, ratio), _elementDim(G, ratio), _elementDim(B, ratio)); +} + +RgbColor RgbColor::Brighten(uint8_t ratio) const +{ + // specifically avoids float math + return RgbColor(_elementBrighten(R, ratio), _elementBrighten(G, ratio), _elementBrighten(B, ratio)); } void RgbColor::Darken(uint8_t delta) { - if (R > delta) - { - R -= delta; - } - else - { - R = 0; - } + if (R > delta) + { + R -= delta; + } + else + { + R = 0; + } - if (G > delta) - { - G -= delta; - } - else - { - G = 0; - } + if (G > delta) + { + G -= delta; + } + else + { + G = 0; + } - if (B > delta) - { - B -= delta; - } - else - { - B = 0; - } + if (B > delta) + { + B -= delta; + } + else + { + B = 0; + } } void RgbColor::Lighten(uint8_t delta) { - if (R < 255 - delta) - { - R += delta; - } - else - { - R = 255; - } + if (R < 255 - delta) + { + R += delta; + } + else + { + R = 255; + } - if (G < 255 - delta) - { - G += delta; - } - else - { - G = 255; - } + if (G < 255 - delta) + { + G += delta; + } + else + { + G = 255; + } - if (B < 255 - delta) - { - B += delta; - } - else - { - B = 255; - } + if (B < 255 - delta) + { + B += delta; + } + else + { + B = 255; + } } RgbColor RgbColor::LinearBlend(const RgbColor& left, const RgbColor& right, float progress) { - return RgbColor( left.R + ((right.R - left.R) * progress), - left.G + ((right.G - left.G) * progress), - left.B + ((right.B - left.B) * progress)); + return RgbColor( left.R + ((right.R - left.R) * progress), + left.G + ((right.G - left.G) * progress), + left.B + ((right.B - left.B) * progress)); } RgbColor RgbColor::BilinearBlend(const RgbColor& c00, diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.h b/lib/NeoPixelBus-2.6.0/src/internal/RgbColor.h similarity index 78% rename from lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.h rename to lib/NeoPixelBus-2.6.0/src/internal/RgbColor.h index 516112319..b50857b1a 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbColor.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/RgbColor.h @@ -26,6 +26,7 @@ License along with NeoPixel. If not, see #pragma once #include +#include "NeoSettings.h" struct HslColor; struct HsbColor; @@ -38,6 +39,8 @@ struct HtmlColor; // ------------------------------------------------------------------------ struct RgbColor { + typedef NeoRgbCurrentSettings SettingsObject; + // ------------------------------------------------------------------------ // Construct a RgbColor using R, G, B values (0-255) // ------------------------------------------------------------------------ @@ -98,6 +101,22 @@ struct RgbColor // ------------------------------------------------------------------------ uint8_t CalculateBrightness() const; + // ------------------------------------------------------------------------ + // Dim will return a new color that is blended to black with the given ratio + // ratio - (0-255) where 255 will return the original color and 0 will return black + // + // NOTE: This is a simple linear blend + // ------------------------------------------------------------------------ + RgbColor Dim(uint8_t ratio) const; + + // ------------------------------------------------------------------------ + // Brighten will return a new color that is blended to white with the given ratio + // ratio - (0-255) where 255 will return the original color and 0 will return white + // + // NOTE: This is a simple linear blend + // ------------------------------------------------------------------------ + RgbColor Brighten(uint8_t ratio) const; + // ------------------------------------------------------------------------ // Darken will adjust the color by the given delta toward black // NOTE: This is a simple linear change @@ -137,6 +156,17 @@ struct RgbColor float x, float y); + uint32_t CalcTotalTenthMilliAmpere(const SettingsObject& settings) + { + auto total = 0; + + total += R * settings.RedTenthMilliAmpere / 255; + total += G * settings.GreenTenthMilliAmpere / 255; + total += B * settings.BlueTenthMilliAmpere / 255; + + return total; + } + // ------------------------------------------------------------------------ // Red, Green, Blue color members (0-255) where // (0,0,0) is black and (255,255,255) is white @@ -144,5 +174,26 @@ struct RgbColor uint8_t R; uint8_t G; uint8_t B; + +private: + inline static uint8_t _elementDim(uint8_t value, uint8_t ratio) + { + return (static_cast(value) * (static_cast(ratio) + 1)) >> 8; + } + + inline static uint8_t _elementBrighten(uint8_t value, uint8_t ratio) + { + uint16_t element = ((static_cast(value) + 1) << 8) / (static_cast(ratio) + 1); + + if (element > 255) + { + element = 255; + } + else + { + element -= 1; + } + return element; + } }; diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.cpp b/lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.cpp similarity index 89% rename from lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.cpp rename to lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.cpp index 062834d03..cb9681f2b 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.cpp +++ b/lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.cpp @@ -67,6 +67,18 @@ uint8_t RgbwColor::CalculateBrightness() const } } +RgbwColor RgbwColor::Dim(uint8_t ratio) const +{ + // specifically avoids float math + return RgbwColor(_elementDim(R, ratio), _elementDim(G, ratio), _elementDim(B, ratio), _elementDim(W, ratio)); +} + +RgbwColor RgbwColor::Brighten(uint8_t ratio) const +{ + // specifically avoids float math + return RgbwColor(_elementBrighten(R, ratio), _elementBrighten(G, ratio), _elementBrighten(B, ratio), _elementBrighten(W, ratio)); +} + void RgbwColor::Darken(uint8_t delta) { if (R > delta) diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.h b/lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.h similarity index 81% rename from lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.h rename to lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.h index 38f25302b..73732b5e4 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/RgbwColor.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/RgbwColor.h @@ -38,6 +38,8 @@ struct HsbColor; // ------------------------------------------------------------------------ struct RgbwColor { + typedef NeoRgbwCurrentSettings SettingsObject; + // ------------------------------------------------------------------------ // Construct a RgbwColor using R, G, B, W values (0-255) // ------------------------------------------------------------------------ @@ -126,6 +128,22 @@ struct RgbwColor // ------------------------------------------------------------------------ uint8_t CalculateBrightness() const; + // ------------------------------------------------------------------------ + // Dim will return a new color that is blended to black with the given ratio + // ratio - (0-255) where 255 will return the original color and 0 will return black + // + // NOTE: This is a simple linear blend + // ------------------------------------------------------------------------ + RgbwColor Dim(uint8_t ratio) const; + + // ------------------------------------------------------------------------ + // Brighten will return a new color that is blended to white with the given ratio + // ratio - (0-255) where 255 will return the original color and 0 will return white + // + // NOTE: This is a simple linear blend + // ------------------------------------------------------------------------ + RgbwColor Brighten(uint8_t ratio) const; + // ------------------------------------------------------------------------ // Darken will adjust the color by the given delta toward black // NOTE: This is a simple linear change @@ -165,6 +183,18 @@ struct RgbwColor float x, float y); + uint16_t CalcTotalTenthMilliAmpere(const SettingsObject& settings) + { + auto total = 0; + + total += R * settings.RedTenthMilliAmpere / 255; + total += G * settings.GreenTenthMilliAmpere / 255; + total += B * settings.BlueTenthMilliAmpere / 255; + total += W * settings.WhiteCurrent / 255; + + return total; + } + // ------------------------------------------------------------------------ // Red, Green, Blue, White color members (0-255) where // (0,0,0,0) is black and (255,255,255, 0) and (0,0,0,255) is white @@ -174,5 +204,26 @@ struct RgbwColor uint8_t G; uint8_t B; uint8_t W; + +private: + inline static uint8_t _elementDim(uint8_t value, uint8_t ratio) + { + return (static_cast(value) * (static_cast(ratio) + 1)) >> 8; + } + + inline static uint8_t _elementBrighten(uint8_t value, uint8_t ratio) + { + uint16_t element = ((static_cast(value) + 1) << 8) / (static_cast(ratio) + 1); + + if (element > 255) + { + element = 255; + } + else + { + element -= 1; + } + return element; + } }; diff --git a/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.cpp b/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.cpp new file mode 100644 index 000000000..91495978a --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.cpp @@ -0,0 +1,153 @@ +/*------------------------------------------------------------------------- +SegmentDigit provides a color object that can be directly consumed by NeoPixelBus + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#include "SegmentDigit.h" + +// +// https://en.wikichip.org/wiki/seven-segment_display/representing_letters +// +const uint8_t SevenSegDigit::DecodeNumbers[] = { + // 0 1 2 3 4 5 6 7 8 9 + 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F }; + +const uint8_t SevenSegDigit::DecodeAlphaCaps[] = { + // A B C D E F G + 0x77, 0x00, 0x39, 0x00, 0x79, 0x71, 0x3D, + // H I J K L M N + 0x76, 0x30, 0x1E, 0x00, 0x38, 0x00, 0x00, + // O P Q R S + 0x3F, 0x73, 0x00, 0x00, 0x6D, + // T U V W X Y Z + 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +const uint8_t SevenSegDigit::DecodeAlpha[] = { + // a b c d e f g + 0x00, 0x7C, 0x58, 0x5E, 0x00, 0x00, 0x00, + // h i j k l m n + 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, + // o p q r s + 0x5C, 0x00, 0x67, 0x50, 0x00, + // t u v w x y z + 0x78, 0x1C, 0x00, 0x00, 0x00, 0x6E, 0x00 }; + +const uint8_t SevenSegDigit::DecodeSpecial[] = { + // , - . / + 0x80, 0x40, 0x80, 0x40 }; + +void SevenSegDigit::init(uint8_t bitmask, uint8_t brightness, uint8_t defaultBrightness) +{ + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + Segment[iSegment] = (bitmask & 0x01) ? brightness : defaultBrightness; + bitmask >>= 1; + } +} + +SevenSegDigit::SevenSegDigit(uint8_t bitmask, uint8_t brightness, uint8_t defaultBrightness) +{ + init(bitmask, brightness, defaultBrightness); +}; + +SevenSegDigit::SevenSegDigit(char letter, uint8_t brightness, uint8_t defaultBrightness) +{ + if (letter >= '0' && letter <= '9') + { + init(DecodeNumbers[letter - '0'], brightness, defaultBrightness); + } + else if (letter >= 'a' && letter <= 'z') + { + init(DecodeAlpha[letter - 'a'], brightness, defaultBrightness); + } + else if (letter >= 'A' && letter <= 'Z') + { + init(DecodeAlphaCaps[letter - 'A'], brightness, defaultBrightness); + } + else if (letter >= ',' && letter <= '/') + { + init(DecodeSpecial[letter - ','], brightness, defaultBrightness); + } + else + { + memset(Segment, defaultBrightness, sizeof(Segment)); + } +}; + +uint8_t SevenSegDigit::CalculateBrightness() const +{ + uint16_t sum = 0; + + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + sum += Segment[iSegment]; + } + + return (uint8_t)(sum / SegmentCount); +} + +void SevenSegDigit::Darken(uint8_t delta) +{ + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + uint8_t element = Segment[iSegment]; + if (element > delta) + { + element -= delta; + } + else + { + element = 0; + } + Segment[iSegment] = element; + } +} + +void SevenSegDigit::Lighten(uint8_t delta) +{ + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + uint8_t element = Segment[iSegment]; + if (element < 255 - delta) + { + element += delta; + } + else + { + element = 255; + } + Segment[iSegment] = element; + } +} + +SevenSegDigit SevenSegDigit::LinearBlend(const SevenSegDigit& left, const SevenSegDigit& right, float progress) +{ + SevenSegDigit result; + + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + result.Segment[iSegment] = left.Segment[iSegment] + ((right.Segment[iSegment] - left.Segment[iSegment]) * progress); + } + return result; +} diff --git a/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.h b/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.h new file mode 100644 index 000000000..826044c41 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/SegmentDigit.h @@ -0,0 +1,202 @@ +/*------------------------------------------------------------------------- +SegmentDigit provides a color object that can be directly consumed by NeoPixelBus + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +#include + +enum LedSegment +{ + LedSegment_A, + LedSegment_B, + LedSegment_C, + LedSegment_D, + LedSegment_E, + LedSegment_F, + LedSegment_G, + LedSegment_Decimal, + LedSegment_COUNT +}; + +// ------------------------------------------------------------------------ +// SevenSegDigit represents a color object that is represented by the segments +// of a 7 segment LED display digit. It contains helpful routines to manipulate +// and set the elements. +// +// The order represents the physical LED location starting at A, through to G, then +// ending at the decimal point +// "abcdefg." +// ------------------------------------------------------------------------ +struct SevenSegDigit +{ + // ------------------------------------------------------------------------ + // Construct a SevenSegDigit using + // the default brightness to apply to all segments + // ------------------------------------------------------------------------ + SevenSegDigit(uint8_t defaultBrightness) + { + memset(Segment, defaultBrightness, sizeof(Segment)); + } + + // ------------------------------------------------------------------------ + // Construct a SevenSegDigit using + // a bitmask for the segment (bit order is ".gfedcba") + // the brightness to apply to them, (0-255) + // the default brightness to apply to those not set in the bitmask (0-255) + // ------------------------------------------------------------------------ + SevenSegDigit(uint8_t bitmask, uint8_t brightness, uint8_t defaultBrightness = 0); + + // ------------------------------------------------------------------------ + // Construct a SevenSegDigit using + // a char that will get mapped to the segments, + // the brightness to apply to them, (0-255) + // the default brightness to apply to those not set in the bitmask (0-255) + // ------------------------------------------------------------------------ + SevenSegDigit(char letter, uint8_t brightness, uint8_t defaultBrightness = 0); + + // ------------------------------------------------------------------------ + // Construct a SevenSegDigit that will have its values set in latter operations + // CAUTION: The members are not initialized and may not be consistent + // ------------------------------------------------------------------------ + SevenSegDigit() + { + }; + + // ------------------------------------------------------------------------ + // Comparison operators + // ------------------------------------------------------------------------ + bool operator==(const SevenSegDigit& other) const + { + for (uint8_t iSegment = 0; iSegment < SegmentCount; iSegment++) + { + if (Segment[iSegment] != other.Segment[iSegment]) + { + return false; + } + } + return true; + }; + + bool operator!=(const SevenSegDigit& other) const + { + return !(*this == other); + }; + + // ------------------------------------------------------------------------ + // CalculateBrightness will calculate the overall brightness + // NOTE: This is a simple linear brightness + // ------------------------------------------------------------------------ + uint8_t CalculateBrightness() const; + + // ------------------------------------------------------------------------ + // Darken will adjust the color by the given delta toward black + // NOTE: This is a simple linear change + // delta - (0-255) the amount to dim the segment + // ------------------------------------------------------------------------ + void Darken(uint8_t delta); + + // ------------------------------------------------------------------------ + // Lighten will adjust the color by the given delta toward white + // NOTE: This is a simple linear change + // delta - (0-255) the amount to lighten the segment + // ------------------------------------------------------------------------ + void Lighten(uint8_t delta); + + // ------------------------------------------------------------------------ + // LinearBlend between two colors by the amount defined by progress variable + // left - the segment to start the blend at + // right - the segment to end the blend at + // progress - (0.0 - 1.0) value where 0 will return left and 1.0 will return right + // and a value between will blend the brightness of each element + // weighted linearly between them + // ------------------------------------------------------------------------ + static SevenSegDigit LinearBlend(const SevenSegDigit& left, const SevenSegDigit& right, float progress); + + template + static void SetString(T_SET_TARGET& target, uint16_t indexDigit, const char* str, uint8_t brightness, uint8_t defaultBrightness = 0) + { + if (str == nullptr) + { + return; + } + + const char* pFirst = str; + const char* pIter = str; + + // digits are right to left + // so find the end + while (*pIter != '\0') + { + pIter++; + } + pIter--; + + + while (pIter >= pFirst) + { + bool decimal = false; + char value = *pIter; + + // check if merging a decimal is required + if (pIter > pFirst && (*pIter == '.' || *pIter == ',')) + { + // merge a decimal as long as they aren't the same + if (*(pIter - 1) != *pIter) + { + decimal = true; + pIter--; + value = *pIter; // use the next char + } + } + + SevenSegDigit digit(value, brightness, defaultBrightness); + if (decimal) + { + digit.Segment[LedSegment_Decimal] = brightness; + } + target.SetPixelColor(indexDigit, digit); + indexDigit++; + } + } + + // ------------------------------------------------------------------------ + // segment members (0-255) where each represents the segment location + // and the value defines the brightnes (0) is off and (255) is full brightness + // ------------------------------------------------------------------------ + static const uint8_t SegmentCount = 9; + uint8_t Segment[SegmentCount]; + + + // segment decode maps from ascii relative first char in map to a bitmask of segments + // + static const uint8_t DecodeNumbers[10]; // 0-9 + static const uint8_t DecodeAlphaCaps[26]; // A-Z + static const uint8_t DecodeAlpha[26]; // a-z + static const uint8_t DecodeSpecial[4]; // , - . / + +protected: + void init(uint8_t bitmask, uint8_t brightness, uint8_t defaultBrightness); +}; + diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarGenericMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImple.h similarity index 58% rename from lib/NeoPixelBus-2.5.0.09/src/internal/DotStarGenericMethod.h rename to lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImple.h index 8b3fe3350..4a784aeab 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarGenericMethod.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImple.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library helper functions for DotStars using general Pins (APA102). +NeoPixel library helper functions for DotStars using general Pins (APA102/LPD8806). Written by Michael C. Miller. @@ -26,86 +26,41 @@ License along with NeoPixel. If not, see #pragma once -class DotStarGenericMethod + +class TwoWireBitBangImple { public: - DotStarGenericMethod(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize) : + TwoWireBitBangImple(uint8_t pinClock, uint8_t pinData) : _pinClock(pinClock), - _pinData(pinData), - _sizePixels(pixelCount * elementSize) + _pinData(pinData) { pinMode(pinClock, OUTPUT); pinMode(pinData, OUTPUT); - - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0, _sizePixels); } - ~DotStarGenericMethod() + ~TwoWireBitBangImple() { pinMode(_pinClock, INPUT); pinMode(_pinData, INPUT); - - free(_pixels); } - bool IsReadyToUpdate() const - { - return true; // dot stars don't have a required delay - } - - void Initialize() + void begin() { digitalWrite(_pinClock, LOW); digitalWrite(_pinData, LOW); } - void Update(bool) + void beginTransaction() { - // start frame - for (int startFrameByte = 0; startFrameByte < 4; startFrameByte++) - { - _transmitByte(0x00); - } - - // data - uint8_t* data = _pixels; - const uint8_t* endData = _pixels + _sizePixels; - while (data < endData) - { - _transmitByte(*data++); - } - - // end frame - // one bit for every two pixels with no less than 1 byte - const uint16_t countEndFrameBytes = ((_sizePixels / 4) + 15) / 16; - for (uint16_t endFrameByte = 0; endFrameByte < countEndFrameBytes; endFrameByte++) - { - _transmitByte(0xff); - } - // set clock and data back to low between updates + } + + void endTransaction() + { digitalWrite(_pinData, LOW); } - uint8_t* getPixels() const - { - return _pixels; - }; - - size_t getPixelsSize() const - { - return _sizePixels; - }; - -private: - const uint8_t _pinClock; // output pin number for clock line - const uint8_t _pinData; // output pin number for data line - const size_t _sizePixels; // Size of '_pixels' buffer below - - uint8_t* _pixels; // Holds LED color values - - void _transmitByte(uint8_t data) + void transmitByte(uint8_t data) { for (int bit = 7; bit >= 0; bit--) { @@ -121,8 +76,17 @@ private: digitalWrite(_pinClock, LOW); } } -}; - -typedef DotStarGenericMethod DotStarMethod; + void transmitBytes(const uint8_t* data, size_t dataSize) + { + const uint8_t* endData = data + dataSize; + while (data < endData) + { + transmitByte(*data++); + } + } +private: + const uint8_t _pinClock; // output pin number for clock line + const uint8_t _pinData; // output pin number for data line +}; \ No newline at end of file diff --git a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarAvrMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImpleAvr.h similarity index 61% rename from lib/NeoPixelBus-2.5.0.09/src/internal/DotStarAvrMethod.h rename to lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImpleAvr.h index a627d0a68..8c0be740d 100644 --- a/lib/NeoPixelBus-2.5.0.09/src/internal/DotStarAvrMethod.h +++ b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireBitBangImpleAvr.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoPixel library helper functions for DotStars on AVR (APA102). +NeoPixel library helper functions for DotStars using general Pins (APA102/LPD8806). Written by Michael C. Miller. @@ -26,99 +26,46 @@ License along with NeoPixel. If not, see #pragma once -// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set -#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) -class DotStarAvrMethod +class TwoWireBitBangImple { public: - DotStarAvrMethod(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize) : + TwoWireBitBangImple(uint8_t pinClock, uint8_t pinData) : _pinClock(pinClock), - _pinData(pinData), - _sizePixels(pixelCount * elementSize) + _pinData(pinData) { pinMode(pinClock, OUTPUT); pinMode(pinData, OUTPUT); - _pixels = (uint8_t*)malloc(_sizePixels); - memset(_pixels, 0, _sizePixels); - _portClock = portOutputRegister(digitalPinToPort(_pinClock)); _pinMaskClock = digitalPinToBitMask(_pinClock); _portData = portOutputRegister(digitalPinToPort(_pinData)); _pinMaskData = digitalPinToBitMask(_pinData); } - ~DotStarAvrMethod() + ~TwoWireBitBangImple() { pinMode(_pinClock, INPUT); pinMode(_pinData, INPUT); - - free(_pixels); } - bool IsReadyToUpdate() const - { - return true; // dot stars don't have a required delay - } - - void Initialize() + void begin() { digitalWrite(_pinClock, LOW); digitalWrite(_pinData, LOW); } - void Update(bool) + void beginTransaction() { - // start frame - for (int startFrameByte = 0; startFrameByte < 4; startFrameByte++) - { - _transmitByte(0x00); - } - - // data - uint8_t* data = _pixels; - const uint8_t* endData = _pixels + _sizePixels; - while (data < endData) - { - _transmitByte(*data++); - } - - // end frame - // one bit for every two pixels with no less than 1 byte - const uint16_t countEndFrameBytes = ((_sizePixels / 4) + 15) / 16; - for (uint16_t endFrameByte = 0; endFrameByte < countEndFrameBytes; endFrameByte++) - { - _transmitByte(0xff); - } - // set clock and data back to low between updates + } + + void endTransaction() + { digitalWrite(_pinData, LOW); } - uint8_t* getPixels() const - { - return _pixels; - }; - - size_t getPixelsSize() const - { - return _sizePixels; - }; - -private: - const uint8_t _pinClock; // output pin number for clock line - const uint8_t _pinData; // output pin number for data line - const size_t _sizePixels; // Size of '_pixels' buffer below - - uint8_t* _pixels; // Holds LED color values - - volatile uint8_t* _portData; // Output PORT register - uint8_t _pinMaskData; // Output PORT bitmask - volatile uint8_t* _portClock; // Output PORT register - uint8_t _pinMaskClock; // Output PORT bitmask - - void _transmitByte(uint8_t data) + void transmitByte(uint8_t data) { for (int bit = 7; bit >= 0; bit--) { @@ -132,13 +79,11 @@ private: { *_portData &= ~_pinMaskData; } - // set clock high as data is ready // digitalWrite(_pinClock, HIGH); *_portClock |= _pinMaskClock; - // done between clock toggle to give a little time data <<= 1; // set clock low as data pin is changed @@ -146,8 +91,22 @@ private: *_portClock &= ~_pinMaskClock; } } -}; -typedef DotStarAvrMethod DotStarMethod; + void transmitBytes(const uint8_t* data, size_t dataSize) + { + const uint8_t* endData = data + dataSize; + while (data < endData) + { + transmitByte(*data++); + } + } -#endif +private: + const uint8_t _pinClock; // output pin number for clock line + const uint8_t _pinData; // output pin number for data line + + volatile uint8_t* _portData; // Output PORT register + uint8_t _pinMaskData; // Output PORT bitmask + volatile uint8_t* _portClock; // Output PORT register + uint8_t _pinMaskClock; // Output PORT bitmask +}; \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/src/internal/TwoWireSpiImple.h b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireSpiImple.h new file mode 100644 index 000000000..9838f7b00 --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/TwoWireSpiImple.h @@ -0,0 +1,115 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for DotStars using general Pins (APA102/LPD8806). + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +#include + +class SpiSpeed40Mhz +{ +public: + static const uint32_t Clock = 40000000L; +}; + +class SpiSpeed20Mhz +{ +public: + static const uint32_t Clock = 20000000L; +}; + +class SpiSpeed10Mhz +{ +public: + static const uint32_t Clock = 10000000L; +}; + +class SpiSpeed2Mhz +{ +public: + static const uint32_t Clock = 2000000L; +}; + +template class TwoWireSpiImple +{ +public: + TwoWireSpiImple(uint8_t, uint8_t) // clock and data pins ignored for hardware SPI + { + } + + ~TwoWireSpiImple() + { + SPI.end(); + } + +#if defined(ARDUINO_ARCH_ESP32) + // for cases where hardware SPI can have pins changed + void begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) + { + SPI.begin(sck, miso, mosi, ss); + } +#endif + + void begin() + { + SPI.begin(); + } + + void beginTransaction() + { + SPI.beginTransaction(SPISettings(T_SPISPEED::Clock, MSBFIRST, SPI_MODE0)); + } + + void endTransaction() + { + SPI.endTransaction(); + } + + void transmitByte(uint8_t data) + { + SPI.transfer(data); + } + + void transmitBytes(const uint8_t* data, size_t dataSize) + { +#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) + // ESPs have a method to write without inplace overwriting the send buffer + // since we don't care what gets received, use it for performance + // FIX: but for what ever reason on Esp32, its not const + SPI.writeBytes(const_cast(data), dataSize); + +#else + // default ARDUINO transfer inplace overwrites the send buffer + // which is bad in this case, so we have to send one byte at a time + const uint8_t* endData = data + dataSize; + while (data < endData) + { + SPI.transfer(*data++); + } +#endif + } + +private: +}; \ No newline at end of file diff --git a/lib/NeoPixelBus-2.6.0/src/internal/Ws2801GenericMethod.h b/lib/NeoPixelBus-2.6.0/src/internal/Ws2801GenericMethod.h new file mode 100644 index 000000000..01271086e --- /dev/null +++ b/lib/NeoPixelBus-2.6.0/src/internal/Ws2801GenericMethod.h @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- +NeoPixel library helper functions for WS2801 + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set +#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__) +#include "TwoWireBitBangImpleAvr.h" +#else +#include "TwoWireBitBangImple.h" +#endif + + +template class Ws2801MethodBase +{ +public: + Ws2801MethodBase(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + _sizeData(pixelCount * elementSize + settingsSize), + _wire(pinClock, pinData) + { + _data = static_cast(malloc(_sizeData)); + memset(_data, 0, _sizeData); + } + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) + Ws2801MethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) : + Ws2801MethodBase(SCK, MOSI, pixelCount, elementSize, settingsSize) + { + } +#endif + + ~Ws2801MethodBase() + { + free(_data); + } + + bool IsReadyToUpdate() const + { + uint32_t delta = micros() - _endTime; + + return (delta >= 500); + } + +#if defined(ARDUINO_ARCH_ESP32) + void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) + { + _wire.begin(sck, miso, mosi, ss); + } +#endif + + void Initialize() + { + _wire.begin(); + + _endTime = micros(); + } + + void Update(bool) + { + while (!IsReadyToUpdate()) + { +#if !defined(ARDUINO_TEEONARDU_LEO) && !defined(ARDUINO_TEEONARDU_FLORA) + yield(); // allows for system yield if needed +#endif + } + + _wire.beginTransaction(); + + // data + _wire.transmitBytes(_data, _sizeData); + + _wire.endTransaction(); + + // save EOD time for latch on next call + _endTime = micros(); + } + + uint8_t* getData() const + { + return _data; + }; + + size_t getDataSize() const + { + return _sizeData; + }; + +private: + const size_t _sizeData; // Size of '_data' buffer below + + uint32_t _endTime; // Latch timing reference + T_TWOWIRE _wire; + uint8_t* _data; // Holds LED color values +}; + +typedef Ws2801MethodBase NeoWs2801Method; + +#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny) +#include "TwoWireSpiImple.h" +typedef Ws2801MethodBase> NeoWs2801Spi20MhzMethod; +typedef Ws2801MethodBase> NeoWs2801Spi10MhzMethod; +typedef Ws2801MethodBase> NeoWs2801Spi2MhzMethod; +typedef NeoWs2801Spi10MhzMethod NeoWs2801SpiMethod; +#endif + + + diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 8899ce12f..dff58d62c 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -9,6 +9,7 @@ - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Change ``Status`` command output for disabled status types +- Change NeoPixelBus library from v2.5.0.09 to v2.6.0 - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) - Fix exception 28 due to device group buffer overflow (#9459) From 0eef729d8f4d94c00b35ac44c5ba73356617bf71 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 18:12:32 +0200 Subject: [PATCH 10/17] Remove migration support from before 7.0 - Remove support for direct upgrade from Tasmota versions before 7.0 - Remove auto config update for all Friendlynames and Switchtopic from Tasmota versions before 8.0 --- RELEASENOTES.md | 4 +- tasmota/CHANGELOG.md | 4 +- tasmota/my_user_config.h | 1 - tasmota/settings.ino | 231 --------------------------------------- 4 files changed, 6 insertions(+), 234 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f8179f3d2..a860f942f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -61,13 +61,15 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ### Version 9.0.0.1 -- Remove auto config update for all Friendlynames and Switchtopic from versions before 8.x +- Remove support for direct upgrade from Tasmota versions before 7.0 +- Remove auto config update for all Friendlynames and Switchtopic from Tasmota versions before 8.0 - Change redesigning ESP8266 GPIO internal representation in line with ESP32 - Change new IR Raw compact format (#9444) - Change MAX31865 driver to support up to 6 thermocouples selected by ``MX31865 CS`` instead of ``SSPI CS`` (#9103) - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Change ``Status`` command output for disabled status types +- Change IRremoteESP8266 library from v2.7.10 to v2.7.11 - Change NeoPixelBus library from v2.5.0.09 to v2.6.0 - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index dff58d62c..7c107d184 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,13 +2,15 @@ ### 9.0.0.1 20201002 -- Remove auto config update for all Friendlynames and Switchtopic from versions before 8.x +- Remove support for direct upgrade from Tasmota versions before 7.0 +- Remove auto config update for all Friendlynames and Switchtopic from Tasmota versions before 8.0 - Change redesigning ESP8266 GPIO internal representation in line with ESP32 - Change new IR Raw compact format (#9444) - Change MAX31865 driver to support up to 6 thermocouples selected by ``MX31865 CS`` instead of ``SSPI CS`` (#9103) - Change A4988 optional microstep pin selection - Change pulsetime to allow use for all relays with 8 interleaved so ``Pulsetime1`` is valid for Relay1, Relay9, Relay17 etc. (#9279) - Change ``Status`` command output for disabled status types +- Change IRremoteESP8266 library from v2.7.10 to v2.7.11 - Change NeoPixelBus library from v2.5.0.09 to v2.6.0 - Fix template conversion when GPIO17 is 0 - Fix ledlink blink when no network connected regression from 8.3.1.4 (#9292) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 647217911..82eb7aa39 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -47,7 +47,6 @@ #define CFG_HOLDER 4617 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash // If following define is disabled it increases configuration corruption detection BUT // it only allows firmware upgrades starting from version 6.6.0.11 -//#define CFG_LEGACY_LOAD // Support for firmware upgrades from version 6.0.0 // -- Project ------------------------------------- #define PROJECT "tasmota" // PROJECT is used as the default topic delimiter diff --git a/tasmota/settings.ino b/tasmota/settings.ino index b56ec08c5..d2868ab79 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -571,50 +571,6 @@ void SettingsSave(uint8_t rotate) void SettingsLoad(void) { #ifdef ESP8266 // Load configuration from eeprom or one of 7 slots below if first valid load does not stop_flash_rotate -#ifdef CFG_LEGACY_LOAD - // Active until version 8.4.0.2 - struct { - uint16_t cfg_holder; // 000 - uint16_t cfg_size; // 002 - unsigned long save_flag; // 004 - } _SettingsH; - unsigned long save_flag = 0; - - settings_location = 0; - uint32_t flash_location = SETTINGS_LOCATION +1; - uint16_t cfg_holder = 0; - for (uint32_t i = 0; i < CFG_ROTATES; i++) { // Read all config pages in search of valid and latest - flash_location--; - ESP.flashRead(flash_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); - bool valid = false; - if (Settings.version > 0x06000000) { - bool almost_valid = (Settings.cfg_crc32 == GetSettingsCrc32()); - if (Settings.version < 0x0606000B) { - almost_valid = (Settings.cfg_crc == GetSettingsCrc()); - } - // Sometimes CRC on pages below FB, overwritten by OTA, is fine but Settings are still invalid. So check cfg_holder too - if (almost_valid && (0 == cfg_holder)) { cfg_holder = Settings.cfg_holder; } // At FB always active cfg_holder - valid = (cfg_holder == Settings.cfg_holder); - } else { - ESP.flashRead((flash_location -1) * SPI_FLASH_SEC_SIZE, (uint32*)&_SettingsH, sizeof(_SettingsH)); - valid = (Settings.cfg_holder == _SettingsH.cfg_holder); - } - if (valid) { - if (Settings.save_flag > save_flag) { // Find latest page based on incrementing save_flag - save_flag = Settings.save_flag; - settings_location = flash_location; - if (Settings.flag.stop_flash_rotate && (0 == i)) { // Stop if only eeprom area should be used and it is valid - break; - } - } - } - delay(1); - } - if (settings_location > 0) { - ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); - AddLog_P2(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag); - } -#else // CFG_RESILIENT // Activated with version 8.4.0.2 - Fails to read any config before version 6.6.0.11 settings_location = 0; uint32_t save_flag = 0; @@ -637,7 +593,6 @@ void SettingsLoad(void) { ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); AddLog_P2(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag); } -#endif // CFG_RESILIENT #else // ESP32 SettingsRead(&Settings, sizeof(Settings)); AddLog_P2(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded, " D_COUNT " %lu"), Settings.save_flag); @@ -1179,192 +1134,6 @@ void SettingsDelta(void) if (Settings.version != VERSION) { // Fix version dependent changes #ifdef ESP8266 -#ifdef CFG_LEGACY_LOAD - if (Settings.version < 0x06000000) { - Settings.cfg_size = sizeof(Settings); - Settings.cfg_crc = GetSettingsCrc(); - } - if (Settings.version < 0x06000002) { - for (uint32_t i = 0; i < MAX_SWITCHES; i++) { - if (i < 4) { - Settings.switchmode[i] = Settings.interlock[i]; - } else { - Settings.switchmode[i] = SWITCH_MODE; - } - } - for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { - if (Settings.ex_my_gp8.io[i] >= GPI8_SWT5) { // Move up from GPI8_SWT5 to GPI8_KEY1 - Settings.ex_my_gp8.io[i] += 4; - } - } - } - if (Settings.version < 0x06000003) { - Settings.flag.mqtt_serial_raw = 0; // Was rules_enabled until 5.14.0b - Settings.flag.pressure_conversion = 0; // Was rules_once until 5.14.0b - Settings.flag3.data = 0; - } - if (Settings.version < 0x06010103) { - Settings.flag3.timers_enable = 1; - } - if (Settings.version < 0x0601010C) { - Settings.button_debounce = KEY_DEBOUNCE_TIME; - Settings.switch_debounce = SWITCH_DEBOUNCE_TIME; - } - if (Settings.version < 0x0602010A) { - for (uint32_t j = 0; j < 5; j++) { - Settings.rgbwwTable[j] = 255; - } - } - if (Settings.version < 0x06030002) { - Settings.timezone_minutes = 0; - } - if (Settings.version < 0x06030004) { - memset(&Settings.monitors, 0xFF, 20); // Enable all possible monitors, displays and sensors - } - if (Settings.version < 0x0603000E) { - Settings.flag2.calc_resolution = CALC_RESOLUTION; - } - if (Settings.version < 0x0603000F) { - if (Settings.sleep < 50) { - Settings.sleep = 50; // Default to 50 for sleep, for now - } - } - if (Settings.version < 0x06040105) { - Settings.flag3.mdns_enabled = MDNS_ENABLED; - Settings.param[P_MDNS_DELAYED_START] = 0; - } - if (Settings.version < 0x0604010B) { - Settings.flag.interlock = APP_INTERLOCK_MODE; - Settings.interlock[0] = APP_INTERLOCK_GROUP_1; - Settings.interlock[1] = APP_INTERLOCK_GROUP_2; - Settings.interlock[2] = APP_INTERLOCK_GROUP_3; - Settings.interlock[3] = APP_INTERLOCK_GROUP_4; - } - if (Settings.version < 0x0604010D) { - Settings.param[P_BOOT_LOOP_OFFSET] = BOOT_LOOP_OFFSET; // SetOption36 - } - if (Settings.version < 0x06040110) { - ModuleDefault(WEMOS); - } - if (Settings.version < 0x06040113) { - Settings.param[P_RGB_REMAP] = RGB_REMAP_RGBW; - } - if (Settings.version < 0x06050003) { - Settings.novasds_startingoffset = STARTING_OFFSET; - } - if (Settings.version < 0x06050006) { - SettingsDefaultWebColor(); - } - if (Settings.version < 0x06050007) { - Settings.ledmask = APP_LEDMASK; - } - if (Settings.version < 0x0605000A) { - Settings.ex_my_adc0 = GPIO_NONE; - } - if (Settings.version < 0x0605000D) { - Settings.param[P_IR_UNKNOW_THRESHOLD] = IR_RCV_MIN_UNKNOWN_SIZE; - } - if (Settings.version < 0x06060001) { - Settings.param[P_OVER_TEMP] = ENERGY_OVERTEMP; - } - if (Settings.version < 0x06060007) { - memset((char*)&Settings +0xE00, 0x00, sizeof(Settings) -0xE00); - } - if (Settings.version < 0x06060008) { - // Move current tuya dimmer range to the new param. - if (Settings.flag3.tuya_serial_mqtt_publish) { // ex Settings.flag3.ex_tuya_dimmer_range_255 SetOption - Settings.param[P_ex_DIMMER_MAX] = 100; - } else { - Settings.param[P_ex_DIMMER_MAX] = 255; - } - } - if (Settings.version < 0x06060009) { - Settings.baudrate = APP_BAUDRATE / 300; - Settings.sbaudrate = SOFT_BAUDRATE / 300; - } - if (Settings.version < 0x0606000A) { - uint8_t tuyaindex = 0; - if (Settings.param[P_BACKLOG_DELAY] > 0) { // ex SetOption34 - Settings.tuya_fnid_map[tuyaindex].fnid = 21; // TUYA_MCU_FUNC_DIMMER - Move Tuya Dimmer Id to Map - Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_BACKLOG_DELAY]; - tuyaindex++; - } else if (Settings.flag3.fast_power_cycle_disable == 1) { // ex SetOption65 - Settings.tuya_fnid_map[tuyaindex].fnid = 11; // TUYA_MCU_FUNC_REL1 - Create FnID for Switches - Settings.tuya_fnid_map[tuyaindex].dpid = 1; - tuyaindex++; - } - if (Settings.param[P_ARP_GRATUITOUS] > 0) { // Was P_ex_TUYA_RELAYS - for (uint8_t i = 0 ; i < Settings.param[P_ARP_GRATUITOUS]; i++) { // ex SetOption41 - Settings.tuya_fnid_map[tuyaindex].fnid = 12 + i; // TUYA_MCU_FUNC_REL2 - Create FnID for Switches - Settings.tuya_fnid_map[tuyaindex].dpid = i + 2; - tuyaindex++; - } - } - if (Settings.param[P_ex_TUYA_POWER_ID] > 0) { // ex SetOption46 - Settings.tuya_fnid_map[tuyaindex].fnid = 31; // TUYA_MCU_FUNC_POWER - Move Tuya Power Id to Map - Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_ex_TUYA_POWER_ID]; - tuyaindex++; - } - if (Settings.param[P_ex_TUYA_VOLTAGE_ID] > 0) { // ex SetOption44 - Settings.tuya_fnid_map[tuyaindex].fnid = 33; // TUYA_MCU_FUNC_VOLTAGE - Move Tuya Voltage Id to Map - Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_ex_TUYA_VOLTAGE_ID]; - tuyaindex++; - } - if (Settings.param[P_ex_TUYA_CURRENT_ID] > 0) { // ex SetOption45 - Settings.tuya_fnid_map[tuyaindex].fnid = 32; // TUYA_MCU_FUNC_CURRENT - Move Tuya Current Id to Map - Settings.tuya_fnid_map[tuyaindex].dpid = Settings.param[P_ex_TUYA_CURRENT_ID]; - } - } -#endif // CFG_LEGACY_LOAD - if (Settings.version < 0x0606000C) { - memset((char*)&Settings +0x1D6, 0x00, 16); - } - if (Settings.version < 0x0606000F) { - Settings.ex_shutter_accuracy = 0; - Settings.ex_mqttlog_level = MQTT_LOG_LEVEL; - } - if (Settings.version < 0x06060011) { - Settings.param[P_BACKLOG_DELAY] = MIN_BACKLOG_DELAY; - } - if (Settings.version < 0x06060012) { - Settings.dimmer_hw_min = DEFAULT_DIMMER_MIN; - Settings.dimmer_hw_max = DEFAULT_DIMMER_MAX; - if (TUYA_DIMMER == Settings.module) { - if (Settings.flag3.ex_tuya_dimmer_min_limit) { - Settings.dimmer_hw_min = 25; - } else { - Settings.dimmer_hw_min = 1; - } - Settings.dimmer_hw_max = Settings.param[P_ex_DIMMER_MAX]; - } - else if (PS_16_DZ == Settings.module) { - Settings.dimmer_hw_min = 10; - Settings.dimmer_hw_max = Settings.param[P_ex_DIMMER_MAX]; - } - } - if (Settings.version < 0x06060014) { - // Clear unused parameters for future use -/* - Settings.flag3.tuya_serial_mqtt_publish = 0; // ex Settings.flag3.ex_tuya_dimmer_range_255 - Settings.flag3.ex_tuya_dimmer_min_limit = 0; - Settings.param[P_ex_TUYA_RELAYS] = 0; - Settings.param[P_ex_DIMMER_MAX] = 0; - Settings.param[P_ex_TUYA_VOLTAGE_ID] = 0; - Settings.param[P_ex_TUYA_CURRENT_ID] = 0; - Settings.param[P_ex_TUYA_POWER_ID] = 0; - Settings.ex_baudrate = 0; - Settings.ex_sbaudrate = 0; -*/ - Settings.flag3.fast_power_cycle_disable = 0; - Settings.hass_new_discovery = Settings.tuyamcu_topic; // replaced ex2_energy_power_delta on 8.5.0.1 - Settings.tuyamcu_topic = 0; // replaced ex_energy_power_delta on 8.5.0.1 - } - if (Settings.version < 0x06060015) { - if ((EX_WIFI_SMARTCONFIG == Settings.ex_sta_config) || (EX_WIFI_WPSCONFIG == Settings.ex_sta_config)) { - Settings.ex_sta_config = WIFI_MANAGER; - } - } - if (Settings.version < 0x07000002) { Settings.web_color2[0][0] = Settings.web_color[0][0]; Settings.web_color2[0][1] = Settings.web_color[0][1]; From 2ffb04d4da890a3cacadc347f3c1cb0dd91dd251 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 18:24:44 +0200 Subject: [PATCH 11/17] Update comment --- tasmota/settings.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index 842444c03..a51372394 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -467,11 +467,11 @@ struct { uint8_t ws_width[3]; // 481 #ifdef ESP8266 - myio8 ex_my_gp8; // 484 - 17 bytes (ESP8266) - free once gpio16 is active + myio8 ex_my_gp8; // 484 - 17 bytes (ESP8266) - free since 9.0.0.1 #else // ESP32 uint8_t free_esp32_484[17]; // 484 #endif // ESP8266 - ESP32 - uint8_t ex_my_adc0; // 495 free once gpio16 is active + uint8_t ex_my_adc0; // 495 free since 9.0.0.1 uint16_t light_pixels; // 496 uint8_t light_color[5]; // 498 @@ -526,7 +526,7 @@ struct { char user_template_name[15]; // 720 15 bytes - Backward compatibility since v8.2.0.3 #ifdef ESP8266 - mytmplt8285 ex_user_template8; // 72F 14 bytes (ESP8266) - free once gpio16 is active + mytmplt8285 ex_user_template8; // 72F 14 bytes (ESP8266) - free since 9.0.0.1 #else // ESP32 uint8_t free_esp32_72f[14]; // 72F #endif // ESP8266 - ESP32 @@ -631,7 +631,7 @@ struct { uint16_t energy_power_delta[3]; // F44 uint16_t shutter_pwmrange[2][MAX_SHUTTERS]; // F4A - + uint8_t free_f5a[89]; // F5A - Decrement if adding new Setting variables just above and below // Only 32 bit boundary variables below From 539ba116902e9db3f2c45685e24dc353a9c66dfa Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Oct 2020 19:03:40 +0200 Subject: [PATCH 12/17] Add support for inverted NeoPixelBus data Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/my_user_config.h | 1 + tasmota/xlgt_01_ws2812.ino | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index a860f942f..46e203c81 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -79,3 +79,4 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) +- Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 7c107d184..d4296a9ee 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -20,6 +20,7 @@ - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) +- Add support for inverted NeoPixelBus data line by enabling ``#define USE_WS2812_INVERTED`` (#8988) ## Released diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 82eb7aa39..89fdd678d 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -474,6 +474,7 @@ // -- Optional light modules ---------------------- #define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem, 232 iram) - Disable by // // #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow +// #define USE_WS2812_INVERTED // Use inverted data signal #define USE_WS2812_HARDWARE NEO_HW_WS2812 // Hardware type (NEO_HW_WS2812, NEO_HW_WS2812X, NEO_HW_WS2813, NEO_HW_SK6812, NEO_HW_LC8812, NEO_HW_APA106) #define USE_WS2812_CTYPE NEO_GRB // Color type (NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_RGBW, NEO_GRBW) #define USE_MY92X1 // Add support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index 368567181..e22d090d4 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -63,7 +63,21 @@ void (* const Ws2812Command[])(void) PROGMEM = { #ifdef USE_WS2812_DMA +#ifdef USE_WS2812_INVERTED // See NeoEspDmaMethod.h for available options + +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) + typedef NeoEsp8266DmaInvertedWs2812xMethod selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) + typedef NeoEsp8266DmaInvertedSk6812Method selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_APA106) + typedef NeoEsp8266DmaInvertedApa106Method selectedNeoSpeedType; +#else // USE_WS2812_HARDWARE + typedef NeoEsp8266DmaInverted800KbpsMethod selectedNeoSpeedType; +#endif // USE_WS2812_HARDWARE + +#else // No USE_WS2812_INVERTED + #if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) typedef NeoEsp8266DmaWs2812xMethod selectedNeoSpeedType; #elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) @@ -74,9 +88,23 @@ void (* const Ws2812Command[])(void) PROGMEM = { typedef NeoEsp8266Dma800KbpsMethod selectedNeoSpeedType; #endif // USE_WS2812_HARDWARE -#else // USE_WS2812_DMA +#endif // No USE_WS2812_INVERTED +#else // No USE_WS2812_DMA + +#ifdef USE_WS2812_INVERTED // See NeoEspBitBangMethod.h for available options + +#if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) + typedef NeoEsp8266BitBangWs2812xInvertedMethod selectedNeoSpeedType; +#elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) + typedef NeoEsp8266BitBangSk6812InvertedMethod selectedNeoSpeedType; +#else // USE_WS2812_HARDWARE + typedef NeoEsp8266BitBang400KbpsInvertedMethod selectedNeoSpeedType; +#endif // USE_WS2812_HARDWARE + +#else // No USE_WS2812_INVERTED + #if (USE_WS2812_HARDWARE == NEO_HW_WS2812X) typedef NeoEsp8266BitBangWs2812xMethod selectedNeoSpeedType; #elif (USE_WS2812_HARDWARE == NEO_HW_SK6812) @@ -85,7 +113,9 @@ void (* const Ws2812Command[])(void) PROGMEM = { typedef NeoEsp8266BitBang800KbpsMethod selectedNeoSpeedType; #endif // USE_WS2812_HARDWARE -#endif // USE_WS2812_DMA +#endif // No USE_WS2812_INVERTED + +#endif // No USE_WS2812_DMA NeoPixelBus *strip = nullptr; From d5216091e7a6fbc1e6ab00f68cf376586a5106eb Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Mon, 5 Oct 2020 15:15:32 -0500 Subject: [PATCH 13/17] Add PWM Dimmer color change/trigger on tap and SO88 brightness led support. Add DGR WITH_LOCAL flag support. --- tasmota/support_command.ino | 2 +- tasmota/support_device_groups.ino | 8 +- tasmota/tasmota.h | 2 +- tasmota/xdrv_04_light.ino | 6 +- tasmota/xdrv_35_pwm_dimmer.ino | 331 +++++++++++++++--------------- 5 files changed, 179 insertions(+), 170 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 2bad15eb3..4272f70d5 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1999,7 +1999,7 @@ void CmndDevGroupSend(void) { uint8_t device_group_index = (XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0); if (device_group_index < device_group_count) { - if (!_SendDeviceGroupMessage(device_group_index, DGR_MSGTYPE_UPDATE_COMMAND)) { + if (!_SendDeviceGroupMessage(device_group_index, (DevGroupMessageType)(DGR_MSGTYPE_UPDATE_COMMAND + DGR_MSGTYPFLAG_WITH_LOCAL))) { ResponseCmndChar(XdrvMailbox.data); } } diff --git a/tasmota/support_device_groups.ino b/tasmota/support_device_groups.ino index 5aecd4359..510ba53f2 100644 --- a/tasmota/support_device_groups.ino +++ b/tasmota/support_device_groups.ino @@ -468,6 +468,10 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes // If the device group index is higher then the number of device groups, ignore this request. if (device_group_index >= device_group_count) return 0; + // Extract the flags from the message type. + bool with_local = ((message_type & DGR_MSGTYPFLAG_WITH_LOCAL) != 0); + message_type = (DevGroupMessageType)(message_type & 0x7F); + // If we're currently processing a remote device message, ignore this request. if (ignore_dgr_sends && message_type != DGR_MSGTYPE_UPDATE_COMMAND) return 0; @@ -723,8 +727,8 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, device_group->message_length, false); #ifdef USE_DEVICE_GROUPS_SEND - // If this is the DevGroupSend command, also handle the update locally. - if (message_type == DGR_MSGTYPE_UPDATE_COMMAND) { + // If requested, handle this updated locally as well. + if (with_local) { struct XDRVMAILBOX save_XdrvMailbox = XdrvMailbox; SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, device_group->message_length, true); XdrvMailbox = save_XdrvMailbox; diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 9fbaf6629..ba69c9b05 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -308,7 +308,7 @@ enum SettingsTextIndex { SET_OTAURL, #endif SET_MAX }; -enum DevGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYPE_UPDATE_COMMAND }; +enum DevGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYPE_UPDATE_COMMAND, DGR_MSGTYPFLAG_WITH_LOCAL = 128 }; enum DevGroupMessageFlag { DGR_FLAG_RESET = 1, DGR_FLAG_STATUS_REQUEST = 2, DGR_FLAG_FULL_STATUS = 4, DGR_FLAG_ACK = 8, DGR_FLAG_MORE_TO_COME = 16, DGR_FLAG_DIRECT = 32, DGR_FLAG_ANNOUNCEMENT = 64 }; diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index ffe346f5d..71edc6564 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -572,7 +572,7 @@ class LightStateClass { _briRGB = bri_rgb; if (bri_rgb > 0) { addRGBMode(); } #ifdef USE_PWM_DIMMER - if (PWM_DIMMER == my_module_type) PWMDimmerSetBrightnessLeds(0); + if (PWM_DIMMER == my_module_type) PWMDimmerSetBrightnessLeds(-1); #endif // USE_PWM_DIMMER return prev_bri; } @@ -583,7 +583,7 @@ class LightStateClass { _briCT = bri_ct; if (bri_ct > 0) { addCTMode(); } #ifdef USE_PWM_DIMMER - if (PWM_DIMMER == my_module_type) PWMDimmerSetBrightnessLeds(0); + if (PWM_DIMMER == my_module_type) PWMDimmerSetBrightnessLeds(-1); #endif // USE_PWM_DIMMER return prev_bri; } @@ -2409,7 +2409,7 @@ void LightHandleDevGroupItem(void) break; } #endif // !USE_LIGHT_PALETTE - value = value % MAX_FIXED_COLOR; + value = value % MAX_FIXED_COLOR + 1; if (value) { bool save_decimal_text = Settings.flag.decimal_text; char str[16]; diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index fc2de3034..c895cf67b 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -58,18 +58,18 @@ struct remote_pwm_dimmer { }; #endif // USE_PWM_DIMMER_REMOTE -uint32_t last_button_press_time; uint32_t button_hold_time[3]; uint8_t led_timeout_seconds = 0; uint8_t restore_powered_off_led_counter = 0; uint8_t power_button_index = 0; -uint8_t down_button_index = 1; uint8_t buttons_pressed = 0; -uint8_t tap_count = 0; +uint8_t local_fixed_color_index = 128; +bool ignore_power_button = false; +bool button_tapped = false; bool down_button_tapped = false; +bool tap_handled = false; bool power_button_increases_bri = true; bool invert_power_button_bri_direction = false; -bool restore_brightness_leds = false; bool button_pressed[3] = { false, false, false }; bool button_hold_sent[3]; bool button_hold_processed[3]; @@ -127,6 +127,7 @@ void PWMModulePreInit(void) active_remote_pwm_dimmer->bri_power_on = 128; active_remote_pwm_dimmer->bri_preset_low = 10; active_remote_pwm_dimmer->bri_preset_high = 255; + active_remote_pwm_dimmer->fixed_color_index = 128; } } } @@ -135,29 +136,30 @@ void PWMModulePreInit(void) #endif // USE_PWM_DIMMER_REMOTE } -// operation: 0 = normal, -1 = all off, 1 = all on -void PWMDimmerSetBrightnessLeds(int32_t operation) +// bri: -1 = set to current light bri, -2 = timeout, 0-255 = set to bri +void PWMDimmerSetBrightnessLeds(int32_t bri) { if (leds_present) { - uint32_t step = (!operation ? 256 / (leds_present + 1) : operation < 0 ? 256 : 0); - uint32_t current_bri = (Light.power ? light_state.getBri() : 0); + led_timeout_seconds = 5; + if (bri < 0) { + bri = ((bri == -2 && Settings.flag4.led_timeout) || !Light.power ? 0 : light_state.getBri()); + if (!bri || !Settings.flag4.led_timeout) led_timeout_seconds = 0; + } + uint32_t step = 256 / (leds_present + 1); uint32_t level = step; - SetLedPowerIdx(0, current_bri >= level); + SetLedPowerIdx(0, bri >= level); if (leds_present > 1) { level += step; - SetLedPowerIdx(1, current_bri >= level); + SetLedPowerIdx(1, bri >= level); if (leds_present > 2) { level += step; - SetLedPowerIdx(2, current_bri >= level); + SetLedPowerIdx(2, bri >= level); if (leds_present > 3) { level += step; - SetLedPowerIdx(3, current_bri >= level); + SetLedPowerIdx(3, bri >= level); } } } - - // If enabled, set the LED timeout. - if (!operation) led_timeout_seconds = (current_bri && Settings.flag4.led_timeout ? 5 : 0); } } @@ -174,7 +176,7 @@ void PWMDimmerSetPoweredOffLed(void) void PWMDimmerSetPower(void) { DigitalWrite(GPIO_REL1, 0, bitRead(rel_inverted, 0) ? !power : power); - PWMDimmerSetBrightnessLeds(0); + PWMDimmerSetBrightnessLeds(-1); PWMDimmerSetPoweredOffLed(); } @@ -272,23 +274,17 @@ void PWMDimmerHandleButton(void) * 3 1 2 */ - // If the button is not pressed and was not just released (the most common case), ... - if (XdrvMailbox.payload && !button_pressed[XdrvMailbox.index]) { - - // If no buttons have been pressed for 400ms, reset the button press counts. - if (last_button_press_time && !buttons_pressed && millis() - last_button_press_time > 400) { - last_button_press_time = 0; - tap_count = 0; - } - return; - } + // If the button is not pressed and was not just released (the most common case), just return. + if (XdrvMailbox.payload && !button_pressed[XdrvMailbox.index]) return; + bool handle_tap = false; bool state_updated = false; int32_t bri_offset = 0; uint8_t power_on_bri = 0; uint8_t dgr_item = 0; uint8_t dgr_value = 0; - uint8_t dgr_more_to_come = false; + uint8_t dgr_more_to_come = true; + uint8_t mqtt_trigger = 0; uint32_t button_index = XdrvMailbox.index; uint32_t now = millis(); @@ -300,7 +296,7 @@ void PWMDimmerHandleButton(void) bool power_is_on = power; bool is_power_button = !button_index; #endif // USE_PWM_DIMMER_REMOTE - bool is_down_button = (button_index == down_button_index); + bool is_down_button = (button_index == (power_button_index ? 0 : 1)); // If the button is pressed, ... if (!XdrvMailbox.payload) { @@ -308,10 +304,8 @@ void PWMDimmerHandleButton(void) // If the button was just pressed, flag the button as pressed, clear the hold sent flag and // increment the buttons pressed count. if (!button_pressed[button_index]) { - last_button_press_time = now; button_pressed[button_index] = true; button_hold_time[button_index] = now + Settings.param[P_HOLD_TIME] * 100; - button_hold_sent[button_index] = false; buttons_pressed++; #ifdef USE_PWM_DIMMER_REMOTE @@ -319,7 +313,6 @@ void PWMDimmerHandleButton(void) // associated with this button the device we're going to control. if (buttons_pressed == 1 && Settings.flag4.multiple_device_groups) { power_button_index = button_index; - down_button_index = (button_index ? 0 : 1); active_device_is_local = device_groups[power_button_index].local; if (!active_device_is_local) active_remote_pwm_dimmer = &remote_pwm_dimmers[power_button_index - 1]; } @@ -331,9 +324,9 @@ void PWMDimmerHandleButton(void) // If the button is being held, ... if (button_hold_time[button_index] < now) { - // If the power button is not also pressed and the button has been held for over 10 seconds, - // execute the WiFiConfig 2 command. - if (!button_pressed[power_button_index] && now - button_hold_time[button_index] > 10000) { + // If we're not in the middle of a power button plus up/down button sequence and the button + // has been held for over 10 seconds, execute the WiFiConfig 2 command. + if (!ignore_power_button && now - button_hold_time[button_index] > 10000) { button_hold_time[button_index] = now + 90000; char scmnd[20]; snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_WIFICONFIG " 2")); @@ -345,16 +338,15 @@ void PWMDimmerHandleButton(void) // rule), ignore the this button until it's released. if (!button_hold_sent[button_index]) { button_hold_sent[button_index] = true; - button_hold_processed[button_index] = (!is_power_button && tap_count ? false : SendKey(KEY_BUTTON, button_index + 1, POWER_HOLD)); + button_hold_processed[button_index] = (!is_power_button && button_tapped ? false : SendKey(KEY_BUTTON, button_index + 1, POWER_HOLD)); } if (!button_hold_processed[button_index]) { // If this is about the power button, ... if (is_power_button) { - // If no other buttons are pressed and the up or down button was not tapped while holding - // the power button before this, ... - if (buttons_pressed == 1 && !tap_count) { + // If we're not ignoring the power button and no other buttons are pressed, ... + if (!ignore_power_button && buttons_pressed == 1) { // If the power is on, adjust the brightness. Set the direction based on the current // direction for the device and then invert the direction when the power button is @@ -385,73 +377,28 @@ void PWMDimmerHandleButton(void) // If this is about the down or up buttons, ... else { - // If the power is on and the up or down button was not tapped while holding the power - // button before this, adjust the brightness. Set the direction based on which button is - // pressed. The new brightness will be calculated below. - if (power_is_on && !tap_count) { - bri_offset = (is_down_button ? -1 : 1); - } - - else { - uint8_t mqtt_trigger = 0; + // If the power button is also pressed, ... + if (button_pressed[power_button_index]) { // If the up or down button was tapped while holding the power button before this, - // handle the operation. - if (tap_count) { - - // Send a device group update to select the previous/next fixed color. - if (down_button_tapped) { -#ifdef USE_DEVICE_GROUPS - uint8_t uint8_value; -#ifdef USE_PWM_DIMMER_REMOTE - if (!active_device_is_local) - uint8_value = active_remote_pwm_dimmer->fixed_color_index; - else -#endif // USE_PWM_DIMMER_REMOTE - uint8_value = Light.fixed_color_index; - if (is_down_button) - uint8_value--; - else - uint8_value++; -#ifdef USE_PWM_DIMMER_REMOTE - if (!active_device_is_local) - active_remote_pwm_dimmer->fixed_color_index = uint8_value; - else -#endif // USE_PWM_DIMMER_REMOTE - Light.fixed_color_index = uint8_value; - dgr_item = DGR_ITEM_LIGHT_FIXED_COLOR; - dgr_value = uint8_value; - dgr_more_to_come = true; -#endif // USE_DEVICE_GROUPS - ; - } - - // Publish MQTT Event Trigger#. - else { - mqtt_trigger = (is_down_button ? 3 : 4); - } + // handle the operation below. + if (button_tapped) { + handle_tap = true; + button_hold_time[button_index] = now + 500; } - // If the power is not on, publish MQTT Event Trigger#. - else if (!power_is_on) { + // Otherwise, publish MQTT Event Trigger#. + else { mqtt_trigger = (is_down_button ? 1 : 2); + button_hold_time[button_index] = now + 60000; + ignore_power_button = true; } + } - // If we need to publish an MQTT trigger, do it. - if (mqtt_trigger) { - char topic[TOPSZ]; - sprintf_P(mqtt_data, PSTR("Trigger%u"), mqtt_trigger); -#ifdef USE_PWM_DIMMER_REMOTE - if (!active_device_is_local) { - snprintf_P(topic, sizeof(topic), PSTR("cmnd/%s/Event"), device_groups[power_button_index].group_name); - MqttPublish(topic); - } - else -#endif // USE_PWM_DIMMER_REMOTE - MqttPublishPrefixTopic_P(CMND, PSTR("Event")); - } - - button_hold_time[button_index] = now + 500; + // Otherwise, if the power is on, adjust the brightness. Set the direction based on which + // button is pressed. The new brightness will be calculated below. + else if (power_is_on && !button_tapped) { + bri_offset = (is_down_button ? -1 : 1); } } } @@ -461,16 +408,44 @@ void PWMDimmerHandleButton(void) // If the button was just released, ... else { bool button_was_held = button_hold_sent[button_index]; + button_hold_sent[button_index] = false; // If the button was not held, send a button toggle. If the button was held but not processes by // support_button or support_buttondoesn't process the toggle (is not handled by a rule), ... - if (!(button_hold_sent[button_index] ? button_hold_processed[button_index] : SendKey(KEY_BUTTON, button_index + 1, POWER_TOGGLE))) { + if (!(button_was_held ? button_hold_processed[button_index] : SendKey(KEY_BUTTON, button_index + 1, POWER_TOGGLE))) { // If this is about the power button, ... if (is_power_button) { - // If the power button was held, ... - if (button_was_held) { + // If the up or down button was tapped while the power button was held and the up or + // down buttons weren't tapped or held afterwards, handle the operation based on which + // button was tapped. + if (button_tapped) { + if (!tap_handled) { +#ifdef USE_PWM_DIMMER_REMOTE + if (active_device_is_local) { +#endif // USE_PWM_DIMMER_REMOTE + + // Toggle the powered-off LED option. + if (down_button_tapped) { + Settings.flag4.led_timeout ^= 1; + if (Light.power) PWMDimmerSetBrightnessLeds(Settings.flag4.led_timeout ? 0 : -1); + } + + // Toggle the LED timeout. + else { + Settings.flag4.powered_off_led ^= 1; + PWMDimmerSetPoweredOffLed(); + } +#ifdef USE_PWM_DIMMER_REMOTE + } +#endif // USE_PWM_DIMMER_REMOTE + } + tap_handled = false; + } + + // Otherwise, if the power button was held, ... + else if (button_was_held) { // If the power button was held with no other buttons pressed, we changed the brightness // so invert the bri direction for the next time and send a final update. @@ -487,44 +462,11 @@ void PWMDimmerHandleButton(void) state_updated = true; #endif // USE_PWM_DIMMER_REMOTE } - - // If the up or down button was tapped while the power button was held, ... - else if (tap_count) { - - // If the button was tapped but not held, handle the operation based on which button was - // tapped. - if (!button_was_held) { - -#ifdef USE_PWM_DIMMER_REMOTE - if (active_device_is_local) { -#endif // USE_PWM_DIMMER_REMOTE - - // Toggle the powered-off LED option. - if (down_button_tapped) { - Settings.flag4.led_timeout ^= 1; - if (Light.power) PWMDimmerSetBrightnessLeds(Settings.flag4.led_timeout ? -1 : 0); - } - - // Toggle the LED timeout. - else { - Settings.flag4.powered_off_led ^= 1; - PWMDimmerSetPoweredOffLed(); - } -#ifdef USE_PWM_DIMMER_REMOTE - } -#endif // USE_PWM_DIMMER_REMOTE - } - - // If the down button was tapped and held, we changed the fixed color. Send a final - // update. - else if (down_button_tapped) { - dgr_item = DGR_ITEM_FLAGS; - } - } } - // If the power button was not held, toggle the power. - else { + // If the power button was not held and we're not ignoring the next power button release, + // toggle the power. + else if (!ignore_power_button) { #ifdef USE_PWM_DIMMER_REMOTE if (!active_device_is_local) power_on_bri = active_remote_pwm_dimmer->bri_power_on; @@ -537,30 +479,34 @@ void PWMDimmerHandleButton(void) // If this is about the up or down buttons, ... else { - if (restore_brightness_leds) { - restore_brightness_leds = false; - PWMDimmerSetBrightnessLeds(Settings.flag4.led_timeout ? -1 : 0); + // If the power button is also pressed, set the flag to ignore the power button until it is + // released. + if (button_pressed[power_button_index]) { + ignore_power_button = true; + + // If the button was tapped, handle it below. + if (button_tapped) { + handle_tap = true; + } + + // Otherwise, if the button was not held, flag the tap. + else if (!button_was_held) { + button_tapped = true; + down_button_tapped = is_down_button; + } } - // If the button was not held and the power button is also pressed, increment the count of - // how many times the button has been tapped. - if (!button_was_held && button_pressed[power_button_index]) { - down_button_tapped = is_down_button; - tap_count++; - } - - // If the button wasn't tapped while the power button was pressed, ... - if (!tap_count) { + // If the power button is not also pressed, ... + else { // If the power is on, ... if (power_is_on) { // If the button was not held, adjust the brightness. Set the direction based on which // button is pressed. The new brightness will be calculated below. - if (button_hold_time[button_index] >= now) { + if (!button_was_held) { bri_offset = (is_down_button ? -1 : 1); - dgr_item = DGR_ITEM_FLAGS; - state_updated = true; + dgr_more_to_come = false; } // If the button was held and the hold was not processed by a rule, we changed the @@ -589,6 +535,10 @@ void PWMDimmerHandleButton(void) // Flag the button as released. button_pressed[button_index] = false; buttons_pressed--; + if (is_power_button) { + ignore_power_button = false; + button_tapped = false; + } } // If we need to adjust the brightness, do it. @@ -610,11 +560,13 @@ void PWMDimmerHandleButton(void) } if (new_bri != bri) { #ifdef USE_DEVICE_GROUPS - SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_ITEM_LIGHT_BRI, new_bri); + SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_BRI, new_bri); #endif // USE_DEVICE_GROUPS #ifdef USE_PWM_DIMMER_REMOTE - if (!active_device_is_local) + if (!active_device_is_local) { active_remote_pwm_dimmer->bri_power_on = active_remote_pwm_dimmer->bri = new_bri; + PWMDimmerSetBrightnessLeds(new_bri); + } else { #endif // USE_PWM_DIMMER_REMOTE skip_light_fade = true; @@ -632,12 +584,15 @@ void PWMDimmerHandleButton(void) } #endif // USE_PWM_DIMMER_REMOTE } - else { - PWMDimmerSetBrightnessLeds(0); - } +#ifdef USE_PWM_DIMMER_REMOTE + else if (!active_device_is_local) + PWMDimmerSetBrightnessLeds(new_bri); +#endif // USE_PWM_DIMMER_REMOTE + else + PWMDimmerSetBrightnessLeds(-1); } - // If we're supposed to toggle the power on, do it. + // If we need to toggle the power on, do it. else if (power_on_bri) { power_t new_power; #ifdef USE_DEVICE_GROUPS @@ -645,6 +600,7 @@ void PWMDimmerHandleButton(void) if (!active_device_is_local) { active_remote_pwm_dimmer->power_on ^= 1; new_power = active_remote_pwm_dimmer->power_on; + PWMDimmerSetBrightnessLeds(new_power ? -power_on_bri : 0); } else { #endif // USE_PWM_DIMMER_REMOTE @@ -664,18 +620,67 @@ void PWMDimmerHandleButton(void) else { #endif // USE_PWM_DIMMER_REMOTE light_state.setBri(power_on_bri); + Light.devgrp_no_channels_out = true; ExecuteCommandPower(1, POWER_TOGGLE, SRC_RETRY); + Light.devgrp_no_channels_out = false; #ifdef USE_PWM_DIMMER_REMOTE } #endif // USE_PWM_DIMMER_REMOTE } + // If the up or down button was tapped while holding the power button and the up or down button + // is being held or was just released after not being held, handle the operation. + if (handle_tap) { + ignore_power_button = tap_handled = true; + + // If the down button was tapped while holding the power button, send a device group update to + // select the previous/next fixed color. + if (down_button_tapped) { +#ifdef USE_DEVICE_GROUPS + int8_t add_value = (is_down_button ? -1 : 1); +#ifdef USE_PWM_DIMMER_REMOTE + if (!active_device_is_local) { + active_remote_pwm_dimmer->fixed_color_index += add_value; + dgr_value = active_remote_pwm_dimmer->fixed_color_index; + } + else { +#endif // USE_PWM_DIMMER_REMOTE + local_fixed_color_index += add_value; + dgr_value = local_fixed_color_index; +#ifdef USE_PWM_DIMMER_REMOTE + } +#endif // USE_PWM_DIMMER_REMOTE + dgr_item = DGR_ITEM_LIGHT_FIXED_COLOR; +#endif // USE_DEVICE_GROUPS + ; + } + // If the down button was tapped while holding the power button, publish an MQTT Event Trigger#. + else { + mqtt_trigger = (is_down_button ? 3 : 4); + } + } + + // If we need to publish an MQTT trigger, do it. + if (mqtt_trigger) { + char topic[TOPSZ]; + sprintf_P(mqtt_data, PSTR("Trigger%u"), mqtt_trigger); +#ifdef USE_PWM_DIMMER_REMOTE + if (!active_device_is_local) { + snprintf_P(topic, sizeof(topic), PSTR("cmnd/%s/Event"), device_groups[power_button_index].group_name); + MqttPublish(topic); + } + else +#endif // USE_PWM_DIMMER_REMOTE + MqttPublishPrefixTopic_P(CMND, PSTR("Event")); + } + // If we're not changing the brightness or toggling the power and we made changes, send a group // update. if (dgr_item) { #ifdef USE_DEVICE_GROUPS -AddLog_P2(LOG_LEVEL_ERROR, PSTR("PWMDimmer: sending DGR item %u"), dgr_item); - SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), dgr_item, dgr_value); + DevGroupMessageType message_type = DGR_MSGTYP_UPDATE_DIRECT; + if (handle_tap && active_device_is_local) message_type = (DevGroupMessageType)(message_type + DGR_MSGTYPFLAG_WITH_LOCAL); + SendDeviceGroupMessage(power_button_index, message_type, dgr_item, dgr_value); #endif // USE_DEVICE_GROUPS #ifdef USE_PWM_DIMMER_REMOTE if (active_device_is_local) { @@ -762,9 +767,9 @@ bool Xdrv35(uint8_t function) switch (function) { case FUNC_EVERY_SECOND: - // Turn off the brightness LED's if it's time. - if (led_timeout_seconds && !led_timeout_seconds--) { - PWMDimmerSetBrightnessLeds(-1); + // Turn off/restore the brightness LED's if it's time. + if (led_timeout_seconds && !--led_timeout_seconds) { + PWMDimmerSetBrightnessLeds(-2); } // The powered-off LED is also the LedLink LED. If we lose the WiFi or MQTT server connection, From 7a9e539f1cc69abe4237cc7fdad6402aadf558c2 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Mon, 5 Oct 2020 15:58:17 -0500 Subject: [PATCH 14/17] Wrap Light.devgrp_no_channels_out in #ifdef USE_DEVICE_GROUPS --- tasmota/xdrv_35_pwm_dimmer.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index c895cf67b..e26d60b3c 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -620,9 +620,13 @@ void PWMDimmerHandleButton(void) else { #endif // USE_PWM_DIMMER_REMOTE light_state.setBri(power_on_bri); +#ifdef USE_DEVICE_GROUPS Light.devgrp_no_channels_out = true; +#endif // USE_DEVICE_GROUPS ExecuteCommandPower(1, POWER_TOGGLE, SRC_RETRY); +#ifdef USE_DEVICE_GROUPS Light.devgrp_no_channels_out = false; +#endif // USE_DEVICE_GROUPS #ifdef USE_PWM_DIMMER_REMOTE } #endif // USE_PWM_DIMMER_REMOTE From 0c90f71e00c23b957a366e767c9e1f4c5f30d8d1 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 6 Oct 2020 12:12:14 +0200 Subject: [PATCH 15/17] Fix ADC initalization sequence Fix ADC initalization sequence (#9473) --- RELEASENOTES.md | 1 + tasmota/CHANGELOG.md | 1 + tasmota/support_tasmota.ino | 3 +++ tasmota/xsns_02_analog.ino | 2 +- tasmota/xsns_interface.ino | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 46e203c81..2f5ccd21a 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -76,6 +76,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Fix exception 28 due to device group buffer overflow (#9459) - Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) - Fix light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466) +- Fix ADC initalization sequence (#9473) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index d4296a9ee..81c7dfe55 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -17,6 +17,7 @@ - Fix exception 28 due to device group buffer overflow (#9459) - Fix shutter timing problem due to buffer overflow in calibration matrix (#9458) - Fix light wakeup exception 0 (divide by zero) when ``WakeupDuration`` is not initialised (#9466) +- Fix ADC initalization sequence (#9473) - Add optional support for Mitsubishi Electric HVAC by David Gwynne (#9237) - Add optional support for Orno WE517-Modbus energy meter by Maxime Vincent (#9353) - Add SDM630 three phase ImportActive Energy display when ``#define SDM630_IMPORT`` is enabled by Janusz Kostorz (#9124) diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 675e3fac8..801fcce4e 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1655,6 +1655,9 @@ void GpioInit(void) devices_present = 0; light_type = LT_BASIC; // Use basic PWM control if SetOption15 = 0 + + XsnsCall(FUNC_MODULE_INIT); + if (XdrvCall(FUNC_MODULE_INIT)) { // Serviced } diff --git a/tasmota/xsns_02_analog.ino b/tasmota/xsns_02_analog.ino index 8feca385e..09254d0a9 100644 --- a/tasmota/xsns_02_analog.ino +++ b/tasmota/xsns_02_analog.ino @@ -573,7 +573,7 @@ bool Xsns02(uint8_t function) { case FUNC_COMMAND: result = DecodeCommand(kAdcCommands, AdcCommand); break; - case FUNC_INIT: + case FUNC_MODULE_INIT: AdcInit(); break; default: diff --git a/tasmota/xsns_interface.ino b/tasmota/xsns_interface.ino index 0c85854de..4c4d273ea 100644 --- a/tasmota/xsns_interface.ino +++ b/tasmota/xsns_interface.ino @@ -924,6 +924,7 @@ bool XsnsCall(uint8_t Function) if (result && ((FUNC_COMMAND == Function) || (FUNC_PIN_STATE == Function) || + (FUNC_MODULE_INIT == Function) || (FUNC_COMMAND_SENSOR == Function) )) { break; From f9c75d885a6f8ea884b24a03972beba717161f76 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 6 Oct 2020 12:20:28 +0200 Subject: [PATCH 16/17] Refactor sensor init --- tasmota/xsns_interface.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/tasmota/xsns_interface.ino b/tasmota/xsns_interface.ino index 4c4d273ea..0c85854de 100644 --- a/tasmota/xsns_interface.ino +++ b/tasmota/xsns_interface.ino @@ -924,7 +924,6 @@ bool XsnsCall(uint8_t Function) if (result && ((FUNC_COMMAND == Function) || (FUNC_PIN_STATE == Function) || - (FUNC_MODULE_INIT == Function) || (FUNC_COMMAND_SENSOR == Function) )) { break; From 75b3cb7216e780bad264a483c2d66a4cfa353d73 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 6 Oct 2020 16:03:59 +0200 Subject: [PATCH 17/17] Platformio v.5.0 change All runtime Platformio build files are in folder `.pio` The entrys are left overs from Platformio before 5.x --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 16fb10282..f0bda9039 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,7 @@ ## Project files ###### .platformio -.pioenvs -.piolibdeps +.pio .clang_complete .gcc-flags.json .cache