@@ -157,7 +157,7 @@ void Wippersnapper_AnalogIO::initAnalogInputPin(
157
157
break ;
158
158
}
159
159
}
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):" ) );
161
161
WS_DEBUG_PRINTLN (periodMs);
162
162
}
163
163
@@ -189,11 +189,11 @@ void Wippersnapper_AnalogIO::disableAnalogInPin(int pin) {
189
189
/* **********************************************************************************/
190
190
void Wippersnapper_AnalogIO::deinitAnalogPin (
191
191
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" ) );
193
193
WS_DEBUG_PRINTLN (pin);
194
194
if (direction ==
195
195
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." ) );
197
197
disableAnalogInPin (pin);
198
198
}
199
199
pinMode (pin, INPUT); // hi-z
@@ -233,10 +233,10 @@ uint16_t Wippersnapper_AnalogIO::getPinValue(int pin) {
233
233
/* *********************************************************/
234
234
float Wippersnapper_AnalogIO::getPinValueVolts (int pin) {
235
235
#ifdef ARDUINO_ARCH_ESP32
236
- WS_DEBUG_PRINTLN (" ESP32: Using analogReadMilliVolts()" );
236
+ WS_DEBUG_PRINTLN (F ( " ESP32: Using analogReadMilliVolts()" ) );
237
237
return analogReadMilliVolts (pin) / 1000.0 ;
238
238
#else
239
- WS_DEBUG_PRINTLN (" Using old getPinValueVolts()" );
239
+ WS_DEBUG_PRINTLN (F ( " Using old getPinValueVolts()" ) );
240
240
uint16_t rawValue = getPinValue (pin);
241
241
return rawValue * getAref () / 65536 ;
242
242
#endif
@@ -293,7 +293,7 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
293
293
pb_ostream_from_buffer (WS._buffer_outgoing , sizeof (WS._buffer_outgoing ));
294
294
if (!ws_pb_encode (&stream, wippersnapper_signal_v1_CreateSignalRequest_fields,
295
295
&outgoingSignalMsg)) {
296
- WS_DEBUG_PRINTLN (" ERROR: Unable to encode signal message" );
296
+ WS_DEBUG_PRINTLN (F ( " ERROR: Unable to encode signal message" ) );
297
297
return false ;
298
298
}
299
299
@@ -302,9 +302,9 @@ bool Wippersnapper_AnalogIO::encodePinEvent(
302
302
pb_get_encoded_size (&msgSz,
303
303
wippersnapper_signal_v1_CreateSignalRequest_fields,
304
304
&outgoingSignalMsg);
305
- WS_DEBUG_PRINT (" Publishing pinEvent..." );
305
+ WS_DEBUG_PRINT (F ( " Publishing pinEvent..." ) );
306
306
WS.publish (WS._topic_signal_device , WS._buffer_outgoing , msgSz, 1 );
307
- WS_DEBUG_PRINTLN (" Published!" );
307
+ WS_DEBUG_PRINTLN (F ( " Published!" ) );
308
308
309
309
return true ;
310
310
}
@@ -344,7 +344,7 @@ void Wippersnapper_AnalogIO::update() {
344
344
345
345
// Does the pin execute on-period?
346
346
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" ) );
348
348
WS_DEBUG_PRINTLN (_analog_input_pins[i].pinName );
349
349
350
350
// Read from analog pin
@@ -356,8 +356,8 @@ void Wippersnapper_AnalogIO::update() {
356
356
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VALUE) {
357
357
pinValRaw = getPinValue (_analog_input_pins[i].pinName );
358
358
} 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!" )) ;
361
361
pinValRaw = 0.0 ;
362
362
}
363
363
@@ -371,11 +371,11 @@ void Wippersnapper_AnalogIO::update() {
371
371
// Does the pin execute on_change?
372
372
else if (_analog_input_pins[i].period == 0L ) {
373
373
374
- WS_DEBUG_PRINT (" CurrentTime: " );
374
+ WS_DEBUG_PRINT (F ( " CurrentTime: " ) );
375
375
WS_DEBUG_PRINTLN (millis ());
376
- WS_DEBUG_PRINT (" PrvPeriod: " );
376
+ WS_DEBUG_PRINT (F ( " PrvPeriod: " ) );
377
377
WS_DEBUG_PRINTLN (_analog_input_pins[i].prvPeriod );
378
- WS_DEBUG_PRINT (" Diff: " );
378
+ WS_DEBUG_PRINT (F ( " Diff: " ) );
379
379
WS_DEBUG_PRINTLN ((long )millis () - _analog_input_pins[i].prvPeriod );
380
380
381
381
if (_analog_input_pins[i].prvPeriod == 0L ) {
@@ -391,23 +391,23 @@ void Wippersnapper_AnalogIO::update() {
391
391
// note: on-change requires ADC DEFAULT_HYSTERISIS to check against prv
392
392
// pin value
393
393
uint16_t pinValRaw = getPinValue (_analog_input_pins[i].pinName );
394
- WS_DEBUG_PRINT (" PinValRaw: " );
394
+ WS_DEBUG_PRINT (F ( " PinValRaw: " ) );
395
395
WS_DEBUG_PRINTLN (pinValRaw);
396
396
397
397
double currentLogValue = log10 (pinValRaw + 1 ); // +1 to avoid log(0)
398
398
double lastLogValue =
399
399
log10 (_analog_input_pins[i].prvPinVal + 1 ); // +1 to avoid log(0)
400
- WS_DEBUG_PRINT (" CurrentLogValue: " );
400
+ WS_DEBUG_PRINT (F ( " CurrentLogValue: " ) );
401
401
WS_DEBUG_PRINTLN (currentLogValue);
402
- WS_DEBUG_PRINT (" LastLogValue: " );
402
+ WS_DEBUG_PRINT (F ( " LastLogValue: " ) );
403
403
WS_DEBUG_PRINTLN (lastLogValue);
404
404
bool passed_hysterisys = false ;
405
405
// Check if the logarithmic change exceeds the threshold
406
406
if (abs (currentLogValue - lastLogValue) > DEFAULT_HYSTERISIS) {
407
407
passed_hysterisys = true ;
408
- WS_DEBUG_PRINTLN (" ADC passed hysteresis" );
408
+ WS_DEBUG_PRINTLN (F ( " ADC passed hysteresis" ) );
409
409
} else {
410
- WS_DEBUG_PRINTLN (" ADC did not pass hysteresis" );
410
+ WS_DEBUG_PRINTLN (F ( " ADC did not pass hysteresis" ) );
411
411
}
412
412
413
413
// old technique
@@ -417,28 +417,28 @@ void Wippersnapper_AnalogIO::update() {
417
417
uint16_t _pinValThreshLow =
418
418
_analog_input_pins[i].prvPinVal -
419
419
(_analog_input_pins[i].prvPinVal * DEFAULT_HYSTERISIS);
420
- WS_DEBUG_PRINT (" PinValThreshHi: " );
420
+ WS_DEBUG_PRINT (F ( " PinValThreshHi: " ) );
421
421
WS_DEBUG_PRINTLN (_pinValThreshHi);
422
- WS_DEBUG_PRINT (" PinValThreshLow: " );
422
+ WS_DEBUG_PRINT (F ( " PinValThreshLow: " ) );
423
423
WS_DEBUG_PRINTLN (_pinValThreshLow);
424
424
425
425
if (pinValRaw > _pinValThreshHi || pinValRaw < _pinValThreshLow) {
426
426
// passed_hysterisys = true;
427
- WS_DEBUG_PRINTLN (" ADC passed OLD hysteresis" );
427
+ WS_DEBUG_PRINTLN (F ( " ADC passed OLD hysteresis" ) );
428
428
} else {
429
- WS_DEBUG_PRINTLN (" ADC did not pass OLD hysteresis" );
429
+ WS_DEBUG_PRINTLN (F ( " ADC did not pass OLD hysteresis" ) );
430
430
}
431
431
432
432
if (_analog_input_pins[i].readMode ==
433
433
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VOLTAGE) {
434
434
pinValVolts = getPinValueVolts (_analog_input_pins[i].pinName );
435
- WS_DEBUG_PRINT (" PinValVolts: " );
435
+ WS_DEBUG_PRINT (F ( " PinValVolts: " ) );
436
436
WS_DEBUG_PRINTLN (pinValVolts);
437
437
} else if (
438
438
_analog_input_pins[i].readMode ==
439
439
wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VALUE) {
440
440
// already fetched raw value, just print it
441
- WS_DEBUG_PRINT (" PinValRaw: " );
441
+ WS_DEBUG_PRINT (F ( " PinValRaw: " ) );
442
442
WS_DEBUG_PRINTLN (pinValRaw);
443
443
} else {
444
444
WS_DEBUG_PRINTLN (" ERROR: Unable to read pin value, cannot determine "
@@ -454,7 +454,7 @@ void Wippersnapper_AnalogIO::update() {
454
454
if (passed_hysterisys &&
455
455
(((long )millis () - _analog_input_pins[i].prvPeriod ) > 200 ||
456
456
_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..." ) );
458
458
_analog_input_pins[i].prvPinVal = pinValRaw;
459
459
_analog_input_pins[i].prvPeriod = millis ();
460
460
// Publish pin event to IO
@@ -479,7 +479,7 @@ void Wippersnapper_AnalogIO::update() {
479
479
// pinValVolts);
480
480
481
481
// } else {
482
- // WS_DEBUG_PRINTLN("ADC has not changed enough, continue...");
482
+ // WS_DEBUG_PRINTLN(F( "ADC has not changed enough, continue...") );
483
483
// _analog_input_pins[i].prvPeriod = millis();
484
484
// _analog_input_pins[i].prvPinVal = pinValRaw;
485
485
// continue;
@@ -496,7 +496,7 @@ void Wippersnapper_AnalogIO::update() {
496
496
// _analog_input_pins[i].readMode, pinValRaw,
497
497
// pinValVolts);
498
498
// } else {
499
- // // WS_DEBUG_PRINTLN("ADC has not changed enough, continue...");
499
+ // // WS_DEBUG_PRINTLN(F( "ADC has not changed enough, continue...") );
500
500
// continue;
501
501
// }
502
502
// set the pin value in the digital pin object for comparison on next
0 commit comments