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/09/15 11:42] – [Notes] mypower_cz | source [2016/04/22 21:34] (aktuální) – upraveno mimo DokuWiki 127.0.0.1 | ||
|---|---|---|---|
| Řádek 3: | Řádek 3: | ||
| ===== Info ===== | ===== Info ===== | ||
| - | Verze 2.03 - pravděpodobně poslední testovací verze před vydáním první veřejné verze | + | 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 |
| - | * opraven bug s - znaménkem u malých | + | * čítač sekund byl změněn na uint32_t |
| - | * přidána volitelná negativní logika pro digitální výstupy | + | * mapa eprom byla přesunuta z kódu na [[mod:eprom|wiki]] |
| - | * opravy www rozhraní | + | |
| - | * přidána záloha | + | |
| * [[http:// | * [[http:// | ||
| Řádek 31: | Řádek 40: | ||
| // ---[ VERSION ]------------------------------------- | // ---[ VERSION ]------------------------------------- | ||
| - | #define MPWMicroLogVersion | + | #define MPWMicroLogVersion |
| // ---[ INCLUDE ]------------------------------------- | // ---[ INCLUDE ]------------------------------------- | ||
| Řádek 78: | Řá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 | // mod DisplayEmulation | ||
| - | #define modDisplayEmulation | + | #define modDisplayEmulation |
| - | | + | |
| // --------------------------------------------------- | // --------------------------------------------------- | ||
| Řádek 93: | Řá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 127: | Řádek 136: | ||
| #define xpinOPTsampleG2 | #define xpinOPTsampleG2 | ||
| #define xpinOPTsampleG3 | #define xpinOPTsampleG3 | ||
| - | |||
| - | // ---------------------------------------------------- | ||
| - | |||
| - | // EEPROM | ||
| - | // 0 - 40 PIN0 CONF (41 bytes struct tPinConf) | ||
| - | // 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 - 2067 DPIN Name 0 (char [20]) | ||
| - | // 2068 - 2087 DPIN Name 1 | ||
| - | // 2088 - 2107 DPIN Name 2 | ||
| - | // 2008 - 2127 DPIN Name 3 | ||
| - | // 2028 - 2147 DPIN Name 4 | ||
| - | // 2048 - 2167 DPIN Name 5 | ||
| - | // 2068 - 2187 DPIN Name 6 | ||
| - | // 2088 - 2207 DPIN Name 7 | ||
| - | // 2008 - 2227 DPIN Name 8 | ||
| - | // 2028 - 2247 DPIN Name 9 | ||
| - | // 2048 - 2267 DPIN Name 10 | ||
| - | // 2068 - 2287 DPIN Name 11 | ||
| - | // 2088 - 2307 DPIN Name 12 | ||
| - | // 2008 - 2327 DPIN Name 13 | ||
| - | // 2028 - 2347 DPIN Name 14 | ||
| - | // 2048 - 2367 DPIN Name 15 | ||
| - | // 2368 ... FREE | ||
| struct tPinConf { | struct tPinConf { | ||
| Řádek 177: | Řádek 147: | ||
| }; | }; | ||
| - | #define xComStatusNop | + | #define xComStatusNop |
| - | #define xComStatusASchanged | + | #define xComStatusASchanged |
| - | #define xComStatusDSchanged | + | #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 234: | Řádek 228: | ||
| void lcdPrintAt(char * str,int x) { | void lcdPrintAt(char * str,int x) { | ||
| int ix=strlen(str); | int ix=strlen(str); | ||
| + | // int ix=strlen(str); | ||
| void lcdClearLine() { int i; for (i=0; | void lcdClearLine() { int i; for (i=0; | ||
| void lcdPrintLine(int y) { | void lcdPrintLine(int y) { | ||
| Řádek 268: | Řá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) | ||
| + | char ccx[50]=""; | ||
| #if (modDisplayEmulation == 1 ) | #if (modDisplayEmulation == 1 ) | ||
| - | XLog(" | + | sprintf(ccx," |
| #else | #else | ||
| - | XLog(" | + | sprintf(ccx," |
| #endif | #endif | ||
| + | XLog(ccx); | ||
| #endif | #endif | ||
| + | |||
| #endif | #endif | ||
| Řádek 295: | Řádek 301: | ||
| DPINResetHW(); | DPINResetHW(); | ||
| - | pinMode(10, OUTPUT); | + | pinMode(53, OUTPUT); |
| int xret=0; | int xret=0; | ||
| Řádek 345: | Řádek 351: | ||
| server.begin(); | server.begin(); | ||
| #if modSerialLog == 1 | #if modSerialLog == 1 | ||
| - | char c[30]=""; | + | char c[30]=""; |
| #endif | #endif | ||
| #endif | #endif | ||
| Řádek 435: | Řá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 454: | Řádek 460: | ||
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| - | //struct tMpwAccess { unsigned long mpwtime; unsigned long mpwtimeAtMS; | + | |
| - | + | ||
| - | | + | |
| if (islogin) | if (islogin) | ||
| Řádek 468: | Řádek 472: | ||
| } | } | ||
| - | sprintf(xtext," | + | sprintf(xtext," |
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| sprintf(xtext," | sprintf(xtext," | ||
| Řádek 571: | Řá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 1107: | Řá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, | ||
| Řádek 1139: | Řádek 1306: | ||
| sprintf(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 | ||
| Řádek 1708: | Řádek 1896: | ||
| xvar-> | xvar-> | ||
| xvar-> | xvar-> | ||
| - | DisplayFillVarByPinValue(xpin, | + | |
| + | if ( (xvar-> | ||
| + | DisplayFillVarByTimeVar(xvar); | ||
| + | else | ||
| + | | ||
| + | | ||
| } | } | ||
| else | else | ||
| Řádek 1890: | Řádek 2083: | ||
| { | { | ||
| if (c==' | if (c==' | ||
| + | if (c==' | ||
| if ((c> | if ((c> | ||
| c='#'; | c='#'; | ||
| Řádek 1926: | Řá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]!=' | ||
| + | } | ||
| } | } | ||
| - | sprint10k(pxval, | ||
| - | // sprintf(pxval," | ||
| - | DisplayCorrectDecs(pxval, | ||
| - | if ((xsc[0]!=' | ||
| for (int cc=0; | for (int cc=0; | ||
| if (ix< | if (ix< | ||
| Řádek 1957: | Řá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 2391: | Řádek 2624: | ||
| DPINUpdateHW(); | DPINUpdateHW(); | ||
| } | } | ||
| + | |||
| </ | </ | ||
source.1379238125.txt.gz · Poslední úprava: 2013/09/15 17:42 (upraveno mimo DokuWiki)