misc fixes for esp32 warns

This commit is contained in:
caternuson 2022-07-07 11:38:24 -07:00
parent 028d5c3796
commit 94bf08de33
2 changed files with 26 additions and 22 deletions

View file

@ -5,7 +5,7 @@
/*
* Adafruit Prop-Maker Featherwing
* LED Example
*
*
* Rainbow swirl example for 3W LED.
*/
@ -65,7 +65,7 @@ uint8_t i=0;
void setup() {
Serial.begin(115200);
Serial.println("\nProp-Maker Wing: LED Example");
// set up the power pin
pinMode(POWER_PIN, OUTPUT);
// disable the power pin, we're not writing to the LEDs
@ -84,23 +84,27 @@ void setup() {
pinMode(GREEN_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
#endif
analogWrite(RED_LED, 0);
analogWrite(GREEN_LED, 0);
analogWrite(BLUE_LED, 0);
}
uint32_t Color(uint8_t r, uint8_t g, uint8_t b) {
return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return (255 - WheelPos * 3, 0, WheelPos * 3);
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return (0, WheelPos * 3, 255 - WheelPos * 3);
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return (WheelPos * 3, 255 - WheelPos * 3, 0);
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
void loop()

View file

@ -9,7 +9,7 @@
#include <seesaw_servo.h>
#include <seesaw_motor.h>
#include <seesaw_neopixel.h>
#define NEOPIX_PIN (20) /* Neopixel pin */
#define NEOPIX_NUMBER_OF_PIXELS (7)
#define LUX CRICKIT_SIGNAL1
@ -49,14 +49,14 @@ seesaw_NeoPixel strip = seesaw_NeoPixel(NEOPIX_NUMBER_OF_PIXELS, NEOPIX_PIN, NEO
#define MQTTled5 "house/led/five"
#define MQTTled5Bright "house/led/five/brightness"
#define MQTTled5Color "house/led/five/color"
//***** Light Level Sensor
//***** Light Level Sensor
#define MQTTlux "house/lux"
//***** Temperature and Humidity Sensor
//***** Temperature and Humidity Sensor
#define MQTTtemp "house/temperature"
#define MQTThumid "house/humidity"
//***** Motion Sensor
//***** Motion Sensor
#define MQTTpir "house/motion"
//***** Door Sensor
//***** Door Sensor
#define MQTTdoor "house/door"
//****************************** Connection Settings
@ -100,7 +100,7 @@ void setup() {
crickit.pinMode(LUX, INPUT);
crickit.pinMode(PIR, INPUT_PULLUP);
crickit.pinMode(DOOR, INPUT_PULLUP);
myservo.attach(CRICKIT_SERVO1); // attaches the servo to CRICKIT_SERVO1 pin
motor_a.attach(CRICKIT_MOTOR_A1, CRICKIT_MOTOR_A2);
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
@ -153,7 +153,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
StrPayload = String(message_buff);
int IntPayload = StrPayload.toInt();
Serial.print(StrPayload);
if (String(topic) == MQTTlock) {
if (StrPayload == "UNLOCK") {
myservo.write(180);
@ -236,7 +236,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
strip.setPixelColor(1, strip.Color(R[1], G[1], B[1]));
}
strip.show();
//.................. Light 3 ......................//
if (String(topic) == MQTTled3) {
if (StrPayload == "OFF") {
@ -263,7 +263,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
strip.setPixelColor(2, strip.Color(R[2], G[2], B[2]));
}
strip.show();
//.................. Light 4 ......................//
if (String(topic) == MQTTled4) {
if (StrPayload == "OFF") {
@ -290,7 +290,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
strip.setPixelColor(3, strip.Color(R[3], G[3], B[3]));
}
strip.show();
//.................. Light 5 ......................//
if (String(topic) == MQTTled5) {
if (StrPayload == "OFF") {
@ -359,7 +359,7 @@ void reconnect() {
client.subscribe(MQTTled5);
client.subscribe(MQTTled5Bright);
client.subscribe(MQTTled5Color);
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
@ -384,9 +384,9 @@ void loop() {
if (!client.connected()) {
reconnect();
}
//************** Lux Smoothing
total = total - lux_R[readIndex]; // subtract the last reading
lux_R[readIndex] = crickit.analogRead(LUX); // read from the sensor
total = total + lux_R[readIndex]; // add the reading to the total
@ -400,7 +400,7 @@ void loop() {
Serial.print("Lux = ");
Serial.println(Lux_A);
snprintf (msg, 75, "%ld", Lux_A);
snprintf (msg, 75, "%d", Lux_A);
Serial.println(msg);
client.publish(MQTTlux, msg);
@ -412,7 +412,7 @@ void loop() {
Serial.println("Motion Sensor = STILL");
client.publish(MQTTpir, "STILL");
}
delay(10);
delay(10);
if (crickit.digitalRead(DOOR)){
Serial.println("Door = OPEN");
client.publish(MQTTdoor, "OPEN");
@ -421,7 +421,7 @@ void loop() {
client.publish(MQTTdoor, "CLOSED");
}
}
delay(10); // delay in between reads for stability
delay(10); // delay in between reads for stability
client.loop();
}