Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 output Flash resolution #815

Merged
merged 15 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 121 additions & 11 deletions html/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var StatusRequestTimer = null;
var DiagTimer = null;
var ConfigSessionId = new Date().getTime();

// global data
var AdminInfo = null;
Expand All @@ -23,6 +24,111 @@ var ctx = canvas.getContext("2d");
ctx.font = "20px Arial";
ctx.textAlign = "center";

const rssiToPercent =
[
/* -100 */ 0,
/* -99 */ 0,
/* -98 */ 0,
/* -97 */ 0,
/* -96 */ 0,
/* -95 */ 0,
/* -94 */ 4,
/* -93 */ 6,
/* -92 */ 8,
/* -91 */ 11,
/* -90 */ 13,
/* -89 */ 15,
/* -88 */ 17,
/* -87 */ 19,
/* -86 */ 21,
/* -85 */ 23,
/* -84 */ 26,
/* -83 */ 28,
/* -82 */ 30,
/* -81 */ 32,
/* -80 */ 34,
/* -79 */ 35,
/* -78 */ 37,
/* -77 */ 39,
/* -76 */ 41,
/* -75 */ 43,
/* -74 */ 45,
/* -73 */ 46,
/* -72 */ 48,
/* -71 */ 50,
/* -70 */ 52,
/* -69 */ 53,
/* -68 */ 55,
/* -67 */ 56,
/* -66 */ 58,
/* -65 */ 59,
/* -64 */ 61,
/* -63 */ 62,
/* -62 */ 64,
/* -61 */ 65,
/* -60 */ 67,
/* -59 */ 68,
/* -58 */ 69,
/* -57 */ 71,
/* -56 */ 72,
/* -55 */ 73,
/* -54 */ 75,
/* -53 */ 76,
/* -52 */ 77,
/* -51 */ 78,
/* -50 */ 79,
/* -49 */ 80,
/* -48 */ 81,
/* -47 */ 82,
/* -46 */ 83,
/* -45 */ 84,
/* -44 */ 85,
/* -43 */ 86,
/* -42 */ 87,
/* -41 */ 88,
/* -40 */ 89,
/* -39 */ 90,
/* -38 */ 90,
/* -37 */ 91,
/* -36 */ 92,
/* -35 */ 93,
/* -34 */ 93,
/* -33 */ 94,
/* -32 */ 95,
/* -31 */ 95,
/* -30 */ 96,
/* -29 */ 96,
/* -28 */ 97,
/* -27 */ 97,
/* -26 */ 98,
/* -25 */ 98,
/* -24 */ 99,
/* -23 */ 99,
/* -22 */ 99,
/* -21 */ 100,
/* -20 */ 100,
/* -19 */ 100,
/* -18 */ 100,
/* -17 */ 100,
/* -16 */ 100,
/* -15 */ 100,
/* -14 */ 100,
/* -13 */ 100,
/* -12 */ 100,
/* -11 */ 100,
/* -10 */ 100,
/* -9 */ 100,
/* -8 */ 100,
/* -7 */ 100,
/* -6 */ 100,
/* -5 */ 100,
/* -4 */ 100,
/* -3 */ 100,
/* -2 */ 100,
/* -1 */ 100,
/* 0 */ 100,
];

// Default modal properties
$.fn.modal.Constructor.DEFAULTS.backdrop = 'static';
$.fn.modal.Constructor.DEFAULTS.keyboard = false;
Expand Down Expand Up @@ -267,7 +373,7 @@ $(function () {

let DeltaTime = (new Date().getTime() - FseqFileTransferStartTime.getTime()) / 1000;
let rate = Math.floor((file.size / DeltaTime) / 1000);
console.debug("Final Transfer Rate: " + rate + "KBps");
// console.debug("Final Transfer Rate: " + rate + "KBps");
});

this.on('addedfile', function (file, resp) {
Expand Down Expand Up @@ -442,7 +548,7 @@ function MergeConfigTree(SourceTree, TargetTree, CurrentTarget, FullSelector)

if(CurrentElementValue === undefined)
{
console.info("target element is not properly formed");
console.error("target element is not properly formed");
continue;
}

Expand All @@ -468,7 +574,7 @@ function MergeConfigTree(SourceTree, TargetTree, CurrentTarget, FullSelector)
}
else
{
console.info("NOT Saving CurrentElement. Source value is Not in target tree.");
console.error("NOT Saving CurrentElement. Source value is Not in target tree.");
}
}
}
Expand Down Expand Up @@ -616,7 +722,9 @@ async function RequestConfigFile(FileName)
{
// console.log("RequestConfigFile FileName: " + FileName);

await $.getJSON("HTTP://" + target + "/conf/" + FileName, function(data)
var url = "HTTP://" + target + "/conf/" + FileName + '?t=' + ConfigSessionId;
// console.info("'GET' Config URL: '" + url + "'");
await $.getJSON(url, function(data)
{
// console.log("RequestConfigFile: " + JSON.stringify(data));
ProcessReceivedJsonConfigMessage(data);
Expand Down Expand Up @@ -1742,21 +1850,21 @@ function hexToRgb(hex) {

function ExtractConfigFromHtmlPages(elementids, modeControlName, ChannelConfig)
{
console.info("Preping config to send to ESP");
console.info("num elementids: " + elementids.length);
// console.debug("Preping config to send to ESP");
// console.debug("num elementids: " + elementids.length);

elementids.forEach(function (elementid)
{
let SelectedElement = modeControlName + ' #' + elementid;
console.info("Element ID: " + $(SelectedElement).id)
// console.debug("Element ID: " + $(SelectedElement).id)

if ($(SelectedElement).is(':checkbox'))
{
ChannelConfig[elementid] = $(SelectedElement).prop('checked');
}
else if ($(SelectedElement).attr('type') === 'number')
{
console.info("Found Number: " + $(SelectedElement).id)
// console.debug("Found Number: " + $(SelectedElement).id)
ChannelConfig[elementid] = parseInt($(SelectedElement).val());
}
else
Expand Down Expand Up @@ -1805,6 +1913,7 @@ function submitDeviceConfig() {

ExtractChannelConfigFromHtmlPage(Output_Config.channels, "output");

ConfigSessionId = new Date().getTime();
ServerAccess.callFunction(SendConfigFileToServer, "output_config", JSON.stringify({'output_config': Output_Config}));
ServerAccess.callFunction(SendConfigFileToServer, "input_config", JSON.stringify({'input_config': Input_Config}));
submitNetworkConfig();
Expand Down Expand Up @@ -1930,19 +2039,19 @@ function ProcessReceivedJsonStatusMessage(JsonStat) {
let Ethernet = Network.wifi;

let rssi = Wifi.rssi;
let quality = 2 * (rssi + 100);
let quality = rssi + 100;

if (rssi <= -100) {
quality = 0;
}
else if (rssi >= -50) {
else if (rssi >= 0) {
quality = 100;
}

$('#w_connected').text((true === Wifi.connected) ? "Yes" : "No");
$('#w_hostname').text(Wifi.hostname);
$('#w_rssi').text(rssi);
$('#w_quality').text(quality);
$('#w_quality').text(rssiToPercent[quality]);
$('#w_ssid').text(Wifi.ssid);
$('#w_ip').text(Wifi.ip);
$('#w_subnet').text(Wifi.subnet);
Expand Down Expand Up @@ -2222,4 +2331,5 @@ function reboot() {
$('#confirm-reset .btn-ok').on("click", (function () {
showReboot();
SendCommand('X7');
ConfigSessionId = new Date().getTime();
}));
3 changes: 1 addition & 2 deletions include/output/OutputAPA102Spi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputAPA102Spi.h - APA102 driver code for ESPixelStick Spi Channel
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2022 Shelby Merrick
* Copyright (c) 2015, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -46,7 +46,6 @@ class c_OutputAPA102Spi : public c_OutputAPA102
#if defined(ARDUINO_ARCH_ESP32)
bool RmtPoll () {return false;}
#endif // defined(ARDUINO_ARCH_ESP32)
void PauseOutput () {};

private:

Expand Down
5 changes: 4 additions & 1 deletion include/output/OutputCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ class c_OutputCommon
virtual void SetOutputBufferSize (uint32_t NewOutputBufferSize) { OutputBufferSize = NewOutputBufferSize; };
virtual uint32_t GetNumOutputBufferBytesNeeded () = 0;
virtual uint32_t GetNumOutputBufferChannelsServiced () = 0;
virtual void PauseOutput (bool State) {}
virtual void PauseOutput (bool NewState) {Paused = NewState;}
virtual void ClearBuffer ();
virtual void WriteChannelData (uint32_t StartChannelId, uint32_t ChannelCount, byte *pSourceData);
virtual void ReadChannelData (uint32_t StartChannelId, uint32_t ChannelCount, byte *pTargetData);
virtual bool ValidateGpio (gpio_num_t ConsoleTxGpio, gpio_num_t ConsoleRxGpio);
virtual bool DriverIsSendingIntensityData() {return false;}
virtual uint32_t GetFrameTimeMs() {return 1 + (ActualFrameDurationMicroSec / 1000); }
bool IsPaused() {return Paused;}

protected:

gpio_num_t DataPin = gpio_num_t (-1);
Expand All @@ -78,6 +80,7 @@ class c_OutputCommon
uint8_t * pOutputBuffer = nullptr;
uint32_t OutputBufferSize = 0;
uint32_t FrameCount = 0;
bool Paused = false;

virtual void ReportNewFrame ();

Expand Down
3 changes: 2 additions & 1 deletion include/output/OutputGECERmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputGECERmt.h - GECE driver code for ESPixelStick RMT Channel
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2022 Shelby Merrick
* Copyright (c) 2015, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -46,6 +46,7 @@ class c_OutputGECERmt : public c_OutputGECE
#endif // defined(ARDUINO_ARCH_ESP32)
void GetStatus (ArduinoJson::JsonObject& jsonStatus);
void SetOutputBufferSize (uint32_t NumChannelsAvailable);
void PauseOutput (bool State);

private:

Expand Down
3 changes: 2 additions & 1 deletion include/output/OutputGS8208Rmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputGS8208Rmt.h - GS8208 driver code for ESPixelStick RMT Channel
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2022 Shelby Merrick
* Copyright (c) 2015, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -47,6 +47,7 @@ class c_OutputGS8208Rmt : public c_OutputGS8208
#endif // defined(ARDUINO_ARCH_ESP32)
void GetStatus (ArduinoJson::JsonObject& jsonStatus);
void SetOutputBufferSize (uint32_t NumChannelsAvailable);
void PauseOutput (bool State);

private:

Expand Down
3 changes: 1 addition & 2 deletions include/output/OutputGrinchSpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputGrinchSpi.h - GRINCH driver code for ESPixelStick Spi Channel
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2024 Shelby Merrick
* Copyright (c) 2015, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -45,7 +45,6 @@ class c_OutputGrinchSpi : public c_OutputGrinch
#if defined(ARDUINO_ARCH_ESP32)
bool RmtPoll () {return false;}
#endif // defined(ARDUINO_ARCH_ESP32)
void PauseOutput () {};

private:

Expand Down
8 changes: 4 additions & 4 deletions include/output/OutputRmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class c_OutputRmt
uint32_t NumRmtSlotOverruns = 0;
uint32_t MaxNumRmtSlotsPerInterrupt = (NUM_RMT_SLOTS/2);

rmt_item32_t SendBuffer[NUM_RMT_SLOTS];
rmt_item32_t SendBuffer[NUM_RMT_SLOTS * 2];
uint32_t RmtBufferWriteIndex = 0;
uint32_t SendBufferWriteIndex = 0;
uint32_t SendBufferReadIndex = 0;
Expand All @@ -109,7 +109,7 @@ class c_OutputRmt
uint32_t TxIntensityDataStartingMask = 0x80;
RmtDataBitIdType_t InterIntensityValueId = RMT_INVALID_VALUE;

inline void IRAM_ATTR ISR_TransferIntensityDataToRMT ();
inline void IRAM_ATTR ISR_TransferIntensityDataToRMT (uint32_t NumEntriesToTransfer);
inline void IRAM_ATTR ISR_CreateIntensityData ();
inline void IRAM_ATTR ISR_WriteToBuffer(uint32_t value);
inline bool IRAM_ATTR ISR_MoreDataToSend();
Expand All @@ -129,7 +129,7 @@ class c_OutputRmt

void Begin (OutputRmtConfig_t config, c_OutputCommon * pParent);
bool StartNewFrame ();
bool StartNextFrame () { return (pParent) ? pParent->RmtPoll() : false; }
bool StartNextFrame () { return ((nullptr != pParent) & (!OutputIsPaused)) ? pParent->RmtPoll() : false; }
void GetStatus (ArduinoJson::JsonObject& jsonStatus);
void set_pin (gpio_num_t _DataPin) { OutputRmtConfig.DataPin = _DataPin; rmt_set_gpio (OutputRmtConfig.RmtChannelId, rmt_mode_t::RMT_MODE_TX, OutputRmtConfig.DataPin, false); }
void PauseOutput (bool State);
Expand Down Expand Up @@ -164,7 +164,6 @@ class c_OutputRmt
uint32_t DataTaskcounter = 0;
uint32_t ISRcounter = 0;
uint32_t FrameStartCounter = 0;
uint32_t FrameEndISRcounter = 0;
uint32_t SendBlockIsrCounter = 0;
uint32_t RanOutOfData = 0;
uint32_t UnknownISRcounter = 0;
Expand All @@ -181,6 +180,7 @@ class c_OutputRmt
uint32_t RmtEntriesTransfered = 0;
uint32_t RmtXmtFills = 0;
uint32_t RmtWhiteDetected = 0;
uint32_t FailedToSendAllData = 0;

#define RMT_DEBUG_COUNTER(p) p

Expand Down
4 changes: 2 additions & 2 deletions include/output/OutputSerialRmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputSerialRmt.h - WS2811 driver code for ESPixelStick RMT Channel
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2015, 2022 Shelby Merrick
* Copyright (c) 2015, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -44,7 +44,7 @@ class c_OutputSerialRmt : public c_OutputSerial
bool RmtPoll ();
void GetStatus (ArduinoJson::JsonObject& jsonStatus);
void SetOutputBufferSize (uint32_t NumChannelsAvailable);
void PauseOutput(bool State) {Rmt.PauseOutput(State);}
void PauseOutput(bool State);

private:
void SetUpRmtBitTimes();
Expand Down
3 changes: 2 additions & 1 deletion include/output/OutputSerialUart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/******************************************************************
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel (And Serial!) driver
* Orginal ESPixelStickproject by 2015 Shelby Merrick
* Orginal ESPixelStickproject by 2015 - 2025 Shelby Merrick
*
*This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
This program is distributed in the hope that it will be useful,
Expand Down Expand Up @@ -47,6 +47,7 @@ class c_OutputSerialUart : public c_OutputSerial
#if defined(ARDUINO_ARCH_ESP32)
bool RmtPoll () {return false;}
#endif // defined(ARDUINO_ARCH_ESP32)
void PauseOutput (bool NewState);

private:
c_OutputUart Uart;
Expand Down
Loading
Loading