Debug for analog pin.

Minor tweaks.
This commit is contained in:
Blaz Kristan 2021-02-28 22:54:30 +01:00
parent 847178b7be
commit bd7671c07e
5 changed files with 840 additions and 808 deletions

View File

@ -2506,7 +2506,6 @@ uint16_t WS2812FX::mode_spots_fade()
//each needs 12 bytes //each needs 12 bytes
//Spark type is used for popcorn and 1D fireworks
typedef struct Ball { typedef struct Ball {
unsigned long lastBounceTime; unsigned long lastBounceTime;
float impactVelocity; float impactVelocity;
@ -2635,7 +2634,7 @@ uint16_t WS2812FX::mode_glitter()
//each needs 12 bytes //each needs 11 bytes
//Spark type is used for popcorn, 1D fireworks, and drip //Spark type is used for popcorn, 1D fireworks, and drip
typedef struct Spark { typedef struct Spark {
float pos; float pos;

View File

@ -294,19 +294,19 @@ class WS2812FX {
{ {
return ((options >> n) & 0x01); return ((options >> n) & 0x01);
} }
bool isSelected() inline bool isSelected()
{ {
return getOption(0); return getOption(0);
} }
bool isActive() inline bool isActive()
{ {
return stop > start; return stop > start;
} }
uint16_t length() inline uint16_t length()
{ {
return stop - start; return stop - start;
} }
uint16_t groupLength() inline uint16_t groupLength()
{ {
return grouping + spacing; return grouping + spacing;
} }
@ -366,7 +366,7 @@ class WS2812FX {
* the internal segment state should be reset. * the internal segment state should be reset.
* Call resetIfRequired before calling the next effect function. * Call resetIfRequired before calling the next effect function.
*/ */
void reset() { _requiresReset = true; } inline void reset() { _requiresReset = true; }
private: private:
uint16_t _dataLen = 0; uint16_t _dataLen = 0;
bool _requiresReset = false; bool _requiresReset = false;

View File

@ -212,6 +212,11 @@ class BusPwm : public Bus {
if (!IS_PWM(bc.type)) return; if (!IS_PWM(bc.type)) return;
uint8_t numPins = NUM_PWM_PINS(bc.type); uint8_t numPins = NUM_PWM_PINS(bc.type);
#ifdef WLED_DEBUG
Serial.print(F("Init: Number of pins="));
Serial.println(numPins);
#endif
#ifdef ESP8266 #ifdef ESP8266
analogWriteRange(255); //same range as one RGB channel analogWriteRange(255); //same range as one RGB channel
analogWriteFreq(WLED_PWM_FREQ); analogWriteFreq(WLED_PWM_FREQ);
@ -224,9 +229,21 @@ class BusPwm : public Bus {
for (uint8_t i = 0; i < numPins; i++) { for (uint8_t i = 0; i < numPins; i++) {
_pins[i] = bc.pins[i]; _pins[i] = bc.pins[i];
#ifdef WLED_DEBUG
Serial.print(F("Init: Allocating pin #"));
Serial.println(i);
#endif
if (!pinManager.allocatePin(_pins[i])) { if (!pinManager.allocatePin(_pins[i])) {
#ifdef WLED_DEBUG
Serial.print(F("Init: Wooooow!!!! Allocation failed for pin="));
Serial.println(_pins[i]);
#endif
deallocatePins(); return; deallocatePins(); return;
} }
#ifdef WLED_DEBUG
Serial.print(F("Init: Allocation successful for pin="));
Serial.println(bc.pins[i]);
#endif
#ifdef ESP8266 #ifdef ESP8266
pinMode(_pins[i], OUTPUT); pinMode(_pins[i], OUTPUT);
#else #else
@ -281,7 +298,13 @@ class BusPwm : public Bus {
uint8_t getPins(uint8_t* pinArray) { uint8_t getPins(uint8_t* pinArray) {
uint8_t numPins = NUM_PWM_PINS(_type); uint8_t numPins = NUM_PWM_PINS(_type);
for (uint8_t i = 0; i < numPins; i++) pinArray[i] = _pins[i]; for (uint8_t i = 0; i < numPins; i++) {
#ifdef WLED_DEBUG
Serial.print(F("Getting pin="));
Serial.println(_pins[i]);
#endif
pinArray[i] = _pins[i];
}
return numPins; return numPins;
} }
@ -302,14 +325,26 @@ class BusPwm : public Bus {
void deallocatePins() { void deallocatePins() {
uint8_t numPins = NUM_PWM_PINS(_type); uint8_t numPins = NUM_PWM_PINS(_type);
#ifdef WLED_DEBUG
Serial.print(F("DeAllocating pin "));
Serial.println(numPins);
#endif
for (uint8_t i = 0; i < numPins; i++) { for (uint8_t i = 0; i < numPins; i++) {
if (!pinManager.isPinOk(_pins[i])) continue; if (!pinManager.isPinOk(_pins[i])) continue;
#ifdef WLED_DEBUG
Serial.print(F("DeAllocating pin #"));
Serial.println(i);
#endif
#ifdef ESP8266 #ifdef ESP8266
digitalWrite(_pins[i], LOW); //turn off PWM interrupt digitalWrite(_pins[i], LOW); //turn off PWM interrupt
#else #else
if (_ledcStart < 16) ledcDetachPin(_pins[i]); if (_ledcStart < 16) ledcDetachPin(_pins[i]);
#endif #endif
pinManager.deallocatePin(_pins[i]); pinManager.deallocatePin(_pins[i]);
#ifdef WLED_DEBUG
Serial.print(F("DeAllocatied pin="));
Serial.println(_pins[i]);
#endif
} }
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
pinManager.deallocateLedc(_ledcStart, numPins); pinManager.deallocateLedc(_ledcStart, numPins);

View File

@ -919,11 +919,11 @@ function updateUI(scrollto=false)
function updateSelectedPalette(scrollto=false) function updateSelectedPalette(scrollto=false)
{ {
var parent = d.getElementById('selectPalette'); var parent = d.getElementById('selectPalette');
var selectedPalette = parent.querySelector(`input[name="palette"][value="${selectedPal}"]`); var selectedPaletteInput = parent.querySelector(`input[name="palette"][value="${selectedPal}"]`);
if (selectedPalette) { if (selectedPaletteInput) {
selectedPalette.checked = true; selectedPaletteInput.checked = true;
} }
selElement = parent.querySelector('.selected'); var selElement = parent.querySelector('.selected');
if (selElement) { if (selElement) {
selElement.classList.remove('selected') selElement.classList.remove('selected')
} }
@ -947,7 +947,7 @@ function updateSelectedFx(scrollto=false)
var selectedEffectInput = parent.querySelector(`input[name="fx"][value="${selectedFx}"]`); var selectedEffectInput = parent.querySelector(`input[name="fx"][value="${selectedFx}"]`);
if (selectedEffectInput) { if (selectedEffectInput) {
parent.querySelector(`input[name="fx"][value="${selectedFx}"]`).checked = true; selectedEffectInput.checked = true;
} }
var selElement = parent.querySelector('.selected'); var selElement = parent.querySelector('.selected');
if (selElement) { if (selElement) {
@ -999,7 +999,6 @@ function requestJson(command, rinfo = true, verbose = true, callback = null) {
command.v = verbose; command.v = verbose;
command.time = Math.floor(Date.now() / 1000); command.time = Math.floor(Date.now() / 1000);
req = JSON.stringify(command); req = JSON.stringify(command);
//console.log(req);
} }
fetch fetch
(url, { (url, {

File diff suppressed because it is too large Load Diff