Skip to content

Commit 94bf08d

Browse files
committed
misc fixes for esp32 warns
1 parent 028d5c3 commit 94bf08d

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

Adafruit_Prop_Maker_FeatherWing/Prop_Maker_LED_Simpletest/Prop_Maker_LED_Simpletest.ino

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/*
66
* Adafruit Prop-Maker Featherwing
77
* LED Example
8-
*
8+
*
99
* Rainbow swirl example for 3W LED.
1010
*/
1111

@@ -65,7 +65,7 @@ uint8_t i=0;
6565
void setup() {
6666
Serial.begin(115200);
6767
Serial.println("\nProp-Maker Wing: LED Example");
68-
68+
6969
// set up the power pin
7070
pinMode(POWER_PIN, OUTPUT);
7171
// disable the power pin, we're not writing to the LEDs
@@ -84,23 +84,27 @@ void setup() {
8484
pinMode(GREEN_LED, OUTPUT);
8585
pinMode(BLUE_LED, OUTPUT);
8686
#endif
87-
87+
8888
analogWrite(RED_LED, 0);
8989
analogWrite(GREEN_LED, 0);
9090
analogWrite(BLUE_LED, 0);
9191
}
9292

93+
uint32_t Color(uint8_t r, uint8_t g, uint8_t b) {
94+
return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
95+
}
96+
9397
uint32_t Wheel(byte WheelPos) {
9498
WheelPos = 255 - WheelPos;
9599
if(WheelPos < 85) {
96-
return (255 - WheelPos * 3, 0, WheelPos * 3);
100+
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
97101
}
98102
if(WheelPos < 170) {
99103
WheelPos -= 85;
100-
return (0, WheelPos * 3, 255 - WheelPos * 3);
104+
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
101105
}
102106
WheelPos -= 170;
103-
return (WheelPos * 3, 255 - WheelPos * 3, 0);
107+
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
104108
}
105109

106110
void loop()

Mini_Smart_Home_with_Huzzah/HuzzahCrickitIOT-ESP32/HuzzahCrickitIOT-ESP32.ino

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <seesaw_servo.h>
1010
#include <seesaw_motor.h>
1111
#include <seesaw_neopixel.h>
12-
12+
1313
#define NEOPIX_PIN (20) /* Neopixel pin */
1414
#define NEOPIX_NUMBER_OF_PIXELS (7)
1515
#define LUX CRICKIT_SIGNAL1
@@ -49,14 +49,14 @@ seesaw_NeoPixel strip = seesaw_NeoPixel(NEOPIX_NUMBER_OF_PIXELS, NEOPIX_PIN, NEO
4949
#define MQTTled5 "house/led/five"
5050
#define MQTTled5Bright "house/led/five/brightness"
5151
#define MQTTled5Color "house/led/five/color"
52-
//***** Light Level Sensor
52+
//***** Light Level Sensor
5353
#define MQTTlux "house/lux"
54-
//***** Temperature and Humidity Sensor
54+
//***** Temperature and Humidity Sensor
5555
#define MQTTtemp "house/temperature"
5656
#define MQTThumid "house/humidity"
57-
//***** Motion Sensor
57+
//***** Motion Sensor
5858
#define MQTTpir "house/motion"
59-
//***** Door Sensor
59+
//***** Door Sensor
6060
#define MQTTdoor "house/door"
6161

6262
//****************************** Connection Settings
@@ -100,7 +100,7 @@ void setup() {
100100
crickit.pinMode(LUX, INPUT);
101101
crickit.pinMode(PIR, INPUT_PULLUP);
102102
crickit.pinMode(DOOR, INPUT_PULLUP);
103-
103+
104104
myservo.attach(CRICKIT_SERVO1); // attaches the servo to CRICKIT_SERVO1 pin
105105
motor_a.attach(CRICKIT_MOTOR_A1, CRICKIT_MOTOR_A2);
106106
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
@@ -153,7 +153,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
153153
StrPayload = String(message_buff);
154154
int IntPayload = StrPayload.toInt();
155155
Serial.print(StrPayload);
156-
156+
157157
if (String(topic) == MQTTlock) {
158158
if (StrPayload == "UNLOCK") {
159159
myservo.write(180);
@@ -236,7 +236,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
236236
strip.setPixelColor(1, strip.Color(R[1], G[1], B[1]));
237237
}
238238
strip.show();
239-
239+
240240
//.................. Light 3 ......................//
241241
if (String(topic) == MQTTled3) {
242242
if (StrPayload == "OFF") {
@@ -263,7 +263,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
263263
strip.setPixelColor(2, strip.Color(R[2], G[2], B[2]));
264264
}
265265
strip.show();
266-
266+
267267
//.................. Light 4 ......................//
268268
if (String(topic) == MQTTled4) {
269269
if (StrPayload == "OFF") {
@@ -290,7 +290,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
290290
strip.setPixelColor(3, strip.Color(R[3], G[3], B[3]));
291291
}
292292
strip.show();
293-
293+
294294
//.................. Light 5 ......................//
295295
if (String(topic) == MQTTled5) {
296296
if (StrPayload == "OFF") {
@@ -359,7 +359,7 @@ void reconnect() {
359359
client.subscribe(MQTTled5);
360360
client.subscribe(MQTTled5Bright);
361361
client.subscribe(MQTTled5Color);
362-
362+
363363
} else {
364364
Serial.print("failed, rc=");
365365
Serial.print(client.state());
@@ -384,9 +384,9 @@ void loop() {
384384
if (!client.connected()) {
385385
reconnect();
386386
}
387-
387+
388388
//************** Lux Smoothing
389-
389+
390390
total = total - lux_R[readIndex]; // subtract the last reading
391391
lux_R[readIndex] = crickit.analogRead(LUX); // read from the sensor
392392
total = total + lux_R[readIndex]; // add the reading to the total
@@ -400,7 +400,7 @@ void loop() {
400400
Serial.print("Lux = ");
401401
Serial.println(Lux_A);
402402

403-
snprintf (msg, 75, "%ld", Lux_A);
403+
snprintf (msg, 75, "%d", Lux_A);
404404
Serial.println(msg);
405405
client.publish(MQTTlux, msg);
406406

@@ -412,7 +412,7 @@ void loop() {
412412
Serial.println("Motion Sensor = STILL");
413413
client.publish(MQTTpir, "STILL");
414414
}
415-
delay(10);
415+
delay(10);
416416
if (crickit.digitalRead(DOOR)){
417417
Serial.println("Door = OPEN");
418418
client.publish(MQTTdoor, "OPEN");
@@ -421,7 +421,7 @@ void loop() {
421421
client.publish(MQTTdoor, "CLOSED");
422422
}
423423
}
424-
delay(10); // delay in between reads for stability
424+
delay(10); // delay in between reads for stability
425425
client.loop();
426426
}
427427

0 commit comments

Comments
 (0)