Skip to content

Commit f837709

Browse files
committed
Fstring the world for SAMD
1 parent 226b9b9 commit f837709

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void Wippersnapper_AnalogIO::initAnalogInputPin(
157157
break;
158158
}
159159
}
160-
WS_DEBUG_PRINT("Configured Analog Input pin with polling time (ms):");
160+
WS_DEBUG_PRINT(F("Configured Analog Input pin with polling time (ms):"));
161161
WS_DEBUG_PRINTLN(periodMs);
162162
}
163163

@@ -189,11 +189,11 @@ void Wippersnapper_AnalogIO::disableAnalogInPin(int pin) {
189189
/***********************************************************************************/
190190
void Wippersnapper_AnalogIO::deinitAnalogPin(
191191
wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, int pin) {
192-
WS_DEBUG_PRINT("Deinitializing analog pin A");
192+
WS_DEBUG_PRINT(F("Deinitializing analog pin A"));
193193
WS_DEBUG_PRINTLN(pin);
194194
if (direction ==
195195
wippersnapper_pin_v1_ConfigurePinRequest_Direction_DIRECTION_INPUT) {
196-
WS_DEBUG_PRINTLN("Deinitialized analog input pin obj.");
196+
WS_DEBUG_PRINTLN(F("Deinitialized analog input pin obj."));
197197
disableAnalogInPin(pin);
198198
}
199199
pinMode(pin, INPUT); // hi-z
@@ -233,10 +233,10 @@ uint16_t Wippersnapper_AnalogIO::getPinValue(int pin) {
233233
/**********************************************************/
234234
float Wippersnapper_AnalogIO::getPinValueVolts(int pin) {
235235
#ifdef ARDUINO_ARCH_ESP32
236-
WS_DEBUG_PRINTLN("ESP32: Using analogReadMilliVolts()");
236+
WS_DEBUG_PRINTLN(F("ESP32: Using analogReadMilliVolts()"));
237237
return analogReadMilliVolts(pin) / 1000.0;
238238
#else
239-
WS_DEBUG_PRINTLN("Using old getPinValueVolts()");
239+
WS_DEBUG_PRINTLN(F("Using old getPinValueVolts()"));
240240
uint16_t rawValue = getPinValue(pin);
241241
return rawValue * getAref() / 65536;
242242
#endif
@@ -293,7 +293,7 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
293293
pb_ostream_from_buffer(WS._buffer_outgoing, sizeof(WS._buffer_outgoing));
294294
if (!ws_pb_encode(&stream, wippersnapper_signal_v1_CreateSignalRequest_fields,
295295
&outgoingSignalMsg)) {
296-
WS_DEBUG_PRINTLN("ERROR: Unable to encode signal message");
296+
WS_DEBUG_PRINTLN(F("ERROR: Unable to encode signal message"));
297297
return false;
298298
}
299299

@@ -302,9 +302,9 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
302302
pb_get_encoded_size(&msgSz,
303303
wippersnapper_signal_v1_CreateSignalRequest_fields,
304304
&outgoingSignalMsg);
305-
WS_DEBUG_PRINT("Publishing pinEvent...");
305+
WS_DEBUG_PRINT(F("Publishing pinEvent..."));
306306
WS.publish(WS._topic_signal_device, WS._buffer_outgoing, msgSz, 1);
307-
WS_DEBUG_PRINTLN("Published!");
307+
WS_DEBUG_PRINTLN(F("Published!"));
308308

309309
return true;
310310
}
@@ -344,7 +344,7 @@ void Wippersnapper_AnalogIO::update() {
344344

345345
// Does the pin execute on-period?
346346
if (timerExpired((long)millis(), _analog_input_pins[i])) {
347-
WS_DEBUG_PRINT("Executing periodic event on A");
347+
WS_DEBUG_PRINT(F("Executing periodic event on A"));
348348
WS_DEBUG_PRINTLN(_analog_input_pins[i].pinName);
349349

350350
// Read from analog pin
@@ -356,8 +356,8 @@ void Wippersnapper_AnalogIO::update() {
356356
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VALUE) {
357357
pinValRaw = getPinValue(_analog_input_pins[i].pinName);
358358
} else {
359-
WS_DEBUG_PRINTLN("ERROR: Unable to read pin value, cannot determine "
360-
"analog read mode!");
359+
WS_DEBUG_PRINTLN(F("ERROR: Unable to read pin value, cannot determine "
360+
"analog read mode!"));
361361
pinValRaw = 0.0;
362362
}
363363

@@ -371,11 +371,11 @@ void Wippersnapper_AnalogIO::update() {
371371
// Does the pin execute on_change?
372372
else if (_analog_input_pins[i].period == 0L) {
373373

374-
WS_DEBUG_PRINT("CurrentTime: ");
374+
WS_DEBUG_PRINT(F("CurrentTime: "));
375375
WS_DEBUG_PRINTLN(millis());
376-
WS_DEBUG_PRINT("PrvPeriod: ");
376+
WS_DEBUG_PRINT(F("PrvPeriod: "));
377377
WS_DEBUG_PRINTLN(_analog_input_pins[i].prvPeriod);
378-
WS_DEBUG_PRINT("Diff: ");
378+
WS_DEBUG_PRINT(F("Diff: "));
379379
WS_DEBUG_PRINTLN((long)millis() - _analog_input_pins[i].prvPeriod);
380380

381381
if (_analog_input_pins[i].prvPeriod == 0L) {
@@ -391,23 +391,23 @@ void Wippersnapper_AnalogIO::update() {
391391
// note: on-change requires ADC DEFAULT_HYSTERISIS to check against prv
392392
// pin value
393393
uint16_t pinValRaw = getPinValue(_analog_input_pins[i].pinName);
394-
WS_DEBUG_PRINT("PinValRaw: ");
394+
WS_DEBUG_PRINT(F("PinValRaw: "));
395395
WS_DEBUG_PRINTLN(pinValRaw);
396396

397397
double currentLogValue = log10(pinValRaw + 1); // +1 to avoid log(0)
398398
double lastLogValue =
399399
log10(_analog_input_pins[i].prvPinVal + 1); // +1 to avoid log(0)
400-
WS_DEBUG_PRINT("CurrentLogValue: ");
400+
WS_DEBUG_PRINT(F("CurrentLogValue: "));
401401
WS_DEBUG_PRINTLN(currentLogValue);
402-
WS_DEBUG_PRINT("LastLogValue: ");
402+
WS_DEBUG_PRINT(F("LastLogValue: "));
403403
WS_DEBUG_PRINTLN(lastLogValue);
404404
bool passed_hysterisys = false;
405405
// Check if the logarithmic change exceeds the threshold
406406
if (abs(currentLogValue - lastLogValue) > DEFAULT_HYSTERISIS) {
407407
passed_hysterisys = true;
408-
WS_DEBUG_PRINTLN("ADC passed hysteresis");
408+
WS_DEBUG_PRINTLN(F("ADC passed hysteresis"));
409409
} else {
410-
WS_DEBUG_PRINTLN("ADC did not pass hysteresis");
410+
WS_DEBUG_PRINTLN(F("ADC did not pass hysteresis"));
411411
}
412412

413413
// old technique
@@ -417,28 +417,28 @@ void Wippersnapper_AnalogIO::update() {
417417
uint16_t _pinValThreshLow =
418418
_analog_input_pins[i].prvPinVal -
419419
(_analog_input_pins[i].prvPinVal * DEFAULT_HYSTERISIS);
420-
WS_DEBUG_PRINT("PinValThreshHi: ");
420+
WS_DEBUG_PRINT(F("PinValThreshHi: "));
421421
WS_DEBUG_PRINTLN(_pinValThreshHi);
422-
WS_DEBUG_PRINT("PinValThreshLow: ");
422+
WS_DEBUG_PRINT(F("PinValThreshLow: "));
423423
WS_DEBUG_PRINTLN(_pinValThreshLow);
424424

425425
if (pinValRaw > _pinValThreshHi || pinValRaw < _pinValThreshLow) {
426426
// passed_hysterisys = true;
427-
WS_DEBUG_PRINTLN("ADC passed OLD hysteresis");
427+
WS_DEBUG_PRINTLN(F("ADC passed OLD hysteresis"));
428428
} else {
429-
WS_DEBUG_PRINTLN("ADC did not pass OLD hysteresis");
429+
WS_DEBUG_PRINTLN(F("ADC did not pass OLD hysteresis"));
430430
}
431431

432432
if (_analog_input_pins[i].readMode ==
433433
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VOLTAGE) {
434434
pinValVolts = getPinValueVolts(_analog_input_pins[i].pinName);
435-
WS_DEBUG_PRINT("PinValVolts: ");
435+
WS_DEBUG_PRINT(F("PinValVolts: "));
436436
WS_DEBUG_PRINTLN(pinValVolts);
437437
} else if (
438438
_analog_input_pins[i].readMode ==
439439
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VALUE) {
440440
// already fetched raw value, just print it
441-
WS_DEBUG_PRINT("PinValRaw: ");
441+
WS_DEBUG_PRINT(F("PinValRaw: "));
442442
WS_DEBUG_PRINTLN(pinValRaw);
443443
} else {
444444
WS_DEBUG_PRINTLN("ERROR: Unable to read pin value, cannot determine "
@@ -454,7 +454,7 @@ void Wippersnapper_AnalogIO::update() {
454454
if (passed_hysterisys &&
455455
(((long)millis() - _analog_input_pins[i].prvPeriod) > 200 ||
456456
_analog_input_pins[i].prvPeriod == 0L)) {
457-
WS_DEBUG_PRINTLN("ADC has changed enough, publishing event...");
457+
WS_DEBUG_PRINTLN(F("ADC has changed enough, publishing event..."));
458458
_analog_input_pins[i].prvPinVal = pinValRaw;
459459
_analog_input_pins[i].prvPeriod = millis();
460460
// Publish pin event to IO
@@ -479,7 +479,7 @@ void Wippersnapper_AnalogIO::update() {
479479
// pinValVolts);
480480

481481
// } else {
482-
// WS_DEBUG_PRINTLN("ADC has not changed enough, continue...");
482+
// WS_DEBUG_PRINTLN(F("ADC has not changed enough, continue..."));
483483
// _analog_input_pins[i].prvPeriod = millis();
484484
// _analog_input_pins[i].prvPinVal = pinValRaw;
485485
// continue;
@@ -496,7 +496,7 @@ void Wippersnapper_AnalogIO::update() {
496496
// _analog_input_pins[i].readMode, pinValRaw,
497497
// pinValVolts);
498498
// } else {
499-
// // WS_DEBUG_PRINTLN("ADC has not changed enough, continue...");
499+
// // WS_DEBUG_PRINTLN(F("ADC has not changed enough, continue..."));
500500
// continue;
501501
// }
502502
// set the pin value in the digital pin object for comparison on next

0 commit comments

Comments
 (0)