Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions examples/air-quality-monitoring/sketch/air_quality_frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@
*/

const uint32_t good[] = {
0x904101f0,
0x5f420212,
0x41390a28,
0x10,
0x0f808209,
0x484042fa,
0x14509c82,
0x08000000,
};

const uint32_t moderate[] = {
0x904101f0,
0x51420212,
0x808209c8,
0xf,
0x0f808209,
0x4840428a,
0x13904101,
0xf0000000,
};

const uint32_t unhealthy_for_sensitive_groups[] = {
0x904101f0,
0x5f420212,
0x80820808,
0xf,
0x0f808209,
0x484042fa,
0x10104101,
0xf0000000,
};

const uint32_t unhealthy[] = {
0x904101f0,
0x4e420212,
0xc1010a28,
0x1f,
0x0f808209,
0x48404272,
0x14508083,
0xf8000000,
};

const uint32_t very_unhealthy[] = {
0x904101f0,
0x4042da12,
0x808209c8,
0xf,
0x0f808209,
0x485b4202,
0x13904101,
0xf0000000,
};

const uint32_t hazardous[] = {
0xd04101f0,
0x44428a16,
0x80540410,
0xa,
0x0f80820b,
0x68514222,
0x08202a01,
0x50000000,
};

const uint32_t unknown[] = {
0x400c0000,
0x4004002,
0x40,
0x1,
0x00003002,
0x40020020,
0x02000000,
0x80000000,
};
48 changes: 24 additions & 24 deletions examples/air-quality-monitoring/sketch/sketch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
//
// SPDX-License-Identifier: MPL-2.0

#include <Arduino_LED_Matrix.h>
#include <Arduino_RouterBridge.h>

#include "air_quality_frames.h"

// TODO: those will go into an header file.
extern "C" void matrixWrite(const uint32_t* buf);
extern "C" void matrixBegin();
Arduino_LED_Matrix matrix;

void setup() {
matrixBegin();
matrix.begin();
matrix.clear();

Bridge.begin();
Bridge.begin();
}

void loop() {
String airQuality;
bool ok = Bridge.call("get_air_quality").result(airQuality);
if (ok) {
if (airQuality == "Good") {
matrixWrite(good);
} else if (airQuality == "Moderate") {
matrixWrite(moderate);
} else if (airQuality == "Unhealthy for Sensitive Groups") {
matrixWrite(unhealthy_for_sensitive_groups);
} else if (airQuality == "Unhealthy") {
matrixWrite(unhealthy);
} else if (airQuality == "Very Unhealthy") {
matrixWrite(very_unhealthy);
} else if (airQuality == "Hazardous") {
matrixWrite(hazardous);
} else {
matrixWrite(unknown);
}
String airQuality;
bool ok = Bridge.call("get_air_quality").result(airQuality);
if (ok) {
if (airQuality == "Good") {
matrix.loadFrame(good);
} else if (airQuality == "Moderate") {
matrix.loadFrame(moderate);
} else if (airQuality == "Unhealthy for Sensitive Groups") {
matrix.loadFrame(unhealthy_for_sensitive_groups);
} else if (airQuality == "Unhealthy") {
matrix.loadFrame(unhealthy);
} else if (airQuality == "Very Unhealthy") {
matrix.loadFrame(very_unhealthy);
} else if (airQuality == "Hazardous") {
matrix.loadFrame(hazardous);
} else {
matrix.loadFrame(unknown);
}
delay(1000);
}
delay(1000);
}
81 changes: 16 additions & 65 deletions examples/keyword-spotting/sketch/heart_frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,20 @@
* SPDX-License-Identifier: MPL-2.0
*/

const uint32_t LittleHeart[] = {
0x20360000,
0x11010409,
0x100140,
0x0
const uint32_t HeartStatic[4] = {
0x00006c04,
0x90208088,
0x02800800,
0x00000000,
};

const uint32_t HeartAnim[][5] = {
{0x1dc11108, 0x08404104, 0x04401400, 0x40000000, 55}, // 1
{0x3fe31198, 0x0cc06306, 0x0c603600, 0xe0000000, 55}, // 2
{0x3fe31198, 0x0cc06306, 0x0c603600, 0xe0000000, 55}, // 3
{0x7ff711f8, 0x0fc07707, 0x1c707701, 0xf0000000, 55}, // 4
{0xffff11f8, 0x0fc07f07, 0xbc78f783, 0xf8000000, 55}, // 5
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ef, 0xfe000000, 55}, // 6
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ff, 0xff000000, 55}, // 7
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ff, 0xff000000, 55} // 8
};

const uint32_t* HeartStatic[] = { LittleHeart };

const uint32_t Heart1[] = {
0x108883b8,
0x20820210,
0x280220,
0x2
};

const uint32_t Heart2[] = {
0x1988c7fc,
0x60c60330,
0x6c0630,
0x7
};

const uint32_t Heart3[] = {
0x1988c7fc,
0x60c60330,
0x6c0630,
0x7
};

const uint32_t Heart4[] = {
0x1f88effe,
0xe0ee03f0,
0x80ee0e38,
0xf
};

const uint32_t Heart5[] = {
0x1f88ffff,
0xe0fe03f0,
0xc1ef1e3d,
0x1f
};

const uint32_t Heart6[] = {
0x1f88ffff,
0xe0fe03f0,
0xf7effe3f,
0x7f
};

const uint32_t Heart7[] = {
0x1f88ffff,
0xe0fe03f0,
0xffeffe3f,
0xff
};

const uint32_t Heart8[] = {
0x1f88ffff,
0xe0fe03f0,
0xffeffe3f,
0xff
};

const uint32_t* HeartAnim[] = { Heart1, Heart2, Heart3, Heart4, Heart5, Heart6, Heart7, Heart8 };
41 changes: 15 additions & 26 deletions examples/keyword-spotting/sketch/sketch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,29 @@
//
// SPDX-License-Identifier: MPL-2.0

#include <Arduino_LED_Matrix.h>
#include <Arduino_RouterBridge.h>
#include "heart_frames.h"

// TODO: those will go into an header file.
extern "C" void matrixWrite(const uint32_t* buf);
extern "C" void matrixBegin();
#include "heart_frames.h"

bool awake = false;
Arduino_LED_Matrix matrix;

void setup() {
matrixBegin();
playAnimation(HeartStatic, 1, 1, 2000);
Bridge.begin();
Bridge.provide("keyword_detected", wake_up);
}
matrix.begin();
matrix.clear();
matrix.loadFrame(HeartStatic);

void loop() {
if (awake) {
playAnimation(HeartAnim, 8, 1, 50);
delay(1000);
playAnimation(HeartStatic, 1, 1, 2000);
awake = false;
}
Bridge.begin();
Bridge.provide("keyword_detected", wake_up);
}

void playAnimation(const uint32_t* frames[], int frameCount, int repeat, int frameDelay) {
for (int r = 0; r < repeat; r++) {
for (int i = 0; i < frameCount; i++) {
matrixWrite(frames[i]);
delay(frameDelay);
}
}
}
void loop() {}

void wake_up() {
awake = true;
matrix.loadSequence(HeartAnim);
matrix.playSequence();

delay(1000);

matrix.loadFrame(HeartStatic);
}
44 changes: 23 additions & 21 deletions examples/weather-forecast/sketch/sketch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,47 @@
//
// SPDX-License-Identifier: MPL-2.0

#include <Arduino_LED_Matrix.h>
#include <Arduino_RouterBridge.h>

#include "weather_frames.h"

// TODO: those will go into an header file.
extern "C" void matrixWrite(const uint32_t* buf);
extern "C" void matrixBegin();
String city = "Turin";

Arduino_LED_Matrix matrix;

void setup() {
matrixBegin();
matrix.begin();
matrix.clear();

Bridge.begin();
}

void playAnimation(const uint32_t* frames[], int frameCount, int repeat, int frameDelay) {
for (int r = 0; r < repeat; r++) {
for (int i = 0; i < frameCount; i++) {
matrixWrite(frames[i]);
delay(frameDelay);
}
}
}

String city = "Turin";

void loop() {
String weather_forecast;
bool ok = Bridge.call("get_weather_forecast", city).result(weather_forecast);
bool ok = Bridge.call("get_weather_forecast", city).result(weather_forecast);
if (ok) {
if (weather_forecast == "sunny") {
playAnimation(SunnyFrames, 2, 20, 500);
matrix.loadSequence(sunny);
playRepeat(10);
} else if (weather_forecast == "cloudy") {
playAnimation(CloudyFrames, 4, 20, 500);
matrix.loadSequence(cloudy);
playRepeat(10);
} else if (weather_forecast == "rainy") {
playAnimation(RainyFrames, 3, 16, 200);
matrix.loadSequence(rainy);
playRepeat(20);
} else if (weather_forecast == "snowy") {
playAnimation(SnowyFrames, 3, 5, 650);
matrix.loadSequence(snowy);
playRepeat(10);
} else if (weather_forecast == "foggy") {
playAnimation(FoggyFrames, 2, 5, 660);
matrix.loadSequence(foggy);
playRepeat(5);
}
}
}

void playRepeat(int repeat_count) {
for (int i = 0; i < repeat_count; i++) {
matrix.playSequence();
}
}
Loading