Skip to content

Commit 2523b79

Browse files
committed
3. Party libs
1 parent 740cc86 commit 2523b79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+392
-334
lines changed

.github/workflows/LibraryBuild.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
repository: ArminJo/Arduino-BlueDisplay
9292
ref: master
9393
path: CustomBlueDisplay # must contain string "Custom"
94-
# No need to put "Custom" library in the required-libraries list
94+
# No need to put this custom library in the required-libraries list
9595

9696
- name: Compile all examples using the arduino-test-compile action
9797
uses: ArminJo/arduino-test-compile@master
@@ -103,4 +103,4 @@ jobs:
103103
build-properties: ${{ toJson(matrix.build-properties) }}
104104
extra-arduino-lib-install-args: "--no-deps" # suppress dependency resolving for libraries, here the "Adafruit Motor Shield V2 Library"
105105
# debug-install: true
106-
debug-compile: true
106+
# debug-compile: true

.github/workflows/PlatformIoPublish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ jobs:
4040
# run: |
4141
# pio package pack
4242
# pio package publish --owner arminjo --non-interactive
43-

examples/BasicDistance/ADCUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#if defined(__AVR__) && defined(ADCSRA) && defined(ADATE) && (!defined(__AVR_ATmega4809__))
3030
#define ADC_UTILS_ARE_AVAILABLE
3131

32+
// External Reference Current is 150 uA for 5 V and 100 uA for 3.5 V
33+
#define READING_FOR_AREF 1024L // Datasheet 24.2: The minimum value represents GND and the maximum value represents the voltage on the AREF pin minus 1 LSB
34+
3235
// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
3336
#define ADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
3437
#define ADC_PRESCALE4 2 // 52 microseconds per ADC conversion at 1 MHz

examples/BasicDistance/ADCUtils.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "ADCUtils.h"
2929
#if defined(ADC_UTILS_ARE_AVAILABLE) // set in ADCUtils.h, if supported architecture was detected
3030

31-
#if !defined(STR_HELPER)
31+
#if !defined(STR)
3232
#define STR_HELPER(x) #x
3333
#define STR(x) STR_HELPER(x)
3434
#endif
@@ -58,7 +58,7 @@ union WordUnionForADCUtils {
5858
* Enable this to see information on each call.
5959
* Since there should be no library which uses Serial, it should only be enabled for development purposes.
6060
*/
61-
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
61+
#if defined(DEBUG)
6262
#define LOCAL_DEBUG
6363
#else
6464
//#define LOCAL_DEBUG // This enables debug output only for this file
@@ -403,7 +403,7 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aADCChannelNumber, uint8_t
403403
/*
404404
* Get min and max of the last 4 values
405405
*/
406-
tMin = 1024;
406+
tMin = READING_FOR_AREF;
407407
tMax = 0;
408408
for (uint_fast8_t i = 0; i < 4; ++i) {
409409
if (tValues[i] < tMin) {
@@ -472,7 +472,7 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aADCChannelNumber, uint8_t
472472
float getVCCVoltageSimple(void) {
473473
// use AVCC with (optional) external capacitor at AREF pin as reference
474474
float tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
475-
return ((1023 * 1.1 * 4) / tVCC);
475+
return ((READING_FOR_AREF * 1.1 * 4) / tVCC);
476476
}
477477

478478
/*
@@ -483,19 +483,19 @@ float getVCCVoltageSimple(void) {
483483
uint16_t getVCCVoltageMillivoltSimple(void) {
484484
// use AVCC with external capacitor at AREF pin as reference
485485
uint16_t tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
486-
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCC);
486+
return ((READING_FOR_AREF * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCC);
487487
}
488488

489489
/*
490490
* Gets the hypothetical 14 bit reading of VCC using 1.1 volt reference
491-
* Similar to getVCCVoltageMillivolt() * 1023 / 1100
491+
* Similar to getVCCVoltageMillivolt() * 1024 / 1100
492492
*/
493493
uint16_t getVCCVoltageReadingFor1_1VoltReference(void) {
494494
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
495495
/*
496496
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
497497
*/
498-
return ((1023L * 1023L) / tVCC);
498+
return ((READING_FOR_AREF * READING_FOR_AREF) / tVCC);
499499
}
500500

501501
/*
@@ -519,7 +519,7 @@ uint16_t getVCCVoltageMillivolt(void) {
519519
/*
520520
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
521521
*/
522-
return ((1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCC);
522+
return ((READING_FOR_AREF * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCC);
523523
}
524524

525525
/*
@@ -547,7 +547,7 @@ void readAndPrintVCCVoltageMillivolt(Print *aSerial) {
547547
void readVCCVoltageSimple(void) {
548548
// use AVCC with (optional) external capacitor at AREF pin as reference
549549
float tVCC = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
550-
sVCCVoltage = (1023 * (((float) ADC_INTERNAL_REFERENCE_MILLIVOLT) / 1000) * 4) / tVCC;
550+
sVCCVoltage = (READING_FOR_AREF * (((float) ADC_INTERNAL_REFERENCE_MILLIVOLT) / 1000) * 4) / tVCC;
551551
}
552552

553553
/*
@@ -558,7 +558,7 @@ void readVCCVoltageSimple(void) {
558558
void readVCCVoltageMillivoltSimple(void) {
559559
// use AVCC with external capacitor at AREF pin as reference
560560
uint16_t tVCCVoltageMillivoltRaw = readADCChannelMultiSamplesWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4);
561-
sVCCVoltageMillivolt = (1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCCVoltageMillivoltRaw;
561+
sVCCVoltageMillivolt = (READING_FOR_AREF * ADC_INTERNAL_REFERENCE_MILLIVOLT * 4) / tVCCVoltageMillivoltRaw;
562562
}
563563

564564
/*
@@ -579,7 +579,7 @@ void readVCCVoltageMillivolt(void) {
579579
/*
580580
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
581581
*/
582-
sVCCVoltageMillivolt = (1023L * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCCVoltageMillivoltRaw;
582+
sVCCVoltageMillivolt = (READING_FOR_AREF * ADC_INTERNAL_REFERENCE_MILLIVOLT) / tVCCVoltageMillivoltRaw;
583583
}
584584

585585
/*
@@ -588,7 +588,7 @@ void readVCCVoltageMillivolt(void) {
588588
*/
589589
uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelForVoltageMeasurement) {
590590
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
591-
return (aVCCVoltageMillivolt * (uint32_t) tInputVoltageRaw) / 1023;
591+
return (aVCCVoltageMillivolt * (uint32_t) tInputVoltageRaw) / READING_FOR_AREF;
592592
}
593593

594594
/*
@@ -597,12 +597,12 @@ uint16_t getVoltageMillivolt(uint16_t aVCCVoltageMillivolt, uint8_t aADCChannelF
597597
*/
598598
uint16_t getVoltageMillivolt(uint8_t aADCChannelForVoltageMeasurement) {
599599
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, DEFAULT);
600-
return (getVCCVoltageMillivolt() * (uint32_t) tInputVoltageRaw) / 1023;
600+
return (getVCCVoltageMillivolt() * (uint32_t) tInputVoltageRaw) / READING_FOR_AREF;
601601
}
602602

603603
uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageMeasurement) {
604604
uint16_t tInputVoltageRaw = waitAndReadADCChannelWithReference(aADCChannelForVoltageMeasurement, INTERNAL);
605-
return (ADC_INTERNAL_REFERENCE_MILLIVOLT * (uint32_t) tInputVoltageRaw) / 1023;
605+
return (ADC_INTERNAL_REFERENCE_MILLIVOLT * (uint32_t) tInputVoltageRaw) / READING_FOR_AREF;
606606
}
607607

608608
/*

examples/BasicIRControl/TinyIRReceiver.hpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,14 @@
6262
* - USE_ONKYO_PROTOCOL Like NEC, but take the 16 bit address and command each as one 16 bit value and not as 8 bit normal and 8 bit inverted value.
6363
* - USE_FAST_PROTOCOL Use FAST protocol (no address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command) instead of NEC.
6464
* - ENABLE_NEC2_REPEATS Instead of sending / receiving the NEC special repeat code, send / receive the original frame for repeat.
65-
* - USE_CALLBACK_FOR_TINY_RECEIVER Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
65+
* - USE_CALLBACK_FOR_TINY_RECEIVER Call the user provided function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
6666
*/
6767

6868
#ifndef _TINY_IR_RECEIVER_HPP
6969
#define _TINY_IR_RECEIVER_HPP
7070

7171
#include <Arduino.h>
7272

73-
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
74-
#define LOCAL_DEBUG
75-
#else
76-
//#define LOCAL_DEBUG // This enables debug output only for this file
77-
#endif
78-
7973
/*
8074
* Protocol selection
8175
*/
@@ -84,21 +78,26 @@
8478
//#define USE_ONKYO_PROTOCOL // Like NEC, but take the 16 bit address and command each as one 16 bit value and not as 8 bit normal and 8 bit inverted value.
8579
//#define USE_FAST_PROTOCOL // Use FAST protocol instead of NEC / ONKYO.
8680
//#define ENABLE_NEC2_REPEATS // Instead of sending / receiving the NEC special repeat code, send / receive the original frame for repeat.
87-
#include "TinyIR.h" // If not defined, it defines IR_RECEIVE_PIN, IR_FEEDBACK_LED_PIN and TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT
81+
#include "TinyIR.h"
8882

8983
#include "digitalWriteFast.h"
9084
/** \addtogroup TinyReceiver Minimal receiver for NEC and FAST protocol
9185
* @{
9286
*/
9387

9488
#if defined(DEBUG)
89+
#define LOCAL_DEBUG
9590
#define LOCAL_DEBUG_ATTACH_INTERRUPT
9691
#else
97-
//#define LOCAL_DEBUG_ATTACH_INTERRUPT // to see if attachInterrupt() or static interrupt (by register tweaking) is used
92+
//#define LOCAL_DEBUG // This enables debug output only for this file
93+
//#define LOCAL_DEBUG_ATTACH_INTERRUPT // To see if attachInterrupt() or static interrupt (by register tweaking) is used and no other debug output
9894
#endif
95+
9996
#if defined(TRACE)
97+
#define LOCAL_TRACE
10098
#define LOCAL_TRACE_STATE_MACHINE
10199
#else
100+
//#define LOCAL_TRACE // This enables trace output only for this file
102101
//#define LOCAL_TRACE_STATE_MACHINE // to see the state of the ISR (Interrupt Service Routine) state machine
103102
#endif
104103

@@ -110,6 +109,8 @@ volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData;
110109
/*
111110
* Set input pin and output pin definitions etc.
112111
*/
112+
//#define IR_RECEIVE_PIN 2
113+
//#define IR_FEEDBACK_LED_PIN LED_BUILTIN
113114
#if defined(IR_INPUT_PIN)
114115
#warning "IR_INPUT_PIN is deprecated, use IR_RECEIVE_PIN"
115116
#define IR_RECEIVE_PIN IR_INPUT_PIN
@@ -129,7 +130,7 @@ volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData;
129130
#endif
130131

131132
#if !defined(IR_FEEDBACK_LED_PIN) && defined(LED_BUILTIN)
132-
#define IR_FEEDBACK_LED_PIN LED_BUILTIN
133+
#define IR_FEEDBACK_LED_PIN LED_BUILTIN
133134
#endif
134135

135136
#if !( \
@@ -150,7 +151,7 @@ volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData;
150151
* Declaration of the callback function provided by the user application.
151152
* It is called every time a complete IR command or repeat was received.
152153
*/
153-
extern void handleTinyReceivedIRData();
154+
extern void handleReceivedTinyIRData();
154155

155156
#if defined(LOCAL_DEBUG)
156157
uint32_t sMicrosOfGap; // The length of the gap before the start bit
@@ -569,26 +570,31 @@ bool enablePCIInterruptForTinyReceiver() {
569570

570571
#if defined(USE_ATTACH_INTERRUPT) || defined(USE_ATTACH_INTERRUPT_DIRECT)
571572
# if defined(USE_ATTACH_INTERRUPT)
572-
#if defined(NOT_AN_INTERRUPT)
573+
# if defined(NOT_AN_INTERRUPT) // check if IDE has defined the check of digitalPinToInterrupt
573574
if(digitalPinToInterrupt(IR_RECEIVE_PIN) == NOT_AN_INTERRUPT){
574575
return false;
575576
}
576-
#endif
577+
# endif
577578
// costs 112 bytes program memory + 4 bytes RAM
579+
# if defined(ARDUINO_ARCH_SAMD) // see https://www.arduino.cc/reference/tr/language/functions/external-interrupts/attachinterrupt/ paragraph: Syntax
580+
attachInterrupt(IR_RECEIVE_PIN, IRPinChangeInterruptHandler, CHANGE); // no extra pin mapping here :-(
581+
# else
578582
attachInterrupt(digitalPinToInterrupt(IR_RECEIVE_PIN), IRPinChangeInterruptHandler, CHANGE);
583+
# endif
579584
# else
585+
// USE_ATTACH_INTERRUPT_DIRECT here, only defined for ATtinies *16, see above
580586
// 2.2 us more than version configured with macros and not compatible
581587
attachInterrupt(IR_RECEIVE_PIN, IRPinChangeInterruptHandler, CHANGE); // no extra pin mapping here
582588
# endif
583589

584590
# if defined(LOCAL_DEBUG_ATTACH_INTERRUPT)
585591
Serial.println(F("Use attachInterrupt for pin=" STR(IR_RECEIVE_PIN)));
586592
# endif
587-
588593
#else
589594
# if defined(LOCAL_DEBUG_ATTACH_INTERRUPT)
590595
Serial.println(F("Use static interrupt for pin=" STR(IR_RECEIVE_PIN)));
591596
# endif
597+
592598
# if defined(USE_INT0)
593599
// interrupt on any logical change
594600
EICRA |= _BV(ISC00);

examples/IRDispatcherControl/Distance.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,10 @@ int8_t scanForTargetAndPrint(uint8_t aMaximumTargetDistance) {
626626
}
627627

628628
// Clear old line
629-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y,
629+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y,
630630
sRawForwardDistancesArray[tIndex], tServoDegreeToScan, COLOR16_WHITE, 3);
631631
// draw new one and store value in distances array for clearing at next scan
632-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tCentimeter, tServoDegreeToScan,
632+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tCentimeter, tServoDegreeToScan,
633633
tColor, 3);
634634
sRawForwardDistancesArray[tIndex] = tCentimeter;
635635
}
@@ -673,7 +673,7 @@ int8_t scanForTargetAndPrint(uint8_t aMaximumTargetDistance) {
673673
* Print results
674674
*/
675675
#if defined(USE_BLUE_DISPLAY_GUI)
676-
sprintf_P(sBDStringBuffer, PSTR("rotation:%3d\xB0 distance:%3dcm"), tRotationDegree, tMinDistance); // \xB0 is degree character
676+
snprintf_P(sBDStringBuffer, sizeof(sBDStringBuffer), PSTR("rotation:%3d\xB0 distance:%3dcm"), tRotationDegree, tMinDistance); // \xB0 is degree character
677677
BlueDisplay1.drawText(BUTTON_WIDTH_3_5_POS_2, US_DISTANCE_MAP_ORIGIN_Y + TEXT_SIZE_11, sBDStringBuffer, TEXT_SIZE_11,
678678
COLOR16_BLACK, COLOR16_WHITE);
679679
#else
@@ -819,9 +819,9 @@ bool __attribute__((weak)) fillAndShowForwardDistancesInfo(bool aDoFirstValue, b
819819
/*
820820
* Clear old and draw new distance line
821821
*/
822-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y,
822+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y,
823823
sForwardDistancesInfo.RawDistancesArray[tIndex], tCurrentDegrees, COLOR16_WHITE, 3);
824-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tCentimeter, tCurrentDegrees, tColor,
824+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tCentimeter, tCurrentDegrees, tColor,
825825
3);
826826
}
827827

@@ -862,7 +862,7 @@ void drawForwardDistancesInfos() {
862862
/*
863863
* Draw line
864864
*/
865-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tDistance, tCurrentDegrees, tColor, 3);
865+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tDistance, tCurrentDegrees, tColor, 3);
866866
tCurrentDegrees += DEGREES_PER_STEP;
867867
}
868868
}
@@ -1024,7 +1024,7 @@ void doWallDetection() {
10241024
tNextDistanceOriginal = tNextDistanceComputed;
10251025
#if defined(USE_BLUE_DISPLAY_GUI)
10261026
if (sCurrentPage == PAGE_AUTOMATIC_CONTROL) {
1027-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tNextDistanceComputed,
1027+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tNextDistanceComputed,
10281028
tCurrentAngleToCheck, COLOR16_WHITE, 1);
10291029
}
10301030
#endif
@@ -1098,7 +1098,7 @@ void doWallDetection() {
10981098
tNextValue = tNextValueComputed;
10991099
#if defined(USE_BLUE_DISPLAY_GUI)
11001100
if (sCurrentPage == PAGE_AUTOMATIC_CONTROL) {
1101-
BlueDisplay1.drawVectorDegrees(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tNextValueComputed,
1101+
BlueDisplay1.drawVectorDegree(US_DISTANCE_MAP_ORIGIN_X, US_DISTANCE_MAP_ORIGIN_Y, tNextValueComputed,
11021102
tCurrentAngleToCheck, COLOR16_WHITE, 1);
11031103
}
11041104
#endif

examples/IRDispatcherControl/IRCommandDispatcher.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#else
6060
//#define LOCAL_INFO // This enables info output only for this file
6161
#endif
62-
#if defined(DEBUG) && !defined(LOCAL_DEBUG)
62+
#if defined(DEBUG)
6363
#define LOCAL_DEBUG
6464
// Propagate debug level
6565
#define LOCAL_INFO
@@ -78,7 +78,7 @@ IRCommandDispatcher IRDispatcher;
7878
#endif
7979

8080
#if defined(USE_TINY_IR_RECEIVER)
81-
#define USE_CALLBACK_FOR_TINY_RECEIVER // Call the fixed function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
81+
#define USE_CALLBACK_FOR_TINY_RECEIVER // Call the user provided function "void handleReceivedTinyIRData()" each time a frame or repeat is received.
8282
#include "TinyIRReceiver.hpp" // included in "IRremote" library
8383

8484
void IRCommandDispatcher::init() {

examples/IRDispatcherControl/RobotCarUtils.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ bool readVINVoltage() {
249249
// tVIN * 0,01182795
250250
#if defined(VIN_VOLTAGE_CORRECTION)
251251
// we have a diode (requires 0.8 to 0.9 volt) between LiIon and VIN
252-
sVINVoltage = (tVINRawSum * ((VOLTAGE_DIVIDER_DIVISOR * (ADC_INTERNAL_REFERENCE_MILLIVOLT / (1000.0 * NUMBER_OF_VIN_SAMPLES))) / 1023)) + VIN_VOLTAGE_CORRECTION;
252+
sVINVoltage = (tVINRawSum * ((VOLTAGE_DIVIDER_DIVISOR * (ADC_INTERNAL_REFERENCE_MILLIVOLT / (1000.0 * NUMBER_OF_VIN_SAMPLES))) / 1024)) + VIN_VOLTAGE_CORRECTION;
253253
#else
254254
/*
255255
* Here voltage correction is 0 volt.
256256
* tVINRawSum * 0.000591
257257
*/
258258
sVINVoltage = tVINRawSum
259-
* ((VOLTAGE_DIVIDER_DIVISOR * (ADC_INTERNAL_REFERENCE_MILLIVOLT / 1000.0)) / (1023.0 * NUMBER_OF_VIN_SAMPLES));
259+
* ((VOLTAGE_DIVIDER_DIVISOR * (ADC_INTERNAL_REFERENCE_MILLIVOLT / 1000.0)) / (1024.0 * NUMBER_OF_VIN_SAMPLES));
260260
#endif
261261
// resolution is about 5 mV and we display in a 10 mV resolution -> compare with (2 * NUMBER_OF_VIN_SAMPLES)
262262
if (abs(sLastVINRawSum - tVINRawSum) > (2 * NUMBER_OF_VIN_SAMPLES)) {
@@ -283,7 +283,7 @@ void readVINVoltageAndAdjustDriveSpeedAndPrint() {
283283
RobotCar.setDriveSpeedPWMFor2Volt(sVINVoltage);
284284
PWMDcMotor::MotorPWMHasChanged = true; // to force a new display of motor voltage
285285

286-
sprintf_P(sBDStringBuffer, PSTR("2 volt PWM %3d -> %3d"), tOldDriveSpeedPWM, RobotCar.rightCarMotor.DriveSpeedPWMFor2Volt);
286+
snprintf_P(sBDStringBuffer, sizeof(sBDStringBuffer), PSTR("2 volt PWM %3d -> %3d"), tOldDriveSpeedPWM, RobotCar.rightCarMotor.DriveSpeedPWMFor2Volt);
287287
BlueDisplay1.debug(sBDStringBuffer);
288288
# else
289289
Serial.print(F("2 volt PWM: "));

0 commit comments

Comments
 (0)