Skip to content

Commit 87109ff

Browse files
committed
CLang-format analogIO
1 parent a0bfb49 commit 87109ff

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ void Wippersnapper_AnalogIO::setADCResolution(int resolution) {
8787
analogReadResolution(16);
8888
_nativeResolution = 12;
8989
#elif defined(ARDUINO_ARCH_ESP32)
90-
scaleAnalogRead = false; // should be false, handled in bsp (analogReadResolution)
90+
scaleAnalogRead =
91+
false; // should be false, handled in bsp (analogReadResolution)
9192
analogReadResolution(resolution); // 16 bit values (shifted from 12 or 13bit)
9293
#if defined(ESP32S3)
9394
_nativeResolution = 13; // S3 ADC is 13-bit, others are 12-bit
@@ -323,12 +324,12 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
323324
@returns True if pin's period expired, False otherwise.
324325
*/
325326
/**********************************************************/
326-
bool Wippersnapper_AnalogIO::timerExpired(long currentTime,
327-
analogInputPin pin, long periodOffset) {
327+
bool Wippersnapper_AnalogIO::timerExpired(long currentTime, analogInputPin pin,
328+
long periodOffset) {
328329
if (pin.period + periodOffset != 0L &&
329-
currentTime - pin.prvPeriod > (pin.period + periodOffset)) {
330-
return true;
331-
}
330+
currentTime - pin.prvPeriod > (pin.period + periodOffset)) {
331+
return true;
332+
}
332333
return false;
333334
}
334335

@@ -348,7 +349,7 @@ void Wippersnapper_AnalogIO::update() {
348349

349350
// Does the pin execute on-period?
350351
if (_analog_input_pins[i].period != 0L &&
351-
timerExpired(millis(), _analog_input_pins[i])) {
352+
timerExpired(millis(), _analog_input_pins[i])) {
352353
WS_DEBUG_PRINT("Executing periodic event on A");
353354
WS_DEBUG_PRINTLN(_analog_input_pins[i].pinName);
354355

@@ -376,18 +377,17 @@ void Wippersnapper_AnalogIO::update() {
376377
// Does the pin execute on_change?
377378
else if (_analog_input_pins[i].period == 0L) {
378379

379-
// TODO: after testing combine these two conditionals to just send the event and not debug print.
380+
// TODO: after testing combine these two conditionals to just send the
381+
// event and not debug print.
380382
if (_analog_input_pins[i].prvPeriod == 0L) {
381-
// first time reading pin, no previous timestamp so send event + update prvPeriod
382-
// WS_DEBUG_PRINT("First time reading pin A");
383+
// first time reading pin, no previous timestamp so send event +
384+
// update prvPeriod WS_DEBUG_PRINT("First time reading pin A");
383385
// WS_DEBUG_PRINTLN(_analog_input_pins[i].pinName);
384-
}
385-
else if (timerExpired(millis(), _analog_input_pins[i], 500)) {
386+
} else if (timerExpired(millis(), _analog_input_pins[i], 500)) {
386387
// timer expired, send event + update prvPeriod
387388
// WS_DEBUG_PRINT("Timer passed for pin A");
388389
// WS_DEBUG_PRINTLN(_analog_input_pins[i].pinName);
389-
}
390-
else {
390+
} else {
391391
// last event was too recently, skip this one...
392392
// WS_DEBUG_PRINTLN("Timer has not expired, continue...");
393393
continue;
@@ -397,12 +397,14 @@ void Wippersnapper_AnalogIO::update() {
397397
// pin value
398398
uint16_t pinValRaw = getPinValue(_analog_input_pins[i].pinName);
399399

400-
// All boards ADC values scaled to 16bit, in future we may need to adjust dynamically
400+
// All boards ADC values scaled to 16bit, in future we may need to
401+
// adjust dynamically
401402
uint16_t maxDecimalValue = 65535;
402403

403-
// Calculate threshold values - using DEFAULT_HYSTERISIS for first third (1/3) of the range,
404-
// then 2x DEFAULT_HYSTERISIS for the middle 1/3, and 4x DEFAULT_HYSTERISIS for the last 1/3.
405-
// This should allow a more wifi blip tolerant threshold for the both ends of the range.
404+
// Calculate threshold values - using DEFAULT_HYSTERISIS for first third
405+
// (1/3) of the range, then 2x DEFAULT_HYSTERISIS for the middle 1/3,
406+
// and 4x DEFAULT_HYSTERISIS for the last 1/3. This should allow a more
407+
// wifi blip tolerant threshold for the both ends of the range.
406408
float CURRENT_HYSTERISIS;
407409
if (pinValRaw < maxDecimalValue / 3) {
408410
CURRENT_HYSTERISIS = maxDecimalValue * DEFAULT_HYSTERISIS;
@@ -412,15 +414,14 @@ void Wippersnapper_AnalogIO::update() {
412414
CURRENT_HYSTERISIS = maxDecimalValue * DEFAULT_HYSTERISIS * 4;
413415
}
414416

415-
416-
417417
// get the threshold values for previous pin value
418418
uint16_t _pinValThreshHi =
419419
_analog_input_pins[i].prvPinVal + CURRENT_HYSTERISIS;
420420
uint16_t _pinValThreshLow =
421421
_analog_input_pins[i].prvPinVal - CURRENT_HYSTERISIS;
422422

423-
if (_analog_input_pins[i].prvPeriod == 0 || pinValRaw > _pinValThreshHi || pinValRaw < _pinValThreshLow) {
423+
if (_analog_input_pins[i].prvPeriod == 0 ||
424+
pinValRaw > _pinValThreshHi || pinValRaw < _pinValThreshLow) {
424425
// Perform voltage conversion if we need to
425426
if (_analog_input_pins[i].readMode ==
426427
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VOLTAGE) {

0 commit comments

Comments
 (0)