source
Rozdíly
Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.
| Následující verze | Předchozí verze | ||
| source [2013/08/24 08:01] – vytvořeno mypower_cz | source [2016/04/22 21:34] (aktuální) – upraveno mimo DokuWiki 127.0.0.1 | ||
|---|---|---|---|
| Řádek 1: | Řádek 1: | ||
| ====== Microlog2 Source ====== | ====== Microlog2 Source ====== | ||
| - | Pozor! Tato verze je pracovní a není plně funkční. | + | ===== Info ===== |
| + | |||
| + | Verze 2.04 | ||
| + | |||
| + | ===== Kompilace projektu ===== | ||
| + | |||
| + | **Pozor: Pro kompilaci | ||
| + | |||
| + | V nových verzích se můžete setkat s chybou | ||
| + | |||
| + | microlog2: | ||
| + | |||
| + | nebo | ||
| + | |||
| + | microlog2: | ||
| + | ===== Notes ===== | ||
| + | |||
| + | * přidána podpora pro datum a čas, synchronizováno při přenosu na mypower.cz | ||
| + | * čítač sekund byl změněn na uint32_t | ||
| + | * mapa eprom byla přesunuta z kódu na [[mod: | ||
| + | |||
| + | * [[http:// | ||
| + | |||
| + | ===== Download ===== | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | ===== Source ===== | ||
| <file c microlog2.ino> | <file c microlog2.ino> | ||
| Řádek 7: | Řá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 27: | Řádek 51: | ||
| // ---[ BUILT-IN CONFIG ]----------------------------- | // ---[ BUILT-IN CONFIG ]----------------------------- | ||
| - | int sendInterval = 30; // sec default: 120 | + | int sendInterval |
| - | int sendRetry | + | int sendRetry |
| - | byte maxErrors | + | byte maxErrors |
| + | |||
| + | byte NETmac[6] | ||
| + | //byte NETip[4] | ||
| + | byte NETip[4] | ||
| + | byte NETgw[4] | ||
| + | byte NETmask[4] | ||
| + | byte NETdns[4] | ||
| - | byte NETmac[] = { 0xF6, 0x88, 0x00, 0x00, 0x00, 0x01 }; | + | // ---[ 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] = { 40, 42, 44, 46, 48, 0, 0, 0, 22, 23, 24, 25, 26, 27, 28, 29 }; | ||
| + | uint16_t DPINstatus | ||
| + | // < | ||
| + | uint16_t DPINlogicmask = (B00000000 << 8) | B00000011; | ||
| // ---[ MODS ]---------------------------------------- | // ---[ MODS ]---------------------------------------- | ||
| // mod MyPowerLog | // mod MyPowerLog | ||
| - | #define modMyPowerLog | + | #define modMyPowerLog |
| - | #define modMyPowerHost | + | #define modMyPowerHost |
| - | #define modMyPowerFVEID | + | #define modMyPowerFVEID |
| // mod StausLed | // mod StausLed | ||
| - | #define modStatusLed | + | #define modStatusLed |
| - | #define modStatusLedPin | + | #define modStatusLedPin |
| // mod SerialLog | // mod SerialLog | ||
| - | #define modSerialLog | + | #define modSerialLog |
| - | #define modSerialForce | + | #define modSerialForce |
| + | #define modSerialBaudRate | ||
| // 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 60: | Řá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 94: | Řá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 - 2057 MyPower Serial Number | ||
| struct tPinConf { | struct tPinConf { | ||
| Řádek 125: | Řádek 143: | ||
| }; | }; | ||
| - | struct tMpwAccess { | + | struct tDPinConf { |
| - | byte sn[10]; | + | char xname[20]; |
| - | | + | }; |
| - | | + | |
| + | #define xComStatusNop | ||
| + | #define xComStatusASchanged | ||
| + | #define xComStatusDSchanged | ||
| + | #define xComStatusIsLastDayInMonth | ||
| + | #define xComStatusIsDST | ||
| + | |||
| + | #define xComStatusXXDaysMonthMask | ||
| + | #define xComStatus28DaysMonth | ||
| + | #define xComStatus29DaysMonth | ||
| + | #define xComStatus30DaysMonth | ||
| + | #define xComStatus31DaysMonth | ||
| + | |||
| + | struct tMpwAccess { | ||
| + | byte xComStatus; // | ||
| + | | ||
| + | uint8_t mpwremoteDateMonth; | ||
| + | | ||
| + | | ||
| + | | ||
| + | signed | ||
| + | uint32_t mpwremoteCheckedAtS; | ||
| + | uint32_t mpwlogintimeS; | ||
| + | uint32_t mpwDeviceId; | ||
| + | uint32_t mpwAccessId; | ||
| + | } xMpwAccess; | ||
| + | |||
| + | struct tMpwDateTime { | ||
| + | int xyear, xmonth, xday, xhour, xminute, xsecond; | ||
| }; | }; | ||
| Řádek 134: | Řádek 180: | ||
| #define xdcOptActive | #define xdcOptActive | ||
| - | struct tSampledPin { | + | struct tSampledPin { int pin; byte smpHi8[128]; |
| - | | + | struct tPinValue { int smpVal, |
| - | | + | struct tSamplerStruct { tPinValue tPinValues[NUM_ANALOG_INPUTS]; |
| - | }; | + | byte tPinTimes[128]; |
| - | + | ||
| - | struct tPinValue { | + | |
| - | | + | |
| - | }; | + | |
| - | + | ||
| - | struct tSamplerStruct { | + | |
| - | tPinValue tPinValues[NUM_ANALOG_INPUTS]; | + | |
| - | tSampledPin tPinSamples[4]; | + | |
| - | byte tPinTimes[128]; | + | |
| - | unsigned long tPinMicros; | + | |
| - | }; | + | |
| - | + | ||
| - | tSamplerStruct | + | |
| struct tDeviceConf { | struct tDeviceConf { | ||
| Řádek 179: | Řá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 186: | Řá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 205: | Řádek 251: | ||
| pinMode(modStatusLedPin, | pinMode(modStatusLedPin, | ||
| #endif | #endif | ||
| + | |||
| #if ((modSerialLog == 1) || (modSerialForce == 1)) | #if ((modSerialLog == 1) || (modSerialForce == 1)) | ||
| - | Serial.begin(9600); | + | Serial.begin(modSerialBaudRate); |
| #endif | #endif | ||
| + | |||
| #if ((modSerialLog == 1) || (modDisplay == 1)) | #if ((modSerialLog == 1) || (modDisplay == 1)) | ||
| Řádek 215: | Řádek 263: | ||
| #if (modSerialLog == 1) | #if (modSerialLog == 1) | ||
| - | XLog(sn1); | + | XLog(sn1); |
| - | XLog(MPWMicroLogVersion); | + | |
| #if (modMyPowerLog == 1) | #if (modMyPowerLog == 1) | ||
| - | XLog(" | + | 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; | ||
| + | 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(" | + | XLog(ccx); |
| + | #endif | ||
| #endif | #endif | ||
| Řádek 234: | Řádek 300: | ||
| #endif | #endif | ||
| - | pinMode(10, OUTPUT); | + | DPINResetHW(); |
| - | int xret=Ethernet.begin(NETmac); | + | pinMode(53, OUTPUT); |
| + | |||
| + | int xret=0; | ||
| + | |||
| + | boolean isdhcp=((NETip[0]& | ||
| + | |||
| + | if (isdhcp) | ||
| + | { | ||
| + | #if (modSerialLog == 1) | ||
| + | XLog(" | ||
| + | #endif | ||
| + | xret=Ethernet.begin(NETmac); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | Ethernet.begin(NETmac, | ||
| + | xret=1; | ||
| + | delay(1000); | ||
| + | } | ||
| W5100.setRetransmissionTime(0x07FF); | W5100.setRetransmissionTime(0x07FF); | ||
| W5100.setRetransmissionCount(2); | W5100.setRetransmissionCount(2); | ||
| - | if (xret == 0) { | + | |
| + | if ( (xret == 0) && (isdhcp) | ||
| #if modSerialLog == 1 | #if modSerialLog == 1 | ||
| XLog(" | XLog(" | ||
| Řádek 265: | Řádek 351: | ||
| server.begin(); | server.begin(); | ||
| #if modSerialLog == 1 | #if modSerialLog == 1 | ||
| - | char c[30]=""; | + | char c[30]=""; |
| #endif | #endif | ||
| #endif | #endif | ||
| + | |||
| + | SamplerReset(); | ||
| + | |||
| #if modSerialLog == 1 | #if modSerialLog == 1 | ||
| XLog(" | XLog(" | ||
| Řádek 336: | Řádek 425: | ||
| #if modMyPowerLog==1 | #if modMyPowerLog==1 | ||
| void SendDataToMyPower() | void SendDataToMyPower() | ||
| - | { | + | { |
| + | boolean canrun=true; | ||
| + | for (int xp=0; | ||
| + | if (xSamplerStruct.tPinValues[xp].smpTime==0) | ||
| + | { canrun=false; | ||
| + | if (canrun) SendDataToMyPower_int(); | ||
| + | } | ||
| + | |||
| + | void SendDataToMyPower_int() | ||
| + | { | ||
| char xtext[200]; | char xtext[200]; | ||
| int xsi=sendInterval; | int xsi=sendInterval; | ||
| Řádek 343: | Řá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 361: | Řádek 459: | ||
| modMyPowerHost, | modMyPowerHost, | ||
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| - | strcpy(xtext," | ||
| - | boolean xf=false; | ||
| - | char p[10]; | ||
| - | for (int xpin=0; | ||
| - | if (xf) strcat(xtext," | ||
| - | sprintf(p," | ||
| - | strcat(xtext, | ||
| - | } | ||
| - | client.write((byte*)xtext, | ||
| - | strcpy(xtext,"; | + | |
| - | client.write((byte*)xtext, | + | |
| - | + | if (islogin) | |
| + | { | ||
| + | | ||
| + | for (int i=0; | ||
| + | | ||
| + | strcat(xtext," | ||
| + | client.write((byte*)xtext, | ||
| + | client.write(" | ||
| + | } | ||
| + | |||
| + | sprintf(xtext," | ||
| + | client.write((byte*)xtext, | ||
| + | sprintf(xtext," | ||
| + | | ||
| for (int xp=0; | for (int xp=0; | ||
| { | { | ||
| Řádek 379: | Řádek 482: | ||
| tPinValue * qPinValue; | tPinValue * qPinValue; | ||
| qPinValue=& | qPinValue=& | ||
| - | sprintf(xtext," | + | sprintf(xtext," |
| - | qPinValue-> | + | qPinValue-> |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| + | if ( (islogin) || ((xMpwAccess.xComStatus& | ||
| + | { | ||
| tPinConf pconf; | tPinConf pconf; | ||
| boolean isvalid=ReadPinConf(& | boolean isvalid=ReadPinConf(& | ||
| - | if (!isvalid) | + | if (isvalid) |
| - | strcat(xtext," | + | |
| - | else | + | |
| { | { | ||
| - | sprintf(xtext," | + | |
| - | | + | char smax10k[30]=""; |
| + | // | ||
| + | sprintf(xtext," | ||
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| xtext[0]=0; | xtext[0]=0; | ||
| Řádek 401: | Řádek 502: | ||
| byte * p; | byte * p; | ||
| p=(byte*)pconf.xname; | p=(byte*)pconf.xname; | ||
| - | for (int i=0; | + | for (int i=0; |
| - | | + | |
| client.write((byte*)xtext, | client.write((byte*)xtext, | ||
| strcpy(xtext,"/" | strcpy(xtext,"/" | ||
| p=(byte*)pconf.xunit; | p=(byte*)pconf.xunit; | ||
| - | for (int i=0; | + | for (int i=0; |
| - | | + | client.write((byte*)xtext, |
| + | client.write("; | ||
| } | } | ||
| - | strcat(xtext,"; | + | } |
| - | client.write((byte*)xtext, | + | |
| } | } | ||
| + | | ||
| + | xMpwAccess.xComStatus& | ||
| | | ||
| - | | + | |
| - | client.write((byte*)xtext, | + | |
| | | ||
| int lbufpos=0; | int lbufpos=0; | ||
| Řádek 474: | Řádek 575: | ||
| void ParseHTTPResult(char * xtext) { | void ParseHTTPResult(char * xtext) { | ||
| - | 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 530: | Řádek 795: | ||
| // int xs=(xpin*sp); | // int xs=(xpin*sp); | ||
| int xs=GetEpromPinAddr(xpin); | int xs=GetEpromPinAddr(xpin); | ||
| - | for (int ax=0; | + | |
| - | xret=(calcPchsum(xpin, | + | { |
| + | | ||
| + | xret=(calcPchsum(xpin, | ||
| + | } | ||
| } | } | ||
| return xret; | return xret; | ||
| Řádek 538: | Řádek 806: | ||
| int GetEpromPinAddr(int xpin) | int GetEpromPinAddr(int xpin) | ||
| { | { | ||
| - | boolean | + | int xret=-1; |
| if (xpin< | if (xpin< | ||
| xret=(xpin*sizeof(tPinConf)); | xret=(xpin*sizeof(tPinConf)); | ||
| Řádek 560: | Řá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 568: | Řá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 xPinOptNone |
| - | #define xPinOptEnabled | + | #define xPinOptEnabled |
| - | #define xPinOptName | + | #define xPinOptName |
| - | #define xPinOptMin | + | #define xPinOptMin |
| - | #define xPinOptMax | + | #define xPinOptMax |
| - | #define xPinOptUnit | + | #define xPinOptUnit |
| - | #define xPinOptType | + | #define xPinOptType |
| - | #define xPinOptGroup | + | #define xPinOptGroup |
| - | #define xPinCmdWrite | + | #define xPinCmdWrite |
| - | void WebServer_pf(char * xstr,signed long * xsl,int * xsl10000) { | + | #define xDPinOptNone |
| - | int im; *xsl=0;*xsl10000=0; char * p=xstr; char * p10k=p; | + | #define xDPinOptName |
| + | |||
| + | #define xDPinOptSetStatus 0xA0 | ||
| + | |||
| + | #define xDPinSetStatus | ||
| + | |||
| + | void WebServer_pf(char * xstr,signed long * xsl,int * xsl10k) { | ||
| + | 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; | ||
| } | } | ||
| void WebServer_wp(byte xpin, struct tPinConf * pconf) { | void WebServer_wp(byte xpin, struct tPinConf * pconf) { | ||
| if (xpin< | if (xpin< | ||
| + | xMpwAccess.xComStatus|=xComStatusASchanged; | ||
| byte*xconf=(byte*)pconf; | byte*xconf=(byte*)pconf; | ||
| - | // int ax=xpin*sizeof(tPinConf); | ||
| int ax=GetEpromPinAddr(xpin); | int ax=GetEpromPinAddr(xpin); | ||
| - | for (int ii=0; | + | |
| - | if (EEPROM.read(ax+ii) != xconf[ii]) | + | |
| - | EEPROM.write(ax+ii, | + | if (EEPROM.read(ax+ii) != xconf[ii]) |
| + | EEPROM.write(ax+ii, | ||
| } | } | ||
| } | } | ||
| + | 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 656: | Řá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 728: | Řá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 769: | Řá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 781: | Řádek 1156: | ||
| else | else | ||
| if (xpk==xPinOptName) | if (xpk==xPinOptName) | ||
| + | { | ||
| strncpy(pconf-> | strncpy(pconf-> | ||
| + | pconf-> | ||
| + | } | ||
| else | else | ||
| if (xpk==xPinOptMin) { | if (xpk==xPinOptMin) { | ||
| Řádek 823: | Řá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 847: | Řá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 863: | Řá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 880: | Řá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 900: | Řá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 920: | Řá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 1066: | Řá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 1079: | Řádek 1566: | ||
| client.write("< | client.write("< | ||
| client.write("< | client.write("< | ||
| - | client.write("< | + | client.write("< |
| + | client.write("< | ||
| if (qmode==xWEBhome) { | if (qmode==xWEBhome) { | ||
| | | ||
| Řádek 1109: | Řá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 1406: | Řádek 1896: | ||
| xvar-> | xvar-> | ||
| xvar-> | xvar-> | ||
| - | DisplayFillVarByPinValue(xpin, | + | |
| + | if ( (xvar-> | ||
| + | DisplayFillVarByTimeVar(xvar); | ||
| + | else | ||
| + | | ||
| + | | ||
| } | } | ||
| else | else | ||
| Řádek 1524: | Řá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 1587: | Řádek 2083: | ||
| { | { | ||
| if (c==' | if (c==' | ||
| + | if (c==' | ||
| if ((c> | if ((c> | ||
| c='#'; | c='#'; | ||
| Řádek 1623: | Řá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 1653: | Řá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 1700: | Řádek 2237: | ||
| return SamplerAnalogReadType(xpin, | return SamplerAnalogReadType(xpin, | ||
| } | } | ||
| + | |||
| + | |||
| + | void SamplerReset() { | ||
| + | for (int i=0; | ||
| + | xSamplerStruct.tPinValues[i].smpTime=0; | ||
| + | } | ||
| int SamplerAnalogReadType(byte xpin,byte forcextype) | int SamplerAnalogReadType(byte xpin,byte forcextype) | ||
| Řádek 1903: | Řádek 2446: | ||
| xpinvalue-> | xpinvalue-> | ||
| xpinvalue-> | xpinvalue-> | ||
| + | xpinvalue-> | ||
| } | } | ||
| } | } | ||
| Řádek 1910: | Řá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 1991: | Řá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 2003: | Řá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.1377324090.txt.gz · Poslední úprava: 2013/08/24 14:01 (upraveno mimo DokuWiki)