tjc+time
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
#include "TJC_Show.h"
|
||||
|
||||
|
||||
extern RunTime runtime;
|
||||
|
||||
TJC_Show::TJC_Show(HardwareSerial& serial, DS18B20& sensor, BH1750& bh1750_a, BH1750& bh1750_b, MCP45HVX1& digiPot, INA226& INA)
|
||||
: _serial(serial), _sensor(sensor), _bh1750_a(bh1750_a), _bh1750_b(bh1750_b), _digiPot(digiPot), _INA(INA) {}
|
||||
|
||||
|
||||
// 陶晶池串口屏初始化
|
||||
void TJC_Show::TJC_Show_Init()
|
||||
{
|
||||
_serial.begin(115200, SERIAL_8N1, TJC_RX_Pin, TJC_TX_Pin);
|
||||
while (_serial.read() >= 0); // 清空串口缓冲区
|
||||
_serial.print("page main\xff\xff\xff"); // 跳转到 main 页面
|
||||
}
|
||||
|
||||
// 陶晶池串口屏显示二维码
|
||||
void TJC_Show::showQR()
|
||||
{
|
||||
char addr[64];
|
||||
IPAddress ip = WiFi.localIP();
|
||||
sprintf(addr, "qr0.txt=\"http://%d.%d.%d.%d/\"\xff\xff\xff", ip[0], ip[1], ip[2], ip[3]);
|
||||
_serial.print(addr);
|
||||
}
|
||||
|
||||
//陶晶池串口屏发送
|
||||
void TJC_Show::showINFO(unsigned long activeDuration) {
|
||||
char str[128];
|
||||
|
||||
sprintf(str, "t0.txt=\"%.2f\"\xff\xff\xff", _sensor.getTempC());
|
||||
_serial.print(str);
|
||||
|
||||
sprintf(str, "t1.txt=\"%.f\"\xff\xff\xff", _bh1750_a.readLightLevel());
|
||||
_serial.print(str);
|
||||
sprintf(str, "t2.txt=\"%.f\"\xff\xff\xff", _bh1750_b.readLightLevel());
|
||||
_serial.print(str);
|
||||
|
||||
sprintf(str, "t14.txt=\"%s\"\xff\xff\xff", runtime.formatDuration(runtime.getActiveDuration()));
|
||||
_serial.print(str);
|
||||
|
||||
sprintf(str, "t8.txt=\"%d\"\xff\xff\xff", _digiPot.readWiper());
|
||||
_serial.print(str);
|
||||
|
||||
sprintf(str, "t9.txt=\"%.3f\"\xff\xff\xff", _INA.getBusVoltage(), 3);
|
||||
_serial.print(str);
|
||||
sprintf(str, "t10.txt=\"%.3f\"\xff\xff\xff", _INA.getShuntVoltage_mV(), 3);
|
||||
_serial.print(str);
|
||||
sprintf(str, "t11.txt=\"%.3f\"\xff\xff\xff", _INA.getCurrent_mA(), 3);
|
||||
_serial.print(str);
|
||||
sprintf(str, "t12.txt=\"%.3f\"\xff\xff\xff", _INA.getPower_mW(), 3);
|
||||
_serial.print(str);
|
||||
}
|
||||
Reference in New Issue
Block a user