Skip to content

Commit 4885817

Browse files
authored
Merge pull request #5 from arduino-libraries/fix_warnings
Fix (almost all) compilation warnings
2 parents 218a509 + 2b5f5f2 commit 4885817

File tree

26 files changed

+85
-258
lines changed

26 files changed

+85
-258
lines changed

examples/Application/IrrigationSimple/AlarmTasks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ AlarmTask parseAlarmTask(const String line)
4848
AlarmTask task;
4949

5050
line.toCharArray(buf, len);
51-
auto n = sscanf(buf, "%s %d %d %d %d %s", &method, &task.day, &task.hour, &task.min, &task.sec, cmd);
51+
auto n = sscanf(buf, "%s %d %d %d %d %s", method, &task.day, &task.hour, &task.min, &task.sec, cmd);
5252
if (n != 6)
5353
return task;
5454

examples/Application/IrrigationSimple/Helpers.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,30 @@ float getAverage05VRead(int pin)
6767
analogReadResolution(ADC_RESOLUTION);
6868

6969
Input.enable();
70-
for (auto i = 0; i < loops; i++)
70+
for (auto i = 0u; i < loops; i++)
7171
tot += Input.analogRead(pin);
7272
Input.disable();
7373

74-
const auto avg = float { tot } * toV / float { loops };
74+
const auto avg = static_cast<float>(tot) * toV / static_cast<float>(loops);
7575

7676
return avg / rDiv;
7777
}
7878

79-
int getAverageInputRead(int pin, const size_t loops)
79+
uint16_t getAverageInputRead(int pin, const size_t loops)
8080
{
8181
unsigned int tot { 0 };
8282

8383
analogReadResolution(ADC_RESOLUTION);
8484

8585
Input.enable();
86-
for (auto i = 0; i < loops; i++)
86+
for (auto i = 0u; i < loops; i++)
8787
tot += Input.analogRead(pin);
8888
Input.disable();
8989

9090
return tot / loops;
9191
}
9292

93-
int getMoisturePerc(int pin)
93+
uint8_t getMoisturePerc(int pin)
9494
{
9595
// Keep track ok dry/wet values. YMMV.
9696
static long dryValue { 2160 };
@@ -106,5 +106,5 @@ int getMoisturePerc(int pin)
106106

107107
auto perc = map(val, dryValue, wetValue, 0, 100);
108108

109-
return perc;
109+
return static_cast<uint8_t>(perc);
110110
}

examples/Application/IrrigationSimple/Helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
void setSystemClock(String date = __DATE__, String time = __TIME__);
1313
void statusPrint();
14-
int getAverageInputRead(int pin, size_t loops = 20);
14+
uint16_t getAverageInputRead(int pin, size_t loops = 20);
1515
float getAverage05VRead(int pin);
16-
int getMoisturePerc(int pin);
16+
uint8_t getMoisturePerc(int pin);
1717

1818
extern std::list<AlarmID_t> alarmTabIDs;
1919
extern std::list<AlarmID_t> alarmSketchIDs;
20-
extern std::list<DataPoint> dataPoints;
20+
extern std::list<DataPoint> dataPoints;

examples/Application/IrrigationSimpleLCD/AlarmTasks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ AlarmTask parseAlarmTask(const String line)
4848
AlarmTask task;
4949

5050
line.toCharArray(buf, len);
51-
auto n = sscanf(buf, "%s %d %d %d %d %s", &method, &task.day, &task.hour, &task.min, &task.sec, cmd);
51+
auto n = sscanf(buf, "%s %d %d %d %d %s", method, &task.day, &task.hour, &task.min, &task.sec, cmd);
5252
if (n != 6)
5353
return task;
5454

examples/Application/IrrigationSimpleLCD/Helpers.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,30 @@ float getAverage05VRead(int pin)
110110
analogReadResolution(ADC_RESOLUTION);
111111

112112
Input.enable();
113-
for (auto i = 0; i < loops; i++)
113+
for (auto i = 0u; i < loops; i++)
114114
tot += Input.analogRead(pin);
115115
Input.disable();
116116

117-
const auto avg = float { tot } * toV / float { loops };
117+
const auto avg = static_cast<float>(tot) * toV / static_cast<float>(loops);
118118

119119
return avg / rDiv;
120120
}
121121

122-
int getAverageInputRead(int pin, const size_t loops)
122+
uint16_t getAverageInputRead(int pin, const size_t loops)
123123
{
124124
unsigned int tot { 0 };
125125

126126
analogReadResolution(ADC_RESOLUTION);
127127

128128
Input.enable();
129-
for (auto i = 0; i < loops; i++)
129+
for (auto i = 0u; i < loops; i++)
130130
tot += Input.analogRead(pin);
131131
Input.disable();
132132

133133
return tot / loops;
134134
}
135135

136-
int getMoisturePerc(int pin)
136+
uint8_t getMoisturePerc(int pin)
137137
{
138138
// Keep track ok dry/wet values. YMMV.
139139
static long dryValue { 2160 };

examples/Application/IrrigationSimpleLCD/Helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
void setSystemClock(String date = __DATE__, String time = __TIME__);
1414
void statusLCD();
1515
void backlightOff(bool powerDown);
16-
int getAverageInputRead(int pin, size_t loops = 20);
16+
uint16_t getAverageInputRead(int pin, size_t loops = 20);
1717
float getAverage05VRead(int pin);
18-
int getMoisturePerc(int pin);
18+
uint8_t getMoisturePerc(int pin);
1919
void displayMsg(const String msg, const unsigned timeout = 5000, const unsigned line = 0, const bool clear = true, const bool off = true);
2020

2121
extern std::list<AlarmID_t> alarmTabIDs;
2222
extern std::list<AlarmID_t> alarmSketchIDs;
23-
extern std::list<DataPoint> dataPoints;
23+
extern std::list<DataPoint> dataPoints;

examples/Application/LowPowerDataLogger/Helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int getAverageInputRead(int pin, const size_t loops)
5050
analogReadResolution(ADC_RESOLUTION);
5151

5252
Input.enable();
53-
for (auto i = 0; i < loops; i++)
53+
for (auto i = 0u; i < loops; i++)
5454
tot += Input.analogRead(pin);
5555
Input.disable();
5656

examples/Basic/0-5V_Input/0-5V_Input.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void setup()
3535
delay(1000);
3636
Serial.println("Hello, Challenge!");
3737

38-
Power.enable3V3();
39-
Power.enable5V();
38+
Power.on(PWR_3V3);
39+
Power.on(PWR_VBAT);
4040

4141
Wire.begin();
4242
Expander.begin();
@@ -89,9 +89,9 @@ Voltages getAverageAnalogRead(int pin)
8989

9090
int tot { 0 };
9191

92-
for (auto i = 0; i < loops; i++)
92+
for (auto i = 0u; i < loops; i++)
9393
tot += Input.analogRead(pin);
94-
const auto avg = float { tot } * toV / float { loops };
94+
const auto avg = static_cast<float>(tot) * toV / static_cast<float>(loops);
9595

9696
return { avg, avg / rDiv };
9797
}

examples/Basic/19V/19V.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ void setup()
1818
delay(1000);
1919
Serial.println("Hello, Challenge!");
2020

21-
Power.enable3V3();
22-
Power.enable5V();
23-
Power.enable19V();
21+
Power.on(PWR_3V3);
22+
Power.on(PWR_VBAT);
23+
Power.on(PWR_19V);
2424

2525
Wire.begin();
2626
Expander.begin();
@@ -60,9 +60,9 @@ Voltages getAverageAnalogRead(int pin)
6060

6161
int tot { 0 };
6262

63-
for (auto i = 0; i < loops; i++)
63+
for (auto i = 0u; i < loops; i++)
6464
tot += Input.analogRead(pin);
65-
const auto avg = float { tot } * toV / float { loops };
65+
const auto avg = static_cast<float>(tot) * toV / static_cast<float>(loops);
6666

6767
return { avg, avg / rDiv };
6868
}

examples/Basic/4-20mA_Input/4-20mA_Input.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ void setup()
3434
delay(1000);
3535
Serial.println("Hello, Challenge!");
3636

37-
Power.enable3V3();
38-
Power.enable5V();
39-
Power.enable19V();
37+
Power.on(PWR_3V3);
38+
Power.on(PWR_VBAT);
39+
Power.on(PWR_19V);
4040

4141
Wire.begin();
4242
Expander.begin();
@@ -85,9 +85,9 @@ Voltages getAverageAnalogRead(int pin)
8585

8686
int tot { 0 };
8787

88-
for (auto i = 0; i < loops; i++)
88+
for (auto i = 0u; i < loops; i++)
8989
tot += Input.analogRead(pin);
90-
const auto avg = float { tot } * toV / float { loops };
90+
const auto avg = static_cast<float>(tot) * toV / static_cast<float>(loops);
9191

9292
return { avg, avg / rDiv };
9393
}

0 commit comments

Comments
 (0)