Skip to content

Commit 826ba02

Browse files
committed
Merge branch 'main' into food_scale
2 parents 6353acb + 5fb2d3c commit 826ba02

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
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()

MagTag_Arduino_Demos/shipping_demo/shipping_demo.ino

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setup() {
4040
digitalWrite(NEOPIXEL_POWER, LOW); // on
4141

4242
display.begin(THINKINK_MONO);
43-
43+
4444
if (! lis.begin(0x19)) {
4545
Serial.println("Couldnt start LIS3DH");
4646
display.clearBuffer();
@@ -81,7 +81,7 @@ void loop() {
8181
if (j % 10 == 0) {
8282
sensors_event_t event;
8383
lis.getEvent(&event);
84-
84+
8585
/* Display the results (acceleration is measured in m/s^2) */
8686
Serial.print("X: "); Serial.print(event.acceleration.x);
8787
Serial.print(" \tY: "); Serial.print(event.acceleration.y);
@@ -99,11 +99,11 @@ void loop() {
9999
if ((abs(event.acceleration.x) < 5) && (event.acceleration.y < -5)) {
100100
rotation = 2;
101101
}
102-
102+
103103
int light = analogRead(LIGHT_SENSOR);
104104
Serial.print("Light sensor: ");
105105
Serial.println(light);
106-
106+
107107
Serial.print("I2C scanner: ");
108108
for (int i = 0x07; i <= 0x77; i++) {
109109
Wire.beginTransmission(i);
@@ -118,12 +118,12 @@ void loop() {
118118
if (! digitalRead(BUTTON_A)) {
119119
Serial.println("Button A pressed");
120120
intneo.fill(0xFF0000);
121-
intneo.show();
121+
intneo.show();
122122
}
123123
else if (! digitalRead(BUTTON_B)) {
124124
Serial.println("Button B pressed");
125125
intneo.fill(0x00FF00);
126-
intneo.show();
126+
intneo.show();
127127
}
128128
else if (! digitalRead(BUTTON_C)) {
129129
Serial.println("Button C pressed");
@@ -142,7 +142,7 @@ void loop() {
142142
for (int i = 0; i < intneo.numPixels(); i++) {
143143
intneo.setPixelColor(i, Wheel(((i * 256 / intneo.numPixels()) + j) & 255));
144144
}
145-
intneo.show();
145+
intneo.show();
146146
}
147147

148148
// Red LED off
@@ -155,7 +155,8 @@ void loop() {
155155
void play_tune(const uint8_t *audio, uint32_t audio_length) {
156156
uint32_t t;
157157
uint32_t prior, usec = 1000000L / SAMPLE_RATE;
158-
158+
159+
prior = micros();
159160
for (uint32_t i=0; i<audio_length; i++) {
160161
while((t = micros()) - prior < usec);
161162
dacWrite(A0, audio[i]);

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)