source
Rozdíly
Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.
Obě strany předchozí revizePředchozí verzeNásledující verze | Předchozí verze | ||
source [2013/08/27 21:31] – mypower_cz | source [2016/04/22 21:34] (aktuální) – upraveno mimo DokuWiki 127.0.0.1 | ||
---|---|---|---|
Řádek 3: | Řádek 3: | ||
===== Info ===== | ===== Info ===== | ||
- | Tato verze je pracovní a nemusí být plně funkční. | + | Verze 2.04 |
+ | ===== Kompilace projektu ===== | ||
+ | |||
+ | **Pozor: Pro kompilaci je potřeba použít [[https:// | ||
+ | |||
+ | V nových verzích se můžete setkat s chybou | ||
+ | |||
+ | microlog2: | ||
+ | |||
+ | nebo | ||
+ | |||
+ | microlog2: | ||
===== Notes ===== | ===== Notes ===== | ||
- | * přidána | + | * přidána |
- | * přidána definice modSerialBaudRate - nastavení rychlosti USB Serial. Výchozí hodnota: 115200 | + | * čítač sekund byl změněn na uint32_t |
+ | * mapa eprom byla přesunuta z kódu na [[mod:eprom|wiki]] | ||
+ | |||
+ | * [[http:// | ||
===== Download ===== | ===== Download ===== | ||
Řádek 20: | Řádek 34: | ||
// ---[ INFO ]---------------------------------------- | // ---[ INFO ]---------------------------------------- | ||
- | // MyPower.CZ Microlog | + | // Program: MyPower.CZ |
- | // Version 2.0 | + | // License: free for non-commercial use |
- | // Date: 05/2013 | + | // Details: info@mypower.cz |
- | + | ||
- | // created by MyPower.CZ | + | |
- | // Licence: free for non-commercial use | + | |
// ---[ VERSION ]------------------------------------- | // ---[ VERSION ]------------------------------------- | ||
- | #define MPWMicroLogVersion | + | #define MPWMicroLogVersion |
// ---[ INCLUDE ]------------------------------------- | // ---[ INCLUDE ]------------------------------------- | ||
Řádek 50: | Řádek 61: | ||
byte NETmask[4] | byte NETmask[4] | ||
byte NETdns[4] | byte NETdns[4] | ||
+ | |||
+ | // ---[ DPIN 22..49 map ]-------------------------- | ||
+ | // 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 | ||
+ | // [....... LED .....][.not used.][........... RELE .............] | ||
+ | byte DPINmap[16] | ||
+ | uint16_t DPINstatus | ||
+ | // < | ||
+ | uint16_t DPINlogicmask = (B00000000 << 8) | B00000011; | ||
// ---[ MODS ]---------------------------------------- | // ---[ MODS ]---------------------------------------- | ||
Řádek 60: | Řádek 79: | ||
// mod StausLed | // mod StausLed | ||
#define modStatusLed | #define modStatusLed | ||
- | #define modStatusLedPin | + | #define modStatusLedPin |
// mod SerialLog | // mod SerialLog | ||
Řádek 68: | Řádek 87: | ||
// mod WebServer | // mod WebServer | ||
- | #define modWebServer | + | #define modWebServer |
- | #define modWebServerPort 80 // default: 80 | + | #define modWebServerPort |
// mod Display | // mod Display | ||
- | #define modDisplay | + | #define modDisplay |
- | #define modDisplayType | + | #define modDisplayType |
+ | |||
+ | // mod DisplayEmulation | ||
+ | #define modDisplayEmulation | ||
+ | // 0=display pripojen - zobrazeni na fyzickem displayi i na www rozhrani | ||
// --------------------------------------------------- | // --------------------------------------------------- | ||
Řádek 79: | Řádek 102: | ||
byte lxLed=0; | byte lxLed=0; | ||
byte lxTime=0; | byte lxTime=0; | ||
- | long lxSeconds=0; | + | uint32_t |
- | long lxSendIndex=0; | + | uint32_t |
byte lxHttpOk=0; | byte lxHttpOk=0; | ||
byte lxHttpErrors=0; | byte lxHttpErrors=0; | ||
Řádek 113: | Řádek 136: | ||
#define xpinOPTsampleG2 | #define xpinOPTsampleG2 | ||
#define xpinOPTsampleG3 | #define xpinOPTsampleG3 | ||
- | |||
- | // ---------------------------------------------------- | ||
- | |||
- | // EEPROM | ||
- | // 0 - 40 PIN0 CONF | ||
- | // 41 - 81 PIN1 CONF | ||
- | // 82 - 122 PIN2 CONF | ||
- | // 123 - 163 PIN3 CONF | ||
- | // 164 - 204 PIN4 CONF | ||
- | // 205 - 245 PIN5 CONF | ||
- | // 246 - 286 PIN6 CONF | ||
- | // 287 - 327 PIN7 CONF | ||
- | // 328 - 368 PIN8 CONF | ||
- | // 369 - 409 PIN9 CONF | ||
- | // 410 - 450 PIN10 CONF | ||
- | // 451 - 491 PIN11 CONF | ||
- | // 492 - 532 PIN12 CONF | ||
- | // 533 - 573 PIN13 CONF | ||
- | // 574 - 614 PIN14 CONF | ||
- | // 615 - 656 PIN15 CONF | ||
- | // 657 - 683 DeviceConf | ||
- | // 684 - 2047 Display program | ||
- | // 2048 ... FREE | ||
struct tPinConf { | struct tPinConf { | ||
Řádek 143: | Řádek 143: | ||
}; | }; | ||
- | #define xComStatusNop | + | struct tDPinConf { |
- | #define xComStatusASchanged | + | char xname[20]; |
- | #define xComStatusDSchanged | + | }; |
+ | |||
+ | #define xComStatusNop | ||
+ | #define xComStatusASchanged | ||
+ | #define xComStatusDSchanged | ||
+ | #define xComStatusIsLastDayInMonth | ||
+ | #define xComStatusIsDST | ||
+ | |||
+ | #define xComStatusXXDaysMonthMask | ||
+ | #define xComStatus28DaysMonth | ||
+ | #define xComStatus29DaysMonth | ||
+ | #define xComStatus30DaysMonth | ||
+ | #define xComStatus31DaysMonth | ||
+ | |||
+ | struct tMpwAccess { | ||
+ | byte xComStatus; | ||
+ | uint16_t mpwremoteDateYear; | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | signed long mpwremoteTimeS; | ||
+ | uint32_t mpwremoteCheckedAtS; | ||
+ | uint32_t mpwlogintimeS; | ||
+ | uint32_t mpwDeviceId; | ||
+ | uint32_t mpwAccessId; | ||
+ | } xMpwAccess; | ||
- | struct | + | struct |
+ | int xyear, xmonth, xday, xhour, xminute, xsecond; | ||
+ | | ||
#define xdcOptBuiltIn | #define xdcOptBuiltIn | ||
Řádek 184: | Řádek 212: | ||
char * _lcdweblbuf1=NULL; | char * _lcdweblbuf1=NULL; | ||
tDispStats * _lcdwebdispstats=NULL; | tDispStats * _lcdwebdispstats=NULL; | ||
+ | |||
+ | #if (modDisplayEmulation == 0) | ||
#include < | #include < | ||
LiquidCrystal lcd(8, 9, 14, 5, 6, 7); | LiquidCrystal lcd(8, 9, 14, 5, 6, 7); | ||
+ | void lcdClear() { lcd.clear(); | ||
+ | void lcdInit() { lcd.begin(16, | ||
+ | #else | ||
+ | void lcdClear() { } | ||
+ | void lcdInit() { lcdClear(); } | ||
+ | #endif | ||
+ | |||
void lcdPrintRight(char * str) { int x=16-strlen(str); | void lcdPrintRight(char * str) { int x=16-strlen(str); | ||
void lcdPrintCenter(char * str) { int x=8-(strlen(str)/ | void lcdPrintCenter(char * str) { int x=8-(strlen(str)/ | ||
Řádek 191: | Řádek 228: | ||
void lcdPrintAt(char * str,int x) { | void lcdPrintAt(char * str,int x) { | ||
int ix=strlen(str); | int ix=strlen(str); | ||
- | void lcdClear() { lcd.clear(); } | + | // int ix=strlen(str);for (int i=0; |
void lcdClearLine() { int i; for (i=0; | void lcdClearLine() { int i; for (i=0; | ||
void lcdPrintLine(int y) { | void lcdPrintLine(int y) { | ||
if ((_lcdweblbuf0!=NULL) && (_lcdweblbuf1!=NULL)) | if ((_lcdweblbuf0!=NULL) && (_lcdweblbuf1!=NULL)) | ||
{ char * p=_lcdweblbuf0; | { char * p=_lcdweblbuf0; | ||
- | else { lcd.setCursor(0, | + | else { |
- | void lcdInit() { lcd.begin(16, | + | #if (modDisplayEmulation == 0) |
+ | | ||
+ | #endif | ||
+ | } } | ||
#endif | #endif | ||
Řádek 210: | Řádek 251: | ||
pinMode(modStatusLedPin, | pinMode(modStatusLedPin, | ||
#endif | #endif | ||
+ | |||
#if ((modSerialLog == 1) || (modSerialForce == 1)) | #if ((modSerialLog == 1) || (modSerialForce == 1)) | ||
Serial.begin(modSerialBaudRate); | Serial.begin(modSerialBaudRate); | ||
#endif | #endif | ||
+ | |||
#if ((modSerialLog == 1) || (modDisplay == 1)) | #if ((modSerialLog == 1) || (modDisplay == 1)) | ||
Řádek 220: | Řádek 263: | ||
#if (modSerialLog == 1) | #if (modSerialLog == 1) | ||
- | XLog(sn1); | + | XLog(sn1); |
- | XLog(MPWMicroLogVersion); | + | |
#if (modMyPowerLog == 1) | #if (modMyPowerLog == 1) | ||
- | xMpwAccess.mpwtimeAtMS=0; | + | xMpwAccess.mpwremoteDateYear=0; |
+ | xMpwAccess.mpwremoteDateMonth=0; | ||
+ | xMpwAccess.mpwremoteDateDay=0; | ||
+ | xMpwAccess.mpwremoteDateWeek=0; | ||
+ | xMpwAccess.mpwremoteDateDayOfWeek=0; | ||
+ | xMpwAccess.mpwremoteTimeS=-1; | ||
+ | xMpwAccess.mpwremoteCheckedAtS=0; | ||
+ | xMpwAccess.mpwlogintimeS=0; | ||
+ | xMpwAccess.mpwDeviceId=0; | ||
+ | xMpwAccess.mpwAccessId=0; | ||
xMpwAccess.xComStatus=xComStatusNop; | xMpwAccess.xComStatus=xComStatusNop; | ||
- | XLog(" | + | char cx[50]=" |
#endif | #endif | ||
+ | |||
#if (modDisplay == 1) | #if (modDisplay == 1) | ||
- | XLog(" | + | char ccx[50]=""; |
+ | #if (modDisplayEmulation == 1 ) | ||
+ | sprintf(ccx," | ||
+ | #else | ||
+ | sprintf(ccx," | ||
#endif | #endif | ||
+ | XLog(ccx); | ||
+ | #endif | ||
+ | |||
#endif | #endif | ||
Řádek 240: | Řádek 300: | ||
#endif | #endif | ||
- | pinMode(10, OUTPUT); | + | DPINResetHW(); |
+ | pinMode(53, OUTPUT); | ||
int xret=0; | int xret=0; | ||
Řádek 290: | Řádek 351: | ||
server.begin(); | server.begin(); | ||
#if modSerialLog == 1 | #if modSerialLog == 1 | ||
- | char c[30]=""; | + | char c[30]=""; |
#endif | #endif | ||
#endif | #endif | ||
Řádek 380: | Řádek 441: | ||
if (lxHttpOk==2) xsi=xsr; | if (lxHttpOk==2) xsi=xsr; | ||
if (xsi<30) xsi=30; | if (xsi<30) xsi=30; | ||
- | long qlxSendIndex=lxSeconds; | + | uint32_t |
if ((lxSendIndex+xsi< | if ((lxSendIndex+xsi< | ||
{ | { | ||
Řádek 399: | Řádek 460: | ||
client.write((byte*)xtext, | client.write((byte*)xtext, | ||
- | //struct tMpwAccess { unsigned long mpwtime; unsigned long mpwtimeAtMS; | + | |
- | + | ||
- | | + | |
if (islogin) | if (islogin) | ||
Řádek 413: | Řádek 472: | ||
} | } | ||
- | sprintf(xtext," | + | sprintf(xtext," |
client.write((byte*)xtext, | client.write((byte*)xtext, | ||
sprintf(xtext," | sprintf(xtext," | ||
Řádek 433: | Řádek 492: | ||
if (isvalid) | if (isvalid) | ||
{ | { | ||
- | sprintf(xtext," | + | |
- | | + | char smax10k[30]=""; |
+ | // | ||
+ | sprintf(xtext," | ||
client.write((byte*)xtext, | client.write((byte*)xtext, | ||
xtext[0]=0; | xtext[0]=0; | ||
Řádek 514: | Řádek 575: | ||
void ParseHTTPResult(char * xtext) { | void ParseHTTPResult(char * xtext) { | ||
- | xMpwAccess.mpwtimeAtMS=millis(); | ||
- | if (strcmp(xtext," | ||
#if modSerialLog == 1 | #if modSerialLog == 1 | ||
XLog2(xtext,"# | XLog2(xtext,"# | ||
#endif | #endif | ||
+ | if (strcmp(xtext," | ||
+ | if (strncmp(xtext," | ||
+ | } | ||
+ | |||
+ | void ParseQID(char * xtext) { | ||
+ | if (xMpwAccess.mpwlogintimeS==0) xMpwAccess.mpwlogintimeS=lxSeconds; | ||
+ | char * p=strchr(xtext,' | ||
+ | if (p!=NULL) | ||
+ | { | ||
+ | p[0]=0; | ||
+ | xMpwAccess.mpwDeviceId=atol(xtext); | ||
+ | p++; | ||
+ | char * px=strchr(p,' | ||
+ | if (px!=NULL) | ||
+ | { | ||
+ | px[0]=0; | ||
+ | px++; | ||
+ | xMpwAccess.mpwAccessId=atol(p); | ||
+ | if (strlen(px)==20) | ||
+ | { | ||
+ | char c[30]=""; | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | strncpy(c, | ||
+ | |||
+ | if (xisdst==1) | ||
+ | xMpwAccess.xComStatus|=xComStatusIsDST; | ||
+ | else | ||
+ | xMpwAccess.xComStatus& | ||
+ | |||
+ | if (xdaysinmonth==xMpwAccess.mpwremoteDateDay) | ||
+ | xMpwAccess.xComStatus|=xComStatusIsLastDayInMonth; | ||
+ | else | ||
+ | xMpwAccess.xComStatus& | ||
+ | | ||
+ | xMpwAccess.xComStatus& | ||
+ | if (xdaysinmonth==28) xMpwAccess.xComStatus|=xComStatus28DaysMonth; | ||
+ | if (xdaysinmonth==29) xMpwAccess.xComStatus|=xComStatus29DaysMonth; | ||
+ | if (xdaysinmonth==30) xMpwAccess.xComStatus|=xComStatus30DaysMonth; | ||
+ | if (xdaysinmonth==31) xMpwAccess.xComStatus|=xComStatus31DaysMonth; | ||
+ | | ||
+ | xMpwAccess.mpwremoteTimeS=(xhour*3600)+(xminute*60)+(xsecond); | ||
+ | xMpwAccess.mpwremoteCheckedAtS=lxSeconds; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | |||
+ | / | ||
+ | char xstr[50]=""; | ||
+ | tMpwDateTime xMpwDateTime; | ||
+ | GetCurrentDateTime(& | ||
+ | FormatDateTimeStr(xstr, | ||
+ | Serial.println(xstr); | ||
+ | */ | ||
} | } | ||
#endif | #endif | ||
+ | |||
+ | |||
+ | |||
+ | void FormatDateTimeStr(char * xstr, char * xfmt, struct tMpwDateTime * xMpwDateTime, | ||
+ | { | ||
+ | xstr[0]=0; | ||
+ | while (strlen(xfmt)> | ||
+ | { | ||
+ | char ch=xfmt[0]; | ||
+ | char cout[20]=""; | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | if (ch==' | ||
+ | { cout[0]=ch; | ||
+ | | ||
+ | xfmt++; | ||
+ | if (strlen(xstr)+strlen(cout)< | ||
+ | } | ||
+ | } | ||
+ | |||
+ | int GetCurrentDateTime_DaysInMonth() | ||
+ | { | ||
+ | int xret=28; | ||
+ | int xst=xMpwAccess.xComStatus& | ||
+ | if (xst==xComStatus28DaysMonth) xret=28; else | ||
+ | if (xst==xComStatus29DaysMonth) xret=29; else | ||
+ | if (xst==xComStatus30DaysMonth) xret=30; else | ||
+ | if (xst==xComStatus31DaysMonth) xret=31; | ||
+ | return xret; | ||
+ | } | ||
+ | |||
+ | void GetCurrentDateTime(struct tMpwDateTime * xMpwDateTime) | ||
+ | { | ||
+ | if (xMpwAccess.mpwremoteCheckedAtS> | ||
+ | { | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | uint32_t xtime=lxSeconds-xMpwAccess.mpwremoteCheckedAtS+xMpwAccess.mpwremoteTimeS; | ||
+ | if (xtime> | ||
+ | { | ||
+ | int xdaysover=xtime/ | ||
+ | int xtimeover=xtime%86400UL; | ||
+ | |||
+ | if (xdaysover> | ||
+ | { | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | int xdaysinmonth=GetCurrentDateTime_DaysInMonth(); | ||
+ | for (int i=0; | ||
+ | { | ||
+ | if (xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | else | ||
+ | { | ||
+ | xMpwDateTime-> | ||
+ | if (xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | else | ||
+ | { | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | xtime=xtimeover; | ||
+ | } | ||
+ | xMpwDateTime-> | ||
+ | int xmod=(xtime%3600); | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | uint32_t xtime=lxSeconds; | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | signed long xmod=((xtime%86400L)%3600); | ||
+ | xMpwDateTime-> | ||
+ | xMpwDateTime-> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | |||
void FlashError(byte xcount) | void FlashError(byte xcount) | ||
Řádek 604: | Řádek 828: | ||
#define xCFGv 0x20 | #define xCFGv 0x20 | ||
#define xCFGs 0x30 | #define xCFGs 0x30 | ||
+ | |||
+ | // w = write | ||
+ | // [w]as = analog settings | ||
+ | // [w]ds = digital settings | ||
+ | // [w]dp = display | ||
+ | // [w]ep = eprom | ||
+ | // hw = hwinfo | ||
+ | // dd = display dump | ||
+ | // db = display button press emulation | ||
#define xACTnone | #define xACTnone | ||
Řádek 612: | Řádek 845: | ||
#define xACTdb | #define xACTdb | ||
#define xACTsp | #define xACTsp | ||
+ | #define xACTds | ||
+ | #define xACTep | ||
+ | #define xACTwds | ||
+ | #define xACTwep | ||
#define xACTwas | #define xACTwas | ||
#define xACTwdp | #define xACTwdp | ||
- | #define xKEYnone | + | #define xKEYnone |
- | #define xKEYcmd | + | #define xKEYcmd |
- | #define xKEYpin | + | #define xKEYpin |
- | #define xKEYDispButt | + | #define xKEYDispButt |
+ | #define xKEYDpin | ||
+ | |||
+ | #define xPinOptNone | ||
+ | #define xPinOptEnabled | ||
+ | #define xPinOptName | ||
+ | #define xPinOptMin | ||
+ | #define xPinOptMax | ||
+ | #define xPinOptUnit | ||
+ | #define xPinOptType | ||
+ | #define xPinOptGroup | ||
+ | #define xPinCmdWrite | ||
+ | |||
+ | #define xDPinOptNone | ||
+ | #define xDPinOptName | ||
+ | |||
+ | #define xDPinOptSetStatus 0xA0 | ||
- | # | + | # |
- | #define xPinOptEnabled | + | |
- | #define xPinOptName | + | |
- | #define xPinOptMin | + | |
- | #define xPinOptMax | + | |
- | #define xPinOptUnit | + | |
- | #define xPinOptType | + | |
- | #define xPinOptGroup | + | |
- | #define xPinCmdWrite | + | |
- | void WebServer_pf(char * xstr,signed long * xsl,int * xsl10000) { | + | void WebServer_pf(char * xstr,signed long * xsl,int * xsl10k) { |
- | int im; *xsl=0;*xsl10000=0; char * p=xstr; char * p10k=p; | + | int im; *xsl=0;*xsl10k=0; char * p=xstr; char * p10k=p; |
for (int i=0; | for (int i=0; | ||
boolean hm=(p[0]==' | boolean hm=(p[0]==' | ||
for (int i=0; | for (int i=0; | ||
im=strlen(p10k); | im=strlen(p10k); | ||
- | for (int i=0; | + | for (int i=0; |
- | *xsl10000+=(p10k[i]-' | + | *xsl10k+=(p10k[i]-' |
if (hm) *xsl=0-*xsl; | if (hm) *xsl=0-*xsl; | ||
+ | if (hm) *xsl10k=0-*xsl10k; | ||
} | } | ||
Řádek 646: | Řádek 892: | ||
xMpwAccess.xComStatus|=xComStatusASchanged; | xMpwAccess.xComStatus|=xComStatusASchanged; | ||
byte*xconf=(byte*)pconf; | byte*xconf=(byte*)pconf; | ||
- | // int ax=xpin*sizeof(tPinConf); | ||
int ax=GetEpromPinAddr(xpin); | int ax=GetEpromPinAddr(xpin); | ||
- | // Serial.print(" | ||
if (ax>=0) | if (ax>=0) | ||
for (int ii=0; | for (int ii=0; | ||
Řádek 656: | Řádek 900: | ||
} | } | ||
+ | void WebServer_wdp(byte xdpin, struct tDPinConf * pconf) { | ||
+ | if (xdpin< | ||
+ | xMpwAccess.xComStatus|=xComStatusDSchanged; | ||
+ | DPIN_epWriteConfName(xdpin, | ||
+ | } | ||
+ | } | ||
byte WebServer_pb(char * xstr) { | byte WebServer_pb(char * xstr) { | ||
Řádek 703: | Řádek 953: | ||
} | } | ||
#endif | #endif | ||
+ | } | ||
+ | |||
+ | unsigned long WebServer_ph(char * lbuf) | ||
+ | { | ||
+ | unsigned long d=0; | ||
+ | for (byte ii=0; | ||
+ | char c=lbuf[ii]; | ||
+ | if (c=' | ||
+ | d=(d<< | ||
+ | } | ||
+ | return d; | ||
} | } | ||
Řádek 775: | Řádek 1036: | ||
else | else | ||
#endif | #endif | ||
+ | if (*qsaction==xACTwds) | ||
+ | { | ||
+ | char * p=xstr; | ||
+ | if (strcmp(xstr," | ||
+ | { | ||
+ | byte xpinopt=xDPinSetStatus; | ||
+ | *xparam& | ||
+ | *xparam|=xpinopt; | ||
+ | } | ||
+ | else | ||
+ | if (p[0]==' | ||
+ | { | ||
+ | p++; | ||
+ | int xpinindex=atoi(p)& | ||
+ | byte xpinopt=xDPinOptSetStatus; | ||
+ | *xparam& | ||
+ | *xparam|=xpinopt|(xpinindex<< | ||
+ | } | ||
+ | else | ||
+ | if (p[0]==' | ||
+ | { | ||
+ | p++; | ||
+ | char * px=p; | ||
+ | for (int ii=1; | ||
+ | if (p[0]==' | ||
+ | int xpinindex=atoi(px); | ||
+ | byte xpinopt=xDPinOptNone; | ||
+ | if (strcmp(p," | ||
+ | *xparam& | ||
+ | *xparam|=xpinopt|(xpinindex<< | ||
+ | } | ||
+ | *wkey=xKEYDpin; | ||
+ | } | ||
+ | else | ||
if (*qsaction==xACTwas) | if (*qsaction==xACTwas) | ||
{ | { | ||
Řádek 816: | Řádek 1111: | ||
#endif | #endif | ||
+ | // --------------------------------------- | ||
+ | |||
+ | if (*wkey==xKEYDpin) | ||
+ | { | ||
+ | byte xpk=((*xparam)& | ||
+ | tDPinConf * pconf; | ||
+ | pconf=(tDPinConf*)datastruct; | ||
+ | | ||
+ | if (xpk==xDPinOptName) | ||
+ | { | ||
+ | int xpinindex=(((*xparam)& | ||
+ | strncpy(pconf-> | ||
+ | DPIN_epWriteConfName(xpinindex, | ||
+ | for (int ii=0; | ||
+ | } | ||
+ | else | ||
+ | if (xpk==xDPinSetStatus) { | ||
+ | DPINstatus=(uint16_t)WebServer_ph(xstr); | ||
+ | DPINUpdateHW(); | ||
+ | } | ||
+ | else | ||
+ | if (xpk==xDPinOptSetStatus) { | ||
+ | int xpinindex=(((*xparam)& | ||
+ | uint16_t xpinstatus=(atoi(xstr))& | ||
+ | DPINstatus& | ||
+ | DPINstatus|=(xpinstatus<< | ||
+ | DPINUpdateHW(); | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | else | ||
+ | // --------------------------------------- | ||
if (*wkey==xKEYpin) | if (*wkey==xKEYpin) | ||
{ | { | ||
Řádek 828: | Řádek 1156: | ||
else | else | ||
if (xpk==xPinOptName) | if (xpk==xPinOptName) | ||
+ | { | ||
strncpy(pconf-> | strncpy(pconf-> | ||
+ | pconf-> | ||
+ | } | ||
else | else | ||
if (xpk==xPinOptMin) { | if (xpk==xPinOptMin) { | ||
Řádek 870: | Řádek 1201: | ||
} | } | ||
| | ||
- | } | + | } |
+ | // -------------------------------------------- | ||
else | else | ||
if (*wkey==xKEYcmd) | if (*wkey==xKEYcmd) | ||
{ | { | ||
+ | if (strcmp(xstr," | ||
+ | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
+ | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
- | if (strcmp(xstr," | + | if (strcmp(xstr," |
+ | if (strcmp(xstr," | ||
if (strcmp(xstr," | if (strcmp(xstr," | ||
} | } | ||
Řádek 894: | Řádek 1230: | ||
unsigned long xparam=0; | unsigned long xparam=0; | ||
int cx=sizeof(tPinConf); | int cx=sizeof(tPinConf); | ||
+ | int cxq=sizeof(tDPinConf); | ||
byte xDataStruct[cx]; | byte xDataStruct[cx]; | ||
for (int ii=0; | for (int ii=0; | ||
Řádek 910: | Řádek 1247: | ||
byte qsaction=(xmode>> | byte qsaction=(xmode>> | ||
if (c == ' | if (c == ' | ||
- | client.write(" | + | client.write(" |
+ | if (qsaction==xACTep) | ||
+ | { | ||
+ | client.write(" | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | client.write(" | ||
+ | client.write(" | ||
+ | } | ||
+ | else | ||
+ | client.write(" | ||
if (qmode==xWEBpins) { | if (qmode==xWEBpins) { | ||
for (int ain = 0; ain < NUM_ANALOG_INPUTS; | for (int ain = 0; ain < NUM_ANALOG_INPUTS; | ||
Řádek 927: | Řádek 1274: | ||
(int)lxHttpErrors, | (int)lxHttpErrors, | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
- | sprintf(xln," | + | sprintf(xln," |
client.write((byte*)xln, | client.write((byte*)xln, | ||
sprintf(xln, | sprintf(xln, | ||
(int)E2END, | (int)E2END, | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
- | sprintf(xln," | + | sprintf(xln," |
NETmac[0], | NETmac[0], | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
Řádek 947: | Řádek 1294: | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
} | } | ||
- | sprintf(xln," | + | sprintf(xln," |
+ | client.write((byte*)xln, | ||
+ | client.write(" | ||
+ | for (int i=0; | ||
+ | { | ||
+ | int qb=DPINmap[i]; | ||
+ | sprintf(xln," | ||
+ | if (i<16) strcat(xln,"," | ||
+ | client.write((byte*)xln, | ||
+ | } | ||
+ | sprintf(xln,"/ | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
+ | |||
+ | char xstr[30]=""; | ||
+ | tMpwDateTime xMpwDateTime; | ||
+ | GetCurrentDateTime(& | ||
+ | FormatDateTimeStr(xstr, | ||
+ | |||
+ | |||
+ | sprintf(xln," | ||
+ | (int)xMpwAccess.mpwremoteDateMonth, | ||
+ | (int)xMpwAccess.mpwremoteDateDay, | ||
+ | (signed long)xMpwAccess.mpwremoteTimeS, | ||
+ | xMpwAccess.mpwremoteCheckedAtS, | ||
+ | xMpwAccess.mpwlogintimeS, | ||
+ | xMpwAccess.mpwDeviceId, | ||
+ | xMpwAccess.mpwAccessId, | ||
+ | (int)xMpwAccess.xComStatus, | ||
+ | (int)xMpwAccess.mpwremoteDateWeek, | ||
+ | (int)xMpwAccess.mpwremoteDateDayOfWeek, | ||
+ | (unsigned long)(lxSeconds-xMpwAccess.mpwremoteCheckedAtS)); | ||
+ | client.write((byte*)xln, | ||
+ | | ||
} | } | ||
else | else | ||
+ | // ---------------------------------- | ||
+ | if ((qsaction==xACTds) || (qsaction==xACTwds)) | ||
+ | { | ||
+ | if (qsaction==xACTwds) client.write(" | ||
+ | for (int xp=0; | ||
+ | { | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | char cname[30]=""; | ||
+ | DPIN_epReadConfName(xp, | ||
+ | xln[0]=0; | ||
+ | char xf[]=" | ||
+ | char xh[3]; | ||
+ | for (int i=0; | ||
+ | int xi=(uint8_t)cname[i]; | ||
+ | sprintf(xh, | ||
+ | strcat(xln, | ||
+ | } | ||
+ | strcat(xln," | ||
+ | client.write((byte*)xln, | ||
+ | } | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | } | ||
+ | else | ||
+ | // ---------------------------------- | ||
if ((qsaction==xACTas) || (qsaction==xACTwas)) | if ((qsaction==xACTas) || (qsaction==xACTwas)) | ||
{ | { | ||
- | if (qsaction==xACTwas) | + | if (qsaction==xACTwas) client.write(" |
- | | + | |
- | | + | |
- | | + | |
for (int xp=0; | for (int xp=0; | ||
{ | { | ||
Řádek 967: | Řádek 1368: | ||
else | else | ||
{ | { | ||
- | sprintf(xln," | + | |
- | pconf.xmin10000, | + | char smax10k[30]=""; |
+ | | ||
client.write((byte*)xln, | client.write((byte*)xln, | ||
xln[0]=0; | xln[0]=0; | ||
Řádek 1113: | Řádek 1515: | ||
else | else | ||
# | # | ||
+ | if (qsaction==xACTep) | ||
+ | { | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | unsigned long xsum=0; | ||
+ | char s[20]=""; | ||
+ | for (int i=0; | ||
+ | { | ||
+ | if ((i& | ||
+ | { | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | } | ||
+ | int v=EEPROM.read(i); | ||
+ | sprintf(xln," | ||
+ | int xi=i& | ||
+ | s[xi]=((v> | ||
+ | s[xi+1]=0; | ||
+ | client.write((byte*)xln, | ||
+ | xsum=(((xsum>> | ||
+ | if ((i& | ||
+ | { | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | s[0]=0; | ||
+ | } | ||
+ | else client.write(" | ||
+ | } | ||
+ | if (s[0]!=0) | ||
+ | { | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | s[0]=0; | ||
+ | } | ||
+ | sprintf(xln," | ||
+ | client.write((byte*)xln, | ||
+ | } | ||
+ | else | ||
if (qmode==xWEBcfg) | if (qmode==xWEBcfg) | ||
{ | { | ||
Řádek 1126: | Řádek 1566: | ||
client.write("< | client.write("< | ||
client.write("< | client.write("< | ||
- | client.write("< | + | client.write("< |
+ | client.write("< | ||
if (qmode==xWEBhome) { | if (qmode==xWEBhome) { | ||
| | ||
Řádek 1156: | Řádek 1597: | ||
client.write("< | client.write("< | ||
client.write(modMyPowerHost); | client.write(modMyPowerHost); | ||
- | client.write("/ | + | client.write("/ |
+ | client.write(MPWMicroLogVersion); | ||
+ | client.write(" | ||
client.write("< | client.write("< | ||
} | } | ||
Řádek 1453: | Řádek 1896: | ||
xvar-> | xvar-> | ||
xvar-> | xvar-> | ||
- | DisplayFillVarByPinValue(xpin, | + | |
+ | if ( (xvar-> | ||
+ | DisplayFillVarByTimeVar(xvar); | ||
+ | else | ||
+ | | ||
+ | | ||
} | } | ||
else | else | ||
Řádek 1571: | Řádek 2019: | ||
tDispVar xvar; | tDispVar xvar; | ||
DisplayFillVarByPinValue(xpin,& | DisplayFillVarByPinValue(xpin,& | ||
- | signed long xval=xvar.xval; | + | //signed long xval=xvar.xval; |
- | int xval10k=xvar.xval10000; | + | //int xval10k=xvar.xval10000; |
- | sprintf(xret," | + | sprint10k(xret, |
+ | //sprintf(xret," | ||
} | } | ||
Řádek 1634: | Řádek 2083: | ||
{ | { | ||
if (c==' | if (c==' | ||
+ | if (c==' | ||
if ((c> | if ((c> | ||
c='#'; | c='#'; | ||
Řádek 1670: | Řádek 2120: | ||
{ | { | ||
char pxval[50]=""; | char pxval[50]=""; | ||
- | | + | |
- | char *xsc=qsc; | + | |
- | signed long xval=xvar->xval; | + | |
- | int xval10k=xvar-> | + | |
- | while (xval> | + | |
{ | { | ||
- | if (xsc[1]==0) break; | + | |
- | int64 xq,xr; word xmod; | + | } |
- | i64x10k2int10k(& | + | else |
- | i64divW(& | + | { |
- | i64int10k2x10k(& | + | char qsc[]=" |
- | xsc++; | + | char *xsc=qsc; |
+ | signed long xval=xvar-> | ||
+ | int xval10k=xvar-> | ||
+ | |||
+ | if (xdecs==0xFE) | ||
+ | { | ||
+ | sprintf(pxval," | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | while (xval> | ||
+ | { | ||
+ | | ||
+ | int64 xq,xr; word xmod; | ||
+ | i64x10k2int10k(& | ||
+ | i64divW(& | ||
+ | i64int10k2x10k(& | ||
+ | xsc++; | ||
+ | } | ||
+ | sprint10k(pxval, | ||
+ | // sprintf(pxval," | ||
+ | DisplayCorrectDecs(pxval, | ||
+ | if ((xsc[0]!=' | ||
+ | } | ||
} | } | ||
- | sprintf(pxval," | ||
- | DisplayCorrectDecs(pxval, | ||
- | if ((xsc[0]!=' | ||
for (int cc=0; | for (int cc=0; | ||
if (ix< | if (ix< | ||
Řádek 1700: | Řádek 2166: | ||
hasvar=(c==' | hasvar=(c==' | ||
if ((!hasvar) && (ix< | if ((!hasvar) && (ix< | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | void DisplayFillVarByTimeVar(struct tDispVar * xvar) | ||
+ | { | ||
+ | char px[30]=""; | ||
+ | DisplayGetValueByTimeVar(px, | ||
+ | xvar-> | ||
+ | xvar-> | ||
+ | } | ||
+ | |||
+ | |||
+ | void DisplayGetValueByTimeVar(char * xbuf,char * xvarname, | ||
+ | { | ||
+ | xbuf[0]=0; | ||
+ | if ((xvarname[0]==' | ||
+ | { | ||
+ | if (strlen(xvarname)> | ||
+ | { | ||
+ | char xfmt[5]=""; | ||
+ | tMpwDateTime xMpwDateTime; | ||
+ | FormatDateTimeStr(xbuf, | ||
+ | } | ||
} | } | ||
} | } | ||
Řádek 1964: | Řádek 2454: | ||
+ | // -- [MATH10k] ------------------------------------------------- | ||
+ | |||
+ | boolean isnegative10k(signed long xval, int x10k) { | ||
+ | boolean xret=(xval< | ||
+ | } | ||
+ | |||
+ | void sprint10k(char * xret, signed long xval, int x10k) { | ||
+ | char xsgn[5]=""; | ||
+ | if (xval<0) xval=-xval; if (x10k<0) x10k=-x10k; | ||
+ | sprintf(xret," | ||
+ | } | ||
// -- [MATH64] ------------------------------------------------- | // -- [MATH64] ------------------------------------------------- | ||
Řádek 2045: | Řádek 2546: | ||
word xmod=0; | word xmod=0; | ||
signed long qval=(((unsigned long)qret.lh)<< | signed long qval=(((unsigned long)qret.lh)<< | ||
- | *xval=msf? | + | *xval=msf? |
+ | xint64-> | ||
} | } | ||
void i64x10k2int10k(struct int64 * xret, signed long xval, int x10k) { | void i64x10k2int10k(struct int64 * xret, signed long xval, int x10k) { | ||
int64 q1;int64 q2; | int64 q1;int64 q2; | ||
- | boolean msf=((xval)< | + | /* boolean msf=((xval)< |
+ | if (msf) xval=-(xval); | ||
q2.ll=(x10k)& | q2.ll=(x10k)& | ||
i64addS(xret, | i64addS(xret, | ||
Řádek 2057: | Řádek 2560: | ||
void i64x10k2int10kH(struct int64 * xret, signed long xval, int x10k) { | void i64x10k2int10kH(struct int64 * xret, signed long xval, int x10k) { | ||
int64 q1;int64 q2; | int64 q1;int64 q2; | ||
- | boolean msf=((xval)< | + | /* boolean msf=((xval)< |
+ | if (msf) xval=-(xval); | ||
q2.ll=(x10k/ | q2.ll=(x10k/ | ||
i64addS(xret, | i64addS(xret, | ||
} | } | ||
+ | |||
+ | |||
+ | // ---[ Digital Pin Output ]---------------------------------------- | ||
+ | |||
+ | int DPIN_epGetConfNameAddr(byte xpinindex) { | ||
+ | return (xpinindex< | ||
+ | } | ||
+ | |||
+ | void DPIN_epWriteConfName(byte xpinindex, | ||
+ | int xaddr=DPIN_epGetConfNameAddr(xpinindex); | ||
+ | if (xaddr> | ||
+ | { | ||
+ | byte chsum=(xaddr& | ||
+ | for (int i=1; | ||
+ | byte ch=xnamebuf[i-1]; | ||
+ | chsum+=ch+i+(ch& | ||
+ | if (EEPROM.read(xaddr+i)!=ch) EEPROM.write(xaddr+i, | ||
+ | if (ch==0) break; | ||
+ | } | ||
+ | if (EEPROM.read(xaddr)!=chsum) EEPROM.write(xaddr, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void DPIN_epReadConfName(byte xpinindex, | ||
+ | char xbuf[20]=""; | ||
+ | int xaddr=DPIN_epGetConfNameAddr(xpinindex); | ||
+ | byte chsum=(xaddr& | ||
+ | if (xaddr> | ||
+ | { | ||
+ | for (int i=1; | ||
+ | byte ch=EEPROM.read(xaddr+i); | ||
+ | chsum+=ch+i+(ch& | ||
+ | if (ch==0) break; | ||
+ | xbuf[i-1]=ch; | ||
+ | xbuf[i]=0; | ||
+ | } | ||
+ | if (EEPROM.read(xaddr)==chsum) | ||
+ | { | ||
+ | strncpy(xnamebuf, | ||
+ | xnamebuf[xbufsize-1]=0; | ||
+ | } | ||
+ | else | ||
+ | xnamebuf[0]=0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void DPINUpdateHW() { | ||
+ | uint16_t dstat=DPINstatus^DPINlogicmask; | ||
+ | for (int i=0; | ||
+ | if ((xdpin> | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void DPINResetHW() { | ||
+ | for (int i=0; | ||
+ | if ((xdpin> | ||
+ | } | ||
+ | DPINUpdateHW(); | ||
+ | } | ||
+ | |||
</ | </ |
source.1377631893.txt.gz · Poslední úprava: 2013/08/28 03:31 (upraveno mimo DokuWiki)