Skip to content

Commit d9a9902

Browse files
authored
Merge pull request #576 from blinker-iot/dev_3.0
update codes, upgrade BLINKER JOYSTICK example codes.
2 parents 729aee6 + a4bd8a7 commit d9a9902

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* *****************************************************************
2+
*
3+
* Download latest Blinker library here:
4+
* https://github.com/blinker-iot/blinker-library/archive/master.zip
5+
*
6+
*
7+
* Blinker is a cross-hardware, cross-platform solution for the IoT.
8+
* It provides APP, device and server support,
9+
* and uses public cloud services for data transmission and storage.
10+
* It can be used in smart home, data monitoring and other fields
11+
* to help users build Internet of Things projects better and faster.
12+
*
13+
* Make sure installed 2.7.4 or later ESP8266/Arduino package,
14+
* if use ESP8266 with Blinker.
15+
* https://github.com/esp8266/Arduino/releases
16+
*
17+
* Make sure installed 1.0.5 or later ESP32/Arduino package,
18+
* if use ESP32 with Blinker.
19+
* https://github.com/espressif/arduino-esp32/releases
20+
*
21+
* Docs: https://diandeng.tech/doc
22+
*
23+
*
24+
* *****************************************************************
25+
*
26+
* Blinker 库下载地址:
27+
* https://github.com/blinker-iot/blinker-library/archive/master.zip
28+
*
29+
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
30+
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
31+
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
32+
*
33+
* 如果使用 ESP8266 接入 Blinker,
34+
* 请确保安装了 2.7.4 或更新的 ESP8266/Arduino 支持包。
35+
* https://github.com/esp8266/Arduino/releases
36+
*
37+
* 如果使用 ESP32 接入 Blinker,
38+
* 请确保安装了 1.0.5 或更新的 ESP32/Arduino 支持包。
39+
* https://github.com/espressif/arduino-esp32/releases
40+
*
41+
* 文档: https://diandeng.tech/doc
42+
*
43+
*
44+
* *****************************************************************/
45+
46+
#define BLINKER_BLE
47+
48+
#include <Blinker.h>
49+
50+
#define JOY_1 "JOYKey"
51+
52+
BlinkerJoystick JOY1(JOY_1);
53+
54+
void joystick1_callback(uint8_t xAxis, uint8_t yAxis)
55+
{
56+
BLINKER_LOG("Joystick1 X axis: ", xAxis);
57+
BLINKER_LOG("Joystick1 Y axis: ", yAxis);
58+
}
59+
60+
void dataRead(const String & data)
61+
{
62+
BLINKER_LOG("Blinker readString: ", data);
63+
64+
Blinker.vibrate();
65+
66+
uint32_t BlinkerTime = millis();
67+
68+
Blinker.print("millis", BlinkerTime);
69+
}
70+
71+
void setup()
72+
{
73+
Serial.begin(115200);
74+
BLINKER_DEBUG.stream(Serial);
75+
76+
pinMode(LED_BUILTIN, OUTPUT);
77+
digitalWrite(LED_BUILTIN, LOW);
78+
79+
Blinker.begin();
80+
Blinker.attachData(dataRead);
81+
82+
JOY1.attach(joystick1_callback);
83+
}
84+
85+
void loop()
86+
{
87+
Blinker.run();
88+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* *****************************************************************
2+
*
3+
* Download latest Blinker library here:
4+
* https://github.com/blinker-iot/blinker-library/archive/master.zip
5+
*
6+
*
7+
* Blinker is a cross-hardware, cross-platform solution for the IoT.
8+
* It provides APP, device and server support,
9+
* and uses public cloud services for data transmission and storage.
10+
* It can be used in smart home, data monitoring and other fields
11+
* to help users build Internet of Things projects better and faster.
12+
*
13+
* Make sure installed 2.5.0 or later ESP8266/Arduino package,
14+
* if use ESP8266 with Blinker.
15+
* https://github.com/esp8266/Arduino/releases
16+
*
17+
* Make sure installed 1.0.2 or later ESP32/Arduino package,
18+
* if use ESP32 with Blinker.
19+
* https://github.com/espressif/arduino-esp32/releases
20+
*
21+
* Docs: https://diandeng.tech/doc
22+
*
23+
*
24+
* *****************************************************************
25+
*
26+
* Blinker 库下载地址:
27+
* https://github.com/blinker-iot/blinker-library/archive/master.zip
28+
*
29+
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
30+
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
31+
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
32+
*
33+
* 如果使用 ESP8266 接入 Blinker,
34+
* 请确保安装了 2.5.0 或更新的 ESP8266/Arduino 支持包。
35+
* https://github.com/esp8266/Arduino/releases
36+
*
37+
* 如果使用 ESP32 接入 Blinker,
38+
* 请确保安装了 1.0.2 或更新的 ESP32/Arduino 支持包。
39+
* https://github.com/espressif/arduino-esp32/releases
40+
*
41+
* 文档: https://diandeng.tech/doc
42+
*
43+
*
44+
* *****************************************************************/
45+
46+
#define BLINKER_WIFI
47+
48+
#include <Blinker.h>
49+
50+
char auth[] = "Your Device Secret Key";
51+
char ssid[] = "Your WiFi network SSID or name";
52+
char pswd[] = "Your WiFi network WPA password or WEP key";
53+
54+
#define JOY_1 "JOYKey"
55+
56+
BlinkerJoystick JOY1(JOY_1);
57+
58+
void joystick1_callback(uint8_t xAxis, uint8_t yAxis)
59+
{
60+
BLINKER_LOG("Joystick1 X axis: ", xAxis);
61+
BLINKER_LOG("Joystick1 Y axis: ", yAxis);
62+
}
63+
64+
void dataRead(const String & data)
65+
{
66+
BLINKER_LOG("Blinker readString: ", data);
67+
68+
Blinker.vibrate();
69+
70+
uint32_t BlinkerTime = millis();
71+
72+
Blinker.print("millis", BlinkerTime);
73+
}
74+
75+
void setup()
76+
{
77+
Serial.begin(115200);
78+
BLINKER_DEBUG.stream(Serial);
79+
80+
pinMode(LED_BUILTIN, OUTPUT);
81+
digitalWrite(LED_BUILTIN, LOW);
82+
83+
Blinker.begin(auth, ssid, pswd);
84+
Blinker.attachData(dataRead);
85+
86+
JOY1.attach(joystick1_callback);
87+
}
88+
89+
void loop()
90+
{
91+
Blinker.run();
92+
}

0 commit comments

Comments
 (0)