Skip to content

Commit

Permalink
whitespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek committed Jan 6, 2023
1 parent 98be19b commit 506b6b5
Show file tree
Hide file tree
Showing 40 changed files with 328 additions and 326 deletions.
12 changes: 6 additions & 6 deletions wled00/alexa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* Alexa Voice On/Off/Brightness/Color Control. Emulates a Philips Hue bridge to Alexa.
*
*
* This was put together from these two excellent projects:
* https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch
* https://github.com/probonopd/ESP8266HueEmulator
Expand All @@ -21,11 +21,11 @@ void alexaInit()
espalexaDevice = new EspalexaDevice(alexaInvocationName, onAlexaChange, EspalexaDeviceType::extendedcolor);
espalexa.addDevice(espalexaDevice);

// up to 9 devices (added second, third, ... i.e. index 1 to 9) serve for switching on up to nine presets (preset IDs 1 to 9 in WLED),
// up to 9 devices (added second, third, ... i.e. index 1 to 9) serve for switching on up to nine presets (preset IDs 1 to 9 in WLED),
// names are identical as the preset names, switching off can be done by switching off any of them
if (alexaNumPresets) {
String name = "";
for (byte presetIndex = 1; presetIndex <= alexaNumPresets; presetIndex++)
for (byte presetIndex = 1; presetIndex <= alexaNumPresets; presetIndex++)
{
if (!getPresetName(presetIndex, name)) break; // no more presets
EspalexaDevice* dev = new EspalexaDevice(name.c_str(), onAlexaChange, EspalexaDeviceType::extendedcolor);
Expand All @@ -44,7 +44,7 @@ void handleAlexa()
void onAlexaChange(EspalexaDevice* dev)
{
EspalexaDeviceProperty m = dev->getLastChangedProperty();

if (m == EspalexaDeviceProperty::on)
{
if (dev->getId() == 0) // Device 0 is for on/off or macros
Expand All @@ -56,7 +56,7 @@ void onAlexaChange(EspalexaDevice* dev)
bri = briLast;
stateUpdated(CALL_MODE_ALEXA);
}
} else
} else
{
applyPreset(macroAlexaOn, CALL_MODE_ALEXA);
if (bri == 0) dev->setValue(briLast); //stop Alexa from complaining if macroAlexaOn does not actually turn on
Expand All @@ -82,7 +82,7 @@ void onAlexaChange(EspalexaDevice* dev)
bri = 0;
stateUpdated(CALL_MODE_ALEXA);
}
} else
} else
{
applyPreset(macroAlexaOff, CALL_MODE_ALEXA);
// below for loop stops Alexa from complaining if macroAlexaOff does not actually turn off
Expand Down
12 changes: 6 additions & 6 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class Bus {
static uint8_t _gAWM; // definition in FX_fcn.cpp
static int16_t _cct; // definition in FX_fcn.cpp
static uint8_t _cctBlend; // definition in FX_fcn.cpp

uint32_t autoWhiteCalc(uint32_t c) {
uint8_t aWM = _autoWhiteMode;
if (_gAWM < 255) aWM = _gAWM;
Expand Down Expand Up @@ -271,7 +271,7 @@ class BusDigital : public Bus {
//Fix for turning off onboard LED breaking bus
#ifdef LED_BUILTIN
if (_bri == 0 && b > 0) {
if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN) PolyBus::begin(_busPtr, _iType, _pins);
if (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN) PolyBus::begin(_busPtr, _iType, _pins);
}
#endif
Bus::setBrightness(b);
Expand Down Expand Up @@ -343,7 +343,7 @@ class BusDigital : public Bus {
cleanup();
}

private:
private:
uint8_t _colorOrder = COL_ORDER_GRB;
uint8_t _pins[2] = {255, 255};
uint8_t _iType = I_NONE;
Expand Down Expand Up @@ -477,7 +477,7 @@ class BusPwm : public Bus {
cleanup();
}

private:
private:
uint8_t _pins[5] = {255, 255, 255, 255, 255};
uint8_t _data[5] = {0};
#ifdef ARDUINO_ARCH_ESP32
Expand Down Expand Up @@ -553,7 +553,7 @@ class BusOnOff : public Bus {
cleanup();
}

private:
private:
uint8_t _pin = 255;
uint8_t _data = 0;
};
Expand Down Expand Up @@ -717,7 +717,7 @@ class BusManager {
//do not call this method from system context (network callback)
void removeAll() {
DEBUG_PRINTLN(F("Removing all."));
//prevents crashes due to deleting busses while in use.
//prevents crashes due to deleting busses while in use.
while (!canAllShow()) yield();
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
numBusses = 0;
Expand Down
6 changes: 3 additions & 3 deletions wled00/bus_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class PolyBus {
}
};
static uint32_t getPixelColor(void* busPtr, uint8_t busType, uint16_t pix, uint8_t co) {
RgbwColor col(0,0,0,0);
RgbwColor col(0,0,0,0);
switch (busType) {
case I_NONE: break;
#ifdef ESP8266
Expand Down Expand Up @@ -771,7 +771,7 @@ class PolyBus {
case I_HS_P98_3: col = (static_cast<B_HS_P98_3*>(busPtr))->GetPixelColor(pix); break;
case I_SS_P98_3: col = (static_cast<B_SS_P98_3*>(busPtr))->GetPixelColor(pix); break;
}

// upper nibble contains W swap information
uint8_t w = col.W;
switch (co >> 4) {
Expand Down Expand Up @@ -866,7 +866,7 @@ class PolyBus {
}
}

//gives back the internal type index (I_XX_XXX_X above) for the input
//gives back the internal type index (I_XX_XXX_X above) for the input
static uint8_t getI(uint8_t busType, uint8_t* pins, uint8_t num = 0) {
if (!IS_DIGITAL(busType)) return I_NONE;
if (IS_2PIN(busType)) { //SPI LED chips
Expand Down
12 changes: 6 additions & 6 deletions wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ void handleSwitch(uint8_t b)
}

if (buttonLongPressed[b] == buttonPressedBefore[b]) return;

if (millis() - buttonPressedTime[b] > WLED_DEBOUNCE_THRESHOLD) { //fire edge event only after 50ms without change (debounce)
if (!buttonPressedBefore[b]) { // on -> off
if (macroButton[b]) applyPreset(macroButton[b], CALL_MODE_BUTTON_PRESET);
else { //turn on
if (!bri) {toggleOnOff(); stateUpdated(CALL_MODE_BUTTON);}
}
}
} else { // off -> on
if (macroLongPress[b]) applyPreset(macroLongPress[b], CALL_MODE_BUTTON_PRESET);
else { //turn off
if (bri) {toggleOnOff(); stateUpdated(CALL_MODE_BUTTON);}
}
}
}

// publish MQTT message
Expand All @@ -132,7 +132,7 @@ void handleSwitch(uint8_t b)
}

#define ANALOG_BTN_READ_CYCLE 250 // min time between two analog reading cycles
#define STRIP_WAIT_TIME 6 // max wait time in case of strip.isUpdating()
#define STRIP_WAIT_TIME 6 // max wait time in case of strip.isUpdating()
#define POT_SMOOTHING 0.25f // smoothing factor for raw potentiometer readings
#define POT_SENSITIVITY 4 // changes below this amount are noise (POT scratching, or ADC noise)

Expand Down Expand Up @@ -165,7 +165,7 @@ void handleAnalog(uint8_t b)
//while(strip.isUpdating() && (millis() - wait_started < STRIP_WAIT_TIME)) {
// delay(1);
//}
//if (strip.isUpdating()) return; // give up
//if (strip.isUpdating()) return; // give up

oldRead[b] = aRead;

Expand Down Expand Up @@ -326,7 +326,7 @@ void esp32RMTInvertIdle()
void handleIO()
{
handleButton();

//set relay when LEDs turn on
if (strip.getBrightness())
{
Expand Down
14 changes: 7 additions & 7 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
if (apHide > 1) apHide = 1;

CJSON(apBehavior, ap[F("behav")]);

/*
JsonArray ap_ip = ap["ip"];
for (byte i = 0; i < 4; i++) {
Expand Down Expand Up @@ -136,7 +136,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
#endif

JsonArray ins = hw_led["ins"];

if (fromFS || !ins.isNull()) {
uint8_t s = 0; // bus iterator
if (fromFS) busses.removeAll(); // can't safely manipulate busses directly in network callback
Expand Down Expand Up @@ -210,14 +210,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
btnPin[s] = pin;
#ifdef ARDUINO_ARCH_ESP32
// ESP32 only: check that analog button pin is a valid ADC gpio
if (((buttonType[s] == BTN_TYPE_ANALOG) || (buttonType[s] == BTN_TYPE_ANALOG_INVERTED)) && (digitalPinToAnalogChannel(btnPin[s]) < 0))
if (((buttonType[s] == BTN_TYPE_ANALOG) || (buttonType[s] == BTN_TYPE_ANALOG_INVERTED)) && (digitalPinToAnalogChannel(btnPin[s]) < 0))
{
// not an ADC analog pin
DEBUG_PRINTF("PIN ALLOC error: GPIO%d for analog button #%d is not an analog pin!\n", btnPin[s], s);
btnPin[s] = -1;
pinManager.deallocatePin(pin,PinOwner::Button);
}
else
}
else
#endif
{
if (disablePullUp) {
Expand Down Expand Up @@ -253,7 +253,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
// relies upon only being called once with fromFS == true, which is currently true.
uint8_t s = 0;
if (pinManager.allocatePin(btnPin[0], false, PinOwner::Button)) { // initialized to #define value BTNPIN, or zero if not defined(!)
++s; // do not clear default button if allocated successfully
++s; // do not clear default button if allocated successfully
}
for (; s<WLED_MAX_BUTTONS; s++) {
btnPin[s] = -1;
Expand Down Expand Up @@ -497,7 +497,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
uint8_t it = 0;
for (JsonObject timer : timers) {
if (it > 9) break;
if (it<8 && timer[F("hour")]==255) it=8; // hour==255 -> sunrise/sunset
if (it<8 && timer[F("hour")]==255) it=8; // hour==255 -> sunrise/sunset
CJSON(timerHours[it], timer[F("hour")]);
CJSON(timerMinutes[it], timer["min"]);
CJSON(timerMacro[it], timer["macro"]);
Expand Down
4 changes: 2 additions & 2 deletions wled00/colors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void colorKtoRGB(uint16_t kelvin, byte* rgb) //white spectrum to rgb, calc
r = round(329.698727446 * pow((temp - 60), -0.1332047592));
g = round(288.1221695283 * pow((temp - 60), -0.0755148492));
b = 255;
}
}
//g += 12; //mod by Aircoookie, a bit less accurate but visibly less pinkish
rgb[0] = (uint8_t) constrain(r, 0, 255);
rgb[1] = (uint8_t) constrain(g, 0, 255);
Expand Down Expand Up @@ -194,7 +194,7 @@ void colorFromDecOrHexString(byte* rgb, char* in)
if (in[0] == 0) return;
char first = in[0];
uint32_t c = 0;

if (first == '#' || first == 'h' || first == 'H') //is HEX encoded
{
c = strtoul(in +1, NULL, 16);
Expand Down
4 changes: 2 additions & 2 deletions wled00/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@

#define NTP_PACKET_SIZE 48

//maximum number of rendered LEDs - this does not have to match max. physical LEDs, e.g. if there are virtual busses
//maximum number of rendered LEDs - this does not have to match max. physical LEDs, e.g. if there are virtual busses
#ifndef MAX_LEDS
#ifdef ESP8266
#define MAX_LEDS 1664 //can't rely on memory limit to limit this to 1600 LEDs
Expand Down Expand Up @@ -338,7 +338,7 @@
#ifdef ESP8266
#define SETTINGS_STACK_BUF_SIZE 2048
#else
#define SETTINGS_STACK_BUF_SIZE 3096
#define SETTINGS_STACK_BUF_SIZE 3096
#endif

#ifdef WLED_USE_ETHERNET
Expand Down
2 changes: 1 addition & 1 deletion wled00/dmx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void initDMX() {
dmx.init(512); // initialize with bus length
#else
dmx.initWrite(512); // initialize with bus length
#endif
#endif
}

#else
Expand Down
8 changes: 4 additions & 4 deletions wled00/e131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//handles RGB data only
void handleDDPPacket(e131_packet_t* p) {
int lastPushSeq = e131LastSequenceNumber[0];

//reject late packets belonging to previous frame (assuming 4 packets max. before push)
if (e131SkipOutOfSequence && lastPushSeq) {
int sn = p->sequenceNum & 0xF;
Expand All @@ -35,7 +35,7 @@ void handleDDPPacket(e131_packet_t* p) {
if (p->flags & DDP_TIMECODE_FLAG) c = 4; //packet has timecode flag, we do not support it, but data starts 4 bytes later

realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP);

if (!realtimeOverride || (realtimeMode && useMainSegmentOnly)) {
for (uint16_t i = start; i < stop; i++) {
setRealtimePixel(i, data[c], data[c+1], data[c+2], ddpChannelsPerLed >3 ? data[c+3] : 0);
Expand Down Expand Up @@ -242,7 +242,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
strip.setBrightness(bri, true);
}
}

if (!is4Chan) {
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
setRealtimePixel(i, e131_data[dmxOffset], e131_data[dmxOffset+1], e131_data[dmxOffset+2], 0);
Expand Down Expand Up @@ -445,7 +445,7 @@ void sendArtnetPollReply(ArtPollReply *reply, IPAddress ipAddress, uint16_t port
reply->reply_sw_out[0] = (uint8_t)(portAddress & 0x000F);

snprintf_P((char *)reply->reply_node_report, sizeof(reply->reply_node_report)-1, PSTR("#0001 [%04u] OK - WLED v" TOSTRING(WLED_VERSION)), pollReplyCount);

if (pollReplyCount < 9999) {
pollReplyCount++;
} else {
Expand Down
4 changes: 2 additions & 2 deletions wled00/fcn_declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void publishMqtt();
void handleTime();
void handleNetworkTime();
void sendNTPPacket();
bool checkNTPResponse();
bool checkNTPResponse();
void updateLocalTime();
void getTimeString(char* out);
bool checkCountdown();
Expand Down Expand Up @@ -202,7 +202,7 @@ inline bool applyTemporaryPreset() {return applyPreset(255);};
void savePreset(byte index, const char* pname = nullptr, JsonObject saveobj = JsonObject());
inline void saveTemporaryPreset() {savePreset(255);};
void deletePreset(byte index);
bool getPresetName(byte index, String& name);
bool getPresetName(byte index, String& name);

//set.cpp
bool isAsterisksOnly(const char* str, byte maxLen);
Expand Down
Loading

0 comments on commit 506b6b5

Please sign in to comment.