Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec14b0f

Browse files
committed
examples/FirebaseNeoPixel: update to new API
- remove colors_ext.h deps
1 parent7934978 commitec14b0f

File tree

2 files changed

+13
-128
lines changed

2 files changed

+13
-128
lines changed

‎examples/FirebaseNeoPixel_ESP8266/FirebaseNeoPixel_ESP8266.ino

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616

1717
// FirebaseNeoPixel is a sample that demonstrates how
1818
// to set pixel data from Firebase.
19-
#include<Firebase.h>
19+
#include<FirebaseArduino.h>
2020
#include<ESP8266WiFi.h>
2121

2222
#include<Adafruit_NeoPixel.h>
23-
#include"colors_ext.h"
2423

2524
// Set these to run example.
2625
#defineFIREBASE_HOST"example.firebaseio.com"
@@ -31,8 +30,8 @@
3130
constint PIN=13;
3231
Adafruit_NeoPixel strip = Adafruit_NeoPixel(32, PIN, NEO_GRB + NEO_KHZ800);
3332

34-
// TODO: Replace with your own credentials and keep these safe.
35-
Firebase fbase =Firebase(FIREBASE_HOST, FIREBASE_AUTH);
33+
constint pixelPin =13;
34+
Adafruit_NeoPixel strip =Adafruit_NeoPixel(32, pixelPin, NEO_GRB + NEO_KHZ800);
3635

3736
voidsetup() {
3837
Serial.begin(9600);
@@ -41,56 +40,35 @@ void setup() {
4140
strip.setBrightness(25);// 0 ... 255
4241
strip.show();// Initialize all pixels to 'off'
4342

44-
// Not connected, set the LEDs red
45-
colorWipe(&strip,0xFF0000,50);
46-
4743
// connect to wifi.
4844
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
4945
Serial.print("connecting");
50-
51-
int count =0;
5246
while (WiFi.status() != WL_CONNECTED) {
53-
// Draw rainbows while connecting
5447
Serial.print(".");
55-
if (count < strip.numPixels()){
56-
strip.setPixelColor(count++,Wheel(&strip, count *8));
57-
strip.show();
58-
}
59-
delay(20);
48+
delay(500);
6049
}
6150
Serial.println();
6251
Serial.print("connected:");
6352
Serial.println(WiFi.localIP());
6453

65-
// Connected, set the LEDs green
66-
colorWipe(&strip,0x00FF00,50);
54+
Firebase.begin("example.firebaseio.com","secret_or_token");
6755
}
6856

6957

7058
voidloop() {
7159
// Get all entries.
7260
// TODO: Replace with streaming
73-
FirebaseGet get =fbase.get("/rgbdata");
74-
if (get.error()) {
61+
FirebaseObject pixels =Firebase.get("/rgbdata");
62+
if (Firebase.failed()) {
7563
Serial.println("Firebase get failed");
76-
Serial.println(get.error().message());
64+
Serial.println(Firebase.error());
7765
return;
7866
}
7967

80-
// create an empty object
81-
const JsonObject& pixelJSON = get.json();
82-
83-
if(pixelJSON.success()){
84-
for (int i=0; i < strip.numPixels(); i++) {
85-
String pixelAddress ="pixel" +String(i);
86-
String pixelVal = pixelJSON[pixelAddress];
87-
Serial.println(pixelVal);
88-
strip.setPixelColor(i, pixelVal.toInt());
89-
}
90-
strip.show();
91-
}else {
92-
Serial.println("Parse fail.");
93-
Serial.println(get.response());
68+
for (int i =0; i < strip.numPixels(); i++) {
69+
int pixel = pixels.getInt("pixel" + i);
70+
Serial.println(pixel);
71+
strip.setPixelColor(i, pixel);
9472
}
73+
strip.show();
9574
}
96-

‎examples/FirebaseNeoPixel_ESP8266/colors_ext.h

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp