From a5fb9cce17dd8d09e691a4c3dd92a1b131505520 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Fri, 3 Mar 2023 18:16:45 +0100 Subject: [PATCH 01/26] interim version most likely outdated --- miPayload.h | 581 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 581 insertions(+) create mode 100644 miPayload.h diff --git a/miPayload.h b/miPayload.h new file mode 100644 index 00000000..9c68ee18 --- /dev/null +++ b/miPayload.h @@ -0,0 +1,581 @@ +//----------------------------------------------------------------------------- +// 2023 Ahoy, https://ahoydtu.de +// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +//----------------------------------------------------------------------------- + +#ifndef __MI_PAYLOAD_H__ +#define __MI_PAYLOAD_H__ + +//#include "hmInverter.h" +#include "../utils/dbg.h" +#include "../utils/crc.h" +#include "../config/config.h" +#include + +typedef struct { + uint32_t ts; + bool requested; + uint8_t txCmd; + uint8_t len[MAX_PAYLOAD_ENTRIES]; + bool complete; + uint8_t sts[iv->channels]; + uint8_t txId; + uint8_t invId; + uint8_t retransmits; + /* + uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE]; + + uint8_t maxPackId; + bool lastFound; + bool gotFragment;*/ +} miPayload_t; + + +typedef std::function miPayloadListenerType; + + +template +class MiPayload { + public: + MiPayload() {} + + void setup(IApp *app, HMSYSTEM *sys, statistics_t *stat, uint8_t maxRetransmits, uint32_t *timestamp) { + mApp = app; + mSys = sys; + mStat = stat; + mMaxRetrans = maxRetransmits; + mTimestamp = timestamp; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + reset(i); + } + mSerialDebug = false; + mHighPrioIv = NULL; + mCbMiPayload = NULL; + } + + void enableSerialDebug(bool enable) { + mSerialDebug = enable; + } + + void addPayloadListener(miPayloadListenerType cb) { + mCbMiPayload = cb; + } + + void addAlarmListener(alarmListenerType cb) { + mCbMiAlarm = cb; + } + void loop() { + /*if(NULL != mHighPrioIv) { + iv->ivSend(mHighPrioIv, true); // should request firmware version etc.? + mHighPrioIv = NULL; + }*/ + } + + void ivSendHighPrio(Inverter<> *iv) { + mHighPrioIv = iv; + } + + void ivSend(Inverter<> *iv) { + reset(iv->id); + mPayload[iv->id].requested = true; + + yield(); + if (mSerialDebug) + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX)); + + uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; //iv->getQueuedCmd(); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd")); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + } + + void add(Inverter<> *iv, packet_t *p) { + //DPRINTLN(DBG_INFO, F("MI got data [0]=") + String(p->packet[0], HEX)); + + if (p->packet[0] == (0x08 + ALL_FRAMES)) { // 0x88; MI status response to 0x09 + //mPayload[iv->id].sts[0] = true; + miStsDecode(iv, p); + } else if (p->packet[0] == (0x11 + SINGLE_FRAME)) { // 0x92; MI status response to 0x11 + //mPayload[iv->id].sts[1] = true; + miStsDecode(iv, p, CH2); + } else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 + mPayload[iv->id].txId = p->packet[0]; + miDataDecode(iv,p); + iv->setQueuedCmdFinished(); + if (INV_TYPE_2CH == iv->type) { + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + } else { // additional check for mPayload[iv->id].stsa == true might be a good idea (request retransmit?) + mPayload[iv->id].complete = true; + //iv->setQueuedCmdFinished(); + } + + } else if (p->packet[0] == (0x11 + ALL_FRAMES)) { // MI data response to 0x11 + mPayload[iv->id].txId = p->packet[0]; + mPayload[iv->id].complete = true; + miDataDecode(iv,p); + iv->setQueuedCmdFinished(); + + } else if (p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME)) { // MI 1500 data response to 0x36, 0x37, 0x38 and 0x39 + mPayload[iv->id].txId = p->packet[0]; + miDataDecode(iv,p); + iv->setQueuedCmdFinished(); + if (p->packet[0] < (0x39 + ALL_FRAMES)) { + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); + } else { + mPayload[iv->id].complete = true; + //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); + //iv->setQueuedCmdFinished(); + } + + /*} + + if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command + mPayload[iv->id].txId = p->packet[0]; + DPRINTLN(DBG_DEBUG, F("Response from info request received")); + uint8_t *pid = &p->packet[9]; + if (*pid == 0x00) { + DPRINT(DBG_DEBUG, F("fragment number zero received and ignored")); + } else { + DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX)); + if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) { + memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11); + mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11; + mPayload[iv->id].gotFragment = true; + } + + if ((*pid & ALL_FRAMES) == ALL_FRAMES) { + // Last packet + if (((*pid & 0x7f) > mPayload[iv->id].maxPackId) || (MAX_PAYLOAD_ENTRIES == mPayload[iv->id].maxPackId)) { + mPayload[iv->id].maxPackId = (*pid & 0x7f); + if (*pid > 0x81) + mPayload[iv->id].lastFound = true; + } + } + } + } */ + } else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command + DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received")); + + mPayload[iv->id].txId = p->packet[0]; + iv->clearDevControlRequest(); + + if ((p->packet[12] == ActivePowerContr) && (p->packet[13] == 0x00)) { + String msg = ""; + if((p->packet[10] == 0x00) && (p->packet[11] == 0x00)) + mApp->setMqttPowerLimitAck(iv); + else + msg = "NOT "; + DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has ") + msg + F("accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1])); + iv->clearCmdQueue(); + iv->enqueCommand(SystemConfigPara); // read back power limit + } + iv->devControlCmd = Init; + } else { // some other response; copied from hmPayload:process; might not be correct to do that here!!! + DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX)); + DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX)); + //DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); + record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser + mPayload[iv->id].complete = true; + + uint8_t payload[128]; + uint8_t payloadLen = 0; + + memset(payload, 0, 128); + + /*for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) { + memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i])); + payloadLen += (mPayload[iv->id].len[i]); + yield(); + }*/ + payloadLen -= 2; + + if (mSerialDebug) { + DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): "); + mSys->Radio.dumpBuf(payload, payloadLen); + } + + if (NULL == rec) { + DPRINTLN(DBG_ERROR, F("record is NULL!")); + } else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) { + if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES)) + mStat->rxSuccess++; + + rec->ts = mPayload[iv->id].ts; + for (uint8_t i = 0; i < rec->length; i++) { + iv->addValue(i, payload, rec); + yield(); + } + iv->doCalculations(); + notify(mPayload[iv->id].txCmd); + + if(AlarmData == mPayload[iv->id].txCmd) { + uint8_t i = 0; + uint16_t code; + uint32_t start, end; + while(1) { + code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); + if(0 == code) + break; + if (NULL != mCbMiAlarm) + (mCbMiAlarm)(code, start, end); + yield(); + } + } + } else { + DPRINTLN(DBG_ERROR, F("plausibility check failed, expected ") + String(rec->pyldLen) + F(" bytes")); + mStat->rxFail++; + } + + iv->setQueuedCmdFinished(); + } + } + + void process(bool retransmit) { + for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { + Inverter<> *iv = mSys->getInverterByPos(id); + if (NULL == iv) + continue; // skip to next inverter + + if (IV_HM == iv->ivGen) // only process MI inverters + continue; // skip to next inverter + + /*if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) { + // no processing needed if txId is not 0x95 + mPayload[iv->id].complete = true; + continue; // skip to next inverter + }*/ + + if (!mPayload[iv->id].complete) { + bool crcPass, pyldComplete; + crcPass = build(iv->id, &pyldComplete); + if (!crcPass && !pyldComplete) { // payload not complete + if ((mPayload[iv->id].requested) && (retransmit)) { + if (iv->devControlCmd == Restart || iv->devControlCmd == CleanState_LockAndAlarm) { + // This is required to prevent retransmissions without answer. + DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); + mPayload[iv->id].retransmits = mMaxRetrans; + } else if(iv->devControlCmd == ActivePowerContr) { + DPRINTLN(DBG_INFO, F("retransmit power limit")); + mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true); + } else { + if (mPayload[iv->id].retransmits < mMaxRetrans) { + mPayload[iv->id].retransmits++; + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + mSys->Radio.sendCmdPacket(iv->radioId.u64, iv->getQueuedCmd(), 24, true); + /*if(false == mPayload[iv->id].gotFragment) { + DPRINTLN(DBG_WARN, F("(#") + String(iv->id) + F(") nothing received")); + mPayload[iv->id].retransmits = mMaxRetrans; + } else { + for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) { + if (mPayload[iv->id].len[i] == 0) { + DPRINTLN(DBG_WARN, F("Frame ") + String(i + 1) + F(" missing: Request Retransmit")); + mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true); + break; // only request retransmit one frame per loop + } + yield(); + } + }*/ + } + } + } + } else if(!crcPass && pyldComplete) { // crc error on complete Payload + if (mPayload[iv->id].retransmits < mMaxRetrans) { + mPayload[iv->id].retransmits++; + DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit")); + mPayload[iv->id].txCmd = iv->getQueuedCmd(); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); + } + } /*else { // payload complete + DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX)); + DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX)); + DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); + record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser + mPayload[iv->id].complete = true; + + uint8_t payload[128]; + uint8_t payloadLen = 0; + + memset(payload, 0, 128); + + for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) { + memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i])); + payloadLen += (mPayload[iv->id].len[i]); + yield(); + } + payloadLen -= 2; + + if (mSerialDebug) { + DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): "); + mSys->Radio.dumpBuf(payload, payloadLen); + } + + if (NULL == rec) { + DPRINTLN(DBG_ERROR, F("record is NULL!")); + } else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) { + if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES)) + mStat->rxSuccess++; + + rec->ts = mPayload[iv->id].ts; + for (uint8_t i = 0; i < rec->length; i++) { + iv->addValue(i, payload, rec); + yield(); + } + iv->doCalculations(); + notify(mPayload[iv->id].txCmd); + + if(AlarmData == mPayload[iv->id].txCmd) { + uint8_t i = 0; + uint16_t code; + uint32_t start, end; + while(1) { + code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); + if(0 == code) + break; + if (NULL != mCbAlarm) + (mCbAlarm)(code, start, end); + yield(); + } + } + } else { + DPRINTLN(DBG_ERROR, F("plausibility check failed, expected ") + String(rec->pyldLen) + F(" bytes")); + mStat->rxFail++; + } + + iv->setQueuedCmdFinished(); + }*/ + } + yield(); + } + } + + private: + void notify(uint8_t val) { + if(NULL != mCbMiPayload) + (mCbMiPayload)(val); + } + + void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t chan = CH1) { + DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": status msg 0x") + String(p->packet[0], HEX)); + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure + rec->ts = mPayload[iv->id].ts; + + //iv->setValue(iv->getPosByChFld(chan, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); // was 11/12, might be wrong! + + //if (INV_TYPE_1CH == iv->type) + //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); + + //iv->setValue(iv->getPosByChFld(chan, FLD_EVT, rec), rec, (int)((p->packet[13] << 8) + p->packet[14])); + uint8_t status = (p->packet[11] << 8) + p->packet[12]; + uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2; + + mPayload[iv->id].sts[stschan] = status; + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv)); + //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, (int)((p->packet[14] << 8) + p->packet[16])); + if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ + iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? + + DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); + iv->enqueCommand(AlarmData); + } + /* Unclear how in HM inverters Info and alarm data is handled... + */ + + + /* int8_t offset = -2; + + for decoding see + void MI600StsMsg (NRF24_packet_t *p){ + STAT = (int)((p->packet[11] << 8) + p->packet[12]); + FCNT = (int)((p->packet[13] << 8) + p->packet[14]); + FCODE = (int)((p->packet[15] << 8) + p->packet[16]); + #ifdef ESP8266 + VALUES[PV][5]=STAT; + VALUES[PV][6]=FCNT; + VALUES[PV][7]=FCODE; + #endif + } + */ + } + + void miDataDecode(Inverter<> *iv, packet_t *p) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser + rec->ts = mPayload[iv->id].ts; + + uint8_t datachan = ( p->packet[0] == 0x89 || p->packet[0] == (0x36 + ALL_FRAMES) ) ? CH1 : + ( p->packet[0] == 0x91 || p->packet[0] == (0x37 + ALL_FRAMES) ) ? CH2 : + p->packet[0] == (0x38 + ALL_FRAMES) ? CH3 : + CH4; + int8_t offset = -2; + // U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; + iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[11+offset] << 8) + p->packet[12+offset])/10); + yield(); + // I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; + iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[13+offset] << 8) + p->packet[14+offset])/10); + yield(); + // U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; + iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[15+offset] << 8) + p->packet[16+offset])/10); + yield(); + // F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; + //iv->setValue(iv->getPosByChFld(0, FLD_IAC, rec), rec, (float)((p->packet[17+offset] << 8) + p->packet[18+offset])/100); + //yield(); + // P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; + iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[19+offset] << 8) + p->packet[20+offset])/10); + yield(); + // Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; + iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[21+offset] << 8) + p->packet[22+offset])/1); + yield(); + iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[23+offset] << 8) + p->packet[24+offset])/10); //23 is freq or IAC? + iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[17+offset] << 8) + p->packet[18+offset])/100); + iv->setValue(iv->getPosByChFld(0, FLD_IRR, rec), rec, (float) (calcIrradiation(iv, datachan))); + yield(); + //FLD_YD + + if (p->packet[0] >= (0x36 + ALL_FRAMES) ) { + mPayload[iv->id].sts[stschan] = (uint8_t)(p->packet[25+offset]); + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); + if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ + iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; + + DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); + iv->enqueCommand(AlarmData); + } + } + //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); // (getValue(iv->getPosByChFld(1, FLD_YD, rec), rec) + getValue(iv->getPosByChFld(2, FLD_YD, rec), rec))); + iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); //datachan)); + iv->doCalculations(); + notify(mPayload[iv->id].txCmd); +/* + if(AlarmData == mPayload[iv->id].txCmd) { + uint8_t i = 0; + uint16_t code; + uint32_t start, end; + while(1) { + code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); + if(0 == code) + break; + if (NULL != mCbMiAlarm) + (mCbAlarm)(code, start, end); + yield(); + } + }*/ +/*decode here or memcopy payload for later decoding? + void MI600DataMsg(NRF24_packet_t *p){ + U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; + I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; + U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; + F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; + P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; + Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; + TEMP = (float) ((p->packet[23] << 8) + p->packet[24])/10; //(int16_t) + + if ((30packet[2] == 0x89) {PV= 0; TotalP[1]=P_DC; pvCnt[0]=1;}//port 1 + if (p->packet[2] == 0x91) {PV= 1; TotalP[2]=P_DC; pvCnt[1]=1;}//port 2 + + TotalP[0]=TotalP[1]+TotalP[2]+TotalP[3]+TotalP[4];//in TotalP[0] is the totalPV power + if((P_DC>400) || (P_DC<0) || (TotalP[0]>MAXPOWER)){// cant be!! + TotalP[0]=0; + return; + } + #ifdef ESP8266 + VALUES[PV][0]=PV; + VALUES[PV][1]=P_DC; + VALUES[PV][2]=U_DC; + VALUES[PV][3]=I_DC; + VALUES[PV][4]=Q_DC; + #endif + PMI=TotalP[0]; + LIM=(uint16_t)Limit; + PrintOutValues(); + }*/ + + /*For MI1500: + if (MI1500) { + STAT = (uint8_t)(p->packet[25] ); + FCNT = (uint8_t)(p->packet[26]); + FCODE = (uint8_t)(p->packet[27]); + } + */ + DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); + } + + bool build(uint8_t id, bool *complete) { + /*DPRINTLN(DBG_VERBOSE, F("build")); + uint16_t crc = 0xffff, crcRcv = 0x0000; + if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES) + mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; + + // check if all fragments are there + *complete = true; + for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { + if(mPayload[id].len[i] == 0) + *complete = false; + } + if(!*complete) + return false; + + for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { + if (mPayload[id].len[i] > 0) { + if (i == (mPayload[id].maxPackId - 1)) { + crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc); + crcRcv = (mPayload[id].data[i][mPayload[id].len[i] - 2] << 8) | (mPayload[id].data[i][mPayload[id].len[i] - 1]); + } else + crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i], crc); + } + yield(); + } + + return (crc == crcRcv) ? true : false;*/ + return true; + } + + void reset(uint8_t id) { + DPRINTLN(DBG_INFO, "resetPayload: id: " + String(id)); + memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); + /* + mPayload[id].gotFragment = false; + mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; + mPayload[id].lastFound = false;*/ + mPayload[id].retransmits = 0; + mPayload[id].complete = false; + mPayload[id].txCmd = 0; + mPayload[id].requested = false; + mPayload[id].ts = *mTimestamp; + mPayload[id].sts[] = (0); + } + + + template + static T calcMiSts(Inverter<> *iv) { + if(NULL != iv) { + T result = 0; + for(uint8_t i = 1; i <= iv->channels; i++) { + uint8_t sChState = mPayload[iv->id].sts[i]; + if (!sChState && !result || sChState && sChState < result) { + result = sChState; + } + return result; + } + return 0; + } + + IApp *mApp; + HMSYSTEM *mSys; + statistics_t *mStat; + uint8_t mMaxRetrans; + uint32_t *mTimestamp; + miPayload_t mPayload[MAX_NUM_INVERTERS]; + bool mSerialDebug; + + Inverter<> *mHighPrioIv; + alarmListenerType mCbMiAlarm; + payloadListenerType mCbMiPayload; +}; + +#endif /*__MI_PAYLOAD_H__*/ From f1b722fd5d07b9b100deaef0d1131c6286a9a2d4 Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 03:26:18 +0100 Subject: [PATCH 02/26] =?UTF-8?q?ePaper=20und=20Nokia=20=C3=BCber=20HSPI,?= =?UTF-8?q?=20erster=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/settings.h | 833 +++++---- src/platformio.ini | 1 + .../MonochromeDisplay/Display_Mono.cpp | 142 ++ src/plugins/MonochromeDisplay/Display_Mono.h | 40 + .../MonochromeDisplay/Display_ePaper.cpp | 191 ++ .../MonochromeDisplay/Display_ePaper.h | 51 + .../MonochromeDisplay/MonochromeDisplay.h | 255 +-- src/plugins/MonochromeDisplay/imagedata.cpp | 642 +++++++ src/plugins/MonochromeDisplay/imagedata.h | 5 + src/web/RestApi.h | 1213 ++++++------ src/web/web.h | 1664 +++++++++-------- 11 files changed, 3036 insertions(+), 2001 deletions(-) create mode 100644 src/plugins/MonochromeDisplay/Display_Mono.cpp create mode 100644 src/plugins/MonochromeDisplay/Display_Mono.h create mode 100644 src/plugins/MonochromeDisplay/Display_ePaper.cpp create mode 100644 src/plugins/MonochromeDisplay/Display_ePaper.h create mode 100644 src/plugins/MonochromeDisplay/imagedata.cpp create mode 100644 src/plugins/MonochromeDisplay/imagedata.h diff --git a/src/config/settings.h b/src/config/settings.h index f674dac4..bd804386 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -7,44 +7,43 @@ #define __SETTINGS_H__ #include -#include #include +#include + +#include "../defines.h" #include "../utils/dbg.h" #include "../utils/helper.h" -#include "../defines.h" /** * More info: * https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html#flash-layout * */ -#define DEF_PIN_OFF 255 - - -#define PROT_MASK_INDEX 0x0001 -#define PROT_MASK_LIVE 0x0002 -#define PROT_MASK_SERIAL 0x0004 -#define PROT_MASK_SETUP 0x0008 -#define PROT_MASK_UPDATE 0x0010 -#define PROT_MASK_SYSTEM 0x0020 -#define PROT_MASK_API 0x0040 -#define PROT_MASK_MQTT 0x0080 - -#define DEF_PROT_INDEX 0x0001 -#define DEF_PROT_LIVE 0x0000 -#define DEF_PROT_SERIAL 0x0004 -#define DEF_PROT_SETUP 0x0008 -#define DEF_PROT_UPDATE 0x0010 -#define DEF_PROT_SYSTEM 0x0020 -#define DEF_PROT_API 0x0000 -#define DEF_PROT_MQTT 0x0000 - +#define DEF_PIN_OFF 255 + +#define PROT_MASK_INDEX 0x0001 +#define PROT_MASK_LIVE 0x0002 +#define PROT_MASK_SERIAL 0x0004 +#define PROT_MASK_SETUP 0x0008 +#define PROT_MASK_UPDATE 0x0010 +#define PROT_MASK_SYSTEM 0x0020 +#define PROT_MASK_API 0x0040 +#define PROT_MASK_MQTT 0x0080 + +#define DEF_PROT_INDEX 0x0001 +#define DEF_PROT_LIVE 0x0000 +#define DEF_PROT_SERIAL 0x0004 +#define DEF_PROT_SETUP 0x0008 +#define DEF_PROT_UPDATE 0x0010 +#define DEF_PROT_SYSTEM 0x0020 +#define DEF_PROT_API 0x0000 +#define DEF_PROT_MQTT 0x0000 typedef struct { - uint8_t ip[4]; // ip address - uint8_t mask[4]; // sub mask - uint8_t dns1[4]; // dns 1 - uint8_t dns2[4]; // dns 2 - uint8_t gateway[4]; // standard gateway + uint8_t ip[4]; // ip address + uint8_t mask[4]; // sub mask + uint8_t dns1[4]; // dns 1 + uint8_t dns2[4]; // dns 2 + uint8_t gateway[4]; // standard gateway } cfgIp_t; typedef struct { @@ -77,7 +76,7 @@ typedef struct { typedef struct { float lat; float lon; - bool disNightCom; // disable night communication + bool disNightCom; // disable night communication uint16_t offsetSec; } cfgSun_t; @@ -88,8 +87,8 @@ typedef struct { } cfgSerial_t; typedef struct { - uint8_t led0; // first LED pin - uint8_t led1; // second LED pin + uint8_t led0; // first LED pin + uint8_t led1; // second LED pin } cfgLed_t; typedef struct { @@ -106,7 +105,7 @@ typedef struct { char name[MAX_NAME_LENGTH]; serial_u serial; uint16_t chMaxPwr[4]; - int32_t yieldCor[4]; // signed YieldTotal correction value + int32_t yieldCor[4]; // signed YieldTotal correction value char chName[4][MAX_NAME_LENGTH]; } cfgIv_t; @@ -124,12 +123,16 @@ typedef struct { bool pwrSaveAtIvOffline; bool logoEn; bool pxShift; - bool rot180; + uint8_t rot; uint16_t wakeUp; uint16_t sleepAt; uint8_t contrast; - uint8_t pin0; - uint8_t pin1; + uint8_t disp_data; + uint8_t disp_clk; + uint8_t disp_cs; + uint8_t disp_reset; + uint8_t disp_busy; + uint8_t disp_dc; } display_t; typedef struct { @@ -137,409 +140,421 @@ typedef struct { } plugins_t; typedef struct { - cfgSys_t sys; - cfgNrf24_t nrf; - cfgNtp_t ntp; - cfgSun_t sun; + cfgSys_t sys; + cfgNrf24_t nrf; + cfgNtp_t ntp; + cfgSun_t sun; cfgSerial_t serial; - cfgMqtt_t mqtt; - cfgLed_t led; - cfgInst_t inst; - plugins_t plugin; - bool valid; + cfgMqtt_t mqtt; + cfgLed_t led; + cfgInst_t inst; + plugins_t plugin; + bool valid; } settings_t; class settings { - public: - settings() {} - - void setup() { - DPRINTLN(DBG_INFO, F("Initializing FS ..")); - - mCfg.valid = false; - #if !defined(ESP32) - LittleFSConfig cfg; - cfg.setAutoFormat(false); - LittleFS.setConfig(cfg); - #define LITTLFS_TRUE - #define LITTLFS_FALSE - #else - #define LITTLFS_TRUE true - #define LITTLFS_FALSE false - #endif - - if(!LittleFS.begin(LITTLFS_FALSE)) { - DPRINTLN(DBG_INFO, F(".. format ..")); - LittleFS.format(); - if(LittleFS.begin(LITTLFS_TRUE)) { - DPRINTLN(DBG_INFO, F(".. success")); - } else { - DPRINTLN(DBG_INFO, F(".. failed")); - } - + public: + settings() {} + + void setup() { + DPRINTLN(DBG_INFO, F("Initializing FS ..")); + + mCfg.valid = false; +#if !defined(ESP32) + LittleFSConfig cfg; + cfg.setAutoFormat(false); + LittleFS.setConfig(cfg); +#define LITTLFS_TRUE +#define LITTLFS_FALSE +#else +#define LITTLFS_TRUE true +#define LITTLFS_FALSE false +#endif + + if (!LittleFS.begin(LITTLFS_FALSE)) { + DPRINTLN(DBG_INFO, F(".. format ..")); + LittleFS.format(); + if (LittleFS.begin(LITTLFS_TRUE)) { + DPRINTLN(DBG_INFO, F(".. success")); + } else { + DPRINTLN(DBG_INFO, F(".. failed")); } - else - DPRINTLN(DBG_INFO, F(" .. done")); - readSettings("/settings.json"); - } - - // should be used before OTA - void stop() { - LittleFS.end(); - DPRINTLN(DBG_INFO, F("FS stopped")); - } + } else + DPRINTLN(DBG_INFO, F(" .. done")); + + readSettings("/settings.json"); + } + + // should be used before OTA + void stop() { + LittleFS.end(); + DPRINTLN(DBG_INFO, F("FS stopped")); + } + + void getPtr(settings_t *&cfg) { + cfg = &mCfg; + } + + bool getValid(void) { + return mCfg.valid; + } + + void getInfo(uint32_t *used, uint32_t *size) { +#if !defined(ESP32) + FSInfo info; + LittleFS.info(info); + *used = info.usedBytes; + *size = info.totalBytes; + + DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --")); + DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used")); +#else + DPRINTLN(DBG_WARN, F("not supported by ESP32")); +#endif + } + + bool readSettings(const char *path) { + loadDefaults(); + File fp = LittleFS.open(path, "r"); + if (!fp) + DPRINTLN(DBG_WARN, F("failed to load json, using default config")); + else { + // DPRINTLN(DBG_INFO, fp.readString()); + // fp.seek(0, SeekSet); + DynamicJsonDocument root(4500); + DeserializationError err = deserializeJson(root, fp); + if (!err && (root.size() > 0)) { + mCfg.valid = true; + jsonWifi(root[F("wifi")]); + jsonNrf(root[F("nrf")]); + jsonNtp(root[F("ntp")]); + jsonSun(root[F("sun")]); + jsonSerial(root[F("serial")]); + jsonMqtt(root[F("mqtt")]); + jsonLed(root[F("led")]); + jsonPlugin(root[F("plugin")]); + jsonInst(root[F("inst")]); + } else { + Serial.println(F("failed to parse json, using default config")); + } - void getPtr(settings_t *&cfg) { - cfg = &mCfg; + fp.close(); } - - bool getValid(void) { - return mCfg.valid; + return mCfg.valid; + } + + bool saveSettings(void) { + DPRINTLN(DBG_DEBUG, F("save settings")); + File fp = LittleFS.open("/settings.json", "w"); + if (!fp) { + DPRINTLN(DBG_ERROR, F("can't open settings file!")); + return false; } - void getInfo(uint32_t *used, uint32_t *size) { - #if !defined(ESP32) - FSInfo info; - LittleFS.info(info); - *used = info.usedBytes; - *size = info.totalBytes; - - DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --")); - DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used")); - #else - DPRINTLN(DBG_WARN, F("not supported by ESP32")); - #endif + DynamicJsonDocument json(5500); + JsonObject root = json.to(); + jsonWifi(root.createNestedObject(F("wifi")), true); + jsonNrf(root.createNestedObject(F("nrf")), true); + jsonNtp(root.createNestedObject(F("ntp")), true); + jsonSun(root.createNestedObject(F("sun")), true); + jsonSerial(root.createNestedObject(F("serial")), true); + jsonMqtt(root.createNestedObject(F("mqtt")), true); + jsonLed(root.createNestedObject(F("led")), true); + jsonPlugin(root.createNestedObject(F("plugin")), true); + jsonInst(root.createNestedObject(F("inst")), true); + + if (0 == serializeJson(root, fp)) { + DPRINTLN(DBG_ERROR, F("can't write settings file!")); + return false; } - - bool readSettings(const char* path) { - loadDefaults(); - File fp = LittleFS.open(path, "r"); - if(!fp) - DPRINTLN(DBG_WARN, F("failed to load json, using default config")); - else { - //DPRINTLN(DBG_INFO, fp.readString()); - //fp.seek(0, SeekSet); - DynamicJsonDocument root(4500); - DeserializationError err = deserializeJson(root, fp); - if(!err && (root.size() > 0)) { - mCfg.valid = true; - jsonWifi(root[F("wifi")]); - jsonNrf(root[F("nrf")]); - jsonNtp(root[F("ntp")]); - jsonSun(root[F("sun")]); - jsonSerial(root[F("serial")]); - jsonMqtt(root[F("mqtt")]); - jsonLed(root[F("led")]); - jsonPlugin(root[F("plugin")]); - jsonInst(root[F("inst")]); - } - else { - Serial.println(F("failed to parse json, using default config")); - } - - fp.close(); - } - return mCfg.valid; + fp.close(); + + return true; + } + + bool eraseSettings(bool eraseWifi = false) { + if (true == eraseWifi) + return LittleFS.format(); + loadDefaults(!eraseWifi); + return saveSettings(); + } + + private: + void loadDefaults(bool keepWifi = false) { + DPRINTLN(DBG_VERBOSE, F("loadDefaults")); + + cfgSys_t tmp; + if (keepWifi) { + // copy contents which should not be deleted + memset(&tmp.adminPwd, 0, PWD_LEN); + memcpy(&tmp, &mCfg.sys, sizeof(cfgSys_t)); } - - bool saveSettings(void) { - DPRINTLN(DBG_DEBUG, F("save settings")); - File fp = LittleFS.open("/settings.json", "w"); - if(!fp) { - DPRINTLN(DBG_ERROR, F("can't open settings file!")); - return false; - } - - DynamicJsonDocument json(5500); - JsonObject root = json.to(); - jsonWifi(root.createNestedObject(F("wifi")), true); - jsonNrf(root.createNestedObject(F("nrf")), true); - jsonNtp(root.createNestedObject(F("ntp")), true); - jsonSun(root.createNestedObject(F("sun")), true); - jsonSerial(root.createNestedObject(F("serial")), true); - jsonMqtt(root.createNestedObject(F("mqtt")), true); - jsonLed(root.createNestedObject(F("led")), true); - jsonPlugin(root.createNestedObject(F("plugin")), true); - jsonInst(root.createNestedObject(F("inst")), true); - - if(0 == serializeJson(root, fp)) { - DPRINTLN(DBG_ERROR, F("can't write settings file!")); - return false; - } - fp.close(); - - return true; + // erase all settings and reset to default + memset(&mCfg, 0, sizeof(settings_t)); + mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; + mCfg.sys.darkMode = false; + // restore temp settings + if (keepWifi) + memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t)); + else { + snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); + snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); } - bool eraseSettings(bool eraseWifi = false) { - if(true == eraseWifi) - return LittleFS.format(); - loadDefaults(!eraseWifi); - return saveSettings(); + snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME); + + mCfg.nrf.sendInterval = SEND_INTERVAL; + mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; + mCfg.nrf.pinCs = DEF_CS_PIN; + mCfg.nrf.pinCe = DEF_CE_PIN; + mCfg.nrf.pinIrq = DEF_IRQ_PIN; + mCfg.nrf.amplifierPower = DEF_AMPLIFIERPOWER & 0x03; + + snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", DEF_NTP_SERVER_NAME); + mCfg.ntp.port = DEF_NTP_PORT; + + mCfg.sun.lat = 0.0; + mCfg.sun.lon = 0.0; + mCfg.sun.disNightCom = false; + mCfg.sun.offsetSec = 0; + + mCfg.serial.interval = SERIAL_INTERVAL; + mCfg.serial.showIv = false; + mCfg.serial.debug = false; + + mCfg.mqtt.port = DEF_MQTT_PORT; + snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER); + snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", DEF_MQTT_USER); + snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD); + snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC); + mCfg.mqtt.interval = 0; // off + + mCfg.inst.rstYieldMidNight = false; + mCfg.inst.rstValsNotAvail = false; + mCfg.inst.rstValsCommStop = false; + + mCfg.led.led0 = DEF_PIN_OFF; + mCfg.led.led1 = DEF_PIN_OFF; + + memset(&mCfg.inst, 0, sizeof(cfgInst_t)); + + mCfg.plugin.display.pwrSaveAtIvOffline = false; + mCfg.plugin.display.contrast = 60; + mCfg.plugin.display.logoEn = true; + mCfg.plugin.display.pxShift = true; + mCfg.plugin.display.rot = 0; + mCfg.plugin.display.disp_data = DEF_PIN_OFF; // SDA + mCfg.plugin.display.disp_clk = DEF_PIN_OFF; // SCL + mCfg.plugin.display.disp_cs = DEF_PIN_OFF; + mCfg.plugin.display.disp_reset = DEF_PIN_OFF; + mCfg.plugin.display.disp_busy = DEF_PIN_OFF; + mCfg.plugin.display.disp_dc = DEF_PIN_OFF; + } + + void jsonWifi(JsonObject obj, bool set = false) { + if (set) { + char buf[16]; + obj[F("ssid")] = mCfg.sys.stationSsid; + obj[F("pwd")] = mCfg.sys.stationPwd; + obj[F("dev")] = mCfg.sys.deviceName; + obj[F("adm")] = mCfg.sys.adminPwd; + obj[F("prot_mask")] = mCfg.sys.protectionMask; + obj[F("dark")] = mCfg.sys.darkMode; + ah::ip2Char(mCfg.sys.ip.ip, buf); + obj[F("ip")] = String(buf); + ah::ip2Char(mCfg.sys.ip.mask, buf); + obj[F("mask")] = String(buf); + ah::ip2Char(mCfg.sys.ip.dns1, buf); + obj[F("dns1")] = String(buf); + ah::ip2Char(mCfg.sys.ip.dns2, buf); + obj[F("dns2")] = String(buf); + ah::ip2Char(mCfg.sys.ip.gateway, buf); + obj[F("gtwy")] = String(buf); + } else { + snprintf(mCfg.sys.stationSsid, SSID_LEN, "%s", obj[F("ssid")].as()); + snprintf(mCfg.sys.stationPwd, PWD_LEN, "%s", obj[F("pwd")].as()); + snprintf(mCfg.sys.deviceName, DEVNAME_LEN, "%s", obj[F("dev")].as()); + snprintf(mCfg.sys.adminPwd, PWD_LEN, "%s", obj[F("adm")].as()); + mCfg.sys.protectionMask = obj[F("prot_mask")]; + mCfg.sys.darkMode = obj[F("dark")]; + ah::ip2Arr(mCfg.sys.ip.ip, obj[F("ip")].as()); + ah::ip2Arr(mCfg.sys.ip.mask, obj[F("mask")].as()); + ah::ip2Arr(mCfg.sys.ip.dns1, obj[F("dns1")].as()); + ah::ip2Arr(mCfg.sys.ip.dns2, obj[F("dns2")].as()); + ah::ip2Arr(mCfg.sys.ip.gateway, obj[F("gtwy")].as()); + + if (mCfg.sys.protectionMask == 0) + mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; } - - private: - void loadDefaults(bool keepWifi = false) { - DPRINTLN(DBG_VERBOSE, F("loadDefaults")); - - cfgSys_t tmp; - if(keepWifi) { - // copy contents which should not be deleted - memset(&tmp.adminPwd, 0, PWD_LEN); - memcpy(&tmp, &mCfg.sys, sizeof(cfgSys_t)); - } - // erase all settings and reset to default - memset(&mCfg, 0, sizeof(settings_t)); - mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP - | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; - mCfg.sys.darkMode = false; - // restore temp settings - if(keepWifi) - memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t)); - else { - snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); - snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); - } - - snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME); - - mCfg.nrf.sendInterval = SEND_INTERVAL; - mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; - mCfg.nrf.pinCs = DEF_CS_PIN; - mCfg.nrf.pinCe = DEF_CE_PIN; - mCfg.nrf.pinIrq = DEF_IRQ_PIN; - mCfg.nrf.amplifierPower = DEF_AMPLIFIERPOWER & 0x03; - - snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", DEF_NTP_SERVER_NAME); - mCfg.ntp.port = DEF_NTP_PORT; - - mCfg.sun.lat = 0.0; - mCfg.sun.lon = 0.0; - mCfg.sun.disNightCom = false; - mCfg.sun.offsetSec = 0; - - mCfg.serial.interval = SERIAL_INTERVAL; - mCfg.serial.showIv = false; - mCfg.serial.debug = false; - - mCfg.mqtt.port = DEF_MQTT_PORT; - snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER); - snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", DEF_MQTT_USER); - snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD); - snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC); - mCfg.mqtt.interval = 0; // off - - mCfg.inst.rstYieldMidNight = false; - mCfg.inst.rstValsNotAvail = false; - mCfg.inst.rstValsCommStop = false; - - mCfg.led.led0 = DEF_PIN_OFF; - mCfg.led.led1 = DEF_PIN_OFF; - - memset(&mCfg.inst, 0, sizeof(cfgInst_t)); - - mCfg.plugin.display.pwrSaveAtIvOffline = false; - mCfg.plugin.display.contrast = 60; - mCfg.plugin.display.logoEn = true; - mCfg.plugin.display.pxShift = true; - mCfg.plugin.display.rot180 = false; - mCfg.plugin.display.pin0 = DEF_PIN_OFF; // SCL - mCfg.plugin.display.pin1 = DEF_PIN_OFF; // SDA + } + + void jsonNrf(JsonObject obj, bool set = false) { + if (set) { + obj[F("intvl")] = mCfg.nrf.sendInterval; + obj[F("maxRetry")] = mCfg.nrf.maxRetransPerPyld; + obj[F("cs")] = mCfg.nrf.pinCs; + obj[F("ce")] = mCfg.nrf.pinCe; + obj[F("irq")] = mCfg.nrf.pinIrq; + obj[F("pwr")] = mCfg.nrf.amplifierPower; + } else { + mCfg.nrf.sendInterval = obj[F("intvl")]; + mCfg.nrf.maxRetransPerPyld = obj[F("maxRetry")]; + mCfg.nrf.pinCs = obj[F("cs")]; + mCfg.nrf.pinCe = obj[F("ce")]; + mCfg.nrf.pinIrq = obj[F("irq")]; + mCfg.nrf.amplifierPower = obj[F("pwr")]; } - - void jsonWifi(JsonObject obj, bool set = false) { - if(set) { - char buf[16]; - obj[F("ssid")] = mCfg.sys.stationSsid; - obj[F("pwd")] = mCfg.sys.stationPwd; - obj[F("dev")] = mCfg.sys.deviceName; - obj[F("adm")] = mCfg.sys.adminPwd; - obj[F("prot_mask")] = mCfg.sys.protectionMask; - obj[F("dark")] = mCfg.sys.darkMode; - ah::ip2Char(mCfg.sys.ip.ip, buf); obj[F("ip")] = String(buf); - ah::ip2Char(mCfg.sys.ip.mask, buf); obj[F("mask")] = String(buf); - ah::ip2Char(mCfg.sys.ip.dns1, buf); obj[F("dns1")] = String(buf); - ah::ip2Char(mCfg.sys.ip.dns2, buf); obj[F("dns2")] = String(buf); - ah::ip2Char(mCfg.sys.ip.gateway, buf); obj[F("gtwy")] = String(buf); - } else { - snprintf(mCfg.sys.stationSsid, SSID_LEN, "%s", obj[F("ssid")].as()); - snprintf(mCfg.sys.stationPwd, PWD_LEN, "%s", obj[F("pwd")].as()); - snprintf(mCfg.sys.deviceName, DEVNAME_LEN, "%s", obj[F("dev")].as()); - snprintf(mCfg.sys.adminPwd, PWD_LEN, "%s", obj[F("adm")].as()); - mCfg.sys.protectionMask = obj[F("prot_mask")]; - mCfg.sys.darkMode = obj[F("dark")]; - ah::ip2Arr(mCfg.sys.ip.ip, obj[F("ip")].as()); - ah::ip2Arr(mCfg.sys.ip.mask, obj[F("mask")].as()); - ah::ip2Arr(mCfg.sys.ip.dns1, obj[F("dns1")].as()); - ah::ip2Arr(mCfg.sys.ip.dns2, obj[F("dns2")].as()); - ah::ip2Arr(mCfg.sys.ip.gateway, obj[F("gtwy")].as()); - - if(mCfg.sys.protectionMask == 0) - mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP - | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; - } + } + + void jsonNtp(JsonObject obj, bool set = false) { + if (set) { + obj[F("addr")] = mCfg.ntp.addr; + obj[F("port")] = mCfg.ntp.port; + } else { + snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", obj[F("addr")].as()); + mCfg.ntp.port = obj[F("port")]; } - - void jsonNrf(JsonObject obj, bool set = false) { - if(set) { - obj[F("intvl")] = mCfg.nrf.sendInterval; - obj[F("maxRetry")] = mCfg.nrf.maxRetransPerPyld; - obj[F("cs")] = mCfg.nrf.pinCs; - obj[F("ce")] = mCfg.nrf.pinCe; - obj[F("irq")] = mCfg.nrf.pinIrq; - obj[F("pwr")] = mCfg.nrf.amplifierPower; - } else { - mCfg.nrf.sendInterval = obj[F("intvl")]; - mCfg.nrf.maxRetransPerPyld = obj[F("maxRetry")]; - mCfg.nrf.pinCs = obj[F("cs")]; - mCfg.nrf.pinCe = obj[F("ce")]; - mCfg.nrf.pinIrq = obj[F("irq")]; - mCfg.nrf.amplifierPower = obj[F("pwr")]; - } + } + + void jsonSun(JsonObject obj, bool set = false) { + if (set) { + obj[F("lat")] = mCfg.sun.lat; + obj[F("lon")] = mCfg.sun.lon; + obj[F("dis")] = mCfg.sun.disNightCom; + obj[F("offs")] = mCfg.sun.offsetSec; + } else { + mCfg.sun.lat = obj[F("lat")]; + mCfg.sun.lon = obj[F("lon")]; + mCfg.sun.disNightCom = obj[F("dis")]; + mCfg.sun.offsetSec = obj[F("offs")]; } - - void jsonNtp(JsonObject obj, bool set = false) { - if(set) { - obj[F("addr")] = mCfg.ntp.addr; - obj[F("port")] = mCfg.ntp.port; - } else { - snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", obj[F("addr")].as()); - mCfg.ntp.port = obj[F("port")]; - } + } + + void jsonSerial(JsonObject obj, bool set = false) { + if (set) { + obj[F("intvl")] = mCfg.serial.interval; + obj[F("show")] = mCfg.serial.showIv; + obj[F("debug")] = mCfg.serial.debug; + } else { + mCfg.serial.interval = obj[F("intvl")]; + mCfg.serial.showIv = obj[F("show")]; + mCfg.serial.debug = obj[F("debug")]; } - - void jsonSun(JsonObject obj, bool set = false) { - if(set) { - obj[F("lat")] = mCfg.sun.lat; - obj[F("lon")] = mCfg.sun.lon; - obj[F("dis")] = mCfg.sun.disNightCom; - obj[F("offs")] = mCfg.sun.offsetSec; - } else { - mCfg.sun.lat = obj[F("lat")]; - mCfg.sun.lon = obj[F("lon")]; - mCfg.sun.disNightCom = obj[F("dis")]; - mCfg.sun.offsetSec = obj[F("offs")]; - } + } + + void jsonMqtt(JsonObject obj, bool set = false) { + if (set) { + obj[F("broker")] = mCfg.mqtt.broker; + obj[F("port")] = mCfg.mqtt.port; + obj[F("user")] = mCfg.mqtt.user; + obj[F("pwd")] = mCfg.mqtt.pwd; + obj[F("topic")] = mCfg.mqtt.topic; + obj[F("intvl")] = mCfg.mqtt.interval; + + } else { + mCfg.mqtt.port = obj[F("port")]; + mCfg.mqtt.interval = obj[F("intvl")]; + snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", obj[F("broker")].as()); + snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", obj[F("user")].as()); + snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", obj[F("pwd")].as()); + snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", obj[F("topic")].as()); } - - void jsonSerial(JsonObject obj, bool set = false) { - if(set) { - obj[F("intvl")] = mCfg.serial.interval; - obj[F("show")] = mCfg.serial.showIv; - obj[F("debug")] = mCfg.serial.debug; - } else { - mCfg.serial.interval = obj[F("intvl")]; - mCfg.serial.showIv = obj[F("show")]; - mCfg.serial.debug = obj[F("debug")]; - } + } + + void jsonLed(JsonObject obj, bool set = false) { + if (set) { + obj[F("0")] = mCfg.led.led0; + obj[F("1")] = mCfg.led.led1; + } else { + mCfg.led.led0 = obj[F("0")]; + mCfg.led.led1 = obj[F("1")]; } - - void jsonMqtt(JsonObject obj, bool set = false) { - if(set) { - obj[F("broker")] = mCfg.mqtt.broker; - obj[F("port")] = mCfg.mqtt.port; - obj[F("user")] = mCfg.mqtt.user; - obj[F("pwd")] = mCfg.mqtt.pwd; - obj[F("topic")] = mCfg.mqtt.topic; - obj[F("intvl")] = mCfg.mqtt.interval; - - } else { - mCfg.mqtt.port = obj[F("port")]; - mCfg.mqtt.interval = obj[F("intvl")]; - snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", obj[F("broker")].as()); - snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", obj[F("user")].as()); - snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", obj[F("pwd")].as()); - snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", obj[F("topic")].as()); - } + } + + void jsonPlugin(JsonObject obj, bool set = false) { + if (set) { + JsonObject disp = obj.createNestedObject("disp"); + disp[F("type")] = mCfg.plugin.display.type; + disp[F("pwrSafe")] = (bool)mCfg.plugin.display.pwrSaveAtIvOffline; + disp[F("logo")] = (bool)mCfg.plugin.display.logoEn; + disp[F("pxShift")] = (bool)mCfg.plugin.display.pxShift; + disp[F("rotation")] = mCfg.plugin.display.rot; + disp[F("wake")] = mCfg.plugin.display.wakeUp; + disp[F("sleep")] = mCfg.plugin.display.sleepAt; + disp[F("contrast")] = mCfg.plugin.display.contrast; + disp[F("data")] = mCfg.plugin.display.disp_data; + disp[F("clock")] = mCfg.plugin.display.disp_clk; + disp[F("cs")] = mCfg.plugin.display.disp_cs; + disp[F("reset")] = mCfg.plugin.display.disp_reset; + disp[F("busy")] = mCfg.plugin.display.disp_busy; + disp[F("dc")] = mCfg.plugin.display.disp_dc; + } else { + JsonObject disp = obj["disp"]; + mCfg.plugin.display.type = disp[F("type")]; + mCfg.plugin.display.pwrSaveAtIvOffline = (bool)disp[F("pwrSafe")]; + mCfg.plugin.display.logoEn = (bool)disp[F("logo")]; + mCfg.plugin.display.pxShift = (bool)disp[F("pxShift")]; + mCfg.plugin.display.rot = disp[F("rotation")]; + mCfg.plugin.display.wakeUp = disp[F("wake")]; + mCfg.plugin.display.sleepAt = disp[F("sleep")]; + mCfg.plugin.display.contrast = disp[F("contrast")]; + mCfg.plugin.display.disp_data = disp[F("data")]; + mCfg.plugin.display.disp_clk = disp[F("clock")]; + mCfg.plugin.display.disp_cs = disp[F("cs")]; + mCfg.plugin.display.disp_reset = disp[F("reset")]; + mCfg.plugin.display.disp_busy = disp[F("busy")]; + mCfg.plugin.display.disp_dc = disp[F("dc")]; } - - void jsonLed(JsonObject obj, bool set = false) { - if(set) { - obj[F("0")] = mCfg.led.led0; - obj[F("1")] = mCfg.led.led1; - } else { - mCfg.led.led0 = obj[F("0")]; - mCfg.led.led1 = obj[F("1")]; - } + } + + void jsonInst(JsonObject obj, bool set = false) { + if (set) { + obj[F("en")] = (bool)mCfg.inst.enabled; + obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight; + obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail; + obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop; + } else { + mCfg.inst.enabled = (bool)obj[F("en")]; + mCfg.inst.rstYieldMidNight = (bool)obj["rstMidNight"]; + mCfg.inst.rstValsNotAvail = (bool)obj["rstNotAvail"]; + mCfg.inst.rstValsCommStop = (bool)obj["rstComStop"]; } - void jsonPlugin(JsonObject obj, bool set = false) { - if(set) { - JsonObject disp = obj.createNestedObject("disp"); - disp[F("type")] = mCfg.plugin.display.type; - disp[F("pwrSafe")] = (bool)mCfg.plugin.display.pwrSaveAtIvOffline; - disp[F("logo")] = (bool)mCfg.plugin.display.logoEn; - disp[F("pxShift")] = (bool)mCfg.plugin.display.pxShift; - disp[F("rot180")] = (bool)mCfg.plugin.display.rot180; - disp[F("wake")] = mCfg.plugin.display.wakeUp; - disp[F("sleep")] = mCfg.plugin.display.sleepAt; - disp[F("contrast")] = mCfg.plugin.display.contrast; - disp[F("pin0")] = mCfg.plugin.display.pin0; - disp[F("pin1")] = mCfg.plugin.display.pin1; - } else { - JsonObject disp = obj["disp"]; - mCfg.plugin.display.type = disp[F("type")]; - mCfg.plugin.display.pwrSaveAtIvOffline = (bool) disp[F("pwrSafe")]; - mCfg.plugin.display.logoEn = (bool) disp[F("logo")]; - mCfg.plugin.display.pxShift = (bool) disp[F("pxShift")]; - mCfg.plugin.display.rot180 = (bool) disp[F("rot180")]; - mCfg.plugin.display.wakeUp = disp[F("wake")]; - mCfg.plugin.display.sleepAt = disp[F("sleep")]; - mCfg.plugin.display.contrast = disp[F("contrast")]; - mCfg.plugin.display.pin0 = disp[F("pin0")]; - mCfg.plugin.display.pin1 = disp[F("pin1")]; - } + JsonArray ivArr; + if (set) + ivArr = obj.createNestedArray(F("iv")); + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + if (set) + jsonIv(ivArr.createNestedObject(), &mCfg.inst.iv[i], true); + else + jsonIv(obj[F("iv")][i], &mCfg.inst.iv[i]); } - - void jsonInst(JsonObject obj, bool set = false) { - if(set) { - obj[F("en")] = (bool)mCfg.inst.enabled; - obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight; - obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail; - obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop; - } - else { - mCfg.inst.enabled = (bool)obj[F("en")]; - mCfg.inst.rstYieldMidNight = (bool)obj["rstMidNight"]; - mCfg.inst.rstValsNotAvail = (bool)obj["rstNotAvail"]; - mCfg.inst.rstValsCommStop = (bool)obj["rstComStop"]; - } - - JsonArray ivArr; - if(set) - ivArr = obj.createNestedArray(F("iv")); - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - if(set) - jsonIv(ivArr.createNestedObject(), &mCfg.inst.iv[i], true); - else - jsonIv(obj[F("iv")][i], &mCfg.inst.iv[i]); + } + + void jsonIv(JsonObject obj, cfgIv_t *cfg, bool set = false) { + if (set) { + obj[F("en")] = (bool)cfg->enabled; + obj[F("name")] = cfg->name; + obj[F("sn")] = cfg->serial.u64; + for (uint8_t i = 0; i < 4; i++) { + obj[F("yield")][i] = cfg->yieldCor[i]; + obj[F("pwr")][i] = cfg->chMaxPwr[i]; + obj[F("chName")][i] = cfg->chName[i]; } - } - - void jsonIv(JsonObject obj, cfgIv_t *cfg, bool set = false) { - if(set) { - obj[F("en")] = (bool)cfg->enabled; - obj[F("name")] = cfg->name; - obj[F("sn")] = cfg->serial.u64; - for(uint8_t i = 0; i < 4; i++) { - obj[F("yield")][i] = cfg->yieldCor[i]; - obj[F("pwr")][i] = cfg->chMaxPwr[i]; - obj[F("chName")][i] = cfg->chName[i]; - } - } else { - cfg->enabled = (bool)obj[F("en")]; - snprintf(cfg->name, MAX_NAME_LENGTH, "%s", obj[F("name")].as()); - cfg->serial.u64 = obj[F("sn")]; - for(uint8_t i = 0; i < 4; i++) { - cfg->yieldCor[i] = obj[F("yield")][i]; - cfg->chMaxPwr[i] = obj[F("pwr")][i]; - snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chName")][i].as()); - } + } else { + cfg->enabled = (bool)obj[F("en")]; + snprintf(cfg->name, MAX_NAME_LENGTH, "%s", obj[F("name")].as()); + cfg->serial.u64 = obj[F("sn")]; + for (uint8_t i = 0; i < 4; i++) { + cfg->yieldCor[i] = obj[F("yield")][i]; + cfg->chMaxPwr[i] = obj[F("pwr")][i]; + snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chName")][i].as()); } } + } - settings_t mCfg; + settings_t mCfg; }; #endif /*__SETTINGS_H__*/ diff --git a/src/platformio.ini b/src/platformio.ini index caea7b42..08460930 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -41,6 +41,7 @@ lib_deps = bblanchon/ArduinoJson https://github.com/JChristensen/Timezone olikraus/U8g2 + zinggjm/GxEPD2@^1.5.0 ;esp8266/DNSServer ;esp8266/EEPROM ;esp8266/ESP8266WiFi diff --git a/src/plugins/MonochromeDisplay/Display_Mono.cpp b/src/plugins/MonochromeDisplay/Display_Mono.cpp new file mode 100644 index 00000000..23c6f0e3 --- /dev/null +++ b/src/plugins/MonochromeDisplay/Display_Mono.cpp @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include "Display_Mono.h" + +#include + +#include + +#include "WiFi.h" +#include "imagedata.h" + +#ifdef U8X8_HAVE_HW_SPI +#include +#endif +#ifdef U8X8_HAVE_HW_I2C +#include +#endif + +std::map> mono_types = { + {1, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_PCD8544_84X48_F_4W_SW_SPI(U8G2_R2, clock, data, cs, dc, reset); }}, + {2, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, reset, clock, data); }}, + {3, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_SH1106_128X64_NONAME_F_HW_I2C(U8G2_R0, reset, clock, data); }}, +}; + +DisplayMonoClass::DisplayMonoClass() { +} + +DisplayMonoClass::~DisplayMonoClass() { + delete _display; +} + +void DisplayMonoClass::calcLineHeights() { + uint8_t yOff = 0; + for (uint8_t i = 0; i < 4; i++) { + setFont(i); + yOff += (_display->getMaxCharHeight()); + mLineOffsets[i] = yOff; + } +} + +inline void DisplayMonoClass::setFont(uint8_t line) { + switch (line) { + case 0: + _display->setFont((_mIsLarge) ? u8g2_font_ncenB14_tr : u8g2_font_logisoso16_tr); + break; + case 3: + _display->setFont(u8g2_font_5x8_tr); + break; + default: + _display->setFont((_mIsLarge) ? u8g2_font_ncenB10_tr : u8g2_font_5x8_tr); + break; + } +} + +void DisplayMonoClass::printText(const char* text, uint8_t line, uint8_t dispX = 5) { + if (!_mIsLarge) { + dispX = (line == 0) ? 5 : 0; + } else { + dispX = (line == 0) ? 20 : 5; + } + setFont(line); + + dispX += enableScreensaver ? (_mExtra % 7) : 0; + _display->drawStr(dispX, mLineOffsets[line], text); +} + +void DisplayMonoClass::init(uint8_t _type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI) { + if (0 < _type < 4) { + auto constructor = mono_types[_type]; + _display = constructor(_RST, _SCK, _MOSI, _CS, _DC); + _display->begin(); + _display->setDisplayRotation(disp_rotation); + + _mIsLarge = (_display->getWidth() > 100); + calcLineHeights(); + + _display->clearBuffer(); + if (contrast < 255) { + _display->setContrast(contrast); + } + printText("OpenDTU!", 0); + _display->sendBuffer(); + } +} + +void DisplayMonoClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { + _display->clearBuffer(); + + // set Contrast of the Display to raise the lifetime + if (contrast < 255) { + _display->setContrast(contrast); + } + + //=====> Actual Production ========== + if ((totalPower > 0) && (isprod > 0)) { + _display->setPowerSave(false); + if (totalPower > 999) { + snprintf(_fmtText, sizeof(_fmtText), "%2.2f kW", (totalPower / 1000)); + } else { + snprintf(_fmtText, sizeof(_fmtText), "%3.0f W", totalPower); + } + printText(_fmtText, 0); + _previousMillis = millis(); + } + //<======================= + + //=====> Offline =========== + else { + printText("offline", 0); + // check if it's time to enter power saving mode + if (millis() - _previousMillis >= (_mTimeout * 2)) { + _display->setPowerSave(enablePowerSafe); + } + } + //<======================= + + //=====> Today & Total Production ======= + snprintf(_fmtText, sizeof(_fmtText), "today: %4.0f Wh", totalYieldDay); + printText(_fmtText, 1); + + snprintf(_fmtText, sizeof(_fmtText), "total: %.1f kWh", totalYieldTotal); + printText(_fmtText, 2); + //<======================= + + //=====> IP or Date-Time ======== + if (!(_mExtra % 10) && WiFi.localIP()) { + printText(WiFi.localIP().toString().c_str(), 3); + } else if (!(_mExtra % 5)) { + snprintf(_fmtText, sizeof(_fmtText), "#%d Inverter online", isprod); + printText(_fmtText, 3); + } else { + time_t now = time(nullptr); + strftime(_fmtText, sizeof(_fmtText), "%d.%m.%Y %H:%M", localtime(&now)); + printText(_fmtText, 3); + } + + _display->sendBuffer(); + + _dispY = 0; + _mExtra++; +} + +DisplayMonoClass DisplayMono; \ No newline at end of file diff --git a/src/plugins/MonochromeDisplay/Display_Mono.h b/src/plugins/MonochromeDisplay/Display_Mono.h new file mode 100644 index 00000000..eda23f05 --- /dev/null +++ b/src/plugins/MonochromeDisplay/Display_Mono.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include + +class DisplayMonoClass { + public: + DisplayMonoClass(); + ~DisplayMonoClass(); + + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI); + + void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); + + bool enablePowerSafe = true; + bool enableScreensaver = true; + const u8g2_cb_t* disp_rotation = U8G2_R2; + uint8_t contrast = 60; + + private: + void calcLineHeights(); + void setFont(uint8_t line); + void printText(const char* text, uint8_t line, uint8_t dispX); + + U8G2* _display; + + bool _mIsLarge = false; + uint8_t mLoopCnt; + uint32_t* mUtcTs; + uint8_t mLineOffsets[5]; + + uint16_t _dispY = 0; + uint32_t _previousMillis = 0; + + uint8_t _mExtra; + uint16_t _mTimeout; // interval at which to power save (milliseconds) + char _fmtText[32]; +}; + +extern DisplayMonoClass DisplayMono; \ No newline at end of file diff --git a/src/plugins/MonochromeDisplay/Display_ePaper.cpp b/src/plugins/MonochromeDisplay/Display_ePaper.cpp new file mode 100644 index 00000000..4f9665c9 --- /dev/null +++ b/src/plugins/MonochromeDisplay/Display_ePaper.cpp @@ -0,0 +1,191 @@ +#include "Display_ePaper.h" + +#include "WiFi.h" +#include "imagedata.h" + +static const uint32_t spiClk = 4000000; // 4 MHz + +#if defined(ESP32) && defined(USE_HSPI_FOR_EPD) +SPIClass hspi(HSPI); +#endif + +std::map> _ePaperTypes = { + // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1 + {4, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) { return new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); }}, + // GDEW027C44 2.7 " b/w/r 176x264, IL91874 + //{DisplayType_t::ePaper270, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) + // F { return new GxEPD2_3C(GxEPD2_270c(_CS, _DC, _RST, _BUSY)); }}, +}; + +DisplayEPaperClass::DisplayEPaperClass() { +} + +DisplayEPaperClass::~DisplayEPaperClass() { + delete _display; +} +//*************************************************************************** +void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI) { + if (type > 3) { + Serial.begin(115200); + auto constructor = _ePaperTypes[type]; + _display = constructor(_CS, _DC, _RST, _BUSY); + hspi.begin(_SCK, _BUSY, _MOSI, _CS); + +#if defined(ESP32) && defined(USE_HSPI_FOR_EPD) + _display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0)); +#endif + _display->init(115200, true, 2, false); + _display->setRotation(displayRotation); + _display->setFullWindow(); + + // Logo + _display->fillScreen(GxEPD_BLACK); + _display->drawBitmap(0, 0, AhoyLogo, 200, 200, GxEPD_WHITE); + //_display->drawBitmap(0, 0, OpenDTULogo, 200, 200, GxEPD_WHITE); + while (_display->nextPage()) + ; + + // clean the screen + delay(2000); + _display->fillScreen(GxEPD_WHITE); + while (_display->nextPage()) + ; + + headlineIP(); + + // call the PowerPage to change the PV Power Values + actualPowerPaged(0, 0, 0, 0); + } +} +//*************************************************************************** +void DisplayEPaperClass::fullRefresh() { + // screen complete black + _display->fillScreen(GxEPD_BLACK); + while (_display->nextPage()) + ; + delay(2000); + // screen complete white + _display->fillScreen(GxEPD_WHITE); + while (_display->nextPage()); +} +//*************************************************************************** +void DisplayEPaperClass::headlineIP() { + int16_t tbx, tby; + uint16_t tbw, tbh; + + _display->setFont(&FreeSans9pt7b); + _display->setTextColor(GxEPD_WHITE); + + _display->setPartialWindow(0, 0, _display->width(), headfootline); + _display->fillScreen(GxEPD_BLACK); + + do { + if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) { + snprintf(_fmtText, sizeof(_fmtText), "%s", WiFi.localIP().toString().c_str()); + } else { + snprintf(_fmtText, sizeof(_fmtText), "WiFi not connected"); + } + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + uint16_t x = ((_display->width() - tbw) / 2) - tbx; + + _display->setCursor(x, (headfootline - 2)); + _display->println(_fmtText); + } while (_display->nextPage()); +} +//*************************************************************************** +void DisplayEPaperClass::lastUpdatePaged() { + int16_t tbx, tby; + uint16_t tbw, tbh; + + _display->setFont(&FreeSans9pt7b); + _display->setTextColor(GxEPD_WHITE); + + _display->setPartialWindow(0, _display->height() - headfootline, _display->width(), headfootline); + _display->fillScreen(GxEPD_BLACK); + do { + time_t now = time(nullptr); + strftime(_fmtText, sizeof(_fmtText), "%d.%m.%Y %H:%M", localtime(&now)); + + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + uint16_t x = ((_display->width() - tbw) / 2) - tbx; + + _display->setCursor(x, (_display->height() - 3)); + _display->println(_fmtText); + } while (_display->nextPage()); +} +//*************************************************************************** +void DisplayEPaperClass::actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod) { + int16_t tbx, tby; + uint16_t tbw, tbh, x, y; + + _display->setFont(&FreeSans24pt7b); + _display->setTextColor(GxEPD_BLACK); + + _display->setPartialWindow(0, headfootline, _display->width(), _display->height() - (headfootline * 2)); + _display->fillScreen(GxEPD_WHITE); + do { + if (_totalPower > 9999) { + snprintf(_fmtText, sizeof(_fmtText), "%.1f kW", (_totalPower / 10000)); + _changed = true; + } else if ((_totalPower > 0) && (_totalPower <= 9999)) { + snprintf(_fmtText, sizeof(_fmtText), "%.0f W", _totalPower); + _changed = true; + } else { + snprintf(_fmtText, sizeof(_fmtText), "offline"); + } + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + x = ((_display->width() - tbw) / 2) - tbx; + _display->setCursor(x, headfootline + tbh + 10); + _display->print(_fmtText); + + _display->setFont(&FreeSans12pt7b); + y = _display->height() / 2; + _display->setCursor(0, y); + _display->print("today:"); + snprintf(_fmtText, _display->width(), "%.0f", _totalYieldDay); + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + x = ((_display->width() - tbw) / 2) - tbx; + _display->setCursor(x, y); + _display->print(_fmtText); + _display->setCursor(_display->width() - 33, y); + _display->println("Wh"); + + y = y + tbh + 7; + _display->setCursor(0, y); + _display->print("total:"); + snprintf(_fmtText, _display->width(), "%.1f", _totalYieldTotal); + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + x = ((_display->width() - tbw) / 2) - tbx; + _display->setCursor(x, y); + _display->print(_fmtText); + _display->setCursor(_display->width() - 45, y); + _display->println("kWh"); + + _display->setCursor(0, _display->height() - (headfootline + 10)); + snprintf(_fmtText, sizeof(_fmtText), "#%d Inverter online", _isprod); + _display->println(_fmtText); + + } while (_display->nextPage()); +} +//*************************************************************************** +void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { + // check if the IP has changed + if (_settedIP != WiFi.localIP().toString().c_str()) { + // save the new IP and call the Headline Funktion to adapt the Headline + _settedIP = WiFi.localIP().toString().c_str(); + headlineIP(); + } + + // call the PowerPage to change the PV Power Values + actualPowerPaged(totalPower, totalYieldDay, totalYieldTotal, isprod); + + // if there was an change and the Inverter is producing set a new Timestam in the footline + if ((isprod > 0) && (_changed)) { + _changed = false; + lastUpdatePaged(); + } + + _display->powerOff(); +} +//*************************************************************************** +DisplayEPaperClass DisplayEPaper; \ No newline at end of file diff --git a/src/plugins/MonochromeDisplay/Display_ePaper.h b/src/plugins/MonochromeDisplay/Display_ePaper.h new file mode 100644 index 00000000..e404f565 --- /dev/null +++ b/src/plugins/MonochromeDisplay/Display_ePaper.h @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +// uncomment next line to use HSPI for EPD (and VSPI for SD), e.g. with Waveshare ESP32 Driver Board +#define USE_HSPI_FOR_EPD + +/// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX, to use less code and ram +// #include +// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code +// enable GxEPD2_GFX base class +#define ENABLE_GxEPD2_GFX 1 + +#include +#include +#include + +#include +// FreeFonts from Adafruit_GFX +#include +#include +#include +#include + +#include "imagedata.h" + +// GDEW027C44 2.7 " b/w/r 176x264, IL91874 +// GDEH0154D67 1.54" b/w 200x200 + +class DisplayEPaperClass { + public: + DisplayEPaperClass(); + ~DisplayEPaperClass(); + void fullRefresh(); + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI); + void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); + + uint8_t displayRotation = 2; + + private: + void headlineIP(); + void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod); + void lastUpdatePaged(); + + bool _changed = false; + char _fmtText[35]; + const char* _settedIP; + uint8_t headfootline = 16; + GxEPD2_GFX* _display; +}; + +extern DisplayEPaperClass DisplayEPaper; \ No newline at end of file diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index d7880432..6ed8499c 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -1,111 +1,85 @@ #ifndef __MONOCHROME_DISPLAY__ #define __MONOCHROME_DISPLAY__ -#include #include +#include -#include "../../utils/helper.h" #include "../../hm/hmSystem.h" +#include "../../utils/helper.h" +#include "Display_Mono.h" +#include "Display_ePaper.h" +#include "imagedata.h" -#define DISP_DEFAULT_TIMEOUT 60 // in seconds - - -static uint8_t bmp_logo[] PROGMEM = { - B00000000, B00000000, // ................ - B11101100, B00110111, // ..##.######.##.. - B11101100, B00110111, // ..##.######.##.. - B11100000, B00000111, // .....######..... - B11010000, B00001011, // ....#.####.#.... - B10011000, B00011001, // ...##..##..##... - B10000000, B00000001, // .......##....... - B00000000, B00000000, // ................ - B01111000, B00011110, // ...####..####... - B11111100, B00111111, // ..############.. - B01111100, B00111110, // ..#####..#####.. - B00000000, B00000000, // ................ - B11111100, B00111111, // ..############.. - B11111110, B01111111, // .##############. - B01111110, B01111110, // .######..######. - B00000000, B00000000 // ................ -}; +#define DISP_DEFAULT_TIMEOUT 60 // in seconds +template +class MonochromeDisplay { + public: + MonochromeDisplay() {} + + void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { + mCfg = cfg; + mSys = sys; + mUtcTs = utcTs; + mNewPayload = false; + mLoopCnt = 0; + + if (mCfg->type == 0) { + return; + } else if (1 < mCfg->type < 4) { + switch (mCfg->rot) { + case 0: + DisplayMono.disp_rotation = U8G2_R0; + break; + case 1: + DisplayMono.disp_rotation = U8G2_R1; + break; + case 2: + DisplayMono.disp_rotation = U8G2_R2; + break; + case 3: + DisplayMono.disp_rotation = U8G2_R3; + break; + } -static uint8_t bmp_arrow[] PROGMEM = { - B00000000, B00011100, B00011100, B00001110, B00001110, B11111110, B01111111, - B01110000, B01110000, B00110000, B00111000, B00011000, B01111111, B00111111, - B00011110, B00001110, B00000110, B00000000, B00000000, B00000000, B00000000 -}; + DisplayMono.enablePowerSafe = mCfg->pwrSaveAtIvOffline; + DisplayMono.enableScreensaver = mCfg->pxShift; + DisplayMono.contrast = mCfg->contrast; + DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data); + } else if (mCfg->type == 4) { + DisplayEPaper.displayRotation = mCfg->rot; + counterEPaper = 0; -template -class MonochromeDisplay { - public: - MonochromeDisplay() {} - - void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { - mCfg = cfg; - mSys = sys; - mUtcTs = utcTs; - mNewPayload = false; - mLoopCnt = 0; - mTimeout = DISP_DEFAULT_TIMEOUT; // power off timeout (after inverters go offline) - - u8g2_cb_t *rot = (u8g2_cb_t *)((mCfg->rot180) ? U8G2_R2 : U8G2_R0); - - if(mCfg->type) { - switch(mCfg->type) { - case 1: - mDisplay = new U8G2_PCD8544_84X48_F_4W_HW_SPI(rot, mCfg->pin0, mCfg->pin1, disp_reset); - break; - case 2: - mDisplay = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(rot, disp_reset, mCfg->pin0, mCfg->pin1); - break; - case 3: - mDisplay = new U8G2_SH1106_128X64_NONAME_F_HW_I2C(rot, disp_reset, mCfg->pin0, mCfg->pin1); - break; - } - mDisplay->begin(); - - mIsLarge = ((mDisplay->getWidth() > 120) && (mDisplay->getHeight() > 60)); - calcLineHeights(); - - mDisplay->clearBuffer(); - mDisplay->setContrast(mCfg->contrast); - printText("Ahoy!", 0, 35); - printText("ahoydtu.de", 2, 20); - printText(version, 3, 46); - mDisplay->sendBuffer(); - } + DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data); } + } - void payloadEventListener(uint8_t cmd) { - mNewPayload = true; - } + void payloadEventListener(uint8_t cmd) { + mNewPayload = true; + } - void tickerSecond() { - if(mCfg->pwrSaveAtIvOffline) { - if(mTimeout != 0) - mTimeout--; - } - if(mNewPayload || ((++mLoopCnt % 10) == 0)) { - mNewPayload = false; - mLoopCnt = 0; - DataScreen(); - } + void tickerSecond() { + if (mNewPayload || ((++mLoopCnt % 10) == 0)) { + mNewPayload = false; + mLoopCnt = 0; + DataScreen(); } + } - private: - void DataScreen() { - if (mCfg->type == 0) - return; - if(*mUtcTs == 0) - return; + private: + void DataScreen() { + if (mCfg->type == 0) + return; + if (*mUtcTs == 0) + return; + if ((millis() - _lastDisplayUpdate) > period) { float totalPower = 0; float totalYieldDay = 0; float totalYieldTotal = 0; - bool isprod = false; + uint8_t isprod = 0; Inverter<> *iv; record_t<> *rec; @@ -116,102 +90,37 @@ class MonochromeDisplay { continue; if (iv->isProducing(*mUtcTs)) - isprod = true; + uint8_t isprod = 0; totalPower += iv->getChannelFieldValue(CH0, FLD_PAC, rec); totalYieldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec); totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec); } - mDisplay->clearBuffer(); - - // Logos - // pxMovement +x (0 - 6 px) - uint8_t ex = (_mExtra % 7); - if (isprod) { - mDisplay->drawXBMP(5 + ex, 1, 8, 17, bmp_arrow); - if (mCfg->logoEn) - mDisplay->drawXBMP(mDisplay->getWidth() - 24 + ex, 2, 16, 16, bmp_logo); - } - - if ((totalPower > 0) && isprod) { - mTimeout = DISP_DEFAULT_TIMEOUT; - mDisplay->setPowerSave(false); - mDisplay->setContrast(mCfg->contrast); - if (totalPower > 999) - snprintf(_fmtText, sizeof(_fmtText), "%2.1f kW", (totalPower / 1000)); - else - snprintf(_fmtText, sizeof(_fmtText), "%3.0f W", totalPower); - printText(_fmtText, 0, 20); - } else { - printText("offline", 0, 25); - if(mCfg->pwrSaveAtIvOffline) { - if(mTimeout == 0) - mDisplay->setPowerSave(true); - } - } - - snprintf(_fmtText, sizeof(_fmtText), "today: %4.0f Wh", totalYieldDay); - printText(_fmtText, 1); - - snprintf(_fmtText, sizeof(_fmtText), "total: %.1f kWh", totalYieldTotal); - printText(_fmtText, 2); - - IPAddress ip = WiFi.localIP(); - if (!(_mExtra % 10) && (ip)) { - printText(ip.toString().c_str(), 3); - } else { - // Get current time - if(mIsLarge) - printText(ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); - else - printText(ah::getTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); - } - mDisplay->sendBuffer(); - - _mExtra++; - } - - void calcLineHeights() { - uint8_t yOff = 0; - for(uint8_t i = 0; i < 4; i++) { - setFont(i); - yOff += (mDisplay->getMaxCharHeight() + 1); - mLineOffsets[i] = yOff; - } - } - - inline void setFont(uint8_t line) { - switch (line) { - case 0: mDisplay->setFont((mIsLarge) ? u8g2_font_ncenB14_tr : u8g2_font_lubBI14_tr); break; - case 3: mDisplay->setFont(u8g2_font_5x8_tr); break; - default: mDisplay->setFont((mIsLarge) ? u8g2_font_ncenB10_tr : u8g2_font_5x8_tr); break; + if (1 < mCfg->type < 4) { + DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); + } else if (mCfg->type == 4) { + DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); + counterEPaper++; } + _lastDisplayUpdate = millis(); } - void printText(const char* text, uint8_t line, uint8_t dispX = 5) { - if(!mIsLarge) - dispX = (line == 0) ? 10 : 5; - setFont(line); - if(mCfg->pxShift) - dispX += (_mExtra % 7); // add pixel movement - mDisplay->drawStr(dispX, mLineOffsets[line], text); + if (counterEPaper > 480) { + DisplayEPaper.fullRefresh(); + counterEPaper = 0; } - - // private member variables - U8G2* mDisplay; - - uint8_t _mExtra; - uint16_t mTimeout; // interval at which to power save (milliseconds) - char _fmtText[32]; - - bool mNewPayload; - bool mIsLarge; - uint8_t mLoopCnt; - uint32_t *mUtcTs; - uint8_t mLineOffsets[5]; - display_t *mCfg; - HMSYSTEM *mSys; + } + + // private member variables + bool mNewPayload; + uint8_t mLoopCnt; + uint32_t *mUtcTs; + display_t *mCfg; + HMSYSTEM *mSys; + uint16_t period = 10000; // Achtung, max 65535 + uint16_t counterEPaper; + uint32_t _lastDisplayUpdate = 0; }; #endif /*__MONOCHROME_DISPLAY__*/ diff --git a/src/plugins/MonochromeDisplay/imagedata.cpp b/src/plugins/MonochromeDisplay/imagedata.cpp new file mode 100644 index 00000000..9cdf352c --- /dev/null +++ b/src/plugins/MonochromeDisplay/imagedata.cpp @@ -0,0 +1,642 @@ +// GxEPD2_ESP32_ESP8266_WifiData_V1_und_V2 + +#include "imagedata.h" +#if defined(__AVR__) || defined(ARDUINO_ARCH_SAMD) +#include +#elif defined(ESP8266) || defined(ESP32) +#include +#endif + +// 'OpenDTU', 200x200px +const unsigned char OpenDTULogo[] PROGMEM = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, + 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf8, 0x03, 0x80, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xf0, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, + 0x7f, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xfe, 0x01, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x01, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, + 0xfc, 0x7f, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xfc, 0x0f, 0xe0, 0x0f, 0xc0, 0xfe, 0x03, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, + 0xf8, 0x07, 0xc0, 0x0f, 0xc0, 0x3e, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf0, 0x07, 0xc0, 0x0f, 0x80, 0x1e, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x01, 0xe0, 0x07, 0xc0, 0x07, 0x80, 0x0f, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xe0, 0x07, 0xc0, 0x0f, 0x80, + 0x0f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x03, 0xe0, 0x07, 0xc0, 0x0f, 0xc0, 0x1f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xe0, 0x0f, 0xe0, + 0x0f, 0xc0, 0x1f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xf0, 0x3f, 0xf8, 0x3f, 0xf0, 0x7f, 0x81, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0x07, 0xf0, 0x7f, 0xfc, 0xff, 0xf0, 0x7f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0x80, 0x0f, 0xe0, 0x1f, 0xc0, 0x07, + 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0x0f, 0x80, 0x07, 0xe0, 0x0f, 0xc0, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0x00, 0x0f, 0xc0, 0x0f, + 0xc0, 0x03, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf8, 0x0f, 0x00, 0x0f, 0xc0, 0x07, 0xc0, 0x03, 0xe0, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0x00, 0x0f, + 0xc0, 0x07, 0xe0, 0x03, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0x80, 0x0f, 0xc0, 0x0f, 0xe0, 0x03, 0xe0, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, + 0x80, 0x1f, 0xe0, 0x0f, 0xf0, 0x07, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xe0, 0x3f, 0xf8, 0x3f, 0xfc, 0x1f, 0xf0, + 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, + 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0x8f, 0xff, + 0xf3, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0x07, 0xff, 0xe1, 0xfc, 0x00, 0x03, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x1f, + 0x03, 0xff, 0xc0, 0xf8, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x1f, 0x03, 0xff, 0xc0, 0xf0, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x1f, 0xf0, 0x00, + 0x00, 0x1f, 0x03, 0xff, 0xc0, 0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x7f, 0x03, 0xff, 0xc0, 0xc0, 0x3f, + 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xf0, 0x0f, + 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0xc0, 0x7f, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xfc, 0x07, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, + 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xfe, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, + 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xf0, + 0x00, 0x7f, 0xff, 0xf0, 0x03, 0xff, 0xf0, 0x00, 0x7f, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, + 0xff, 0x03, 0xff, 0xc0, 0x83, 0xff, 0xf8, 0x1f, 0xe0, 0x00, 0x1f, 0xff, 0xc0, 0x00, 0xff, 0xe0, + 0x00, 0x1f, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xf8, + 0x1f, 0xe0, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x0f, 0xff, 0x03, 0xff, 0x81, 0xff, + 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x00, 0x07, 0xff, 0x00, 0x00, + 0x3f, 0xe0, 0x00, 0x07, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, + 0xff, 0xfc, 0x1f, 0xe0, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x07, 0xff, 0x03, 0xff, + 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x3c, 0x01, 0xfe, + 0x01, 0xe0, 0x1f, 0xe0, 0x1c, 0x03, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, + 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0x01, 0xfc, 0x07, 0xf8, 0x1f, 0xe0, 0x7f, 0x03, 0xff, + 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, + 0x80, 0xfc, 0x0f, 0xf8, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, + 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xe0, 0x1f, 0xe0, 0x7f, + 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, + 0xe0, 0x7f, 0xc0, 0xfc, 0x0c, 0x00, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, + 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x00, 0x1f, + 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, + 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x00, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc1, + 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, + 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, + 0x03, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x03, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, + 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x83, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, + 0xfc, 0x00, 0x7f, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, + 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x07, 0xff, 0xff, 0xe0, 0x7f, 0x83, + 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x3f, 0xe0, + 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, + 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf0, 0x3f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, + 0x7f, 0x83, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0xc0, 0xff, 0xf0, + 0x3f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xfe, 0x07, 0xff, + 0xf0, 0x3f, 0xff, 0x03, 0xff, 0x80, 0xc0, 0x7f, 0xe0, 0x3f, 0xe0, 0x7f, 0x81, 0xfc, 0x0f, 0xff, + 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xfc, 0x07, 0xff, 0xf0, 0x3f, 0xff, 0x01, 0xff, 0x81, 0xc0, + 0x3f, 0x80, 0x7f, 0xe0, 0x7e, 0x01, 0xfe, 0x07, 0xf0, 0x7f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xe0, + 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0x80, 0xfe, 0x01, 0xe0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x03, 0xfe, + 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0x80, 0x00, + 0x03, 0xf0, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x03, 0xff, 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, + 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x3f, 0xff, 0xc0, 0x00, 0x03, 0xf8, 0x00, 0x01, 0xff, 0xe0, 0x00, + 0x07, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x7f, 0x83, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x3f, 0xff, + 0xe0, 0x00, 0x07, 0xfc, 0x00, 0x03, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0x80, 0x00, 0x7f, 0xe0, 0x7f, + 0x83, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x3f, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0x00, 0x0f, 0xff, + 0xe0, 0x00, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xf0, 0xff, 0x83, 0xff, 0x00, 0x03, 0xff, 0xff, 0xf8, + 0x7f, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xf8, 0x07, 0xff, + 0xf9, 0xff, 0xe7, 0xff, 0xc0, 0x1f, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, + 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + +// 'Logo', 200x200px +const unsigned char AhoyLogo[] PROGMEM = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, + 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x06, + 0x0f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7e, 0x0f, 0xff, 0xff, 0xfc, 0x03, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x03, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x19, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xfe, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0x70, 0x7f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x3f, 0x07, 0xff, 0xff, + 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0x0f, 0xe0, 0x3f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xe0, 0x1f, 0x83, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xe0, 0x1f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, + 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x07, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0xff, 0xc1, 0x07, 0x80, 0x07, 0xfe, 0xff, 0xff, 0xfc, 0x07, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xe1, 0x07, 0xc0, 0x01, 0xe0, 0x0f, + 0xff, 0xfc, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xe1, 0x83, 0xc0, 0x01, 0xc0, 0x07, 0xff, 0xf8, 0x0f, 0xfc, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe1, 0x83, 0xc0, 0x00, + 0xc0, 0x07, 0x8f, 0xf8, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe0, 0x01, 0xc0, 0x00, 0x81, 0x83, 0x07, 0xf0, 0x3f, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xe0, 0x01, + 0xe0, 0xe0, 0x87, 0xe3, 0x0f, 0xf0, 0x3f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0x00, 0xe0, 0xe0, 0x87, 0xe1, 0x0c, 0x60, 0x7f, + 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, + 0xe0, 0x00, 0xe1, 0xf0, 0x87, 0xe1, 0x08, 0x60, 0x7f, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xe0, 0xe0, 0xe0, 0xe0, 0x87, 0xc2, 0x00, + 0x40, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x8f, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, 0x82, 0x00, 0xc0, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, + 0x06, 0x01, 0x81, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xcf, 0xe0, 0xe0, 0x20, 0xe0, 0xe0, 0x0c, 0x03, 0x81, 0xff, 0x1f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x30, + 0xe1, 0xf8, 0x18, 0x07, 0xe1, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x7f, 0xff, 0xff, 0xf0, 0x1f, 0xf3, 0xfe, 0x01, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, + 0xfb, 0xff, 0xff, 0xff, 0xe0, 0x3e, 0x1f, 0xfc, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xfc, 0x0f, + 0xf8, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0x33, 0xef, 0xff, 0xff, 0xff, 0xff, 0x81, 0xfc, 0x0f, 0xf1, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf1, 0xff, 0xff, 0xa0, 0x00, 0x7f, 0xe3, + 0xfc, 0x0f, 0xf3, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf1, 0xf9, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x0f, 0xe7, 0xff, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf9, 0xff, 0x80, 0x3f, 0xff, + 0xe0, 0x0f, 0xfe, 0x1f, 0xc7, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xcf, 0xf8, 0xf0, 0x07, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0x8f, 0xff, 0xfc, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xfc, 0x70, 0x3f, + 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0x1f, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x3f, + 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, + 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7e, 0x3f, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x0c, 0x7f, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x7f, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf8, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x87, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x3f, 0xff, 0xf8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfc, 0x00, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x55, 0x00, 0x3f, 0xf8, 0x00, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0xff, 0xff, 0xf8, 0x0f, 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x9f, 0xff, 0xf8, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0x03, + 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe3, 0xf1, 0xff, + 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xe0, 0xfe, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe7, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x7e, 0x06, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xcf, + 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0x03, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xcf, 0xfc, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x1f, 0x23, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xf3, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xf1, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xf8, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x0f, 0xff, 0x8f, 0xf1, 0xff, 0xff, 0xff, 0xfe, 0xf5, 0x90, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x03, 0xff, + 0x1f, 0xe3, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x31, 0xfe, 0x7f, 0xe7, 0xff, 0x80, 0x00, 0x40, 0x00, + 0x07, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0x3c, + 0xf9, 0xfc, 0xff, 0xe7, 0xfe, 0x3f, 0xc9, 0xff, 0xf1, 0x1f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x3c, 0xf9, 0xf9, 0xff, 0xc7, 0xfc, 0xff, 0x90, + 0x7f, 0xf3, 0x03, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, + 0x3f, 0x39, 0xfd, 0xf3, 0xff, 0xcf, 0xfc, 0xff, 0x90, 0x3f, 0xf3, 0x83, 0xf8, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x39, 0xf9, 0xc7, 0xff, 0xcf, 0xfc, + 0xff, 0x32, 0x7f, 0xe4, 0x77, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0xff, 0xff, 0x7f, 0x33, 0xf9, 0x8f, 0xff, 0xcf, 0xf9, 0xff, 0x00, 0x7f, 0xe0, 0x67, 0xfc, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xb3, 0xf3, 0xbf, 0xff, + 0xcf, 0xf9, 0xff, 0x00, 0xff, 0xfe, 0x47, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xf7, 0xf3, 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe0, 0xff, 0xfc, 0x0f, + 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xe7, 0xe7, + 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe1, 0xff, 0xfc, 0x1f, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xe7, 0xef, 0xff, 0xc7, 0xf9, 0xff, 0xc3, 0xff, + 0xfc, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, + 0xef, 0xef, 0xc0, 0xff, 0xe7, 0xf9, 0xff, 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xcf, 0xf0, 0x01, 0xe7, 0xf1, 0xff, + 0x87, 0xff, 0xf8, 0x7f, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, + 0xff, 0xbf, 0xcf, 0xe7, 0xff, 0xc1, 0xe3, 0xe1, 0xff, 0x8f, 0xff, 0xf0, 0xff, 0xff, 0x9f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x9f, 0xef, 0xe7, 0xff, 0xff, 0xf3, + 0xc1, 0xff, 0x96, 0xaf, 0xf9, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf9, 0xff, 0xff, 0x9f, 0xe7, 0xe3, 0xff, 0xff, 0xf1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, + 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xcf, 0xe7, 0xf3, 0xff, + 0xff, 0xf8, 0xc0, 0x00, 0x4a, 0x90, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf9, 0xff, 0xff, 0xef, 0xf3, 0xf3, 0x9f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe7, 0xf1, + 0xe7, 0xc7, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf3, 0xf0, 0x07, 0xe3, 0xff, 0xff, 0x81, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, + 0xf8, 0x07, 0x1f, 0xf1, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xfc, 0x1f, 0x9f, 0xf8, 0xff, 0xff, 0xc3, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, + 0xff, 0xff, 0xf8, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf9, 0xff, 0x9f, 0xfe, 0x3f, + 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfd, 0xff, 0xff, 0xf1, 0xff, 0x9f, 0xff, 0x9f, 0xff, 0xf3, 0xff, 0x3f, 0x3f, 0xff, 0xff, + 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe1, 0xff, 0xcf, + 0xff, 0xc7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xe1, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, + 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xc1, + 0xff, 0xcf, 0xff, 0xf3, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x81, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xf3, 0xff, + 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, + 0xff, 0x91, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x11, 0xff, 0x9f, 0xff, 0xff, 0xff, + 0xf3, 0xff, 0x1f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0x7f, 0xff, 0x21, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xbf, 0x9f, 0xff, 0xff, 0xfe, + 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x20, 0xff, 0x9f, 0xff, + 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x60, 0x7f, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x64, 0x3f, + 0x1f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xe7, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, + 0xff, 0x3f, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, + 0xe7, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xf1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xf8, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, + 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x9f, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xe7, 0xff, 0xfe, 0x7f, 0xff, 0xc3, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf3, 0xf3, 0xff, 0xfc, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xff, 0xf8, 0xff, 0xff, + 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xf9, 0xe7, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf3, 0xf9, 0xff, 0xe1, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfc, 0x3f, 0x07, + 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf3, 0xe7, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x00, 0x1f, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, + 0xe0, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, + 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf7, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x83, 0xe7, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x13, 0xe7, 0xff, 0xfc, 0x03, + 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfc, 0x31, 0xe7, 0xff, 0xfc, 0x00, 0x7f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfe, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x39, 0xe3, 0xff, + 0xfc, 0x00, 0x1f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x31, 0xf3, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xc7, 0xff, 0xff, + 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, + 0xf3, 0xff, 0xfc, 0x00, 0x07, 0xff, 0x87, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xf3, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x07, + 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x83, 0xf3, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xf3, 0xff, 0xff, 0xff, 0xff, + 0xf8, 0x07, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xe3, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xfe, 0x1f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe1, 0xff, 0xfe, + 0x01, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xf0, 0x00, 0x3f, 0x80, 0x07, 0xff, 0xff, 0xf0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x4c, + 0xff, 0xf0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0c, 0xff, 0xf0, 0x00, 0x00, 0x0b, 0x87, 0xff, + 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0e, 0x7f, 0xf8, 0x00, 0x3f, 0xff, 0xc7, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x86, 0x7f, 0xfe, 0x00, 0xff, 0xff, + 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xf3, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xf3, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x07, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xf3, 0xc0, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, + 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xff, + 0xfe, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x17, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; diff --git a/src/plugins/MonochromeDisplay/imagedata.h b/src/plugins/MonochromeDisplay/imagedata.h new file mode 100644 index 00000000..ebdb918e --- /dev/null +++ b/src/plugins/MonochromeDisplay/imagedata.h @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +extern const unsigned char AhoyLogo[]; +extern const unsigned char OpenDTULogo[]; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 0f18728d..72bf21c3 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -8,646 +8,669 @@ #include "../utils/dbg.h" #ifdef ESP32 - #include "AsyncTCP.h" +#include "AsyncTCP.h" #else - #include "ESPAsyncTCP.h" +#include "ESPAsyncTCP.h" #endif -#include "ESPAsyncWebServer.h" -#include "AsyncJson.h" +#include "../appInterface.h" #include "../hm/hmSystem.h" #include "../utils/helper.h" - -#include "../appInterface.h" +#include "AsyncJson.h" +#include "ESPAsyncWebServer.h" #if defined(F) && defined(ESP32) - #undef F - #define F(sl) (sl) +#undef F +#define F(sl) (sl) #endif const uint8_t acList[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PF, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_Q}; const uint8_t dcList[] = {FLD_UDC, FLD_IDC, FLD_PDC, FLD_YD, FLD_YT, FLD_IRR}; -template +template class RestApi { - public: - RestApi() { - mTimezoneOffset = 0; - mHeapFree = 0; - mHeapFreeBlk = 0; - mHeapFrag = 0; - nr = 0; - } - - void setup(IApp *app, HMSYSTEM *sys, AsyncWebServer *srv, settings_t *config) { - mApp = app; - mSrv = srv; - mSys = sys; - mConfig = config; - mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1)); - mSrv->on("/api", HTTP_POST, std::bind(&RestApi::onApiPost, this, std::placeholders::_1)).onBody( - std::bind(&RestApi::onApiPostBody, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); - - mSrv->on("/get_setup", HTTP_GET, std::bind(&RestApi::onDwnldSetup, this, std::placeholders::_1)); - } - - uint32_t getTimezoneOffset(void) { - return mTimezoneOffset; - } - - void ctrlRequest(JsonObject obj) { - /*char out[128]; - serializeJson(obj, out, 128); - DPRINTLN(DBG_INFO, "RestApi: " + String(out));*/ - DynamicJsonDocument json(128); - JsonObject dummy = json.as(); - if(obj[F("path")] == "ctrl") - setCtrl(obj, dummy); - else if(obj[F("path")] == "setup") - setSetup(obj, dummy); - } - - private: - void onApi(AsyncWebServerRequest *request) { - mHeapFree = ESP.getFreeHeap(); - #ifndef ESP32 - mHeapFreeBlk = ESP.getMaxFreeBlockSize(); - mHeapFrag = ESP.getHeapFragmentation(); - #endif - - AsyncJsonResponse* response = new AsyncJsonResponse(false, 6000); - JsonObject root = response->getRoot(); + public: + RestApi() { + mTimezoneOffset = 0; + mHeapFree = 0; + mHeapFreeBlk = 0; + mHeapFrag = 0; + nr = 0; + } + + void setup(IApp *app, HMSYSTEM *sys, AsyncWebServer *srv, settings_t *config) { + mApp = app; + mSrv = srv; + mSys = sys; + mConfig = config; + mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1)); + mSrv->on("/api", HTTP_POST, std::bind(&RestApi::onApiPost, this, std::placeholders::_1)).onBody(std::bind(&RestApi::onApiPostBody, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + + mSrv->on("/get_setup", HTTP_GET, std::bind(&RestApi::onDwnldSetup, this, std::placeholders::_1)); + } + + uint32_t getTimezoneOffset(void) { + return mTimezoneOffset; + } + + void ctrlRequest(JsonObject obj) { + /*char out[128]; + serializeJson(obj, out, 128); + DPRINTLN(DBG_INFO, "RestApi: " + String(out));*/ + DynamicJsonDocument json(128); + JsonObject dummy = json.as(); + if (obj[F("path")] == "ctrl") + setCtrl(obj, dummy); + else if (obj[F("path")] == "setup") + setSetup(obj, dummy); + } + + private: + void onApi(AsyncWebServerRequest *request) { + mHeapFree = ESP.getFreeHeap(); +#ifndef ESP32 + mHeapFreeBlk = ESP.getMaxFreeBlockSize(); + mHeapFrag = ESP.getHeapFragmentation(); +#endif + AsyncJsonResponse *response = new AsyncJsonResponse(false, 6000); + JsonObject root = response->getRoot(); + + String path = request->url().substring(5); + if (path == "html/system") + getHtmlSystem(root); + else if (path == "html/logout") + getHtmlLogout(root); + else if (path == "html/save") + getHtmlSave(root); + else if (path == "system") + getSysInfo(root); + else if (path == "generic") + getGeneric(root); + else if (path == "reboot") + getReboot(root); + else if (path == "statistics") + getStatistics(root); + else if (path == "inverter/list") + getInverterList(root); + else if (path == "index") + getIndex(root); + else if (path == "setup") + getSetup(root); + else if (path == "setup/networks") + getNetworks(root); + else if (path == "live") + getLive(root); + else if (path == "record/info") + getRecord(root, InverterDevInform_All); + else if (path == "record/alarm") + getRecord(root, AlarmData); + else if (path == "record/config") + getRecord(root, SystemConfigPara); + else if (path == "record/live") + getRecord(root, RealTimeRunData_Debug); + else { + if (path.substring(0, 12) == "inverter/id/") + getInverter(root, request->url().substring(17).toInt()); + else + getNotFound(root, F("http://") + request->host() + F("/api/")); + } + + // DPRINTLN(DBG_INFO, "API mem usage: " + String(root.memoryUsage())); + response->addHeader("Access-Control-Allow-Origin", "*"); + response->addHeader("Access-Control-Allow-Headers", "content-type"); + response->setLength(); + request->send(response); + } + + void onApiPost(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, "onApiPost"); + } + + void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) { + DPRINTLN(DBG_VERBOSE, "onApiPostBody"); + DynamicJsonDocument json(200); + AsyncJsonResponse *response = new AsyncJsonResponse(false, 200); + JsonObject root = response->getRoot(); + + DeserializationError err = deserializeJson(json, (const char *)data, len); + JsonObject obj = json.as(); + root[F("success")] = (err) ? false : true; + if (!err) { String path = request->url().substring(5); - if(path == "html/system") getHtmlSystem(root); - else if(path == "html/logout") getHtmlLogout(root); - else if(path == "html/save") getHtmlSave(root); - else if(path == "system") getSysInfo(root); - else if(path == "generic") getGeneric(root); - else if(path == "reboot") getReboot(root); - else if(path == "statistics") getStatistics(root); - else if(path == "inverter/list") getInverterList(root); - else if(path == "index") getIndex(root); - else if(path == "setup") getSetup(root); - else if(path == "setup/networks") getNetworks(root); - else if(path == "live") getLive(root); - else if(path == "record/info") getRecord(root, InverterDevInform_All); - else if(path == "record/alarm") getRecord(root, AlarmData); - else if(path == "record/config") getRecord(root, SystemConfigPara); - else if(path == "record/live") getRecord(root, RealTimeRunData_Debug); + if (path == "ctrl") + root[F("success")] = setCtrl(obj, root); + else if (path == "setup") + root[F("success")] = setSetup(obj, root); else { - if(path.substring(0, 12) == "inverter/id/") - getInverter(root, request->url().substring(17).toInt()); - else - getNotFound(root, F("http://") + request->host() + F("/api/")); + root[F("success")] = false; + root[F("error")] = "Path not found: " + path; + } + } else { + switch (err.code()) { + case DeserializationError::Ok: + break; + case DeserializationError::InvalidInput: + root[F("error")] = F("Invalid input"); + break; + case DeserializationError::NoMemory: + root[F("error")] = F("Not enough memory"); + break; + default: + root[F("error")] = F("Deserialization failed"); + break; } - - //DPRINTLN(DBG_INFO, "API mem usage: " + String(root.memoryUsage())); - response->addHeader("Access-Control-Allow-Origin", "*"); - response->addHeader("Access-Control-Allow-Headers", "content-type"); - response->setLength(); - request->send(response); - } - - void onApiPost(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, "onApiPost"); } - void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) { - DPRINTLN(DBG_VERBOSE, "onApiPostBody"); - DynamicJsonDocument json(200); - AsyncJsonResponse* response = new AsyncJsonResponse(false, 200); - JsonObject root = response->getRoot(); - - DeserializationError err = deserializeJson(json, (const char *)data, len); - JsonObject obj = json.as(); - root[F("success")] = (err) ? false : true; - if(!err) { - String path = request->url().substring(5); - if(path == "ctrl") - root[F("success")] = setCtrl(obj, root); - else if(path == "setup") - root[F("success")] = setSetup(obj, root); - else { - root[F("success")] = false; - root[F("error")] = "Path not found: " + path; + response->setLength(); + request->send(response); + } + + void getNotFound(JsonObject obj, String url) { + JsonObject ep = obj.createNestedObject("avail_endpoints"); + ep[F("system")] = url + F("system"); + ep[F("statistics")] = url + F("statistics"); + ep[F("inverter/list")] = url + F("inverter/list"); + ep[F("index")] = url + F("index"); + ep[F("setup")] = url + F("setup"); + ep[F("live")] = url + F("live"); + ep[F("record/info")] = url + F("record/info"); + ep[F("record/alarm")] = url + F("record/alarm"); + ep[F("record/config")] = url + F("record/config"); + ep[F("record/live")] = url + F("record/live"); + } + + void onDwnldSetup(AsyncWebServerRequest *request) { + AsyncWebServerResponse *response; + + File fp = LittleFS.open("/settings.json", "r"); + if (!fp) { + DPRINTLN(DBG_ERROR, F("failed to load settings")); + response = request->beginResponse(200, F("application/json; charset=utf-8"), "{}"); + } else { + String tmp = fp.readString(); + int i = 0; + // remove all passwords + while (i != -1) { + i = tmp.indexOf("\"pwd\":", i); + if (-1 != i) { + i += 7; + tmp.remove(i, tmp.indexOf("\"", i) - i); } } - else { - switch (err.code()) { - case DeserializationError::Ok: break; - case DeserializationError::InvalidInput: root[F("error")] = F("Invalid input"); break; - case DeserializationError::NoMemory: root[F("error")] = F("Not enough memory"); break; - default: root[F("error")] = F("Deserialization failed"); break; - } - } - - response->setLength(); - request->send(response); + response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp); } - void getNotFound(JsonObject obj, String url) { - JsonObject ep = obj.createNestedObject("avail_endpoints"); - ep[F("system")] = url + F("system"); - ep[F("statistics")] = url + F("statistics"); - ep[F("inverter/list")] = url + F("inverter/list"); - ep[F("index")] = url + F("index"); - ep[F("setup")] = url + F("setup"); - ep[F("live")] = url + F("live"); - ep[F("record/info")] = url + F("record/info"); - ep[F("record/alarm")] = url + F("record/alarm"); - ep[F("record/config")] = url + F("record/config"); - ep[F("record/live")] = url + F("record/live"); - } + response->addHeader("Content-Type", "application/octet-stream"); + response->addHeader("Content-Description", "File Transfer"); + response->addHeader("Content-Disposition", "attachment; filename=ahoy_setup.json"); + request->send(response); + fp.close(); + } - void onDwnldSetup(AsyncWebServerRequest *request) { - AsyncWebServerResponse *response; + void getGeneric(JsonObject obj) { + obj[F("wifi_rssi")] = (WiFi.status() != WL_CONNECTED) ? 0 : WiFi.RSSI(); + obj[F("ts_uptime")] = mApp->getUptime(); + obj[F("menu_prot")] = mApp->getProtection(); + obj[F("menu_mask")] = (uint16_t)(mConfig->sys.protectionMask); + obj[F("menu_protEn")] = (bool)(strlen(mConfig->sys.adminPwd) > 0); - File fp = LittleFS.open("/settings.json", "r"); - if(!fp) { - DPRINTLN(DBG_ERROR, F("failed to load settings")); - response = request->beginResponse(200, F("application/json; charset=utf-8"), "{}"); - } - else { - String tmp = fp.readString(); - int i = 0; - // remove all passwords - while (i != -1) { - i = tmp.indexOf("\"pwd\":", i); - if(-1 != i) { - i+=7; - tmp.remove(i, tmp.indexOf("\"", i)-i); - } +#if defined(ESP32) + obj[F("esp_type")] = F("ESP32"); +#else + obj[F("esp_type")] = F("ESP8266"); +#endif + } + + void getSysInfo(JsonObject obj) { + obj[F("ssid")] = mConfig->sys.stationSsid; + obj[F("device_name")] = mConfig->sys.deviceName; + obj[F("dark_mode")] = (bool)mConfig->sys.darkMode; + + obj[F("mac")] = WiFi.macAddress(); + obj[F("hostname")] = mConfig->sys.deviceName; + obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); + obj[F("prot_mask")] = mConfig->sys.protectionMask; + + obj[F("sdk")] = ESP.getSdkVersion(); + obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); + obj[F("heap_free")] = mHeapFree; + obj[F("sketch_total")] = ESP.getFreeSketchSpace(); + obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb + getGeneric(obj); + + getRadio(obj.createNestedObject(F("radio"))); + getStatistics(obj.createNestedObject(F("statistics"))); + +#if defined(ESP32) + obj[F("heap_total")] = ESP.getHeapSize(); + obj[F("chip_revision")] = ESP.getChipRevision(); + obj[F("chip_model")] = ESP.getChipModel(); + obj[F("chip_cores")] = ESP.getChipCores(); + // obj[F("core_version")] = F("n/a"); + // obj[F("flash_size")] = F("n/a"); + // obj[F("heap_frag")] = F("n/a"); + // obj[F("max_free_blk")] = F("n/a"); + // obj[F("reboot_reason")] = F("n/a"); +#else + // obj[F("heap_total")] = F("n/a"); + // obj[F("chip_revision")] = F("n/a"); + // obj[F("chip_model")] = F("n/a"); + // obj[F("chip_cores")] = F("n/a"); + obj[F("core_version")] = ESP.getCoreVersion(); + obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb + obj[F("heap_frag")] = mHeapFrag; + obj[F("max_free_blk")] = mHeapFreeBlk; + obj[F("reboot_reason")] = ESP.getResetReason(); +#endif + // obj[F("littlefs_total")] = LittleFS.totalBytes(); + // obj[F("littlefs_used")] = LittleFS.usedBytes(); + + uint8_t max; + mApp->getSchedulerInfo(&max); + obj[F("schMax")] = max; + } + + void getHtmlSystem(JsonObject obj) { + getSysInfo(obj.createNestedObject(F("system"))); + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("html")] = F("Factory Reset

Reboot"); + } + + void getHtmlLogout(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 3; + obj[F("refresh_url")] = "/"; + obj[F("html")] = F("succesfully logged out"); + } + + void getHtmlSave(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 2; + obj[F("refresh_url")] = "/setup"; + obj[F("html")] = F("settings succesfully save"); + } + + void getReboot(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 10; + obj[F("refresh_url")] = "/"; + obj[F("html")] = F("reboot. Autoreload after 10 seconds"); + } + + void getStatistics(JsonObject obj) { + statistics_t *stat = mApp->getStatistics(); + obj[F("rx_success")] = stat->rxSuccess; + obj[F("rx_fail")] = stat->rxFail; + obj[F("rx_fail_answer")] = stat->rxFailNoAnser; + obj[F("frame_cnt")] = stat->frmCnt; + obj[F("tx_cnt")] = mSys->Radio.mSendCnt; + obj[F("retransmits")] = mSys->Radio.mRetransmits; + } + + void getInverterList(JsonObject obj) { + JsonArray invArr = obj.createNestedArray(F("inverter")); + + Inverter<> *iv; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i); + if (NULL != iv) { + JsonObject obj2 = invArr.createNestedObject(); + obj2[F("enabled")] = (bool)iv->config->enabled; + obj2[F("id")] = i; + obj2[F("name")] = String(iv->config->name); + obj2[F("serial")] = String(iv->config->serial.u64, HEX); + obj2[F("channels")] = iv->channels; + obj2[F("version")] = String(iv->getFwVersion()); + + for (uint8_t j = 0; j < iv->channels; j++) { + obj2[F("ch_yield_cor")][j] = iv->config->yieldCor[j]; + obj2[F("ch_max_power")][j] = iv->config->chMaxPwr[j]; + obj2[F("ch_name")][j] = iv->config->chName[j]; } - response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp); } - - response->addHeader("Content-Type", "application/octet-stream"); - response->addHeader("Content-Description", "File Transfer"); - response->addHeader("Content-Disposition", "attachment; filename=ahoy_setup.json"); - request->send(response); - fp.close(); - } - - void getGeneric(JsonObject obj) { - obj[F("wifi_rssi")] = (WiFi.status() != WL_CONNECTED) ? 0 : WiFi.RSSI(); - obj[F("ts_uptime")] = mApp->getUptime(); - obj[F("menu_prot")] = mApp->getProtection(); - obj[F("menu_mask")] = (uint16_t)(mConfig->sys.protectionMask ); - obj[F("menu_protEn")] = (bool) (strlen(mConfig->sys.adminPwd) > 0); - - #if defined(ESP32) - obj[F("esp_type")] = F("ESP32"); - #else - obj[F("esp_type")] = F("ESP8266"); - #endif - } - - void getSysInfo(JsonObject obj) { - obj[F("ssid")] = mConfig->sys.stationSsid; - obj[F("device_name")] = mConfig->sys.deviceName; - obj[F("dark_mode")] = (bool)mConfig->sys.darkMode; - - obj[F("mac")] = WiFi.macAddress(); - obj[F("hostname")] = mConfig->sys.deviceName; - obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); - obj[F("prot_mask")] = mConfig->sys.protectionMask; - - obj[F("sdk")] = ESP.getSdkVersion(); - obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); - obj[F("heap_free")] = mHeapFree; - obj[F("sketch_total")] = ESP.getFreeSketchSpace(); - obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb - getGeneric(obj); - - getRadio(obj.createNestedObject(F("radio"))); - getStatistics(obj.createNestedObject(F("statistics"))); - - #if defined(ESP32) - obj[F("heap_total")] = ESP.getHeapSize(); - obj[F("chip_revision")] = ESP.getChipRevision(); - obj[F("chip_model")] = ESP.getChipModel(); - obj[F("chip_cores")] = ESP.getChipCores(); - //obj[F("core_version")] = F("n/a"); - //obj[F("flash_size")] = F("n/a"); - //obj[F("heap_frag")] = F("n/a"); - //obj[F("max_free_blk")] = F("n/a"); - //obj[F("reboot_reason")] = F("n/a"); - #else - //obj[F("heap_total")] = F("n/a"); - //obj[F("chip_revision")] = F("n/a"); - //obj[F("chip_model")] = F("n/a"); - //obj[F("chip_cores")] = F("n/a"); - obj[F("core_version")] = ESP.getCoreVersion(); - obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb - obj[F("heap_frag")] = mHeapFrag; - obj[F("max_free_blk")] = mHeapFreeBlk; - obj[F("reboot_reason")] = ESP.getResetReason(); - #endif - //obj[F("littlefs_total")] = LittleFS.totalBytes(); - //obj[F("littlefs_used")] = LittleFS.usedBytes(); - - uint8_t max; - mApp->getSchedulerInfo(&max); - obj[F("schMax")] = max; - } - - void getHtmlSystem(JsonObject obj) { - getSysInfo(obj.createNestedObject(F("system"))); - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("html")] = F("Factory Reset

Reboot"); - - } - - void getHtmlLogout(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 3; - obj[F("refresh_url")] = "/"; - obj[F("html")] = F("succesfully logged out"); - } - - void getHtmlSave(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 2; - obj[F("refresh_url")] = "/setup"; - obj[F("html")] = F("settings succesfully save"); - } - - void getReboot(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 10; - obj[F("refresh_url")] = "/"; - obj[F("html")] = F("reboot. Autoreload after 10 seconds"); - } - - void getStatistics(JsonObject obj) { - statistics_t *stat = mApp->getStatistics(); - obj[F("rx_success")] = stat->rxSuccess; - obj[F("rx_fail")] = stat->rxFail; - obj[F("rx_fail_answer")] = stat->rxFailNoAnser; - obj[F("frame_cnt")] = stat->frmCnt; - obj[F("tx_cnt")] = mSys->Radio.mSendCnt; - obj[F("retransmits")] = mSys->Radio.mRetransmits; } + obj[F("interval")] = String(mConfig->nrf.sendInterval); + obj[F("retries")] = String(mConfig->nrf.maxRetransPerPyld); + obj[F("max_num_inverters")] = MAX_NUM_INVERTERS; + obj[F("rstMid")] = (bool)mConfig->inst.rstYieldMidNight; + obj[F("rstNAvail")] = (bool)mConfig->inst.rstValsNotAvail; + obj[F("rstComStop")] = (bool)mConfig->inst.rstValsCommStop; + } + + void getInverter(JsonObject obj, uint8_t id) { + Inverter<> *iv = mSys->getInverterByPos(id); + if (NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + obj[F("id")] = id; + obj[F("enabled")] = (bool)iv->config->enabled; + obj[F("name")] = String(iv->config->name); + obj[F("serial")] = String(iv->config->serial.u64, HEX); + obj[F("version")] = String(iv->getFwVersion()); + obj[F("power_limit_read")] = ah::round3(iv->actPowerLimit); + obj[F("ts_last_success")] = rec->ts; + + JsonArray ch = obj.createNestedArray("ch"); + + // AC + uint8_t pos; + obj[F("ch_name")][0] = "AC"; + JsonArray ch0 = ch.createNestedArray(); + for (uint8_t fld = 0; fld < sizeof(acList); fld++) { + pos = (iv->getPosByChFld(CH0, acList[fld], rec)); + ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + } - void getInverterList(JsonObject obj) { - JsonArray invArr = obj.createNestedArray(F("inverter")); - - Inverter<> *iv; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); - if(NULL != iv) { - JsonObject obj2 = invArr.createNestedObject(); - obj2[F("enabled")] = (bool)iv->config->enabled; - obj2[F("id")] = i; - obj2[F("name")] = String(iv->config->name); - obj2[F("serial")] = String(iv->config->serial.u64, HEX); - obj2[F("channels")] = iv->channels; - obj2[F("version")] = String(iv->getFwVersion()); - - for(uint8_t j = 0; j < iv->channels; j ++) { - obj2[F("ch_yield_cor")][j] = iv->config->yieldCor[j]; - obj2[F("ch_max_power")][j] = iv->config->chMaxPwr[j]; - obj2[F("ch_name")][j] = iv->config->chName[j]; - } + // DC + for (uint8_t j = 0; j < iv->channels; j++) { + obj[F("ch_name")][j + 1] = iv->config->chName[j]; + JsonArray cur = ch.createNestedArray(); + for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { + pos = (iv->getPosByChFld((j + 1), dcList[fld], rec)); + cur[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; } } - obj[F("interval")] = String(mConfig->nrf.sendInterval); - obj[F("retries")] = String(mConfig->nrf.maxRetransPerPyld); - obj[F("max_num_inverters")] = MAX_NUM_INVERTERS; - obj[F("rstMid")] = (bool)mConfig->inst.rstYieldMidNight; - obj[F("rstNAvail")] = (bool)mConfig->inst.rstValsNotAvail; - obj[F("rstComStop")] = (bool)mConfig->inst.rstValsCommStop; + } + } + + void getMqtt(JsonObject obj) { + obj[F("broker")] = String(mConfig->mqtt.broker); + obj[F("port")] = String(mConfig->mqtt.port); + obj[F("user")] = String(mConfig->mqtt.user); + obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); + obj[F("topic")] = String(mConfig->mqtt.topic); + obj[F("interval")] = String(mConfig->mqtt.interval); + } + + void getNtp(JsonObject obj) { + obj[F("addr")] = String(mConfig->ntp.addr); + obj[F("port")] = String(mConfig->ntp.port); + } + + void getSun(JsonObject obj) { + obj[F("lat")] = mConfig->sun.lat ? String(mConfig->sun.lat, 5) : ""; + obj[F("lon")] = mConfig->sun.lat ? String(mConfig->sun.lon, 5) : ""; + obj[F("disnightcom")] = mConfig->sun.disNightCom; + obj[F("offs")] = mConfig->sun.offsetSec; + } + + void getPinout(JsonObject obj) { + obj[F("cs")] = mConfig->nrf.pinCs; + obj[F("ce")] = mConfig->nrf.pinCe; + obj[F("irq")] = mConfig->nrf.pinIrq; + obj[F("led0")] = mConfig->led.led0; + obj[F("led1")] = mConfig->led.led1; + } + + void getRadio(JsonObject obj) { + obj[F("power_level")] = mConfig->nrf.amplifierPower; + obj[F("isconnected")] = mSys->Radio.isChipConnected(); + obj[F("DataRate")] = mSys->Radio.getDataRate(); + obj[F("isPVariant")] = mSys->Radio.isPVariant(); + } + + void getSerial(JsonObject obj) { + obj[F("interval")] = (uint16_t)mConfig->serial.interval; + obj[F("show_live_data")] = mConfig->serial.showIv; + obj[F("debug")] = mConfig->serial.debug; + } + + void getStaticIp(JsonObject obj) { + char buf[16]; + ah::ip2Char(mConfig->sys.ip.ip, buf); + obj[F("ip")] = String(buf); + ah::ip2Char(mConfig->sys.ip.mask, buf); + obj[F("mask")] = String(buf); + ah::ip2Char(mConfig->sys.ip.dns1, buf); + obj[F("dns1")] = String(buf); + ah::ip2Char(mConfig->sys.ip.dns2, buf); + obj[F("dns2")] = String(buf); + ah::ip2Char(mConfig->sys.ip.gateway, buf); + obj[F("gateway")] = String(buf); + } + + void getDisplay(JsonObject obj) { + obj[F("disp_type")] = (uint8_t)mConfig->plugin.display.type; + obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; + obj[F("logo_en")] = (bool)mConfig->plugin.display.logoEn; + obj[F("px_shift")] = (bool)mConfig->plugin.display.pxShift; + obj[F("rotation")] = (uint8_t)mConfig->plugin.display.rot; + obj[F("contrast")] = (uint8_t)mConfig->plugin.display.contrast; + obj[F("data")] = mConfig->plugin.display.disp_data; + obj[F("clock")] = mConfig->plugin.display.disp_clk; + obj[F("cs")] = mConfig->plugin.display.disp_cs; + obj[F("reset")] = mConfig->plugin.display.disp_reset; + obj[F("busy")] = mConfig->plugin.display.disp_busy; + obj[F("dc")] = mConfig->plugin.display.disp_dc; + } + + void getIndex(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("ts_now")] = mApp->getTimestamp(); + obj[F("ts_sunrise")] = mApp->getSunrise(); + obj[F("ts_sunset")] = mApp->getSunset(); + obj[F("ts_offset")] = mConfig->sun.offsetSec; + obj[F("disNightComm")] = mConfig->sun.disNightCom; + + JsonArray inv = obj.createNestedArray(F("inverter")); + Inverter<> *iv; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i); + if (NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + JsonObject invObj = inv.createNestedObject(); + invObj[F("enabled")] = (bool)iv->config->enabled; + invObj[F("id")] = i; + invObj[F("name")] = String(iv->config->name); + invObj[F("version")] = String(iv->getFwVersion()); + invObj[F("is_avail")] = iv->isAvailable(mApp->getTimestamp()); + invObj[F("is_producing")] = iv->isProducing(mApp->getTimestamp()); + invObj[F("ts_last_success")] = iv->getLastTs(rec); + } } - void getInverter(JsonObject obj, uint8_t id) { - Inverter<> *iv = mSys->getInverterByPos(id); + JsonArray warn = obj.createNestedArray(F("warnings")); + if (!mSys->Radio.isChipConnected()) + warn.add(F("your NRF24 module can't be reached, check the wiring and pinout")); + else if (!mSys->Radio.isPVariant()) + warn.add(F("your NRF24 module isn't a plus version(+), maybe incompatible")); + if (!mApp->getSettingsValid()) + warn.add(F("your settings are invalid")); + if (mApp->getRebootRequestState()) + warn.add(F("reboot your ESP to apply all your configuration changes")); + if (0 == mApp->getTimestamp()) + warn.add(F("time not set. No communication to inverter possible")); + /*if(0 == mSys->getNumInverters()) + warn.add(F("no inverter configured"));*/ + + if ((!mApp->getMqttIsConnected()) && (String(mConfig->mqtt.broker).length() > 0)) + warn.add(F("MQTT is not connected")); + + JsonArray info = obj.createNestedArray(F("infos")); + if (mApp->getMqttIsConnected()) + info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent, ") + String(mApp->getMqttRxCnt()) + F(" packets received")); + if (mConfig->mqtt.interval > 0) + info.add(F("MQTT publishes in a fixed interval of ") + String(mConfig->mqtt.interval) + F(" seconds")); + } + + void getSetup(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + getSysInfo(obj.createNestedObject(F("system"))); + // getInverterList(obj.createNestedObject(F("inverter"))); + getMqtt(obj.createNestedObject(F("mqtt"))); + getNtp(obj.createNestedObject(F("ntp"))); + getSun(obj.createNestedObject(F("sun"))); + getPinout(obj.createNestedObject(F("pinout"))); + getRadio(obj.createNestedObject(F("radio"))); + getSerial(obj.createNestedObject(F("serial"))); + getStaticIp(obj.createNestedObject(F("static_ip"))); + getDisplay(obj.createNestedObject(F("display"))); + } + + void getNetworks(JsonObject obj) { + mApp->getAvailNetworks(obj); + } + + void getLive(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + // JsonArray invArr = obj.createNestedArray(F("inverter")); + obj[F("refresh")] = mConfig->nrf.sendInterval; + + for (uint8_t fld = 0; fld < sizeof(acList); fld++) { + obj[F("ch0_fld_units")][fld] = String(units[fieldUnits[acList[fld]]]); + obj[F("ch0_fld_names")][fld] = String(fields[acList[fld]]); + } + for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { + obj[F("fld_units")][fld] = String(units[fieldUnits[dcList[fld]]]); + obj[F("fld_names")][fld] = String(fields[dcList[fld]]); + } + + Inverter<> *iv; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i); + bool parse = false; + if (NULL != iv) + parse = iv->config->enabled; + obj[F("iv")][i] = parse; + } + + /*Inverter<> *iv; + uint8_t pos; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - obj[F("id")] = id; - obj[F("enabled")] = (bool)iv->config->enabled; - obj[F("name")] = String(iv->config->name); - obj[F("serial")] = String(iv->config->serial.u64, HEX); - obj[F("version")] = String(iv->getFwVersion()); - obj[F("power_limit_read")] = ah::round3(iv->actPowerLimit); - obj[F("ts_last_success")] = rec->ts; - - JsonArray ch = obj.createNestedArray("ch"); - - // AC - uint8_t pos; - obj[F("ch_name")][0] = "AC"; + JsonObject obj2 = invArr.createNestedObject(); + obj2[F("enabled")] = (bool)iv->config->enabled; + obj2[F("name")] = String(iv->config->name); + obj2[F("channels")] = iv->channels; + obj2[F("power_limit_read")] = ah::round3(iv->actPowerLimit); + //obj2[F("last_alarm")] = String(iv->lastAlarmMsg); + obj2[F("ts_last_success")] = rec->ts; + + JsonArray ch = obj2.createNestedArray("ch"); JsonArray ch0 = ch.createNestedArray(); - for (uint8_t fld = 0; fld < sizeof(acList); fld++) { - pos = (iv->getPosByChFld(CH0, acList[fld], rec)); + obj2[F("ch_names")][0] = "AC"; + for (uint8_t fld = 0; fld < sizeof(list); fld++) { + pos = (iv->getPosByChFld(CH0, list[fld], rec)); ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; } - // DC - for(uint8_t j = 0; j < iv->channels; j ++) { - obj[F("ch_name")][j+1] = iv->config->chName[j]; + for(uint8_t j = 1; j <= iv->channels; j ++) { + obj2[F("ch_names")][j] = String(iv->config->chName[j-1]); JsonArray cur = ch.createNestedArray(); - for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { - pos = (iv->getPosByChFld((j+1), dcList[fld], rec)); - cur[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - } - } - } - } - - void getMqtt(JsonObject obj) { - obj[F("broker")] = String(mConfig->mqtt.broker); - obj[F("port")] = String(mConfig->mqtt.port); - obj[F("user")] = String(mConfig->mqtt.user); - obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); - obj[F("topic")] = String(mConfig->mqtt.topic); - obj[F("interval")] = String(mConfig->mqtt.interval); - } - - void getNtp(JsonObject obj) { - obj[F("addr")] = String(mConfig->ntp.addr); - obj[F("port")] = String(mConfig->ntp.port); - } - - void getSun(JsonObject obj) { - obj[F("lat")] = mConfig->sun.lat ? String(mConfig->sun.lat, 5) : ""; - obj[F("lon")] = mConfig->sun.lat ? String(mConfig->sun.lon, 5) : ""; - obj[F("disnightcom")] = mConfig->sun.disNightCom; - obj[F("offs")] = mConfig->sun.offsetSec; - } - - void getPinout(JsonObject obj) { - obj[F("cs")] = mConfig->nrf.pinCs; - obj[F("ce")] = mConfig->nrf.pinCe; - obj[F("irq")] = mConfig->nrf.pinIrq; - obj[F("led0")] = mConfig->led.led0; - obj[F("led1")] = mConfig->led.led1; - } - - void getRadio(JsonObject obj) { - obj[F("power_level")] = mConfig->nrf.amplifierPower; - obj[F("isconnected")] = mSys->Radio.isChipConnected(); - obj[F("DataRate")] = mSys->Radio.getDataRate(); - obj[F("isPVariant")] = mSys->Radio.isPVariant(); - } - - void getSerial(JsonObject obj) { - obj[F("interval")] = (uint16_t)mConfig->serial.interval; - obj[F("show_live_data")] = mConfig->serial.showIv; - obj[F("debug")] = mConfig->serial.debug; - } - - void getStaticIp(JsonObject obj) { - char buf[16]; - ah::ip2Char(mConfig->sys.ip.ip, buf); obj[F("ip")] = String(buf); - ah::ip2Char(mConfig->sys.ip.mask, buf); obj[F("mask")] = String(buf); - ah::ip2Char(mConfig->sys.ip.dns1, buf); obj[F("dns1")] = String(buf); - ah::ip2Char(mConfig->sys.ip.dns2, buf); obj[F("dns2")] = String(buf); - ah::ip2Char(mConfig->sys.ip.gateway, buf); obj[F("gateway")] = String(buf); - } - - void getDisplay(JsonObject obj) { - obj[F("disp_type")] = (uint8_t)mConfig->plugin.display.type; - obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; - obj[F("logo_en")] = (bool)mConfig->plugin.display.logoEn; - obj[F("px_shift")] = (bool)mConfig->plugin.display.pxShift; - obj[F("rot180")] = (bool)mConfig->plugin.display.rot180; - obj[F("contrast")] = (uint8_t)mConfig->plugin.display.contrast; - obj[F("pinDisp0")] = mConfig->plugin.display.pin0; - obj[F("pinDisp1")] = mConfig->plugin.display.pin1; - } - - - void getIndex(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("ts_now")] = mApp->getTimestamp(); - obj[F("ts_sunrise")] = mApp->getSunrise(); - obj[F("ts_sunset")] = mApp->getSunset(); - obj[F("ts_offset")] = mConfig->sun.offsetSec; - obj[F("disNightComm")] = mConfig->sun.disNightCom; - - JsonArray inv = obj.createNestedArray(F("inverter")); - Inverter<> *iv; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - JsonObject invObj = inv.createNestedObject(); - invObj[F("enabled")] = (bool)iv->config->enabled; - invObj[F("id")] = i; - invObj[F("name")] = String(iv->config->name); - invObj[F("version")] = String(iv->getFwVersion()); - invObj[F("is_avail")] = iv->isAvailable(mApp->getTimestamp()); - invObj[F("is_producing")] = iv->isProducing(mApp->getTimestamp()); - invObj[F("ts_last_success")] = iv->getLastTs(rec); - } - } - - JsonArray warn = obj.createNestedArray(F("warnings")); - if(!mSys->Radio.isChipConnected()) - warn.add(F("your NRF24 module can't be reached, check the wiring and pinout")); - else if(!mSys->Radio.isPVariant()) - warn.add(F("your NRF24 module isn't a plus version(+), maybe incompatible")); - if(!mApp->getSettingsValid()) - warn.add(F("your settings are invalid")); - if(mApp->getRebootRequestState()) - warn.add(F("reboot your ESP to apply all your configuration changes")); - if(0 == mApp->getTimestamp()) - warn.add(F("time not set. No communication to inverter possible")); - /*if(0 == mSys->getNumInverters()) - warn.add(F("no inverter configured"));*/ - - if((!mApp->getMqttIsConnected()) && (String(mConfig->mqtt.broker).length() > 0)) - warn.add(F("MQTT is not connected")); - - JsonArray info = obj.createNestedArray(F("infos")); - if(mApp->getMqttIsConnected()) - info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent, ") + String(mApp->getMqttRxCnt()) + F(" packets received")); - if(mConfig->mqtt.interval > 0) - info.add(F("MQTT publishes in a fixed interval of ") + String(mConfig->mqtt.interval) + F(" seconds")); - } - - void getSetup(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - getSysInfo(obj.createNestedObject(F("system"))); - //getInverterList(obj.createNestedObject(F("inverter"))); - getMqtt(obj.createNestedObject(F("mqtt"))); - getNtp(obj.createNestedObject(F("ntp"))); - getSun(obj.createNestedObject(F("sun"))); - getPinout(obj.createNestedObject(F("pinout"))); - getRadio(obj.createNestedObject(F("radio"))); - getSerial(obj.createNestedObject(F("serial"))); - getStaticIp(obj.createNestedObject(F("static_ip"))); - getDisplay(obj.createNestedObject(F("display"))); - } - - void getNetworks(JsonObject obj) { - mApp->getAvailNetworks(obj); - } - - void getLive(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - //JsonArray invArr = obj.createNestedArray(F("inverter")); - obj[F("refresh")] = mConfig->nrf.sendInterval; - - for (uint8_t fld = 0; fld < sizeof(acList); fld++) { - obj[F("ch0_fld_units")][fld] = String(units[fieldUnits[acList[fld]]]); - obj[F("ch0_fld_names")][fld] = String(fields[acList[fld]]); - } - for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { - obj[F("fld_units")][fld] = String(units[fieldUnits[dcList[fld]]]); - obj[F("fld_names")][fld] = String(fields[dcList[fld]]); - } - - Inverter<> *iv; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); - bool parse = false; - if(NULL != iv) - parse = iv->config->enabled; - obj[F("iv")][i] = parse; - } - - /*Inverter<> *iv; - uint8_t pos; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - JsonObject obj2 = invArr.createNestedObject(); - obj2[F("enabled")] = (bool)iv->config->enabled; - obj2[F("name")] = String(iv->config->name); - obj2[F("channels")] = iv->channels; - obj2[F("power_limit_read")] = ah::round3(iv->actPowerLimit); - //obj2[F("last_alarm")] = String(iv->lastAlarmMsg); - obj2[F("ts_last_success")] = rec->ts; - - JsonArray ch = obj2.createNestedArray("ch"); - JsonArray ch0 = ch.createNestedArray(); - obj2[F("ch_names")][0] = "AC"; - for (uint8_t fld = 0; fld < sizeof(list); fld++) { - pos = (iv->getPosByChFld(CH0, list[fld], rec)); - ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; - } - - for(uint8_t j = 1; j <= iv->channels; j ++) { - obj2[F("ch_names")][j] = String(iv->config->chName[j-1]); - JsonArray cur = ch.createNestedArray(); - for (uint8_t k = 0; k < 6; k++) { - switch(k) { - default: pos = (iv->getPosByChFld(j, FLD_UDC, rec)); break; - case 1: pos = (iv->getPosByChFld(j, FLD_IDC, rec)); break; - case 2: pos = (iv->getPosByChFld(j, FLD_PDC, rec)); break; - case 3: pos = (iv->getPosByChFld(j, FLD_YD, rec)); break; - case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break; - case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break; - } - cur[k] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - if(1 == j) { - obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; - } + for (uint8_t k = 0; k < 6; k++) { + switch(k) { + default: pos = (iv->getPosByChFld(j, FLD_UDC, rec)); break; + case 1: pos = (iv->getPosByChFld(j, FLD_IDC, rec)); break; + case 2: pos = (iv->getPosByChFld(j, FLD_PDC, rec)); break; + case 3: pos = (iv->getPosByChFld(j, FLD_YD, rec)); break; + case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break; + case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break; + } + cur[k] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + if(1 == j) { + obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; } } } - }*/ - } - - void getRecord(JsonObject obj, uint8_t recType) { - JsonArray invArr = obj.createNestedArray(F("inverter")); - - Inverter<> *iv; - record_t<> *rec; - uint8_t pos; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); - if(NULL != iv) { - rec = iv->getRecordStruct(recType); - JsonArray obj2 = invArr.createNestedArray(); - for(uint8_t j = 0; j < rec->length; j++) { - byteAssign_t *assign = iv->getByteAssign(j, rec); - pos = (iv->getPosByChFld(assign->ch, assign->fieldId, rec)); - obj2[j]["fld"] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; - obj2[j]["unit"] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj2[j]["val"] = (0xff != pos) ? String(iv->getValue(pos, rec)) : notAvail; - } - } - } - } - - bool setCtrl(JsonObject jsonIn, JsonObject jsonOut) { - Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")]); - bool accepted = true; - if(NULL == iv) { - jsonOut[F("error")] = F("inverter index invalid: ") + jsonIn[F("id")].as(); - return false; } - - if(F("power") == jsonIn[F("cmd")]) - accepted = iv->setDevControlRequest((jsonIn[F("val")] == 1) ? TurnOn : TurnOff); - else if(F("restart") == jsonIn[F("restart")]) - accepted = iv->setDevControlRequest(Restart); - else if(0 == strncmp("limit_", jsonIn[F("cmd")].as(), 6)) { - iv->powerLimit[0] = jsonIn["val"]; - if(F("limit_persistent_relative") == jsonIn[F("cmd")]) - iv->powerLimit[1] = RelativPersistent; - else if(F("limit_persistent_absolute") == jsonIn[F("cmd")]) - iv->powerLimit[1] = AbsolutPersistent; - else if(F("limit_nonpersistent_relative") == jsonIn[F("cmd")]) - iv->powerLimit[1] = RelativNonPersistent; - else if(F("limit_nonpersistent_absolute") == jsonIn[F("cmd")]) - iv->powerLimit[1] = AbsolutNonPersistent; - - accepted = iv->setDevControlRequest(ActivePowerContr); - } - else if(F("dev") == jsonIn[F("cmd")]) { - DPRINTLN(DBG_INFO, F("dev cmd")); - iv->enqueCommand(jsonIn[F("val")].as()); - } - else { - jsonOut[F("error")] = F("unknown cmd: '") + jsonIn["cmd"].as() + "'"; - return false; - } - - if(!accepted) { - jsonOut[F("error")] = F("inverter does not accept dev control request at this moment"); - return false; - } else - mApp->ivSendHighPrio(iv); - - return true; - } - - bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { - if(F("scan_wifi") == jsonIn[F("cmd")]) - mApp->scanAvailNetworks(); - else if(F("set_time") == jsonIn[F("cmd")]) - mApp->setTimestamp(jsonIn[F("val")]); - else if(F("sync_ntp") == jsonIn[F("cmd")]) - mApp->setTimestamp(0); // 0: update ntp flag - else if(F("serial_utc_offset") == jsonIn[F("cmd")]) - mTimezoneOffset = jsonIn[F("val")]; - else if(F("discovery_cfg") == jsonIn[F("cmd")]) { - mApp->setMqttDiscoveryFlag(); // for homeassistant - } - else { - jsonOut[F("error")] = F("unknown cmd"); - return false; + }*/ + } + + void getRecord(JsonObject obj, uint8_t recType) { + JsonArray invArr = obj.createNestedArray(F("inverter")); + + Inverter<> *iv; + record_t<> *rec; + uint8_t pos; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i); + if (NULL != iv) { + rec = iv->getRecordStruct(recType); + JsonArray obj2 = invArr.createNestedArray(); + for (uint8_t j = 0; j < rec->length; j++) { + byteAssign_t *assign = iv->getByteAssign(j, rec); + pos = (iv->getPosByChFld(assign->ch, assign->fieldId, rec)); + obj2[j]["fld"] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; + obj2[j]["unit"] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj2[j]["val"] = (0xff != pos) ? String(iv->getValue(pos, rec)) : notAvail; + } } - - return true; } - - IApp *mApp; - HMSYSTEM *mSys; - AsyncWebServer *mSrv; - settings_t *mConfig; - - uint32_t mTimezoneOffset; - uint32_t mHeapFree, mHeapFreeBlk; - uint8_t mHeapFrag; - uint16_t nr; + } + + bool setCtrl(JsonObject jsonIn, JsonObject jsonOut) { + Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")]); + bool accepted = true; + if (NULL == iv) { + jsonOut[F("error")] = F("inverter index invalid: ") + jsonIn[F("id")].as(); + return false; + } + + if (F("power") == jsonIn[F("cmd")]) + accepted = iv->setDevControlRequest((jsonIn[F("val")] == 1) ? TurnOn : TurnOff); + else if (F("restart") == jsonIn[F("restart")]) + accepted = iv->setDevControlRequest(Restart); + else if (0 == strncmp("limit_", jsonIn[F("cmd")].as(), 6)) { + iv->powerLimit[0] = jsonIn["val"]; + if (F("limit_persistent_relative") == jsonIn[F("cmd")]) + iv->powerLimit[1] = RelativPersistent; + else if (F("limit_persistent_absolute") == jsonIn[F("cmd")]) + iv->powerLimit[1] = AbsolutPersistent; + else if (F("limit_nonpersistent_relative") == jsonIn[F("cmd")]) + iv->powerLimit[1] = RelativNonPersistent; + else if (F("limit_nonpersistent_absolute") == jsonIn[F("cmd")]) + iv->powerLimit[1] = AbsolutNonPersistent; + + accepted = iv->setDevControlRequest(ActivePowerContr); + } else if (F("dev") == jsonIn[F("cmd")]) { + DPRINTLN(DBG_INFO, F("dev cmd")); + iv->enqueCommand(jsonIn[F("val")].as()); + } else { + jsonOut[F("error")] = F("unknown cmd: '") + jsonIn["cmd"].as() + "'"; + return false; + } + + if (!accepted) { + jsonOut[F("error")] = F("inverter does not accept dev control request at this moment"); + return false; + } else + mApp->ivSendHighPrio(iv); + + return true; + } + + bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { + if (F("scan_wifi") == jsonIn[F("cmd")]) + mApp->scanAvailNetworks(); + else if (F("set_time") == jsonIn[F("cmd")]) + mApp->setTimestamp(jsonIn[F("val")]); + else if (F("sync_ntp") == jsonIn[F("cmd")]) + mApp->setTimestamp(0); // 0: update ntp flag + else if (F("serial_utc_offset") == jsonIn[F("cmd")]) + mTimezoneOffset = jsonIn[F("val")]; + else if (F("discovery_cfg") == jsonIn[F("cmd")]) { + mApp->setMqttDiscoveryFlag(); // for homeassistant + } else { + jsonOut[F("error")] = F("unknown cmd"); + return false; + } + + return true; + } + + IApp *mApp; + HMSYSTEM *mSys; + AsyncWebServer *mSrv; + settings_t *mConfig; + + uint32_t mTimezoneOffset; + uint32_t mHeapFree, mHeapFreeBlk; + uint8_t mHeapFrag; + uint16_t nr; }; #endif /*__WEB_API_H__*/ diff --git a/src/web/web.h b/src/web/web.h index d79ace82..aa46e4ee 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -8,932 +8,948 @@ #include "../utils/dbg.h" #ifdef ESP32 - #include "AsyncTCP.h" - #include "Update.h" +#include "AsyncTCP.h" +#include "Update.h" #else - #include "ESPAsyncTCP.h" +#include "ESPAsyncTCP.h" #endif -#include "ESPAsyncWebServer.h" - #include "../appInterface.h" - #include "../hm/hmSystem.h" #include "../utils/helper.h" - -#include "html/h/index_html.h" -#include "html/h/login_html.h" -#include "html/h/style_css.h" -#include "html/h/colorDark_css.h" -#include "html/h/colorBright_css.h" +#include "ESPAsyncWebServer.h" #include "html/h/api_js.h" +#include "html/h/colorBright_css.h" +#include "html/h/colorDark_css.h" #include "html/h/favicon_ico.h" -#include "html/h/setup_html.h" -#include "html/h/visualization_html.h" -#include "html/h/update_html.h" +#include "html/h/index_html.h" +#include "html/h/login_html.h" #include "html/h/serial_html.h" +#include "html/h/setup_html.h" +#include "html/h/style_css.h" #include "html/h/system_html.h" +#include "html/h/update_html.h" +#include "html/h/visualization_html.h" #define WEB_SERIAL_BUF_SIZE 2048 -const char* const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinLed0", "pinLed1"}; +const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinLed0", "pinLed1"}; -template +template class Web { - public: - Web(void) : mWeb(80), mEvts("/events") { - mProtected = true; - mLogoutTimeout = 0; - - memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); - mSerialBufFill = 0; - mSerialAddTime = true; - mSerialClientConnnected = false; - } - - void setup(IApp *app, HMSYSTEM *sys, settings_t *config) { - mApp = app; - mSys = sys; - mConfig = config; - - DPRINTLN(DBG_VERBOSE, F("app::setup-on")); - mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1)); - mWeb.on("/login", HTTP_ANY, std::bind(&Web::onLogin, this, std::placeholders::_1)); - mWeb.on("/logout", HTTP_GET, std::bind(&Web::onLogout, this, std::placeholders::_1)); - mWeb.on("/colors.css", HTTP_GET, std::bind(&Web::onColor, this, std::placeholders::_1)); - mWeb.on("/style.css", HTTP_GET, std::bind(&Web::onCss, this, std::placeholders::_1)); - mWeb.on("/api.js", HTTP_GET, std::bind(&Web::onApiJs, this, std::placeholders::_1)); - mWeb.on("/favicon.ico", HTTP_GET, std::bind(&Web::onFavicon, this, std::placeholders::_1)); - mWeb.onNotFound ( std::bind(&Web::showNotFound, this, std::placeholders::_1)); - mWeb.on("/reboot", HTTP_ANY, std::bind(&Web::onReboot, this, std::placeholders::_1)); - mWeb.on("/system", HTTP_ANY, std::bind(&Web::onSystem, this, std::placeholders::_1)); - mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showErase, this, std::placeholders::_1)); - mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1)); - - mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1)); - mWeb.on("/save", HTTP_ANY, std::bind(&Web::showSave, this, std::placeholders::_1)); - - mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); - //mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); - - #ifdef ENABLE_JSON_EP - mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1)); - #endif - #ifdef ENABLE_PROMETHEUS_EP - mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); - #endif - - mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1)); - mWeb.on("/update", HTTP_POST, std::bind(&Web::showUpdate, this, std::placeholders::_1), - std::bind(&Web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); - mWeb.on("/upload", HTTP_POST, std::bind(&Web::onUpload, this, std::placeholders::_1), - std::bind(&Web::onUpload2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); - mWeb.on("/serial", HTTP_GET, std::bind(&Web::onSerial, this, std::placeholders::_1)); - mWeb.on("/debug", HTTP_GET, std::bind(&Web::onDebug, this, std::placeholders::_1)); - - - mEvts.onConnect(std::bind(&Web::onConnect, this, std::placeholders::_1)); - mWeb.addHandler(&mEvts); - - mWeb.begin(); - - registerDebugCb(std::bind(&Web::serialCb, this, std::placeholders::_1)); // dbg.h + public: + Web(void) : mWeb(80), mEvts("/events") { + mProtected = true; + mLogoutTimeout = 0; + + memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); + mSerialBufFill = 0; + mSerialAddTime = true; + mSerialClientConnnected = false; + } + + void setup(IApp *app, HMSYSTEM *sys, settings_t *config) { + mApp = app; + mSys = sys; + mConfig = config; + + DPRINTLN(DBG_VERBOSE, F("app::setup-on")); + mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1)); + mWeb.on("/login", HTTP_ANY, std::bind(&Web::onLogin, this, std::placeholders::_1)); + mWeb.on("/logout", HTTP_GET, std::bind(&Web::onLogout, this, std::placeholders::_1)); + mWeb.on("/colors.css", HTTP_GET, std::bind(&Web::onColor, this, std::placeholders::_1)); + mWeb.on("/style.css", HTTP_GET, std::bind(&Web::onCss, this, std::placeholders::_1)); + mWeb.on("/api.js", HTTP_GET, std::bind(&Web::onApiJs, this, std::placeholders::_1)); + mWeb.on("/favicon.ico", HTTP_GET, std::bind(&Web::onFavicon, this, std::placeholders::_1)); + mWeb.onNotFound(std::bind(&Web::showNotFound, this, std::placeholders::_1)); + mWeb.on("/reboot", HTTP_ANY, std::bind(&Web::onReboot, this, std::placeholders::_1)); + mWeb.on("/system", HTTP_ANY, std::bind(&Web::onSystem, this, std::placeholders::_1)); + mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showErase, this, std::placeholders::_1)); + mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1)); + + mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1)); + mWeb.on("/save", HTTP_ANY, std::bind(&Web::showSave, this, std::placeholders::_1)); + + mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); + // mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); - mUploadFail = false; - } +#ifdef ENABLE_JSON_EP + mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1)); +#endif +#ifdef ENABLE_PROMETHEUS_EP + mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); +#endif - void tickSecond() { - if(0 != mLogoutTimeout) { - mLogoutTimeout -= 1; - if(0 == mLogoutTimeout) { - if(strlen(mConfig->sys.adminPwd) > 0) - mProtected = true; - } + mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1)); + mWeb.on("/update", HTTP_POST, std::bind(&Web::showUpdate, this, std::placeholders::_1), + std::bind(&Web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); + mWeb.on("/upload", HTTP_POST, std::bind(&Web::onUpload, this, std::placeholders::_1), + std::bind(&Web::onUpload2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); + mWeb.on("/serial", HTTP_GET, std::bind(&Web::onSerial, this, std::placeholders::_1)); + mWeb.on("/debug", HTTP_GET, std::bind(&Web::onDebug, this, std::placeholders::_1)); - DPRINTLN(DBG_DEBUG, "auto logout in " + String(mLogoutTimeout)); - } + mEvts.onConnect(std::bind(&Web::onConnect, this, std::placeholders::_1)); + mWeb.addHandler(&mEvts); - if(mSerialClientConnnected) { - if(mSerialBufFill > 0) { - mEvts.send(mSerialBuf, "serial", millis()); - memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); - mSerialBufFill = 0; - } + mWeb.begin(); + + registerDebugCb(std::bind(&Web::serialCb, this, std::placeholders::_1)); // dbg.h + + mUploadFail = false; + } + + void tickSecond() { + if (0 != mLogoutTimeout) { + mLogoutTimeout -= 1; + if (0 == mLogoutTimeout) { + if (strlen(mConfig->sys.adminPwd) > 0) + mProtected = true; } - } - AsyncWebServer *getWebSrvPtr(void) { - return &mWeb; + DPRINTLN(DBG_DEBUG, "auto logout in " + String(mLogoutTimeout)); } - void setProtection(bool protect) { - mProtected = protect; + if (mSerialClientConnnected) { + if (mSerialBufFill > 0) { + mEvts.send(mSerialBuf, "serial", millis()); + memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); + mSerialBufFill = 0; + } } + } - bool getProtection() { - return mProtected; - } + AsyncWebServer *getWebSrvPtr(void) { + return &mWeb; + } - void showUpdate2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - mApp->setOnUpdate(); + void setProtection(bool protect) { + mProtected = protect; + } - if(!index) { - Serial.printf("Update Start: %s\n", filename.c_str()); - #ifndef ESP32 - Update.runAsync(true); - #endif - if(!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { - Update.printError(Serial); - } + bool getProtection() { + return mProtected; + } + + void showUpdate2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + mApp->setOnUpdate(); + + if (!index) { + Serial.printf("Update Start: %s\n", filename.c_str()); +#ifndef ESP32 + Update.runAsync(true); +#endif + if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { + Update.printError(Serial); } - if(!Update.hasError()) { - if(Update.write(data, len) != len){ - Update.printError(Serial); - } + } + if (!Update.hasError()) { + if (Update.write(data, len) != len) { + Update.printError(Serial); } - if(final) { - if(Update.end(true)) { - Serial.printf("Update Success: %uB\n", index+len); - } else { - Update.printError(Serial); - } + } + if (final) { + if (Update.end(true)) { + Serial.printf("Update Success: %uB\n", index + len); + } else { + Update.printError(Serial); } } + } - void onUpload2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - if(!index) { - mUploadFail = false; - mUploadFp = LittleFS.open("/tmp.json", "w"); - if(!mUploadFp) { - DPRINTLN(DBG_ERROR, F("can't open file!")); - mUploadFail = true; - mUploadFp.close(); - } - } - mUploadFp.write(data, len); - if(final) { + void onUpload2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + if (!index) { + mUploadFail = false; + mUploadFp = LittleFS.open("/tmp.json", "w"); + if (!mUploadFp) { + DPRINTLN(DBG_ERROR, F("can't open file!")); + mUploadFail = true; mUploadFp.close(); - File fp = LittleFS.open("/tmp.json", "r"); - if(!fp) + } + } + mUploadFp.write(data, len); + if (final) { + mUploadFp.close(); + File fp = LittleFS.open("/tmp.json", "r"); + if (!fp) + mUploadFail = true; + else { + if (!mApp->readSettings("tmp.json")) { mUploadFail = true; - else { - if(!mApp->readSettings("tmp.json")) { - mUploadFail = true; - DPRINTLN(DBG_ERROR, F("upload JSON error!")); - } - else - mApp->saveSettings(); - } - DPRINTLN(DBG_INFO, F("upload finished!")); + DPRINTLN(DBG_ERROR, F("upload JSON error!")); + } else + mApp->saveSettings(); } + DPRINTLN(DBG_INFO, F("upload finished!")); } + } - void serialCb(String msg) { - if(!mSerialClientConnnected) - return; + void serialCb(String msg) { + if (!mSerialClientConnnected) + return; - msg.replace("\r\n", ""); - if(mSerialAddTime) { - if((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { - if(mApp->getTimestamp() > 0) { - strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9); - mSerialBufFill += 9; - } - } - else { - mSerialBufFill = 0; - mEvts.send("webSerial, buffer overflow!", "serial", millis()); - return; + msg.replace("\r\n", ""); + if (mSerialAddTime) { + if ((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { + if (mApp->getTimestamp() > 0) { + strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9); + mSerialBufFill += 9; } - mSerialAddTime = false; - } - - if(msg.endsWith("")) - mSerialAddTime = true; - - uint16_t length = msg.length(); - if((length + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { - strncpy(&mSerialBuf[mSerialBufFill], msg.c_str(), length); - mSerialBufFill += length; - } - else { + } else { mSerialBufFill = 0; mEvts.send("webSerial, buffer overflow!", "serial", millis()); + return; } - } - - private: - void checkRedirect(AsyncWebServerRequest *request) { - if((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) - request->redirect(F("/index")); - else if((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) - request->redirect(F("/live")); - else if((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) - request->redirect(F("/serial")); - else if((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) - request->redirect(F("/system")); - else - request->redirect(F("/login")); - } - - void onUpdate(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onUpdate")); - - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) { - if(mProtected) { - checkRedirect(request); - return; - } + mSerialAddTime = false; + } + + if (msg.endsWith("")) + mSerialAddTime = true; + + uint16_t length = msg.length(); + if ((length + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { + strncpy(&mSerialBuf[mSerialBufFill], msg.c_str(), length); + mSerialBufFill += length; + } else { + mSerialBufFill = 0; + mEvts.send("webSerial, buffer overflow!", "serial", millis()); + } + } + + private: + void checkRedirect(AsyncWebServerRequest *request) { + if ((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) + request->redirect(F("/index")); + else if ((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) + request->redirect(F("/live")); + else if ((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) + request->redirect(F("/serial")); + else if ((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) + request->redirect(F("/system")); + else + request->redirect(F("/login")); + } + + void onUpdate(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onUpdate")); + + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) { + if (mProtected) { + checkRedirect(request); + return; } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); } - void showUpdate(AsyncWebServerRequest *request) { - bool reboot = !Update.hasError(); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } - String html = F("UpdateUpdate: "); - if(reboot) - html += "success"; - else - html += "failed"; - html += F("

rebooting ... auto reload after 20s"); + void showUpdate(AsyncWebServerRequest *request) { + bool reboot = !Update.hasError(); - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); - response->addHeader("Connection", "close"); - request->send(response); - mApp->setRebootFlag(); - } + String html = F("UpdateUpdate: "); + if (reboot) + html += "success"; + else + html += "failed"; + html += F("

rebooting ... auto reload after 20s"); - void onUpload(AsyncWebServerRequest *request) { - bool reboot = !mUploadFail; + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); + response->addHeader("Connection", "close"); + request->send(response); + mApp->setRebootFlag(); + } - String html = F("UploadUpload: "); - if(reboot) - html += "success"; - else - html += "failed"; - html += F("

rebooting ... auto reload after 20s"); + void onUpload(AsyncWebServerRequest *request) { + bool reboot = !mUploadFail; - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); - response->addHeader("Connection", "close"); - request->send(response); - mApp->setRebootFlag(); - } + String html = F("UploadUpload: "); + if (reboot) + html += "success"; + else + html += "failed"; + html += F("

rebooting ... auto reload after 20s"); - void onConnect(AsyncEventSourceClient *client) { - DPRINTLN(DBG_VERBOSE, "onConnect"); + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); + response->addHeader("Connection", "close"); + request->send(response); + mApp->setRebootFlag(); + } - mSerialClientConnnected = true; + void onConnect(AsyncEventSourceClient *client) { + DPRINTLN(DBG_VERBOSE, "onConnect"); - if(client->lastId()) - DPRINTLN(DBG_VERBOSE, "Client reconnected! Last message ID that it got is: " + String(client->lastId())); + mSerialClientConnnected = true; - client->send("hello!", NULL, millis(), 1000); - } + if (client->lastId()) + DPRINTLN(DBG_VERBOSE, "Client reconnected! Last message ID that it got is: " + String(client->lastId())); - void onIndex(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onIndex")); + client->send("hello!", NULL, millis(), 1000); + } - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) { - if(mProtected) { - checkRedirect(request); - return; - } - } + void onIndex(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onIndex")); - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onLogin(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLogin")); - - if(request->args() > 0) { - if(String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { - mProtected = false; - request->redirect("/"); - } - } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), login_html, login_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onLogout(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLogout")); - - if(mProtected) { + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) { + if (mProtected) { checkRedirect(request); return; } - - mProtected = true; - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onColor(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onColor")); - AsyncWebServerResponse *response; - if(mConfig->sys.darkMode) - response = request->beginResponse_P(200, F("text/css"), colorDark_css, colorDark_css_len); - else - response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); } - void onCss(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onCss")); - mLogoutTimeout = LOGOUT_TIMEOUT; - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onLogin(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLogin")); + + if (request->args() > 0) { + if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { + mProtected = false; + request->redirect("/"); + } + } + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), login_html, login_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onLogout(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLogout")); + + if (mProtected) { + checkRedirect(request); + return; + } + + mProtected = true; + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onColor(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onColor")); + AsyncWebServerResponse *response; + if (mConfig->sys.darkMode) + response = request->beginResponse_P(200, F("text/css"), colorDark_css, colorDark_css_len); + else + response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onCss(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onCss")); + mLogoutTimeout = LOGOUT_TIMEOUT; + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onApiJs(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onApiJs")); + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onFavicon(AsyncWebServerRequest *request) { + static const char favicon_type[] PROGMEM = "image/x-icon"; + AsyncWebServerResponse *response = request->beginResponse_P(200, favicon_type, favicon_ico, favicon_ico_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void showNotFound(AsyncWebServerRequest *request) { + if (mProtected) + checkRedirect(request); + else + request->redirect("/setup"); + } + + void onReboot(AsyncWebServerRequest *request) { + mApp->setRebootFlag(); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void showErase(AsyncWebServerRequest *request) { + if (mProtected) { + checkRedirect(request); + return; + } + + DPRINTLN(DBG_VERBOSE, F("showErase")); + mApp->eraseSettings(false); + onReboot(request); + } + + void showFactoryRst(AsyncWebServerRequest *request) { + if (mProtected) { + checkRedirect(request); + return; + } + + DPRINTLN(DBG_VERBOSE, F("showFactoryRst")); + String content = ""; + int refresh = 3; + if (request->args() > 0) { + if (request->arg("reset").toInt() == 1) { + refresh = 10; + if (mApp->eraseSettings(true)) + content = F("factory reset: success\n\nrebooting ... "); + else + content = F("factory reset: failed\n\nrebooting ... "); + } else { + content = F("factory reset: aborted"); + refresh = 3; + } + } else { + content = F( + "

Factory Reset

" + "

RESET

CANCEL

"); + refresh = 120; } - - void onApiJs(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onApiJs")); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); + request->send(200, F("text/html; charset=UTF-8"), F("Factory Reset") + content + F("")); + if (refresh == 10) { + delay(1000); + ESP.restart(); } + } - void onFavicon(AsyncWebServerRequest *request) { - static const char favicon_type[] PROGMEM = "image/x-icon"; - AsyncWebServerResponse *response = request->beginResponse_P(200, favicon_type, favicon_ico, favicon_ico_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } + void onSetup(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSetup")); - void showNotFound(AsyncWebServerRequest *request) { - if(mProtected) + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) { + if (mProtected) { checkRedirect(request); - else - request->redirect("/setup"); + return; + } } - void onReboot(AsyncWebServerRequest *request) { - mApp->setRebootFlag(); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void showSave(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("showSave")); + + if (mProtected) { + checkRedirect(request); + return; + } + + if (request->args() == 0) + return; + + char buf[20] = {0}; + + // general + if (request->arg("ssid") != "") + request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); + if (request->arg("pwd") != "{PWD}") + request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); + if (request->arg("device") != "") + request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN); + mConfig->sys.darkMode = (request->arg("darkMode") == "on"); + + // protection + if (request->arg("adminpwd") != "{PWD}") { + request->arg("adminpwd").toCharArray(mConfig->sys.adminPwd, PWD_LEN); + mProtected = (strlen(mConfig->sys.adminPwd) > 0); + } + mConfig->sys.protectionMask = 0x0000; + for (uint8_t i = 0; i < 6; i++) { + if (request->arg("protMask" + String(i)) == "on") + mConfig->sys.protectionMask |= (1 << i); + } + + // static ip + request->arg("ipAddr").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.ip, buf); + request->arg("ipMask").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.mask, buf); + request->arg("ipDns1").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.dns1, buf); + request->arg("ipDns2").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.dns2, buf); + request->arg("ipGateway").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.gateway, buf); + + // inverter + Inverter<> *iv; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i, false); + // enable communication + iv->config->enabled = (request->arg("inv" + String(i) + "Enable") == "on"); + // address + request->arg("inv" + String(i) + "Addr").toCharArray(buf, 20); + if (strlen(buf) == 0) + memset(buf, 0, 20); + iv->config->serial.u64 = ah::Serial2u64(buf); + switch (iv->config->serial.b[4]) { + case 0x21: + iv->type = INV_TYPE_1CH; + iv->channels = 1; + break; + case 0x41: + iv->type = INV_TYPE_2CH; + iv->channels = 2; + break; + case 0x61: + iv->type = INV_TYPE_4CH; + iv->channels = 4; + break; + default: + break; + } + + // name + request->arg("inv" + String(i) + "Name").toCharArray(iv->config->name, MAX_NAME_LENGTH); + + // max channel power / name + for (uint8_t j = 0; j < 4; j++) { + iv->config->yieldCor[j] = request->arg("inv" + String(i) + "YieldCor" + String(j)).toInt(); + iv->config->chMaxPwr[j] = request->arg("inv" + String(i) + "ModPwr" + String(j)).toInt() & 0xffff; + request->arg("inv" + String(i) + "ModName" + String(j)).toCharArray(iv->config->chName[j], MAX_NAME_LENGTH); + } + iv->initialized = true; + } + + if (request->arg("invInterval") != "") + mConfig->nrf.sendInterval = request->arg("invInterval").toInt(); + if (request->arg("invRetry") != "") + mConfig->nrf.maxRetransPerPyld = request->arg("invRetry").toInt(); + mConfig->inst.rstYieldMidNight = (request->arg("invRstMid") == "on"); + mConfig->inst.rstValsCommStop = (request->arg("invRstComStop") == "on"); + mConfig->inst.rstValsNotAvail = (request->arg("invRstNotAvail") == "on"); + + // pinout + uint8_t pin; + for (uint8_t i = 0; i < 5; i++) { + pin = request->arg(String(pinArgNames[i])).toInt(); + switch (i) { + default: + mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); + break; + case 1: + mConfig->nrf.pinCe = ((pin != 0xff) ? pin : DEF_CE_PIN); + break; + case 2: + mConfig->nrf.pinIrq = ((pin != 0xff) ? pin : DEF_IRQ_PIN); + break; + case 3: + mConfig->led.led0 = pin; + break; + case 4: + mConfig->led.led1 = pin; + break; + } + } + + // nrf24 amplifier power + mConfig->nrf.amplifierPower = request->arg("rf24Power").toInt() & 0x03; + + // ntp + if (request->arg("ntpAddr") != "") { + request->arg("ntpAddr").toCharArray(mConfig->ntp.addr, NTP_ADDR_LEN); + mConfig->ntp.port = request->arg("ntpPort").toInt() & 0xffff; + } + + // sun + if (request->arg("sunLat") == "" || (request->arg("sunLon") == "")) { + mConfig->sun.lat = 0.0; + mConfig->sun.lon = 0.0; + mConfig->sun.disNightCom = false; + mConfig->sun.offsetSec = 0; + } else { + mConfig->sun.lat = request->arg("sunLat").toFloat(); + mConfig->sun.lon = request->arg("sunLon").toFloat(); + mConfig->sun.disNightCom = (request->arg("sunDisNightCom") == "on"); + mConfig->sun.offsetSec = request->arg("sunOffs").toInt() * 60; + } + + // mqtt + if (request->arg("mqttAddr") != "") { + String addr = request->arg("mqttAddr"); + addr.trim(); + addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN); + } else + mConfig->mqtt.broker[0] = '\0'; + request->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN); + if (request->arg("mqttPwd") != "{PWD}") + request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN); + request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); + mConfig->mqtt.port = request->arg("mqttPort").toInt(); + mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); + + // serial console + if (request->arg("serIntvl") != "") { + mConfig->serial.interval = request->arg("serIntvl").toInt() & 0xffff; + + mConfig->serial.debug = (request->arg("serDbg") == "on"); + mConfig->serial.showIv = (request->arg("serEn") == "on"); + // Needed to log TX buffers to serial console + mSys->Radio.mSerialDebug = mConfig->serial.debug; + } + + // display + mConfig->plugin.display.pwrSaveAtIvOffline = (request->arg("dispPwr") == "on"); + mConfig->plugin.display.logoEn = (request->arg("logoEn") == "on"); + mConfig->plugin.display.pxShift = (request->arg("dispPxSh") == "on"); + mConfig->plugin.display.rot = request->arg("rotation").toInt(); + mConfig->plugin.display.type = request->arg("dispType").toInt(); + mConfig->plugin.display.contrast = request->arg("dispCont").toInt(); + + mConfig->plugin.display.disp_data = request->arg("data").toInt(); + mConfig->plugin.display.disp_clk = request->arg("clock").toInt(); + mConfig->plugin.display.disp_cs = request->arg("cs").toInt(); + mConfig->plugin.display.disp_reset = request->arg("reset").toInt(); + mConfig->plugin.display.disp_busy = request->arg("busy").toInt(); + mConfig->plugin.display.disp_dc = request->arg("dc").toInt(); + + mApp->saveSettings(); + + if (request->arg("reboot") == "on") + onReboot(request); + else { AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); response->addHeader(F("Content-Encoding"), "gzip"); request->send(response); } + } - void showErase(AsyncWebServerRequest *request) { - if(mProtected) { - checkRedirect(request); - return; - } - - DPRINTLN(DBG_VERBOSE, F("showErase")); - mApp->eraseSettings(false); - onReboot(request); - } + void onLive(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLive")); - void showFactoryRst(AsyncWebServerRequest *request) { - if(mProtected) { + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) { + if (mProtected) { checkRedirect(request); return; } - - DPRINTLN(DBG_VERBOSE, F("showFactoryRst")); - String content = ""; - int refresh = 3; - if(request->args() > 0) { - if(request->arg("reset").toInt() == 1) { - refresh = 10; - if(mApp->eraseSettings(true)) - content = F("factory reset: success\n\nrebooting ... "); - else - content = F("factory reset: failed\n\nrebooting ... "); - } - else { - content = F("factory reset: aborted"); - refresh = 3; - } - } - else { - content = F("

Factory Reset

" - "

RESET

CANCEL

"); - refresh = 120; - } - request->send(200, F("text/html; charset=UTF-8"), F("Factory Reset") + content + F("")); - if(refresh == 10) { - delay(1000); - ESP.restart(); - } } - void onSetup(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSetup")); - - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) { - if(mProtected) { - checkRedirect(request); - return; + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + response->addHeader(F("content-type"), "text/html; charset=UTF-8"); + + request->send(response); + } + + /*void showWebApi(AsyncWebServerRequest *request) { + // TODO: remove + DPRINTLN(DBG_VERBOSE, F("web::showWebApi")); + DPRINTLN(DBG_DEBUG, request->arg("plain")); + const size_t capacity = 200; // Use arduinojson.org/assistant to compute the capacity. + DynamicJsonDocument response(capacity); + + // Parse JSON object + deserializeJson(response, request->arg("plain")); + // ToDo: error handling for payload + uint8_t iv_id = response["inverter"]; + uint8_t cmd = response["cmd"]; + Inverter<> *iv = mSys->getInverterByPos(iv_id); + if (NULL != iv) { + if (response["tx_request"] == (uint8_t)TX_REQ_INFO) { + // if the AlarmData is requested set the Alarm Index to the requested one + if (cmd == AlarmData || cmd == AlarmUpdate) { + // set the AlarmMesIndex for the request from user input + iv->alarmMesIndex = response["payload"]; } - } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void showSave(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("showSave")); - - if(mProtected) { - checkRedirect(request); - return; - } - - if(request->args() == 0) - return; - - char buf[20] = {0}; - - // general - if(request->arg("ssid") != "") - request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); - if(request->arg("pwd") != "{PWD}") - request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); - if(request->arg("device") != "") - request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN); - mConfig->sys.darkMode = (request->arg("darkMode") == "on"); - - // protection - if(request->arg("adminpwd") != "{PWD}") { - request->arg("adminpwd").toCharArray(mConfig->sys.adminPwd, PWD_LEN); - mProtected = (strlen(mConfig->sys.adminPwd) > 0); - } - mConfig->sys.protectionMask = 0x0000; - for(uint8_t i = 0; i < 6; i++) { - if(request->arg("protMask" + String(i)) == "on") - mConfig->sys.protectionMask |= (1 << i); - } - - // static ip - request->arg("ipAddr").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.ip, buf); - request->arg("ipMask").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.mask, buf); - request->arg("ipDns1").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.dns1, buf); - request->arg("ipDns2").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.dns2, buf); - request->arg("ipGateway").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.gateway, buf); - - - // inverter - Inverter<> *iv; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i, false); - // enable communication - iv->config->enabled = (request->arg("inv" + String(i) + "Enable") == "on"); - // address - request->arg("inv" + String(i) + "Addr").toCharArray(buf, 20); - if(strlen(buf) == 0) - memset(buf, 0, 20); - iv->config->serial.u64 = ah::Serial2u64(buf); - switch(iv->config->serial.b[4]) { - case 0x21: iv->type = INV_TYPE_1CH; iv->channels = 1; break; - case 0x41: iv->type = INV_TYPE_2CH; iv->channels = 2; break; - case 0x61: iv->type = INV_TYPE_4CH; iv->channels = 4; break; - default: break; + DPRINTLN(DBG_INFO, F("Will make tx-request 0x15 with subcmd ") + String(cmd) + F(" and payload ") + String((uint16_t) response["payload"])); + // process payload from web request corresponding to the cmd + iv->enqueCommand(cmd); + } + + + if (response["tx_request"] == (uint8_t)TX_REQ_DEVCONTROL) { + if (response["cmd"] == (uint8_t)ActivePowerContr) { + uint16_t webapiPayload = response["payload"]; + uint16_t webapiPayload2 = response["payload2"]; + if (webapiPayload > 0 && webapiPayload < 10000) { + iv->devControlCmd = ActivePowerContr; + iv->powerLimit[0] = webapiPayload; + if (webapiPayload2 > 0) + iv->powerLimit[1] = webapiPayload2; // dev option, no sanity check + else // if not set, set it to 0x0000 default + iv->powerLimit[1] = AbsolutNonPersistent; // payload will be seted temporary in Watt absolut + if (iv->powerLimit[1] & 0x0001) + DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("% via REST API")); + else + DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W via REST API")); + iv->devControlRequest = true; // queue it in the request loop + } } - - // name - request->arg("inv" + String(i) + "Name").toCharArray(iv->config->name, MAX_NAME_LENGTH); - - // max channel power / name - for(uint8_t j = 0; j < 4; j++) { - iv->config->yieldCor[j] = request->arg("inv" + String(i) + "YieldCor" + String(j)).toInt(); - iv->config->chMaxPwr[j] = request->arg("inv" + String(i) + "ModPwr" + String(j)).toInt() & 0xffff; - request->arg("inv" + String(i) + "ModName" + String(j)).toCharArray(iv->config->chName[j], MAX_NAME_LENGTH); + if (response["cmd"] == (uint8_t)TurnOff) { + iv->devControlCmd = TurnOff; + iv->devControlRequest = true; // queue it in the request loop } - iv->initialized = true; - } - - if(request->arg("invInterval") != "") - mConfig->nrf.sendInterval = request->arg("invInterval").toInt(); - if(request->arg("invRetry") != "") - mConfig->nrf.maxRetransPerPyld = request->arg("invRetry").toInt(); - mConfig->inst.rstYieldMidNight = (request->arg("invRstMid") == "on"); - mConfig->inst.rstValsCommStop = (request->arg("invRstComStop") == "on"); - mConfig->inst.rstValsNotAvail = (request->arg("invRstNotAvail") == "on"); - - // pinout - uint8_t pin; - for(uint8_t i = 0; i < 5; i ++) { - pin = request->arg(String(pinArgNames[i])).toInt(); - switch(i) { - default: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); break; - case 1: mConfig->nrf.pinCe = ((pin != 0xff) ? pin : DEF_CE_PIN); break; - case 2: mConfig->nrf.pinIrq = ((pin != 0xff) ? pin : DEF_IRQ_PIN); break; - case 3: mConfig->led.led0 = pin; break; - case 4: mConfig->led.led1 = pin; break; + if (response["cmd"] == (uint8_t)TurnOn) { + iv->devControlCmd = TurnOn; + iv->devControlRequest = true; // queue it in the request loop } - } - - // nrf24 amplifier power - mConfig->nrf.amplifierPower = request->arg("rf24Power").toInt() & 0x03; - - // ntp - if(request->arg("ntpAddr") != "") { - request->arg("ntpAddr").toCharArray(mConfig->ntp.addr, NTP_ADDR_LEN); - mConfig->ntp.port = request->arg("ntpPort").toInt() & 0xffff; - } - - // sun - if(request->arg("sunLat") == "" || (request->arg("sunLon") == "")) { - mConfig->sun.lat = 0.0; - mConfig->sun.lon = 0.0; - mConfig->sun.disNightCom = false; - mConfig->sun.offsetSec = 0; - } else { - mConfig->sun.lat = request->arg("sunLat").toFloat(); - mConfig->sun.lon = request->arg("sunLon").toFloat(); - mConfig->sun.disNightCom = (request->arg("sunDisNightCom") == "on"); - mConfig->sun.offsetSec = request->arg("sunOffs").toInt() * 60; - } - - // mqtt - if(request->arg("mqttAddr") != "") { - String addr = request->arg("mqttAddr"); - addr.trim(); - addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN); - } - else - mConfig->mqtt.broker[0] = '\0'; - request->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN); - if(request->arg("mqttPwd") != "{PWD}") - request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN); - request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); - mConfig->mqtt.port = request->arg("mqttPort").toInt(); - mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); - - // serial console - if(request->arg("serIntvl") != "") { - mConfig->serial.interval = request->arg("serIntvl").toInt() & 0xffff; - - mConfig->serial.debug = (request->arg("serDbg") == "on"); - mConfig->serial.showIv = (request->arg("serEn") == "on"); - // Needed to log TX buffers to serial console - mSys->Radio.mSerialDebug = mConfig->serial.debug; - } - - // display - mConfig->plugin.display.pwrSaveAtIvOffline = (request->arg("dispPwr") == "on"); - mConfig->plugin.display.logoEn = (request->arg("logoEn") == "on"); - mConfig->plugin.display.pxShift = (request->arg("dispPxSh") == "on"); - mConfig->plugin.display.rot180 = (request->arg("disp180") == "on"); - mConfig->plugin.display.type = request->arg("dispType").toInt(); - mConfig->plugin.display.contrast = request->arg("dispCont").toInt(); - mConfig->plugin.display.pin0 = request->arg("pinDisp0").toInt(); - mConfig->plugin.display.pin1 = request->arg("pinDisp1").toInt(); - - - mApp->saveSettings(); - - if(request->arg("reboot") == "on") - onReboot(request); - else { - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - } - - void onLive(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLive")); - - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) { - if(mProtected) { - checkRedirect(request); - return; + if (response["cmd"] == (uint8_t)CleanState_LockAndAlarm) { + iv->devControlCmd = CleanState_LockAndAlarm; + iv->devControlRequest = true; // queue it in the request loop + } + if (response["cmd"] == (uint8_t)Restart) { + iv->devControlCmd = Restart; + iv->devControlRequest = true; // queue it in the request loop } } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - response->addHeader(F("content-type"), "text/html; charset=UTF-8"); - - request->send(response); } + request->send(200, "text/json", "{success:true}"); + }*/ - /*void showWebApi(AsyncWebServerRequest *request) { - // TODO: remove - DPRINTLN(DBG_VERBOSE, F("web::showWebApi")); - DPRINTLN(DBG_DEBUG, request->arg("plain")); - const size_t capacity = 200; // Use arduinojson.org/assistant to compute the capacity. - DynamicJsonDocument response(capacity); - - // Parse JSON object - deserializeJson(response, request->arg("plain")); - // ToDo: error handling for payload - uint8_t iv_id = response["inverter"]; - uint8_t cmd = response["cmd"]; - Inverter<> *iv = mSys->getInverterByPos(iv_id); - if (NULL != iv) { - if (response["tx_request"] == (uint8_t)TX_REQ_INFO) { - // if the AlarmData is requested set the Alarm Index to the requested one - if (cmd == AlarmData || cmd == AlarmUpdate) { - // set the AlarmMesIndex for the request from user input - iv->alarmMesIndex = response["payload"]; - } - DPRINTLN(DBG_INFO, F("Will make tx-request 0x15 with subcmd ") + String(cmd) + F(" and payload ") + String((uint16_t) response["payload"])); - // process payload from web request corresponding to the cmd - iv->enqueCommand(cmd); - } + void onDebug(AsyncWebServerRequest *request) { + mApp->getSchedulerNames(); + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), "ok"); + request->send(response); + } + void onSerial(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSerial")); - if (response["tx_request"] == (uint8_t)TX_REQ_DEVCONTROL) { - if (response["cmd"] == (uint8_t)ActivePowerContr) { - uint16_t webapiPayload = response["payload"]; - uint16_t webapiPayload2 = response["payload2"]; - if (webapiPayload > 0 && webapiPayload < 10000) { - iv->devControlCmd = ActivePowerContr; - iv->powerLimit[0] = webapiPayload; - if (webapiPayload2 > 0) - iv->powerLimit[1] = webapiPayload2; // dev option, no sanity check - else // if not set, set it to 0x0000 default - iv->powerLimit[1] = AbsolutNonPersistent; // payload will be seted temporary in Watt absolut - if (iv->powerLimit[1] & 0x0001) - DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("% via REST API")); - else - DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W via REST API")); - iv->devControlRequest = true; // queue it in the request loop - } - } - if (response["cmd"] == (uint8_t)TurnOff) { - iv->devControlCmd = TurnOff; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)TurnOn) { - iv->devControlCmd = TurnOn; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)CleanState_LockAndAlarm) { - iv->devControlCmd = CleanState_LockAndAlarm; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)Restart) { - iv->devControlCmd = Restart; - iv->devControlRequest = true; // queue it in the request loop - } - } + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) { + if (mProtected) { + checkRedirect(request); + return; } - request->send(200, "text/json", "{success:true}"); - }*/ - - void onDebug(AsyncWebServerRequest *request) { - mApp->getSchedulerNames(); - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), "ok"); - request->send(response); } - void onSerial(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSerial")); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) { - if(mProtected) { - checkRedirect(request); - return; - } - } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onSystem(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSystem")); + void onSystem(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSystem")); - if(CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) { - if(mProtected) { - checkRedirect(request); - return; - } + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) { + if (mProtected) { + checkRedirect(request); + return; } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); } -#ifdef ENABLE_JSON_EP - void showJson(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("web::showJson")); - String modJson; - Inverter<> *iv; - record_t<> *rec; - char topic[40], val[25]; - - modJson = F("{\n"); - for(uint8_t id = 0; id < mSys->getNumInverters(); id++) { - iv = mSys->getInverterByPos(id); - if(NULL == iv) - continue; - - rec = iv->getRecordStruct(RealTimeRunData_Debug); - snprintf(topic, 30, "\"%s\": {\n", iv->config->name); - modJson += String(topic); - for(uint8_t i = 0; i < rec->length; i++) { - snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec)); - snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec)); - modJson += String(topic) + ": " + String(val) + F(",\n"); - } - modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n"); - } - modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n"); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } - AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson); - request->send(response); - } +#ifdef ENABLE_JSON_EP + void showJson(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("web::showJson")); + String modJson; + Inverter<> *iv; + record_t<> *rec; + char topic[40], val[25]; + + modJson = F("{\n"); + for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { + iv = mSys->getInverterByPos(id); + if (NULL == iv) + continue; + + rec = iv->getRecordStruct(RealTimeRunData_Debug); + snprintf(topic, 30, "\"%s\": {\n", iv->config->name); + modJson += String(topic); + for (uint8_t i = 0; i < rec->length; i++) { + snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec)); + snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec)); + modJson += String(topic) + ": " + String(val) + F(",\n"); + } + modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n"); + } + modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n"); + + AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson); + request->send(response); + } #endif #ifdef ENABLE_PROMETHEUS_EP - enum { - metricsStateStart, metricsStateInverter, metricStateRealtimeData,metricsStateAlarmData,metricsStateEnd - } metricsStep; - int metricsInverterId,metricsChannelId; - - void showMetrics(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("web::showMetrics")); - - metricsStep = metricsStateStart; - AsyncWebServerResponse *response = request->beginChunkedResponse(F("text/plain"), - [this](uint8_t *buffer, size_t maxLen, size_t filledLength) -> size_t - { - Inverter<> *iv; - record_t<> *rec; - statistics_t *stat; - String promUnit, promType; - String metrics; - char type[60], topic[100], val[25]; - size_t len = 0; - int alarmChannelId; - - switch (metricsStep) { - case metricsStateStart: // System Info & NRF Statistics : fit to one packet - snprintf(type,sizeof(type),"# TYPE ahoy_solar_info gauge\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_info{version=\"%s\",image=\"\",devicename=\"%s\"} 1\n", - mApp->getVersion(), mConfig->sys.deviceName); - metrics = String(type) + String(topic); - - snprintf(topic,sizeof(topic),"# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap()); - metrics += String(topic); - - // NRF Statistics - stat = mApp->getStatistics(); - metrics += radioStatistic(F("rx_success"), stat->rxSuccess); - metrics += radioStatistic(F("rx_fail"), stat->rxFail); - metrics += radioStatistic(F("rx_fail_answer"), stat->rxFailNoAnser); - metrics += radioStatistic(F("frame_cnt"), stat->frmCnt); - metrics += radioStatistic(F("tx_cnt"), mSys->Radio.mSendCnt); - - len = snprintf((char *)buffer,maxLen,"%s",metrics.c_str()); - // Start Inverter loop - metricsInverterId = 0; - metricsStep = metricsStateInverter; - break; - - case metricsStateInverter: // Inverter loop - if (metricsInverterId < mSys->getNumInverters()) { - iv = mSys->getInverterByPos(metricsInverterId); - if(NULL != iv) { - // Inverter info : fit to one packet - snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_info gauge\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_inverter_info{name=\"%s\",serial=\"%12llx\"} 1\n", - iv->config->name, iv->config->serial.u64); - metrics = String(type) + String(topic); - - snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_enabled gauge\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_enabled {inverter=\"%s\"} %d\n",iv->config->name,iv->config->enabled); - metrics += String(type) + String(topic); - - snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_available gauge\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_available {inverter=\"%s\"} %d\n",iv->config->name,iv->isAvailable(mApp->getTimestamp())); - metrics += String(type) + String(topic); - - snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_producing gauge\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_producing {inverter=\"%s\"} %d\n",iv->config->name,iv->isProducing(mApp->getTimestamp())); - metrics += String(type) + String(topic); - - len = snprintf((char *)buffer,maxLen,"%s",metrics.c_str()); - - // Start Realtime Data Channel loop for this inverter - metricsChannelId = 0; - metricsStep = metricStateRealtimeData; - } - } else { - metricsStep = metricsStateEnd; - } - break; - - case metricStateRealtimeData: // Realtime Data Channel loop - iv = mSys->getInverterByPos(metricsInverterId); - rec = iv->getRecordStruct(RealTimeRunData_Debug); - if (metricsChannelId < rec->length) { - uint8_t channel = rec->assign[metricsChannelId].ch; - std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(metricsChannelId, rec)); - snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), promType.c_str()); - if (0 == channel) { - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name); - } else { - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\",channel=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name,iv->config->chName[channel-1]); - } - snprintf(val, sizeof(val), "%.3f", iv->getValue(metricsChannelId, rec)); - len = snprintf((char*)buffer,maxLen,"%s\n%s %s\n",type,topic,val); - - metricsChannelId++; - } else { - len = snprintf((char*)buffer,maxLen,"#\n"); // At least one char to send otherwise the transmission ends. - - // All realtime data channels processed --> try alarm data - metricsStep = metricsStateAlarmData; - } - break; - - case metricsStateAlarmData: // Alarm Info loop - iv = mSys->getInverterByPos(metricsInverterId); - rec = iv->getRecordStruct(AlarmData); - // simple hack : there is only one channel with alarm data - // TODO: find the right one channel with the alarm id - alarmChannelId = 0; - // printf("AlarmData Length %d\n",rec->length); - if (alarmChannelId < rec->length) - { - //uint8_t channel = rec->assign[alarmChannelId].ch; - std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(alarmChannelId, rec)); - snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), promType.c_str()); - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), iv->config->name); - snprintf(val, sizeof(val), "%.3f", iv->getValue(alarmChannelId, rec)); - len = snprintf((char*)buffer,maxLen,"%s\n%s %s\n",type,topic,val); - } else { - len = snprintf((char*)buffer,maxLen,"#\n"); // At least one char to send otherwise the transmission ends. - } - // alarm channel processed --> try next inverter - metricsInverterId++; - metricsStep = metricsStateInverter; - break; - - case metricsStateEnd: - default: // end of transmission - len = 0; - break; - } - return len; - }); - request->send(response); - } - - String radioStatistic(String statistic, uint32_t value) { - char type[60], topic[80], val[25]; - snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge",statistic.c_str()); - snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s",statistic.c_str()); - snprintf(val, sizeof(val), "%d", value); - return ( String(type) + "\n" + String(topic) + " " + String(val) + "\n"); - } - - std::pair convertToPromUnits(String shortUnit) { - if(shortUnit == "A") return {"_ampere", "gauge"}; - if(shortUnit == "V") return {"_volt", "gauge"}; - if(shortUnit == "%") return {"_ratio", "gauge"}; - if(shortUnit == "W") return {"_watt", "gauge"}; - if(shortUnit == "Wh") return {"_wattHours", "counter"}; - if(shortUnit == "kWh") return {"_kilowattHours", "counter"}; - if(shortUnit == "°C") return {"_celsius", "gauge"}; - if(shortUnit == "var") return {"_var", "gauge"}; - if(shortUnit == "Hz") return {"_hertz", "gauge"}; - return {"", "gauge"}; - } + enum { + metricsStateStart, + metricsStateInverter, + metricStateRealtimeData, + metricsStateAlarmData, + metricsStateEnd + } metricsStep; + int metricsInverterId, metricsChannelId; + + void showMetrics(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("web::showMetrics")); + + metricsStep = metricsStateStart; + AsyncWebServerResponse *response = request->beginChunkedResponse(F("text/plain"), + [this](uint8_t *buffer, size_t maxLen, size_t filledLength) -> size_t { + Inverter<> *iv; + record_t<> *rec; + statistics_t *stat; + String promUnit, promType; + String metrics; + char type[60], topic[100], val[25]; + size_t len = 0; + int alarmChannelId; + + switch (metricsStep) { + case metricsStateStart: // System Info & NRF Statistics : fit to one packet + snprintf(type, sizeof(type), "# TYPE ahoy_solar_info gauge\n"); + snprintf(topic, sizeof(topic), "ahoy_solar_info{version=\"%s\",image=\"\",devicename=\"%s\"} 1\n", + mApp->getVersion(), mConfig->sys.deviceName); + metrics = String(type) + String(topic); + + snprintf(topic, sizeof(topic), "# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n", mConfig->sys.deviceName, ESP.getFreeHeap()); + metrics += String(topic); + + // NRF Statistics + stat = mApp->getStatistics(); + metrics += radioStatistic(F("rx_success"), stat->rxSuccess); + metrics += radioStatistic(F("rx_fail"), stat->rxFail); + metrics += radioStatistic(F("rx_fail_answer"), stat->rxFailNoAnser); + metrics += radioStatistic(F("frame_cnt"), stat->frmCnt); + metrics += radioStatistic(F("tx_cnt"), mSys->Radio.mSendCnt); + + len = snprintf((char *)buffer, maxLen, "%s", metrics.c_str()); + // Start Inverter loop + metricsInverterId = 0; + metricsStep = metricsStateInverter; + break; + + case metricsStateInverter: // Inverter loop + if (metricsInverterId < mSys->getNumInverters()) { + iv = mSys->getInverterByPos(metricsInverterId); + if (NULL != iv) { + // Inverter info : fit to one packet + snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_info gauge\n"); + snprintf(topic, sizeof(topic), "ahoy_solar_inverter_info{name=\"%s\",serial=\"%12llx\"} 1\n", + iv->config->name, iv->config->serial.u64); + metrics = String(type) + String(topic); + + snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_enabled gauge\n"); + snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_enabled {inverter=\"%s\"} %d\n", iv->config->name, iv->config->enabled); + metrics += String(type) + String(topic); + + snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_available gauge\n"); + snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_available {inverter=\"%s\"} %d\n", iv->config->name, iv->isAvailable(mApp->getTimestamp())); + metrics += String(type) + String(topic); + + snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_producing gauge\n"); + snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_producing {inverter=\"%s\"} %d\n", iv->config->name, iv->isProducing(mApp->getTimestamp())); + metrics += String(type) + String(topic); + + len = snprintf((char *)buffer, maxLen, "%s", metrics.c_str()); + + // Start Realtime Data Channel loop for this inverter + metricsChannelId = 0; + metricsStep = metricStateRealtimeData; + } + } else { + metricsStep = metricsStateEnd; + } + break; + + case metricStateRealtimeData: // Realtime Data Channel loop + iv = mSys->getInverterByPos(metricsInverterId); + rec = iv->getRecordStruct(RealTimeRunData_Debug); + if (metricsChannelId < rec->length) { + uint8_t channel = rec->assign[metricsChannelId].ch; + std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(metricsChannelId, rec)); + snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), promType.c_str()); + if (0 == channel) { + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name); + } else { + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\",channel=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name, iv->config->chName[channel - 1]); + } + snprintf(val, sizeof(val), "%.3f", iv->getValue(metricsChannelId, rec)); + len = snprintf((char *)buffer, maxLen, "%s\n%s %s\n", type, topic, val); + + metricsChannelId++; + } else { + len = snprintf((char *)buffer, maxLen, "#\n"); // At least one char to send otherwise the transmission ends. + + // All realtime data channels processed --> try alarm data + metricsStep = metricsStateAlarmData; + } + break; + + case metricsStateAlarmData: // Alarm Info loop + iv = mSys->getInverterByPos(metricsInverterId); + rec = iv->getRecordStruct(AlarmData); + // simple hack : there is only one channel with alarm data + // TODO: find the right one channel with the alarm id + alarmChannelId = 0; + // printf("AlarmData Length %d\n",rec->length); + if (alarmChannelId < rec->length) { + // uint8_t channel = rec->assign[alarmChannelId].ch; + std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(alarmChannelId, rec)); + snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), promType.c_str()); + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), iv->config->name); + snprintf(val, sizeof(val), "%.3f", iv->getValue(alarmChannelId, rec)); + len = snprintf((char *)buffer, maxLen, "%s\n%s %s\n", type, topic, val); + } else { + len = snprintf((char *)buffer, maxLen, "#\n"); // At least one char to send otherwise the transmission ends. + } + // alarm channel processed --> try next inverter + metricsInverterId++; + metricsStep = metricsStateInverter; + break; + + case metricsStateEnd: + default: // end of transmission + len = 0; + break; + } + return len; + }); + request->send(response); + } + + String radioStatistic(String statistic, uint32_t value) { + char type[60], topic[80], val[25]; + snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge", statistic.c_str()); + snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s", statistic.c_str()); + snprintf(val, sizeof(val), "%d", value); + return (String(type) + "\n" + String(topic) + " " + String(val) + "\n"); + } + + std::pair convertToPromUnits(String shortUnit) { + if (shortUnit == "A") return {"_ampere", "gauge"}; + if (shortUnit == "V") return {"_volt", "gauge"}; + if (shortUnit == "%") return {"_ratio", "gauge"}; + if (shortUnit == "W") return {"_watt", "gauge"}; + if (shortUnit == "Wh") return {"_wattHours", "counter"}; + if (shortUnit == "kWh") return {"_kilowattHours", "counter"}; + if (shortUnit == "°C") return {"_celsius", "gauge"}; + if (shortUnit == "var") return {"_var", "gauge"}; + if (shortUnit == "Hz") return {"_hertz", "gauge"}; + return {"", "gauge"}; + } #endif - AsyncWebServer mWeb; - AsyncEventSource mEvts; - bool mProtected; - uint32_t mLogoutTimeout; - IApp *mApp; - HMSYSTEM *mSys; - - settings_t *mConfig; - - bool mSerialAddTime; - char mSerialBuf[WEB_SERIAL_BUF_SIZE]; - uint16_t mSerialBufFill; - bool mSerialClientConnnected; - - File mUploadFp; - bool mUploadFail; + AsyncWebServer mWeb; + AsyncEventSource mEvts; + bool mProtected; + uint32_t mLogoutTimeout; + IApp *mApp; + HMSYSTEM *mSys; + + settings_t *mConfig; + + bool mSerialAddTime; + char mSerialBuf[WEB_SERIAL_BUF_SIZE]; + uint16_t mSerialBufFill; + bool mSerialClientConnnected; + + File mUploadFp; + bool mUploadFail; }; #endif /*__WEB_H__*/ From 3a2e2fa28666a9dd4d22165bca375770f4787e05 Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 03:30:34 +0100 Subject: [PATCH 03/26] Ordner MonochromeDisplay auf Display umbenannt --- src/app.h | 2 +- src/plugins/{MonochromeDisplay => Display}/Display_Mono.cpp | 0 src/plugins/{MonochromeDisplay => Display}/Display_Mono.h | 0 src/plugins/{MonochromeDisplay => Display}/Display_ePaper.cpp | 0 src/plugins/{MonochromeDisplay => Display}/Display_ePaper.h | 0 src/plugins/{MonochromeDisplay => Display}/MonochromeDisplay.h | 0 src/plugins/{MonochromeDisplay => Display}/imagedata.cpp | 0 src/plugins/{MonochromeDisplay => Display}/imagedata.h | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename src/plugins/{MonochromeDisplay => Display}/Display_Mono.cpp (100%) rename src/plugins/{MonochromeDisplay => Display}/Display_Mono.h (100%) rename src/plugins/{MonochromeDisplay => Display}/Display_ePaper.cpp (100%) rename src/plugins/{MonochromeDisplay => Display}/Display_ePaper.h (100%) rename src/plugins/{MonochromeDisplay => Display}/MonochromeDisplay.h (100%) rename src/plugins/{MonochromeDisplay => Display}/imagedata.cpp (100%) rename src/plugins/{MonochromeDisplay => Display}/imagedata.h (100%) diff --git a/src/app.h b/src/app.h index 68281492..e55fe85a 100644 --- a/src/app.h +++ b/src/app.h @@ -46,7 +46,7 @@ typedef PubMqtt PubMqttType; typedef PubSerial PubSerialType; // PLUGINS -#include "plugins/MonochromeDisplay/MonochromeDisplay.h" +#include "plugins/Display/MonochromeDisplay.h" typedef MonochromeDisplay MonoDisplayType; diff --git a/src/plugins/MonochromeDisplay/Display_Mono.cpp b/src/plugins/Display/Display_Mono.cpp similarity index 100% rename from src/plugins/MonochromeDisplay/Display_Mono.cpp rename to src/plugins/Display/Display_Mono.cpp diff --git a/src/plugins/MonochromeDisplay/Display_Mono.h b/src/plugins/Display/Display_Mono.h similarity index 100% rename from src/plugins/MonochromeDisplay/Display_Mono.h rename to src/plugins/Display/Display_Mono.h diff --git a/src/plugins/MonochromeDisplay/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp similarity index 100% rename from src/plugins/MonochromeDisplay/Display_ePaper.cpp rename to src/plugins/Display/Display_ePaper.cpp diff --git a/src/plugins/MonochromeDisplay/Display_ePaper.h b/src/plugins/Display/Display_ePaper.h similarity index 100% rename from src/plugins/MonochromeDisplay/Display_ePaper.h rename to src/plugins/Display/Display_ePaper.h diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/Display/MonochromeDisplay.h similarity index 100% rename from src/plugins/MonochromeDisplay/MonochromeDisplay.h rename to src/plugins/Display/MonochromeDisplay.h diff --git a/src/plugins/MonochromeDisplay/imagedata.cpp b/src/plugins/Display/imagedata.cpp similarity index 100% rename from src/plugins/MonochromeDisplay/imagedata.cpp rename to src/plugins/Display/imagedata.cpp diff --git a/src/plugins/MonochromeDisplay/imagedata.h b/src/plugins/Display/imagedata.h similarity index 100% rename from src/plugins/MonochromeDisplay/imagedata.h rename to src/plugins/Display/imagedata.h From 7add54bf2bac79151632bb9aca22f914a9eed067 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 10:50:19 +0100 Subject: [PATCH 04/26] MI - request missing parts seems to basically work --- src/hm/hmInverter.h | 30 ++++- src/hm/miPayload.h | 314 ++++++++++++++++++++++++++------------------ 2 files changed, 210 insertions(+), 134 deletions(-) diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index c764cee0..f150628a 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -90,6 +90,13 @@ class InfoCommand : public CommandAbstract { } }; +class MiInfoCommand : public CommandAbstract { + public: + MiInfoCommand(uint8_t cmd){ + _TxType = cmd; + _Cmd = cmd; + } +}; // list of all available functions, mapped in hmDefines.h template const calcFunc_t calcFunctions[] = { @@ -163,9 +170,26 @@ class Inverter { uint8_t getQueuedCmd() { if (_commandQueue.empty()) { - if (getFwVersion() == 0) - enqueCommand(InverterDevInform_All); // firmware version - enqueCommand(RealTimeRunData_Debug); // live data + if (ivGen != IV_MI) { + if (getFwVersion() == 0) + enqueCommand(InverterDevInform_All); // firmware version + enqueCommand(RealTimeRunData_Debug); // live data + } else if (ivGen == IV_MI){ + if (type == INV_TYPE_4CH) { + enqueCommand(0x36); + /*for(uint8_t i = 0x36; i <= 0x39; i++) { + enqueCommand(i); // live data + }*/ + } else if (type == INV_TYPE_2CH) { + enqueCommand(0x09); + //enqueCommand(0x11); + } else if (type == INV_TYPE_1CH) { + enqueCommand(0x09); + } + //if (getFwVersion() == 0) + // enqueCommand(InverterDevInform_All); // firmware version, might not work, esp. for 1/2 ch hardware + } + if ((actPowerLimit == 0xffff) && isConnected) enqueCommand(SystemConfigPara); // power limit info } diff --git a/src/hm/miPayload.h b/src/hm/miPayload.h index aa295db7..ac455f3d 100644 --- a/src/hm/miPayload.h +++ b/src/hm/miPayload.h @@ -18,8 +18,8 @@ typedef struct { uint8_t txCmd; uint8_t len[MAX_PAYLOAD_ENTRIES]; bool complete; - bool stsa; - bool stsb; + bool dataAB[2]; + uint8_t sts[5]; uint8_t txId; uint8_t invId; uint8_t retransmits; @@ -65,6 +65,7 @@ class MiPayload { void addAlarmListener(alarmListenerType cb) { mCbMiAlarm = cb; } + void loop() { /*if(NULL != mHighPrioIv) { iv->ivSend(mHighPrioIv, true); // should request firmware version etc.? @@ -84,55 +85,83 @@ class MiPayload { if (mSerialDebug) DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX)); - uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; //iv->getQueuedCmd(); - DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd")); + //first channel request + /*uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; + DPRINT(DBG_INFO, F("(#")); + DBGPRINT(String(iv->id)); + DBGPRINT(F(") prepareDevInformCmd 0x")); + DBGPRINTLN(String(cmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].txCmd = cmd;*/ + + uint8_t cmd = iv->getQueuedCmd(); + DPRINT(DBG_INFO, F("(#")); + DBGPRINT(String(iv->id)); + DBGPRINT(F(") prepareDevInformCmd 0x")); + DBGPRINTLN(String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + //other channel requests + /*if (iv->type == INV_TYPE_4CH) { + for(uint8_t i = 1; i < iv->channels; i++) { + iv->enqueCommand(cmd + i, cmd + i); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd + i); + } + } else */ + if (iv->type == INV_TYPE_2CH) { + mPayload[iv->id].dataAB[0] = false; + mPayload[iv->id].dataAB[1] = false; + //iv->enqueCommand(0x11); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + } } void add(Inverter<> *iv, packet_t *p) { //DPRINTLN(DBG_INFO, F("MI got data [0]=") + String(p->packet[0], HEX)); if (p->packet[0] == (0x08 + ALL_FRAMES)) { // 0x88; MI status response to 0x09 - mPayload[iv->id].stsa = true; + //mPayload[iv->id].sts[0] = true; miStsDecode(iv, p); } else if (p->packet[0] == (0x11 + SINGLE_FRAME)) { // 0x92; MI status response to 0x11 - mPayload[iv->id].stsb = true; + //mPayload[iv->id].sts[1] = true; miStsDecode(iv, p, CH2); - } else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 + /*} else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 mPayload[iv->id].txId = p->packet[0]; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); + //iv->setQueuedCmdFinished(); if (INV_TYPE_2CH == iv->type) { //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); } else { // additional check for mPayload[iv->id].stsa == true might be a good idea (request retransmit?) mPayload[iv->id].complete = true; //iv->setQueuedCmdFinished(); } - } else if (p->packet[0] == (0x11 + ALL_FRAMES)) { // MI data response to 0x11 + } else if (p->packet[0] == ()) { // MI data response to 0x11 mPayload[iv->id].txId = p->packet[0]; - mPayload[iv->id].complete = true; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); + mStat->rxSuccess++; + //iv->setQueuedCmdFinished();*/ - } else if (p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME)) { // MI 1500 data response to 0x36, 0x37, 0x38 and 0x39 + } else if ( p->packet[0] == 0x09 + ALL_FRAMES || + p->packet[0] == 0x11 + ALL_FRAMES || + ( p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME) ) ) { // small MI or MI 1500 data responses to 0x09, 0x11, 0x36, 0x37, 0x38 and 0x39 mPayload[iv->id].txId = p->packet[0]; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); - if (p->packet[0] < (0x39 + ALL_FRAMES)) { + //mStat->rxSuccess++; + //iv->setQueuedCmdFinished(); + /*if (p->packet[0] < (0x39 + ALL_FRAMES)) { //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); } else { mPayload[iv->id].complete = true; //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); //iv->setQueuedCmdFinished(); - } + }*/ - /*} + //} - if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command + /*if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command mPayload[iv->id].txId = p->packet[0]; DPRINTLN(DBG_DEBUG, F("Response from info request received")); uint8_t *pid = &p->packet[9]; @@ -170,7 +199,7 @@ class MiPayload { msg = "NOT "; DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has ") + msg + F("accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1])); iv->clearCmdQueue(); - iv->enqueCommand(SystemConfigPara); // read back power limit + iv->enqueCommand(SystemConfigPara); // read back power limit } iv->devControlCmd = Init; } else { // some other response; copied from hmPayload:process; might not be correct to do that here!!! @@ -264,6 +293,7 @@ class MiPayload { if (mPayload[iv->id].retransmits < mMaxRetrans) { mPayload[iv->id].retransmits++; //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + DPRINTLN(DBG_WARN, F("missing answer to 0x") + String(iv->getQueuedCmd(), HEX) + F("Request Retransmit")); mSys->Radio.sendCmdPacket(iv->radioId.u64, iv->getQueuedCmd(), 24, true); /*if(false == mPayload[iv->id].gotFragment) { DPRINTLN(DBG_WARN, F("(#") + String(iv->id) + F(") nothing received")); @@ -363,39 +393,28 @@ class MiPayload { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure rec->ts = mPayload[iv->id].ts; - //iv->setValue(iv->getPosByChFld(chan, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); // was 11/12, might be wrong! - - //if (INV_TYPE_1CH == iv->type) - //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); + uint8_t status = (p->packet[11] << 8) + p->packet[12]; + uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2; + mPayload[iv->id].dataAB[stschan-1] = true; + mPayload[iv->id].sts[stschan] = status; + if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { + mPayload[iv->id].sts[0] = status; + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); + } - //iv->setValue(iv->getPosByChFld(chan, FLD_EVT, rec), rec, (int)((p->packet[13] << 8) + p->packet[14])); + if ( !mPayload[iv->id].dataAB[0] || !mPayload[iv->id].dataAB[1] ) { + uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; + DPRINTLN(DBG_INFO, F("request missing status 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + } - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, (int)((p->packet[11] << 8) + p->packet[12])); - //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, (int)((p->packet[14] << 8) + p->packet[16])); if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); + iv->enqueCommand(AlarmData); } - /* Unclear how in HM inverters Info and alarm data is handled... - */ - - - /* int8_t offset = -2; - - for decoding see - void MI600StsMsg (NRF24_packet_t *p){ - STAT = (int)((p->packet[11] << 8) + p->packet[12]); - FCNT = (int)((p->packet[13] << 8) + p->packet[14]); - FCODE = (int)((p->packet[15] << 8) + p->packet[16]); - #ifdef ESP8266 - VALUES[PV][5]=STAT; - VALUES[PV][6]=FCNT; - VALUES[PV][7]=FCODE; - #endif - } - */ } void miDataDecode(Inverter<> *iv, packet_t *p) { @@ -406,49 +425,93 @@ class MiPayload { ( p->packet[0] == 0x91 || p->packet[0] == (0x37 + ALL_FRAMES) ) ? CH2 : p->packet[0] == (0x38 + ALL_FRAMES) ? CH3 : CH4; - int8_t offset = -2; - // U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[11+offset] << 8) + p->packet[12+offset])/10); + DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); + // count in RF_communication_protocol.xlsx is with offset = -1 + iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[9] << 8) + p->packet[10])/10); yield(); - // I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[13+offset] << 8) + p->packet[14+offset])/10); + iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[11] << 8) + p->packet[12])/10); yield(); - // U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; - iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[15+offset] << 8) + p->packet[16+offset])/10); + iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[13] << 8) + p->packet[14])/10); yield(); - // F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; - //iv->setValue(iv->getPosByChFld(0, FLD_IAC, rec), rec, (float)((p->packet[17+offset] << 8) + p->packet[18+offset])/100); - //yield(); - // P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[19+offset] << 8) + p->packet[20+offset])/10); + iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[15] << 8) + p->packet[16])/100); + iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[17] << 8) + p->packet[18])/10); yield(); - // Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; - iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[21+offset] << 8) + p->packet[22+offset])/1); + iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[19] << 8) + p->packet[20])/1); yield(); - iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[23+offset] << 8) + p->packet[24+offset])/10); //23 is freq or IAC? - iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[17+offset] << 8) + p->packet[18+offset])/100); + iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[21] << 8) + p->packet[22])/10); iv->setValue(iv->getPosByChFld(0, FLD_IRR, rec), rec, (float) (calcIrradiation(iv, datachan))); - yield(); - //FLD_YD + //AC Power is missing; we may have to calculate, as no respective data is in payload if (p->packet[0] >= (0x36 + ALL_FRAMES) ) { - /*status message analysis most liklely needs to be changed, see MiStsMst*/ - /*STAT = (uint8_t)(p->packet[25] ); - FCNT = (uint8_t)(p->packet[26]); - FCODE = (uint8_t)(p->packet[27]); // MI300/Mi600 stsMsg:: (int)((p->packet[15] << 8) + p->packet[16]); */ - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, (uint8_t)(p->packet[25+offset])); - yield(); + + /*For MI1500: + if (MI1500) { + STAT = (uint8_t)(p->packet[25] ); + FCNT = (uint8_t)(p->packet[26]); + FCODE = (uint8_t)(p->packet[27]); + }*/ + + uint8_t status = (uint8_t)(p->packet[23]); + mPayload[iv->id].sts[datachan] = status; + if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { + mPayload[iv->id].sts[0] = status; + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); + } + + if (p->packet[0] < (0x39 + ALL_FRAMES) ) { + uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].complete = false; + } + + //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); + //iv->enqueCommand(AlarmData); } + } - //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); // (getValue(iv->getPosByChFld(1, FLD_YD, rec), rec) + getValue(iv->getPosByChFld(2, FLD_YD, rec), rec))); - iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); //datachan)); - iv->doCalculations(); - notify(mPayload[iv->id].txCmd); + + //preliminary AC calculation... + uint8_t ac_pow = 0; + //if (mPayload[iv->id].sts[0] == 3) { + ac_pow = calcPowerDcCh0(iv, 0)*9.5; + //} + iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); + //iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (mPayload[iv->id].sts[0] == 3 ? calcPowerDcCh0(iv, 0)*0.95 : 0)); + + if ( mPayload[iv->id].sts[0] ) { + uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; + if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { + mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short... + DPRINTLN(DBG_INFO, F("complete tree detected")); + iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); + iv->doCalculations(); + } else { + //retry to get missing status info for one or two channel devices + DPRINTLN(DBG_INFO, F("request missing data or status 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + //iv->enqueCommand(cmd); // mPayload[iv->id].dataAB[1] ? 0x09 : 0x11) + } + } // not yet moved to hmInverter::getQueuedCmd + else if (mPayload[iv->id].txCmd == 0x09 && iv->type == INV_TYPE_2CH) { + uint8_t cmd = 0x11; + DPRINTLN(DBG_INFO, F("request second data channel 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].complete = false; + } + + iv->setQueuedCmdFinished(); + mStat->rxSuccess++; + yield(); + + notify(mPayload[iv->id].txCmd); + /* if(AlarmData == mPayload[iv->id].txCmd) { uint8_t i = 0; @@ -463,66 +526,26 @@ class MiPayload { yield(); } }*/ -/*decode here or memcopy payload for later decoding? - void MI600DataMsg(NRF24_packet_t *p){ - U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; - I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; - U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; - F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; - P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; - Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; - TEMP = (float) ((p->packet[23] << 8) + p->packet[24])/10; //(int16_t) - - if ((30packet[2] == 0x89) {PV= 0; TotalP[1]=P_DC; pvCnt[0]=1;}//port 1 - if (p->packet[2] == 0x91) {PV= 1; TotalP[2]=P_DC; pvCnt[1]=1;}//port 2 - - TotalP[0]=TotalP[1]+TotalP[2]+TotalP[3]+TotalP[4];//in TotalP[0] is the totalPV power - if((P_DC>400) || (P_DC<0) || (TotalP[0]>MAXPOWER)){// cant be!! - TotalP[0]=0; - return; - } - #ifdef ESP8266 - VALUES[PV][0]=PV; - VALUES[PV][1]=P_DC; - VALUES[PV][2]=U_DC; - VALUES[PV][3]=I_DC; - VALUES[PV][4]=Q_DC; - #endif - PMI=TotalP[0]; - LIM=(uint16_t)Limit; - PrintOutValues(); - }*/ - - /*For MI1500: - if (MI1500) { - STAT = (uint8_t)(p->packet[25] ); - FCNT = (uint8_t)(p->packet[26]); - FCODE = (uint8_t)(p->packet[27]); - } - */ - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); } bool build(uint8_t id, bool *complete) { - /*DPRINTLN(DBG_VERBOSE, F("build")); - uint16_t crc = 0xffff, crcRcv = 0x0000; + DPRINTLN(DBG_VERBOSE, F("build")); + /*uint16_t crc = 0xffff, crcRcv = 0x0000; if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES) mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; - - // check if all fragments are there - *complete = true; - for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { - if(mPayload[id].len[i] == 0) - *complete = false; + */ + // check if all messages are there + + *complete = mPayload[id].complete; + uint8_t txCmd = mPayload[id].txCmd; + //uint8_t cmd = getQueuedCmd(); + if(!*complete) { + //if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 ) + // return false; + DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX)); } - if(!*complete) - return false; - for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { + /*for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { if (mPayload[id].len[i] > 0) { if (i == (mPayload[id].maxPackId - 1)) { crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc); @@ -546,13 +569,42 @@ class MiPayload { mPayload[id].lastFound = false;*/ mPayload[id].retransmits = 0; mPayload[id].complete = false; + mPayload[id].dataAB[0] = true; //only required for 2CH devices + mPayload[id].dataAB[1] = true; mPayload[id].txCmd = 0; mPayload[id].requested = false; mPayload[id].ts = *mTimestamp; - mPayload[id].stsa = false; - mPayload[id].stsb = false; + //mPayload[id].sts[0] = 0; + mPayload[id].sts[1] = 0; + mPayload[id].sts[2] = 0; + mPayload[id].sts[3] = 0; + mPayload[id].sts[4] = 0; } + +/* template + static T calcMiSts(Inverter<> *iv) { + if(NULL != iv) { + T result = 0; + bool stsComplete = true; + uint8_t stsCh; + for(uint8_t i = 1; i <= iv->channels; i++) { + stsCh = mPayload[iv->id].sts[i]; + if (!stsCh) { + stsComplete = false; + } else if ( !result || stsCh < result ) { + result = stsCh; + if (stsComplete && stsCh > stsComplete) { + stsComplete = stsCh; + } + } + } + mPayload[iv->id].sts[0] = stsComplete; + return result; + } + return 0; + } */ + IApp *mApp; HMSYSTEM *mSys; statistics_t *mStat; From a60b6affaea4e1a4567efd1dde86ad95c231ff7f Mon Sep 17 00:00:00 2001 From: tomquist Date: Sun, 5 Mar 2023 11:24:00 +0100 Subject: [PATCH 05/26] Add TSOL-M1600 to firmware collection --- User_Manual.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/User_Manual.md b/User_Manual.md index 529125a0..5ff1339a 100644 --- a/User_Manual.md +++ b/User_Manual.md @@ -304,7 +304,8 @@ To get the information open the URL `/api/record/info` on your AhoyDTU. The info | chehrlic | HM-600 | | 1.0.10 | 2021 | 11-01 | 104 | | | | chehrlic | TSOL-M800de | | 1.0.10 | 2021 | 11-01 | 104 | | | | B5r1oJ0A9G | HM-800 | | 1.0.10 | 2021 | | 104 | | | -| | | | | | | | | | +| B5r1oJ0A9G | HM-800 | | 1.0.10 | 2021 | | 104 | | | +| tomquist | TSOL-M1600 | | 1.0.12 | 2020 | 06-24 | 100 | | | | | | | | | | | | | ## Developer Information about Command Queue From 319a69dd712118f2babda8169769a9588deac1b0 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 12:28:48 +0100 Subject: [PATCH 06/26] small changes --- hmInverter.h | 689 +++++++++++++++++++++++++++++++++++++++++++++++++++ miPayload.h | 299 ++++++++++++---------- 2 files changed, 858 insertions(+), 130 deletions(-) create mode 100644 hmInverter.h diff --git a/hmInverter.h b/hmInverter.h new file mode 100644 index 00000000..175c6177 --- /dev/null +++ b/hmInverter.h @@ -0,0 +1,689 @@ +//----------------------------------------------------------------------------- +// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778 +// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ +//----------------------------------------------------------------------------- + +#ifndef __HM_INVERTER_H__ +#define __HM_INVERTER_H__ + +#if defined(ESP32) && defined(F) + #undef F + #define F(sl) (sl) +#endif + +#include "hmDefines.h" +#include +#include +#include "../config/settings.h" + +/** + * For values which are of interest and not transmitted by the inverter can be + * calculated automatically. + * A list of functions can be linked to the assignment and will be executed + * automatically. Their result does not differ from original read values. + */ + +// forward declaration of class +template +class Inverter; + + +// prototypes +template +static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0); + +template +static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0); + +template +static T calcUdcCh(Inverter<> *iv, uint8_t arg0); + +template +static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0); + +template +static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0); + +template +static T calcIrradiation(Inverter<> *iv, uint8_t arg0); + +template +using func_t = T (Inverter<> *, uint8_t); + +template +struct calcFunc_t { + uint8_t funcId; // unique id + func_t* func; // function pointer +}; + +template +struct record_t { + byteAssign_t* assign; // assigment of bytes in payload + uint8_t length; // length of the assignment list + T *record; // data pointer + uint32_t ts; // timestamp of last received payload + uint8_t pyldLen; // expected payload length for plausibility check +}; + +class CommandAbstract { + public: + CommandAbstract(uint8_t txType = 0, uint8_t cmd = 0) { + _TxType = txType; + _Cmd = cmd; + }; + virtual ~CommandAbstract() {}; + + const uint8_t getCmd() { + return _Cmd; + } + + protected: + uint8_t _TxType; + uint8_t _Cmd; +}; + +class InfoCommand : public CommandAbstract { + public: + InfoCommand(uint8_t cmd){ + _TxType = 0x15; + _Cmd = cmd; + } +}; + +class MiInfoCommand : public CommandAbstract { + public: + MiInfoCommand(uint8_t cmd){ + _TxType = cmd; + _Cmd = cmd; + } +}; +// list of all available functions, mapped in hmDefines.h +template +const calcFunc_t calcFunctions[] = { + { CALC_YT_CH0, &calcYieldTotalCh0 }, + { CALC_YD_CH0, &calcYieldDayCh0 }, + { CALC_UDC_CH, &calcUdcCh }, + { CALC_PDC_CH0, &calcPowerDcCh0 }, + { CALC_EFF_CH0, &calcEffiencyCh0 }, + { CALC_IRR_CH, &calcIrradiation } +}; + + +template +class Inverter { + public: + uint8_t ivGen; // generation of inverter (HM / MI) + cfgIv_t *config; // stored settings + uint8_t id; // unique id + uint8_t type; // integer which refers to inverter type + uint16_t alarmMesIndex; // Last recorded Alarm Message Index + uint16_t powerLimit[2]; // limit power output + float actPowerLimit; // actual power limit + uint8_t devControlCmd; // carries the requested cmd + serial_u radioId; // id converted to modbus + uint8_t channels; // number of PV channels (1-4) + record_t recordMeas; // structure for measured values + record_t recordInfo; // structure for info values + record_t recordConfig; // structure for system config values + record_t recordAlarm; // structure for alarm values + //String lastAlarmMsg; + bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null) + bool isConnected; // shows if inverter was successfully identified (fw version and hardware info) + + Inverter() { + ivGen = IV_HM; + powerLimit[0] = 0xffff; // 65535 W Limit -> unlimited + powerLimit[1] = AbsolutNonPersistent; // default power limit setting + actPowerLimit = 0xffff; // init feedback from inverter to -1 + mDevControlRequest = false; + devControlCmd = InitDataState; + initialized = false; + //lastAlarmMsg = "nothing"; + alarmMesIndex = 0; + isConnected = false; + } + + ~Inverter() { + // TODO: cleanup + } + + template + void enqueCommand(uint8_t cmd) { + _commandQueue.push(std::make_shared(cmd)); + DPRINTLN(DBG_INFO, F("(#") + String(id) + F(") enqueuedCmd: 0x") + String(cmd, HEX)); + } + + void setQueuedCmdFinished() { + if (!_commandQueue.empty()) { + // Will destroy CommandAbstract Class Object (?) + _commandQueue.pop(); + } + } + + void clearCmdQueue() { + DPRINTLN(DBG_INFO, F("clearCmdQueue")); + while (!_commandQueue.empty()) { + // Will destroy CommandAbstract Class Object (?) + _commandQueue.pop(); + } + } + + uint8_t getQueuedCmd() { + if (_commandQueue.empty()) { + if (ivGen != IV_MI) { + if (getFwVersion() == 0) + enqueCommand(InverterDevInform_All); // firmware version + enqueCommand(RealTimeRunData_Debug); // live data + } else if (ivGen == IV_MI){ + if (type == INV_TYPE_4CH) { + enqueCommand(0x36); + /*for(uint8_t i = 0x36; i <= 0x39; i++) { + enqueCommand(i); // live data + }*/ + } else if (type == INV_TYPE_2CH) { + enqueCommand(0x09); + //enqueCommand(0x11); + } else if (type == INV_TYPE_1CH) { + enqueCommand(0x09); + } + //if (getFwVersion() == 0) + // enqueCommand(InverterDevInform_All); // firmware version, might not work, esp. for 1/2 ch hardware + } + + if ((actPowerLimit == 0xffff) && isConnected) + enqueCommand(SystemConfigPara); // power limit info + } + return _commandQueue.front().get()->getCmd(); + } + + + void init(void) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:init")); + initAssignment(&recordMeas, RealTimeRunData_Debug); + initAssignment(&recordInfo, InverterDevInform_All); + initAssignment(&recordConfig, SystemConfigPara); + initAssignment(&recordAlarm, AlarmData); + toRadioId(); + initialized = true; + } + + uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId, record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getPosByChFld")); + uint8_t pos = 0; + if(NULL != rec) { + for(; pos < rec->length; pos++) { + if((rec->assign[pos].ch == channel) && (rec->assign[pos].fieldId == fieldId)) + break; + } + return (pos >= rec->length) ? 0xff : pos; + } + else + return 0xff; + } + + byteAssign_t *getByteAssign(uint8_t pos, record_t<> *rec) { + return &rec->assign[pos]; + } + + const char *getFieldName(uint8_t pos, record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getFieldName")); + if(NULL != rec) + return fields[rec->assign[pos].fieldId]; + return notAvail; + } + + const char *getUnit(uint8_t pos, record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getUnit")); + if(NULL != rec) + return units[rec->assign[pos].unitId]; + return notAvail; + } + + uint8_t getChannel(uint8_t pos, record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getChannel")); + if(NULL != rec) + return rec->assign[pos].ch; + return 0; + } + + bool setDevControlRequest(uint8_t cmd) { + if(isConnected) { + mDevControlRequest = true; + devControlCmd = cmd; + } + return isConnected; + } + + void clearDevControlRequest() { + mDevControlRequest = false; + } + + inline bool getDevControlRequest() { + return mDevControlRequest; + } + + void addValue(uint8_t pos, uint8_t buf[], record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:addValue")); + if(NULL != rec) { + uint8_t ptr = rec->assign[pos].start; + uint8_t end = ptr + rec->assign[pos].num; + uint16_t div = rec->assign[pos].div; + + if(NULL != rec) { + if(CMD_CALC != div) { + uint32_t val = 0; + do { + val <<= 8; + val |= buf[ptr]; + } while(++ptr != end); + if (FLD_T == rec->assign[pos].fieldId) { + // temperature is a signed value! + rec->record[pos] = (REC_TYP)((int16_t)val) / (REC_TYP)(div); + } else if (FLD_YT == rec->assign[pos].fieldId) { + rec->record[pos] = ((REC_TYP)(val) / (REC_TYP)(div)) + ((REC_TYP)config->yieldCor[rec->assign[pos].ch-1]); + } else { + if ((REC_TYP)(div) > 1) + rec->record[pos] = (REC_TYP)(val) / (REC_TYP)(div); + else + rec->record[pos] = (REC_TYP)(val); + } + } + } + + if(rec == &recordMeas) { + DPRINTLN(DBG_VERBOSE, "add real time"); + + // get last alarm message index and save it in the inverter object + if (getPosByChFld(0, FLD_EVT, rec) == pos){ + if (alarmMesIndex < rec->record[pos]){ + alarmMesIndex = rec->record[pos]; + //enqueCommand(AlarmUpdate); // What is the function of AlarmUpdate? + + DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(alarmMesIndex)); + enqueCommand(AlarmData); + } + } + } + else if (rec->assign == InfoAssignment) { + DPRINTLN(DBG_DEBUG, "add info"); + // eg. fw version ... + isConnected = true; + } + else if (rec->assign == SystemConfigParaAssignment) { + DPRINTLN(DBG_DEBUG, "add config"); + if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){ + actPowerLimit = rec->record[pos]; + DPRINT(DBG_DEBUG, F("Inverter actual power limit: ") + String(actPowerLimit, 1)); + } + } + else if (rec->assign == AlarmDataAssignment) { + DPRINTLN(DBG_DEBUG, "add alarm"); + //if (getPosByChFld(0, FLD_LAST_ALARM_CODE, rec) == pos){ + // lastAlarmMsg = getAlarmStr(rec->record[pos]); + //} + } + else + DPRINTLN(DBG_WARN, F("add with unknown assginment")); + } + else + DPRINTLN(DBG_ERROR, F("addValue: assignment not found with cmd 0x")); + } + + /*inline REC_TYP getPowerLimit(void) { + record_t<> *rec = getRecordStruct(SystemConfigPara); + return getChannelFieldValue(CH0, FLD_ACT_ACTIVE_PWR_LIMIT, rec); + }*/ + + bool setValue(uint8_t pos, record_t<> *rec, REC_TYP val) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:setValue")); + if(NULL == rec) + return false; + if(pos > rec->length) + return false; + rec->record[pos] = val; + return true; + } + + REC_TYP getChannelFieldValue(uint8_t channel, uint8_t fieldId, record_t<> *rec) { + uint8_t pos = 0; + if(NULL != rec) { + for(; pos < rec->length; pos++) { + if((rec->assign[pos].ch == channel) && (rec->assign[pos].fieldId == fieldId)) + break; + } + if(pos >= rec->length) + return 0; + + return rec->record[pos]; + } + else + return 0; + } + + REC_TYP getValue(uint8_t pos, record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getValue")); + if(NULL == rec) + return 0; + if(pos > rec->length) + return 0; + return rec->record[pos]; + } + + void doCalculations() { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:doCalculations")); + record_t<> *rec = getRecordStruct(RealTimeRunData_Debug); + for(uint8_t i = 0; i < rec->length; i++) { + if(CMD_CALC == rec->assign[i].div) { + rec->record[i] = calcFunctions[rec->assign[i].start].func(this, rec->assign[i].num); + } + yield(); + } + } + + bool isAvailable(uint32_t timestamp) { + if((timestamp - recordMeas.ts) < INACT_THRES_SEC) + return true; + if((timestamp - recordInfo.ts) < INACT_THRES_SEC) + return true; + if((timestamp - recordConfig.ts) < INACT_THRES_SEC) + return true; + if((timestamp - recordAlarm.ts) < INACT_THRES_SEC) + return true; + return false; + } + + bool isProducing(uint32_t timestamp) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:isProducing")); + if(isAvailable(timestamp)) { + uint8_t pos = getPosByChFld(CH0, FLD_PAC, &recordMeas); + return (getValue(pos, &recordMeas) > INACT_PWR_THRESH); + } + return false; + } + + uint16_t getFwVersion() { + record_t<> *rec = getRecordStruct(InverterDevInform_All); + uint8_t pos = getPosByChFld(CH0, FLD_FW_VERSION, rec); + return getValue(pos, rec); + } + + uint32_t getLastTs(record_t<> *rec) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getLastTs")); + return rec->ts; + } + + record_t<> *getRecordStruct(uint8_t cmd) { + switch (cmd) { + case RealTimeRunData_Debug: return &recordMeas; // 11 = 0x0b + case InverterDevInform_All: return &recordInfo; // 1 = 0x01 + case SystemConfigPara: return &recordConfig; // 5 = 0x05 + case AlarmData: return &recordAlarm; // 17 = 0x11 + default: break; + } + return NULL; + } + + void initAssignment(record_t<> *rec, uint8_t cmd) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:initAssignment")); + rec->ts = 0; + rec->length = 0; + switch (cmd) { + case RealTimeRunData_Debug: + if (INV_TYPE_1CH == type) { + rec->length = (uint8_t)(HM1CH_LIST_LEN); + rec->assign = (byteAssign_t *)hm1chAssignment; + rec->pyldLen = HM1CH_PAYLOAD_LEN; + channels = 1; + } + else if (INV_TYPE_2CH == type) { + rec->length = (uint8_t)(HM2CH_LIST_LEN); + rec->assign = (byteAssign_t *)hm2chAssignment; + rec->pyldLen = HM2CH_PAYLOAD_LEN; + channels = 2; + } + else if (INV_TYPE_4CH == type) { + rec->length = (uint8_t)(HM4CH_LIST_LEN); + rec->assign = (byteAssign_t *)hm4chAssignment; + rec->pyldLen = HM4CH_PAYLOAD_LEN; + channels = 4; + } + else { + rec->length = 0; + rec->assign = NULL; + rec->pyldLen = 0; + channels = 0; + } + break; + case InverterDevInform_All: + rec->length = (uint8_t)(HMINFO_LIST_LEN); + rec->assign = (byteAssign_t *)InfoAssignment; + rec->pyldLen = HMINFO_PAYLOAD_LEN; + break; + case SystemConfigPara: + rec->length = (uint8_t)(HMSYSTEM_LIST_LEN); + rec->assign = (byteAssign_t *)SystemConfigParaAssignment; + rec->pyldLen = HMSYSTEM_PAYLOAD_LEN; + break; + case AlarmData: + rec->length = (uint8_t)(HMALARMDATA_LIST_LEN); + rec->assign = (byteAssign_t *)AlarmDataAssignment; + rec->pyldLen = HMALARMDATA_PAYLOAD_LEN; + break; + default: + DPRINTLN(DBG_INFO, F("initAssignment: Parser not implemented")); + break; + } + + if(0 != rec->length) { + rec->record = new REC_TYP[rec->length]; + memset(rec->record, 0, sizeof(REC_TYP) * rec->length); + } + } + + uint16_t parseAlarmLog(uint8_t id, uint8_t pyld[], uint8_t len, uint32_t *start, uint32_t *endTime) { + uint8_t startOff = 2 + id * ALARM_LOG_ENTRY_SIZE; + if((startOff + ALARM_LOG_ENTRY_SIZE) > len) + return 0; + + uint16_t wCode = ((uint16_t)pyld[startOff]) << 8 | pyld[startOff+1]; + uint32_t startTimeOffset = 0, endTimeOffset = 0; + + if (((wCode >> 13) & 0x01) == 1) // check if is AM or PM + startTimeOffset = 12 * 60 * 60; + if (((wCode >> 12) & 0x01) == 1) // check if is AM or PM + endTimeOffset = 12 * 60 * 60; + + *start = (((uint16_t)pyld[startOff + 4] << 8) | ((uint16_t)pyld[startOff + 5])) + startTimeOffset; + *endTime = (((uint16_t)pyld[startOff + 6] << 8) | ((uint16_t)pyld[startOff + 7])) + endTimeOffset; + + DPRINTLN(DBG_INFO, "Alarm #" + String(pyld[startOff+1]) + " '" + String(getAlarmStr(pyld[startOff+1])) + "' start: " + ah::getTimeStr(*start) + ", end: " + ah::getTimeStr(*endTime)); + return pyld[startOff+1]; + } + + String getAlarmStr(uint16_t alarmCode) { + switch (alarmCode) { // breaks are intentionally missing! + case 1: return String(F("Inverter start")); + case 2: return String(F("DTU command failed")); + case 121: return String(F("Over temperature protection")); + case 125: return String(F("Grid configuration parameter error")); + case 126: return String(F("Software error code 126")); + case 127: return String(F("Firmware error")); + case 128: return String(F("Software error code 128")); + case 129: return String(F("Software error code 129")); + case 130: return String(F("Offline")); + case 141: return String(F("Grid overvoltage")); + case 142: return String(F("Average grid overvoltage")); + case 143: return String(F("Grid undervoltage")); + case 144: return String(F("Grid overfrequency")); + case 145: return String(F("Grid underfrequency")); + case 146: return String(F("Rapid grid frequency change")); + case 147: return String(F("Power grid outage")); + case 148: return String(F("Grid disconnection")); + case 149: return String(F("Island detected")); + case 205: return String(F("Input port 1 & 2 overvoltage")); + case 206: return String(F("Input port 3 & 4 overvoltage")); + case 207: return String(F("Input port 1 & 2 undervoltage")); + case 208: return String(F("Input port 3 & 4 undervoltage")); + case 209: return String(F("Port 1 no input")); + case 210: return String(F("Port 2 no input")); + case 211: return String(F("Port 3 no input")); + case 212: return String(F("Port 4 no input")); + case 213: return String(F("PV-1 & PV-2 abnormal wiring")); + case 214: return String(F("PV-3 & PV-4 abnormal wiring")); + case 215: return String(F("PV-1 Input overvoltage")); + case 216: return String(F("PV-1 Input undervoltage")); + case 217: return String(F("PV-2 Input overvoltage")); + case 218: return String(F("PV-2 Input undervoltage")); + case 219: return String(F("PV-3 Input overvoltage")); + case 220: return String(F("PV-3 Input undervoltage")); + case 221: return String(F("PV-4 Input overvoltage")); + case 222: return String(F("PV-4 Input undervoltage")); + case 301: return String(F("Hardware error code 301")); + case 302: return String(F("Hardware error code 302")); + case 303: return String(F("Hardware error code 303")); + case 304: return String(F("Hardware error code 304")); + case 305: return String(F("Hardware error code 305")); + case 306: return String(F("Hardware error code 306")); + case 307: return String(F("Hardware error code 307")); + case 308: return String(F("Hardware error code 308")); + case 309: return String(F("Hardware error code 309")); + case 310: return String(F("Hardware error code 310")); + case 311: return String(F("Hardware error code 311")); + case 312: return String(F("Hardware error code 312")); + case 313: return String(F("Hardware error code 313")); + case 314: return String(F("Hardware error code 314")); + case 5041: return String(F("Error code-04 Port 1")); + case 5042: return String(F("Error code-04 Port 2")); + case 5043: return String(F("Error code-04 Port 3")); + case 5044: return String(F("Error code-04 Port 4")); + case 5051: return String(F("PV Input 1 Overvoltage/Undervoltage")); + case 5052: return String(F("PV Input 2 Overvoltage/Undervoltage")); + case 5053: return String(F("PV Input 3 Overvoltage/Undervoltage")); + case 5054: return String(F("PV Input 4 Overvoltage/Undervoltage")); + case 5060: return String(F("Abnormal bias")); + case 5070: return String(F("Over temperature protection")); + case 5080: return String(F("Grid Overvoltage/Undervoltage")); + case 5090: return String(F("Grid Overfrequency/Underfrequency")); + case 5100: return String(F("Island detected")); + case 5120: return String(F("EEPROM reading and writing error")); + case 5150: return String(F("10 min value grid overvoltage")); + case 5200: return String(F("Firmware error")); + case 8310: return String(F("Shut down")); + case 9000: return String(F("Microinverter is suspected of being stolen")); + default: return String(F("Unknown")); + } + } + + private: + void toRadioId(void) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:toRadioId")); + radioId.u64 = 0ULL; + radioId.b[4] = config->serial.b[0]; + radioId.b[3] = config->serial.b[1]; + radioId.b[2] = config->serial.b[2]; + radioId.b[1] = config->serial.b[3]; + radioId.b[0] = 0x01; + } + + std::queue> _commandQueue; + bool mDevControlRequest; // true if change needed +}; + + +/** + * To calculate values which are not transmitted by the unit there is a generic + * list of functions which can be linked to the assignment. + * The special command 0xff (CMDFF) must be used. + */ + +template +static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldTotalCh0")); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + T yield = 0; + for(uint8_t i = 1; i <= iv->channels; i++) { + uint8_t pos = iv->getPosByChFld(i, FLD_YT, rec); + yield += iv->getValue(pos, rec); + } + return yield; + } + return 0.0; +} + +template +static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldDayCh0")); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + T yield = 0; + for(uint8_t i = 1; i <= iv->channels; i++) { + uint8_t pos = iv->getPosByChFld(i, FLD_YD, rec); + yield += iv->getValue(pos, rec); + } + return yield; + } + return 0.0; +} + +template +static T calcUdcCh(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcUdcCh")); + // arg0 = channel of source + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + for(uint8_t i = 0; i < rec->length; i++) { + if((FLD_UDC == rec->assign[i].fieldId) && (arg0 == rec->assign[i].ch)) { + return iv->getValue(i, rec); + } + } + + return 0.0; +} + +template +static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcPowerDcCh0")); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + T dcPower = 0; + for(uint8_t i = 1; i <= iv->channels; i++) { + uint8_t pos = iv->getPosByChFld(i, FLD_PDC, rec); + dcPower += iv->getValue(pos, rec); + } + return dcPower; + } + return 0.0; +} + +template +static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcEfficiencyCh0")); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + uint8_t pos = iv->getPosByChFld(CH0, FLD_PAC, rec); + T acPower = iv->getValue(pos, rec); + T dcPower = 0; + for(uint8_t i = 1; i <= iv->channels; i++) { + pos = iv->getPosByChFld(i, FLD_PDC, rec); + dcPower += iv->getValue(pos, rec); + } + if(dcPower > 0) + return acPower / dcPower * 100.0f; + } + return 0.0; +} + +template +static T calcIrradiation(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcIrradiation")); + // arg0 = channel + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + uint8_t pos = iv->getPosByChFld(arg0, FLD_PDC, rec); + if(iv->config->chMaxPwr[arg0-1] > 0) + return iv->getValue(pos, rec) / iv->config->chMaxPwr[arg0-1] * 100.0f; + } + return 0.0; +} + +#endif /*__HM_INVERTER_H__*/ diff --git a/miPayload.h b/miPayload.h index 9c68ee18..ae750710 100644 --- a/miPayload.h +++ b/miPayload.h @@ -18,7 +18,8 @@ typedef struct { uint8_t txCmd; uint8_t len[MAX_PAYLOAD_ENTRIES]; bool complete; - uint8_t sts[iv->channels]; + bool dataAB[2]; + uint8_t sts[5]; uint8_t txId; uint8_t invId; uint8_t retransmits; @@ -64,6 +65,7 @@ class MiPayload { void addAlarmListener(alarmListenerType cb) { mCbMiAlarm = cb; } + void loop() { /*if(NULL != mHighPrioIv) { iv->ivSend(mHighPrioIv, true); // should request firmware version etc.? @@ -83,10 +85,35 @@ class MiPayload { if (mSerialDebug) DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX)); - uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; //iv->getQueuedCmd(); - DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd")); + //first channel request + /*uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; + DPRINT(DBG_INFO, F("(#")); + DBGPRINT(String(iv->id)); + DBGPRINT(F(") prepareDevInformCmd 0x")); + DBGPRINTLN(String(cmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].txCmd = cmd;*/ + + uint8_t cmd = iv->getQueuedCmd(); + DPRINT(DBG_INFO, F("(#")); + DBGPRINT(String(iv->id)); + DBGPRINT(F(") prepareDevInformCmd 0x")); + DBGPRINTLN(String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + //other channel requests + /*if (iv->type == INV_TYPE_4CH) { + for(uint8_t i = 1; i < iv->channels; i++) { + iv->enqueCommand(cmd + i, cmd + i); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd + i); + } + } else */ + if (iv->type == INV_TYPE_2CH) { + mPayload[iv->id].dataAB[0] = false; + mPayload[iv->id].dataAB[1] = false; + //iv->enqueCommand(0x11); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + } } void add(Inverter<> *iv, packet_t *p) { @@ -98,40 +125,43 @@ class MiPayload { } else if (p->packet[0] == (0x11 + SINGLE_FRAME)) { // 0x92; MI status response to 0x11 //mPayload[iv->id].sts[1] = true; miStsDecode(iv, p, CH2); - } else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 + /*} else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 mPayload[iv->id].txId = p->packet[0]; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); + //iv->setQueuedCmdFinished(); if (INV_TYPE_2CH == iv->type) { //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); } else { // additional check for mPayload[iv->id].stsa == true might be a good idea (request retransmit?) mPayload[iv->id].complete = true; //iv->setQueuedCmdFinished(); } - } else if (p->packet[0] == (0x11 + ALL_FRAMES)) { // MI data response to 0x11 + } else if (p->packet[0] == ()) { // MI data response to 0x11 mPayload[iv->id].txId = p->packet[0]; - mPayload[iv->id].complete = true; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); + mStat->rxSuccess++; + //iv->setQueuedCmdFinished();*/ - } else if (p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME)) { // MI 1500 data response to 0x36, 0x37, 0x38 and 0x39 + } else if ( p->packet[0] == 0x09 + ALL_FRAMES || + p->packet[0] == 0x11 + ALL_FRAMES || + ( p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME) ) ) { // small MI or MI 1500 data responses to 0x09, 0x11, 0x36, 0x37, 0x38 and 0x39 mPayload[iv->id].txId = p->packet[0]; miDataDecode(iv,p); - iv->setQueuedCmdFinished(); - if (p->packet[0] < (0x39 + ALL_FRAMES)) { + //mStat->rxSuccess++; + //iv->setQueuedCmdFinished(); + /*if (p->packet[0] < (0x39 + ALL_FRAMES)) { //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); + //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); } else { mPayload[iv->id].complete = true; //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); //iv->setQueuedCmdFinished(); - } + }*/ - /*} + //} - if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command + /*if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command mPayload[iv->id].txId = p->packet[0]; DPRINTLN(DBG_DEBUG, F("Response from info request received")); uint8_t *pid = &p->packet[9]; @@ -169,7 +199,7 @@ class MiPayload { msg = "NOT "; DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has ") + msg + F("accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1])); iv->clearCmdQueue(); - iv->enqueCommand(SystemConfigPara); // read back power limit + iv->enqueCommand(SystemConfigPara); // read back power limit } iv->devControlCmd = Init; } else { // some other response; copied from hmPayload:process; might not be correct to do that here!!! @@ -263,6 +293,7 @@ class MiPayload { if (mPayload[iv->id].retransmits < mMaxRetrans) { mPayload[iv->id].retransmits++; //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + DPRINTLN(DBG_WARN, F("missing answer to 0x") + String(iv->getQueuedCmd(), HEX) + F("Request Retransmit")); mSys->Radio.sendCmdPacket(iv->radioId.u64, iv->getQueuedCmd(), 24, true); /*if(false == mPayload[iv->id].gotFragment) { DPRINTLN(DBG_WARN, F("(#") + String(iv->id) + F(") nothing received")); @@ -362,42 +393,28 @@ class MiPayload { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure rec->ts = mPayload[iv->id].ts; - //iv->setValue(iv->getPosByChFld(chan, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); // was 11/12, might be wrong! - - //if (INV_TYPE_1CH == iv->type) - //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, (int)((p->packet[11+6] << 8) + p->packet[12+6])); - - //iv->setValue(iv->getPosByChFld(chan, FLD_EVT, rec), rec, (int)((p->packet[13] << 8) + p->packet[14])); uint8_t status = (p->packet[11] << 8) + p->packet[12]; uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2; - + mPayload[iv->id].dataAB[stschan-1] = true; mPayload[iv->id].sts[stschan] = status; - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv)); - //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, (int)((p->packet[14] << 8) + p->packet[16])); + if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { + mPayload[iv->id].sts[0] = status; + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); + } + + if ( !mPayload[iv->id].dataAB[0] || !mPayload[iv->id].dataAB[1] ) { + uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; + DPRINTLN(DBG_INFO, F("request missing status 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + } + if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); + iv->enqueCommand(AlarmData); } - /* Unclear how in HM inverters Info and alarm data is handled... - */ - - - /* int8_t offset = -2; - - for decoding see - void MI600StsMsg (NRF24_packet_t *p){ - STAT = (int)((p->packet[11] << 8) + p->packet[12]); - FCNT = (int)((p->packet[13] << 8) + p->packet[14]); - FCODE = (int)((p->packet[15] << 8) + p->packet[16]); - #ifdef ESP8266 - VALUES[PV][5]=STAT; - VALUES[PV][6]=FCNT; - VALUES[PV][7]=FCODE; - #endif - } - */ } void miDataDecode(Inverter<> *iv, packet_t *p) { @@ -408,45 +425,92 @@ class MiPayload { ( p->packet[0] == 0x91 || p->packet[0] == (0x37 + ALL_FRAMES) ) ? CH2 : p->packet[0] == (0x38 + ALL_FRAMES) ? CH3 : CH4; - int8_t offset = -2; - // U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[11+offset] << 8) + p->packet[12+offset])/10); + DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); + // count in RF_communication_protocol.xlsx is with offset = -1 + iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[9] << 8) + p->packet[10])/10); yield(); - // I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[13+offset] << 8) + p->packet[14+offset])/10); + iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[11] << 8) + p->packet[12])/10); yield(); - // U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; - iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[15+offset] << 8) + p->packet[16+offset])/10); + iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[13] << 8) + p->packet[14])/10); yield(); - // F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; - //iv->setValue(iv->getPosByChFld(0, FLD_IAC, rec), rec, (float)((p->packet[17+offset] << 8) + p->packet[18+offset])/100); - //yield(); - // P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; - iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[19+offset] << 8) + p->packet[20+offset])/10); + iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[15] << 8) + p->packet[16])/100); + iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[17] << 8) + p->packet[18])/10); yield(); - // Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; - iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[21+offset] << 8) + p->packet[22+offset])/1); + iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[19] << 8) + p->packet[20])/1); yield(); - iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[23+offset] << 8) + p->packet[24+offset])/10); //23 is freq or IAC? - iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[17+offset] << 8) + p->packet[18+offset])/100); + iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[21] << 8) + p->packet[22])/10); iv->setValue(iv->getPosByChFld(0, FLD_IRR, rec), rec, (float) (calcIrradiation(iv, datachan))); - yield(); - //FLD_YD + //AC Power is missing; we may have to calculate, as no respective data is in payload if (p->packet[0] >= (0x36 + ALL_FRAMES) ) { - mPayload[iv->id].sts[stschan] = (uint8_t)(p->packet[25+offset]); - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); + + /*For MI1500: + if (MI1500) { + STAT = (uint8_t)(p->packet[25] ); + FCNT = (uint8_t)(p->packet[26]); + FCODE = (uint8_t)(p->packet[27]); + }*/ + + uint8_t status = (uint8_t)(p->packet[23]); + mPayload[iv->id].sts[datachan] = status; + if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { + mPayload[iv->id].sts[0] = status; + iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); + } + + if (p->packet[0] < (0x39 + ALL_FRAMES) ) { + uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].complete = false; + } + + //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); + //iv->enqueCommand(AlarmData); } + } - //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); // (getValue(iv->getPosByChFld(1, FLD_YD, rec), rec) + getValue(iv->getPosByChFld(2, FLD_YD, rec), rec))); - iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); //datachan)); - iv->doCalculations(); - notify(mPayload[iv->id].txCmd); + + //preliminary AC calculation... + uint8_t ac_pow = 0; + //if (mPayload[iv->id].sts[0] == 3) { + ac_pow = calcPowerDcCh0(iv, 0)*9.5; + //} + iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); + + if ( mPayload[iv->id].sts[0] ) { + uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; + if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { + mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short... + DPRINTLN(DBG_INFO, F("complete tree detected")); + iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); + iv->doCalculations(); + } else { + //retry to get missing status info for one or two channel devices + DPRINTLN(DBG_INFO, F("request missing data or status 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + //iv->enqueCommand(cmd); // mPayload[iv->id].dataAB[1] ? 0x09 : 0x11) + } + } // not yet moved to hmInverter::getQueuedCmd + else if (mPayload[iv->id].txCmd == 0x09 && iv->type == INV_TYPE_2CH) { + uint8_t cmd = 0x11; + DPRINTLN(DBG_INFO, F("request second data channel 0x") + String(cmd, HEX)); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].complete = false; + } + + iv->setQueuedCmdFinished(); + mStat->rxSuccess++; + yield(); + + notify(mPayload[iv->id].txCmd); + /* if(AlarmData == mPayload[iv->id].txCmd) { uint8_t i = 0; @@ -461,66 +525,26 @@ class MiPayload { yield(); } }*/ -/*decode here or memcopy payload for later decoding? - void MI600DataMsg(NRF24_packet_t *p){ - U_DC = (float) ((p->packet[11] << 8) + p->packet[12])/10; - I_DC = (float) ((p->packet[13] << 8) + p->packet[14])/10; - U_AC = (float) ((p->packet[15] << 8) + p->packet[16])/10; - F_AC = (float) ((p->packet[17] << 8) + p->packet[18])/100; - P_DC = (float)((p->packet[19] << 8) + p->packet[20])/10; - Q_DC = (float)((p->packet[21] << 8) + p->packet[22])/1; - TEMP = (float) ((p->packet[23] << 8) + p->packet[24])/10; //(int16_t) - - if ((30packet[2] == 0x89) {PV= 0; TotalP[1]=P_DC; pvCnt[0]=1;}//port 1 - if (p->packet[2] == 0x91) {PV= 1; TotalP[2]=P_DC; pvCnt[1]=1;}//port 2 - - TotalP[0]=TotalP[1]+TotalP[2]+TotalP[3]+TotalP[4];//in TotalP[0] is the totalPV power - if((P_DC>400) || (P_DC<0) || (TotalP[0]>MAXPOWER)){// cant be!! - TotalP[0]=0; - return; - } - #ifdef ESP8266 - VALUES[PV][0]=PV; - VALUES[PV][1]=P_DC; - VALUES[PV][2]=U_DC; - VALUES[PV][3]=I_DC; - VALUES[PV][4]=Q_DC; - #endif - PMI=TotalP[0]; - LIM=(uint16_t)Limit; - PrintOutValues(); - }*/ - - /*For MI1500: - if (MI1500) { - STAT = (uint8_t)(p->packet[25] ); - FCNT = (uint8_t)(p->packet[26]); - FCODE = (uint8_t)(p->packet[27]); - } - */ - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); } bool build(uint8_t id, bool *complete) { - /*DPRINTLN(DBG_VERBOSE, F("build")); - uint16_t crc = 0xffff, crcRcv = 0x0000; + DPRINTLN(DBG_VERBOSE, F("build")); + /*uint16_t crc = 0xffff, crcRcv = 0x0000; if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES) mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; - - // check if all fragments are there - *complete = true; - for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { - if(mPayload[id].len[i] == 0) - *complete = false; + */ + // check if all messages are there + + *complete = mPayload[id].complete; + uint8_t txCmd = mPayload[id].txCmd; + //uint8_t cmd = getQueuedCmd(); + if(!*complete) { + //if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 ) + // return false; + DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX)); } - if(!*complete) - return false; - for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { + /*for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { if (mPayload[id].len[i] > 0) { if (i == (mPayload[id].maxPackId - 1)) { crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc); @@ -544,26 +568,41 @@ class MiPayload { mPayload[id].lastFound = false;*/ mPayload[id].retransmits = 0; mPayload[id].complete = false; + mPayload[id].dataAB[0] = true; //only required for 2CH devices + mPayload[id].dataAB[1] = true; mPayload[id].txCmd = 0; mPayload[id].requested = false; mPayload[id].ts = *mTimestamp; - mPayload[id].sts[] = (0); + //mPayload[id].sts[0] = 0; + mPayload[id].sts[1] = 0; + mPayload[id].sts[2] = 0; + mPayload[id].sts[3] = 0; + mPayload[id].sts[4] = 0; } - template +/* template static T calcMiSts(Inverter<> *iv) { if(NULL != iv) { T result = 0; + bool stsComplete = true; + uint8_t stsCh; for(uint8_t i = 1; i <= iv->channels; i++) { - uint8_t sChState = mPayload[iv->id].sts[i]; - if (!sChState && !result || sChState && sChState < result) { - result = sChState; + stsCh = mPayload[iv->id].sts[i]; + if (!stsCh) { + stsComplete = false; + } else if ( !result || stsCh < result ) { + result = stsCh; + if (stsComplete && stsCh > stsComplete) { + stsComplete = stsCh; + } + } } + mPayload[iv->id].sts[0] = stsComplete; return result; } return 0; - } + } */ IApp *mApp; HMSYSTEM *mSys; From 0026b2e5b38b9f59372f8fc0d11c56f422446b52 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 12:29:50 +0100 Subject: [PATCH 07/26] Delete hmInverter.h ...wrong place --- hmInverter.h | 689 --------------------------------------------------- 1 file changed, 689 deletions(-) delete mode 100644 hmInverter.h diff --git a/hmInverter.h b/hmInverter.h deleted file mode 100644 index 175c6177..00000000 --- a/hmInverter.h +++ /dev/null @@ -1,689 +0,0 @@ -//----------------------------------------------------------------------------- -// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778 -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ -//----------------------------------------------------------------------------- - -#ifndef __HM_INVERTER_H__ -#define __HM_INVERTER_H__ - -#if defined(ESP32) && defined(F) - #undef F - #define F(sl) (sl) -#endif - -#include "hmDefines.h" -#include -#include -#include "../config/settings.h" - -/** - * For values which are of interest and not transmitted by the inverter can be - * calculated automatically. - * A list of functions can be linked to the assignment and will be executed - * automatically. Their result does not differ from original read values. - */ - -// forward declaration of class -template -class Inverter; - - -// prototypes -template -static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0); - -template -static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0); - -template -static T calcUdcCh(Inverter<> *iv, uint8_t arg0); - -template -static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0); - -template -static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0); - -template -static T calcIrradiation(Inverter<> *iv, uint8_t arg0); - -template -using func_t = T (Inverter<> *, uint8_t); - -template -struct calcFunc_t { - uint8_t funcId; // unique id - func_t* func; // function pointer -}; - -template -struct record_t { - byteAssign_t* assign; // assigment of bytes in payload - uint8_t length; // length of the assignment list - T *record; // data pointer - uint32_t ts; // timestamp of last received payload - uint8_t pyldLen; // expected payload length for plausibility check -}; - -class CommandAbstract { - public: - CommandAbstract(uint8_t txType = 0, uint8_t cmd = 0) { - _TxType = txType; - _Cmd = cmd; - }; - virtual ~CommandAbstract() {}; - - const uint8_t getCmd() { - return _Cmd; - } - - protected: - uint8_t _TxType; - uint8_t _Cmd; -}; - -class InfoCommand : public CommandAbstract { - public: - InfoCommand(uint8_t cmd){ - _TxType = 0x15; - _Cmd = cmd; - } -}; - -class MiInfoCommand : public CommandAbstract { - public: - MiInfoCommand(uint8_t cmd){ - _TxType = cmd; - _Cmd = cmd; - } -}; -// list of all available functions, mapped in hmDefines.h -template -const calcFunc_t calcFunctions[] = { - { CALC_YT_CH0, &calcYieldTotalCh0 }, - { CALC_YD_CH0, &calcYieldDayCh0 }, - { CALC_UDC_CH, &calcUdcCh }, - { CALC_PDC_CH0, &calcPowerDcCh0 }, - { CALC_EFF_CH0, &calcEffiencyCh0 }, - { CALC_IRR_CH, &calcIrradiation } -}; - - -template -class Inverter { - public: - uint8_t ivGen; // generation of inverter (HM / MI) - cfgIv_t *config; // stored settings - uint8_t id; // unique id - uint8_t type; // integer which refers to inverter type - uint16_t alarmMesIndex; // Last recorded Alarm Message Index - uint16_t powerLimit[2]; // limit power output - float actPowerLimit; // actual power limit - uint8_t devControlCmd; // carries the requested cmd - serial_u radioId; // id converted to modbus - uint8_t channels; // number of PV channels (1-4) - record_t recordMeas; // structure for measured values - record_t recordInfo; // structure for info values - record_t recordConfig; // structure for system config values - record_t recordAlarm; // structure for alarm values - //String lastAlarmMsg; - bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null) - bool isConnected; // shows if inverter was successfully identified (fw version and hardware info) - - Inverter() { - ivGen = IV_HM; - powerLimit[0] = 0xffff; // 65535 W Limit -> unlimited - powerLimit[1] = AbsolutNonPersistent; // default power limit setting - actPowerLimit = 0xffff; // init feedback from inverter to -1 - mDevControlRequest = false; - devControlCmd = InitDataState; - initialized = false; - //lastAlarmMsg = "nothing"; - alarmMesIndex = 0; - isConnected = false; - } - - ~Inverter() { - // TODO: cleanup - } - - template - void enqueCommand(uint8_t cmd) { - _commandQueue.push(std::make_shared(cmd)); - DPRINTLN(DBG_INFO, F("(#") + String(id) + F(") enqueuedCmd: 0x") + String(cmd, HEX)); - } - - void setQueuedCmdFinished() { - if (!_commandQueue.empty()) { - // Will destroy CommandAbstract Class Object (?) - _commandQueue.pop(); - } - } - - void clearCmdQueue() { - DPRINTLN(DBG_INFO, F("clearCmdQueue")); - while (!_commandQueue.empty()) { - // Will destroy CommandAbstract Class Object (?) - _commandQueue.pop(); - } - } - - uint8_t getQueuedCmd() { - if (_commandQueue.empty()) { - if (ivGen != IV_MI) { - if (getFwVersion() == 0) - enqueCommand(InverterDevInform_All); // firmware version - enqueCommand(RealTimeRunData_Debug); // live data - } else if (ivGen == IV_MI){ - if (type == INV_TYPE_4CH) { - enqueCommand(0x36); - /*for(uint8_t i = 0x36; i <= 0x39; i++) { - enqueCommand(i); // live data - }*/ - } else if (type == INV_TYPE_2CH) { - enqueCommand(0x09); - //enqueCommand(0x11); - } else if (type == INV_TYPE_1CH) { - enqueCommand(0x09); - } - //if (getFwVersion() == 0) - // enqueCommand(InverterDevInform_All); // firmware version, might not work, esp. for 1/2 ch hardware - } - - if ((actPowerLimit == 0xffff) && isConnected) - enqueCommand(SystemConfigPara); // power limit info - } - return _commandQueue.front().get()->getCmd(); - } - - - void init(void) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:init")); - initAssignment(&recordMeas, RealTimeRunData_Debug); - initAssignment(&recordInfo, InverterDevInform_All); - initAssignment(&recordConfig, SystemConfigPara); - initAssignment(&recordAlarm, AlarmData); - toRadioId(); - initialized = true; - } - - uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId, record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getPosByChFld")); - uint8_t pos = 0; - if(NULL != rec) { - for(; pos < rec->length; pos++) { - if((rec->assign[pos].ch == channel) && (rec->assign[pos].fieldId == fieldId)) - break; - } - return (pos >= rec->length) ? 0xff : pos; - } - else - return 0xff; - } - - byteAssign_t *getByteAssign(uint8_t pos, record_t<> *rec) { - return &rec->assign[pos]; - } - - const char *getFieldName(uint8_t pos, record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getFieldName")); - if(NULL != rec) - return fields[rec->assign[pos].fieldId]; - return notAvail; - } - - const char *getUnit(uint8_t pos, record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getUnit")); - if(NULL != rec) - return units[rec->assign[pos].unitId]; - return notAvail; - } - - uint8_t getChannel(uint8_t pos, record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getChannel")); - if(NULL != rec) - return rec->assign[pos].ch; - return 0; - } - - bool setDevControlRequest(uint8_t cmd) { - if(isConnected) { - mDevControlRequest = true; - devControlCmd = cmd; - } - return isConnected; - } - - void clearDevControlRequest() { - mDevControlRequest = false; - } - - inline bool getDevControlRequest() { - return mDevControlRequest; - } - - void addValue(uint8_t pos, uint8_t buf[], record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:addValue")); - if(NULL != rec) { - uint8_t ptr = rec->assign[pos].start; - uint8_t end = ptr + rec->assign[pos].num; - uint16_t div = rec->assign[pos].div; - - if(NULL != rec) { - if(CMD_CALC != div) { - uint32_t val = 0; - do { - val <<= 8; - val |= buf[ptr]; - } while(++ptr != end); - if (FLD_T == rec->assign[pos].fieldId) { - // temperature is a signed value! - rec->record[pos] = (REC_TYP)((int16_t)val) / (REC_TYP)(div); - } else if (FLD_YT == rec->assign[pos].fieldId) { - rec->record[pos] = ((REC_TYP)(val) / (REC_TYP)(div)) + ((REC_TYP)config->yieldCor[rec->assign[pos].ch-1]); - } else { - if ((REC_TYP)(div) > 1) - rec->record[pos] = (REC_TYP)(val) / (REC_TYP)(div); - else - rec->record[pos] = (REC_TYP)(val); - } - } - } - - if(rec == &recordMeas) { - DPRINTLN(DBG_VERBOSE, "add real time"); - - // get last alarm message index and save it in the inverter object - if (getPosByChFld(0, FLD_EVT, rec) == pos){ - if (alarmMesIndex < rec->record[pos]){ - alarmMesIndex = rec->record[pos]; - //enqueCommand(AlarmUpdate); // What is the function of AlarmUpdate? - - DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(alarmMesIndex)); - enqueCommand(AlarmData); - } - } - } - else if (rec->assign == InfoAssignment) { - DPRINTLN(DBG_DEBUG, "add info"); - // eg. fw version ... - isConnected = true; - } - else if (rec->assign == SystemConfigParaAssignment) { - DPRINTLN(DBG_DEBUG, "add config"); - if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){ - actPowerLimit = rec->record[pos]; - DPRINT(DBG_DEBUG, F("Inverter actual power limit: ") + String(actPowerLimit, 1)); - } - } - else if (rec->assign == AlarmDataAssignment) { - DPRINTLN(DBG_DEBUG, "add alarm"); - //if (getPosByChFld(0, FLD_LAST_ALARM_CODE, rec) == pos){ - // lastAlarmMsg = getAlarmStr(rec->record[pos]); - //} - } - else - DPRINTLN(DBG_WARN, F("add with unknown assginment")); - } - else - DPRINTLN(DBG_ERROR, F("addValue: assignment not found with cmd 0x")); - } - - /*inline REC_TYP getPowerLimit(void) { - record_t<> *rec = getRecordStruct(SystemConfigPara); - return getChannelFieldValue(CH0, FLD_ACT_ACTIVE_PWR_LIMIT, rec); - }*/ - - bool setValue(uint8_t pos, record_t<> *rec, REC_TYP val) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:setValue")); - if(NULL == rec) - return false; - if(pos > rec->length) - return false; - rec->record[pos] = val; - return true; - } - - REC_TYP getChannelFieldValue(uint8_t channel, uint8_t fieldId, record_t<> *rec) { - uint8_t pos = 0; - if(NULL != rec) { - for(; pos < rec->length; pos++) { - if((rec->assign[pos].ch == channel) && (rec->assign[pos].fieldId == fieldId)) - break; - } - if(pos >= rec->length) - return 0; - - return rec->record[pos]; - } - else - return 0; - } - - REC_TYP getValue(uint8_t pos, record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getValue")); - if(NULL == rec) - return 0; - if(pos > rec->length) - return 0; - return rec->record[pos]; - } - - void doCalculations() { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:doCalculations")); - record_t<> *rec = getRecordStruct(RealTimeRunData_Debug); - for(uint8_t i = 0; i < rec->length; i++) { - if(CMD_CALC == rec->assign[i].div) { - rec->record[i] = calcFunctions[rec->assign[i].start].func(this, rec->assign[i].num); - } - yield(); - } - } - - bool isAvailable(uint32_t timestamp) { - if((timestamp - recordMeas.ts) < INACT_THRES_SEC) - return true; - if((timestamp - recordInfo.ts) < INACT_THRES_SEC) - return true; - if((timestamp - recordConfig.ts) < INACT_THRES_SEC) - return true; - if((timestamp - recordAlarm.ts) < INACT_THRES_SEC) - return true; - return false; - } - - bool isProducing(uint32_t timestamp) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:isProducing")); - if(isAvailable(timestamp)) { - uint8_t pos = getPosByChFld(CH0, FLD_PAC, &recordMeas); - return (getValue(pos, &recordMeas) > INACT_PWR_THRESH); - } - return false; - } - - uint16_t getFwVersion() { - record_t<> *rec = getRecordStruct(InverterDevInform_All); - uint8_t pos = getPosByChFld(CH0, FLD_FW_VERSION, rec); - return getValue(pos, rec); - } - - uint32_t getLastTs(record_t<> *rec) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:getLastTs")); - return rec->ts; - } - - record_t<> *getRecordStruct(uint8_t cmd) { - switch (cmd) { - case RealTimeRunData_Debug: return &recordMeas; // 11 = 0x0b - case InverterDevInform_All: return &recordInfo; // 1 = 0x01 - case SystemConfigPara: return &recordConfig; // 5 = 0x05 - case AlarmData: return &recordAlarm; // 17 = 0x11 - default: break; - } - return NULL; - } - - void initAssignment(record_t<> *rec, uint8_t cmd) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:initAssignment")); - rec->ts = 0; - rec->length = 0; - switch (cmd) { - case RealTimeRunData_Debug: - if (INV_TYPE_1CH == type) { - rec->length = (uint8_t)(HM1CH_LIST_LEN); - rec->assign = (byteAssign_t *)hm1chAssignment; - rec->pyldLen = HM1CH_PAYLOAD_LEN; - channels = 1; - } - else if (INV_TYPE_2CH == type) { - rec->length = (uint8_t)(HM2CH_LIST_LEN); - rec->assign = (byteAssign_t *)hm2chAssignment; - rec->pyldLen = HM2CH_PAYLOAD_LEN; - channels = 2; - } - else if (INV_TYPE_4CH == type) { - rec->length = (uint8_t)(HM4CH_LIST_LEN); - rec->assign = (byteAssign_t *)hm4chAssignment; - rec->pyldLen = HM4CH_PAYLOAD_LEN; - channels = 4; - } - else { - rec->length = 0; - rec->assign = NULL; - rec->pyldLen = 0; - channels = 0; - } - break; - case InverterDevInform_All: - rec->length = (uint8_t)(HMINFO_LIST_LEN); - rec->assign = (byteAssign_t *)InfoAssignment; - rec->pyldLen = HMINFO_PAYLOAD_LEN; - break; - case SystemConfigPara: - rec->length = (uint8_t)(HMSYSTEM_LIST_LEN); - rec->assign = (byteAssign_t *)SystemConfigParaAssignment; - rec->pyldLen = HMSYSTEM_PAYLOAD_LEN; - break; - case AlarmData: - rec->length = (uint8_t)(HMALARMDATA_LIST_LEN); - rec->assign = (byteAssign_t *)AlarmDataAssignment; - rec->pyldLen = HMALARMDATA_PAYLOAD_LEN; - break; - default: - DPRINTLN(DBG_INFO, F("initAssignment: Parser not implemented")); - break; - } - - if(0 != rec->length) { - rec->record = new REC_TYP[rec->length]; - memset(rec->record, 0, sizeof(REC_TYP) * rec->length); - } - } - - uint16_t parseAlarmLog(uint8_t id, uint8_t pyld[], uint8_t len, uint32_t *start, uint32_t *endTime) { - uint8_t startOff = 2 + id * ALARM_LOG_ENTRY_SIZE; - if((startOff + ALARM_LOG_ENTRY_SIZE) > len) - return 0; - - uint16_t wCode = ((uint16_t)pyld[startOff]) << 8 | pyld[startOff+1]; - uint32_t startTimeOffset = 0, endTimeOffset = 0; - - if (((wCode >> 13) & 0x01) == 1) // check if is AM or PM - startTimeOffset = 12 * 60 * 60; - if (((wCode >> 12) & 0x01) == 1) // check if is AM or PM - endTimeOffset = 12 * 60 * 60; - - *start = (((uint16_t)pyld[startOff + 4] << 8) | ((uint16_t)pyld[startOff + 5])) + startTimeOffset; - *endTime = (((uint16_t)pyld[startOff + 6] << 8) | ((uint16_t)pyld[startOff + 7])) + endTimeOffset; - - DPRINTLN(DBG_INFO, "Alarm #" + String(pyld[startOff+1]) + " '" + String(getAlarmStr(pyld[startOff+1])) + "' start: " + ah::getTimeStr(*start) + ", end: " + ah::getTimeStr(*endTime)); - return pyld[startOff+1]; - } - - String getAlarmStr(uint16_t alarmCode) { - switch (alarmCode) { // breaks are intentionally missing! - case 1: return String(F("Inverter start")); - case 2: return String(F("DTU command failed")); - case 121: return String(F("Over temperature protection")); - case 125: return String(F("Grid configuration parameter error")); - case 126: return String(F("Software error code 126")); - case 127: return String(F("Firmware error")); - case 128: return String(F("Software error code 128")); - case 129: return String(F("Software error code 129")); - case 130: return String(F("Offline")); - case 141: return String(F("Grid overvoltage")); - case 142: return String(F("Average grid overvoltage")); - case 143: return String(F("Grid undervoltage")); - case 144: return String(F("Grid overfrequency")); - case 145: return String(F("Grid underfrequency")); - case 146: return String(F("Rapid grid frequency change")); - case 147: return String(F("Power grid outage")); - case 148: return String(F("Grid disconnection")); - case 149: return String(F("Island detected")); - case 205: return String(F("Input port 1 & 2 overvoltage")); - case 206: return String(F("Input port 3 & 4 overvoltage")); - case 207: return String(F("Input port 1 & 2 undervoltage")); - case 208: return String(F("Input port 3 & 4 undervoltage")); - case 209: return String(F("Port 1 no input")); - case 210: return String(F("Port 2 no input")); - case 211: return String(F("Port 3 no input")); - case 212: return String(F("Port 4 no input")); - case 213: return String(F("PV-1 & PV-2 abnormal wiring")); - case 214: return String(F("PV-3 & PV-4 abnormal wiring")); - case 215: return String(F("PV-1 Input overvoltage")); - case 216: return String(F("PV-1 Input undervoltage")); - case 217: return String(F("PV-2 Input overvoltage")); - case 218: return String(F("PV-2 Input undervoltage")); - case 219: return String(F("PV-3 Input overvoltage")); - case 220: return String(F("PV-3 Input undervoltage")); - case 221: return String(F("PV-4 Input overvoltage")); - case 222: return String(F("PV-4 Input undervoltage")); - case 301: return String(F("Hardware error code 301")); - case 302: return String(F("Hardware error code 302")); - case 303: return String(F("Hardware error code 303")); - case 304: return String(F("Hardware error code 304")); - case 305: return String(F("Hardware error code 305")); - case 306: return String(F("Hardware error code 306")); - case 307: return String(F("Hardware error code 307")); - case 308: return String(F("Hardware error code 308")); - case 309: return String(F("Hardware error code 309")); - case 310: return String(F("Hardware error code 310")); - case 311: return String(F("Hardware error code 311")); - case 312: return String(F("Hardware error code 312")); - case 313: return String(F("Hardware error code 313")); - case 314: return String(F("Hardware error code 314")); - case 5041: return String(F("Error code-04 Port 1")); - case 5042: return String(F("Error code-04 Port 2")); - case 5043: return String(F("Error code-04 Port 3")); - case 5044: return String(F("Error code-04 Port 4")); - case 5051: return String(F("PV Input 1 Overvoltage/Undervoltage")); - case 5052: return String(F("PV Input 2 Overvoltage/Undervoltage")); - case 5053: return String(F("PV Input 3 Overvoltage/Undervoltage")); - case 5054: return String(F("PV Input 4 Overvoltage/Undervoltage")); - case 5060: return String(F("Abnormal bias")); - case 5070: return String(F("Over temperature protection")); - case 5080: return String(F("Grid Overvoltage/Undervoltage")); - case 5090: return String(F("Grid Overfrequency/Underfrequency")); - case 5100: return String(F("Island detected")); - case 5120: return String(F("EEPROM reading and writing error")); - case 5150: return String(F("10 min value grid overvoltage")); - case 5200: return String(F("Firmware error")); - case 8310: return String(F("Shut down")); - case 9000: return String(F("Microinverter is suspected of being stolen")); - default: return String(F("Unknown")); - } - } - - private: - void toRadioId(void) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:toRadioId")); - radioId.u64 = 0ULL; - radioId.b[4] = config->serial.b[0]; - radioId.b[3] = config->serial.b[1]; - radioId.b[2] = config->serial.b[2]; - radioId.b[1] = config->serial.b[3]; - radioId.b[0] = 0x01; - } - - std::queue> _commandQueue; - bool mDevControlRequest; // true if change needed -}; - - -/** - * To calculate values which are not transmitted by the unit there is a generic - * list of functions which can be linked to the assignment. - * The special command 0xff (CMDFF) must be used. - */ - -template -static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldTotalCh0")); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - T yield = 0; - for(uint8_t i = 1; i <= iv->channels; i++) { - uint8_t pos = iv->getPosByChFld(i, FLD_YT, rec); - yield += iv->getValue(pos, rec); - } - return yield; - } - return 0.0; -} - -template -static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldDayCh0")); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - T yield = 0; - for(uint8_t i = 1; i <= iv->channels; i++) { - uint8_t pos = iv->getPosByChFld(i, FLD_YD, rec); - yield += iv->getValue(pos, rec); - } - return yield; - } - return 0.0; -} - -template -static T calcUdcCh(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcUdcCh")); - // arg0 = channel of source - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - for(uint8_t i = 0; i < rec->length; i++) { - if((FLD_UDC == rec->assign[i].fieldId) && (arg0 == rec->assign[i].ch)) { - return iv->getValue(i, rec); - } - } - - return 0.0; -} - -template -static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcPowerDcCh0")); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - T dcPower = 0; - for(uint8_t i = 1; i <= iv->channels; i++) { - uint8_t pos = iv->getPosByChFld(i, FLD_PDC, rec); - dcPower += iv->getValue(pos, rec); - } - return dcPower; - } - return 0.0; -} - -template -static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcEfficiencyCh0")); - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - uint8_t pos = iv->getPosByChFld(CH0, FLD_PAC, rec); - T acPower = iv->getValue(pos, rec); - T dcPower = 0; - for(uint8_t i = 1; i <= iv->channels; i++) { - pos = iv->getPosByChFld(i, FLD_PDC, rec); - dcPower += iv->getValue(pos, rec); - } - if(dcPower > 0) - return acPower / dcPower * 100.0f; - } - return 0.0; -} - -template -static T calcIrradiation(Inverter<> *iv, uint8_t arg0) { - DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcIrradiation")); - // arg0 = channel - if(NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - uint8_t pos = iv->getPosByChFld(arg0, FLD_PDC, rec); - if(iv->config->chMaxPwr[arg0-1] > 0) - return iv->getValue(pos, rec) / iv->config->chMaxPwr[arg0-1] * 100.0f; - } - return 0.0; -} - -#endif /*__HM_INVERTER_H__*/ From b973d61d0451d6b9d6b880eef33ebee926dcb7d0 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 12:30:05 +0100 Subject: [PATCH 08/26] Delete miPayload.h ...wrong place --- miPayload.h | 620 ---------------------------------------------------- 1 file changed, 620 deletions(-) delete mode 100644 miPayload.h diff --git a/miPayload.h b/miPayload.h deleted file mode 100644 index ae750710..00000000 --- a/miPayload.h +++ /dev/null @@ -1,620 +0,0 @@ -//----------------------------------------------------------------------------- -// 2023 Ahoy, https://ahoydtu.de -// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ -//----------------------------------------------------------------------------- - -#ifndef __MI_PAYLOAD_H__ -#define __MI_PAYLOAD_H__ - -//#include "hmInverter.h" -#include "../utils/dbg.h" -#include "../utils/crc.h" -#include "../config/config.h" -#include - -typedef struct { - uint32_t ts; - bool requested; - uint8_t txCmd; - uint8_t len[MAX_PAYLOAD_ENTRIES]; - bool complete; - bool dataAB[2]; - uint8_t sts[5]; - uint8_t txId; - uint8_t invId; - uint8_t retransmits; - /* - uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE]; - - uint8_t maxPackId; - bool lastFound; - bool gotFragment;*/ -} miPayload_t; - - -typedef std::function miPayloadListenerType; - - -template -class MiPayload { - public: - MiPayload() {} - - void setup(IApp *app, HMSYSTEM *sys, statistics_t *stat, uint8_t maxRetransmits, uint32_t *timestamp) { - mApp = app; - mSys = sys; - mStat = stat; - mMaxRetrans = maxRetransmits; - mTimestamp = timestamp; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - reset(i); - } - mSerialDebug = false; - mHighPrioIv = NULL; - mCbMiPayload = NULL; - } - - void enableSerialDebug(bool enable) { - mSerialDebug = enable; - } - - void addPayloadListener(miPayloadListenerType cb) { - mCbMiPayload = cb; - } - - void addAlarmListener(alarmListenerType cb) { - mCbMiAlarm = cb; - } - - void loop() { - /*if(NULL != mHighPrioIv) { - iv->ivSend(mHighPrioIv, true); // should request firmware version etc.? - mHighPrioIv = NULL; - }*/ - } - - void ivSendHighPrio(Inverter<> *iv) { - mHighPrioIv = iv; - } - - void ivSend(Inverter<> *iv) { - reset(iv->id); - mPayload[iv->id].requested = true; - - yield(); - if (mSerialDebug) - DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX)); - - //first channel request - /*uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; - DPRINT(DBG_INFO, F("(#")); - DBGPRINT(String(iv->id)); - DBGPRINT(F(") prepareDevInformCmd 0x")); - DBGPRINTLN(String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd;*/ - - uint8_t cmd = iv->getQueuedCmd(); - DPRINT(DBG_INFO, F("(#")); - DBGPRINT(String(iv->id)); - DBGPRINT(F(") prepareDevInformCmd 0x")); - DBGPRINTLN(String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - //other channel requests - /*if (iv->type == INV_TYPE_4CH) { - for(uint8_t i = 1; i < iv->channels; i++) { - iv->enqueCommand(cmd + i, cmd + i); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd + i); - } - } else */ - if (iv->type == INV_TYPE_2CH) { - mPayload[iv->id].dataAB[0] = false; - mPayload[iv->id].dataAB[1] = false; - //iv->enqueCommand(0x11); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - } - } - - void add(Inverter<> *iv, packet_t *p) { - //DPRINTLN(DBG_INFO, F("MI got data [0]=") + String(p->packet[0], HEX)); - - if (p->packet[0] == (0x08 + ALL_FRAMES)) { // 0x88; MI status response to 0x09 - //mPayload[iv->id].sts[0] = true; - miStsDecode(iv, p); - } else if (p->packet[0] == (0x11 + SINGLE_FRAME)) { // 0x92; MI status response to 0x11 - //mPayload[iv->id].sts[1] = true; - miStsDecode(iv, p, CH2); - /*} else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 - mPayload[iv->id].txId = p->packet[0]; - miDataDecode(iv,p); - //iv->setQueuedCmdFinished(); - if (INV_TYPE_2CH == iv->type) { - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - } else { // additional check for mPayload[iv->id].stsa == true might be a good idea (request retransmit?) - mPayload[iv->id].complete = true; - //iv->setQueuedCmdFinished(); - } - - } else if (p->packet[0] == ()) { // MI data response to 0x11 - mPayload[iv->id].txId = p->packet[0]; - miDataDecode(iv,p); - mStat->rxSuccess++; - //iv->setQueuedCmdFinished();*/ - - } else if ( p->packet[0] == 0x09 + ALL_FRAMES || - p->packet[0] == 0x11 + ALL_FRAMES || - ( p->packet[0] >= (0x36 + ALL_FRAMES) && p->packet[0] < (0x39 + SINGLE_FRAME) ) ) { // small MI or MI 1500 data responses to 0x09, 0x11, 0x36, 0x37, 0x38 and 0x39 - mPayload[iv->id].txId = p->packet[0]; - miDataDecode(iv,p); - //mStat->rxSuccess++; - //iv->setQueuedCmdFinished(); - /*if (p->packet[0] < (0x39 + ALL_FRAMES)) { - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, p->packet[0] + 1 - ALL_FRAMES, mPayload[iv->id].ts, iv->alarmMesIndex, false, p->packet[0] + 1 - ALL_FRAMES); - } else { - mPayload[iv->id].complete = true; - //iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, CALC_YD_CH0); - //iv->setQueuedCmdFinished(); - }*/ - - //} - - /*if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command - mPayload[iv->id].txId = p->packet[0]; - DPRINTLN(DBG_DEBUG, F("Response from info request received")); - uint8_t *pid = &p->packet[9]; - if (*pid == 0x00) { - DPRINT(DBG_DEBUG, F("fragment number zero received and ignored")); - } else { - DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX)); - if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) { - memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11); - mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11; - mPayload[iv->id].gotFragment = true; - } - - if ((*pid & ALL_FRAMES) == ALL_FRAMES) { - // Last packet - if (((*pid & 0x7f) > mPayload[iv->id].maxPackId) || (MAX_PAYLOAD_ENTRIES == mPayload[iv->id].maxPackId)) { - mPayload[iv->id].maxPackId = (*pid & 0x7f); - if (*pid > 0x81) - mPayload[iv->id].lastFound = true; - } - } - } - } */ - } else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command - DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received")); - - mPayload[iv->id].txId = p->packet[0]; - iv->clearDevControlRequest(); - - if ((p->packet[12] == ActivePowerContr) && (p->packet[13] == 0x00)) { - String msg = ""; - if((p->packet[10] == 0x00) && (p->packet[11] == 0x00)) - mApp->setMqttPowerLimitAck(iv); - else - msg = "NOT "; - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has ") + msg + F("accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1])); - iv->clearCmdQueue(); - iv->enqueCommand(SystemConfigPara); // read back power limit - } - iv->devControlCmd = Init; - } else { // some other response; copied from hmPayload:process; might not be correct to do that here!!! - DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX)); - DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX)); - //DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); - record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser - mPayload[iv->id].complete = true; - - uint8_t payload[128]; - uint8_t payloadLen = 0; - - memset(payload, 0, 128); - - /*for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) { - memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i])); - payloadLen += (mPayload[iv->id].len[i]); - yield(); - }*/ - payloadLen -= 2; - - if (mSerialDebug) { - DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): "); - mSys->Radio.dumpBuf(payload, payloadLen); - } - - if (NULL == rec) { - DPRINTLN(DBG_ERROR, F("record is NULL!")); - } else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) { - if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES)) - mStat->rxSuccess++; - - rec->ts = mPayload[iv->id].ts; - for (uint8_t i = 0; i < rec->length; i++) { - iv->addValue(i, payload, rec); - yield(); - } - iv->doCalculations(); - notify(mPayload[iv->id].txCmd); - - if(AlarmData == mPayload[iv->id].txCmd) { - uint8_t i = 0; - uint16_t code; - uint32_t start, end; - while(1) { - code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); - if(0 == code) - break; - if (NULL != mCbMiAlarm) - (mCbMiAlarm)(code, start, end); - yield(); - } - } - } else { - DPRINTLN(DBG_ERROR, F("plausibility check failed, expected ") + String(rec->pyldLen) + F(" bytes")); - mStat->rxFail++; - } - - iv->setQueuedCmdFinished(); - } - } - - void process(bool retransmit) { - for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { - Inverter<> *iv = mSys->getInverterByPos(id); - if (NULL == iv) - continue; // skip to next inverter - - if (IV_HM == iv->ivGen) // only process MI inverters - continue; // skip to next inverter - - /*if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) { - // no processing needed if txId is not 0x95 - mPayload[iv->id].complete = true; - continue; // skip to next inverter - }*/ - - if (!mPayload[iv->id].complete) { - bool crcPass, pyldComplete; - crcPass = build(iv->id, &pyldComplete); - if (!crcPass && !pyldComplete) { // payload not complete - if ((mPayload[iv->id].requested) && (retransmit)) { - if (iv->devControlCmd == Restart || iv->devControlCmd == CleanState_LockAndAlarm) { - // This is required to prevent retransmissions without answer. - DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm...")); - mPayload[iv->id].retransmits = mMaxRetrans; - } else if(iv->devControlCmd == ActivePowerContr) { - DPRINTLN(DBG_INFO, F("retransmit power limit")); - mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true); - } else { - if (mPayload[iv->id].retransmits < mMaxRetrans) { - mPayload[iv->id].retransmits++; - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - DPRINTLN(DBG_WARN, F("missing answer to 0x") + String(iv->getQueuedCmd(), HEX) + F("Request Retransmit")); - mSys->Radio.sendCmdPacket(iv->radioId.u64, iv->getQueuedCmd(), 24, true); - /*if(false == mPayload[iv->id].gotFragment) { - DPRINTLN(DBG_WARN, F("(#") + String(iv->id) + F(") nothing received")); - mPayload[iv->id].retransmits = mMaxRetrans; - } else { - for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) { - if (mPayload[iv->id].len[i] == 0) { - DPRINTLN(DBG_WARN, F("Frame ") + String(i + 1) + F(" missing: Request Retransmit")); - mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true); - break; // only request retransmit one frame per loop - } - yield(); - } - }*/ - } - } - } - } else if(!crcPass && pyldComplete) { // crc error on complete Payload - if (mPayload[iv->id].retransmits < mMaxRetrans) { - mPayload[iv->id].retransmits++; - DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit")); - mPayload[iv->id].txCmd = iv->getQueuedCmd(); - DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); - } - } /*else { // payload complete - DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX)); - DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX)); - DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); - record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser - mPayload[iv->id].complete = true; - - uint8_t payload[128]; - uint8_t payloadLen = 0; - - memset(payload, 0, 128); - - for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) { - memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i])); - payloadLen += (mPayload[iv->id].len[i]); - yield(); - } - payloadLen -= 2; - - if (mSerialDebug) { - DPRINT(DBG_INFO, F("Payload (") + String(payloadLen) + "): "); - mSys->Radio.dumpBuf(payload, payloadLen); - } - - if (NULL == rec) { - DPRINTLN(DBG_ERROR, F("record is NULL!")); - } else if ((rec->pyldLen == payloadLen) || (0 == rec->pyldLen)) { - if (mPayload[iv->id].txId == (TX_REQ_INFO + ALL_FRAMES)) - mStat->rxSuccess++; - - rec->ts = mPayload[iv->id].ts; - for (uint8_t i = 0; i < rec->length; i++) { - iv->addValue(i, payload, rec); - yield(); - } - iv->doCalculations(); - notify(mPayload[iv->id].txCmd); - - if(AlarmData == mPayload[iv->id].txCmd) { - uint8_t i = 0; - uint16_t code; - uint32_t start, end; - while(1) { - code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); - if(0 == code) - break; - if (NULL != mCbAlarm) - (mCbAlarm)(code, start, end); - yield(); - } - } - } else { - DPRINTLN(DBG_ERROR, F("plausibility check failed, expected ") + String(rec->pyldLen) + F(" bytes")); - mStat->rxFail++; - } - - iv->setQueuedCmdFinished(); - }*/ - } - yield(); - } - } - - private: - void notify(uint8_t val) { - if(NULL != mCbMiPayload) - (mCbMiPayload)(val); - } - - void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t chan = CH1) { - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": status msg 0x") + String(p->packet[0], HEX)); - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure - rec->ts = mPayload[iv->id].ts; - - uint8_t status = (p->packet[11] << 8) + p->packet[12]; - uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2; - mPayload[iv->id].dataAB[stschan-1] = true; - mPayload[iv->id].sts[stschan] = status; - if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { - mPayload[iv->id].sts[0] = status; - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); - } - - if ( !mPayload[iv->id].dataAB[0] || !mPayload[iv->id].dataAB[1] ) { - uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; - DPRINTLN(DBG_INFO, F("request missing status 0x") + String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - } - - if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ - iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? - - DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); - } - } - - void miDataDecode(Inverter<> *iv, packet_t *p) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser - rec->ts = mPayload[iv->id].ts; - - uint8_t datachan = ( p->packet[0] == 0x89 || p->packet[0] == (0x36 + ALL_FRAMES) ) ? CH1 : - ( p->packet[0] == 0x91 || p->packet[0] == (0x37 + ALL_FRAMES) ) ? CH2 : - p->packet[0] == (0x38 + ALL_FRAMES) ? CH3 : - CH4; - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); - // count in RF_communication_protocol.xlsx is with offset = -1 - iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[9] << 8) + p->packet[10])/10); - yield(); - iv->setValue(iv->getPosByChFld(datachan, FLD_IDC, rec), rec, (float)((p->packet[11] << 8) + p->packet[12])/10); - yield(); - iv->setValue(iv->getPosByChFld(0, FLD_UAC, rec), rec, (float)((p->packet[13] << 8) + p->packet[14])/10); - yield(); - iv->setValue(iv->getPosByChFld(0, FLD_F, rec), rec, (float) ((p->packet[15] << 8) + p->packet[16])/100); - iv->setValue(iv->getPosByChFld(datachan, FLD_PDC, rec), rec, (float)((p->packet[17] << 8) + p->packet[18])/10); - yield(); - iv->setValue(iv->getPosByChFld(datachan, FLD_YD, rec), rec, (float)((p->packet[19] << 8) + p->packet[20])/1); - yield(); - iv->setValue(iv->getPosByChFld(0, FLD_T, rec), rec, (float) ((int16_t)(p->packet[21] << 8) + p->packet[22])/10); - iv->setValue(iv->getPosByChFld(0, FLD_IRR, rec), rec, (float) (calcIrradiation(iv, datachan))); - //AC Power is missing; we may have to calculate, as no respective data is in payload - - if (p->packet[0] >= (0x36 + ALL_FRAMES) ) { - - /*For MI1500: - if (MI1500) { - STAT = (uint8_t)(p->packet[25] ); - FCNT = (uint8_t)(p->packet[26]); - FCODE = (uint8_t)(p->packet[27]); - }*/ - - uint8_t status = (uint8_t)(p->packet[23]); - mPayload[iv->id].sts[datachan] = status; - if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { - mPayload[iv->id].sts[0] = status; - iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); - } - - if (p->packet[0] < (0x39 + ALL_FRAMES) ) { - uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - mPayload[iv->id].complete = false; - } - - //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); - if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ - iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; - - DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - //iv->enqueCommand(AlarmData); - } - - } - - //preliminary AC calculation... - uint8_t ac_pow = 0; - //if (mPayload[iv->id].sts[0] == 3) { - ac_pow = calcPowerDcCh0(iv, 0)*9.5; - //} - iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); - - if ( mPayload[iv->id].sts[0] ) { - uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; - if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { - mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short... - DPRINTLN(DBG_INFO, F("complete tree detected")); - iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); - iv->doCalculations(); - } else { - //retry to get missing status info for one or two channel devices - DPRINTLN(DBG_INFO, F("request missing data or status 0x") + String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - //iv->enqueCommand(cmd); // mPayload[iv->id].dataAB[1] ? 0x09 : 0x11) - } - } // not yet moved to hmInverter::getQueuedCmd - else if (mPayload[iv->id].txCmd == 0x09 && iv->type == INV_TYPE_2CH) { - uint8_t cmd = 0x11; - DPRINTLN(DBG_INFO, F("request second data channel 0x") + String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - mPayload[iv->id].complete = false; - } - - iv->setQueuedCmdFinished(); - mStat->rxSuccess++; - yield(); - - notify(mPayload[iv->id].txCmd); - -/* - if(AlarmData == mPayload[iv->id].txCmd) { - uint8_t i = 0; - uint16_t code; - uint32_t start, end; - while(1) { - code = iv->parseAlarmLog(i++, payload, payloadLen, &start, &end); - if(0 == code) - break; - if (NULL != mCbMiAlarm) - (mCbAlarm)(code, start, end); - yield(); - } - }*/ - } - - bool build(uint8_t id, bool *complete) { - DPRINTLN(DBG_VERBOSE, F("build")); - /*uint16_t crc = 0xffff, crcRcv = 0x0000; - if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES) - mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; - */ - // check if all messages are there - - *complete = mPayload[id].complete; - uint8_t txCmd = mPayload[id].txCmd; - //uint8_t cmd = getQueuedCmd(); - if(!*complete) { - //if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 ) - // return false; - DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX)); - } - - /*for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { - if (mPayload[id].len[i] > 0) { - if (i == (mPayload[id].maxPackId - 1)) { - crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc); - crcRcv = (mPayload[id].data[i][mPayload[id].len[i] - 2] << 8) | (mPayload[id].data[i][mPayload[id].len[i] - 1]); - } else - crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i], crc); - } - yield(); - } - - return (crc == crcRcv) ? true : false;*/ - return true; - } - - void reset(uint8_t id) { - DPRINTLN(DBG_INFO, "resetPayload: id: " + String(id)); - memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); - /* - mPayload[id].gotFragment = false; - mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; - mPayload[id].lastFound = false;*/ - mPayload[id].retransmits = 0; - mPayload[id].complete = false; - mPayload[id].dataAB[0] = true; //only required for 2CH devices - mPayload[id].dataAB[1] = true; - mPayload[id].txCmd = 0; - mPayload[id].requested = false; - mPayload[id].ts = *mTimestamp; - //mPayload[id].sts[0] = 0; - mPayload[id].sts[1] = 0; - mPayload[id].sts[2] = 0; - mPayload[id].sts[3] = 0; - mPayload[id].sts[4] = 0; - } - - -/* template - static T calcMiSts(Inverter<> *iv) { - if(NULL != iv) { - T result = 0; - bool stsComplete = true; - uint8_t stsCh; - for(uint8_t i = 1; i <= iv->channels; i++) { - stsCh = mPayload[iv->id].sts[i]; - if (!stsCh) { - stsComplete = false; - } else if ( !result || stsCh < result ) { - result = stsCh; - if (stsComplete && stsCh > stsComplete) { - stsComplete = stsCh; - } - } - } - mPayload[iv->id].sts[0] = stsComplete; - return result; - } - return 0; - } */ - - IApp *mApp; - HMSYSTEM *mSys; - statistics_t *mStat; - uint8_t mMaxRetrans; - uint32_t *mTimestamp; - miPayload_t mPayload[MAX_NUM_INVERTERS]; - bool mSerialDebug; - - Inverter<> *mHighPrioIv; - alarmListenerType mCbMiAlarm; - payloadListenerType mCbMiPayload; -}; - -#endif /*__MI_PAYLOAD_H__*/ From 4eed422cacf42b633d320f924bd91d59b7504ba4 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 12:30:44 +0100 Subject: [PATCH 09/26] MI - small changes --- src/hm/hmInverter.h | 4 ++-- src/hm/miPayload.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index f150628a..175c6177 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -176,7 +176,7 @@ class Inverter { enqueCommand(RealTimeRunData_Debug); // live data } else if (ivGen == IV_MI){ if (type == INV_TYPE_4CH) { - enqueCommand(0x36); + enqueCommand(0x36); /*for(uint8_t i = 0x36; i <= 0x39; i++) { enqueCommand(i); // live data }*/ @@ -184,7 +184,7 @@ class Inverter { enqueCommand(0x09); //enqueCommand(0x11); } else if (type == INV_TYPE_1CH) { - enqueCommand(0x09); + enqueCommand(0x09); } //if (getFwVersion() == 0) // enqueCommand(InverterDevInform_All); // firmware version, might not work, esp. for 1/2 ch hardware diff --git a/src/hm/miPayload.h b/src/hm/miPayload.h index ac455f3d..ae750710 100644 --- a/src/hm/miPayload.h +++ b/src/hm/miPayload.h @@ -481,8 +481,7 @@ class MiPayload { ac_pow = calcPowerDcCh0(iv, 0)*9.5; //} iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); - //iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (mPayload[iv->id].sts[0] == 3 ? calcPowerDcCh0(iv, 0)*0.95 : 0)); - + if ( mPayload[iv->id].sts[0] ) { uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { From 18ea8b5925ed917d8d9eb2441864c1ae4974d05f Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 16:21:06 +0100 Subject: [PATCH 10/26] =?UTF-8?q?Versuch=20die=20WebOberfl=C3=A4che=20an?= =?UTF-8?q?=20zu=20passen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/Display/Display_ePaper.cpp | 5 +++-- src/plugins/Display/MonochromeDisplay.h | 4 ++-- src/web/RestApi.h | 1 - src/web/web.h | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index 4f9665c9..6e260ab1 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -11,7 +11,7 @@ SPIClass hspi(HSPI); std::map> _ePaperTypes = { // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1 - {4, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) { return new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); }}, + {11, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) { return new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); }}, // GDEW027C44 2.7 " b/w/r 176x264, IL91874 //{DisplayType_t::ePaper270, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) // F { return new GxEPD2_3C(GxEPD2_270c(_CS, _DC, _RST, _BUSY)); }}, @@ -66,7 +66,8 @@ void DisplayEPaperClass::fullRefresh() { delay(2000); // screen complete white _display->fillScreen(GxEPD_WHITE); - while (_display->nextPage()); + while (_display->nextPage()) + ; } //*************************************************************************** void DisplayEPaperClass::headlineIP() { diff --git a/src/plugins/Display/MonochromeDisplay.h b/src/plugins/Display/MonochromeDisplay.h index 6ed8499c..22be9fff 100644 --- a/src/plugins/Display/MonochromeDisplay.h +++ b/src/plugins/Display/MonochromeDisplay.h @@ -26,7 +26,7 @@ class MonochromeDisplay { if (mCfg->type == 0) { return; - } else if (1 < mCfg->type < 4) { + } else if (1 < mCfg->type < 10) { switch (mCfg->rot) { case 0: DisplayMono.disp_rotation = U8G2_R0; @@ -47,7 +47,7 @@ class MonochromeDisplay { DisplayMono.contrast = mCfg->contrast; DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data); - } else if (mCfg->type == 4) { + } else if (mCfg->type > 10) { DisplayEPaper.displayRotation = mCfg->rot; counterEPaper = 0; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 72bf21c3..1236b35f 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -431,7 +431,6 @@ class RestApi { void getDisplay(JsonObject obj) { obj[F("disp_type")] = (uint8_t)mConfig->plugin.display.type; obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; - obj[F("logo_en")] = (bool)mConfig->plugin.display.logoEn; obj[F("px_shift")] = (bool)mConfig->plugin.display.pxShift; obj[F("rotation")] = (uint8_t)mConfig->plugin.display.rot; obj[F("contrast")] = (uint8_t)mConfig->plugin.display.contrast; diff --git a/src/web/web.h b/src/web/web.h index aa46e4ee..2f5cc364 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -602,7 +602,6 @@ class Web { // display mConfig->plugin.display.pwrSaveAtIvOffline = (request->arg("dispPwr") == "on"); - mConfig->plugin.display.logoEn = (request->arg("logoEn") == "on"); mConfig->plugin.display.pxShift = (request->arg("dispPxSh") == "on"); mConfig->plugin.display.rot = request->arg("rotation").toInt(); mConfig->plugin.display.type = request->arg("dispType").toInt(); From ce20d7c1b4a64e84e35b71417a784487e47ffbaa Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 16:43:41 +0100 Subject: [PATCH 11/26] MonochromeDisplay in Display umbenannt --- src/app.cpp | 133 +++-- src/app.h | 454 +++++++++--------- .../{MonochromeDisplay.h => Display.h} | 16 +- 3 files changed, 298 insertions(+), 305 deletions(-) rename src/plugins/Display/{MonochromeDisplay.h => Display.h} (92%) diff --git a/src/app.cpp b/src/app.cpp index d83e169b..e6b577bc 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -4,13 +4,14 @@ //----------------------------------------------------------------------------- #include "app.h" + #include + #include "utils/sun.h" //----------------------------------------------------------------------------- app::app() : ah::Scheduler() {} - //----------------------------------------------------------------------------- void app::setup() { Serial.begin(115200); @@ -24,7 +25,7 @@ void app::setup() { mSettings.setup(); mSettings.getPtr(mConfig); DPRINT(DBG_INFO, F("Settings valid: ")); - if(mSettings.getValid()) + if (mSettings.getValid()) DBGPRINTLN(F("true")); else DBGPRINTLN(F("false")); @@ -32,16 +33,16 @@ void app::setup() { mSys.enableDebug(); mSys.setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs); - #if defined(AP_ONLY) +#if defined(AP_ONLY) mInnerLoopCb = std::bind(&app::loopStandard, this); - #else +#else mInnerLoopCb = std::bind(&app::loopWifi, this); - #endif +#endif mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onWifi, this, std::placeholders::_1)); - #if !defined(AP_ONLY) +#if !defined(AP_ONLY) everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); - #endif +#endif mSys.addInverters(&mConfig->inst); @@ -52,23 +53,23 @@ void app::setup() { mMiPayload.setup(this, &mSys, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp); mMiPayload.enableSerialDebug(mConfig->serial.debug); - //DBGPRINTLN("--- after payload"); - //DBGPRINTLN(String(ESP.getFreeHeap())); - //DBGPRINTLN(String(ESP.getHeapFragmentation())); - //DBGPRINTLN(String(ESP.getMaxFreeBlockSize())); + // DBGPRINTLN("--- after payload"); + // DBGPRINTLN(String(ESP.getFreeHeap())); + // DBGPRINTLN(String(ESP.getHeapFragmentation())); + // DBGPRINTLN(String(ESP.getMaxFreeBlockSize())); - if(!mSys.Radio.isChipConnected()) + if (!mSys.Radio.isChipConnected()) DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring")); - // when WiFi is in client mode, then enable mqtt broker - #if !defined(AP_ONLY) +// when WiFi is in client mode, then enable mqtt broker +#if !defined(AP_ONLY) mMqttEnabled = (mConfig->mqtt.broker[0] > 0); if (mMqttEnabled) { mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, &mSys, &mTimestamp); mMqtt.setSubscriptionCb(std::bind(&app::mqttSubRxCb, this, std::placeholders::_1)); mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } - #endif +#endif setupLed(); mWeb.setup(this, &mSys, mConfig); @@ -77,18 +78,17 @@ void app::setup() { mApi.setup(this, &mSys, mWeb.getWebSrvPtr(), mConfig); // Plugins - if(mConfig->plugin.display.type != 0) - mMonoDisplay.setup(&mConfig->plugin.display, &mSys, &mTimestamp, 0xff, mVersion); + if (mConfig->plugin.display.type != 0) + mDisplay.setup(&mConfig->plugin.display, &mSys, &mTimestamp, 0xff, mVersion); mPubSerial.setup(mConfig, &mSys, &mTimestamp); regularTickers(); - - //DBGPRINTLN("--- end setup"); - //DBGPRINTLN(String(ESP.getFreeHeap())); - //DBGPRINTLN(String(ESP.getHeapFragmentation())); - //DBGPRINTLN(String(ESP.getMaxFreeBlockSize())); + // DBGPRINTLN("--- end setup"); + // DBGPRINTLN(String(ESP.getFreeHeap())); + // DBGPRINTLN(String(ESP.getHeapFragmentation())); + // DBGPRINTLN(String(ESP.getMaxFreeBlockSize())); } //----------------------------------------------------------------------------- @@ -115,8 +115,8 @@ void app::loopStandard(void) { mStat.frmCnt++; Inverter<> *iv = mSys.findInverter(&p->packet[1]); - if(NULL != iv) { - if(IV_HM == iv->ivGen) + if (NULL != iv) { + if (IV_HM == iv->ivGen) mPayload.add(iv, p); else mMiPayload.add(iv, p); @@ -130,7 +130,7 @@ void app::loopStandard(void) { mPayload.loop(); mMiPayload.loop(); - if(mMqttEnabled) + if (mMqttEnabled) mMqtt.loop(); } @@ -144,19 +144,18 @@ void app::loopWifi(void) { void app::onWifi(bool gotIp) { DPRINTLN(DBG_DEBUG, F("onWifi")); ah::Scheduler::resetTicker(); - regularTickers(); // reinstall regular tickers + regularTickers(); // reinstall regular tickers if (gotIp) { mInnerLoopCb = std::bind(&app::loopStandard, this); every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval, "tSend"); mMqttReconnect = true; - mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers! + mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers! once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2"); - if(WIFI_AP == WiFi.getMode()) { + if (WIFI_AP == WiFi.getMode()) { mMqttEnabled = false; everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); } - } - else { + } else { mInnerLoopCb = std::bind(&app::loopWifi, this); everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); } @@ -167,8 +166,8 @@ void app::regularTickers(void) { DPRINTLN(DBG_DEBUG, F("regularTickers")); everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc"); // Plugins - if(mConfig->plugin.display.type != 0) - everySec(std::bind(&MonoDisplayType::tickerSecond, &mMonoDisplay), "disp"); + if (mConfig->plugin.display.type != 0) + everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp"); every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart"); } @@ -184,26 +183,26 @@ void app::tickNtpUpdate(void) { } // only install schedulers once even if NTP wasn't successful in first loop - if(mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed - if(mConfig->inst.rstValsNotAvail) + if (mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed + if (mConfig->inst.rstValsNotAvail) everyMin(std::bind(&app::tickMinute, this), "tMin"); - if(mConfig->inst.rstYieldMidNight) { + if (mConfig->inst.rstYieldMidNight) { uint32_t localTime = gTimezone.toLocal(mTimestamp); - uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time + uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi"); } } - nxtTrig = isOK ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min + nxtTrig = isOK ? 43200 : 60; // depending on NTP update success check again in 12 h or in 1 min - if((mSunrise == 0) && (mConfig->sun.lat) && (mConfig->sun.lon)) { + if ((mSunrise == 0) && (mConfig->sun.lat) && (mConfig->sun.lon)) { mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600; tickCalcSunrise(); } // immediately start communicating // @TODO: leads to reboot loops? not sure #674 - if(isOK && mSendFirst) { + if (isOK && mSendFirst) { mSendFirst = false; once(std::bind(&app::tickSend, this), 2, "senOn"); } @@ -215,15 +214,15 @@ void app::tickNtpUpdate(void) { //----------------------------------------------------------------------------- void app::tickCalcSunrise(void) { - if (mSunrise == 0) // on boot/reboot calc sun values for current time + if (mSunrise == 0) // on boot/reboot calc sun values for current time ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset); - if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) // current time is past communication stop, calc sun values for next day + if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) // current time is past communication stop, calc sun values for next day ah::calculateSunriseSunset(mTimestamp + 86400, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset); tickIVCommunication(); - uint32_t nxtTrig = mSunset + mConfig->sun.offsetSec + 60; // set next trigger to communication stop, +60 for safety that it is certain past communication stop + uint32_t nxtTrig = mSunset + mConfig->sun.offsetSec + 60; // set next trigger to communication stop, +60 for safety that it is certain past communication stop onceAt(std::bind(&app::tickCalcSunrise, this), nxtTrig, "Sunri"); if (mMqttEnabled) tickSun(); @@ -231,15 +230,15 @@ void app::tickCalcSunrise(void) { //----------------------------------------------------------------------------- void app::tickIVCommunication(void) { - mIVCommunicationOn = !mConfig->sun.disNightCom; // if sun.disNightCom is false, communication is always on - if (!mIVCommunicationOn) { // inverter communication only during the day + mIVCommunicationOn = !mConfig->sun.disNightCom; // if sun.disNightCom is false, communication is always on + if (!mIVCommunicationOn) { // inverter communication only during the day uint32_t nxtTrig; - if (mTimestamp < (mSunrise - mConfig->sun.offsetSec)) { // current time is before communication start, set next trigger to communication start + if (mTimestamp < (mSunrise - mConfig->sun.offsetSec)) { // current time is before communication start, set next trigger to communication start nxtTrig = mSunrise - mConfig->sun.offsetSec; } else { - if (mTimestamp >= (mSunset + mConfig->sun.offsetSec)) { // current time is past communication stop, nothing to do. Next update will be done at midnight by tickCalcSunrise + if (mTimestamp >= (mSunset + mConfig->sun.offsetSec)) { // current time is past communication stop, nothing to do. Next update will be done at midnight by tickCalcSunrise nxtTrig = 0; - } else { // current time lies within communication start/stop time, set next trigger to communication stop + } else { // current time lies within communication start/stop time, set next trigger to communication stop mIVCommunicationOn = true; nxtTrig = mSunset + mConfig->sun.offsetSec; } @@ -254,17 +253,17 @@ void app::tickIVCommunication(void) { void app::tickSun(void) { // only used and enabled by MQTT (see setup()) if (!mMqtt.tickerSun(mSunrise, mSunset, mConfig->sun.offsetSec, mConfig->sun.disNightCom)) - once(std::bind(&app::tickSun, this), 1, "mqSun"); // MQTT not connected, retry + once(std::bind(&app::tickSun, this), 1, "mqSun"); // MQTT not connected, retry } //----------------------------------------------------------------------------- void app::tickComm(void) { - if((!mIVCommunicationOn) && (mConfig->inst.rstValsCommStop)) + if ((!mIVCommunicationOn) && (mConfig->inst.rstValsCommStop)) once(std::bind(&app::tickZeroValues, this), mConfig->nrf.sendInterval, "tZero"); if (mMqttEnabled) { if (!mMqtt.tickerComm(!mIVCommunicationOn)) - once(std::bind(&app::tickComm, this), 5, "mqCom"); // MQTT not connected, retry after 5s + once(std::bind(&app::tickComm, this), 5, "mqCom"); // MQTT not connected, retry after 5s } } @@ -275,7 +274,7 @@ void app::tickZeroValues(void) { for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { iv = mSys.getInverterByPos(id); if (NULL == iv) - continue; // skip to next inverter + continue; // skip to next inverter mPayload.zeroInverterValues(iv); } @@ -290,9 +289,9 @@ void app::tickMinute(void) { for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { iv = mSys.getInverterByPos(id); if (NULL == iv) - continue; // skip to next inverter + continue; // skip to next inverter - if(!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled) + if (!iv->isAvailable(mTimestamp) && !iv->isProducing(mTimestamp) && iv->config->enabled) mPayload.zeroInverterValues(iv); } } @@ -301,7 +300,7 @@ void app::tickMinute(void) { void app::tickMidnight(void) { // only triggered if 'reset values at midnight is enabled' uint32_t localTime = gTimezone.toLocal(mTimestamp); - uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time + uint32_t nxtTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time onceAt(std::bind(&app::tickMidnight, this), nxtTrig, "mid2"); Inverter<> *iv; @@ -309,7 +308,7 @@ void app::tickMidnight(void) { for (uint8_t id = 0; id < mSys.getNumInverters(); id++) { iv = mSys.getInverterByPos(id); if (NULL == iv) - continue; // skip to next inverter + continue; // skip to next inverter mPayload.zeroInverterValues(iv); mPayload.zeroYieldDay(iv); @@ -321,7 +320,7 @@ void app::tickMidnight(void) { //----------------------------------------------------------------------------- void app::tickSend(void) { - if(!mSys.Radio.isChipConnected()) { + if (!mSys.Radio.isChipConnected()) { DPRINTLN(DBG_WARN, F("NRF24 not connected!")); return; } @@ -341,8 +340,8 @@ void app::tickSend(void) { } while ((NULL == iv) && ((maxLoop--) > 0)); if (NULL != iv) { - if(iv->config->enabled) { - if(iv->ivGen == IV_HM) + if (iv->config->enabled) { + if (iv->ivGen == IV_HM) mPayload.ivSend(iv); else mMiPayload.ivSend(iv); @@ -368,7 +367,7 @@ void app::resetSystem(void) { mSendFirst = true; mSunrise = 0; - mSunset = 0; + mSunset = 0; mMqttEnabled = false; @@ -391,25 +390,25 @@ void app::setupLed(void) { * PIN ---- |<----- 3.3V * * */ - if(mConfig->led.led0 != 0xff) { + if (mConfig->led.led0 != 0xff) { pinMode(mConfig->led.led0, OUTPUT); - digitalWrite(mConfig->led.led0, HIGH); // LED off + digitalWrite(mConfig->led.led0, HIGH); // LED off } - if(mConfig->led.led1 != 0xff) { + if (mConfig->led.led1 != 0xff) { pinMode(mConfig->led.led1, OUTPUT); - digitalWrite(mConfig->led.led1, HIGH); // LED off + digitalWrite(mConfig->led.led1, HIGH); // LED off } } //----------------------------------------------------------------------------- void app::updateLed(void) { - if(mConfig->led.led0 != 0xff) { + if (mConfig->led.led0 != 0xff) { Inverter<> *iv = mSys.getInverterByPos(0); if (NULL != iv) { - if(iv->isProducing(mTimestamp)) - digitalWrite(mConfig->led.led0, LOW); // LED on + if (iv->isProducing(mTimestamp)) + digitalWrite(mConfig->led.led0, LOW); // LED on else - digitalWrite(mConfig->led.led0, HIGH); // LED off + digitalWrite(mConfig->led.led0, HIGH); // LED off } } } diff --git a/src/app.h b/src/app.h index e55fe85a..8e7c5617 100644 --- a/src/app.h +++ b/src/app.h @@ -6,30 +6,25 @@ #ifndef __APP_H__ #define __APP_H__ - -#include "utils/dbg.h" #include +#include #include #include -#include #include "appInterface.h" - #include "config/settings.h" #include "defines.h" -#include "utils/crc.h" -#include "utils/scheduler.h" - -#include "hm/hmSystem.h" #include "hm/hmPayload.h" +#include "hm/hmSystem.h" #include "hm/miPayload.h" -#include "wifi/ahoywifi.h" -#include "web/web.h" -#include "web/RestApi.h" - #include "publisher/pubMqtt.h" #include "publisher/pubSerial.h" - +#include "utils/crc.h" +#include "utils/dbg.h" +#include "utils/scheduler.h" +#include "web/RestApi.h" +#include "web/web.h" +#include "wifi/ahoywifi.h" // convert degrees and radians for sun calculation #define SIN(x) (sin(radians(x))) @@ -46,235 +41,234 @@ typedef PubMqtt PubMqttType; typedef PubSerial PubSerialType; // PLUGINS -#include "plugins/Display/MonochromeDisplay.h" -typedef MonochromeDisplay MonoDisplayType; - +#include "plugins/Display/Display.h" +typedef Display DisplayType; class app : public IApp, public ah::Scheduler { - public: - app(); - ~app() {} - - void setup(void); - void loop(void); - void loopStandard(void); - void loopWifi(void); - void onWifi(bool gotIp); - void regularTickers(void); - - void handleIntr(void) { - mSys.Radio.handleIntr(); - } - - uint32_t getUptime() { - return Scheduler::getUptime(); - } - - uint32_t getTimestamp() { - return Scheduler::getTimestamp(); - } - - bool saveSettings() { - mShowRebootRequest = true; - return mSettings.saveSettings(); - } - - bool readSettings(const char *path) { - return mSettings.readSettings(path); + public: + app(); + ~app() {} + + void setup(void); + void loop(void); + void loopStandard(void); + void loopWifi(void); + void onWifi(bool gotIp); + void regularTickers(void); + + void handleIntr(void) { + mSys.Radio.handleIntr(); + } + + uint32_t getUptime() { + return Scheduler::getUptime(); + } + + uint32_t getTimestamp() { + return Scheduler::getTimestamp(); + } + + bool saveSettings() { + mShowRebootRequest = true; + return mSettings.saveSettings(); + } + + bool readSettings(const char *path) { + return mSettings.readSettings(path); + } + + bool eraseSettings(bool eraseWifi = false) { + return mSettings.eraseSettings(eraseWifi); + } + + statistics_t *getStatistics() { + return &mStat; + } + + void scanAvailNetworks() { + mWifi.scanAvailNetworks(); + } + + void getAvailNetworks(JsonObject obj) { + mWifi.getAvailNetworks(obj); + } + + void setOnUpdate() { + onWifi(false); + } + + void setRebootFlag() { + once(std::bind(&app::tickReboot, this), 3, "rboot"); + } + + const char *getVersion() { + return mVersion; + } + + uint32_t getSunrise() { + return mSunrise; + } + + uint32_t getSunset() { + return mSunset; + } + + bool getSettingsValid() { + return mSettings.getValid(); + } + + bool getRebootRequestState() { + return mShowRebootRequest; + } + + void setMqttDiscoveryFlag() { + once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1, "disCf"); + } + + void setMqttPowerLimitAck(Inverter<> *iv) { + mMqtt.setPowerLimitAck(iv); + } + + void ivSendHighPrio(Inverter<> *iv) { + if (mIVCommunicationOn) // only send commands if communcation is enabled + mPayload.ivSendHighPrio(iv); + } + + bool getMqttIsConnected() { + return mMqtt.isConnected(); + } + + uint32_t getMqttTxCnt() { + return mMqtt.getTxCnt(); + } + + uint32_t getMqttRxCnt() { + return mMqtt.getRxCnt(); + } + + bool getProtection() { + return mWeb.getProtection(); + } + + uint8_t getIrqPin(void) { + return mConfig->nrf.pinIrq; + } + + String getTimeStr(uint32_t offset = 0) { + char str[10]; + if (0 == mTimestamp) + sprintf(str, "n/a"); + else + sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset)); + return String(str); + } + + uint32_t getTimezoneOffset() { + return mApi.getTimezoneOffset(); + } + + void getSchedulerInfo(uint8_t *max) { + getStat(max); + } + + void getSchedulerNames(void) { + printSchedulers(); + } + + void setTimestamp(uint32_t newTime) { + DPRINT(DBG_DEBUG, F("setTimestamp: ")); + DBGPRINTLN(String(newTime)); + if (0 == newTime) + mWifi.getNtpTime(); + else + Scheduler::setTimestamp(newTime); + } + + HmSystemType mSys; + + private: + typedef std::function innerLoopCb; + + void resetSystem(void); + + void payloadEventListener(uint8_t cmd) { +#if !defined(AP_ONLY) + if (mMqttEnabled) + mMqtt.payloadEventListener(cmd); +#endif + if (mConfig->plugin.display.type != 0) + mDisplay.payloadEventListener(cmd); + } + + void mqttSubRxCb(JsonObject obj); + + void setupLed(void); + void updateLed(void); + + void tickReboot(void) { + DPRINTLN(DBG_INFO, F("Rebooting...")); + onWifi(false); + ah::Scheduler::resetTicker(); + WiFi.disconnect(); + ESP.restart(); + } + + void tickNtpUpdate(void); + void tickCalcSunrise(void); + void tickIVCommunication(void); + void tickSun(void); + void tickComm(void); + void tickSend(void); + void tickMinute(void); + void tickZeroValues(void); + void tickMidnight(void); + /*void tickSerial(void) { + if(Serial.available() == 0) + return; + + uint8_t buf[80]; + uint8_t len = Serial.readBytes(buf, 80); + DPRINTLN(DBG_INFO, "got serial data, len: " + String(len)); + for(uint8_t i = 0; i < len; i++) { + if((0 != i) && (i % 8 == 0)) + DBGPRINTLN(""); + DBGPRINT(String(buf[i], HEX) + " "); } + DBGPRINTLN(""); + }*/ - bool eraseSettings(bool eraseWifi = false) { - return mSettings.eraseSettings(eraseWifi); - } + innerLoopCb mInnerLoopCb; - statistics_t *getStatistics() { - return &mStat; - } + bool mShowRebootRequest; + bool mIVCommunicationOn; - void scanAvailNetworks() { - mWifi.scanAvailNetworks(); - } - - void getAvailNetworks(JsonObject obj) { - mWifi.getAvailNetworks(obj); - } + ahoywifi mWifi; + WebType mWeb; + RestApiType mApi; + PayloadType mPayload; + MiPayloadType mMiPayload; + PubSerialType mPubSerial; - void setOnUpdate() { - onWifi(false); - } + char mVersion[12]; + settings mSettings; + settings_t *mConfig; - void setRebootFlag() { - once(std::bind(&app::tickReboot, this), 3, "rboot"); - } + uint8_t mSendLastIvId; + bool mSendFirst; - const char *getVersion() { - return mVersion; - } + statistics_t mStat; - uint32_t getSunrise() { - return mSunrise; - } + // mqtt + PubMqttType mMqtt; + bool mMqttReconnect; + bool mMqttEnabled; - uint32_t getSunset() { - return mSunset; - } - - bool getSettingsValid() { - return mSettings.getValid(); - } - - bool getRebootRequestState() { - return mShowRebootRequest; - } - - void setMqttDiscoveryFlag() { - once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1, "disCf"); - } - - void setMqttPowerLimitAck(Inverter<> *iv) { - mMqtt.setPowerLimitAck(iv); - } - - void ivSendHighPrio(Inverter<> *iv) { - if(mIVCommunicationOn) // only send commands if communcation is enabled - mPayload.ivSendHighPrio(iv); - } - - bool getMqttIsConnected() { - return mMqtt.isConnected(); - } - - uint32_t getMqttTxCnt() { - return mMqtt.getTxCnt(); - } - - uint32_t getMqttRxCnt() { - return mMqtt.getRxCnt(); - } - - bool getProtection() { - return mWeb.getProtection(); - } - - uint8_t getIrqPin(void) { - return mConfig->nrf.pinIrq; - } - - String getTimeStr(uint32_t offset = 0) { - char str[10]; - if(0 == mTimestamp) - sprintf(str, "n/a"); - else - sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset)); - return String(str); - } - - uint32_t getTimezoneOffset() { - return mApi.getTimezoneOffset(); - } - - void getSchedulerInfo(uint8_t *max) { - getStat(max); - } - - void getSchedulerNames(void) { - printSchedulers(); - } - - void setTimestamp(uint32_t newTime) { - DPRINT(DBG_DEBUG, F("setTimestamp: ")); - DBGPRINTLN(String(newTime)); - if(0 == newTime) - mWifi.getNtpTime(); - else - Scheduler::setTimestamp(newTime); - } - - HmSystemType mSys; - - private: - typedef std::function innerLoopCb; - - void resetSystem(void); - - void payloadEventListener(uint8_t cmd) { - #if !defined(AP_ONLY) - if (mMqttEnabled) - mMqtt.payloadEventListener(cmd); - #endif - if(mConfig->plugin.display.type != 0) - mMonoDisplay.payloadEventListener(cmd); - } - - void mqttSubRxCb(JsonObject obj); - - void setupLed(void); - void updateLed(void); - - void tickReboot(void) { - DPRINTLN(DBG_INFO, F("Rebooting...")); - onWifi(false); - ah::Scheduler::resetTicker(); - WiFi.disconnect(); - ESP.restart(); - } + // sun + int32_t mCalculatedTimezoneOffset; + uint32_t mSunrise, mSunset; - void tickNtpUpdate(void); - void tickCalcSunrise(void); - void tickIVCommunication(void); - void tickSun(void); - void tickComm(void); - void tickSend(void); - void tickMinute(void); - void tickZeroValues(void); - void tickMidnight(void); - /*void tickSerial(void) { - if(Serial.available() == 0) - return; - - uint8_t buf[80]; - uint8_t len = Serial.readBytes(buf, 80); - DPRINTLN(DBG_INFO, "got serial data, len: " + String(len)); - for(uint8_t i = 0; i < len; i++) { - if((0 != i) && (i % 8 == 0)) - DBGPRINTLN(""); - DBGPRINT(String(buf[i], HEX) + " "); - } - DBGPRINTLN(""); - }*/ - - innerLoopCb mInnerLoopCb; - - bool mShowRebootRequest; - bool mIVCommunicationOn; - - ahoywifi mWifi; - WebType mWeb; - RestApiType mApi; - PayloadType mPayload; - MiPayloadType mMiPayload; - PubSerialType mPubSerial; - - char mVersion[12]; - settings mSettings; - settings_t *mConfig; - - uint8_t mSendLastIvId; - bool mSendFirst; - - statistics_t mStat; - - // mqtt - PubMqttType mMqtt; - bool mMqttReconnect; - bool mMqttEnabled; - - // sun - int32_t mCalculatedTimezoneOffset; - uint32_t mSunrise, mSunset; - - // plugins - MonoDisplayType mMonoDisplay; + // plugins + DisplayType mDisplay; }; #endif /*__APP_H__*/ diff --git a/src/plugins/Display/MonochromeDisplay.h b/src/plugins/Display/Display.h similarity index 92% rename from src/plugins/Display/MonochromeDisplay.h rename to src/plugins/Display/Display.h index 22be9fff..9903c4e3 100644 --- a/src/plugins/Display/MonochromeDisplay.h +++ b/src/plugins/Display/Display.h @@ -1,5 +1,5 @@ -#ifndef __MONOCHROME_DISPLAY__ -#define __MONOCHROME_DISPLAY__ +#ifndef __DISPLAY__ +#define __DISPLAY__ #include #include @@ -13,9 +13,9 @@ #define DISP_DEFAULT_TIMEOUT 60 // in seconds template -class MonochromeDisplay { +class Display { public: - MonochromeDisplay() {} + Display() {} void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { mCfg = cfg; @@ -26,7 +26,7 @@ class MonochromeDisplay { if (mCfg->type == 0) { return; - } else if (1 < mCfg->type < 10) { + } else if (1 < mCfg->type < 11) { switch (mCfg->rot) { case 0: DisplayMono.disp_rotation = U8G2_R0; @@ -97,9 +97,9 @@ class MonochromeDisplay { totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec); } - if (1 < mCfg->type < 4) { + if (1 < mCfg->type < 11) { DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); - } else if (mCfg->type == 4) { + } else if (mCfg->type > 10) { DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); counterEPaper++; } @@ -123,4 +123,4 @@ class MonochromeDisplay { uint32_t _lastDisplayUpdate = 0; }; -#endif /*__MONOCHROME_DISPLAY__*/ +#endif /*__DISPLAY__*/ From 0ff821aeac6ae4f8cd893943da121c92e20c8778 Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 16:56:01 +0100 Subject: [PATCH 12/26] kleine Optimierungen --- src/plugins/Display/Display.h | 6 ++++-- src/plugins/Display/Display_Mono.cpp | 6 ++++-- src/plugins/Display/Display_Mono.h | 2 +- src/plugins/Display/Display_ePaper.cpp | 4 ++-- src/plugins/Display/Display_ePaper.h | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index 9903c4e3..8849f30e 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -23,6 +23,7 @@ class Display { mUtcTs = utcTs; mNewPayload = false; mLoopCnt = 0; + mVersion = version; if (mCfg->type == 0) { return; @@ -46,12 +47,12 @@ class Display { DisplayMono.enableScreensaver = mCfg->pxShift; DisplayMono.contrast = mCfg->contrast; - DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data); + DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); } else if (mCfg->type > 10) { DisplayEPaper.displayRotation = mCfg->rot; counterEPaper = 0; - DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data); + DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); } } @@ -116,6 +117,7 @@ class Display { bool mNewPayload; uint8_t mLoopCnt; uint32_t *mUtcTs; + const char *mVersion; display_t *mCfg; HMSYSTEM *mSys; uint16_t period = 10000; // Achtung, max 65535 diff --git a/src/plugins/Display/Display_Mono.cpp b/src/plugins/Display/Display_Mono.cpp index 23c6f0e3..d6caa1a0 100644 --- a/src/plugins/Display/Display_Mono.cpp +++ b/src/plugins/Display/Display_Mono.cpp @@ -63,7 +63,7 @@ void DisplayMonoClass::printText(const char* text, uint8_t line, uint8_t dispX = _display->drawStr(dispX, mLineOffsets[line], text); } -void DisplayMonoClass::init(uint8_t _type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI) { +void DisplayMonoClass::init(uint8_t _type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version) { if (0 < _type < 4) { auto constructor = mono_types[_type]; _display = constructor(_RST, _SCK, _MOSI, _CS, _DC); @@ -77,7 +77,9 @@ void DisplayMonoClass::init(uint8_t _type, uint8_t _CS, uint8_t _DC, uint8_t _RS if (contrast < 255) { _display->setContrast(contrast); } - printText("OpenDTU!", 0); + printText("AHOY!", 0, 35); + printText("ahoydtu.de", 2, 20); + printText(version, 3, 46); _display->sendBuffer(); } } diff --git a/src/plugins/Display/Display_Mono.h b/src/plugins/Display/Display_Mono.h index eda23f05..b3307ef9 100644 --- a/src/plugins/Display/Display_Mono.h +++ b/src/plugins/Display/Display_Mono.h @@ -8,7 +8,7 @@ class DisplayMonoClass { DisplayMonoClass(); ~DisplayMonoClass(); - void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI); + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index 6e260ab1..01b641ba 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -9,7 +9,7 @@ static const uint32_t spiClk = 4000000; // 4 MHz SPIClass hspi(HSPI); #endif -std::map> _ePaperTypes = { +std::map> _ePaperTypes = { // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1 {11, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) { return new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); }}, // GDEW027C44 2.7 " b/w/r 176x264, IL91874 @@ -24,7 +24,7 @@ DisplayEPaperClass::~DisplayEPaperClass() { delete _display; } //*************************************************************************** -void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI) { +void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *version) { if (type > 3) { Serial.begin(115200); auto constructor = _ePaperTypes[type]; diff --git a/src/plugins/Display/Display_ePaper.h b/src/plugins/Display/Display_ePaper.h index e404f565..ed8fb025 100644 --- a/src/plugins/Display/Display_ePaper.h +++ b/src/plugins/Display/Display_ePaper.h @@ -31,7 +31,7 @@ class DisplayEPaperClass { DisplayEPaperClass(); ~DisplayEPaperClass(); void fullRefresh(); - void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI); + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); uint8_t displayRotation = 2; From 565b944da37e33c57b928c95883fe48198a1865c Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Sun, 5 Mar 2023 17:22:03 +0100 Subject: [PATCH 13/26] =?UTF-8?q?PeriodenDauer=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/settings.h | 6 ++++-- src/plugins/Display/Display.h | 5 +---- src/plugins/Display/Display_Mono.h | 3 ++- src/web/RestApi.h | 1 + src/web/web.h | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/config/settings.h b/src/config/settings.h index bd804386..b02b5a61 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -124,6 +124,7 @@ typedef struct { bool logoEn; bool pxShift; uint8_t rot; + uint16_t period; uint16_t wakeUp; uint16_t sleepAt; uint8_t contrast; @@ -344,6 +345,7 @@ class settings { mCfg.plugin.display.logoEn = true; mCfg.plugin.display.pxShift = true; mCfg.plugin.display.rot = 0; + mCfg.plugin.display.period = 10000; mCfg.plugin.display.disp_data = DEF_PIN_OFF; // SDA mCfg.plugin.display.disp_clk = DEF_PIN_OFF; // SCL mCfg.plugin.display.disp_cs = DEF_PIN_OFF; @@ -477,7 +479,7 @@ class settings { JsonObject disp = obj.createNestedObject("disp"); disp[F("type")] = mCfg.plugin.display.type; disp[F("pwrSafe")] = (bool)mCfg.plugin.display.pwrSaveAtIvOffline; - disp[F("logo")] = (bool)mCfg.plugin.display.logoEn; + disp[F("period")] = mCfg.plugin.display.period; disp[F("pxShift")] = (bool)mCfg.plugin.display.pxShift; disp[F("rotation")] = mCfg.plugin.display.rot; disp[F("wake")] = mCfg.plugin.display.wakeUp; @@ -493,7 +495,7 @@ class settings { JsonObject disp = obj["disp"]; mCfg.plugin.display.type = disp[F("type")]; mCfg.plugin.display.pwrSaveAtIvOffline = (bool)disp[F("pwrSafe")]; - mCfg.plugin.display.logoEn = (bool)disp[F("logo")]; + mCfg.plugin.display.period = disp[F("period")]; mCfg.plugin.display.pxShift = (bool)disp[F("pxShift")]; mCfg.plugin.display.rot = disp[F("rotation")]; mCfg.plugin.display.wakeUp = disp[F("wake")]; diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index 8849f30e..8509dacd 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -10,8 +10,6 @@ #include "Display_ePaper.h" #include "imagedata.h" -#define DISP_DEFAULT_TIMEOUT 60 // in seconds - template class Display { public: @@ -75,7 +73,7 @@ class Display { if (*mUtcTs == 0) return; - if ((millis() - _lastDisplayUpdate) > period) { + if ((millis() - _lastDisplayUpdate) > mCfg->period) { float totalPower = 0; float totalYieldDay = 0; float totalYieldTotal = 0; @@ -120,7 +118,6 @@ class Display { const char *mVersion; display_t *mCfg; HMSYSTEM *mSys; - uint16_t period = 10000; // Achtung, max 65535 uint16_t counterEPaper; uint32_t _lastDisplayUpdate = 0; }; diff --git a/src/plugins/Display/Display_Mono.h b/src/plugins/Display/Display_Mono.h index b3307ef9..81375605 100644 --- a/src/plugins/Display/Display_Mono.h +++ b/src/plugins/Display/Display_Mono.h @@ -2,6 +2,7 @@ #pragma once #include +#define DISP_DEFAULT_TIMEOUT 60000 // in milliseconds class DisplayMonoClass { public: @@ -33,7 +34,7 @@ class DisplayMonoClass { uint32_t _previousMillis = 0; uint8_t _mExtra; - uint16_t _mTimeout; // interval at which to power save (milliseconds) + uint16_t _mTimeout = DISP_DEFAULT_TIMEOUT; // interval at which to power save (milliseconds) char _fmtText[32]; }; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 1236b35f..616244fa 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -433,6 +433,7 @@ class RestApi { obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; obj[F("px_shift")] = (bool)mConfig->plugin.display.pxShift; obj[F("rotation")] = (uint8_t)mConfig->plugin.display.rot; + obj[F("period")] = (uint16_t)mConfig->plugin.display.period; obj[F("contrast")] = (uint8_t)mConfig->plugin.display.contrast; obj[F("data")] = mConfig->plugin.display.disp_data; obj[F("clock")] = mConfig->plugin.display.disp_clk; diff --git a/src/web/web.h b/src/web/web.h index 2f5cc364..5eed3688 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -606,7 +606,7 @@ class Web { mConfig->plugin.display.rot = request->arg("rotation").toInt(); mConfig->plugin.display.type = request->arg("dispType").toInt(); mConfig->plugin.display.contrast = request->arg("dispCont").toInt(); - + mConfig->plugin.display.period = request->arg("period").toInt(); mConfig->plugin.display.disp_data = request->arg("data").toInt(); mConfig->plugin.display.disp_clk = request->arg("clock").toInt(); mConfig->plugin.display.disp_cs = request->arg("cs").toInt(); From f7a7026ac88f161ad02c84e5eb90d56695124805 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 5 Mar 2023 20:38:22 +0100 Subject: [PATCH 14/26] renamed var to VAr --- src/web/html/visualization.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index 4c3c6a47..0fbbeeee 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -115,7 +115,7 @@ numMid(obj.ch[0][1], "A", "Current"), numMid(obj.ch[0][3], "Hz", "Frequency"), numMid(obj.ch[0][9], "%", "Efficiency"), - numMid(obj.ch[0][10], "var", "Reactive Power"), + numMid(obj.ch[0][10], "VAr", "Reactive Power"), numMid(obj.ch[0][4], "", "Power Factor") ]) ]) From 892ce444415c1fe326038605f092cc57a20296d5 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Sun, 5 Mar 2023 21:47:02 +0100 Subject: [PATCH 15/26] MI - delete unnecessary MiInfoCommand compiles, but untested yet; should work --- src/hm/hmInverter.h | 7 ------- src/hm/miPayload.h | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 175c6177..e8b83726 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -90,13 +90,6 @@ class InfoCommand : public CommandAbstract { } }; -class MiInfoCommand : public CommandAbstract { - public: - MiInfoCommand(uint8_t cmd){ - _TxType = cmd; - _Cmd = cmd; - } -}; // list of all available functions, mapped in hmDefines.h template const calcFunc_t calcFunctions[] = { diff --git a/src/hm/miPayload.h b/src/hm/miPayload.h index ae750710..d2b53145 100644 --- a/src/hm/miPayload.h +++ b/src/hm/miPayload.h @@ -199,7 +199,7 @@ class MiPayload { msg = "NOT "; DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has ") + msg + F("accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1])); iv->clearCmdQueue(); - iv->enqueCommand(SystemConfigPara); // read back power limit + iv->enqueCommand(SystemConfigPara); // read back power limit } iv->devControlCmd = Init; } else { // some other response; copied from hmPayload:process; might not be correct to do that here!!! @@ -413,7 +413,7 @@ class MiPayload { iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); - iv->enqueCommand(AlarmData); + iv->enqueCommand(AlarmData); } } @@ -481,7 +481,7 @@ class MiPayload { ac_pow = calcPowerDcCh0(iv, 0)*9.5; //} iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); - + if ( mPayload[iv->id].sts[0] ) { uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { From 52020d54313deeb80dcf7d41b999b7b17ccf3e58 Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Tue, 7 Mar 2023 08:38:36 +0100 Subject: [PATCH 16/26] MI - refacture "complete?" code for 1/2 ch --- src/hm/miPayload.h | 239 ++++++++++++++++++++++++++++++--------------- 1 file changed, 161 insertions(+), 78 deletions(-) diff --git a/src/hm/miPayload.h b/src/hm/miPayload.h index d2b53145..24e6693a 100644 --- a/src/hm/miPayload.h +++ b/src/hm/miPayload.h @@ -18,11 +18,13 @@ typedef struct { uint8_t txCmd; uint8_t len[MAX_PAYLOAD_ENTRIES]; bool complete; - bool dataAB[2]; + bool dataAB[3]; + bool stsAB[3]; uint8_t sts[5]; uint8_t txId; uint8_t invId; uint8_t retransmits; + bool gotFragment; /* uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE]; @@ -85,34 +87,29 @@ class MiPayload { if (mSerialDebug) DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->config->serial.u64, HEX)); - //first channel request - /*uint8_t cmd = iv->type == INV_TYPE_4CH ? 0x36 : 0x09; + uint8_t cmd = iv->getQueuedCmd(); DPRINT(DBG_INFO, F("(#")); DBGPRINT(String(iv->id)); DBGPRINT(F(") prepareDevInformCmd 0x")); DBGPRINTLN(String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd;*/ + uint8_t cmd2 = cmd; + if (cmd == 0x1 ) { + cmd = TX_REQ_INFO; + cmd2 = 0x00; + }; + + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd2, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd; + if (iv->type == INV_TYPE_1CH || iv->type == INV_TYPE_2CH) { + mPayload[iv->id].dataAB[CH1] = false; + mPayload[iv->id].stsAB[CH1] = false; + mPayload[iv->id].dataAB[CH0] = false; + mPayload[iv->id].stsAB[CH0] = false; + } - uint8_t cmd = iv->getQueuedCmd(); - DPRINT(DBG_INFO, F("(#")); - DBGPRINT(String(iv->id)); - DBGPRINT(F(") prepareDevInformCmd 0x")); - DBGPRINTLN(String(cmd, HEX)); - mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; - //other channel requests - /*if (iv->type == INV_TYPE_4CH) { - for(uint8_t i = 1; i < iv->channels; i++) { - iv->enqueCommand(cmd + i, cmd + i); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd + i); - } - } else */ if (iv->type == INV_TYPE_2CH) { - mPayload[iv->id].dataAB[0] = false; - mPayload[iv->id].dataAB[1] = false; - //iv->enqueCommand(0x11); - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, 0x11, mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); + mPayload[iv->id].dataAB[CH2] = false; + mPayload[iv->id].stsAB[CH2] = false; } } @@ -120,10 +117,8 @@ class MiPayload { //DPRINTLN(DBG_INFO, F("MI got data [0]=") + String(p->packet[0], HEX)); if (p->packet[0] == (0x08 + ALL_FRAMES)) { // 0x88; MI status response to 0x09 - //mPayload[iv->id].sts[0] = true; miStsDecode(iv, p); } else if (p->packet[0] == (0x11 + SINGLE_FRAME)) { // 0x92; MI status response to 0x11 - //mPayload[iv->id].sts[1] = true; miStsDecode(iv, p, CH2); /*} else if (p->packet[0] == (0x09 + ALL_FRAMES)) { // MI data response to 0x09 mPayload[iv->id].txId = p->packet[0]; @@ -161,14 +156,39 @@ class MiPayload { //} - /*if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command + } else if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command + // atm, we just do nothing else than print out what we got... + // for decoding see xls- Data collection instructions - #147ff +/* + Polling the device software and hardware version number command + start byte Command word routing address target address User data check end byte + byte[0] byte[1] byte[2] byte[3] byte[4] byte[5] byte[6] byte[7] byte[8] byte[9] byte[10] byte[11] byte[12] + 0x7e 0x0f xx xx xx xx YY YY YY YY 0x00 CRC 0x7f + + Command Receipt - First Frame + start byte Command word target address routing address Multi-frame marking User data User data User data User data User data User data User data User data User data User data User data User data User data User data User data User data check end byte + byte[0] byte[1] byte[2] byte[3] byte[4] byte[5] byte[6] byte[7] byte[8] byte[9] byte[10] byte[11] byte[12] byte[13] byte[14] byte[15] byte[16] byte[17] byte[18] byte[19] byte[20] byte[21] byte[22] byte[23] byte[24] byte[25] byte[26] byte[27] byte[28] + 0x7e 0x8f YY YY YY YY xx xx xx xx 0x00 USFWBuild_VER APPFWBuild_VER APPFWBuild_YYYY APPFWBuild_MMDD APPFWBuild_HHMM APPFW_PN HW_VER CRC 0x7f + Command Receipt - Second Frame + start byte Command word target address routing address Multi-frame marking User data User data User data User data User data User data User data User data User data User data User data User data User data User data User data User data check end byte + byte[0] byte[1] byte[2] byte[3] byte[4] byte[5] byte[6] byte[7] byte[8] byte[9] byte[10] byte[11] byte[12] byte[13] byte[14] byte[15] byte[16] byte[17] byte[18] byte[19] byte[20] byte[21] byte[22] byte[23] byte[24] byte[25] byte[26] byte[27] byte[28] + 0x7e 0x8f YY YY YY YY xx xx xx xx 0x01 HW_PN HW_FB_TLmValue HW_FB_ReSPRT HW_GridSamp_ResValule HW_ECapValue Matching_APPFW_PN CRC 0x7f + Command receipt - third frame + start byte Command word target address routing address Multi-frame marking User data User data User data User data User data User data User data User data check end byte + byte[0] byte[1] byte[2] byte[3] byte[4] byte[5] byte[6] byte[7] byte[8] byte[9] byte[10] byte[11] byte[12] byte[13] byte[14] byte[15] byte[16] byte[15] byte[16] byte[17] byte[18] + 0x7e 0x8f YY YY YY YY xx xx xx xx 0x12 APPFW_MINVER HWInfoAddr PNInfoCRC_gusv PNInfoCRC_gusv CRC 0x7f + +*/ mPayload[iv->id].txId = p->packet[0]; DPRINTLN(DBG_DEBUG, F("Response from info request received")); uint8_t *pid = &p->packet[9]; if (*pid == 0x00) { - DPRINT(DBG_DEBUG, F("fragment number zero received and ignored")); - } else { + DPRINT(DBG_DEBUG, F("fragment number zero received")); + + iv->setQueuedCmdFinished(); + } //else { DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX)); + /* if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) { memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11); mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11; @@ -271,13 +291,21 @@ class MiPayload { if (IV_HM == iv->ivGen) // only process MI inverters continue; // skip to next inverter - /*if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) { - // no processing needed if txId is not 0x95 + if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && + (mPayload[iv->id].txId < (0x36 + ALL_FRAMES)) && + (mPayload[iv->id].txId > (0x39 + ALL_FRAMES)) && + (mPayload[iv->id].txId != (0x09 + ALL_FRAMES)) && + (mPayload[iv->id].txId != (0x11 + ALL_FRAMES)) && + (mPayload[iv->id].txId != (0x88)) && + (mPayload[iv->id].txId != (0x92)) && + (mPayload[iv->id].txId != 0 )) { + // no processing needed if txId is not one of 0x95, 0x88, 0x89, 0x91, 0x92 or resonse to 0x36ff mPayload[iv->id].complete = true; continue; // skip to next inverter - }*/ + } if (!mPayload[iv->id].complete) { + //DPRINTLN(DBG_INFO, F("Pyld incompl code")); //info for testing only bool crcPass, pyldComplete; crcPass = build(iv->id, &pyldComplete); if (!crcPass && !pyldComplete) { // payload not complete @@ -292,22 +320,32 @@ class MiPayload { } else { if (mPayload[iv->id].retransmits < mMaxRetrans) { mPayload[iv->id].retransmits++; - //mSys->Radio.prepareDevInformCmd(iv->radioId.u64, iv->getQueuedCmd(), mPayload[iv->id].ts, iv->alarmMesIndex, false, 0x11); - DPRINTLN(DBG_WARN, F("missing answer to 0x") + String(iv->getQueuedCmd(), HEX) + F("Request Retransmit")); - mSys->Radio.sendCmdPacket(iv->radioId.u64, iv->getQueuedCmd(), 24, true); - /*if(false == mPayload[iv->id].gotFragment) { - DPRINTLN(DBG_WARN, F("(#") + String(iv->id) + F(") nothing received")); + if( !mPayload[iv->id].gotFragment ) { + DPRINT(DBG_INFO, F("(#")); + DBGPRINT(String(iv->id)); + DBGPRINTLN(F(") nothing received")); mPayload[iv->id].retransmits = mMaxRetrans; } else { - for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) { - if (mPayload[iv->id].len[i] == 0) { - DPRINTLN(DBG_WARN, F("Frame ") + String(i + 1) + F(" missing: Request Retransmit")); - mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true); - break; // only request retransmit one frame per loop + uint8_t cmd = mPayload[iv->id].txCmd; + if ( cmd >= 0x36 && cmd < 0x39 ) { // MI-1500 Data command + cmd++; // just request the next channel + } else if ( cmd == 0x09 ) {//MI single or dual channel device + if ( mPayload[iv->id].dataAB[CH1] && iv->type == INV_TYPE_2CH ) { + if (!mPayload[iv->id].stsAB[CH2] || !mPayload[iv->id].dataAB[CH2] ) + cmd = 0x11; + } + } else if ( cmd == 0x11) { + if ( mPayload[iv->id].dataAB[CH2] ) { // data is there, but no status + if (!mPayload[iv->id].stsAB[CH1] || !mPayload[iv->id].dataAB[CH1] ) + cmd = 0x09; } - yield(); } - }*/ + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") next request is 0x") + String(cmd, HEX)); + //mSys->Radio.sendCmdPacket(iv->radioId.u64, cmd, cmd, true); + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, true, cmd); + mPayload[iv->id].txCmd = cmd; + yield(); + } } } } @@ -319,14 +357,25 @@ class MiPayload { DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true); } - } /*else { // payload complete + } else { // payload complete DPRINTLN(DBG_INFO, F("procPyld: cmd: 0x") + String(mPayload[iv->id].txCmd, HEX)); DPRINTLN(DBG_INFO, F("procPyld: txid: 0x") + String(mPayload[iv->id].txId, HEX)); - DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); - record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser - mPayload[iv->id].complete = true; + //DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId)); + //record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser - uint8_t payload[128]; + mPayload[iv->id].complete = true; + uint8_t ac_pow = 0; + //if (mPayload[iv->id].sts[0] == 3) { + ac_pow = calcPowerDcCh0(iv, 0)*9.5; + //} + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser + iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); + + DPRINTLN(DBG_INFO, F("proces: compl. set of msgs detected")); + iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); + iv->doCalculations(); + + /*uint8_t payload[128]; uint8_t payloadLen = 0; memset(payload, 0, 128); @@ -375,8 +424,8 @@ class MiPayload { mStat->rxFail++; } - iv->setQueuedCmdFinished(); - }*/ + iv->setQueuedCmdFinished(); */ + } } yield(); } @@ -389,25 +438,30 @@ class MiPayload { } void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t chan = CH1) { - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": status msg 0x") + String(p->packet[0], HEX)); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") status msg 0x") + String(p->packet[0], HEX)); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the record structure rec->ts = mPayload[iv->id].ts; + mPayload[iv->id].gotFragment = true; + mPayload[iv->id].txId = p->packet[0]; uint8_t status = (p->packet[11] << 8) + p->packet[12]; uint8_t stschan = p->packet[0] == 0x88 ? CH1 : CH2; - mPayload[iv->id].dataAB[stschan-1] = true; mPayload[iv->id].sts[stschan] = status; + mPayload[iv->id].stsAB[stschan] = true; + if (mPayload[iv->id].stsAB[CH1] && mPayload[iv->id].stsAB[CH2]) + mPayload[iv->id].stsAB[CH0] = true; if ( !mPayload[iv->id].sts[0] || status < mPayload[iv->id].sts[0]) { mPayload[iv->id].sts[0] = status; iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, status); } - if ( !mPayload[iv->id].dataAB[0] || !mPayload[iv->id].dataAB[1] ) { + /*if ( !mPayload[iv->id].dataAB[0] || !mPayload[iv->id].dataAB[1] ) { uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; DPRINTLN(DBG_INFO, F("request missing status 0x") + String(cmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); mPayload[iv->id].txCmd = cmd; - } + rem: gotFragment should be a better solution + } */ if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; // seems there's no status per channel in 3rd gen. models?!? @@ -415,17 +469,27 @@ class MiPayload { DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); iv->enqueCommand(AlarmData); } + if (mPayload[iv->id].stsAB[CH0] && mPayload[iv->id].dataAB[CH0] && !mPayload[iv->id].complete) { + mPayload[iv->id].complete = true; + DPRINTLN(DBG_INFO, F("rec. complete set of msgs")); + iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); + iv->setQueuedCmdFinished(); + iv->doCalculations(); + notify(mPayload[iv->id].txCmd); + } + } void miDataDecode(Inverter<> *iv, packet_t *p) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser rec->ts = mPayload[iv->id].ts; + mPayload[iv->id].gotFragment = true; uint8_t datachan = ( p->packet[0] == 0x89 || p->packet[0] == (0x36 + ALL_FRAMES) ) ? CH1 : ( p->packet[0] == 0x91 || p->packet[0] == (0x37 + ALL_FRAMES) ) ? CH2 : p->packet[0] == (0x38 + ALL_FRAMES) ? CH3 : CH4; - DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(": data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); + DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") data msg 0x") + String(p->packet[0], HEX) + F(" channel ") + datachan); // count in RF_communication_protocol.xlsx is with offset = -1 iv->setValue(iv->getPosByChFld(datachan, FLD_UDC, rec), rec, (float)((p->packet[9] << 8) + p->packet[10])/10); yield(); @@ -442,6 +506,13 @@ class MiPayload { iv->setValue(iv->getPosByChFld(0, FLD_IRR, rec), rec, (float) (calcIrradiation(iv, datachan))); //AC Power is missing; we may have to calculate, as no respective data is in payload + if ( datachan < 3 ) { + mPayload[iv->id].dataAB[datachan] = true; + } + if ( !mPayload[iv->id].dataAB[CH0] && mPayload[iv->id].dataAB[CH2] && mPayload[iv->id].dataAB[CH2] ) { + mPayload[iv->id].dataAB[CH0] = true; + } + if (p->packet[0] >= (0x36 + ALL_FRAMES) ) { /*For MI1500: @@ -459,17 +530,24 @@ class MiPayload { } if (p->packet[0] < (0x39 + ALL_FRAMES) ) { - uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; + /*uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); - mPayload[iv->id].txCmd = cmd; + mPayload[iv->id].txCmd = cmd;*/ mPayload[iv->id].complete = false; } + else if (p->packet[0] == (0x39 + ALL_FRAMES) ) { + /*uint8_t cmd = p->packet[0] - ALL_FRAMES + 1; + mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); + mPayload[iv->id].txCmd = cmd;*/ + mPayload[iv->id].complete = true; + } + //iv->setValue(iv->getPosByChFld(0, FLD_EVT, rec), rec, calcMiSts(iv));yield(); if (iv->alarmMesIndex < rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]){ iv->alarmMesIndex = rec->record[iv->getPosByChFld(0, FLD_EVT, rec)]; - DPRINTLN(DBG_INFO, "alarm ID incremented to " + String(iv->alarmMesIndex)); + DPRINTLN(DBG_INFO, F("alarm ID incremented to ") + String(iv->alarmMesIndex)); //iv->enqueCommand(AlarmData); } @@ -482,28 +560,30 @@ class MiPayload { //} iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10)); - if ( mPayload[iv->id].sts[0] ) { - uint8_t cmd = mPayload[iv->id].dataAB[0] ? 0x11 : 0x09; - if ( mPayload[iv->id].dataAB[0] && mPayload[iv->id].dataAB[1] ) { + if ( mPayload[iv->id].complete || //4ch device + iv->type != INV_TYPE_4CH //other devices + && mPayload[iv->id].dataAB[CH0] + && mPayload[iv->id].stsAB[CH0] ) { mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short... - DPRINTLN(DBG_INFO, F("complete tree detected")); + DPRINTLN(DBG_INFO, F("rec. complete set of msgs")); iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); iv->doCalculations(); - } else { + /*} else { //retry to get missing status info for one or two channel devices DPRINTLN(DBG_INFO, F("request missing data or status 0x") + String(cmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); mPayload[iv->id].txCmd = cmd; //iv->enqueCommand(cmd); // mPayload[iv->id].dataAB[1] ? 0x09 : 0x11) - } - } // not yet moved to hmInverter::getQueuedCmd + }*/ + } + /* should be included in process() else if (mPayload[iv->id].txCmd == 0x09 && iv->type == INV_TYPE_2CH) { uint8_t cmd = 0x11; DPRINTLN(DBG_INFO, F("request second data channel 0x") + String(cmd, HEX)); mSys->Radio.prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false, cmd); mPayload[iv->id].txCmd = cmd; mPayload[iv->id].complete = false; - } + }*/ iv->setQueuedCmdFinished(); mStat->rxSuccess++; @@ -539,9 +619,9 @@ class MiPayload { uint8_t txCmd = mPayload[id].txCmd; //uint8_t cmd = getQueuedCmd(); if(!*complete) { - //if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 ) - // return false; DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX)); + if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 ) + return false; } /*for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) { @@ -560,24 +640,27 @@ class MiPayload { } void reset(uint8_t id) { - DPRINTLN(DBG_INFO, "resetPayload: id: " + String(id)); + DPRINTLN(DBG_INFO, F("resetPayload: id: ") + String(id)); memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES); - /* mPayload[id].gotFragment = false; - mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; + /*mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES; mPayload[id].lastFound = false;*/ mPayload[id].retransmits = 0; mPayload[id].complete = false; - mPayload[id].dataAB[0] = true; //only required for 2CH devices - mPayload[id].dataAB[1] = true; + mPayload[id].dataAB[CH0] = true; //required for 1CH and 2CH devices + mPayload[id].dataAB[CH1] = true; //required for 1CH and 2CH devices + mPayload[id].dataAB[CH2] = true; //only required for 2CH devices + mPayload[id].stsAB[CH0] = true; //required for 1CH and 2CH devices + mPayload[id].stsAB[CH1] = true; //required for 1CH and 2CH devices + mPayload[id].stsAB[CH2] = true; //only required for 2CH devices mPayload[id].txCmd = 0; mPayload[id].requested = false; mPayload[id].ts = *mTimestamp; - //mPayload[id].sts[0] = 0; - mPayload[id].sts[1] = 0; - mPayload[id].sts[2] = 0; - mPayload[id].sts[3] = 0; - mPayload[id].sts[4] = 0; + mPayload[id].sts[0] = 0; //disable this in case gotFragment is not working + mPayload[id].sts[CH1] = 0; + mPayload[id].sts[CH2] = 0; + mPayload[id].sts[CH3] = 0; + mPayload[id].sts[CH4] = 0; } From 6dbb88e27ecf77a1b6487a559fc6538d6255617d Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 6 Mar 2023 22:53:38 +0100 Subject: [PATCH 17/26] added ePaper (for ESP32 only!), thx @dAjaY85 #735 improved `/live` margins #732 renamed `var` to `VAr` #732 --- src/CHANGES.md | 5 + src/LICENSE | 7 + src/app.cpp | 38 +- src/app.h | 426 +++---- src/config/settings.h | 826 ++++++------ src/defines.h | 2 +- src/platformio.ini | 7 +- src/plugins/Display/Display.h | 142 +-- src/plugins/Display/Display_Mono.cpp | 205 +-- src/plugins/Display/Display_Mono.h | 49 +- src/plugins/Display/Display_ePaper.cpp | 65 +- src/plugins/Display/Display_ePaper.h | 38 +- src/plugins/Display/imagedata.cpp | 642 ---------- src/plugins/Display/imagedata.h | 332 ++++- src/web/RestApi.h | 1197 +++++++++--------- src/web/html/setup.html | 58 +- src/web/html/style.css | 36 + src/web/html/visualization.html | 5 +- src/web/web.h | 1600 ++++++++++++------------ 19 files changed, 2678 insertions(+), 3002 deletions(-) create mode 100644 src/LICENSE delete mode 100644 src/plugins/Display/imagedata.cpp diff --git a/src/CHANGES.md b/src/CHANGES.md index 043e8578..78d3c728 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,11 @@ (starting from release version `0.5.66`) +## 0.5.94 +* added ePaper (for ESP32 only!), thx @dAjaY85 #735 +* improved `/live` margins #732 +* renamed `var` to `VAr` #732 + ## 0.5.93 * improved web API for `live` * added dark mode option diff --git a/src/LICENSE b/src/LICENSE new file mode 100644 index 00000000..057d1565 --- /dev/null +++ b/src/LICENSE @@ -0,0 +1,7 @@ +License + +CC-CY-NC-SA 3.0 + +https://creativecommons.org/licenses/by-nc-sa/3.0/de + +This project is for non-commercial use only! diff --git a/src/app.cpp b/src/app.cpp index e6b577bc..d65dbe1d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -4,14 +4,13 @@ //----------------------------------------------------------------------------- #include "app.h" - #include - #include "utils/sun.h" //----------------------------------------------------------------------------- app::app() : ah::Scheduler() {} + //----------------------------------------------------------------------------- void app::setup() { Serial.begin(115200); @@ -33,16 +32,16 @@ void app::setup() { mSys.enableDebug(); mSys.setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs); -#if defined(AP_ONLY) + #if defined(AP_ONLY) mInnerLoopCb = std::bind(&app::loopStandard, this); -#else + #else mInnerLoopCb = std::bind(&app::loopWifi, this); -#endif + #endif mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onWifi, this, std::placeholders::_1)); -#if !defined(AP_ONLY) + #if !defined(AP_ONLY) everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL"); -#endif + #endif mSys.addInverters(&mConfig->inst); @@ -61,15 +60,15 @@ void app::setup() { if (!mSys.Radio.isChipConnected()) DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring")); -// when WiFi is in client mode, then enable mqtt broker -#if !defined(AP_ONLY) + // when WiFi is in client mode, then enable mqtt broker + #if !defined(AP_ONLY) mMqttEnabled = (mConfig->mqtt.broker[0] > 0); if (mMqttEnabled) { mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, &mSys, &mTimestamp); mMqtt.setSubscriptionCb(std::bind(&app::mqttSubRxCb, this, std::placeholders::_1)); mPayload.addAlarmListener(std::bind(&PubMqttType::alarmEventListener, &mMqtt, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); } -#endif + #endif setupLed(); mWeb.setup(this, &mSys, mConfig); @@ -85,6 +84,7 @@ void app::setup() { regularTickers(); + // DBGPRINTLN("--- end setup"); // DBGPRINTLN(String(ESP.getFreeHeap())); // DBGPRINTLN(String(ESP.getHeapFragmentation())); @@ -214,15 +214,15 @@ void app::tickNtpUpdate(void) { //----------------------------------------------------------------------------- void app::tickCalcSunrise(void) { - if (mSunrise == 0) // on boot/reboot calc sun values for current time + if (mSunrise == 0) // on boot/reboot calc sun values for current time ah::calculateSunriseSunset(mTimestamp, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset); - if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) // current time is past communication stop, calc sun values for next day + if (mTimestamp > (mSunset + mConfig->sun.offsetSec)) // current time is past communication stop, calc sun values for next day ah::calculateSunriseSunset(mTimestamp + 86400, mCalculatedTimezoneOffset, mConfig->sun.lat, mConfig->sun.lon, &mSunrise, &mSunset); tickIVCommunication(); - uint32_t nxtTrig = mSunset + mConfig->sun.offsetSec + 60; // set next trigger to communication stop, +60 for safety that it is certain past communication stop + uint32_t nxtTrig = mSunset + mConfig->sun.offsetSec + 60; // set next trigger to communication stop, +60 for safety that it is certain past communication stop onceAt(std::bind(&app::tickCalcSunrise, this), nxtTrig, "Sunri"); if (mMqttEnabled) tickSun(); @@ -230,15 +230,15 @@ void app::tickCalcSunrise(void) { //----------------------------------------------------------------------------- void app::tickIVCommunication(void) { - mIVCommunicationOn = !mConfig->sun.disNightCom; // if sun.disNightCom is false, communication is always on - if (!mIVCommunicationOn) { // inverter communication only during the day + mIVCommunicationOn = !mConfig->sun.disNightCom; // if sun.disNightCom is false, communication is always on + if (!mIVCommunicationOn) { // inverter communication only during the day uint32_t nxtTrig; - if (mTimestamp < (mSunrise - mConfig->sun.offsetSec)) { // current time is before communication start, set next trigger to communication start + if (mTimestamp < (mSunrise - mConfig->sun.offsetSec)) { // current time is before communication start, set next trigger to communication start nxtTrig = mSunrise - mConfig->sun.offsetSec; } else { - if (mTimestamp >= (mSunset + mConfig->sun.offsetSec)) { // current time is past communication stop, nothing to do. Next update will be done at midnight by tickCalcSunrise + if (mTimestamp >= (mSunset + mConfig->sun.offsetSec)) { // current time is past communication stop, nothing to do. Next update will be done at midnight by tickCalcSunrise nxtTrig = 0; - } else { // current time lies within communication start/stop time, set next trigger to communication stop + } else { // current time lies within communication start/stop time, set next trigger to communication stop mIVCommunicationOn = true; nxtTrig = mSunset + mConfig->sun.offsetSec; } @@ -367,7 +367,7 @@ void app::resetSystem(void) { mSendFirst = true; mSunrise = 0; - mSunset = 0; + mSunset = 0; mMqttEnabled = false; diff --git a/src/app.h b/src/app.h index 8e7c5617..b68dc0c4 100644 --- a/src/app.h +++ b/src/app.h @@ -46,229 +46,229 @@ typedef Display DisplayType; class app : public IApp, public ah::Scheduler { public: - app(); - ~app() {} - - void setup(void); - void loop(void); - void loopStandard(void); - void loopWifi(void); - void onWifi(bool gotIp); - void regularTickers(void); - - void handleIntr(void) { - mSys.Radio.handleIntr(); - } - - uint32_t getUptime() { - return Scheduler::getUptime(); - } - - uint32_t getTimestamp() { - return Scheduler::getTimestamp(); - } - - bool saveSettings() { - mShowRebootRequest = true; - return mSettings.saveSettings(); - } - - bool readSettings(const char *path) { - return mSettings.readSettings(path); - } - - bool eraseSettings(bool eraseWifi = false) { - return mSettings.eraseSettings(eraseWifi); - } - - statistics_t *getStatistics() { - return &mStat; - } - - void scanAvailNetworks() { - mWifi.scanAvailNetworks(); - } - - void getAvailNetworks(JsonObject obj) { - mWifi.getAvailNetworks(obj); - } - - void setOnUpdate() { - onWifi(false); - } - - void setRebootFlag() { - once(std::bind(&app::tickReboot, this), 3, "rboot"); - } - - const char *getVersion() { - return mVersion; - } - - uint32_t getSunrise() { - return mSunrise; - } - - uint32_t getSunset() { - return mSunset; - } - - bool getSettingsValid() { - return mSettings.getValid(); - } - - bool getRebootRequestState() { - return mShowRebootRequest; - } - - void setMqttDiscoveryFlag() { - once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1, "disCf"); - } - - void setMqttPowerLimitAck(Inverter<> *iv) { - mMqtt.setPowerLimitAck(iv); - } - - void ivSendHighPrio(Inverter<> *iv) { - if (mIVCommunicationOn) // only send commands if communcation is enabled - mPayload.ivSendHighPrio(iv); - } - - bool getMqttIsConnected() { - return mMqtt.isConnected(); - } - - uint32_t getMqttTxCnt() { - return mMqtt.getTxCnt(); - } - - uint32_t getMqttRxCnt() { - return mMqtt.getRxCnt(); - } - - bool getProtection() { - return mWeb.getProtection(); - } - - uint8_t getIrqPin(void) { - return mConfig->nrf.pinIrq; - } - - String getTimeStr(uint32_t offset = 0) { - char str[10]; - if (0 == mTimestamp) - sprintf(str, "n/a"); - else - sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset)); - return String(str); - } - - uint32_t getTimezoneOffset() { - return mApi.getTimezoneOffset(); - } - - void getSchedulerInfo(uint8_t *max) { - getStat(max); - } - - void getSchedulerNames(void) { - printSchedulers(); - } - - void setTimestamp(uint32_t newTime) { - DPRINT(DBG_DEBUG, F("setTimestamp: ")); - DBGPRINTLN(String(newTime)); - if (0 == newTime) - mWifi.getNtpTime(); - else - Scheduler::setTimestamp(newTime); - } - - HmSystemType mSys; - - private: - typedef std::function innerLoopCb; - - void resetSystem(void); - - void payloadEventListener(uint8_t cmd) { -#if !defined(AP_ONLY) - if (mMqttEnabled) - mMqtt.payloadEventListener(cmd); -#endif - if (mConfig->plugin.display.type != 0) - mDisplay.payloadEventListener(cmd); - } - - void mqttSubRxCb(JsonObject obj); - - void setupLed(void); - void updateLed(void); - - void tickReboot(void) { - DPRINTLN(DBG_INFO, F("Rebooting...")); - onWifi(false); - ah::Scheduler::resetTicker(); - WiFi.disconnect(); - ESP.restart(); - } - - void tickNtpUpdate(void); - void tickCalcSunrise(void); - void tickIVCommunication(void); - void tickSun(void); - void tickComm(void); - void tickSend(void); - void tickMinute(void); - void tickZeroValues(void); - void tickMidnight(void); - /*void tickSerial(void) { - if(Serial.available() == 0) - return; - - uint8_t buf[80]; - uint8_t len = Serial.readBytes(buf, 80); - DPRINTLN(DBG_INFO, "got serial data, len: " + String(len)); - for(uint8_t i = 0; i < len; i++) { - if((0 != i) && (i % 8 == 0)) - DBGPRINTLN(""); - DBGPRINT(String(buf[i], HEX) + " "); + app(); + ~app() {} + + void setup(void); + void loop(void); + void loopStandard(void); + void loopWifi(void); + void onWifi(bool gotIp); + void regularTickers(void); + + void handleIntr(void) { + mSys.Radio.handleIntr(); } - DBGPRINTLN(""); - }*/ - innerLoopCb mInnerLoopCb; + uint32_t getUptime() { + return Scheduler::getUptime(); + } + + uint32_t getTimestamp() { + return Scheduler::getTimestamp(); + } - bool mShowRebootRequest; - bool mIVCommunicationOn; + bool saveSettings() { + mShowRebootRequest = true; + return mSettings.saveSettings(); + } - ahoywifi mWifi; - WebType mWeb; - RestApiType mApi; - PayloadType mPayload; - MiPayloadType mMiPayload; - PubSerialType mPubSerial; + bool readSettings(const char *path) { + return mSettings.readSettings(path); + } - char mVersion[12]; - settings mSettings; - settings_t *mConfig; + bool eraseSettings(bool eraseWifi = false) { + return mSettings.eraseSettings(eraseWifi); + } - uint8_t mSendLastIvId; - bool mSendFirst; + statistics_t *getStatistics() { + return &mStat; + } - statistics_t mStat; + void scanAvailNetworks() { + mWifi.scanAvailNetworks(); + } - // mqtt - PubMqttType mMqtt; - bool mMqttReconnect; - bool mMqttEnabled; + void getAvailNetworks(JsonObject obj) { + mWifi.getAvailNetworks(obj); + } + + void setOnUpdate() { + onWifi(false); + } + + void setRebootFlag() { + once(std::bind(&app::tickReboot, this), 3, "rboot"); + } + + const char *getVersion() { + return mVersion; + } + + uint32_t getSunrise() { + return mSunrise; + } + + uint32_t getSunset() { + return mSunset; + } + + bool getSettingsValid() { + return mSettings.getValid(); + } + + bool getRebootRequestState() { + return mShowRebootRequest; + } + + void setMqttDiscoveryFlag() { + once(std::bind(&PubMqttType::sendDiscoveryConfig, &mMqtt), 1, "disCf"); + } + + void setMqttPowerLimitAck(Inverter<> *iv) { + mMqtt.setPowerLimitAck(iv); + } + + void ivSendHighPrio(Inverter<> *iv) { + if(mIVCommunicationOn) // only send commands if communcation is enabled + mPayload.ivSendHighPrio(iv); + } - // sun - int32_t mCalculatedTimezoneOffset; - uint32_t mSunrise, mSunset; + bool getMqttIsConnected() { + return mMqtt.isConnected(); + } + + uint32_t getMqttTxCnt() { + return mMqtt.getTxCnt(); + } + + uint32_t getMqttRxCnt() { + return mMqtt.getRxCnt(); + } + + bool getProtection() { + return mWeb.getProtection(); + } + + uint8_t getIrqPin(void) { + return mConfig->nrf.pinIrq; + } + + String getTimeStr(uint32_t offset = 0) { + char str[10]; + if(0 == mTimestamp) + sprintf(str, "n/a"); + else + sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset)); + return String(str); + } + + uint32_t getTimezoneOffset() { + return mApi.getTimezoneOffset(); + } + + void getSchedulerInfo(uint8_t *max) { + getStat(max); + } + + void getSchedulerNames(void) { + printSchedulers(); + } + + void setTimestamp(uint32_t newTime) { + DPRINT(DBG_DEBUG, F("setTimestamp: ")); + DBGPRINTLN(String(newTime)); + if(0 == newTime) + mWifi.getNtpTime(); + else + Scheduler::setTimestamp(newTime); + } + + HmSystemType mSys; + + private: + typedef std::function innerLoopCb; + + void resetSystem(void); + + void payloadEventListener(uint8_t cmd) { + #if !defined(AP_ONLY) + if (mMqttEnabled) + mMqtt.payloadEventListener(cmd); + #endif + if(mConfig->plugin.display.type != 0) + mDisplay.payloadEventListener(cmd); + } + + void mqttSubRxCb(JsonObject obj); + + void setupLed(void); + void updateLed(void); + + void tickReboot(void) { + DPRINTLN(DBG_INFO, F("Rebooting...")); + onWifi(false); + ah::Scheduler::resetTicker(); + WiFi.disconnect(); + ESP.restart(); + } - // plugins - DisplayType mDisplay; + void tickNtpUpdate(void); + void tickCalcSunrise(void); + void tickIVCommunication(void); + void tickSun(void); + void tickComm(void); + void tickSend(void); + void tickMinute(void); + void tickZeroValues(void); + void tickMidnight(void); + /*void tickSerial(void) { + if(Serial.available() == 0) + return; + + uint8_t buf[80]; + uint8_t len = Serial.readBytes(buf, 80); + DPRINTLN(DBG_INFO, "got serial data, len: " + String(len)); + for(uint8_t i = 0; i < len; i++) { + if((0 != i) && (i % 8 == 0)) + DBGPRINTLN(""); + DBGPRINT(String(buf[i], HEX) + " "); + } + DBGPRINTLN(""); + }*/ + + innerLoopCb mInnerLoopCb; + + bool mShowRebootRequest; + bool mIVCommunicationOn; + + ahoywifi mWifi; + WebType mWeb; + RestApiType mApi; + PayloadType mPayload; + MiPayloadType mMiPayload; + PubSerialType mPubSerial; + + char mVersion[12]; + settings mSettings; + settings_t *mConfig; + + uint8_t mSendLastIvId; + bool mSendFirst; + + statistics_t mStat; + + // mqtt + PubMqttType mMqtt; + bool mMqttReconnect; + bool mMqttEnabled; + + // sun + int32_t mCalculatedTimezoneOffset; + uint32_t mSunrise, mSunset; + + // plugins + DisplayType mDisplay; }; #endif /*__APP_H__*/ diff --git a/src/config/settings.h b/src/config/settings.h index b02b5a61..0e118bde 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -18,32 +18,34 @@ * More info: * https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html#flash-layout * */ -#define DEF_PIN_OFF 255 - -#define PROT_MASK_INDEX 0x0001 -#define PROT_MASK_LIVE 0x0002 -#define PROT_MASK_SERIAL 0x0004 -#define PROT_MASK_SETUP 0x0008 -#define PROT_MASK_UPDATE 0x0010 -#define PROT_MASK_SYSTEM 0x0020 -#define PROT_MASK_API 0x0040 -#define PROT_MASK_MQTT 0x0080 - -#define DEF_PROT_INDEX 0x0001 -#define DEF_PROT_LIVE 0x0000 -#define DEF_PROT_SERIAL 0x0004 -#define DEF_PROT_SETUP 0x0008 -#define DEF_PROT_UPDATE 0x0010 -#define DEF_PROT_SYSTEM 0x0020 -#define DEF_PROT_API 0x0000 -#define DEF_PROT_MQTT 0x0000 +#define DEF_PIN_OFF 255 + + +#define PROT_MASK_INDEX 0x0001 +#define PROT_MASK_LIVE 0x0002 +#define PROT_MASK_SERIAL 0x0004 +#define PROT_MASK_SETUP 0x0008 +#define PROT_MASK_UPDATE 0x0010 +#define PROT_MASK_SYSTEM 0x0020 +#define PROT_MASK_API 0x0040 +#define PROT_MASK_MQTT 0x0080 + +#define DEF_PROT_INDEX 0x0001 +#define DEF_PROT_LIVE 0x0000 +#define DEF_PROT_SERIAL 0x0004 +#define DEF_PROT_SETUP 0x0008 +#define DEF_PROT_UPDATE 0x0010 +#define DEF_PROT_SYSTEM 0x0020 +#define DEF_PROT_API 0x0000 +#define DEF_PROT_MQTT 0x0000 + typedef struct { - uint8_t ip[4]; // ip address - uint8_t mask[4]; // sub mask - uint8_t dns1[4]; // dns 1 - uint8_t dns2[4]; // dns 2 - uint8_t gateway[4]; // standard gateway + uint8_t ip[4]; // ip address + uint8_t mask[4]; // sub mask + uint8_t dns1[4]; // dns 1 + uint8_t dns2[4]; // dns 2 + uint8_t gateway[4]; // standard gateway } cfgIp_t; typedef struct { @@ -121,12 +123,10 @@ typedef struct { typedef struct { uint8_t type; bool pwrSaveAtIvOffline; - bool logoEn; bool pxShift; uint8_t rot; - uint16_t period; - uint16_t wakeUp; - uint16_t sleepAt; + //uint16_t wakeUp; + //uint16_t sleepAt; uint8_t contrast; uint8_t disp_data; uint8_t disp_clk; @@ -141,422 +141,418 @@ typedef struct { } plugins_t; typedef struct { - cfgSys_t sys; - cfgNrf24_t nrf; - cfgNtp_t ntp; - cfgSun_t sun; + cfgSys_t sys; + cfgNrf24_t nrf; + cfgNtp_t ntp; + cfgSun_t sun; cfgSerial_t serial; - cfgMqtt_t mqtt; - cfgLed_t led; - cfgInst_t inst; - plugins_t plugin; - bool valid; + cfgMqtt_t mqtt; + cfgLed_t led; + cfgInst_t inst; + plugins_t plugin; + bool valid; } settings_t; class settings { - public: - settings() {} - - void setup() { - DPRINTLN(DBG_INFO, F("Initializing FS ..")); - - mCfg.valid = false; -#if !defined(ESP32) - LittleFSConfig cfg; - cfg.setAutoFormat(false); - LittleFS.setConfig(cfg); -#define LITTLFS_TRUE -#define LITTLFS_FALSE -#else -#define LITTLFS_TRUE true -#define LITTLFS_FALSE false -#endif - - if (!LittleFS.begin(LITTLFS_FALSE)) { - DPRINTLN(DBG_INFO, F(".. format ..")); - LittleFS.format(); - if (LittleFS.begin(LITTLFS_TRUE)) { - DPRINTLN(DBG_INFO, F(".. success")); - } else { - DPRINTLN(DBG_INFO, F(".. failed")); - } + public: + settings() {} + + void setup() { + DPRINTLN(DBG_INFO, F("Initializing FS ..")); + + mCfg.valid = false; + #if !defined(ESP32) + LittleFSConfig cfg; + cfg.setAutoFormat(false); + LittleFS.setConfig(cfg); + #define LITTLFS_TRUE + #define LITTLFS_FALSE + #else + #define LITTLFS_TRUE true + #define LITTLFS_FALSE false + #endif + + if(!LittleFS.begin(LITTLFS_FALSE)) { + DPRINTLN(DBG_INFO, F(".. format ..")); + LittleFS.format(); + if(LittleFS.begin(LITTLFS_TRUE)) { + DPRINTLN(DBG_INFO, F(".. success")); + } else { + DPRINTLN(DBG_INFO, F(".. failed")); + } - } else - DPRINTLN(DBG_INFO, F(" .. done")); - - readSettings("/settings.json"); - } - - // should be used before OTA - void stop() { - LittleFS.end(); - DPRINTLN(DBG_INFO, F("FS stopped")); - } - - void getPtr(settings_t *&cfg) { - cfg = &mCfg; - } - - bool getValid(void) { - return mCfg.valid; - } - - void getInfo(uint32_t *used, uint32_t *size) { -#if !defined(ESP32) - FSInfo info; - LittleFS.info(info); - *used = info.usedBytes; - *size = info.totalBytes; - - DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --")); - DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used")); -#else - DPRINTLN(DBG_WARN, F("not supported by ESP32")); -#endif - } - - bool readSettings(const char *path) { - loadDefaults(); - File fp = LittleFS.open(path, "r"); - if (!fp) - DPRINTLN(DBG_WARN, F("failed to load json, using default config")); - else { - // DPRINTLN(DBG_INFO, fp.readString()); - // fp.seek(0, SeekSet); - DynamicJsonDocument root(4500); - DeserializationError err = deserializeJson(root, fp); - if (!err && (root.size() > 0)) { - mCfg.valid = true; - jsonWifi(root[F("wifi")]); - jsonNrf(root[F("nrf")]); - jsonNtp(root[F("ntp")]); - jsonSun(root[F("sun")]); - jsonSerial(root[F("serial")]); - jsonMqtt(root[F("mqtt")]); - jsonLed(root[F("led")]); - jsonPlugin(root[F("plugin")]); - jsonInst(root[F("inst")]); - } else { - Serial.println(F("failed to parse json, using default config")); } + else + DPRINTLN(DBG_INFO, F(" .. done")); - fp.close(); + readSettings("/settings.json"); } - return mCfg.valid; - } - - bool saveSettings(void) { - DPRINTLN(DBG_DEBUG, F("save settings")); - File fp = LittleFS.open("/settings.json", "w"); - if (!fp) { - DPRINTLN(DBG_ERROR, F("can't open settings file!")); - return false; + + // should be used before OTA + void stop() { + LittleFS.end(); + DPRINTLN(DBG_INFO, F("FS stopped")); } - DynamicJsonDocument json(5500); - JsonObject root = json.to(); - jsonWifi(root.createNestedObject(F("wifi")), true); - jsonNrf(root.createNestedObject(F("nrf")), true); - jsonNtp(root.createNestedObject(F("ntp")), true); - jsonSun(root.createNestedObject(F("sun")), true); - jsonSerial(root.createNestedObject(F("serial")), true); - jsonMqtt(root.createNestedObject(F("mqtt")), true); - jsonLed(root.createNestedObject(F("led")), true); - jsonPlugin(root.createNestedObject(F("plugin")), true); - jsonInst(root.createNestedObject(F("inst")), true); - - if (0 == serializeJson(root, fp)) { - DPRINTLN(DBG_ERROR, F("can't write settings file!")); - return false; + void getPtr(settings_t *&cfg) { + cfg = &mCfg; } - fp.close(); - - return true; - } - - bool eraseSettings(bool eraseWifi = false) { - if (true == eraseWifi) - return LittleFS.format(); - loadDefaults(!eraseWifi); - return saveSettings(); - } - - private: - void loadDefaults(bool keepWifi = false) { - DPRINTLN(DBG_VERBOSE, F("loadDefaults")); - - cfgSys_t tmp; - if (keepWifi) { - // copy contents which should not be deleted - memset(&tmp.adminPwd, 0, PWD_LEN); - memcpy(&tmp, &mCfg.sys, sizeof(cfgSys_t)); + + bool getValid(void) { + return mCfg.valid; } - // erase all settings and reset to default - memset(&mCfg, 0, sizeof(settings_t)); - mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; - mCfg.sys.darkMode = false; - // restore temp settings - if (keepWifi) - memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t)); - else { - snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); - snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); + + void getInfo(uint32_t *used, uint32_t *size) { + #if !defined(ESP32) + FSInfo info; + LittleFS.info(info); + *used = info.usedBytes; + *size = info.totalBytes; + + DPRINTLN(DBG_INFO, F("-- FILESYSTEM INFO --")); + DPRINTLN(DBG_INFO, String(info.usedBytes) + F(" of ") + String(info.totalBytes) + F(" used")); + #else + DPRINTLN(DBG_WARN, F("not supported by ESP32")); + #endif } - snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME); - - mCfg.nrf.sendInterval = SEND_INTERVAL; - mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; - mCfg.nrf.pinCs = DEF_CS_PIN; - mCfg.nrf.pinCe = DEF_CE_PIN; - mCfg.nrf.pinIrq = DEF_IRQ_PIN; - mCfg.nrf.amplifierPower = DEF_AMPLIFIERPOWER & 0x03; - - snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", DEF_NTP_SERVER_NAME); - mCfg.ntp.port = DEF_NTP_PORT; - - mCfg.sun.lat = 0.0; - mCfg.sun.lon = 0.0; - mCfg.sun.disNightCom = false; - mCfg.sun.offsetSec = 0; - - mCfg.serial.interval = SERIAL_INTERVAL; - mCfg.serial.showIv = false; - mCfg.serial.debug = false; - - mCfg.mqtt.port = DEF_MQTT_PORT; - snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER); - snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", DEF_MQTT_USER); - snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD); - snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC); - mCfg.mqtt.interval = 0; // off - - mCfg.inst.rstYieldMidNight = false; - mCfg.inst.rstValsNotAvail = false; - mCfg.inst.rstValsCommStop = false; - - mCfg.led.led0 = DEF_PIN_OFF; - mCfg.led.led1 = DEF_PIN_OFF; - - memset(&mCfg.inst, 0, sizeof(cfgInst_t)); - - mCfg.plugin.display.pwrSaveAtIvOffline = false; - mCfg.plugin.display.contrast = 60; - mCfg.plugin.display.logoEn = true; - mCfg.plugin.display.pxShift = true; - mCfg.plugin.display.rot = 0; - mCfg.plugin.display.period = 10000; - mCfg.plugin.display.disp_data = DEF_PIN_OFF; // SDA - mCfg.plugin.display.disp_clk = DEF_PIN_OFF; // SCL - mCfg.plugin.display.disp_cs = DEF_PIN_OFF; - mCfg.plugin.display.disp_reset = DEF_PIN_OFF; - mCfg.plugin.display.disp_busy = DEF_PIN_OFF; - mCfg.plugin.display.disp_dc = DEF_PIN_OFF; - } - - void jsonWifi(JsonObject obj, bool set = false) { - if (set) { - char buf[16]; - obj[F("ssid")] = mCfg.sys.stationSsid; - obj[F("pwd")] = mCfg.sys.stationPwd; - obj[F("dev")] = mCfg.sys.deviceName; - obj[F("adm")] = mCfg.sys.adminPwd; - obj[F("prot_mask")] = mCfg.sys.protectionMask; - obj[F("dark")] = mCfg.sys.darkMode; - ah::ip2Char(mCfg.sys.ip.ip, buf); - obj[F("ip")] = String(buf); - ah::ip2Char(mCfg.sys.ip.mask, buf); - obj[F("mask")] = String(buf); - ah::ip2Char(mCfg.sys.ip.dns1, buf); - obj[F("dns1")] = String(buf); - ah::ip2Char(mCfg.sys.ip.dns2, buf); - obj[F("dns2")] = String(buf); - ah::ip2Char(mCfg.sys.ip.gateway, buf); - obj[F("gtwy")] = String(buf); - } else { - snprintf(mCfg.sys.stationSsid, SSID_LEN, "%s", obj[F("ssid")].as()); - snprintf(mCfg.sys.stationPwd, PWD_LEN, "%s", obj[F("pwd")].as()); - snprintf(mCfg.sys.deviceName, DEVNAME_LEN, "%s", obj[F("dev")].as()); - snprintf(mCfg.sys.adminPwd, PWD_LEN, "%s", obj[F("adm")].as()); - mCfg.sys.protectionMask = obj[F("prot_mask")]; - mCfg.sys.darkMode = obj[F("dark")]; - ah::ip2Arr(mCfg.sys.ip.ip, obj[F("ip")].as()); - ah::ip2Arr(mCfg.sys.ip.mask, obj[F("mask")].as()); - ah::ip2Arr(mCfg.sys.ip.dns1, obj[F("dns1")].as()); - ah::ip2Arr(mCfg.sys.ip.dns2, obj[F("dns2")].as()); - ah::ip2Arr(mCfg.sys.ip.gateway, obj[F("gtwy")].as()); - - if (mCfg.sys.protectionMask == 0) - mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; + bool readSettings(const char* path) { + loadDefaults(); + File fp = LittleFS.open(path, "r"); + if(!fp) + DPRINTLN(DBG_WARN, F("failed to load json, using default config")); + else { + //DPRINTLN(DBG_INFO, fp.readString()); + //fp.seek(0, SeekSet); + DynamicJsonDocument root(5500); + DeserializationError err = deserializeJson(root, fp); + if(!err && (root.size() > 0)) { + mCfg.valid = true; + jsonWifi(root[F("wifi")]); + jsonNrf(root[F("nrf")]); + jsonNtp(root[F("ntp")]); + jsonSun(root[F("sun")]); + jsonSerial(root[F("serial")]); + jsonMqtt(root[F("mqtt")]); + jsonLed(root[F("led")]); + jsonPlugin(root[F("plugin")]); + jsonInst(root[F("inst")]); + } + else { + Serial.println(F("failed to parse json, using default config")); + } + + fp.close(); + } + return mCfg.valid; } - } - - void jsonNrf(JsonObject obj, bool set = false) { - if (set) { - obj[F("intvl")] = mCfg.nrf.sendInterval; - obj[F("maxRetry")] = mCfg.nrf.maxRetransPerPyld; - obj[F("cs")] = mCfg.nrf.pinCs; - obj[F("ce")] = mCfg.nrf.pinCe; - obj[F("irq")] = mCfg.nrf.pinIrq; - obj[F("pwr")] = mCfg.nrf.amplifierPower; - } else { - mCfg.nrf.sendInterval = obj[F("intvl")]; - mCfg.nrf.maxRetransPerPyld = obj[F("maxRetry")]; - mCfg.nrf.pinCs = obj[F("cs")]; - mCfg.nrf.pinCe = obj[F("ce")]; - mCfg.nrf.pinIrq = obj[F("irq")]; - mCfg.nrf.amplifierPower = obj[F("pwr")]; + + bool saveSettings(void) { + DPRINTLN(DBG_DEBUG, F("save settings")); + File fp = LittleFS.open("/settings.json", "w"); + if(!fp) { + DPRINTLN(DBG_ERROR, F("can't open settings file!")); + return false; + } + + DynamicJsonDocument json(6500); + JsonObject root = json.to(); + jsonWifi(root.createNestedObject(F("wifi")), true); + jsonNrf(root.createNestedObject(F("nrf")), true); + jsonNtp(root.createNestedObject(F("ntp")), true); + jsonSun(root.createNestedObject(F("sun")), true); + jsonSerial(root.createNestedObject(F("serial")), true); + jsonMqtt(root.createNestedObject(F("mqtt")), true); + jsonLed(root.createNestedObject(F("led")), true); + jsonPlugin(root.createNestedObject(F("plugin")), true); + jsonInst(root.createNestedObject(F("inst")), true); + + if(0 == serializeJson(root, fp)) { + DPRINTLN(DBG_ERROR, F("can't write settings file!")); + return false; + } + fp.close(); + + return true; } - } - - void jsonNtp(JsonObject obj, bool set = false) { - if (set) { - obj[F("addr")] = mCfg.ntp.addr; - obj[F("port")] = mCfg.ntp.port; - } else { - snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", obj[F("addr")].as()); - mCfg.ntp.port = obj[F("port")]; + + bool eraseSettings(bool eraseWifi = false) { + if(true == eraseWifi) + return LittleFS.format(); + loadDefaults(!eraseWifi); + return saveSettings(); } - } - - void jsonSun(JsonObject obj, bool set = false) { - if (set) { - obj[F("lat")] = mCfg.sun.lat; - obj[F("lon")] = mCfg.sun.lon; - obj[F("dis")] = mCfg.sun.disNightCom; - obj[F("offs")] = mCfg.sun.offsetSec; - } else { - mCfg.sun.lat = obj[F("lat")]; - mCfg.sun.lon = obj[F("lon")]; - mCfg.sun.disNightCom = obj[F("dis")]; - mCfg.sun.offsetSec = obj[F("offs")]; + + private: + void loadDefaults(bool keepWifi = false) { + DPRINTLN(DBG_VERBOSE, F("loadDefaults")); + + cfgSys_t tmp; + if(keepWifi) { + // copy contents which should not be deleted + memset(&tmp.adminPwd, 0, PWD_LEN); + memcpy(&tmp, &mCfg.sys, sizeof(cfgSys_t)); + } + // erase all settings and reset to default + memset(&mCfg, 0, sizeof(settings_t)); + mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP + | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; + mCfg.sys.darkMode = false; + // restore temp settings + if(keepWifi) + memcpy(&mCfg.sys, &tmp, sizeof(cfgSys_t)); + else { + snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); + snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); + } + + snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME); + + mCfg.nrf.sendInterval = SEND_INTERVAL; + mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; + mCfg.nrf.pinCs = DEF_CS_PIN; + mCfg.nrf.pinCe = DEF_CE_PIN; + mCfg.nrf.pinIrq = DEF_IRQ_PIN; + mCfg.nrf.amplifierPower = DEF_AMPLIFIERPOWER & 0x03; + + snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", DEF_NTP_SERVER_NAME); + mCfg.ntp.port = DEF_NTP_PORT; + + mCfg.sun.lat = 0.0; + mCfg.sun.lon = 0.0; + mCfg.sun.disNightCom = false; + mCfg.sun.offsetSec = 0; + + mCfg.serial.interval = SERIAL_INTERVAL; + mCfg.serial.showIv = false; + mCfg.serial.debug = false; + + mCfg.mqtt.port = DEF_MQTT_PORT; + snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER); + snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", DEF_MQTT_USER); + snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD); + snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC); + mCfg.mqtt.interval = 0; // off + + mCfg.inst.rstYieldMidNight = false; + mCfg.inst.rstValsNotAvail = false; + mCfg.inst.rstValsCommStop = false; + + mCfg.led.led0 = DEF_PIN_OFF; + mCfg.led.led1 = DEF_PIN_OFF; + + memset(&mCfg.inst, 0, sizeof(cfgInst_t)); + + mCfg.plugin.display.pwrSaveAtIvOffline = false; + mCfg.plugin.display.contrast = 60; + mCfg.plugin.display.pxShift = true; + mCfg.plugin.display.rot = 0; + mCfg.plugin.display.disp_data = DEF_PIN_OFF; // SDA + mCfg.plugin.display.disp_clk = DEF_PIN_OFF; // SCL + mCfg.plugin.display.disp_cs = DEF_PIN_OFF; + mCfg.plugin.display.disp_reset = DEF_PIN_OFF; + mCfg.plugin.display.disp_busy = DEF_PIN_OFF; + mCfg.plugin.display.disp_dc = DEF_PIN_OFF; + } + + void jsonWifi(JsonObject obj, bool set = false) { + if(set) { + char buf[16]; + obj[F("ssid")] = mCfg.sys.stationSsid; + obj[F("pwd")] = mCfg.sys.stationPwd; + obj[F("dev")] = mCfg.sys.deviceName; + obj[F("adm")] = mCfg.sys.adminPwd; + obj[F("prot_mask")] = mCfg.sys.protectionMask; + obj[F("dark")] = mCfg.sys.darkMode; + ah::ip2Char(mCfg.sys.ip.ip, buf); obj[F("ip")] = String(buf); + ah::ip2Char(mCfg.sys.ip.mask, buf); obj[F("mask")] = String(buf); + ah::ip2Char(mCfg.sys.ip.dns1, buf); obj[F("dns1")] = String(buf); + ah::ip2Char(mCfg.sys.ip.dns2, buf); obj[F("dns2")] = String(buf); + ah::ip2Char(mCfg.sys.ip.gateway, buf); obj[F("gtwy")] = String(buf); + } else { + snprintf(mCfg.sys.stationSsid, SSID_LEN, "%s", obj[F("ssid")].as()); + snprintf(mCfg.sys.stationPwd, PWD_LEN, "%s", obj[F("pwd")].as()); + snprintf(mCfg.sys.deviceName, DEVNAME_LEN, "%s", obj[F("dev")].as()); + snprintf(mCfg.sys.adminPwd, PWD_LEN, "%s", obj[F("adm")].as()); + mCfg.sys.protectionMask = obj[F("prot_mask")]; + mCfg.sys.darkMode = obj[F("dark")]; + ah::ip2Arr(mCfg.sys.ip.ip, obj[F("ip")].as()); + ah::ip2Arr(mCfg.sys.ip.mask, obj[F("mask")].as()); + ah::ip2Arr(mCfg.sys.ip.dns1, obj[F("dns1")].as()); + ah::ip2Arr(mCfg.sys.ip.dns2, obj[F("dns2")].as()); + ah::ip2Arr(mCfg.sys.ip.gateway, obj[F("gtwy")].as()); + + if(mCfg.sys.protectionMask == 0) + mCfg.sys.protectionMask = DEF_PROT_INDEX | DEF_PROT_LIVE | DEF_PROT_SERIAL | DEF_PROT_SETUP + | DEF_PROT_UPDATE | DEF_PROT_SYSTEM | DEF_PROT_API | DEF_PROT_MQTT; + } } - } - - void jsonSerial(JsonObject obj, bool set = false) { - if (set) { - obj[F("intvl")] = mCfg.serial.interval; - obj[F("show")] = mCfg.serial.showIv; - obj[F("debug")] = mCfg.serial.debug; - } else { - mCfg.serial.interval = obj[F("intvl")]; - mCfg.serial.showIv = obj[F("show")]; - mCfg.serial.debug = obj[F("debug")]; + + void jsonNrf(JsonObject obj, bool set = false) { + if(set) { + obj[F("intvl")] = mCfg.nrf.sendInterval; + obj[F("maxRetry")] = mCfg.nrf.maxRetransPerPyld; + obj[F("cs")] = mCfg.nrf.pinCs; + obj[F("ce")] = mCfg.nrf.pinCe; + obj[F("irq")] = mCfg.nrf.pinIrq; + obj[F("pwr")] = mCfg.nrf.amplifierPower; + } else { + mCfg.nrf.sendInterval = obj[F("intvl")]; + mCfg.nrf.maxRetransPerPyld = obj[F("maxRetry")]; + mCfg.nrf.pinCs = obj[F("cs")]; + mCfg.nrf.pinCe = obj[F("ce")]; + mCfg.nrf.pinIrq = obj[F("irq")]; + mCfg.nrf.amplifierPower = obj[F("pwr")]; + } } - } - - void jsonMqtt(JsonObject obj, bool set = false) { - if (set) { - obj[F("broker")] = mCfg.mqtt.broker; - obj[F("port")] = mCfg.mqtt.port; - obj[F("user")] = mCfg.mqtt.user; - obj[F("pwd")] = mCfg.mqtt.pwd; - obj[F("topic")] = mCfg.mqtt.topic; - obj[F("intvl")] = mCfg.mqtt.interval; - - } else { - mCfg.mqtt.port = obj[F("port")]; - mCfg.mqtt.interval = obj[F("intvl")]; - snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", obj[F("broker")].as()); - snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", obj[F("user")].as()); - snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", obj[F("pwd")].as()); - snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", obj[F("topic")].as()); + + void jsonNtp(JsonObject obj, bool set = false) { + if(set) { + obj[F("addr")] = mCfg.ntp.addr; + obj[F("port")] = mCfg.ntp.port; + } else { + snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", obj[F("addr")].as()); + mCfg.ntp.port = obj[F("port")]; + } + } + + void jsonSun(JsonObject obj, bool set = false) { + if(set) { + obj[F("lat")] = mCfg.sun.lat; + obj[F("lon")] = mCfg.sun.lon; + obj[F("dis")] = mCfg.sun.disNightCom; + obj[F("offs")] = mCfg.sun.offsetSec; + } else { + mCfg.sun.lat = obj[F("lat")]; + mCfg.sun.lon = obj[F("lon")]; + mCfg.sun.disNightCom = obj[F("dis")]; + mCfg.sun.offsetSec = obj[F("offs")]; + } } - } - - void jsonLed(JsonObject obj, bool set = false) { - if (set) { - obj[F("0")] = mCfg.led.led0; - obj[F("1")] = mCfg.led.led1; - } else { - mCfg.led.led0 = obj[F("0")]; - mCfg.led.led1 = obj[F("1")]; + + void jsonSerial(JsonObject obj, bool set = false) { + if(set) { + obj[F("intvl")] = mCfg.serial.interval; + obj[F("show")] = mCfg.serial.showIv; + obj[F("debug")] = mCfg.serial.debug; + } else { + mCfg.serial.interval = obj[F("intvl")]; + mCfg.serial.showIv = obj[F("show")]; + mCfg.serial.debug = obj[F("debug")]; + } } - } - - void jsonPlugin(JsonObject obj, bool set = false) { - if (set) { - JsonObject disp = obj.createNestedObject("disp"); - disp[F("type")] = mCfg.plugin.display.type; - disp[F("pwrSafe")] = (bool)mCfg.plugin.display.pwrSaveAtIvOffline; - disp[F("period")] = mCfg.plugin.display.period; - disp[F("pxShift")] = (bool)mCfg.plugin.display.pxShift; - disp[F("rotation")] = mCfg.plugin.display.rot; - disp[F("wake")] = mCfg.plugin.display.wakeUp; - disp[F("sleep")] = mCfg.plugin.display.sleepAt; - disp[F("contrast")] = mCfg.plugin.display.contrast; - disp[F("data")] = mCfg.plugin.display.disp_data; - disp[F("clock")] = mCfg.plugin.display.disp_clk; - disp[F("cs")] = mCfg.plugin.display.disp_cs; - disp[F("reset")] = mCfg.plugin.display.disp_reset; - disp[F("busy")] = mCfg.plugin.display.disp_busy; - disp[F("dc")] = mCfg.plugin.display.disp_dc; - } else { - JsonObject disp = obj["disp"]; - mCfg.plugin.display.type = disp[F("type")]; - mCfg.plugin.display.pwrSaveAtIvOffline = (bool)disp[F("pwrSafe")]; - mCfg.plugin.display.period = disp[F("period")]; - mCfg.plugin.display.pxShift = (bool)disp[F("pxShift")]; - mCfg.plugin.display.rot = disp[F("rotation")]; - mCfg.plugin.display.wakeUp = disp[F("wake")]; - mCfg.plugin.display.sleepAt = disp[F("sleep")]; - mCfg.plugin.display.contrast = disp[F("contrast")]; - mCfg.plugin.display.disp_data = disp[F("data")]; - mCfg.plugin.display.disp_clk = disp[F("clock")]; - mCfg.plugin.display.disp_cs = disp[F("cs")]; - mCfg.plugin.display.disp_reset = disp[F("reset")]; - mCfg.plugin.display.disp_busy = disp[F("busy")]; - mCfg.plugin.display.disp_dc = disp[F("dc")]; + + void jsonMqtt(JsonObject obj, bool set = false) { + if(set) { + obj[F("broker")] = mCfg.mqtt.broker; + obj[F("port")] = mCfg.mqtt.port; + obj[F("user")] = mCfg.mqtt.user; + obj[F("pwd")] = mCfg.mqtt.pwd; + obj[F("topic")] = mCfg.mqtt.topic; + obj[F("intvl")] = mCfg.mqtt.interval; + + } else { + mCfg.mqtt.port = obj[F("port")]; + mCfg.mqtt.interval = obj[F("intvl")]; + snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", obj[F("broker")].as()); + snprintf(mCfg.mqtt.user, MQTT_USER_LEN, "%s", obj[F("user")].as()); + snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", obj[F("pwd")].as()); + snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", obj[F("topic")].as()); + } } - } - - void jsonInst(JsonObject obj, bool set = false) { - if (set) { - obj[F("en")] = (bool)mCfg.inst.enabled; - obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight; - obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail; - obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop; - } else { - mCfg.inst.enabled = (bool)obj[F("en")]; - mCfg.inst.rstYieldMidNight = (bool)obj["rstMidNight"]; - mCfg.inst.rstValsNotAvail = (bool)obj["rstNotAvail"]; - mCfg.inst.rstValsCommStop = (bool)obj["rstComStop"]; + + void jsonLed(JsonObject obj, bool set = false) { + if(set) { + obj[F("0")] = mCfg.led.led0; + obj[F("1")] = mCfg.led.led1; + } else { + mCfg.led.led0 = obj[F("0")]; + mCfg.led.led1 = obj[F("1")]; + } } - JsonArray ivArr; - if (set) - ivArr = obj.createNestedArray(F("iv")); - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - if (set) - jsonIv(ivArr.createNestedObject(), &mCfg.inst.iv[i], true); - else - jsonIv(obj[F("iv")][i], &mCfg.inst.iv[i]); + void jsonPlugin(JsonObject obj, bool set = false) { + if(set) { + JsonObject disp = obj.createNestedObject("disp"); + disp[F("type")] = mCfg.plugin.display.type; + disp[F("pwrSafe")] = (bool)mCfg.plugin.display.pwrSaveAtIvOffline; + disp[F("pxShift")] = (bool)mCfg.plugin.display.pxShift; + disp[F("rotation")] = mCfg.plugin.display.rot; + //disp[F("wake")] = mCfg.plugin.display.wakeUp; + //disp[F("sleep")] = mCfg.plugin.display.sleepAt; + disp[F("contrast")] = mCfg.plugin.display.contrast; + disp[F("data")] = mCfg.plugin.display.disp_data; + disp[F("clock")] = mCfg.plugin.display.disp_clk; + disp[F("cs")] = mCfg.plugin.display.disp_cs; + disp[F("reset")] = mCfg.plugin.display.disp_reset; + disp[F("busy")] = mCfg.plugin.display.disp_busy; + disp[F("dc")] = mCfg.plugin.display.disp_dc; + } else { + JsonObject disp = obj["disp"]; + mCfg.plugin.display.type = disp[F("type")]; + mCfg.plugin.display.pwrSaveAtIvOffline = (bool)disp[F("pwrSafe")]; + mCfg.plugin.display.pxShift = (bool)disp[F("pxShift")]; + mCfg.plugin.display.rot = disp[F("rotation")]; + //mCfg.plugin.display.wakeUp = disp[F("wake")]; + //mCfg.plugin.display.sleepAt = disp[F("sleep")]; + mCfg.plugin.display.contrast = disp[F("contrast")]; + mCfg.plugin.display.disp_data = disp[F("data")]; + mCfg.plugin.display.disp_clk = disp[F("clock")]; + mCfg.plugin.display.disp_cs = disp[F("cs")]; + mCfg.plugin.display.disp_reset = disp[F("reset")]; + mCfg.plugin.display.disp_busy = disp[F("busy")]; + mCfg.plugin.display.disp_dc = disp[F("dc")]; + } } - } - - void jsonIv(JsonObject obj, cfgIv_t *cfg, bool set = false) { - if (set) { - obj[F("en")] = (bool)cfg->enabled; - obj[F("name")] = cfg->name; - obj[F("sn")] = cfg->serial.u64; - for (uint8_t i = 0; i < 4; i++) { - obj[F("yield")][i] = cfg->yieldCor[i]; - obj[F("pwr")][i] = cfg->chMaxPwr[i]; - obj[F("chName")][i] = cfg->chName[i]; + + void jsonInst(JsonObject obj, bool set = false) { + if(set) { + obj[F("en")] = (bool)mCfg.inst.enabled; + obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight; + obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail; + obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop; + } + else { + mCfg.inst.enabled = (bool)obj[F("en")]; + mCfg.inst.rstYieldMidNight = (bool)obj["rstMidNight"]; + mCfg.inst.rstValsNotAvail = (bool)obj["rstNotAvail"]; + mCfg.inst.rstValsCommStop = (bool)obj["rstComStop"]; + } + + JsonArray ivArr; + if(set) + ivArr = obj.createNestedArray(F("iv")); + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + if(set) + jsonIv(ivArr.createNestedObject(), &mCfg.inst.iv[i], true); + else + jsonIv(obj[F("iv")][i], &mCfg.inst.iv[i]); } - } else { - cfg->enabled = (bool)obj[F("en")]; - snprintf(cfg->name, MAX_NAME_LENGTH, "%s", obj[F("name")].as()); - cfg->serial.u64 = obj[F("sn")]; - for (uint8_t i = 0; i < 4; i++) { - cfg->yieldCor[i] = obj[F("yield")][i]; - cfg->chMaxPwr[i] = obj[F("pwr")][i]; - snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chName")][i].as()); + } + + void jsonIv(JsonObject obj, cfgIv_t *cfg, bool set = false) { + if(set) { + obj[F("en")] = (bool)cfg->enabled; + obj[F("name")] = cfg->name; + obj[F("sn")] = cfg->serial.u64; + for(uint8_t i = 0; i < 4; i++) { + obj[F("yield")][i] = cfg->yieldCor[i]; + obj[F("pwr")][i] = cfg->chMaxPwr[i]; + obj[F("chName")][i] = cfg->chName[i]; + } + } else { + cfg->enabled = (bool)obj[F("en")]; + snprintf(cfg->name, MAX_NAME_LENGTH, "%s", obj[F("name")].as()); + cfg->serial.u64 = obj[F("sn")]; + for(uint8_t i = 0; i < 4; i++) { + cfg->yieldCor[i] = obj[F("yield")][i]; + cfg->chMaxPwr[i] = obj[F("pwr")][i]; + snprintf(cfg->chName[i], MAX_NAME_LENGTH, "%s", obj[F("chName")][i].as()); + } } } - } - settings_t mCfg; + settings_t mCfg; }; #endif /*__SETTINGS_H__*/ diff --git a/src/defines.h b/src/defines.h index 56e02583..92723091 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 93 +#define VERSION_PATCH 94 //------------------------------------- typedef struct { diff --git a/src/platformio.ini b/src/platformio.ini index 08460930..e52cf3fb 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -56,9 +56,9 @@ board_build.f_cpu = 80000000L build_flags = -D RELEASE monitor_filters = ;default ; Remove typical terminal control codes from input - time ; Add timestamp with milliseconds for each new line + ;time ; Add timestamp with milliseconds for each new line ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory - esp8266_exception_decoder, default + esp8266_exception_decoder [env:esp8266-debug] platform = espressif8266 @@ -101,8 +101,9 @@ build_flags = -D RELEASE -std=gnu++14 build_unflags = -std=gnu++11 monitor_filters = ;default ; Remove typical terminal control codes from input - time ; Add timestamp with milliseconds for each new line + ;time ; Add timestamp with milliseconds for each new line ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory + esp32_exception_decoder [env:esp32-wroom32-debug] platform = espressif32 diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index 8509dacd..c5c9f676 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -8,72 +8,54 @@ #include "../../utils/helper.h" #include "Display_Mono.h" #include "Display_ePaper.h" -#include "imagedata.h" template class Display { public: - Display() {} - - void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { - mCfg = cfg; - mSys = sys; - mUtcTs = utcTs; - mNewPayload = false; - mLoopCnt = 0; - mVersion = version; - - if (mCfg->type == 0) { - return; - } else if (1 < mCfg->type < 11) { - switch (mCfg->rot) { - case 0: - DisplayMono.disp_rotation = U8G2_R0; - break; - case 1: - DisplayMono.disp_rotation = U8G2_R1; - break; - case 2: - DisplayMono.disp_rotation = U8G2_R2; - break; - case 3: - DisplayMono.disp_rotation = U8G2_R3; - break; - } - - DisplayMono.enablePowerSafe = mCfg->pwrSaveAtIvOffline; - DisplayMono.enableScreensaver = mCfg->pxShift; - DisplayMono.contrast = mCfg->contrast; + Display() {} - DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); - } else if (mCfg->type > 10) { - DisplayEPaper.displayRotation = mCfg->rot; - counterEPaper = 0; - - DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); + void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs, uint8_t disp_reset, const char *version) { + mCfg = cfg; + mSys = sys; + mUtcTs = utcTs; + mNewPayload = false; + mLoopCnt = 0; + mVersion = version; + + if (mCfg->type == 0) + return; + + if ((1 < mCfg->type) && (mCfg->type < 10)) { + mMono.config(mCfg->pwrSaveAtIvOffline, mCfg->pxShift, mCfg->contrast); + mMono.init(mCfg->type, mCfg->rot, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion); + } else if (mCfg->type >= 10) { + #if defined(ESP32) + mRefreshCycle = 0; + mEpaper.config(mCfg->rot); + mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); + #endif + } } - } - void payloadEventListener(uint8_t cmd) { - mNewPayload = true; - } + void payloadEventListener(uint8_t cmd) { + mNewPayload = true; + } - void tickerSecond() { - if (mNewPayload || ((++mLoopCnt % 10) == 0)) { - mNewPayload = false; - mLoopCnt = 0; - DataScreen(); + void tickerSecond() { + if (mNewPayload || ((++mLoopCnt % 10) == 0)) { + mNewPayload = false; + mLoopCnt = 0; + DataScreen(); + } } - } - private: - void DataScreen() { - if (mCfg->type == 0) - return; - if (*mUtcTs == 0) - return; + private: + void DataScreen() { + if (mCfg->type == 0) + return; + if (*mUtcTs == 0) + return; - if ((millis() - _lastDisplayUpdate) > mCfg->period) { float totalPower = 0; float totalYieldDay = 0; float totalYieldTotal = 0; @@ -89,37 +71,43 @@ class Display { continue; if (iv->isProducing(*mUtcTs)) - uint8_t isprod = 0; + isprod++; totalPower += iv->getChannelFieldValue(CH0, FLD_PAC, rec); totalYieldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec); totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec); } - if (1 < mCfg->type < 11) { - DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); - } else if (mCfg->type > 10) { - DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); - counterEPaper++; + if ((1 < mCfg->type) && (mCfg->type < 10)) { + mMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); + } else if (mCfg->type >= 10) { + #if defined(ESP32) + mEpaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); + mRefreshCycle++; + #endif } - _lastDisplayUpdate = millis(); - } - if (counterEPaper > 480) { - DisplayEPaper.fullRefresh(); - counterEPaper = 0; + #if defined(ESP32) + if (mRefreshCycle > 480) { + mEpaper.fullRefresh(); + mRefreshCycle = 0; + } + #endif } - } - - // private member variables - bool mNewPayload; - uint8_t mLoopCnt; - uint32_t *mUtcTs; - const char *mVersion; - display_t *mCfg; - HMSYSTEM *mSys; - uint16_t counterEPaper; - uint32_t _lastDisplayUpdate = 0; + + // private member variables + bool mNewPayload; + uint8_t mLoopCnt; + uint32_t *mUtcTs; + const char *mVersion; + display_t *mCfg; + HMSYSTEM *mSys; + uint16_t mRefreshCycle; + + #if defined(ESP32) + DisplayEPaper mEpaper; + #endif + DisplayMono mMono; }; #endif /*__DISPLAY__*/ diff --git a/src/plugins/Display/Display_Mono.cpp b/src/plugins/Display/Display_Mono.cpp index d6caa1a0..af9cd870 100644 --- a/src/plugins/Display/Display_Mono.cpp +++ b/src/plugins/Display/Display_Mono.cpp @@ -1,144 +1,149 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "Display_Mono.h" -#include - -#include - -#include "WiFi.h" -#include "imagedata.h" - -#ifdef U8X8_HAVE_HW_SPI -#include -#endif -#ifdef U8X8_HAVE_HW_I2C -#include +#ifdef ESP8266 + #include +#elif defined(ESP32) + #include #endif - -std::map> mono_types = { - {1, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_PCD8544_84X48_F_4W_SW_SPI(U8G2_R2, clock, data, cs, dc, reset); }}, - {2, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, reset, clock, data); }}, - {3, [](uint8_t reset, uint8_t clock, uint8_t data, uint8_t cs, uint8_t dc) { return new U8G2_SH1106_128X64_NONAME_F_HW_I2C(U8G2_R0, reset, clock, data); }}, -}; - -DisplayMonoClass::DisplayMonoClass() { -} - -DisplayMonoClass::~DisplayMonoClass() { - delete _display; +#include "../../utils/helper.h" + +//#ifdef U8X8_HAVE_HW_SPI +//#include +//#endif +//#ifdef U8X8_HAVE_HW_I2C +//#include +//#endif + +DisplayMono::DisplayMono() { + mEnPowerSafe = true; + mEnScreenSaver = true; + mLuminance = 60; + _dispY = 0; + mTimeout = DISP_DEFAULT_TIMEOUT; // interval at which to power save (milliseconds) + mUtcTs = NULL; } -void DisplayMonoClass::calcLineHeights() { - uint8_t yOff = 0; - for (uint8_t i = 0; i < 4; i++) { - setFont(i); - yOff += (_display->getMaxCharHeight()); - mLineOffsets[i] = yOff; - } -} -inline void DisplayMonoClass::setFont(uint8_t line) { - switch (line) { - case 0: - _display->setFont((_mIsLarge) ? u8g2_font_ncenB14_tr : u8g2_font_logisoso16_tr); - break; - case 3: - _display->setFont(u8g2_font_5x8_tr); - break; - default: - _display->setFont((_mIsLarge) ? u8g2_font_ncenB10_tr : u8g2_font_5x8_tr); - break; - } -} -void DisplayMonoClass::printText(const char* text, uint8_t line, uint8_t dispX = 5) { - if (!_mIsLarge) { - dispX = (line == 0) ? 5 : 0; - } else { - dispX = (line == 0) ? 20 : 5; - } - setFont(line); +void DisplayMono::init(uint8_t type, uint8_t rot, uint8_t cs, uint8_t dc, uint8_t reset, uint8_t clock, uint8_t data, uint32_t *utcTs, const char* version) { + if ((0 < type) && (type < 4)) { + u8g2_cb_t *rot = (u8g2_cb_t *)((rot != 0x00) ? U8G2_R2 : U8G2_R0); + switch(type) { + case 1: + mDisplay = new U8G2_PCD8544_84X48_F_4W_HW_SPI(rot, cs, dc, reset); + break; + case 2: + mDisplay = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(rot, reset, clock, data); + break; + default: + case 3: + mDisplay = new U8G2_SH1106_128X64_NONAME_F_HW_I2C(rot, reset, clock, data); + break; + } - dispX += enableScreensaver ? (_mExtra % 7) : 0; - _display->drawStr(dispX, mLineOffsets[line], text); -} + mUtcTs = utcTs; -void DisplayMonoClass::init(uint8_t _type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version) { - if (0 < _type < 4) { - auto constructor = mono_types[_type]; - _display = constructor(_RST, _SCK, _MOSI, _CS, _DC); - _display->begin(); - _display->setDisplayRotation(disp_rotation); + mDisplay->begin(); - _mIsLarge = (_display->getWidth() > 100); + mIsLarge = (mDisplay->getWidth() > 120); calcLineHeights(); - _display->clearBuffer(); - if (contrast < 255) { - _display->setContrast(contrast); - } + mDisplay->clearBuffer(); + mDisplay->setContrast(mLuminance); printText("AHOY!", 0, 35); printText("ahoydtu.de", 2, 20); printText(version, 3, 46); - _display->sendBuffer(); + mDisplay->sendBuffer(); } } -void DisplayMonoClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { - _display->clearBuffer(); +void DisplayMono::config(bool enPowerSafe, bool enScreenSaver, uint8_t lum) { + mEnPowerSafe = enPowerSafe; + mEnScreenSaver = enScreenSaver; + mLuminance = lum; +} + +void DisplayMono::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { + if (mEnPowerSafe) + if(mTimeout != 0) + mTimeout--; + + mDisplay->clearBuffer(); // set Contrast of the Display to raise the lifetime - if (contrast < 255) { - _display->setContrast(contrast); - } + mDisplay->setContrast(mLuminance); - //=====> Actual Production ========== if ((totalPower > 0) && (isprod > 0)) { - _display->setPowerSave(false); + mTimeout = DISP_DEFAULT_TIMEOUT; + mDisplay->setPowerSave(false); if (totalPower > 999) { - snprintf(_fmtText, sizeof(_fmtText), "%2.2f kW", (totalPower / 1000)); + snprintf(_fmtText, DISP_FMT_TEXT_LEN, "%2.2f kW", (totalPower / 1000)); } else { - snprintf(_fmtText, sizeof(_fmtText), "%3.0f W", totalPower); + snprintf(_fmtText, DISP_FMT_TEXT_LEN, "%3.0f W", totalPower); } printText(_fmtText, 0); - _previousMillis = millis(); - } - //<======================= - - //=====> Offline =========== - else { - printText("offline", 0); + } else { + printText("offline", 0, 25); // check if it's time to enter power saving mode - if (millis() - _previousMillis >= (_mTimeout * 2)) { - _display->setPowerSave(enablePowerSafe); - } + if (mTimeout == 0) + mDisplay->setPowerSave(mEnPowerSafe); } - //<======================= - //=====> Today & Total Production ======= - snprintf(_fmtText, sizeof(_fmtText), "today: %4.0f Wh", totalYieldDay); + snprintf(_fmtText, DISP_FMT_TEXT_LEN, "today: %4.0f Wh", totalYieldDay); printText(_fmtText, 1); - snprintf(_fmtText, sizeof(_fmtText), "total: %.1f kWh", totalYieldTotal); + snprintf(_fmtText, DISP_FMT_TEXT_LEN, "total: %.1f kWh", totalYieldTotal); printText(_fmtText, 2); - //<======================= - //=====> IP or Date-Time ======== - if (!(_mExtra % 10) && WiFi.localIP()) { - printText(WiFi.localIP().toString().c_str(), 3); + IPAddress ip = WiFi.localIP(); + if (!(_mExtra % 10) && (ip)) { + printText(ip.toString().c_str(), 3); } else if (!(_mExtra % 5)) { - snprintf(_fmtText, sizeof(_fmtText), "#%d Inverter online", isprod); + snprintf(_fmtText, DISP_FMT_TEXT_LEN, "#%d Inverter online", isprod); printText(_fmtText, 3); } else { - time_t now = time(nullptr); - strftime(_fmtText, sizeof(_fmtText), "%d.%m.%Y %H:%M", localtime(&now)); - printText(_fmtText, 3); + if(mIsLarge && (NULL != mUtcTs)) + printText(ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); + else + printText(ah::getTimeStr(gTimezone.toLocal(*mUtcTs)).c_str(), 3); } - _display->sendBuffer(); + mDisplay->sendBuffer(); _dispY = 0; _mExtra++; } -DisplayMonoClass DisplayMono; \ No newline at end of file +void DisplayMono::calcLineHeights() { + uint8_t yOff = 0; + for (uint8_t i = 0; i < 4; i++) { + setFont(i); + yOff += (mDisplay->getMaxCharHeight()); + mLineOffsets[i] = yOff; + } +} + +inline void DisplayMono::setFont(uint8_t line) { + switch (line) { + case 0: + mDisplay->setFont((mIsLarge) ? u8g2_font_ncenB14_tr : u8g2_font_logisoso16_tr); + break; + case 3: + mDisplay->setFont(u8g2_font_5x8_tr); + break; + default: + mDisplay->setFont((mIsLarge) ? u8g2_font_ncenB10_tr : u8g2_font_5x8_tr); + break; + } +} + +void DisplayMono::printText(const char* text, uint8_t line, uint8_t dispX) { + if (!mIsLarge) { + dispX = (line == 0) ? 10 : 5; + } + setFont(line); + + dispX += (mEnPowerSafe) ? (_mExtra % 7) : 0; + mDisplay->drawStr(dispX, mLineOffsets[line], text); +} diff --git a/src/plugins/Display/Display_Mono.h b/src/plugins/Display/Display_Mono.h index 81375605..cf14f27e 100644 --- a/src/plugins/Display/Display_Mono.h +++ b/src/plugins/Display/Display_Mono.h @@ -2,40 +2,35 @@ #pragma once #include -#define DISP_DEFAULT_TIMEOUT 60000 // in milliseconds +#define DISP_DEFAULT_TIMEOUT 60 // in seconds +#define DISP_FMT_TEXT_LEN 32 -class DisplayMonoClass { +class DisplayMono { public: - DisplayMonoClass(); - ~DisplayMonoClass(); + DisplayMono(); - void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); - - void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); - - bool enablePowerSafe = true; - bool enableScreensaver = true; - const u8g2_cb_t* disp_rotation = U8G2_R2; - uint8_t contrast = 60; + void init(uint8_t type, uint8_t rot, uint8_t cs, uint8_t dc, uint8_t reset, uint8_t clock, uint8_t data, uint32_t *utcTs, const char* version); + void config(bool enPowerSafe, bool enScreenSaver, uint8_t lum); + void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); private: - void calcLineHeights(); - void setFont(uint8_t line); - void printText(const char* text, uint8_t line, uint8_t dispX); + void calcLineHeights(); + void setFont(uint8_t line); + void printText(const char* text, uint8_t line, uint8_t dispX = 5); - U8G2* _display; + U8G2* mDisplay; - bool _mIsLarge = false; - uint8_t mLoopCnt; - uint32_t* mUtcTs; - uint8_t mLineOffsets[5]; + bool mEnPowerSafe, mEnScreenSaver; + uint8_t mLuminance; - uint16_t _dispY = 0; - uint32_t _previousMillis = 0; + bool mIsLarge = false; + uint8_t mLoopCnt; + uint32_t* mUtcTs; + uint8_t mLineOffsets[5]; - uint8_t _mExtra; - uint16_t _mTimeout = DISP_DEFAULT_TIMEOUT; // interval at which to power save (milliseconds) - char _fmtText[32]; -}; + uint16_t _dispY; -extern DisplayMonoClass DisplayMono; \ No newline at end of file + uint8_t _mExtra; + uint16_t mTimeout; + char _fmtText[DISP_FMT_TEXT_LEN]; +}; diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index 01b641ba..f27d7cf4 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -1,47 +1,43 @@ #include "Display_ePaper.h" -#include "WiFi.h" +#ifdef ESP8266 + #include +#elif defined(ESP32) + #include +#endif #include "imagedata.h" +#if defined(ESP32) + static const uint32_t spiClk = 4000000; // 4 MHz #if defined(ESP32) && defined(USE_HSPI_FOR_EPD) SPIClass hspi(HSPI); #endif -std::map> _ePaperTypes = { - // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1 - {11, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) { return new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); }}, - // GDEW027C44 2.7 " b/w/r 176x264, IL91874 - //{DisplayType_t::ePaper270, [](uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY) - // F { return new GxEPD2_3C(GxEPD2_270c(_CS, _DC, _RST, _BUSY)); }}, -}; - -DisplayEPaperClass::DisplayEPaperClass() { +DisplayEPaper::DisplayEPaper() { + mDisplayRotation = 2; + mHeadFootPadding = 16; } -DisplayEPaperClass::~DisplayEPaperClass() { - delete _display; -} + //*************************************************************************** -void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *version) { - if (type > 3) { +void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *version) { + if (type > 9) { Serial.begin(115200); - auto constructor = _ePaperTypes[type]; - _display = constructor(_CS, _DC, _RST, _BUSY); + _display = new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); hspi.begin(_SCK, _BUSY, _MOSI, _CS); #if defined(ESP32) && defined(USE_HSPI_FOR_EPD) _display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0)); #endif _display->init(115200, true, 2, false); - _display->setRotation(displayRotation); + _display->setRotation(mDisplayRotation); _display->setFullWindow(); // Logo _display->fillScreen(GxEPD_BLACK); - _display->drawBitmap(0, 0, AhoyLogo, 200, 200, GxEPD_WHITE); - //_display->drawBitmap(0, 0, OpenDTULogo, 200, 200, GxEPD_WHITE); + _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE); while (_display->nextPage()) ; @@ -57,8 +53,13 @@ void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _R actualPowerPaged(0, 0, 0, 0); } } + +void DisplayEPaper::config(uint8_t rotation) { + mDisplayRotation = rotation; +} + //*************************************************************************** -void DisplayEPaperClass::fullRefresh() { +void DisplayEPaper::fullRefresh() { // screen complete black _display->fillScreen(GxEPD_BLACK); while (_display->nextPage()) @@ -70,14 +71,14 @@ void DisplayEPaperClass::fullRefresh() { ; } //*************************************************************************** -void DisplayEPaperClass::headlineIP() { +void DisplayEPaper::headlineIP() { int16_t tbx, tby; uint16_t tbw, tbh; _display->setFont(&FreeSans9pt7b); _display->setTextColor(GxEPD_WHITE); - _display->setPartialWindow(0, 0, _display->width(), headfootline); + _display->setPartialWindow(0, 0, _display->width(), mHeadFootPadding); _display->fillScreen(GxEPD_BLACK); do { @@ -89,19 +90,19 @@ void DisplayEPaperClass::headlineIP() { _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); uint16_t x = ((_display->width() - tbw) / 2) - tbx; - _display->setCursor(x, (headfootline - 2)); + _display->setCursor(x, (mHeadFootPadding - 2)); _display->println(_fmtText); } while (_display->nextPage()); } //*************************************************************************** -void DisplayEPaperClass::lastUpdatePaged() { +void DisplayEPaper::lastUpdatePaged() { int16_t tbx, tby; uint16_t tbw, tbh; _display->setFont(&FreeSans9pt7b); _display->setTextColor(GxEPD_WHITE); - _display->setPartialWindow(0, _display->height() - headfootline, _display->width(), headfootline); + _display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding); _display->fillScreen(GxEPD_BLACK); do { time_t now = time(nullptr); @@ -115,14 +116,14 @@ void DisplayEPaperClass::lastUpdatePaged() { } while (_display->nextPage()); } //*************************************************************************** -void DisplayEPaperClass::actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod) { +void DisplayEPaper::actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod) { int16_t tbx, tby; uint16_t tbw, tbh, x, y; _display->setFont(&FreeSans24pt7b); _display->setTextColor(GxEPD_BLACK); - _display->setPartialWindow(0, headfootline, _display->width(), _display->height() - (headfootline * 2)); + _display->setPartialWindow(0, mHeadFootPadding, _display->width(), _display->height() - (mHeadFootPadding * 2)); _display->fillScreen(GxEPD_WHITE); do { if (_totalPower > 9999) { @@ -136,7 +137,7 @@ void DisplayEPaperClass::actualPowerPaged(float _totalPower, float _totalYieldDa } _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); x = ((_display->width() - tbw) / 2) - tbx; - _display->setCursor(x, headfootline + tbh + 10); + _display->setCursor(x, mHeadFootPadding + tbh + 10); _display->print(_fmtText); _display->setFont(&FreeSans12pt7b); @@ -162,14 +163,14 @@ void DisplayEPaperClass::actualPowerPaged(float _totalPower, float _totalYieldDa _display->setCursor(_display->width() - 45, y); _display->println("kWh"); - _display->setCursor(0, _display->height() - (headfootline + 10)); + _display->setCursor(0, _display->height() - (mHeadFootPadding + 10)); snprintf(_fmtText, sizeof(_fmtText), "#%d Inverter online", _isprod); _display->println(_fmtText); } while (_display->nextPage()); } //*************************************************************************** -void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { +void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { // check if the IP has changed if (_settedIP != WiFi.localIP().toString().c_str()) { // save the new IP and call the Headline Funktion to adapt the Headline @@ -189,4 +190,4 @@ void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float total _display->powerOff(); } //*************************************************************************** -DisplayEPaperClass DisplayEPaper; \ No newline at end of file +#endif // ESP32 diff --git a/src/plugins/Display/Display_ePaper.h b/src/plugins/Display/Display_ePaper.h index ed8fb025..489ed7c1 100644 --- a/src/plugins/Display/Display_ePaper.h +++ b/src/plugins/Display/Display_ePaper.h @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once +#if defined(ESP32) + // uncomment next line to use HSPI for EPD (and VSPI for SD), e.g. with Waveshare ESP32 Driver Board #define USE_HSPI_FOR_EPD @@ -21,31 +23,29 @@ #include #include -#include "imagedata.h" - // GDEW027C44 2.7 " b/w/r 176x264, IL91874 // GDEH0154D67 1.54" b/w 200x200 -class DisplayEPaperClass { +class DisplayEPaper { public: - DisplayEPaperClass(); - ~DisplayEPaperClass(); - void fullRefresh(); - void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); - void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); + DisplayEPaper(); + void fullRefresh(); + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); + void config(uint8_t rotation); + void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); - uint8_t displayRotation = 2; private: - void headlineIP(); - void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod); - void lastUpdatePaged(); - - bool _changed = false; - char _fmtText[35]; - const char* _settedIP; - uint8_t headfootline = 16; - GxEPD2_GFX* _display; + void headlineIP(); + void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod); + void lastUpdatePaged(); + + uint8_t mDisplayRotation; + bool _changed = false; + char _fmtText[35]; + const char* _settedIP; + uint8_t mHeadFootPadding; + GxEPD2_GFX* _display; }; -extern DisplayEPaperClass DisplayEPaper; \ No newline at end of file +#endif // ESP32 diff --git a/src/plugins/Display/imagedata.cpp b/src/plugins/Display/imagedata.cpp deleted file mode 100644 index 9cdf352c..00000000 --- a/src/plugins/Display/imagedata.cpp +++ /dev/null @@ -1,642 +0,0 @@ -// GxEPD2_ESP32_ESP8266_WifiData_V1_und_V2 - -#include "imagedata.h" -#if defined(__AVR__) || defined(ARDUINO_ARCH_SAMD) -#include -#elif defined(ESP8266) || defined(ESP32) -#include -#endif - -// 'OpenDTU', 200x200px -const unsigned char OpenDTULogo[] PROGMEM = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, - 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf8, 0x03, 0x80, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xf0, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, - 0x7f, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xfe, 0x01, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x01, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0x07, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, - 0xfc, 0x7f, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xfc, 0x0f, 0xe0, 0x0f, 0xc0, 0xfe, 0x03, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, - 0xf8, 0x07, 0xc0, 0x0f, 0xc0, 0x3e, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf0, 0x07, 0xc0, 0x0f, 0x80, 0x1e, 0x03, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x01, 0xe0, 0x07, 0xc0, 0x07, 0x80, 0x0f, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xe0, 0x07, 0xc0, 0x0f, 0x80, - 0x0f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x03, 0xe0, 0x07, 0xc0, 0x0f, 0xc0, 0x1f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xe0, 0x0f, 0xe0, - 0x0f, 0xc0, 0x1f, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xf0, 0x3f, 0xf8, 0x3f, 0xf0, 0x7f, 0x81, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x07, 0xf0, 0x7f, 0xfc, 0xff, 0xf0, 0x7f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0x80, 0x0f, 0xe0, 0x1f, 0xc0, 0x07, - 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0x0f, 0x80, 0x07, 0xe0, 0x0f, 0xc0, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0x00, 0x0f, 0xc0, 0x0f, - 0xc0, 0x03, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf8, 0x0f, 0x00, 0x0f, 0xc0, 0x07, 0xc0, 0x03, 0xe0, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0x00, 0x0f, - 0xc0, 0x07, 0xe0, 0x03, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0x80, 0x0f, 0xc0, 0x0f, 0xe0, 0x03, 0xe0, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x1f, - 0x80, 0x1f, 0xe0, 0x0f, 0xf0, 0x07, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xe0, 0x3f, 0xf8, 0x3f, 0xfc, 0x1f, 0xf0, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, - 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0x8f, 0xff, - 0xf3, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0x07, 0xff, 0xe1, 0xfc, 0x00, 0x03, 0xff, 0xff, 0xff, - 0xf0, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x1f, - 0x03, 0xff, 0xc0, 0xf8, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x1f, 0x03, 0xff, 0xc0, 0xf0, 0x00, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x1f, 0xf0, 0x00, - 0x00, 0x1f, 0x03, 0xff, 0xc0, 0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x7f, 0x03, 0xff, 0xc0, 0xc0, 0x3f, - 0x80, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xf0, 0x0f, - 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0xc0, 0x7f, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xfc, 0x07, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, - 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, - 0xfe, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, - 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xf0, - 0x00, 0x7f, 0xff, 0xf0, 0x03, 0xff, 0xf0, 0x00, 0x7f, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, - 0xff, 0x03, 0xff, 0xc0, 0x83, 0xff, 0xf8, 0x1f, 0xe0, 0x00, 0x1f, 0xff, 0xc0, 0x00, 0xff, 0xe0, - 0x00, 0x1f, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xf8, - 0x1f, 0xe0, 0x00, 0x0f, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x0f, 0xff, 0x03, 0xff, 0x81, 0xff, - 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x00, 0x07, 0xff, 0x00, 0x00, - 0x3f, 0xe0, 0x00, 0x07, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, - 0xff, 0xfc, 0x1f, 0xe0, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x07, 0xff, 0x03, 0xff, - 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x3c, 0x01, 0xfe, - 0x01, 0xe0, 0x1f, 0xe0, 0x1c, 0x03, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, - 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0x01, 0xfc, 0x07, 0xf8, 0x1f, 0xe0, 0x7f, 0x03, 0xff, - 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, - 0x80, 0xfc, 0x0f, 0xf8, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, - 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xe0, 0x1f, 0xe0, 0x7f, - 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, - 0xe0, 0x7f, 0xc0, 0xfc, 0x0c, 0x00, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, - 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x00, 0x1f, - 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc0, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, - 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x00, 0x1f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0xc1, - 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xfc, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, - 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, - 0x03, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x00, 0x03, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, - 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x83, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, - 0xfc, 0x00, 0x7f, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, - 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x1f, 0xe0, 0x7f, 0xc0, 0xfc, 0x07, 0xff, 0xff, 0xe0, 0x7f, 0x83, - 0xff, 0x03, 0xff, 0x81, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf8, 0x3f, 0xe0, - 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, - 0xff, 0x03, 0xff, 0xc0, 0x81, 0xff, 0xf0, 0x3f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, - 0x7f, 0x83, 0xff, 0x03, 0xff, 0x03, 0xff, 0xf0, 0x3f, 0xff, 0x03, 0xff, 0xc0, 0xc0, 0xff, 0xf0, - 0x3f, 0xe0, 0x7f, 0xc0, 0xfc, 0x0f, 0xff, 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xfe, 0x07, 0xff, - 0xf0, 0x3f, 0xff, 0x03, 0xff, 0x80, 0xc0, 0x7f, 0xe0, 0x3f, 0xe0, 0x7f, 0x81, 0xfc, 0x0f, 0xff, - 0xff, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xfc, 0x07, 0xff, 0xf0, 0x3f, 0xff, 0x01, 0xff, 0x81, 0xc0, - 0x3f, 0x80, 0x7f, 0xe0, 0x7e, 0x01, 0xfe, 0x07, 0xf0, 0x7f, 0xe0, 0x7f, 0x83, 0xff, 0x03, 0xe0, - 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0x80, 0xfe, 0x01, 0xe0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x03, 0xfe, - 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x3f, 0xff, 0x80, 0x00, - 0x03, 0xf0, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x03, 0xff, 0x00, 0x00, 0x3f, 0xe0, 0x7f, 0x83, 0xff, - 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x3f, 0xff, 0xc0, 0x00, 0x03, 0xf8, 0x00, 0x01, 0xff, 0xe0, 0x00, - 0x07, 0xff, 0x00, 0x00, 0x7f, 0xe0, 0x7f, 0x83, 0xff, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x3f, 0xff, - 0xe0, 0x00, 0x07, 0xfc, 0x00, 0x03, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0x80, 0x00, 0x7f, 0xe0, 0x7f, - 0x83, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x3f, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0x00, 0x0f, 0xff, - 0xe0, 0x00, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xf0, 0xff, 0x83, 0xff, 0x00, 0x03, 0xff, 0xff, 0xf8, - 0x7f, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x00, 0xff, 0xff, 0xf8, 0x07, 0xff, - 0xf9, 0xff, 0xe7, 0xff, 0xc0, 0x1f, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; - -// 'Logo', 200x200px -const unsigned char AhoyLogo[] PROGMEM = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, - 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x06, - 0x0f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7e, 0x0f, 0xff, 0xff, 0xfc, 0x03, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x03, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x19, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xfe, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xe0, 0x70, 0x7f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x3f, 0x07, 0xff, 0xff, - 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfc, 0x0f, 0xe0, 0x3f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xe0, 0x1f, 0x83, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xe0, 0x1f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, - 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x07, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0xff, 0xc1, 0x07, 0x80, 0x07, 0xfe, 0xff, 0xff, 0xfc, 0x07, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xe1, 0x07, 0xc0, 0x01, 0xe0, 0x0f, - 0xff, 0xfc, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0xff, 0xe1, 0x83, 0xc0, 0x01, 0xc0, 0x07, 0xff, 0xf8, 0x0f, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe1, 0x83, 0xc0, 0x00, - 0xc0, 0x07, 0x8f, 0xf8, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe0, 0x01, 0xc0, 0x00, 0x81, 0x83, 0x07, 0xf0, 0x3f, 0xf9, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xe0, 0x01, - 0xe0, 0xe0, 0x87, 0xe3, 0x0f, 0xf0, 0x3f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0x00, 0xe0, 0xe0, 0x87, 0xe1, 0x0c, 0x60, 0x7f, - 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, - 0xe0, 0x00, 0xe1, 0xf0, 0x87, 0xe1, 0x08, 0x60, 0x7f, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xe0, 0xe0, 0xe0, 0xe0, 0x87, 0xc2, 0x00, - 0x40, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x8f, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, 0x82, 0x00, 0xc0, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, - 0x06, 0x01, 0x81, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xcf, 0xe0, 0xe0, 0x20, 0xe0, 0xe0, 0x0c, 0x03, 0x81, 0xff, 0x1f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x30, - 0xe1, 0xf8, 0x18, 0x07, 0xe1, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x7f, 0xff, 0xff, 0xf0, 0x1f, 0xf3, 0xfe, 0x01, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, - 0xfb, 0xff, 0xff, 0xff, 0xe0, 0x3e, 0x1f, 0xfc, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xfc, 0x0f, - 0xf8, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0x33, 0xef, 0xff, 0xff, 0xff, 0xff, 0x81, 0xfc, 0x0f, 0xf1, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf1, 0xff, 0xff, 0xa0, 0x00, 0x7f, 0xe3, - 0xfc, 0x0f, 0xf3, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf1, 0xf9, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x0f, 0xe7, 0xff, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf9, 0xff, 0x80, 0x3f, 0xff, - 0xe0, 0x0f, 0xfe, 0x1f, 0xc7, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xcf, 0xf8, 0xf0, 0x07, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0x8f, 0xff, 0xfc, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xfc, 0x70, 0x3f, - 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0x1f, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x3f, - 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, - 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7e, 0x3f, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x0c, 0x7f, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, - 0x7f, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf8, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x87, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x3f, 0xff, 0xf8, 0x00, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfc, 0x00, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x55, 0x00, 0x3f, 0xf8, 0x00, - 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x01, 0xff, 0xff, 0xf8, 0x0f, 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0x9f, 0xff, 0xf8, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0x03, - 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe3, 0xf1, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xe0, 0xfe, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe7, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x7e, 0x06, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xcf, - 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0x03, 0x3f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xcf, 0xfc, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x1f, 0x23, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, - 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xf3, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xf1, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xf8, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x0f, 0xff, 0x8f, 0xf1, 0xff, 0xff, 0xff, 0xfe, 0xf5, 0x90, 0x07, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x03, 0xff, - 0x1f, 0xe3, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x31, 0xfe, 0x7f, 0xe7, 0xff, 0x80, 0x00, 0x40, 0x00, - 0x07, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0x3c, - 0xf9, 0xfc, 0xff, 0xe7, 0xfe, 0x3f, 0xc9, 0xff, 0xf1, 0x1f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x3c, 0xf9, 0xf9, 0xff, 0xc7, 0xfc, 0xff, 0x90, - 0x7f, 0xf3, 0x03, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, - 0x3f, 0x39, 0xfd, 0xf3, 0xff, 0xcf, 0xfc, 0xff, 0x90, 0x3f, 0xf3, 0x83, 0xf8, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x39, 0xf9, 0xc7, 0xff, 0xcf, 0xfc, - 0xff, 0x32, 0x7f, 0xe4, 0x77, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, - 0xff, 0xff, 0x7f, 0x33, 0xf9, 0x8f, 0xff, 0xcf, 0xf9, 0xff, 0x00, 0x7f, 0xe0, 0x67, 0xfc, 0x7f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xb3, 0xf3, 0xbf, 0xff, - 0xcf, 0xf9, 0xff, 0x00, 0xff, 0xfe, 0x47, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xf7, 0xf3, 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe0, 0xff, 0xfc, 0x0f, - 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xe7, 0xe7, - 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe1, 0xff, 0xfc, 0x1f, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xe7, 0xef, 0xff, 0xc7, 0xf9, 0xff, 0xc3, 0xff, - 0xfc, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, - 0xef, 0xef, 0xc0, 0xff, 0xe7, 0xf9, 0xff, 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xcf, 0xf0, 0x01, 0xe7, 0xf1, 0xff, - 0x87, 0xff, 0xf8, 0x7f, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, - 0xff, 0xbf, 0xcf, 0xe7, 0xff, 0xc1, 0xe3, 0xe1, 0xff, 0x8f, 0xff, 0xf0, 0xff, 0xff, 0x9f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x9f, 0xef, 0xe7, 0xff, 0xff, 0xf3, - 0xc1, 0xff, 0x96, 0xaf, 0xf9, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf9, 0xff, 0xff, 0x9f, 0xe7, 0xe3, 0xff, 0xff, 0xf1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, - 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xcf, 0xe7, 0xf3, 0xff, - 0xff, 0xf8, 0xc0, 0x00, 0x4a, 0x90, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xf9, 0xff, 0xff, 0xef, 0xf3, 0xf3, 0x9f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe7, 0xf1, - 0xe7, 0xc7, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf3, 0xf0, 0x07, 0xe3, 0xff, 0xff, 0x81, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, - 0xf8, 0x07, 0x1f, 0xf1, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xfc, 0x1f, 0x9f, 0xf8, 0xff, 0xff, 0xc3, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, - 0xff, 0xff, 0xf8, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf9, 0xff, 0x9f, 0xfe, 0x3f, - 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfd, 0xff, 0xff, 0xf1, 0xff, 0x9f, 0xff, 0x9f, 0xff, 0xf3, 0xff, 0x3f, 0x3f, 0xff, 0xff, - 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe1, 0xff, 0xcf, - 0xff, 0xc7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xe1, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, - 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xc1, - 0xff, 0xcf, 0xff, 0xf3, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x81, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xf3, 0xff, - 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, - 0xff, 0x91, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x11, 0xff, 0x9f, 0xff, 0xff, 0xff, - 0xf3, 0xff, 0x1f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xfe, 0x7f, 0xff, 0x21, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xbf, 0x9f, 0xff, 0xff, 0xfe, - 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x20, 0xff, 0x9f, 0xff, - 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x60, 0x7f, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x64, 0x3f, - 0x1f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xe7, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, - 0xff, 0x3f, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, - 0xe7, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xf1, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xf8, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, - 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x9f, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xe7, 0xff, 0xfe, 0x7f, 0xff, 0xc3, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf3, 0xf3, 0xff, 0xfc, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xff, 0xf8, 0xff, 0xff, - 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xf9, 0xe7, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf3, 0xf9, 0xff, 0xe1, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfc, 0x3f, 0x07, - 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf3, 0xe7, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x00, 0x1f, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, - 0xe0, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, - 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf7, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x83, 0xe7, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x13, 0xe7, 0xff, 0xfc, 0x03, - 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfc, 0x31, 0xe7, 0xff, 0xfc, 0x00, 0x7f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfe, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x39, 0xe3, 0xff, - 0xfc, 0x00, 0x1f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x31, 0xf3, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xc7, 0xff, 0xff, - 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, - 0xf3, 0xff, 0xfc, 0x00, 0x07, 0xff, 0x87, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xf3, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x07, - 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x83, 0xf3, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xf3, 0xff, 0xff, 0xff, 0xff, - 0xf8, 0x07, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xe3, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xfe, 0x1f, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe1, 0xff, 0xfe, - 0x01, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xf0, 0x00, 0x3f, 0x80, 0x07, 0xff, 0xff, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x4c, - 0xff, 0xf0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0c, 0xff, 0xf0, 0x00, 0x00, 0x0b, 0x87, 0xff, - 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0e, 0x7f, 0xf8, 0x00, 0x3f, 0xff, 0xc7, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x86, 0x7f, 0xfe, 0x00, 0xff, 0xff, - 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xf3, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, - 0xff, 0xff, 0xf3, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x07, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, - 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xf3, 0xc0, 0x7f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, - 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xff, - 0xfe, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xf0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x17, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff -}; diff --git a/src/plugins/Display/imagedata.h b/src/plugins/Display/imagedata.h index ebdb918e..baaddec8 100644 --- a/src/plugins/Display/imagedata.h +++ b/src/plugins/Display/imagedata.h @@ -1,5 +1,329 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#pragma once +// GxEPD2_ESP32_ESP8266_WifiData_V1_und_V2 -extern const unsigned char AhoyLogo[]; -extern const unsigned char OpenDTULogo[]; +#ifndef __IMAGEDATA_H__ +#define __IMAGEDATA_H__ + +#if defined(__AVR__) || defined(ARDUINO_ARCH_SAMD) +#include +#elif defined(ESP8266) || defined(ESP32) +#include +#endif + +// 'Logo', 200x200px +const unsigned char logo[] PROGMEM = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x5f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, + 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x06, + 0x0f, 0xff, 0xff, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x7e, 0x0f, 0xff, 0xff, 0xfc, 0x03, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x03, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x19, 0xfe, 0x07, 0xff, 0xff, 0xff, 0xfe, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe0, 0x70, 0x7f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x3f, 0x07, 0xff, 0xff, + 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0x0f, 0xe0, 0x3f, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f, 0xe0, 0x1f, 0x83, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xe0, 0x1f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, + 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xe0, 0x0f, 0x83, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x07, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0xff, 0xc1, 0x07, 0x80, 0x07, 0xfe, 0xff, 0xff, 0xfc, 0x07, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xe1, 0x07, 0xc0, 0x01, 0xe0, 0x0f, + 0xff, 0xfc, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xe1, 0x83, 0xc0, 0x01, 0xc0, 0x07, 0xff, 0xf8, 0x0f, 0xfc, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe1, 0x83, 0xc0, 0x00, + 0xc0, 0x07, 0x8f, 0xf8, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xe0, 0x01, 0xc0, 0x00, 0x81, 0x83, 0x07, 0xf0, 0x3f, 0xf9, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xe0, 0x01, + 0xe0, 0xe0, 0x87, 0xe3, 0x0f, 0xf0, 0x3f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0x00, 0xe0, 0xe0, 0x87, 0xe1, 0x0c, 0x60, 0x7f, + 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, + 0xe0, 0x00, 0xe1, 0xf0, 0x87, 0xe1, 0x08, 0x60, 0x7f, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xe0, 0xe0, 0xe0, 0xe0, 0x87, 0xc2, 0x00, + 0x40, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x8f, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, 0x82, 0x00, 0xc0, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xc0, 0xe0, 0x60, 0xe0, 0xc0, + 0x06, 0x01, 0x81, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xcf, 0xe0, 0xe0, 0x20, 0xe0, 0xe0, 0x0c, 0x03, 0x81, 0xff, 0x1f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x30, + 0xe1, 0xf8, 0x18, 0x07, 0xe1, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xc0, 0xf0, 0x7f, 0xff, 0xff, 0xf0, 0x1f, 0xf3, 0xfe, 0x01, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, + 0xfb, 0xff, 0xff, 0xff, 0xe0, 0x3e, 0x1f, 0xfc, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xfc, 0x0f, + 0xf8, 0xfc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0x33, 0xef, 0xff, 0xff, 0xff, 0xff, 0x81, 0xfc, 0x0f, 0xf1, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf1, 0xff, 0xff, 0xa0, 0x00, 0x7f, 0xe3, + 0xfc, 0x0f, 0xf3, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf1, 0xf9, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xfc, 0x0f, 0xe7, 0xff, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf9, 0xff, 0x80, 0x3f, 0xff, + 0xe0, 0x0f, 0xfe, 0x1f, 0xc7, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xcf, 0xf8, 0xf0, 0x07, 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0x8f, 0xff, 0xfc, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xfc, 0x70, 0x3f, + 0xff, 0xff, 0xff, 0xf0, 0x1f, 0xff, 0x1f, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0x3f, + 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfe, + 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7e, 0x3f, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x23, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x0c, 0x7f, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x7f, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf8, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x87, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x3f, 0xff, 0xf8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfc, 0x00, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x55, 0x00, 0x3f, 0xf8, 0x00, + 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0xff, 0xff, 0xf8, 0x0f, 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x9f, 0xff, 0xf8, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0x03, + 0xfc, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe3, 0xf1, 0xff, + 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xe0, 0xfe, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xe7, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x7e, 0x06, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xcf, + 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0x03, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xcf, 0xfc, 0xff, 0xff, 0xff, 0xfe, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x1f, 0x23, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xf3, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xf1, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xf8, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x0f, 0xff, 0x8f, 0xf1, 0xff, 0xff, 0xff, 0xfe, 0xf5, 0x90, 0x07, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x9f, 0xff, 0x03, 0xff, + 0x1f, 0xe3, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x31, 0xfe, 0x7f, 0xe7, 0xff, 0x80, 0x00, 0x40, 0x00, + 0x07, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0x3f, 0x3c, + 0xf9, 0xfc, 0xff, 0xe7, 0xfe, 0x3f, 0xc9, 0xff, 0xf1, 0x1f, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x3c, 0xf9, 0xf9, 0xff, 0xc7, 0xfc, 0xff, 0x90, + 0x7f, 0xf3, 0x03, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, + 0x3f, 0x39, 0xfd, 0xf3, 0xff, 0xcf, 0xfc, 0xff, 0x90, 0x3f, 0xf3, 0x83, 0xf8, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0x39, 0xf9, 0xc7, 0xff, 0xcf, 0xfc, + 0xff, 0x32, 0x7f, 0xe4, 0x77, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0xff, 0xff, 0x7f, 0x33, 0xf9, 0x8f, 0xff, 0xcf, 0xf9, 0xff, 0x00, 0x7f, 0xe0, 0x67, 0xfc, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xb3, 0xf3, 0xbf, 0xff, + 0xcf, 0xf9, 0xff, 0x00, 0xff, 0xfe, 0x47, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xf7, 0xf3, 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe0, 0xff, 0xfc, 0x0f, + 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x7f, 0xe7, 0xe7, + 0xff, 0xff, 0xcf, 0xf9, 0xff, 0xe1, 0xff, 0xfc, 0x1f, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xe7, 0xef, 0xff, 0xc7, 0xf9, 0xff, 0xc3, 0xff, + 0xfc, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, + 0xef, 0xef, 0xc0, 0xff, 0xe7, 0xf9, 0xff, 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x3f, 0xef, 0xcf, 0xf0, 0x01, 0xe7, 0xf1, 0xff, + 0x87, 0xff, 0xf8, 0x7f, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, + 0xff, 0xbf, 0xcf, 0xe7, 0xff, 0xc1, 0xe3, 0xe1, 0xff, 0x8f, 0xff, 0xf0, 0xff, 0xff, 0x9f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0x9f, 0xef, 0xe7, 0xff, 0xff, 0xf3, + 0xc1, 0xff, 0x96, 0xaf, 0xf9, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf9, 0xff, 0xff, 0x9f, 0xe7, 0xe3, 0xff, 0xff, 0xf1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, + 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xcf, 0xe7, 0xf3, 0xff, + 0xff, 0xf8, 0xc0, 0x00, 0x4a, 0x90, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xf9, 0xff, 0xff, 0xef, 0xf3, 0xf3, 0x9f, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe7, 0xf1, + 0xe7, 0xc7, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf3, 0xf0, 0x07, 0xe3, 0xff, 0xff, 0x81, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, + 0xf8, 0x07, 0x1f, 0xf1, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xfc, 0x1f, 0x9f, 0xf8, 0xff, 0xff, 0xc3, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, + 0xff, 0xff, 0xf8, 0xff, 0x9f, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xf9, 0xff, 0x9f, 0xfe, 0x3f, + 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfd, 0xff, 0xff, 0xf1, 0xff, 0x9f, 0xff, 0x9f, 0xff, 0xf3, 0xff, 0x3f, 0x3f, 0xff, 0xff, + 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xe1, 0xff, 0xcf, + 0xff, 0xc7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xe1, 0xff, 0x8f, 0xff, 0xe7, 0xff, 0xf3, 0xff, 0x3f, 0x9f, + 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xc1, + 0xff, 0xcf, 0xff, 0xf3, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x81, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xf3, 0xff, + 0x3f, 0x9f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, + 0xff, 0x91, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0x3f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x11, 0xff, 0x9f, 0xff, 0xff, 0xff, + 0xf3, 0xff, 0x1f, 0x9f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0x7f, 0xff, 0x21, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xbf, 0x9f, 0xff, 0xff, 0xfe, + 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x20, 0xff, 0x9f, 0xff, + 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x60, 0x7f, 0x9f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x64, 0x3f, + 0x1f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xe7, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, + 0xff, 0x3f, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfc, + 0xe7, 0x80, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xf1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xf8, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, + 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x9f, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xe7, 0xff, 0xfe, 0x7f, 0xff, 0xc3, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf3, 0xf3, 0xff, 0xfc, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xcf, 0xf9, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xff, 0xf8, 0xff, 0xff, + 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xf9, 0xe7, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf3, 0xf9, 0xff, 0xe1, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfc, 0x3f, 0x07, + 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xf3, 0xe7, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x00, 0x1f, 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, + 0xe0, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, + 0xf3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf7, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x83, 0xe7, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x13, 0xe7, 0xff, 0xfc, 0x03, + 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfc, 0x31, 0xe7, 0xff, 0xfc, 0x00, 0x7f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfe, + 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x39, 0xe3, 0xff, + 0xfc, 0x00, 0x1f, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x31, 0xf3, 0xff, 0xfc, 0x00, 0x1f, 0xff, 0xc7, 0xff, 0xff, + 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, + 0xf3, 0xff, 0xfc, 0x00, 0x07, 0xff, 0x87, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xf3, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x07, + 0xff, 0xff, 0xff, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x83, 0xf3, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xf3, 0xff, 0xff, 0xff, 0xff, + 0xf8, 0x07, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xe3, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xfe, 0x1f, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xe1, 0xff, 0xfe, + 0x01, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xe1, 0xff, 0xf0, 0x00, 0x3f, 0x80, 0x07, 0xff, 0xff, 0xf0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x4c, + 0xff, 0xf0, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x0c, 0xff, 0xf0, 0x00, 0x00, 0x0b, 0x87, 0xff, + 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0e, 0x7f, 0xf8, 0x00, 0x3f, 0xff, 0xc7, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x86, 0x7f, 0xfe, 0x00, 0xff, 0xff, + 0xc3, 0xff, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0x87, 0xff, 0xff, 0xf3, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, + 0xff, 0xff, 0xf3, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xfe, 0x07, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf0, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xf3, 0xc0, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xe0, + 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x03, 0xff, + 0xfe, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x17, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; + +#endif /*__IMAGEDATA_H__*/ diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 616244fa..e9479a0b 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -28,649 +28,626 @@ const uint8_t dcList[] = {FLD_UDC, FLD_IDC, FLD_PDC, FLD_YD, FLD_YT, FLD_IRR}; template class RestApi { - public: - RestApi() { - mTimezoneOffset = 0; - mHeapFree = 0; - mHeapFreeBlk = 0; - mHeapFrag = 0; - nr = 0; - } - - void setup(IApp *app, HMSYSTEM *sys, AsyncWebServer *srv, settings_t *config) { - mApp = app; - mSrv = srv; - mSys = sys; - mConfig = config; - mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1)); - mSrv->on("/api", HTTP_POST, std::bind(&RestApi::onApiPost, this, std::placeholders::_1)).onBody(std::bind(&RestApi::onApiPostBody, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); - - mSrv->on("/get_setup", HTTP_GET, std::bind(&RestApi::onDwnldSetup, this, std::placeholders::_1)); - } - - uint32_t getTimezoneOffset(void) { - return mTimezoneOffset; - } - - void ctrlRequest(JsonObject obj) { - /*char out[128]; - serializeJson(obj, out, 128); - DPRINTLN(DBG_INFO, "RestApi: " + String(out));*/ - DynamicJsonDocument json(128); - JsonObject dummy = json.as(); - if (obj[F("path")] == "ctrl") - setCtrl(obj, dummy); - else if (obj[F("path")] == "setup") - setSetup(obj, dummy); - } - - private: - void onApi(AsyncWebServerRequest *request) { - mHeapFree = ESP.getFreeHeap(); -#ifndef ESP32 - mHeapFreeBlk = ESP.getMaxFreeBlockSize(); - mHeapFrag = ESP.getHeapFragmentation(); -#endif + public: + RestApi() { + mTimezoneOffset = 0; + mHeapFree = 0; + mHeapFreeBlk = 0; + mHeapFrag = 0; + nr = 0; + } + + void setup(IApp *app, HMSYSTEM *sys, AsyncWebServer *srv, settings_t *config) { + mApp = app; + mSrv = srv; + mSys = sys; + mConfig = config; + mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1)); + mSrv->on("/api", HTTP_POST, std::bind(&RestApi::onApiPost, this, std::placeholders::_1)).onBody( + std::bind(&RestApi::onApiPostBody, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + + mSrv->on("/get_setup", HTTP_GET, std::bind(&RestApi::onDwnldSetup, this, std::placeholders::_1)); + } + + uint32_t getTimezoneOffset(void) { + return mTimezoneOffset; + } + + void ctrlRequest(JsonObject obj) { + /*char out[128]; + serializeJson(obj, out, 128); + DPRINTLN(DBG_INFO, "RestApi: " + String(out));*/ + DynamicJsonDocument json(128); + JsonObject dummy = json.as(); + if(obj[F("path")] == "ctrl") + setCtrl(obj, dummy); + else if(obj[F("path")] == "setup") + setSetup(obj, dummy); + } + + private: + void onApi(AsyncWebServerRequest *request) { + mHeapFree = ESP.getFreeHeap(); + #ifndef ESP32 + mHeapFreeBlk = ESP.getMaxFreeBlockSize(); + mHeapFrag = ESP.getHeapFragmentation(); + #endif + + AsyncJsonResponse* response = new AsyncJsonResponse(false, 6000); + JsonObject root = response->getRoot(); - AsyncJsonResponse *response = new AsyncJsonResponse(false, 6000); - JsonObject root = response->getRoot(); - - String path = request->url().substring(5); - if (path == "html/system") - getHtmlSystem(root); - else if (path == "html/logout") - getHtmlLogout(root); - else if (path == "html/save") - getHtmlSave(root); - else if (path == "system") - getSysInfo(root); - else if (path == "generic") - getGeneric(root); - else if (path == "reboot") - getReboot(root); - else if (path == "statistics") - getStatistics(root); - else if (path == "inverter/list") - getInverterList(root); - else if (path == "index") - getIndex(root); - else if (path == "setup") - getSetup(root); - else if (path == "setup/networks") - getNetworks(root); - else if (path == "live") - getLive(root); - else if (path == "record/info") - getRecord(root, InverterDevInform_All); - else if (path == "record/alarm") - getRecord(root, AlarmData); - else if (path == "record/config") - getRecord(root, SystemConfigPara); - else if (path == "record/live") - getRecord(root, RealTimeRunData_Debug); - else { - if (path.substring(0, 12) == "inverter/id/") - getInverter(root, request->url().substring(17).toInt()); - else - getNotFound(root, F("http://") + request->host() + F("/api/")); - } - - // DPRINTLN(DBG_INFO, "API mem usage: " + String(root.memoryUsage())); - response->addHeader("Access-Control-Allow-Origin", "*"); - response->addHeader("Access-Control-Allow-Headers", "content-type"); - response->setLength(); - request->send(response); - } - - void onApiPost(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, "onApiPost"); - } - - void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) { - DPRINTLN(DBG_VERBOSE, "onApiPostBody"); - DynamicJsonDocument json(200); - AsyncJsonResponse *response = new AsyncJsonResponse(false, 200); - JsonObject root = response->getRoot(); - - DeserializationError err = deserializeJson(json, (const char *)data, len); - JsonObject obj = json.as(); - root[F("success")] = (err) ? false : true; - if (!err) { String path = request->url().substring(5); - if (path == "ctrl") - root[F("success")] = setCtrl(obj, root); - else if (path == "setup") - root[F("success")] = setSetup(obj, root); + if(path == "html/system") getHtmlSystem(root); + else if(path == "html/logout") getHtmlLogout(root); + else if(path == "html/save") getHtmlSave(root); + else if(path == "system") getSysInfo(root); + else if(path == "generic") getGeneric(root); + else if(path == "reboot") getReboot(root); + else if(path == "statistics") getStatistics(root); + else if(path == "inverter/list") getInverterList(root); + else if(path == "index") getIndex(root); + else if(path == "setup") getSetup(root); + else if(path == "setup/networks") getNetworks(root); + else if(path == "live") getLive(root); + else if(path == "record/info") getRecord(root, InverterDevInform_All); + else if(path == "record/alarm") getRecord(root, AlarmData); + else if(path == "record/config") getRecord(root, SystemConfigPara); + else if(path == "record/live") getRecord(root, RealTimeRunData_Debug); else { - root[F("success")] = false; - root[F("error")] = "Path not found: " + path; - } - } else { - switch (err.code()) { - case DeserializationError::Ok: - break; - case DeserializationError::InvalidInput: - root[F("error")] = F("Invalid input"); - break; - case DeserializationError::NoMemory: - root[F("error")] = F("Not enough memory"); - break; - default: - root[F("error")] = F("Deserialization failed"); - break; + if(path.substring(0, 12) == "inverter/id/") + getInverter(root, request->url().substring(17).toInt()); + else + getNotFound(root, F("http://") + request->host() + F("/api/")); } + + //DPRINTLN(DBG_INFO, "API mem usage: " + String(root.memoryUsage())); + response->addHeader("Access-Control-Allow-Origin", "*"); + response->addHeader("Access-Control-Allow-Headers", "content-type"); + response->setLength(); + request->send(response); + } + + void onApiPost(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, "onApiPost"); } - response->setLength(); - request->send(response); - } - - void getNotFound(JsonObject obj, String url) { - JsonObject ep = obj.createNestedObject("avail_endpoints"); - ep[F("system")] = url + F("system"); - ep[F("statistics")] = url + F("statistics"); - ep[F("inverter/list")] = url + F("inverter/list"); - ep[F("index")] = url + F("index"); - ep[F("setup")] = url + F("setup"); - ep[F("live")] = url + F("live"); - ep[F("record/info")] = url + F("record/info"); - ep[F("record/alarm")] = url + F("record/alarm"); - ep[F("record/config")] = url + F("record/config"); - ep[F("record/live")] = url + F("record/live"); - } - - void onDwnldSetup(AsyncWebServerRequest *request) { - AsyncWebServerResponse *response; - - File fp = LittleFS.open("/settings.json", "r"); - if (!fp) { - DPRINTLN(DBG_ERROR, F("failed to load settings")); - response = request->beginResponse(200, F("application/json; charset=utf-8"), "{}"); - } else { - String tmp = fp.readString(); - int i = 0; - // remove all passwords - while (i != -1) { - i = tmp.indexOf("\"pwd\":", i); - if (-1 != i) { - i += 7; - tmp.remove(i, tmp.indexOf("\"", i) - i); + void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) { + DPRINTLN(DBG_VERBOSE, "onApiPostBody"); + DynamicJsonDocument json(200); + AsyncJsonResponse* response = new AsyncJsonResponse(false, 200); + JsonObject root = response->getRoot(); + + DeserializationError err = deserializeJson(json, (const char *)data, len); + JsonObject obj = json.as(); + root[F("success")] = (err) ? false : true; + if(!err) { + String path = request->url().substring(5); + if(path == "ctrl") + root[F("success")] = setCtrl(obj, root); + else if(path == "setup") + root[F("success")] = setSetup(obj, root); + else { + root[F("success")] = false; + root[F("error")] = "Path not found: " + path; } } - response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp); + else { + switch (err.code()) { + case DeserializationError::Ok: break; + case DeserializationError::InvalidInput: root[F("error")] = F("Invalid input"); break; + case DeserializationError::NoMemory: root[F("error")] = F("Not enough memory"); break; + default: root[F("error")] = F("Deserialization failed"); break; + } + } + + response->setLength(); + request->send(response); } - response->addHeader("Content-Type", "application/octet-stream"); - response->addHeader("Content-Description", "File Transfer"); - response->addHeader("Content-Disposition", "attachment; filename=ahoy_setup.json"); - request->send(response); - fp.close(); - } + void getNotFound(JsonObject obj, String url) { + JsonObject ep = obj.createNestedObject("avail_endpoints"); + ep[F("system")] = url + F("system"); + ep[F("statistics")] = url + F("statistics"); + ep[F("inverter/list")] = url + F("inverter/list"); + ep[F("index")] = url + F("index"); + ep[F("setup")] = url + F("setup"); + ep[F("live")] = url + F("live"); + ep[F("record/info")] = url + F("record/info"); + ep[F("record/alarm")] = url + F("record/alarm"); + ep[F("record/config")] = url + F("record/config"); + ep[F("record/live")] = url + F("record/live"); + } - void getGeneric(JsonObject obj) { - obj[F("wifi_rssi")] = (WiFi.status() != WL_CONNECTED) ? 0 : WiFi.RSSI(); - obj[F("ts_uptime")] = mApp->getUptime(); - obj[F("menu_prot")] = mApp->getProtection(); - obj[F("menu_mask")] = (uint16_t)(mConfig->sys.protectionMask); - obj[F("menu_protEn")] = (bool)(strlen(mConfig->sys.adminPwd) > 0); -#if defined(ESP32) - obj[F("esp_type")] = F("ESP32"); -#else - obj[F("esp_type")] = F("ESP8266"); -#endif - } - - void getSysInfo(JsonObject obj) { - obj[F("ssid")] = mConfig->sys.stationSsid; - obj[F("device_name")] = mConfig->sys.deviceName; - obj[F("dark_mode")] = (bool)mConfig->sys.darkMode; - - obj[F("mac")] = WiFi.macAddress(); - obj[F("hostname")] = mConfig->sys.deviceName; - obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); - obj[F("prot_mask")] = mConfig->sys.protectionMask; - - obj[F("sdk")] = ESP.getSdkVersion(); - obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); - obj[F("heap_free")] = mHeapFree; - obj[F("sketch_total")] = ESP.getFreeSketchSpace(); - obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb - getGeneric(obj); - - getRadio(obj.createNestedObject(F("radio"))); - getStatistics(obj.createNestedObject(F("statistics"))); - -#if defined(ESP32) - obj[F("heap_total")] = ESP.getHeapSize(); - obj[F("chip_revision")] = ESP.getChipRevision(); - obj[F("chip_model")] = ESP.getChipModel(); - obj[F("chip_cores")] = ESP.getChipCores(); - // obj[F("core_version")] = F("n/a"); - // obj[F("flash_size")] = F("n/a"); - // obj[F("heap_frag")] = F("n/a"); - // obj[F("max_free_blk")] = F("n/a"); - // obj[F("reboot_reason")] = F("n/a"); -#else - // obj[F("heap_total")] = F("n/a"); - // obj[F("chip_revision")] = F("n/a"); - // obj[F("chip_model")] = F("n/a"); - // obj[F("chip_cores")] = F("n/a"); - obj[F("core_version")] = ESP.getCoreVersion(); - obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb - obj[F("heap_frag")] = mHeapFrag; - obj[F("max_free_blk")] = mHeapFreeBlk; - obj[F("reboot_reason")] = ESP.getResetReason(); -#endif - // obj[F("littlefs_total")] = LittleFS.totalBytes(); - // obj[F("littlefs_used")] = LittleFS.usedBytes(); - - uint8_t max; - mApp->getSchedulerInfo(&max); - obj[F("schMax")] = max; - } - - void getHtmlSystem(JsonObject obj) { - getSysInfo(obj.createNestedObject(F("system"))); - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("html")] = F("Factory Reset

Reboot"); - } - - void getHtmlLogout(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 3; - obj[F("refresh_url")] = "/"; - obj[F("html")] = F("succesfully logged out"); - } - - void getHtmlSave(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 2; - obj[F("refresh_url")] = "/setup"; - obj[F("html")] = F("settings succesfully save"); - } - - void getReboot(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("refresh")] = 10; - obj[F("refresh_url")] = "/"; - obj[F("html")] = F("reboot. Autoreload after 10 seconds"); - } - - void getStatistics(JsonObject obj) { - statistics_t *stat = mApp->getStatistics(); - obj[F("rx_success")] = stat->rxSuccess; - obj[F("rx_fail")] = stat->rxFail; - obj[F("rx_fail_answer")] = stat->rxFailNoAnser; - obj[F("frame_cnt")] = stat->frmCnt; - obj[F("tx_cnt")] = mSys->Radio.mSendCnt; - obj[F("retransmits")] = mSys->Radio.mRetransmits; - } - - void getInverterList(JsonObject obj) { - JsonArray invArr = obj.createNestedArray(F("inverter")); - - Inverter<> *iv; - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(i); - if (NULL != iv) { - JsonObject obj2 = invArr.createNestedObject(); - obj2[F("enabled")] = (bool)iv->config->enabled; - obj2[F("id")] = i; - obj2[F("name")] = String(iv->config->name); - obj2[F("serial")] = String(iv->config->serial.u64, HEX); - obj2[F("channels")] = iv->channels; - obj2[F("version")] = String(iv->getFwVersion()); - - for (uint8_t j = 0; j < iv->channels; j++) { - obj2[F("ch_yield_cor")][j] = iv->config->yieldCor[j]; - obj2[F("ch_max_power")][j] = iv->config->chMaxPwr[j]; - obj2[F("ch_name")][j] = iv->config->chName[j]; + void onDwnldSetup(AsyncWebServerRequest *request) { + AsyncWebServerResponse *response; + + File fp = LittleFS.open("/settings.json", "r"); + if(!fp) { + DPRINTLN(DBG_ERROR, F("failed to load settings")); + response = request->beginResponse(200, F("application/json; charset=utf-8"), "{}"); + } + else { + String tmp = fp.readString(); + int i = 0; + // remove all passwords + while (i != -1) { + i = tmp.indexOf("\"pwd\":", i); + if(-1 != i) { + i+=7; + tmp.remove(i, tmp.indexOf("\"", i)-i); + } } + response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp); } + + response->addHeader("Content-Type", "application/octet-stream"); + response->addHeader("Content-Description", "File Transfer"); + response->addHeader("Content-Disposition", "attachment; filename=ahoy_setup.json"); + request->send(response); + fp.close(); } - obj[F("interval")] = String(mConfig->nrf.sendInterval); - obj[F("retries")] = String(mConfig->nrf.maxRetransPerPyld); - obj[F("max_num_inverters")] = MAX_NUM_INVERTERS; - obj[F("rstMid")] = (bool)mConfig->inst.rstYieldMidNight; - obj[F("rstNAvail")] = (bool)mConfig->inst.rstValsNotAvail; - obj[F("rstComStop")] = (bool)mConfig->inst.rstValsCommStop; - } - - void getInverter(JsonObject obj, uint8_t id) { - Inverter<> *iv = mSys->getInverterByPos(id); - if (NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - obj[F("id")] = id; - obj[F("enabled")] = (bool)iv->config->enabled; - obj[F("name")] = String(iv->config->name); - obj[F("serial")] = String(iv->config->serial.u64, HEX); - obj[F("version")] = String(iv->getFwVersion()); - obj[F("power_limit_read")] = ah::round3(iv->actPowerLimit); - obj[F("ts_last_success")] = rec->ts; - - JsonArray ch = obj.createNestedArray("ch"); - - // AC - uint8_t pos; - obj[F("ch_name")][0] = "AC"; - JsonArray ch0 = ch.createNestedArray(); - for (uint8_t fld = 0; fld < sizeof(acList); fld++) { - pos = (iv->getPosByChFld(CH0, acList[fld], rec)); - ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - } - // DC - for (uint8_t j = 0; j < iv->channels; j++) { - obj[F("ch_name")][j + 1] = iv->config->chName[j]; - JsonArray cur = ch.createNestedArray(); - for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { - pos = (iv->getPosByChFld((j + 1), dcList[fld], rec)); - cur[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - } - } + void getGeneric(JsonObject obj) { + obj[F("wifi_rssi")] = (WiFi.status() != WL_CONNECTED) ? 0 : WiFi.RSSI(); + obj[F("ts_uptime")] = mApp->getUptime(); + obj[F("menu_prot")] = mApp->getProtection(); + obj[F("menu_mask")] = (uint16_t)(mConfig->sys.protectionMask ); + obj[F("menu_protEn")] = (bool) (strlen(mConfig->sys.adminPwd) > 0); + + #if defined(ESP32) + obj[F("esp_type")] = F("ESP32"); + #else + obj[F("esp_type")] = F("ESP8266"); + #endif } - } - - void getMqtt(JsonObject obj) { - obj[F("broker")] = String(mConfig->mqtt.broker); - obj[F("port")] = String(mConfig->mqtt.port); - obj[F("user")] = String(mConfig->mqtt.user); - obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); - obj[F("topic")] = String(mConfig->mqtt.topic); - obj[F("interval")] = String(mConfig->mqtt.interval); - } - - void getNtp(JsonObject obj) { - obj[F("addr")] = String(mConfig->ntp.addr); - obj[F("port")] = String(mConfig->ntp.port); - } - - void getSun(JsonObject obj) { - obj[F("lat")] = mConfig->sun.lat ? String(mConfig->sun.lat, 5) : ""; - obj[F("lon")] = mConfig->sun.lat ? String(mConfig->sun.lon, 5) : ""; - obj[F("disnightcom")] = mConfig->sun.disNightCom; - obj[F("offs")] = mConfig->sun.offsetSec; - } - - void getPinout(JsonObject obj) { - obj[F("cs")] = mConfig->nrf.pinCs; - obj[F("ce")] = mConfig->nrf.pinCe; - obj[F("irq")] = mConfig->nrf.pinIrq; - obj[F("led0")] = mConfig->led.led0; - obj[F("led1")] = mConfig->led.led1; - } - - void getRadio(JsonObject obj) { - obj[F("power_level")] = mConfig->nrf.amplifierPower; - obj[F("isconnected")] = mSys->Radio.isChipConnected(); - obj[F("DataRate")] = mSys->Radio.getDataRate(); - obj[F("isPVariant")] = mSys->Radio.isPVariant(); - } - - void getSerial(JsonObject obj) { - obj[F("interval")] = (uint16_t)mConfig->serial.interval; - obj[F("show_live_data")] = mConfig->serial.showIv; - obj[F("debug")] = mConfig->serial.debug; - } - - void getStaticIp(JsonObject obj) { - char buf[16]; - ah::ip2Char(mConfig->sys.ip.ip, buf); - obj[F("ip")] = String(buf); - ah::ip2Char(mConfig->sys.ip.mask, buf); - obj[F("mask")] = String(buf); - ah::ip2Char(mConfig->sys.ip.dns1, buf); - obj[F("dns1")] = String(buf); - ah::ip2Char(mConfig->sys.ip.dns2, buf); - obj[F("dns2")] = String(buf); - ah::ip2Char(mConfig->sys.ip.gateway, buf); - obj[F("gateway")] = String(buf); - } - - void getDisplay(JsonObject obj) { - obj[F("disp_type")] = (uint8_t)mConfig->plugin.display.type; - obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; - obj[F("px_shift")] = (bool)mConfig->plugin.display.pxShift; - obj[F("rotation")] = (uint8_t)mConfig->plugin.display.rot; - obj[F("period")] = (uint16_t)mConfig->plugin.display.period; - obj[F("contrast")] = (uint8_t)mConfig->plugin.display.contrast; - obj[F("data")] = mConfig->plugin.display.disp_data; - obj[F("clock")] = mConfig->plugin.display.disp_clk; - obj[F("cs")] = mConfig->plugin.display.disp_cs; - obj[F("reset")] = mConfig->plugin.display.disp_reset; - obj[F("busy")] = mConfig->plugin.display.disp_busy; - obj[F("dc")] = mConfig->plugin.display.disp_dc; - } - - void getIndex(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - obj[F("ts_now")] = mApp->getTimestamp(); - obj[F("ts_sunrise")] = mApp->getSunrise(); - obj[F("ts_sunset")] = mApp->getSunset(); - obj[F("ts_offset")] = mConfig->sun.offsetSec; - obj[F("disNightComm")] = mConfig->sun.disNightCom; - - JsonArray inv = obj.createNestedArray(F("inverter")); - Inverter<> *iv; - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(i); - if (NULL != iv) { - record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - JsonObject invObj = inv.createNestedObject(); - invObj[F("enabled")] = (bool)iv->config->enabled; - invObj[F("id")] = i; - invObj[F("name")] = String(iv->config->name); - invObj[F("version")] = String(iv->getFwVersion()); - invObj[F("is_avail")] = iv->isAvailable(mApp->getTimestamp()); - invObj[F("is_producing")] = iv->isProducing(mApp->getTimestamp()); - invObj[F("ts_last_success")] = iv->getLastTs(rec); + + void getSysInfo(JsonObject obj) { + obj[F("ssid")] = mConfig->sys.stationSsid; + obj[F("device_name")] = mConfig->sys.deviceName; + obj[F("dark_mode")] = (bool)mConfig->sys.darkMode; + + obj[F("mac")] = WiFi.macAddress(); + obj[F("hostname")] = mConfig->sys.deviceName; + obj[F("pwd_set")] = (strlen(mConfig->sys.adminPwd) > 0); + obj[F("prot_mask")] = mConfig->sys.protectionMask; + + obj[F("sdk")] = ESP.getSdkVersion(); + obj[F("cpu_freq")] = ESP.getCpuFreqMHz(); + obj[F("heap_free")] = mHeapFree; + obj[F("sketch_total")] = ESP.getFreeSketchSpace(); + obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb + getGeneric(obj); + + getRadio(obj.createNestedObject(F("radio"))); + getStatistics(obj.createNestedObject(F("statistics"))); + + #if defined(ESP32) + obj[F("heap_total")] = ESP.getHeapSize(); + obj[F("chip_revision")] = ESP.getChipRevision(); + obj[F("chip_model")] = ESP.getChipModel(); + obj[F("chip_cores")] = ESP.getChipCores(); + //obj[F("core_version")] = F("n/a"); + //obj[F("flash_size")] = F("n/a"); + //obj[F("heap_frag")] = F("n/a"); + //obj[F("max_free_blk")] = F("n/a"); + //obj[F("reboot_reason")] = F("n/a"); + #else + //obj[F("heap_total")] = F("n/a"); + //obj[F("chip_revision")] = F("n/a"); + //obj[F("chip_model")] = F("n/a"); + //obj[F("chip_cores")] = F("n/a"); + obj[F("core_version")] = ESP.getCoreVersion(); + obj[F("flash_size")] = ESP.getFlashChipRealSize() / 1024; // in kb + obj[F("heap_frag")] = mHeapFrag; + obj[F("max_free_blk")] = mHeapFreeBlk; + obj[F("reboot_reason")] = ESP.getResetReason(); + #endif + //obj[F("littlefs_total")] = LittleFS.totalBytes(); + //obj[F("littlefs_used")] = LittleFS.usedBytes(); + + uint8_t max; + mApp->getSchedulerInfo(&max); + obj[F("schMax")] = max; + } + + void getHtmlSystem(JsonObject obj) { + getSysInfo(obj.createNestedObject(F("system"))); + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("html")] = F("Factory Reset

Reboot"); + } + + void getHtmlLogout(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 3; + obj[F("refresh_url")] = "/"; + obj[F("html")] = F("succesfully logged out"); + } + + void getHtmlSave(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 2; + obj[F("refresh_url")] = "/setup"; + obj[F("html")] = F("settings succesfully save"); + } + + void getReboot(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("refresh")] = 10; + obj[F("refresh_url")] = "/"; + obj[F("html")] = F("reboot. Autoreload after 10 seconds"); + } + + void getStatistics(JsonObject obj) { + statistics_t *stat = mApp->getStatistics(); + obj[F("rx_success")] = stat->rxSuccess; + obj[F("rx_fail")] = stat->rxFail; + obj[F("rx_fail_answer")] = stat->rxFailNoAnser; + obj[F("frame_cnt")] = stat->frmCnt; + obj[F("tx_cnt")] = mSys->Radio.mSendCnt; + obj[F("retransmits")] = mSys->Radio.mRetransmits; + } + + void getInverterList(JsonObject obj) { + JsonArray invArr = obj.createNestedArray(F("inverter")); + + Inverter<> *iv; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); + if(NULL != iv) { + JsonObject obj2 = invArr.createNestedObject(); + obj2[F("enabled")] = (bool)iv->config->enabled; + obj2[F("id")] = i; + obj2[F("name")] = String(iv->config->name); + obj2[F("serial")] = String(iv->config->serial.u64, HEX); + obj2[F("channels")] = iv->channels; + obj2[F("version")] = String(iv->getFwVersion()); + + for(uint8_t j = 0; j < iv->channels; j ++) { + obj2[F("ch_yield_cor")][j] = iv->config->yieldCor[j]; + obj2[F("ch_max_power")][j] = iv->config->chMaxPwr[j]; + obj2[F("ch_name")][j] = iv->config->chName[j]; + } + } } + obj[F("interval")] = String(mConfig->nrf.sendInterval); + obj[F("retries")] = String(mConfig->nrf.maxRetransPerPyld); + obj[F("max_num_inverters")] = MAX_NUM_INVERTERS; + obj[F("rstMid")] = (bool)mConfig->inst.rstYieldMidNight; + obj[F("rstNAvail")] = (bool)mConfig->inst.rstValsNotAvail; + obj[F("rstComStop")] = (bool)mConfig->inst.rstValsCommStop; } - JsonArray warn = obj.createNestedArray(F("warnings")); - if (!mSys->Radio.isChipConnected()) - warn.add(F("your NRF24 module can't be reached, check the wiring and pinout")); - else if (!mSys->Radio.isPVariant()) - warn.add(F("your NRF24 module isn't a plus version(+), maybe incompatible")); - if (!mApp->getSettingsValid()) - warn.add(F("your settings are invalid")); - if (mApp->getRebootRequestState()) - warn.add(F("reboot your ESP to apply all your configuration changes")); - if (0 == mApp->getTimestamp()) - warn.add(F("time not set. No communication to inverter possible")); - /*if(0 == mSys->getNumInverters()) - warn.add(F("no inverter configured"));*/ - - if ((!mApp->getMqttIsConnected()) && (String(mConfig->mqtt.broker).length() > 0)) - warn.add(F("MQTT is not connected")); - - JsonArray info = obj.createNestedArray(F("infos")); - if (mApp->getMqttIsConnected()) - info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent, ") + String(mApp->getMqttRxCnt()) + F(" packets received")); - if (mConfig->mqtt.interval > 0) - info.add(F("MQTT publishes in a fixed interval of ") + String(mConfig->mqtt.interval) + F(" seconds")); - } - - void getSetup(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - getSysInfo(obj.createNestedObject(F("system"))); - // getInverterList(obj.createNestedObject(F("inverter"))); - getMqtt(obj.createNestedObject(F("mqtt"))); - getNtp(obj.createNestedObject(F("ntp"))); - getSun(obj.createNestedObject(F("sun"))); - getPinout(obj.createNestedObject(F("pinout"))); - getRadio(obj.createNestedObject(F("radio"))); - getSerial(obj.createNestedObject(F("serial"))); - getStaticIp(obj.createNestedObject(F("static_ip"))); - getDisplay(obj.createNestedObject(F("display"))); - } - - void getNetworks(JsonObject obj) { - mApp->getAvailNetworks(obj); - } - - void getLive(JsonObject obj) { - getGeneric(obj.createNestedObject(F("generic"))); - // JsonArray invArr = obj.createNestedArray(F("inverter")); - obj[F("refresh")] = mConfig->nrf.sendInterval; - - for (uint8_t fld = 0; fld < sizeof(acList); fld++) { - obj[F("ch0_fld_units")][fld] = String(units[fieldUnits[acList[fld]]]); - obj[F("ch0_fld_names")][fld] = String(fields[acList[fld]]); - } - for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { - obj[F("fld_units")][fld] = String(units[fieldUnits[dcList[fld]]]); - obj[F("fld_names")][fld] = String(fields[dcList[fld]]); - } - - Inverter<> *iv; - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(i); - bool parse = false; - if (NULL != iv) - parse = iv->config->enabled; - obj[F("iv")][i] = parse; - } - - /*Inverter<> *iv; - uint8_t pos; - for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { - iv = mSys->getInverterByPos(i); + void getInverter(JsonObject obj, uint8_t id) { + Inverter<> *iv = mSys->getInverterByPos(id); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); - JsonObject obj2 = invArr.createNestedObject(); - obj2[F("enabled")] = (bool)iv->config->enabled; - obj2[F("name")] = String(iv->config->name); - obj2[F("channels")] = iv->channels; - obj2[F("power_limit_read")] = ah::round3(iv->actPowerLimit); - //obj2[F("last_alarm")] = String(iv->lastAlarmMsg); - obj2[F("ts_last_success")] = rec->ts; - - JsonArray ch = obj2.createNestedArray("ch"); + obj[F("id")] = id; + obj[F("enabled")] = (bool)iv->config->enabled; + obj[F("name")] = String(iv->config->name); + obj[F("serial")] = String(iv->config->serial.u64, HEX); + obj[F("version")] = String(iv->getFwVersion()); + obj[F("power_limit_read")] = ah::round3(iv->actPowerLimit); + obj[F("ts_last_success")] = rec->ts; + + JsonArray ch = obj.createNestedArray("ch"); + + // AC + uint8_t pos; + obj[F("ch_name")][0] = "AC"; JsonArray ch0 = ch.createNestedArray(); - obj2[F("ch_names")][0] = "AC"; - for (uint8_t fld = 0; fld < sizeof(list); fld++) { - pos = (iv->getPosByChFld(CH0, list[fld], rec)); + for (uint8_t fld = 0; fld < sizeof(acList); fld++) { + pos = (iv->getPosByChFld(CH0, acList[fld], rec)); ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; } - for(uint8_t j = 1; j <= iv->channels; j ++) { - obj2[F("ch_names")][j] = String(iv->config->chName[j-1]); + // DC + for(uint8_t j = 0; j < iv->channels; j ++) { + obj[F("ch_name")][j+1] = iv->config->chName[j]; JsonArray cur = ch.createNestedArray(); - for (uint8_t k = 0; k < 6; k++) { - switch(k) { - default: pos = (iv->getPosByChFld(j, FLD_UDC, rec)); break; - case 1: pos = (iv->getPosByChFld(j, FLD_IDC, rec)); break; - case 2: pos = (iv->getPosByChFld(j, FLD_PDC, rec)); break; - case 3: pos = (iv->getPosByChFld(j, FLD_YD, rec)); break; - case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break; - case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break; - } - cur[k] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; - if(1 == j) { - obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; - } + for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { + pos = (iv->getPosByChFld((j+1), dcList[fld], rec)); + cur[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; } } } - }*/ - } - - void getRecord(JsonObject obj, uint8_t recType) { - JsonArray invArr = obj.createNestedArray(F("inverter")); - - Inverter<> *iv; - record_t<> *rec; - uint8_t pos; - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(i); - if (NULL != iv) { - rec = iv->getRecordStruct(recType); - JsonArray obj2 = invArr.createNestedArray(); - for (uint8_t j = 0; j < rec->length; j++) { - byteAssign_t *assign = iv->getByteAssign(j, rec); - pos = (iv->getPosByChFld(assign->ch, assign->fieldId, rec)); - obj2[j]["fld"] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; - obj2[j]["unit"] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; - obj2[j]["val"] = (0xff != pos) ? String(iv->getValue(pos, rec)) : notAvail; + } + + void getMqtt(JsonObject obj) { + obj[F("broker")] = String(mConfig->mqtt.broker); + obj[F("port")] = String(mConfig->mqtt.port); + obj[F("user")] = String(mConfig->mqtt.user); + obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); + obj[F("topic")] = String(mConfig->mqtt.topic); + obj[F("interval")] = String(mConfig->mqtt.interval); + } + + void getNtp(JsonObject obj) { + obj[F("addr")] = String(mConfig->ntp.addr); + obj[F("port")] = String(mConfig->ntp.port); + } + + void getSun(JsonObject obj) { + obj[F("lat")] = mConfig->sun.lat ? String(mConfig->sun.lat, 5) : ""; + obj[F("lon")] = mConfig->sun.lat ? String(mConfig->sun.lon, 5) : ""; + obj[F("disnightcom")] = mConfig->sun.disNightCom; + obj[F("offs")] = mConfig->sun.offsetSec; + } + + void getPinout(JsonObject obj) { + obj[F("cs")] = mConfig->nrf.pinCs; + obj[F("ce")] = mConfig->nrf.pinCe; + obj[F("irq")] = mConfig->nrf.pinIrq; + obj[F("led0")] = mConfig->led.led0; + obj[F("led1")] = mConfig->led.led1; + } + + void getRadio(JsonObject obj) { + obj[F("power_level")] = mConfig->nrf.amplifierPower; + obj[F("isconnected")] = mSys->Radio.isChipConnected(); + obj[F("DataRate")] = mSys->Radio.getDataRate(); + obj[F("isPVariant")] = mSys->Radio.isPVariant(); + } + + void getSerial(JsonObject obj) { + obj[F("interval")] = (uint16_t)mConfig->serial.interval; + obj[F("show_live_data")] = mConfig->serial.showIv; + obj[F("debug")] = mConfig->serial.debug; + } + + void getStaticIp(JsonObject obj) { + char buf[16]; + ah::ip2Char(mConfig->sys.ip.ip, buf); obj[F("ip")] = String(buf); + ah::ip2Char(mConfig->sys.ip.mask, buf); obj[F("mask")] = String(buf); + ah::ip2Char(mConfig->sys.ip.dns1, buf); obj[F("dns1")] = String(buf); + ah::ip2Char(mConfig->sys.ip.dns2, buf); obj[F("dns2")] = String(buf); + ah::ip2Char(mConfig->sys.ip.gateway, buf); obj[F("gateway")] = String(buf); + } + + void getDisplay(JsonObject obj) { + obj[F("disp_typ")] = (uint8_t)mConfig->plugin.display.type; + obj[F("disp_pwr")] = (bool)mConfig->plugin.display.pwrSaveAtIvOffline; + obj[F("disp_pxshift")] = (bool)mConfig->plugin.display.pxShift; + obj[F("disp_rot")] = (uint8_t)mConfig->plugin.display.rot; + obj[F("disp_cont")] = (uint8_t)mConfig->plugin.display.contrast; + obj[F("disp_clk")] = mConfig->plugin.display.disp_clk; + obj[F("disp_data")] = mConfig->plugin.display.disp_data; + obj[F("disp_cs")] = mConfig->plugin.display.disp_cs; + obj[F("disp_dc")] = mConfig->plugin.display.disp_dc; + obj[F("disp_rst")] = mConfig->plugin.display.disp_reset; + obj[F("disp_bsy")] = mConfig->plugin.display.disp_busy; + } + + void getIndex(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + obj[F("ts_now")] = mApp->getTimestamp(); + obj[F("ts_sunrise")] = mApp->getSunrise(); + obj[F("ts_sunset")] = mApp->getSunset(); + obj[F("ts_offset")] = mConfig->sun.offsetSec; + obj[F("disNightComm")] = mConfig->sun.disNightCom; + + JsonArray inv = obj.createNestedArray(F("inverter")); + Inverter<> *iv; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + JsonObject invObj = inv.createNestedObject(); + invObj[F("enabled")] = (bool)iv->config->enabled; + invObj[F("id")] = i; + invObj[F("name")] = String(iv->config->name); + invObj[F("version")] = String(iv->getFwVersion()); + invObj[F("is_avail")] = iv->isAvailable(mApp->getTimestamp()); + invObj[F("is_producing")] = iv->isProducing(mApp->getTimestamp()); + invObj[F("ts_last_success")] = iv->getLastTs(rec); + } + } + + JsonArray warn = obj.createNestedArray(F("warnings")); + if(!mSys->Radio.isChipConnected()) + warn.add(F("your NRF24 module can't be reached, check the wiring and pinout")); + else if(!mSys->Radio.isPVariant()) + warn.add(F("your NRF24 module isn't a plus version(+), maybe incompatible")); + if(!mApp->getSettingsValid()) + warn.add(F("your settings are invalid")); + if(mApp->getRebootRequestState()) + warn.add(F("reboot your ESP to apply all your configuration changes")); + if(0 == mApp->getTimestamp()) + warn.add(F("time not set. No communication to inverter possible")); + /*if(0 == mSys->getNumInverters()) + warn.add(F("no inverter configured"));*/ + + if((!mApp->getMqttIsConnected()) && (String(mConfig->mqtt.broker).length() > 0)) + warn.add(F("MQTT is not connected")); + + JsonArray info = obj.createNestedArray(F("infos")); + if(mApp->getMqttIsConnected()) + info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent, ") + String(mApp->getMqttRxCnt()) + F(" packets received")); + if(mConfig->mqtt.interval > 0) + info.add(F("MQTT publishes in a fixed interval of ") + String(mConfig->mqtt.interval) + F(" seconds")); + } + + void getSetup(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + getSysInfo(obj.createNestedObject(F("system"))); + //getInverterList(obj.createNestedObject(F("inverter"))); + getMqtt(obj.createNestedObject(F("mqtt"))); + getNtp(obj.createNestedObject(F("ntp"))); + getSun(obj.createNestedObject(F("sun"))); + getPinout(obj.createNestedObject(F("pinout"))); + getRadio(obj.createNestedObject(F("radio"))); + getSerial(obj.createNestedObject(F("serial"))); + getStaticIp(obj.createNestedObject(F("static_ip"))); + getDisplay(obj.createNestedObject(F("display"))); + } + + void getNetworks(JsonObject obj) { + mApp->getAvailNetworks(obj); + } + + void getLive(JsonObject obj) { + getGeneric(obj.createNestedObject(F("generic"))); + //JsonArray invArr = obj.createNestedArray(F("inverter")); + obj[F("refresh")] = mConfig->nrf.sendInterval; + + for (uint8_t fld = 0; fld < sizeof(acList); fld++) { + obj[F("ch0_fld_units")][fld] = String(units[fieldUnits[acList[fld]]]); + obj[F("ch0_fld_names")][fld] = String(fields[acList[fld]]); + } + for (uint8_t fld = 0; fld < sizeof(dcList); fld++) { + obj[F("fld_units")][fld] = String(units[fieldUnits[dcList[fld]]]); + obj[F("fld_names")][fld] = String(fields[dcList[fld]]); + } + + Inverter<> *iv; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); + bool parse = false; + if(NULL != iv) + parse = iv->config->enabled; + obj[F("iv")][i] = parse; + } + + /*Inverter<> *iv; + uint8_t pos; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + JsonObject obj2 = invArr.createNestedObject(); + obj2[F("enabled")] = (bool)iv->config->enabled; + obj2[F("name")] = String(iv->config->name); + obj2[F("channels")] = iv->channels; + obj2[F("power_limit_read")] = ah::round3(iv->actPowerLimit); + //obj2[F("last_alarm")] = String(iv->lastAlarmMsg); + obj2[F("ts_last_success")] = rec->ts; + + JsonArray ch = obj2.createNestedArray("ch"); + JsonArray ch0 = ch.createNestedArray(); + obj2[F("ch_names")][0] = "AC"; + for (uint8_t fld = 0; fld < sizeof(list); fld++) { + pos = (iv->getPosByChFld(CH0, list[fld], rec)); + ch0[fld] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + obj[F("ch0_fld_units")][fld] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj[F("ch0_fld_names")][fld] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; + } + + for(uint8_t j = 1; j <= iv->channels; j ++) { + obj2[F("ch_names")][j] = String(iv->config->chName[j-1]); + JsonArray cur = ch.createNestedArray(); + for (uint8_t k = 0; k < 6; k++) { + switch(k) { + default: pos = (iv->getPosByChFld(j, FLD_UDC, rec)); break; + case 1: pos = (iv->getPosByChFld(j, FLD_IDC, rec)); break; + case 2: pos = (iv->getPosByChFld(j, FLD_PDC, rec)); break; + case 3: pos = (iv->getPosByChFld(j, FLD_YD, rec)); break; + case 4: pos = (iv->getPosByChFld(j, FLD_YT, rec)); break; + case 5: pos = (iv->getPosByChFld(j, FLD_IRR, rec)); break; + } + cur[k] = (0xff != pos) ? ah::round3(iv->getValue(pos, rec)) : 0.0; + if(1 == j) { + obj[F("fld_units")][k] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj[F("fld_names")][k] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; + } + } + } + } + }*/ + } + + void getRecord(JsonObject obj, uint8_t recType) { + JsonArray invArr = obj.createNestedArray(F("inverter")); + + Inverter<> *iv; + record_t<> *rec; + uint8_t pos; + for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i ++) { + iv = mSys->getInverterByPos(i); + if(NULL != iv) { + rec = iv->getRecordStruct(recType); + JsonArray obj2 = invArr.createNestedArray(); + for(uint8_t j = 0; j < rec->length; j++) { + byteAssign_t *assign = iv->getByteAssign(j, rec); + pos = (iv->getPosByChFld(assign->ch, assign->fieldId, rec)); + obj2[j]["fld"] = (0xff != pos) ? String(iv->getFieldName(pos, rec)) : notAvail; + obj2[j]["unit"] = (0xff != pos) ? String(iv->getUnit(pos, rec)) : notAvail; + obj2[j]["val"] = (0xff != pos) ? String(iv->getValue(pos, rec)) : notAvail; + } } } } - } - - bool setCtrl(JsonObject jsonIn, JsonObject jsonOut) { - Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")]); - bool accepted = true; - if (NULL == iv) { - jsonOut[F("error")] = F("inverter index invalid: ") + jsonIn[F("id")].as(); - return false; - } - - if (F("power") == jsonIn[F("cmd")]) - accepted = iv->setDevControlRequest((jsonIn[F("val")] == 1) ? TurnOn : TurnOff); - else if (F("restart") == jsonIn[F("restart")]) - accepted = iv->setDevControlRequest(Restart); - else if (0 == strncmp("limit_", jsonIn[F("cmd")].as(), 6)) { - iv->powerLimit[0] = jsonIn["val"]; - if (F("limit_persistent_relative") == jsonIn[F("cmd")]) - iv->powerLimit[1] = RelativPersistent; - else if (F("limit_persistent_absolute") == jsonIn[F("cmd")]) - iv->powerLimit[1] = AbsolutPersistent; - else if (F("limit_nonpersistent_relative") == jsonIn[F("cmd")]) - iv->powerLimit[1] = RelativNonPersistent; - else if (F("limit_nonpersistent_absolute") == jsonIn[F("cmd")]) - iv->powerLimit[1] = AbsolutNonPersistent; - - accepted = iv->setDevControlRequest(ActivePowerContr); - } else if (F("dev") == jsonIn[F("cmd")]) { - DPRINTLN(DBG_INFO, F("dev cmd")); - iv->enqueCommand(jsonIn[F("val")].as()); - } else { - jsonOut[F("error")] = F("unknown cmd: '") + jsonIn["cmd"].as() + "'"; - return false; - } - - if (!accepted) { - jsonOut[F("error")] = F("inverter does not accept dev control request at this moment"); - return false; - } else - mApp->ivSendHighPrio(iv); - - return true; - } - - bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { - if (F("scan_wifi") == jsonIn[F("cmd")]) - mApp->scanAvailNetworks(); - else if (F("set_time") == jsonIn[F("cmd")]) - mApp->setTimestamp(jsonIn[F("val")]); - else if (F("sync_ntp") == jsonIn[F("cmd")]) - mApp->setTimestamp(0); // 0: update ntp flag - else if (F("serial_utc_offset") == jsonIn[F("cmd")]) - mTimezoneOffset = jsonIn[F("val")]; - else if (F("discovery_cfg") == jsonIn[F("cmd")]) { - mApp->setMqttDiscoveryFlag(); // for homeassistant - } else { - jsonOut[F("error")] = F("unknown cmd"); - return false; - } - - return true; - } - - IApp *mApp; - HMSYSTEM *mSys; - AsyncWebServer *mSrv; - settings_t *mConfig; - - uint32_t mTimezoneOffset; - uint32_t mHeapFree, mHeapFreeBlk; - uint8_t mHeapFrag; - uint16_t nr; + + bool setCtrl(JsonObject jsonIn, JsonObject jsonOut) { + Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")]); + bool accepted = true; + if(NULL == iv) { + jsonOut[F("error")] = F("inverter index invalid: ") + jsonIn[F("id")].as(); + return false; + } + + if(F("power") == jsonIn[F("cmd")]) + accepted = iv->setDevControlRequest((jsonIn[F("val")] == 1) ? TurnOn : TurnOff); + else if(F("restart") == jsonIn[F("restart")]) + accepted = iv->setDevControlRequest(Restart); + else if(0 == strncmp("limit_", jsonIn[F("cmd")].as(), 6)) { + iv->powerLimit[0] = jsonIn["val"]; + if(F("limit_persistent_relative") == jsonIn[F("cmd")]) + iv->powerLimit[1] = RelativPersistent; + else if(F("limit_persistent_absolute") == jsonIn[F("cmd")]) + iv->powerLimit[1] = AbsolutPersistent; + else if(F("limit_nonpersistent_relative") == jsonIn[F("cmd")]) + iv->powerLimit[1] = RelativNonPersistent; + else if(F("limit_nonpersistent_absolute") == jsonIn[F("cmd")]) + iv->powerLimit[1] = AbsolutNonPersistent; + + accepted = iv->setDevControlRequest(ActivePowerContr); + } + else if(F("dev") == jsonIn[F("cmd")]) { + DPRINTLN(DBG_INFO, F("dev cmd")); + iv->enqueCommand(jsonIn[F("val")].as()); + } + else { + jsonOut[F("error")] = F("unknown cmd: '") + jsonIn["cmd"].as() + "'"; + return false; + } + + if(!accepted) { + jsonOut[F("error")] = F("inverter does not accept dev control request at this moment"); + return false; + } else + mApp->ivSendHighPrio(iv); + + return true; + } + + bool setSetup(JsonObject jsonIn, JsonObject jsonOut) { + if(F("scan_wifi") == jsonIn[F("cmd")]) + mApp->scanAvailNetworks(); + else if(F("set_time") == jsonIn[F("cmd")]) + mApp->setTimestamp(jsonIn[F("val")]); + else if(F("sync_ntp") == jsonIn[F("cmd")]) + mApp->setTimestamp(0); // 0: update ntp flag + else if(F("serial_utc_offset") == jsonIn[F("cmd")]) + mTimezoneOffset = jsonIn[F("val")]; + else if(F("discovery_cfg") == jsonIn[F("cmd")]) { + mApp->setMqttDiscoveryFlag(); // for homeassistant + } else { + jsonOut[F("error")] = F("unknown cmd"); + return false; + } + + return true; + } + + IApp *mApp; + HMSYSTEM *mSys; + AsyncWebServer *mSrv; + settings_t *mConfig; + + uint32_t mTimezoneOffset; + uint32_t mHeapFree, mHeapFreeBlk; + uint8_t mHeapFrag; + uint16_t nr; }; #endif /*__WEB_API_H__*/ diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 7342a121..09cc4a67 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -255,28 +255,19 @@
Display Config
-
-
Show Logo
-
-
+
Turn off while inverters are offline
-
-
-
-
Enable pixel shifting
-
+
-
Rotate 180 degree
-
+
Enable Screensaver (pixel shifting)
+
Contrast
-
+
- -

Pinout

@@ -509,10 +500,10 @@ for(var j of [ ["ModPwr", "ch_max_power", "Max Module Power (Wp)", 4, "[0-9]+"], - ["ModName", "ch_name", "Module Name", 16, null], - ["YieldCor", "ch_yield_cor", "Yield Total Correction [kWh]", 16, "[0-9-]+"]]) { + ["ModName", "ch_name", "Module Name", 15, null], + ["YieldCor", "ch_yield_cor", "Yield Total Correction [kWh]", 8, "[0-9-]+"]]) { - var cl = (re.test(obj["serial"])) ? null : ["hide"]; + var cl = (re.test(obj["serial"])) ? "" : " hide"; i = 0; arrIn = []; @@ -524,7 +515,7 @@ } iv.append( - ml("div", {class: "row mb-2 mb-sm-3", id: "row" + id + j[0]}, [ + ml("div", {class: "row mb-2 mb-sm-3" + cl, id: "row" + id + j[0]}, [ ml("div", {class: "col-12 col-sm-3 my-2"}, j[2]), ml("div", {class: "col-12 col-sm-9"}, ml("div", {class: "row"}, arrIn) @@ -639,12 +630,14 @@ } function parseDisplay(obj, type) { - for(var i of [["logoEn", "logo_en"], ["dispPwr", "disp_pwr"], ["dispPxSh", "px_shift"], ["disp180", "rot180"]]) - document.getElementsByName(i[0])[0].checked = obj[i[1]]; + for(var i of ["disp_pwr", "disp_pxshift"]) + document.getElementsByName(i)[0].checked = obj[i]; var e = document.getElementById("dispPins"); - pins = [['SCL / CS', 'pinDisp0'], ['SDA / DC', 'pinDisp1']]; + pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst'], ['busy', 'disp_bsy']]; for(p of pins) { + if(("ESP8266" == type) && p[0] == "cs") + break; e.append( ml("div", {class: "row mb-3"}, [ ml("div", {class: "col-12 col-sm-3 my-2"}, p[0].toUpperCase()), @@ -655,18 +648,31 @@ ); } - var opts = [[0, "None"], [1, "Nokia5110"], [2, "SSD1306 0.96\""], [3, "SH1106 1.3\""]]; + var opts = [[0, "None"], [2, "SSD1306 0.96\""], [3, "SH1106 1.3\""]]; + if("ESP32" == type) { + opts.push([1, "Nokia5110"]); + opts.push([10, "ePaper"]); + } document.getElementById("dispType").append( ml("div", {class: "row mb-3"}, [ ml("div", {class: "col-12 col-sm-3 my-2"}, "Type"), - ml("div", {class: "col-12 col-sm-9"}, sel("dispType", opts, obj["disp_type"])) + ml("div", {class: "col-12 col-sm-9"}, sel("disp_typ", opts, obj["disp_typ"])) ]) ); - e = document.getElementById("contrast"); - for(var i = 30; i < 101; i += 2) { - e.appendChild(opt(i, i, (i == obj["contrast"]))); + opts = [[0, "0°"], [2, "180°"]]; + if("ESP32" == type) { + opts.push([1, "90°"]); + opts.push([3, "270°"]); } + document.getElementById("dispRot").append( + ml("div", {class: "row mb-3"}, [ + ml("div", {class: "col-12 col-sm-3 my-2"}, "Rotation"), + ml("div", {class: "col-12 col-sm-9"}, sel("disp_rot", opts, obj["disp_rot"])) + ]) + ); + + document.getElementsByName("disp_cont")[0].value = obj["disp_cont"]; } function parse(root) { diff --git a/src/web/html/style.css b/src/web/html/style.css index 1b0f8c48..ca4b0c9a 100644 --- a/src/web/html/style.css +++ b/src/web/html/style.css @@ -595,3 +595,39 @@ div.hr { background-color: var(--primary); color: #fff; } + + +.css-tooltip{ + position: relative; +} +.css-tooltip:hover:after{ + content:attr(data-tooltip); + background:#000; + padding:5px; + border-radius:3px; + display: inline-block; + position: absolute; + transform: translate(-50%,-100%); + margin:0 auto; + color:#FFF; + min-width:100px; + min-width:150px; + top:-5px; + left: 50%; + text-align:center; +} +.css-tooltip:hover:before { + top:-5px; + left: 50%; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-color: rgba(0, 0, 0, 0); + border-top-color: #000; + border-width: 5px; + margin-left: -5px; + transform: translate(0,0px); +} diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index 0fbbeeee..9b6dd5d5 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -46,7 +46,7 @@ } function numMid(val, unit, des) { - return ml("div", {class: "col-6 col-sm-4 col-md-3"}, [ + return ml("div", {class: "col-6 col-sm-4 col-md-3 mb-2"}, [ ml("div", {class: "row"}, ml("div", {class: "col"}, [ ml("span", {class: "fs-6"}, String(val)), @@ -93,13 +93,14 @@ total[2] += obj.ch[0][6]; // YieldTotal total[3] += obj.ch[0][8]; // P_DC total[4] += obj.ch[0][10]; // Q_AC + var t = span(" ° C"); return ml("div", {class: "row"}, ml("div", {class: "col"}, [ ml("div", {class: "p-2 iv-h"}, ml("div", {class: "row"}, [ ml("div", {class: "col mx-2 mx-md-1"}, obj.name), ml("div", {class: "col a-c"}, "Power limit " + ((obj.power_limit_read == 65535) ? "n/a" : (obj.power_limit_read + " %"))), - ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + " C") + ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5]) + t.innerHTML) ]) ), ml("div", {class: "p-2 iv-bg"}, [ diff --git a/src/web/web.h b/src/web/web.h index 5eed3688..9f12400e 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -37,918 +37,894 @@ const char *const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinLed0", "pinLe template class Web { public: - Web(void) : mWeb(80), mEvts("/events") { - mProtected = true; - mLogoutTimeout = 0; - - memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); - mSerialBufFill = 0; - mSerialAddTime = true; - mSerialClientConnnected = false; - } - - void setup(IApp *app, HMSYSTEM *sys, settings_t *config) { - mApp = app; - mSys = sys; - mConfig = config; - - DPRINTLN(DBG_VERBOSE, F("app::setup-on")); - mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1)); - mWeb.on("/login", HTTP_ANY, std::bind(&Web::onLogin, this, std::placeholders::_1)); - mWeb.on("/logout", HTTP_GET, std::bind(&Web::onLogout, this, std::placeholders::_1)); - mWeb.on("/colors.css", HTTP_GET, std::bind(&Web::onColor, this, std::placeholders::_1)); - mWeb.on("/style.css", HTTP_GET, std::bind(&Web::onCss, this, std::placeholders::_1)); - mWeb.on("/api.js", HTTP_GET, std::bind(&Web::onApiJs, this, std::placeholders::_1)); - mWeb.on("/favicon.ico", HTTP_GET, std::bind(&Web::onFavicon, this, std::placeholders::_1)); - mWeb.onNotFound(std::bind(&Web::showNotFound, this, std::placeholders::_1)); - mWeb.on("/reboot", HTTP_ANY, std::bind(&Web::onReboot, this, std::placeholders::_1)); - mWeb.on("/system", HTTP_ANY, std::bind(&Web::onSystem, this, std::placeholders::_1)); - mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showErase, this, std::placeholders::_1)); - mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1)); - - mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1)); - mWeb.on("/save", HTTP_ANY, std::bind(&Web::showSave, this, std::placeholders::_1)); - - mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); - // mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); - -#ifdef ENABLE_JSON_EP - mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1)); -#endif -#ifdef ENABLE_PROMETHEUS_EP - mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); -#endif - - mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1)); - mWeb.on("/update", HTTP_POST, std::bind(&Web::showUpdate, this, std::placeholders::_1), - std::bind(&Web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); - mWeb.on("/upload", HTTP_POST, std::bind(&Web::onUpload, this, std::placeholders::_1), - std::bind(&Web::onUpload2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); - mWeb.on("/serial", HTTP_GET, std::bind(&Web::onSerial, this, std::placeholders::_1)); - mWeb.on("/debug", HTTP_GET, std::bind(&Web::onDebug, this, std::placeholders::_1)); - - mEvts.onConnect(std::bind(&Web::onConnect, this, std::placeholders::_1)); - mWeb.addHandler(&mEvts); - - mWeb.begin(); + Web(void) : mWeb(80), mEvts("/events") { + mProtected = true; + mLogoutTimeout = 0; + + memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); + mSerialBufFill = 0; + mSerialAddTime = true; + mSerialClientConnnected = false; + } + + void setup(IApp *app, HMSYSTEM *sys, settings_t *config) { + mApp = app; + mSys = sys; + mConfig = config; + + DPRINTLN(DBG_VERBOSE, F("app::setup-on")); + mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1)); + mWeb.on("/login", HTTP_ANY, std::bind(&Web::onLogin, this, std::placeholders::_1)); + mWeb.on("/logout", HTTP_GET, std::bind(&Web::onLogout, this, std::placeholders::_1)); + mWeb.on("/colors.css", HTTP_GET, std::bind(&Web::onColor, this, std::placeholders::_1)); + mWeb.on("/style.css", HTTP_GET, std::bind(&Web::onCss, this, std::placeholders::_1)); + mWeb.on("/api.js", HTTP_GET, std::bind(&Web::onApiJs, this, std::placeholders::_1)); + mWeb.on("/favicon.ico", HTTP_GET, std::bind(&Web::onFavicon, this, std::placeholders::_1)); + mWeb.onNotFound ( std::bind(&Web::showNotFound, this, std::placeholders::_1)); + mWeb.on("/reboot", HTTP_ANY, std::bind(&Web::onReboot, this, std::placeholders::_1)); + mWeb.on("/system", HTTP_ANY, std::bind(&Web::onSystem, this, std::placeholders::_1)); + mWeb.on("/erase", HTTP_ANY, std::bind(&Web::showErase, this, std::placeholders::_1)); + mWeb.on("/factory", HTTP_ANY, std::bind(&Web::showFactoryRst, this, std::placeholders::_1)); + + mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1)); + mWeb.on("/save", HTTP_ANY, std::bind(&Web::showSave, this, std::placeholders::_1)); + + mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); + //mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); + + #ifdef ENABLE_JSON_EP + mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1)); + #endif + #ifdef ENABLE_PROMETHEUS_EP + mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); + #endif + + mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1)); + mWeb.on("/update", HTTP_POST, std::bind(&Web::showUpdate, this, std::placeholders::_1), + std::bind(&Web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); + mWeb.on("/upload", HTTP_POST, std::bind(&Web::onUpload, this, std::placeholders::_1), + std::bind(&Web::onUpload2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); + mWeb.on("/serial", HTTP_GET, std::bind(&Web::onSerial, this, std::placeholders::_1)); + mWeb.on("/debug", HTTP_GET, std::bind(&Web::onDebug, this, std::placeholders::_1)); + + + mEvts.onConnect(std::bind(&Web::onConnect, this, std::placeholders::_1)); + mWeb.addHandler(&mEvts); + + mWeb.begin(); + + registerDebugCb(std::bind(&Web::serialCb, this, std::placeholders::_1)); // dbg.h - registerDebugCb(std::bind(&Web::serialCb, this, std::placeholders::_1)); // dbg.h + mUploadFail = false; + } - mUploadFail = false; - } + void tickSecond() { + if (0 != mLogoutTimeout) { + mLogoutTimeout -= 1; + if (0 == mLogoutTimeout) { + if (strlen(mConfig->sys.adminPwd) > 0) + mProtected = true; + } - void tickSecond() { - if (0 != mLogoutTimeout) { - mLogoutTimeout -= 1; - if (0 == mLogoutTimeout) { - if (strlen(mConfig->sys.adminPwd) > 0) - mProtected = true; + DPRINTLN(DBG_DEBUG, "auto logout in " + String(mLogoutTimeout)); } - DPRINTLN(DBG_DEBUG, "auto logout in " + String(mLogoutTimeout)); - } - - if (mSerialClientConnnected) { - if (mSerialBufFill > 0) { - mEvts.send(mSerialBuf, "serial", millis()); - memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); - mSerialBufFill = 0; + if (mSerialClientConnnected) { + if (mSerialBufFill > 0) { + mEvts.send(mSerialBuf, "serial", millis()); + memset(mSerialBuf, 0, WEB_SERIAL_BUF_SIZE); + mSerialBufFill = 0; + } } } - } - AsyncWebServer *getWebSrvPtr(void) { - return &mWeb; - } + AsyncWebServer *getWebSrvPtr(void) { + return &mWeb; + } - void setProtection(bool protect) { - mProtected = protect; - } + void setProtection(bool protect) { + mProtected = protect; + } - bool getProtection() { - return mProtected; - } + bool getProtection() { + return mProtected; + } - void showUpdate2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - mApp->setOnUpdate(); + void showUpdate2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + mApp->setOnUpdate(); - if (!index) { - Serial.printf("Update Start: %s\n", filename.c_str()); -#ifndef ESP32 - Update.runAsync(true); -#endif - if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { - Update.printError(Serial); + if (!index) { + Serial.printf("Update Start: %s\n", filename.c_str()); + #ifndef ESP32 + Update.runAsync(true); + #endif + if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { + Update.printError(Serial); + } } - } - if (!Update.hasError()) { - if (Update.write(data, len) != len) { - Update.printError(Serial); + if (!Update.hasError()) { + if (Update.write(data, len) != len) { + Update.printError(Serial); + } } - } - if (final) { - if (Update.end(true)) { - Serial.printf("Update Success: %uB\n", index + len); - } else { - Update.printError(Serial); + if (final) { + if (Update.end(true)) { + Serial.printf("Update Success: %uB\n", index + len); + } else { + Update.printError(Serial); + } } } - } - void onUpload2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { - if (!index) { - mUploadFail = false; - mUploadFp = LittleFS.open("/tmp.json", "w"); - if (!mUploadFp) { - DPRINTLN(DBG_ERROR, F("can't open file!")); - mUploadFail = true; - mUploadFp.close(); + void onUpload2(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + if (!index) { + mUploadFail = false; + mUploadFp = LittleFS.open("/tmp.json", "w"); + if (!mUploadFp) { + DPRINTLN(DBG_ERROR, F("can't open file!")); + mUploadFail = true; + mUploadFp.close(); + } } - } - mUploadFp.write(data, len); - if (final) { - mUploadFp.close(); - File fp = LittleFS.open("/tmp.json", "r"); - if (!fp) - mUploadFail = true; - else { - if (!mApp->readSettings("tmp.json")) { + mUploadFp.write(data, len); + if (final) { + mUploadFp.close(); + File fp = LittleFS.open("/tmp.json", "r"); + if (!fp) mUploadFail = true; - DPRINTLN(DBG_ERROR, F("upload JSON error!")); - } else - mApp->saveSettings(); + else { + if (!mApp->readSettings("tmp.json")) { + mUploadFail = true; + DPRINTLN(DBG_ERROR, F("upload JSON error!")); + } else + mApp->saveSettings(); + } + DPRINTLN(DBG_INFO, F("upload finished!")); } - DPRINTLN(DBG_INFO, F("upload finished!")); } - } - void serialCb(String msg) { - if (!mSerialClientConnnected) - return; + void serialCb(String msg) { + if (!mSerialClientConnnected) + return; - msg.replace("\r\n", ""); - if (mSerialAddTime) { - if ((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { - if (mApp->getTimestamp() > 0) { - strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9); - mSerialBufFill += 9; + msg.replace("\r\n", ""); + if (mSerialAddTime) { + if ((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { + if (mApp->getTimestamp() > 0) { + strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9); + mSerialBufFill += 9; + } + } else { + mSerialBufFill = 0; + mEvts.send("webSerial, buffer overflow!", "serial", millis()); + return; } + mSerialAddTime = false; + } + + if (msg.endsWith("")) + mSerialAddTime = true; + + uint16_t length = msg.length(); + if ((length + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { + strncpy(&mSerialBuf[mSerialBufFill], msg.c_str(), length); + mSerialBufFill += length; } else { mSerialBufFill = 0; mEvts.send("webSerial, buffer overflow!", "serial", millis()); - return; } - mSerialAddTime = false; } - if (msg.endsWith("")) - mSerialAddTime = true; + private: + void checkRedirect(AsyncWebServerRequest *request) { + if ((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) + request->redirect(F("/index")); + else if ((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) + request->redirect(F("/live")); + else if ((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) + request->redirect(F("/serial")); + else if ((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) + request->redirect(F("/system")); + else + request->redirect(F("/login")); + } + + void onUpdate(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onUpdate")); + + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) { + if (mProtected) { + checkRedirect(request); + return; + } + } - uint16_t length = msg.length(); - if ((length + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) { - strncpy(&mSerialBuf[mSerialBufFill], msg.c_str(), length); - mSerialBufFill += length; - } else { - mSerialBufFill = 0; - mEvts.send("webSerial, buffer overflow!", "serial", millis()); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } - } - private: - void checkRedirect(AsyncWebServerRequest *request) { - if ((mConfig->sys.protectionMask & PROT_MASK_INDEX) != PROT_MASK_INDEX) - request->redirect(F("/index")); - else if ((mConfig->sys.protectionMask & PROT_MASK_LIVE) != PROT_MASK_LIVE) - request->redirect(F("/live")); - else if ((mConfig->sys.protectionMask & PROT_MASK_SERIAL) != PROT_MASK_SERIAL) - request->redirect(F("/serial")); - else if ((mConfig->sys.protectionMask & PROT_MASK_SYSTEM) != PROT_MASK_SYSTEM) - request->redirect(F("/system")); - else - request->redirect(F("/login")); - } + void showUpdate(AsyncWebServerRequest *request) { + bool reboot = !Update.hasError(); - void onUpdate(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onUpdate")); + String html = F("UpdateUpdate: "); + if (reboot) + html += "success"; + else + html += "failed"; + html += F("

rebooting ... auto reload after 20s"); - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_UPDATE)) { - if (mProtected) { - checkRedirect(request); - return; - } + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); + response->addHeader("Connection", "close"); + request->send(response); + mApp->setRebootFlag(); } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), update_html, update_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } + void onUpload(AsyncWebServerRequest *request) { + bool reboot = !mUploadFail; - void showUpdate(AsyncWebServerRequest *request) { - bool reboot = !Update.hasError(); + String html = F("UploadUpload: "); + if (reboot) + html += "success"; + else + html += "failed"; + html += F("

rebooting ... auto reload after 20s"); - String html = F("UpdateUpdate: "); - if (reboot) - html += "success"; - else - html += "failed"; - html += F("

rebooting ... auto reload after 20s"); + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); + response->addHeader("Connection", "close"); + request->send(response); + mApp->setRebootFlag(); + } - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); - response->addHeader("Connection", "close"); - request->send(response); - mApp->setRebootFlag(); - } + void onConnect(AsyncEventSourceClient *client) { + DPRINTLN(DBG_VERBOSE, "onConnect"); - void onUpload(AsyncWebServerRequest *request) { - bool reboot = !mUploadFail; + mSerialClientConnnected = true; - String html = F("UploadUpload: "); - if (reboot) - html += "success"; - else - html += "failed"; - html += F("

rebooting ... auto reload after 20s"); + if (client->lastId()) + DPRINTLN(DBG_VERBOSE, "Client reconnected! Last message ID that it got is: " + String(client->lastId())); - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), html); - response->addHeader("Connection", "close"); - request->send(response); - mApp->setRebootFlag(); - } + client->send("hello!", NULL, millis(), 1000); + } - void onConnect(AsyncEventSourceClient *client) { - DPRINTLN(DBG_VERBOSE, "onConnect"); + void onIndex(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onIndex")); - mSerialClientConnnected = true; + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) { + if (mProtected) { + checkRedirect(request); + return; + } + } - if (client->lastId()) - DPRINTLN(DBG_VERBOSE, "Client reconnected! Last message ID that it got is: " + String(client->lastId())); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } - client->send("hello!", NULL, millis(), 1000); - } + void onLogin(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLogin")); - void onIndex(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onIndex")); + if (request->args() > 0) { + if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { + mProtected = false; + request->redirect("/"); + } + } + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), login_html, login_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onLogout(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLogout")); - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_INDEX)) { if (mProtected) { checkRedirect(request); return; } + + mProtected = true; + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), index_html, index_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onLogin(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLogin")); - - if (request->args() > 0) { - if (String(request->arg("pwd")) == String(mConfig->sys.adminPwd)) { - mProtected = false; - request->redirect("/"); - } - } - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), login_html, login_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onLogout(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLogout")); - - if (mProtected) { - checkRedirect(request); - return; - } - - mProtected = true; - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onColor(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onColor")); - AsyncWebServerResponse *response; - if (mConfig->sys.darkMode) - response = request->beginResponse_P(200, F("text/css"), colorDark_css, colorDark_css_len); - else - response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onCss(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onCss")); - mLogoutTimeout = LOGOUT_TIMEOUT; - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onApiJs(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onApiJs")); - - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void onFavicon(AsyncWebServerRequest *request) { - static const char favicon_type[] PROGMEM = "image/x-icon"; - AsyncWebServerResponse *response = request->beginResponse_P(200, favicon_type, favicon_ico, favicon_ico_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void showNotFound(AsyncWebServerRequest *request) { - if (mProtected) - checkRedirect(request); - else - request->redirect("/setup"); - } - - void onReboot(AsyncWebServerRequest *request) { - mApp->setRebootFlag(); - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void showErase(AsyncWebServerRequest *request) { - if (mProtected) { - checkRedirect(request); - return; - } - - DPRINTLN(DBG_VERBOSE, F("showErase")); - mApp->eraseSettings(false); - onReboot(request); - } - - void showFactoryRst(AsyncWebServerRequest *request) { - if (mProtected) { - checkRedirect(request); - return; - } - - DPRINTLN(DBG_VERBOSE, F("showFactoryRst")); - String content = ""; - int refresh = 3; - if (request->args() > 0) { - if (request->arg("reset").toInt() == 1) { - refresh = 10; - if (mApp->eraseSettings(true)) - content = F("factory reset: success\n\nrebooting ... "); - else - content = F("factory reset: failed\n\nrebooting ... "); - } else { - content = F("factory reset: aborted"); - refresh = 3; - } - } else { - content = F( - "

Factory Reset

" - "

RESET

CANCEL

"); - refresh = 120; + void onColor(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onColor")); + AsyncWebServerResponse *response; + if (mConfig->sys.darkMode) + response = request->beginResponse_P(200, F("text/css"), colorDark_css, colorDark_css_len); + else + response = request->beginResponse_P(200, F("text/css"), colorBright_css, colorBright_css_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } - request->send(200, F("text/html; charset=UTF-8"), F("Factory Reset") + content + F("")); - if (refresh == 10) { - delay(1000); - ESP.restart(); + + void onCss(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onCss")); + mLogoutTimeout = LOGOUT_TIMEOUT; + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/css"), style_css, style_css_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } - } - void onSetup(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSetup")); + void onApiJs(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onApiJs")); - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) { - if (mProtected) { + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/javascript"), api_js, api_js_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void onFavicon(AsyncWebServerRequest *request) { + static const char favicon_type[] PROGMEM = "image/x-icon"; + AsyncWebServerResponse *response = request->beginResponse_P(200, favicon_type, favicon_ico, favicon_ico_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void showNotFound(AsyncWebServerRequest *request) { + if (mProtected) checkRedirect(request); - return; - } + else + request->redirect("/setup"); } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } - - void showSave(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("showSave")); - - if (mProtected) { - checkRedirect(request); - return; - } - - if (request->args() == 0) - return; - - char buf[20] = {0}; - - // general - if (request->arg("ssid") != "") - request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); - if (request->arg("pwd") != "{PWD}") - request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); - if (request->arg("device") != "") - request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN); - mConfig->sys.darkMode = (request->arg("darkMode") == "on"); - - // protection - if (request->arg("adminpwd") != "{PWD}") { - request->arg("adminpwd").toCharArray(mConfig->sys.adminPwd, PWD_LEN); - mProtected = (strlen(mConfig->sys.adminPwd) > 0); - } - mConfig->sys.protectionMask = 0x0000; - for (uint8_t i = 0; i < 6; i++) { - if (request->arg("protMask" + String(i)) == "on") - mConfig->sys.protectionMask |= (1 << i); - } - - // static ip - request->arg("ipAddr").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.ip, buf); - request->arg("ipMask").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.mask, buf); - request->arg("ipDns1").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.dns1, buf); - request->arg("ipDns2").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.dns2, buf); - request->arg("ipGateway").toCharArray(buf, 20); - ah::ip2Arr(mConfig->sys.ip.gateway, buf); - - // inverter - Inverter<> *iv; - for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { - iv = mSys->getInverterByPos(i, false); - // enable communication - iv->config->enabled = (request->arg("inv" + String(i) + "Enable") == "on"); - // address - request->arg("inv" + String(i) + "Addr").toCharArray(buf, 20); - if (strlen(buf) == 0) - memset(buf, 0, 20); - iv->config->serial.u64 = ah::Serial2u64(buf); - switch (iv->config->serial.b[4]) { - case 0x21: - iv->type = INV_TYPE_1CH; - iv->channels = 1; - break; - case 0x41: - iv->type = INV_TYPE_2CH; - iv->channels = 2; - break; - case 0x61: - iv->type = INV_TYPE_4CH; - iv->channels = 4; - break; - default: - break; - } - - // name - request->arg("inv" + String(i) + "Name").toCharArray(iv->config->name, MAX_NAME_LENGTH); - - // max channel power / name - for (uint8_t j = 0; j < 4; j++) { - iv->config->yieldCor[j] = request->arg("inv" + String(i) + "YieldCor" + String(j)).toInt(); - iv->config->chMaxPwr[j] = request->arg("inv" + String(i) + "ModPwr" + String(j)).toInt() & 0xffff; - request->arg("inv" + String(i) + "ModName" + String(j)).toCharArray(iv->config->chName[j], MAX_NAME_LENGTH); - } - iv->initialized = true; - } - - if (request->arg("invInterval") != "") - mConfig->nrf.sendInterval = request->arg("invInterval").toInt(); - if (request->arg("invRetry") != "") - mConfig->nrf.maxRetransPerPyld = request->arg("invRetry").toInt(); - mConfig->inst.rstYieldMidNight = (request->arg("invRstMid") == "on"); - mConfig->inst.rstValsCommStop = (request->arg("invRstComStop") == "on"); - mConfig->inst.rstValsNotAvail = (request->arg("invRstNotAvail") == "on"); - - // pinout - uint8_t pin; - for (uint8_t i = 0; i < 5; i++) { - pin = request->arg(String(pinArgNames[i])).toInt(); - switch (i) { - default: - mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); - break; - case 1: - mConfig->nrf.pinCe = ((pin != 0xff) ? pin : DEF_CE_PIN); - break; - case 2: - mConfig->nrf.pinIrq = ((pin != 0xff) ? pin : DEF_IRQ_PIN); - break; - case 3: - mConfig->led.led0 = pin; - break; - case 4: - mConfig->led.led1 = pin; - break; - } - } - - // nrf24 amplifier power - mConfig->nrf.amplifierPower = request->arg("rf24Power").toInt() & 0x03; - - // ntp - if (request->arg("ntpAddr") != "") { - request->arg("ntpAddr").toCharArray(mConfig->ntp.addr, NTP_ADDR_LEN); - mConfig->ntp.port = request->arg("ntpPort").toInt() & 0xffff; - } - - // sun - if (request->arg("sunLat") == "" || (request->arg("sunLon") == "")) { - mConfig->sun.lat = 0.0; - mConfig->sun.lon = 0.0; - mConfig->sun.disNightCom = false; - mConfig->sun.offsetSec = 0; - } else { - mConfig->sun.lat = request->arg("sunLat").toFloat(); - mConfig->sun.lon = request->arg("sunLon").toFloat(); - mConfig->sun.disNightCom = (request->arg("sunDisNightCom") == "on"); - mConfig->sun.offsetSec = request->arg("sunOffs").toInt() * 60; - } - - // mqtt - if (request->arg("mqttAddr") != "") { - String addr = request->arg("mqttAddr"); - addr.trim(); - addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN); - } else - mConfig->mqtt.broker[0] = '\0'; - request->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN); - if (request->arg("mqttPwd") != "{PWD}") - request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN); - request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); - mConfig->mqtt.port = request->arg("mqttPort").toInt(); - mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); - - // serial console - if (request->arg("serIntvl") != "") { - mConfig->serial.interval = request->arg("serIntvl").toInt() & 0xffff; - - mConfig->serial.debug = (request->arg("serDbg") == "on"); - mConfig->serial.showIv = (request->arg("serEn") == "on"); - // Needed to log TX buffers to serial console - mSys->Radio.mSerialDebug = mConfig->serial.debug; - } - - // display - mConfig->plugin.display.pwrSaveAtIvOffline = (request->arg("dispPwr") == "on"); - mConfig->plugin.display.pxShift = (request->arg("dispPxSh") == "on"); - mConfig->plugin.display.rot = request->arg("rotation").toInt(); - mConfig->plugin.display.type = request->arg("dispType").toInt(); - mConfig->plugin.display.contrast = request->arg("dispCont").toInt(); - mConfig->plugin.display.period = request->arg("period").toInt(); - mConfig->plugin.display.disp_data = request->arg("data").toInt(); - mConfig->plugin.display.disp_clk = request->arg("clock").toInt(); - mConfig->plugin.display.disp_cs = request->arg("cs").toInt(); - mConfig->plugin.display.disp_reset = request->arg("reset").toInt(); - mConfig->plugin.display.disp_busy = request->arg("busy").toInt(); - mConfig->plugin.display.disp_dc = request->arg("dc").toInt(); - - mApp->saveSettings(); - - if (request->arg("reboot") == "on") - onReboot(request); - else { + void onReboot(AsyncWebServerRequest *request) { + mApp->setRebootFlag(); AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); response->addHeader(F("Content-Encoding"), "gzip"); request->send(response); } - } - void onLive(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onLive")); - - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) { + void showErase(AsyncWebServerRequest *request) { if (mProtected) { checkRedirect(request); return; } + + DPRINTLN(DBG_VERBOSE, F("showErase")); + mApp->eraseSettings(false); + onReboot(request); } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - response->addHeader(F("content-type"), "text/html; charset=UTF-8"); - - request->send(response); - } - - /*void showWebApi(AsyncWebServerRequest *request) { - // TODO: remove - DPRINTLN(DBG_VERBOSE, F("web::showWebApi")); - DPRINTLN(DBG_DEBUG, request->arg("plain")); - const size_t capacity = 200; // Use arduinojson.org/assistant to compute the capacity. - DynamicJsonDocument response(capacity); - - // Parse JSON object - deserializeJson(response, request->arg("plain")); - // ToDo: error handling for payload - uint8_t iv_id = response["inverter"]; - uint8_t cmd = response["cmd"]; - Inverter<> *iv = mSys->getInverterByPos(iv_id); - if (NULL != iv) { - if (response["tx_request"] == (uint8_t)TX_REQ_INFO) { - // if the AlarmData is requested set the Alarm Index to the requested one - if (cmd == AlarmData || cmd == AlarmUpdate) { - // set the AlarmMesIndex for the request from user input - iv->alarmMesIndex = response["payload"]; - } - DPRINTLN(DBG_INFO, F("Will make tx-request 0x15 with subcmd ") + String(cmd) + F(" and payload ") + String((uint16_t) response["payload"])); - // process payload from web request corresponding to the cmd - iv->enqueCommand(cmd); - } - - - if (response["tx_request"] == (uint8_t)TX_REQ_DEVCONTROL) { - if (response["cmd"] == (uint8_t)ActivePowerContr) { - uint16_t webapiPayload = response["payload"]; - uint16_t webapiPayload2 = response["payload2"]; - if (webapiPayload > 0 && webapiPayload < 10000) { - iv->devControlCmd = ActivePowerContr; - iv->powerLimit[0] = webapiPayload; - if (webapiPayload2 > 0) - iv->powerLimit[1] = webapiPayload2; // dev option, no sanity check - else // if not set, set it to 0x0000 default - iv->powerLimit[1] = AbsolutNonPersistent; // payload will be seted temporary in Watt absolut - if (iv->powerLimit[1] & 0x0001) - DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("% via REST API")); - else - DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W via REST API")); - iv->devControlRequest = true; // queue it in the request loop - } - } - if (response["cmd"] == (uint8_t)TurnOff) { - iv->devControlCmd = TurnOff; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)TurnOn) { - iv->devControlCmd = TurnOn; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)CleanState_LockAndAlarm) { - iv->devControlCmd = CleanState_LockAndAlarm; - iv->devControlRequest = true; // queue it in the request loop - } - if (response["cmd"] == (uint8_t)Restart) { - iv->devControlCmd = Restart; - iv->devControlRequest = true; // queue it in the request loop + void showFactoryRst(AsyncWebServerRequest *request) { + if (mProtected) { + checkRedirect(request); + return; + } + + DPRINTLN(DBG_VERBOSE, F("showFactoryRst")); + String content = ""; + int refresh = 3; + if (request->args() > 0) { + if (request->arg("reset").toInt() == 1) { + refresh = 10; + if (mApp->eraseSettings(true)) + content = F("factory reset: success\n\nrebooting ... "); + else + content = F("factory reset: failed\n\nrebooting ... "); + } else { + content = F("factory reset: aborted"); + refresh = 3; } + } else { + content = F("

Factory Reset

" + "

RESET

CANCEL

"); + refresh = 120; + } + request->send(200, F("text/html; charset=UTF-8"), F("Factory Reset") + content + F("")); + if (refresh == 10) { + delay(1000); + ESP.restart(); } } - request->send(200, "text/json", "{success:true}"); - }*/ - void onDebug(AsyncWebServerRequest *request) { - mApp->getSchedulerNames(); - AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), "ok"); - request->send(response); - } + void onSetup(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSetup")); - void onSerial(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSerial")); + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SETUP)) { + if (mProtected) { + checkRedirect(request); + return; + } + } + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), setup_html, setup_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } + + void showSave(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("showSave")); - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) { if (mProtected) { checkRedirect(request); return; } + + if (request->args() == 0) + return; + + char buf[20] = {0}; + + // general + if (request->arg("ssid") != "") + request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); + if (request->arg("pwd") != "{PWD}") + request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); + if (request->arg("device") != "") + request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN); + mConfig->sys.darkMode = (request->arg("darkMode") == "on"); + + // protection + if (request->arg("adminpwd") != "{PWD}") { + request->arg("adminpwd").toCharArray(mConfig->sys.adminPwd, PWD_LEN); + mProtected = (strlen(mConfig->sys.adminPwd) > 0); + } + mConfig->sys.protectionMask = 0x0000; + for (uint8_t i = 0; i < 6; i++) { + if (request->arg("protMask" + String(i)) == "on") + mConfig->sys.protectionMask |= (1 << i); + } + + // static ip + request->arg("ipAddr").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.ip, buf); + request->arg("ipMask").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.mask, buf); + request->arg("ipDns1").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.dns1, buf); + request->arg("ipDns2").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.dns2, buf); + request->arg("ipGateway").toCharArray(buf, 20); + ah::ip2Arr(mConfig->sys.ip.gateway, buf); + + // inverter + Inverter<> *iv; + for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { + iv = mSys->getInverterByPos(i, false); + // enable communication + iv->config->enabled = (request->arg("inv" + String(i) + "Enable") == "on"); + // address + request->arg("inv" + String(i) + "Addr").toCharArray(buf, 20); + if (strlen(buf) == 0) + memset(buf, 0, 20); + iv->config->serial.u64 = ah::Serial2u64(buf); + switch(iv->config->serial.b[4]) { + case 0x21: iv->type = INV_TYPE_1CH; iv->channels = 1; break; + case 0x41: iv->type = INV_TYPE_2CH; iv->channels = 2; break; + case 0x61: iv->type = INV_TYPE_4CH; iv->channels = 4; break; + default: break; + } + + // name + request->arg("inv" + String(i) + "Name").toCharArray(iv->config->name, MAX_NAME_LENGTH); + + // max channel power / name + for (uint8_t j = 0; j < 4; j++) { + iv->config->yieldCor[j] = request->arg("inv" + String(i) + "YieldCor" + String(j)).toInt(); + iv->config->chMaxPwr[j] = request->arg("inv" + String(i) + "ModPwr" + String(j)).toInt() & 0xffff; + request->arg("inv" + String(i) + "ModName" + String(j)).toCharArray(iv->config->chName[j], MAX_NAME_LENGTH); + } + iv->initialized = true; + } + + if (request->arg("invInterval") != "") + mConfig->nrf.sendInterval = request->arg("invInterval").toInt(); + if (request->arg("invRetry") != "") + mConfig->nrf.maxRetransPerPyld = request->arg("invRetry").toInt(); + mConfig->inst.rstYieldMidNight = (request->arg("invRstMid") == "on"); + mConfig->inst.rstValsCommStop = (request->arg("invRstComStop") == "on"); + mConfig->inst.rstValsNotAvail = (request->arg("invRstNotAvail") == "on"); + + // pinout + uint8_t pin; + for (uint8_t i = 0; i < 5; i++) { + pin = request->arg(String(pinArgNames[i])).toInt(); + switch(i) { + default: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); break; + case 1: mConfig->nrf.pinCe = ((pin != 0xff) ? pin : DEF_CE_PIN); break; + case 2: mConfig->nrf.pinIrq = ((pin != 0xff) ? pin : DEF_IRQ_PIN); break; + case 3: mConfig->led.led0 = pin; break; + case 4: mConfig->led.led1 = pin; break; + } + } + + // nrf24 amplifier power + mConfig->nrf.amplifierPower = request->arg("rf24Power").toInt() & 0x03; + + // ntp + if (request->arg("ntpAddr") != "") { + request->arg("ntpAddr").toCharArray(mConfig->ntp.addr, NTP_ADDR_LEN); + mConfig->ntp.port = request->arg("ntpPort").toInt() & 0xffff; + } + + // sun + if (request->arg("sunLat") == "" || (request->arg("sunLon") == "")) { + mConfig->sun.lat = 0.0; + mConfig->sun.lon = 0.0; + mConfig->sun.disNightCom = false; + mConfig->sun.offsetSec = 0; + } else { + mConfig->sun.lat = request->arg("sunLat").toFloat(); + mConfig->sun.lon = request->arg("sunLon").toFloat(); + mConfig->sun.disNightCom = (request->arg("sunDisNightCom") == "on"); + mConfig->sun.offsetSec = request->arg("sunOffs").toInt() * 60; + } + + // mqtt + if (request->arg("mqttAddr") != "") { + String addr = request->arg("mqttAddr"); + addr.trim(); + addr.toCharArray(mConfig->mqtt.broker, MQTT_ADDR_LEN); + } else + mConfig->mqtt.broker[0] = '\0'; + request->arg("mqttUser").toCharArray(mConfig->mqtt.user, MQTT_USER_LEN); + if (request->arg("mqttPwd") != "{PWD}") + request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN); + request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); + mConfig->mqtt.port = request->arg("mqttPort").toInt(); + mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); + + // serial console + if (request->arg("serIntvl") != "") { + mConfig->serial.interval = request->arg("serIntvl").toInt() & 0xffff; + + mConfig->serial.debug = (request->arg("serDbg") == "on"); + mConfig->serial.showIv = (request->arg("serEn") == "on"); + // Needed to log TX buffers to serial console + mSys->Radio.mSerialDebug = mConfig->serial.debug; + } + + // display + mConfig->plugin.display.pwrSaveAtIvOffline = (request->arg("disp_pwr") == "on"); + mConfig->plugin.display.pxShift = (request->arg("disp_pxshift") == "on"); + mConfig->plugin.display.rot = request->arg("disp_rot").toInt(); + mConfig->plugin.display.type = request->arg("disp_typ").toInt(); + mConfig->plugin.display.contrast = request->arg("disp_cont").toInt(); + mConfig->plugin.display.disp_data = request->arg("disp_data").toInt(); + mConfig->plugin.display.disp_clk = request->arg("disp_clk").toInt(); + mConfig->plugin.display.disp_cs = request->arg("disp_cs").toInt(); + mConfig->plugin.display.disp_reset = request->arg("disp_rst").toInt(); + mConfig->plugin.display.disp_busy = request->arg("disp_bsy").toInt(); + mConfig->plugin.display.disp_dc = request->arg("disp_dc").toInt(); + + mApp->saveSettings(); + + if (request->arg("reboot") == "on") + onReboot(request); + else { + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } + void onLive(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onLive")); - void onSystem(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("onSystem")); + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_LIVE)) { + if (mProtected) { + checkRedirect(request); + return; + } + } - if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) { - if (mProtected) { - checkRedirect(request); - return; + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), visualization_html, visualization_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + response->addHeader(F("content-type"), "text/html; charset=UTF-8"); + + request->send(response); + } + + /*void showWebApi(AsyncWebServerRequest *request) { + // TODO: remove + DPRINTLN(DBG_VERBOSE, F("web::showWebApi")); + DPRINTLN(DBG_DEBUG, request->arg("plain")); + const size_t capacity = 200; // Use arduinojson.org/assistant to compute the capacity. + DynamicJsonDocument response(capacity); + + // Parse JSON object + deserializeJson(response, request->arg("plain")); + // ToDo: error handling for payload + uint8_t iv_id = response["inverter"]; + uint8_t cmd = response["cmd"]; + Inverter<> *iv = mSys->getInverterByPos(iv_id); + if (NULL != iv) { + if (response["tx_request"] == (uint8_t)TX_REQ_INFO) { + // if the AlarmData is requested set the Alarm Index to the requested one + if (cmd == AlarmData || cmd == AlarmUpdate) { + // set the AlarmMesIndex for the request from user input + iv->alarmMesIndex = response["payload"]; + } + DPRINTLN(DBG_INFO, F("Will make tx-request 0x15 with subcmd ") + String(cmd) + F(" and payload ") + String((uint16_t) response["payload"])); + // process payload from web request corresponding to the cmd + iv->enqueCommand(cmd); + } + + + if (response["tx_request"] == (uint8_t)TX_REQ_DEVCONTROL) { + if (response["cmd"] == (uint8_t)ActivePowerContr) { + uint16_t webapiPayload = response["payload"]; + uint16_t webapiPayload2 = response["payload2"]; + if (webapiPayload > 0 && webapiPayload < 10000) { + iv->devControlCmd = ActivePowerContr; + iv->powerLimit[0] = webapiPayload; + if (webapiPayload2 > 0) + iv->powerLimit[1] = webapiPayload2; // dev option, no sanity check + else // if not set, set it to 0x0000 default + iv->powerLimit[1] = AbsolutNonPersistent; // payload will be seted temporary in Watt absolut + if (iv->powerLimit[1] & 0x0001) + DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("% via REST API")); + else + DPRINTLN(DBG_INFO, F("Power limit for inverter ") + String(iv->id) + F(" set to ") + String(iv->powerLimit[0]) + F("W via REST API")); + iv->devControlRequest = true; // queue it in the request loop + } + } + if (response["cmd"] == (uint8_t)TurnOff) { + iv->devControlCmd = TurnOff; + iv->devControlRequest = true; // queue it in the request loop + } + if (response["cmd"] == (uint8_t)TurnOn) { + iv->devControlCmd = TurnOn; + iv->devControlRequest = true; // queue it in the request loop + } + if (response["cmd"] == (uint8_t)CleanState_LockAndAlarm) { + iv->devControlCmd = CleanState_LockAndAlarm; + iv->devControlRequest = true; // queue it in the request loop + } + if (response["cmd"] == (uint8_t)Restart) { + iv->devControlCmd = Restart; + iv->devControlRequest = true; // queue it in the request loop + } + } } + request->send(200, "text/json", "{success:true}"); + }*/ + + void onDebug(AsyncWebServerRequest *request) { + mApp->getSchedulerNames(); + AsyncWebServerResponse *response = request->beginResponse(200, F("text/html; charset=UTF-8"), "ok"); + request->send(response); } - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); - response->addHeader(F("Content-Encoding"), "gzip"); - request->send(response); - } + void onSerial(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSerial")); -#ifdef ENABLE_JSON_EP - void showJson(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("web::showJson")); - String modJson; - Inverter<> *iv; - record_t<> *rec; - char topic[40], val[25]; + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SERIAL)) { + if (mProtected) { + checkRedirect(request); + return; + } + } + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), serial_html, serial_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); + } - modJson = F("{\n"); - for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { - iv = mSys->getInverterByPos(id); - if (NULL == iv) - continue; + void onSystem(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("onSystem")); - rec = iv->getRecordStruct(RealTimeRunData_Debug); - snprintf(topic, 30, "\"%s\": {\n", iv->config->name); - modJson += String(topic); - for (uint8_t i = 0; i < rec->length; i++) { - snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec)); - snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec)); - modJson += String(topic) + ": " + String(val) + F(",\n"); + if (CHECK_MASK(mConfig->sys.protectionMask, PROT_MASK_SYSTEM)) { + if (mProtected) { + checkRedirect(request); + return; + } } - modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n"); + + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, system_html_len); + response->addHeader(F("Content-Encoding"), "gzip"); + request->send(response); } - modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n"); - AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson); - request->send(response); - } + #ifdef ENABLE_JSON_EP + void showJson(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("web::showJson")); + String modJson; + Inverter<> *iv; + record_t<> *rec; + char topic[40], val[25]; + + modJson = F("{\n"); + for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { + iv = mSys->getInverterByPos(id); + if (NULL == iv) + continue; + + rec = iv->getRecordStruct(RealTimeRunData_Debug); + snprintf(topic, 30, "\"%s\": {\n", iv->config->name); + modJson += String(topic); + for (uint8_t i = 0; i < rec->length; i++) { + snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec)); + snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec)); + modJson += String(topic) + ": " + String(val) + F(",\n"); + } + modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n"); + } + modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n"); + + AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson); + request->send(response); + } #endif #ifdef ENABLE_PROMETHEUS_EP - enum { - metricsStateStart, - metricsStateInverter, - metricStateRealtimeData, - metricsStateAlarmData, - metricsStateEnd - } metricsStep; - int metricsInverterId, metricsChannelId; - - void showMetrics(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("web::showMetrics")); - - metricsStep = metricsStateStart; - AsyncWebServerResponse *response = request->beginChunkedResponse(F("text/plain"), - [this](uint8_t *buffer, size_t maxLen, size_t filledLength) -> size_t { - Inverter<> *iv; - record_t<> *rec; - statistics_t *stat; - String promUnit, promType; - String metrics; - char type[60], topic[100], val[25]; - size_t len = 0; - int alarmChannelId; - - switch (metricsStep) { - case metricsStateStart: // System Info & NRF Statistics : fit to one packet - snprintf(type, sizeof(type), "# TYPE ahoy_solar_info gauge\n"); - snprintf(topic, sizeof(topic), "ahoy_solar_info{version=\"%s\",image=\"\",devicename=\"%s\"} 1\n", - mApp->getVersion(), mConfig->sys.deviceName); - metrics = String(type) + String(topic); - - snprintf(topic, sizeof(topic), "# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n", mConfig->sys.deviceName, ESP.getFreeHeap()); - metrics += String(topic); - - // NRF Statistics - stat = mApp->getStatistics(); - metrics += radioStatistic(F("rx_success"), stat->rxSuccess); - metrics += radioStatistic(F("rx_fail"), stat->rxFail); - metrics += radioStatistic(F("rx_fail_answer"), stat->rxFailNoAnser); - metrics += radioStatistic(F("frame_cnt"), stat->frmCnt); - metrics += radioStatistic(F("tx_cnt"), mSys->Radio.mSendCnt); - - len = snprintf((char *)buffer, maxLen, "%s", metrics.c_str()); - // Start Inverter loop - metricsInverterId = 0; - metricsStep = metricsStateInverter; - break; - - case metricsStateInverter: // Inverter loop - if (metricsInverterId < mSys->getNumInverters()) { - iv = mSys->getInverterByPos(metricsInverterId); - if (NULL != iv) { - // Inverter info : fit to one packet - snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_info gauge\n"); - snprintf(topic, sizeof(topic), "ahoy_solar_inverter_info{name=\"%s\",serial=\"%12llx\"} 1\n", - iv->config->name, iv->config->serial.u64); - metrics = String(type) + String(topic); - - snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_enabled gauge\n"); - snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_enabled {inverter=\"%s\"} %d\n", iv->config->name, iv->config->enabled); - metrics += String(type) + String(topic); - - snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_available gauge\n"); - snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_available {inverter=\"%s\"} %d\n", iv->config->name, iv->isAvailable(mApp->getTimestamp())); - metrics += String(type) + String(topic); - - snprintf(type, sizeof(type), "# TYPE ahoy_solar_inverter_is_producing gauge\n"); - snprintf(topic, sizeof(topic), "ahoy_solar_inverter_is_producing {inverter=\"%s\"} %d\n", iv->config->name, iv->isProducing(mApp->getTimestamp())); - metrics += String(type) + String(topic); - - len = snprintf((char *)buffer, maxLen, "%s", metrics.c_str()); - - // Start Realtime Data Channel loop for this inverter - metricsChannelId = 0; - metricsStep = metricStateRealtimeData; - } - } else { - metricsStep = metricsStateEnd; - } - break; - - case metricStateRealtimeData: // Realtime Data Channel loop - iv = mSys->getInverterByPos(metricsInverterId); - rec = iv->getRecordStruct(RealTimeRunData_Debug); - if (metricsChannelId < rec->length) { - uint8_t channel = rec->assign[metricsChannelId].ch; - std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(metricsChannelId, rec)); - snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), promType.c_str()); - if (0 == channel) { - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name); - } else { - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\",channel=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name, iv->config->chName[channel - 1]); - } - snprintf(val, sizeof(val), "%.3f", iv->getValue(metricsChannelId, rec)); - len = snprintf((char *)buffer, maxLen, "%s\n%s %s\n", type, topic, val); - - metricsChannelId++; - } else { - len = snprintf((char *)buffer, maxLen, "#\n"); // At least one char to send otherwise the transmission ends. - - // All realtime data channels processed --> try alarm data - metricsStep = metricsStateAlarmData; - } - break; - - case metricsStateAlarmData: // Alarm Info loop - iv = mSys->getInverterByPos(metricsInverterId); - rec = iv->getRecordStruct(AlarmData); - // simple hack : there is only one channel with alarm data - // TODO: find the right one channel with the alarm id - alarmChannelId = 0; - // printf("AlarmData Length %d\n",rec->length); - if (alarmChannelId < rec->length) { - // uint8_t channel = rec->assign[alarmChannelId].ch; - std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(alarmChannelId, rec)); - snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), promType.c_str()); - snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), iv->config->name); - snprintf(val, sizeof(val), "%.3f", iv->getValue(alarmChannelId, rec)); - len = snprintf((char *)buffer, maxLen, "%s\n%s %s\n", type, topic, val); - } else { - len = snprintf((char *)buffer, maxLen, "#\n"); // At least one char to send otherwise the transmission ends. - } - // alarm channel processed --> try next inverter - metricsInverterId++; - metricsStep = metricsStateInverter; - break; - - case metricsStateEnd: - default: // end of transmission - len = 0; - break; - } - return len; - }); - request->send(response); - } - - String radioStatistic(String statistic, uint32_t value) { - char type[60], topic[80], val[25]; - snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge", statistic.c_str()); - snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s", statistic.c_str()); - snprintf(val, sizeof(val), "%d", value); - return (String(type) + "\n" + String(topic) + " " + String(val) + "\n"); - } - - std::pair convertToPromUnits(String shortUnit) { - if (shortUnit == "A") return {"_ampere", "gauge"}; - if (shortUnit == "V") return {"_volt", "gauge"}; - if (shortUnit == "%") return {"_ratio", "gauge"}; - if (shortUnit == "W") return {"_watt", "gauge"}; - if (shortUnit == "Wh") return {"_wattHours", "counter"}; - if (shortUnit == "kWh") return {"_kilowattHours", "counter"}; - if (shortUnit == "°C") return {"_celsius", "gauge"}; - if (shortUnit == "var") return {"_var", "gauge"}; - if (shortUnit == "Hz") return {"_hertz", "gauge"}; - return {"", "gauge"}; - } + enum { + metricsStateStart, metricsStateInverter, metricStateRealtimeData,metricsStateAlarmData,metricsStateEnd + } metricsStep; + int metricsInverterId,metricsChannelId; + + void showMetrics(AsyncWebServerRequest *request) { + DPRINTLN(DBG_VERBOSE, F("web::showMetrics")); + + metricsStep = metricsStateStart; + AsyncWebServerResponse *response = request->beginChunkedResponse(F("text/plain"), + [this](uint8_t *buffer, size_t maxLen, size_t filledLength) -> size_t + { + Inverter<> *iv; + record_t<> *rec; + statistics_t *stat; + String promUnit, promType; + String metrics; + char type[60], topic[100], val[25]; + size_t len = 0; + int alarmChannelId; + + switch (metricsStep) { + case metricsStateStart: // System Info & NRF Statistics : fit to one packet + snprintf(type,sizeof(type),"# TYPE ahoy_solar_info gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_info{version=\"%s\",image=\"\",devicename=\"%s\"} 1\n", + mApp->getVersion(), mConfig->sys.deviceName); + metrics = String(type) + String(topic); + + snprintf(topic,sizeof(topic),"# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap()); + metrics += String(topic); + + // NRF Statistics + stat = mApp->getStatistics(); + metrics += radioStatistic(F("rx_success"), stat->rxSuccess); + metrics += radioStatistic(F("rx_fail"), stat->rxFail); + metrics += radioStatistic(F("rx_fail_answer"), stat->rxFailNoAnser); + metrics += radioStatistic(F("frame_cnt"), stat->frmCnt); + metrics += radioStatistic(F("tx_cnt"), mSys->Radio.mSendCnt); + + len = snprintf((char *)buffer,maxLen,"%s",metrics.c_str()); + // Start Inverter loop + metricsInverterId = 0; + metricsStep = metricsStateInverter; + break; + + case metricsStateInverter: // Inverter loop + if (metricsInverterId < mSys->getNumInverters()) { + iv = mSys->getInverterByPos(metricsInverterId); + if(NULL != iv) { + // Inverter info : fit to one packet + snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_info gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_inverter_info{name=\"%s\",serial=\"%12llx\"} 1\n", + iv->config->name, iv->config->serial.u64); + metrics = String(type) + String(topic); + + snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_enabled gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_enabled {inverter=\"%s\"} %d\n",iv->config->name,iv->config->enabled); + metrics += String(type) + String(topic); + + snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_available gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_available {inverter=\"%s\"} %d\n",iv->config->name,iv->isAvailable(mApp->getTimestamp())); + metrics += String(type) + String(topic); + + snprintf(type,sizeof(type),"# TYPE ahoy_solar_inverter_is_producing gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_inverter_is_producing {inverter=\"%s\"} %d\n",iv->config->name,iv->isProducing(mApp->getTimestamp())); + metrics += String(type) + String(topic); + + len = snprintf((char *)buffer,maxLen,"%s",metrics.c_str()); + + // Start Realtime Data Channel loop for this inverter + metricsChannelId = 0; + metricsStep = metricStateRealtimeData; + } + } else { + metricsStep = metricsStateEnd; + } + break; + + case metricStateRealtimeData: // Realtime Data Channel loop + iv = mSys->getInverterByPos(metricsInverterId); + rec = iv->getRecordStruct(RealTimeRunData_Debug); + if (metricsChannelId < rec->length) { + uint8_t channel = rec->assign[metricsChannelId].ch; + std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(metricsChannelId, rec)); + snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), promType.c_str()); + if (0 == channel) { + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name); + } else { + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\",channel=\"%s\"}", iv->getFieldName(metricsChannelId, rec), promUnit.c_str(), iv->config->name,iv->config->chName[channel-1]); + } + snprintf(val, sizeof(val), "%.3f", iv->getValue(metricsChannelId, rec)); + len = snprintf((char*)buffer,maxLen,"%s\n%s %s\n",type,topic,val); + + metricsChannelId++; + } else { + len = snprintf((char*)buffer,maxLen,"#\n"); // At least one char to send otherwise the transmission ends. + + // All realtime data channels processed --> try alarm data + metricsStep = metricsStateAlarmData; + } + break; + + case metricsStateAlarmData: // Alarm Info loop + iv = mSys->getInverterByPos(metricsInverterId); + rec = iv->getRecordStruct(AlarmData); + // simple hack : there is only one channel with alarm data + // TODO: find the right one channel with the alarm id + alarmChannelId = 0; + // printf("AlarmData Length %d\n",rec->length); + if (alarmChannelId < rec->length) { + //uint8_t channel = rec->assign[alarmChannelId].ch; + std::tie(promUnit, promType) = convertToPromUnits(iv->getUnit(alarmChannelId, rec)); + snprintf(type, sizeof(type), "# TYPE ahoy_solar_%s%s %s", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), promType.c_str()); + snprintf(topic, sizeof(topic), "ahoy_solar_%s%s{inverter=\"%s\"}", iv->getFieldName(alarmChannelId, rec), promUnit.c_str(), iv->config->name); + snprintf(val, sizeof(val), "%.3f", iv->getValue(alarmChannelId, rec)); + len = snprintf((char*)buffer,maxLen,"%s\n%s %s\n",type,topic,val); + } else { + len = snprintf((char*)buffer,maxLen,"#\n"); // At least one char to send otherwise the transmission ends. + } + // alarm channel processed --> try next inverter + metricsInverterId++; + metricsStep = metricsStateInverter; + break; + + case metricsStateEnd: + default: // end of transmission + len = 0; + break; + } + return len; + }); + request->send(response); + } + + String radioStatistic(String statistic, uint32_t value) { + char type[60], topic[80], val[25]; + snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge",statistic.c_str()); + snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s",statistic.c_str()); + snprintf(val, sizeof(val), "%d", value); + return ( String(type) + "\n" + String(topic) + " " + String(val) + "\n"); + } + + std::pair convertToPromUnits(String shortUnit) { + if(shortUnit == "A") return {"_ampere", "gauge"}; + if(shortUnit == "V") return {"_volt", "gauge"}; + if(shortUnit == "%") return {"_ratio", "gauge"}; + if(shortUnit == "W") return {"_watt", "gauge"}; + if(shortUnit == "Wh") return {"_wattHours", "counter"}; + if(shortUnit == "kWh") return {"_kilowattHours", "counter"}; + if(shortUnit == "°C") return {"_celsius", "gauge"}; + if(shortUnit == "var") return {"_var", "gauge"}; + if(shortUnit == "Hz") return {"_hertz", "gauge"}; + return {"", "gauge"}; + } #endif - AsyncWebServer mWeb; - AsyncEventSource mEvts; - bool mProtected; - uint32_t mLogoutTimeout; - IApp *mApp; - HMSYSTEM *mSys; - - settings_t *mConfig; - - bool mSerialAddTime; - char mSerialBuf[WEB_SERIAL_BUF_SIZE]; - uint16_t mSerialBufFill; - bool mSerialClientConnnected; - - File mUploadFp; - bool mUploadFail; + AsyncWebServer mWeb; + AsyncEventSource mEvts; + bool mProtected; + uint32_t mLogoutTimeout; + IApp *mApp; + HMSYSTEM *mSys; + + settings_t *mConfig; + + bool mSerialAddTime; + char mSerialBuf[WEB_SERIAL_BUF_SIZE]; + uint16_t mSerialBufFill; + bool mSerialClientConnnected; + + File mUploadFp; + bool mUploadFail; }; #endif /*__WEB_H__*/ From c27c5e136b2f10280d208abf98236b5c8816b2f0 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 16:00:51 +0100 Subject: [PATCH 18/26] fix time for ePaper --- src/plugins/Display/Display.h | 2 +- src/plugins/Display/Display_ePaper.cpp | 18 +++++++++++------- src/plugins/Display/Display_ePaper.h | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index c5c9f676..1f229ba4 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -32,7 +32,7 @@ class Display { #if defined(ESP32) mRefreshCycle = 0; mEpaper.config(mCfg->rot); - mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); + mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion); #endif } } diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index f27d7cf4..fea372cd 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -5,6 +5,7 @@ #elif defined(ESP32) #include #endif +#include "../../utils/helper.h" #include "imagedata.h" #if defined(ESP32) @@ -22,7 +23,9 @@ DisplayEPaper::DisplayEPaper() { //*************************************************************************** -void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *version) { +void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) { + mUtcTs = utcTs; + if (type > 9) { Serial.begin(115200); _display = new GxEPD2_BW(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); @@ -105,14 +108,15 @@ void DisplayEPaper::lastUpdatePaged() { _display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding); _display->fillScreen(GxEPD_BLACK); do { - time_t now = time(nullptr); - strftime(_fmtText, sizeof(_fmtText), "%d.%m.%Y %H:%M", localtime(&now)); + if (NULL != mUtcTs) { + snprintf(_fmtText, sizeof(_fmtText), ah::getDateTimeStr(gTimezone.toLocal(*mUtcTs)).c_str()); - _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); - uint16_t x = ((_display->width() - tbw) / 2) - tbx; + _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); + uint16_t x = ((_display->width() - tbw) / 2) - tbx; - _display->setCursor(x, (_display->height() - 3)); - _display->println(_fmtText); + _display->setCursor(x, (_display->height() - 3)); + _display->println(_fmtText); + } } while (_display->nextPage()); } //*************************************************************************** diff --git a/src/plugins/Display/Display_ePaper.h b/src/plugins/Display/Display_ePaper.h index 489ed7c1..b2729f25 100644 --- a/src/plugins/Display/Display_ePaper.h +++ b/src/plugins/Display/Display_ePaper.h @@ -30,7 +30,7 @@ class DisplayEPaper { public: DisplayEPaper(); void fullRefresh(); - void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char* version); + void init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char* version); void config(uint8_t rotation); void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); @@ -46,6 +46,7 @@ class DisplayEPaper { const char* _settedIP; uint8_t mHeadFootPadding; GxEPD2_GFX* _display; + uint32_t *mUtcTs; }; #endif // ESP32 From ce81ca8f531f779f44e03eefeb4b9c1d60eaf254 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 21:24:29 +0100 Subject: [PATCH 19/26] add license Readme to have it better visible to all --- LICENSE | 437 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++ 2 files changed, 449 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..cbe5ad16 --- /dev/null +++ b/LICENSE @@ -0,0 +1,437 @@ +Attribution-NonCommercial-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International +Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-NonCommercial-ShareAlike 4.0 International Public License +("Public License"). To the extent this Public License may be +interpreted as a contract, You are granted the Licensed Rights in +consideration of Your acceptance of these terms and conditions, and the +Licensor grants You such rights in consideration of benefits the +Licensor receives from making the Licensed Material available under +these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-NC-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution, NonCommercial, and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. NonCommercial means not primarily intended for or directed towards + commercial advantage or monetary compensation. For purposes of + this Public License, the exchange of the Licensed Material for + other material subject to Copyright and Similar Rights by digital + file-sharing or similar means is NonCommercial provided there is + no payment of monetary compensation in connection with the + exchange. + + l. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + m. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + n. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part, for NonCommercial purposes only; and + + b. produce, reproduce, and Share Adapted Material for + NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties, including when + the Licensed Material is used other than for NonCommercial + purposes. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-NC-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database for NonCommercial purposes + only; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + including for purposes of Section 3(b); and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/README.md b/README.md index c378424c..ecf6b58f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +Shield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] + +This work is licensed under a +[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. + +[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa] + +[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.de +[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png +[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg + + ![actions/workflows/compile_esp8266.yml](../../actions/workflows/compile_esp8266.yml/badge.svg) ![actions/workflows/compile_development.yml](../../actions/workflows/compile_development.yml/badge.svg) # 🖐 Ahoy! From 9cc0b5b19caba6d3d5f93aa1a1d6c684889a48cb Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 21:31:47 +0100 Subject: [PATCH 20/26] readme update --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ecf6b58f..a5be1ce9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Shield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] +[![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. @@ -9,8 +9,9 @@ This work is licensed under a [cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png [cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg +[dev-action-badge]: ../../actions/workflows/compile_esp8266.yml/badge.svg +[dev-action-link]: actions/workflows/compile_development.yml -![actions/workflows/compile_esp8266.yml](../../actions/workflows/compile_esp8266.yml/badge.svg) ![actions/workflows/compile_development.yml](../../actions/workflows/compile_development.yml/badge.svg) # 🖐 Ahoy! ![Logo](https://github.com/grindylow/ahoy/blob/main/doc/logo1_small.png?raw=true) From 6dd6670b137158f6480b9ec16230135e499f16a9 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 21:42:35 +0100 Subject: [PATCH 21/26] readme update --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5be1ce9..b51439c7 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -[![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] +[![CC BY-NC-SA 3.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] This work is licensed under a -[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. +[Creative Commons Attribution-NonCommercial-ShareAlike 3.0 International License][cc-by-nc-sa]. -[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa] +[![CC BY-NC-SA 3.0][cc-by-nc-sa-image]][cc-by-nc-sa] -[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.de -[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png -[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg +[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/3.0/de/ +[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/3.0/88x31.png +[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%203.0-lightgrey.svg -[dev-action-badge]: ../../actions/workflows/compile_esp8266.yml/badge.svg -[dev-action-link]: actions/workflows/compile_development.yml +[dev-action-badge]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml/badge.svg +[dev-action-link]: .github/workflows/compile_development.yml # 🖐 Ahoy! From 6f344458f9b822182a4cb12e35b731558ebaaa2f Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 21:43:50 +0100 Subject: [PATCH 22/26] fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b51439c7..472e7c92 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This work is licensed under a [cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%203.0-lightgrey.svg [dev-action-badge]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml/badge.svg -[dev-action-link]: .github/workflows/compile_development.yml +[dev-action-link]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml # 🖐 Ahoy! From a6610001a38f3fdeddf98be0e282331fcb3cd56b Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 21:52:25 +0100 Subject: [PATCH 23/26] update readme --- README.md | 12 ++++++------ scripts/gh-action-dev-build-flash.html | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 472e7c92..33ce8964 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -[![CC BY-NC-SA 3.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] +[![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa] [![Ahoy Dev Build][dev-action-badge]][dev-action-link] This work is licensed under a -[Creative Commons Attribution-NonCommercial-ShareAlike 3.0 International License][cc-by-nc-sa]. +[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa]. -[![CC BY-NC-SA 3.0][cc-by-nc-sa-image]][cc-by-nc-sa] +[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa] -[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/3.0/de/ -[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/3.0/88x31.png -[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%203.0-lightgrey.svg +[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/4.0/de/ +[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png +[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg [dev-action-badge]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml/badge.svg [dev-action-link]: https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml diff --git a/scripts/gh-action-dev-build-flash.html b/scripts/gh-action-dev-build-flash.html index b6566b27..ea6146db 100644 --- a/scripts/gh-action-dev-build-flash.html +++ b/scripts/gh-action-dev-build-flash.html @@ -10,6 +10,9 @@ Flash | AhoyDTU
+

Development Build (ESP8266 / ESP32)

From 32e26d5e14398450ce6410e9b548881d88afe136 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 22:07:00 +0100 Subject: [PATCH 24/26] fix link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33ce8964..43b31dfe 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This work is licensed under a [![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa] -[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/4.0/de/ +[cc-by-nc-sa]: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.de [cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png [cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg From 39c02f8668f1f81364dba24aff053bdb0e272ea8 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 22:25:53 +0100 Subject: [PATCH 25/26] merged #742 MI Improvments --- src/CHANGES.md | 3 +++ src/defines.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 78d3c728..266ab5f7 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,9 @@ (starting from release version `0.5.66`) +## 0.5.95 +* merged #742 MI Improvments + ## 0.5.94 * added ePaper (for ESP32 only!), thx @dAjaY85 #735 * improved `/live` margins #732 diff --git a/src/defines.h b/src/defines.h index 92723091..83157143 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 94 +#define VERSION_PATCH 95 //------------------------------------- typedef struct { From f5ef19ccab0f9c8bc68d339a72d4e19f0c248c05 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 7 Mar 2023 22:29:23 +0100 Subject: [PATCH 26/26] merged #736 remove obsolete JSON Endpoint --- src/CHANGES.md | 1 + src/config/config_override_example.h | 3 --- src/web/web.h | 33 ---------------------------- 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 266ab5f7..602af895 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -4,6 +4,7 @@ ## 0.5.95 * merged #742 MI Improvments +* merged #736 remove obsolete JSON Endpoint ## 0.5.94 * added ePaper (for ESP32 only!), thx @dAjaY85 #735 diff --git a/src/config/config_override_example.h b/src/config/config_override_example.h index b56214c8..ed976ceb 100644 --- a/src/config/config_override_example.h +++ b/src/config/config_override_example.h @@ -30,9 +30,6 @@ #undef MIDNIGHTTICKER_OFFSET #define MIDNIGHTTICKER_OFFSET (mCalculatedTimezoneOffset + 1) -// To enable the json endpoint at /json -// #define ENABLE_JSON_EP - // To enable the endpoint for prometheus to scrape data from at /metrics // #define ENABLE_PROMETHEUS_EP diff --git a/src/web/web.h b/src/web/web.h index 9f12400e..15b22eb0 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -72,9 +72,6 @@ class Web { mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); //mWeb.on("/api1", HTTP_POST, std::bind(&Web::showWebApi, this, std::placeholders::_1)); - #ifdef ENABLE_JSON_EP - mWeb.on("/json", HTTP_ANY, std::bind(&Web::showJson, this, std::placeholders::_1)); - #endif #ifdef ENABLE_PROMETHEUS_EP mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1)); #endif @@ -722,36 +719,6 @@ class Web { request->send(response); } - #ifdef ENABLE_JSON_EP - void showJson(AsyncWebServerRequest *request) { - DPRINTLN(DBG_VERBOSE, F("web::showJson")); - String modJson; - Inverter<> *iv; - record_t<> *rec; - char topic[40], val[25]; - - modJson = F("{\n"); - for (uint8_t id = 0; id < mSys->getNumInverters(); id++) { - iv = mSys->getInverterByPos(id); - if (NULL == iv) - continue; - - rec = iv->getRecordStruct(RealTimeRunData_Debug); - snprintf(topic, 30, "\"%s\": {\n", iv->config->name); - modJson += String(topic); - for (uint8_t i = 0; i < rec->length; i++) { - snprintf(topic, 40, "\t\"ch%d/%s\"", rec->assign[i].ch, iv->getFieldName(i, rec)); - snprintf(val, 25, "[%.3f, \"%s\"]", iv->getValue(i, rec), iv->getUnit(i, rec)); - modJson += String(topic) + ": " + String(val) + F(",\n"); - } - modJson += F("\t\"last_msg\": \"") + ah::getDateTimeStr(rec->ts) + F("\"\n\t},\n"); - } - modJson += F("\"json_ts\": \"") + String(ah::getDateTimeStr(mApp->getTimestamp())) + F("\"\n}\n"); - - AsyncWebServerResponse *response = request->beginResponse(200, F("application/json"), modJson); - request->send(response); - } -#endif #ifdef ENABLE_PROMETHEUS_EP enum {