你想去哪里游玩呢?带上这个作品吧!
材料清单
- 掌控板 X1 链接
步骤1 下载Mind+
作品选择的编程平台是“Mind+”,这提供一个下载地址:https://www.mindplus.cc
步骤2 天气预报
旅途中倍受关注的莫过于天气了。因此运用了互联网模块以获取天气,当按下A键,可以显示天气及最高气温、最低气温,还可以显示气象图标呢。当然,热点名称及密码可以修改~
步骤3 计步功能
一天的旅行结束后,往往会看看自己的成就——步数,在这个功能中用到了掌控版自带的三轴加速度传感器。当按下B键,开始计步;当触摸P键,步数清零。
步骤4 手电筒
在晚上徒步时常常会用到手电筒。而掌控板上的RGB LED可以实现这个功能。触摸Y键,打开手电筒;触摸T键,会关闭手电筒。
步骤5 求救装置
有好事就有坏事。可能您在越野中发生了危险,那么这个功能就发挥作用了。当触摸H键,蜂鸣器鸣叫;触摸O键,停止鸣叫。
步骤6 亮度提醒
人们在划船时,景色怡人,但是湖面上反射的水光对眼睛不好,这时就要戴上墨镜了。当触摸N键,若光线亮,显示“有点亮”,反之则显示“光线正常”。
如果您是位编程高手,这提供一个源代码(因本人是一名小学生,选用了模块化编程 ^_^)↓↓↓
代码
#include <MPython.h>
#include <DFRobot_Iot.h>
#include <mPython_Weather.h>
double _6B65_6570;
DFRobot_Iot myIot;
mPython_Weather myWeather;
const uint8_t imageMatrix__I5Q[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xf8,0x6f,0xff,0xff,0xc0,0xff,0xff,0xf8,0x25,0xff,0xff,0xc0,0xff,0xff,0x80,0x1,0xff,0xff,0xc0,0xff,0xfe,0x1b,0x80,0x3f,0xff,0xc0,0xff,0xfc,0x3f,0xf8,0x27,0xff,0xc0,0xff,0xfc,0x78,0x0,0x3,0xff,0xc0,0xff,0xfc,0xf0,0x1,0x3,0xff,0xc0,0xff,0xf9,0xc0,0x0,0xc7,0xff,0xc0,0xff,0xff,0x80,0x0,0x41,0xff,0xc0,0xff,0xfb,0x80,0x0,0x0,0xff,0xc0,0xff,0xf7,0x0,0x0,0x30,0xff,0xc0,0xff,0xf7,0x0,0x0,0x19,0xff,0xc0,0xff,0xf2,0x0,0x0,0x11,0xff,0xc0,0xff,0xe6,0x0,0x0,0x11,0xff,0xc0,0xff,0xc6,0x0,0x0,0x18,0xff,0xc0,0xff,0xc0,0x0,0x0,0x1d,0xff,0xc0,0xff,0xe0,0x0,0x0,0x1d,0xff,0xc0,0xff,0xe0,0x0,0x0,0x19,0xff,0xc0,0xff,0xf1,0x0,0x0,0x1f,0xff,0xc0,0xff,0xe1,0x0,0x0,0x3d,0xff,0xc0,0xff,0xe0,0x0,0x0,0x39,0xff,0xc0,0xff,0xf0,0x0,0x0,0x1,0xff,0xc0,0xff,0xf8,0x40,0x0,0x87,0xff,0xc0,0xff,0xfc,0x10,0x1,0xf,0xff,0xc0,0xff,0xfc,0x0,0x0,0x1f,0xff,0xc0,0xff,0xff,0x0,0x50,0xf,0xff,0xc0,0xff,0xff,0x0,0x0,0x1f,0xff,0xc0,0xff,0xff,0x80,0x0,0xff,0xff,0xc0,0xff,0xff,0xf0,0x3,0xff,0xff,0xc0,0xff,0xff,0xff,0x3,0xff,0xff,0xc0,0xff,0xff,0xff,0xf7,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0x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0x11,0x64,0x10,0x70,0x31,0x8c,0xe2,0x04,0x00,0x00,0x00,0x00}},
{0x62a5,0xe68aa5,0xB1A8,{0x23,0xfc,0x22,0x04,0xfa,0x0c,0x22,0x78,0x22,0x00,0x3b,0xfc,0x72,0x84,0xa2,0x88,0x22,0x48,0x22,0x70,0x22,0x30,0x22,0xd8,0x63,0x04,0x00,0x00,0x00,0x00,0x00,0x00}},
{0x957f,0xe995bf,0xB3A4,{0x00,0x00,0x10,0x10,0x10,0x60,0x11,0xc0,0x16,0x00,0x10,0x00,0xff,0xfe,0x11,0x00,0x10,0x80,0x10,0xc0,0x10,0x60,0x10,0x18,0x13,0x04,0x18,0x00,0x00,0x00,0x00,0x00}},
{0x6625,0xe698a5,0xB4BA,{0x00,0x00,0x01,0x00,0x7f,0xfc,0x02,0x00,0x3f,0xf8,0x06,0x00,0x7f,0xfc,0x18,0x20,0x3f,0xf8,0x58,0x34,0x1f,0xf0,0x18,0x30,0x1f,0xf0,0x18,0x30,0x00,0x00,0x00,0x00}},
{0x6700,0xe69c80,0xD7EE,{0x00,0x00,0x3f,0xf8,0x20,0x08,0x3f,0xf8,0x20,0x08,0xff,0xfe,0x22,0x00,0x3e,0xfc,0x22,0x48,0x3e,0x48,0x22,0x30,0x2f,0x30,0x72,0x58,0x02,0x84,0x00,0x00,0x00,0x00}},
{0x9ad8,0xe9ab98,0xB8DF,{0x00,0x00,0x01,0x00,0xff,0xfe,0x00,0x00,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x00,0x00,0x7f,0xfc,0x40,0x04,0x4f,0xe4,0x48,0x24,0x4f,0xe4,0x40,0x3c,0x00,0x00,0x00,0x00}},
{0x6e29,0xe6b8a9,0xCEC2,{0x00,0x00,0x47,0xf8,0x24,0x08,0x17,0xf8,0x44,0x08,0x67,0xf8,0x24,0x08,0x00,0x00,0x27,0xfc,0x25,0x24,0x65,0x24,0x65,0x24,0x45,0x24,0x5f,0xfe,0x00,0x00,0x00,0x00}},
{0x4f4e,0xe4bd8e,0xB5CD,{0x00,0x00,0x10,0x1c,0x17,0xf0,0x34,0x60,0x24,0x20,0x64,0x20,0xe7,0xfe,0xa4,0x20,0x24,0x20,0x24,0x20,0x24,0xa2,0x27,0x92,0x26,0x5e,0x24,0x4c,0x00,0x00,0x00,0x00}},
{0x8ba1,0xe8aea1,0xBCC6,{0x00,0x00,0x40,0x40,0x20,0x40,0x10,0x40,0x00,0x40,0xe7,0xfe,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x3c,0x40,0x38,0x40,0x20,0x40,0x00,0x00,0x00,0x00}},
{0x6b65,0xe6ada5,0xB2BD,{0x00,0x00,0x01,0x00,0x11,0x00,0x11,0xf8,0x11,0x00,0x11,0x00,0xff,0xfe,0x09,0x08,0x11,0x18,0x21,0x30,0x40,0xe0,0x03,0x80,0x1e,0x00,0x70,0x00,0x00,0x00,0x00,0x00}},
{0x6570,0xe695b0,0xCAFD,{0x00,0x00,0x49,0x20,0x6a,0x40,0x2a,0x7e,0x7f,0x44,0x38,0xcc,0xcf,0xc8,0x10,0x48,0xfe,0x28,0x22,0x30,0x36,0x30,0x1c,0x78,0x32,0xcc,0xc1,0x86,0x00,0x00,0x00,0x00}},
{0xff1a,0xefbc9a,0xff1a,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00}},
{0x6709,0xe69c89,0xD3D0,{0x00,0x00,0x02,0x00,0x06,0x00,0x7f,0xfe,0x08,0x00,0x1f,0xf8,0x30,0x08,0x5f,0xf8,0x90,0x08,0x10,0x08,0x1f,0xf8,0x10,0x08,0x10,0x08,0x10,0x70,0x00,0x00,0x00,0x00}},
{0x70b9,0xe782b9,0xB5E3,{0x00,0x00,0x01,0x00,0x01,0xfc,0x01,0x00,0x01,0x00,0x3f,0xf8,0x20,0x08,0x20,0x08,0x3f,0xf8,0x00,0x00,0x24,0x88,0x64,0xcc,0x44,0x44,0x42,0x44,0x00,0x00,0x00,0x00}},
{0x4eae,0xe4baae,0xC1C1,{0x00,0x00,0x01,0x00,0x7f,0xfc,0x00,0x00,0x1f,0xf0,0x10,0x10,0x1f,0xf0,0x00,0x00,0x7f,0xfc,0x40,0x04,0x0f,0xc0,0x08,0x42,0x18,0x66,0x60,0x3c,0x00,0x00,0x00,0x00}},
{0x5149,0xe58589,0xB9E2,{0x00,0x00,0x01,0x00,0x21,0x08,0x31,0x18,0x19,0x30,0x09,0x20,0x01,0x00,0xff,0xfe,0x04,0x40,0x0c,0x40,0x08,0x42,0x18,0x42,0x30,0x46,0xc0,0x7c,0x00,0x00,0x00,0x00}},
{0x7ebf,0xe7babf,0xCFDF,{0x00,0x00,0x10,0x90,0x30,0x88,0x20,0x8c,0x48,0xf0,0x4e,0x80,0xf0,0x8e,0x20,0xf0,0x27,0xc0,0x78,0x48,0x40,0x58,0x08,0x62,0x71,0xf6,0xc6,0x1c,0x00,0x00,0x00,0x00}},
{0x6b63,0xe6ada3,0xD5FD,{0x00,0x00,0x7f,0xfc,0x00,0x80,0x00,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0xfc,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0xff,0xfe,0x00,0x00,0x00,0x00}},
{0x5e38,0xe5b8b8,0xB3A3,{0x00,0x00,0x11,0x18,0x19,0x30,0x7f,0xfc,0x40,0x04,0x5f,0xf4,0x10,0x10,0x1f,0xf0,0x01,0x00,0x3f,0xf8,0x21,0x08,0x21,0x08,0x21,0x38,0x01,0x00,0x00,0x00,0x00,0x00}},
};
void onButtonAPressed()
{
display.setCursorXY(35, 22);
display.print("天气预报");
myIot.wifiConnect("OPPO A57", "12345678");
while (!myIot.wifiStatus()) {
}
display.fillScreen(1);
for (int count = 0; count < 2; count++) {
display.setCursorXY(18, 5);
display.print("长春天气");
display.setCursorXY(18, 30);
display.print(myWeather.getWeather("weather", "101060101"));
}
for (int count = 0; count < 2; count++) {
display.setCursorXY(18, 5);
display.print("最高气温");
display.setCursorXY(18, 30);
display.print(myWeather.getWeather("temperaturHigh", "101060101"));
}
for (int count = 0; count < 2; count++) {
display.setCursorXY(18, 5);
display.print("最低气温");
display.setCursorXY(18, 30);
display.print(myWeather.getWeather("temperaturLow", "101060101"));
}
display.fillScreen(1);
if ((myWeather.getWeather("weather", "101060101") == "晴")) {
display.drawImage(39, 7, 50, 50, imageMatrix__I5Q);
}
else {
display.drawImage(39, 7, 50, 50, imageMatrix_FGnF);
}
}
void onButtonBPressed()
{
_6B65_6570 = 0;
while (1) {
if (((accelerometer.getStrength()) > 1)) {
_6B65_6570 = _6B65_6570 + 1;
display.setCursorXY(70, 25);
display.print(" ");
display.setCursorXY(70, 25);
display.print(_6B65_6570);
}
delay(200);
display.setCursorXY(0, 25);
display.print(" ");
display.setCursorXY(0, 0);
display.print("计步数:");
display.setCursorXY(70, 0);
display.print(_6B65_6570);
delay(1000);
}
}
void pin27TouchCallback()
{
_6B65_6570 = 0;
}
void pin14TouchCallback()
{
rgb.write(-1, 0xffffff);
}
void pin12TouchCallback()
{
rgb.brightness(round(0));
}
void pin13TouchCallback()
{
while (1) {
buzz.freq(932, BEAT_1_4);
}
}
void pin15TouchCallback()
{
while (1) {
buzz.off();
}
}
void pin4TouchCallback()
{
if ((100 < (light.read()))) {
display.setCursorXY(42, 22);
display.print("有点亮");
}
else {
display.setCursorXY(30, 22);
display.print("光线正常");
}
}
void setup() {
mPython.begin();
buttonA.setPressedCallback(onButtonAPressed);
display.setChCode(chBuf);
myWeather.connectServer();
buttonB.setPressedCallback(onButtonBPressed);
touchPadP.setTouchedCallback(pin27TouchCallback);
touchPadY.setTouchedCallback(pin14TouchCallback);
touchPadT.setTouchedCallback(pin12TouchCallback);
touchPadH.setTouchedCallback(pin13TouchCallback);
touchPadO.setTouchedCallback(pin15TouchCallback);
touchPadN.setTouchedCallback(pin4TouchCallback);
}
void loop() {
}
效果展示↓↓↓
温馨提示:切换功能时要摁RST键噢!
小刚郭2019.09.30
怎么感觉。。。。。。忍不住的想说,嘉年华没你这么干的