#include <Arduino.h>
#include <rgb_show.h>
#include <DS1302.h>
#include <network.h>
#include <boutton.h>
#include <pinpu.h>
const char* ssid = "zk1";
const char* password = "zk011122";
#define TZ 8 // 中国时区为8
#define DST_MN 0 // 默认为0
#define TZ_MN ((TZ) * 60) // 时间换算
#define TZ_SEC ((TZ) * 3600)
#define DST_SEC ((DST_MN) * 60)
String B_fans = "108629265";
hw_timer_t *timer = NULL;
DPLAY SHOW;
DS1302_Dev ds1302_dev;
DS1302_DateTime ds1302_time_data;
_RTC_obj r_calendar;
Network wifi;
bouton btoun;
PINPU FT;
int tem_data;
extern int temperture, weather, Bfans;
void IRAM_ATTR TimerEvent()
{
btoun.boutton_tick();
}
void setup()
{
Serial.begin(115200); /* prepare for possible serial debug */
btoun.boutton_init();
FT.tft_init();
DS1302_begin(&ds1302_dev, 5, 18, 19);
// wifi.SmartConfig(); // wifi智能配网
wifi.init(ssid, password); // wifi密码连接
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &TimerEvent, true);
timerAlarmWrite(timer, 100, true);
timerAlarmEnable(timer); // 使能定时器
wifi.setClock(); // 访问时间并赋值给rtc时钟
tem_data = wifi.getxinzhiweatherdata(); // 获取天气数据
temperture = tem_data / 100;
weather = tem_data % 100;
Serial.printf("%d,%d\r\n", temperture, weather);
Bfans = wifi.getBilibiliFans(B_fans); // 获取B站粉丝数
Serial.printf("B粉丝=%d\r\n", Bfans);
DS1302_setDateTime(&ds1302_dev, &ds1302_time_data);
}
void loop()
{
//DS1302_setDateTime(&ds1302_dev, &ds1302_time_data);
if (flagShow != 0)
{
UpdateShow = flagShow;
FT.ws281x_closeAll();
wifi.setClock();
flagShow = 0;
delay(100);
// printf("%d\r\n", UpdateShow);
// printf("%d\r\n", flagShow);
}
if (UpdateShow == 1)
{
wifi.setClock();
SHOW.Show_Timer();
}
if (UpdateShow == 2)
{
SHOW.Show_Year();
}
if (UpdateShow == 3)
{
SHOW.Show_Temp();
}
if (UpdateShow == 4)
{
}
if (UpdateShow == 5)
{
FT.tft_run();
}
if (UpdateShow == 6) // 更新数据
{
wifi.setClock(); // 访问时间并赋值给rtc时钟
tem_data = wifi.getxinzhiweatherdata(); // 获取天气数据
temperture = tem_data / 100;
weather = tem_data % 100;
Serial.printf("%d,%d\r\n", temperture, weather);
Bfans = wifi.getBilibiliFans(B_fans); // 获取B站粉丝数
Serial.printf("B粉丝=%d\r\n", Bfans);
}
if (UpdateShow == 7)
{
SHOW.Show_Bfans();
// SHOW.ws281x_ShowIcon();
}
if (UpdateShow == 8) // 关闭显示
{
FT.ws281x_closeAll();
}
}