pAkt = 0 pPass = 1 tPin = 1 pPin = 2 t = 60 webI$ = read(webIF) if webI$ <> "Auswahl" then webI$ = "Alles" udpPort$ = read(udpPortF) if udpPort$ == "" then udpPort$ = "8910" udpMAdr$ = read(udpMAdrF) if udpMAdr$ == "" then udpMAdr$ = "234.5.6.7" zD$ = read(zDF) 'Digitimp. lesen gosub [sImp] 'setzen bZ = 43 'Basisimp. sZ = 20 'Startimp. tZ = 18 'Trennimp. eZ = 70 'Endimimp. uZZ$ = read(ZZF) if uZZ$ == "" then uZZ$ = "1" aZeit$ = "..." bQuit$ = " (letzter Befehl)" udpRxAdr = " (UDP-Sender-Adr.)" tmr$ = "015" wZeit$ = "0800" count$ = "1" sUhr$ = "0" daten1$ = "00--00" daten2$ = "999999" zufall$ = "123456" bBef$ = "301289-" farben$ ="rt .or .ge .gn .gnbl.blgn.hlbl.vi .rs .ws .@ .@@@@.idx .1RGB.RGB ." cIndex = read.val(cIndexF) if cIndex < 0 or cIndex > 13 then cIndex = 6 indexF$ = read(indexFF) if len(indexF$) < 6 then indexF$ = "440033" cRGB$ = read(cRGBF) if len(cRGB$) <> 18 then cRGB$ = "090090060060040040" [start] msgbranch [msg] timer 1000, [aTimerON] 'Timer! gosub [iUDP] 'UDP Ini '------------------------------ [prg0] t = 60 tL = 60 'Timerzeit 60s print "EREL CRONIXIE Web-Interface v6.0 " textbox aZeit$ print button "Fernsteuerung", [prg1] button "Systemeinstellungen", [prg5] ipAdr$ = udpMAdr$ if val(udpPort$) == 0 then goto [prg0b] if len(ipAdr$) > 8 then goto [prg0a] ipAdr$ = ip() print "UDP: " & ipAdr$ & ":" & udpPort$ & " " goto [prg0c] [prg0a] print "UDP-Multicast: " & ipAdr$ & ":" & udpPort$ & " " goto [prg0c] [prg0b] print "UDP aus! " [prg0c] button "Einstellungen", [prg5] button " WiFi Reset", [WifiRes] print "Status: " textbox udpRxAdr textbox bQuit$ print wait [prg1] cls t = 60 tL = 60 'Timerzeit 60s print "EREL CRONIXIE Fernsteuerung v6.1 " print button "Uhrzeit", [aUhr] button "Datum", [aDat] button "Wecker/Timer", [prg2] button "Counter/Stoppuhr", [prg2] button "Daten/Zufall", [prg3] print button "Helligkeit", [prg7] button "Farben", [prg8] button "RGB-Farben", [prg9] textbox aZeit$ button "Uhr/Datum stellen", [prg6] print button "System", [prg5] if webI$ == "Alles" then textbox bQuit$ gosub [tFl] if webI$ <> read(webIF) then write(webIF, webI$) if apFlag$ == "1" then wifiapsta wait [prg2] cls print "EREL CRONIXIE Wecker/Timer " gosub [mQHaupt] print "Weckzeit: " textbox wZeit$ button "Set", [wSet] button "Aus", [wAus] button "Anzeigen", [wAnz] print "Timer: " textbox tmr$ button "Set", [tSet] button "Halt", [tHalt] button "Start", [tStart] wait [prg3] cls print "EREL CRONIXIE Counter/Stoppuhr " gosub [mQHaupt] print "Counter: " textbox count$ button "Count", [cCount] button "Reset", [cRes] button "Anzeigen", [cAnz] print "Stoppuhr: " textbox sUhr$ button "Set", [sSet] button "Reset", [sRes] button "Stop", [sStop] button "Start", [sStart] wait [prg4] cls print "EREL CRONIXIE Datendisplay/Zufall " gosub [mQHaupt] print textbox daten1$ button " Senden", [d1Send] print textbox daten2$ button " Senden", [d2Send] zufall$ = "123456" print "Zufall: " textbox zufall$ button "Muster", [zMust] button "Chaos", [zAA] button "Stop", [zStop] wait [prg5] cls print "EREL CRONIXIE System " gosub [mHaupt] print "Webinterface: " listbox webI$, "Auswahl,Alles", 1 button " WiFi Reset!", [WifiRes] print "Befehl [0]...[9],[-]: " textbox bBef$ button "Befehl senden...", [bEing] if webI$ <> "Alles" then goto [prg5a] textbox bQuit$ print "Ziffernwert [ms]: " zD$ = str(dZ) textbox zD$ button "Set", [zImp] button "Reset", [rImp] [prg5a] print "UDP-Multicast IP (224.0.0.0~239.255.255.255, 0=Aus), Port (0=UDP Aus):" print textbox udpMAdr$ textbox udpPort$ button "UDP-Set", [sUDP] wait [prg6] cls t = 60 tL = 0 'Timer @1 s print "EREL CRONIXIE Uhr/Datum stellen " gosub [mQHaupt] print "Zeitzone: +" listbox uZZ$, "0,1,2,3,4", 1 if webI$ <> "Alles" then goto [prg6a] button "MEZ", [uMEZ] button "MESZ", [uMESZ] [prg6a] textbox aZeit$ button "Uhr automatisch stellen", [aStell] print "Manuell: (ss/hhmm/ttmmjj): " textbox stell$ button "stellen", [uStell] wait [prg7] cls print "EREL CRONIXIE Helligkeitseinstellung " gosub [mQHaupt] print if webI$ <> "Alles" then goto [prg7a] button "Aus", [hAus] button " 1 ", [h1] button " 5 ", [h5] button " 10 ", [h10] button " 20 ", [h20] button " 33 ", [h33] button " 50 ", [h50] button " 75 ", [h75] button " 100 ", [h99] print "Sensor: " button " 0 ... ", [hAuto] button " 5 ... ", [hAmin] button "anzeigen", [ldr] wait [prg7a] button " 1 ", [h1] button " 5 ", [h5] button " 20 ", [h20] button " 50 ", [h50] button " 99 ", [h99] button " 5 ... Sensor ", [hAmin] wait [prg8] cls print "EREL CRONIXIE Farbeinstellung " gosub [mQHaupt] print button "<<", [iL] textbox iFarbe$ button ">>", [iR] button "Set Zeit-Farbe", [iZeit] button "Set Datum-Farbe", [iDat] if webI$ == "Alles" then print "Indexfarben (0=rt 1=or 2=ge 3=gn 4=gnbl 5=blgn 6=hlbl 7=vi 8=rs 9=ws): " print textbox indexF$ button "Set 1...6", [iSet] gosub [fDispl] wait [prg9] cls if webI$ <> "Alles" then goto [prg9a] print "EREL CRONIXIE RGB-Farbeinstellung " gosub [mQHaupt] print "Farbwerte 000...999: " button "Set Pos. 1...6", [sRGB16] print textbox rgb1$ button "Set Pos. 1", [sRGB1] print textbox rgb2$ button "Set Pos. 2", [sRGB2] print textbox rgb3$ button "Set Pos. 3", [sRGB3] print textbox rgb4$ button "Set Pos. 4", [sRGB4] print textbox rgb5$ button "Set Pos. 5", [sRGB5] print textbox rgb6$ button "Set Pos. 6", [sRGB6] gosub [aRGB] wait [prg9a] print "EREL CRONIXIE RGB-Farbeinstellung " gosub [mQHaupt] print "Farbwerte 000...999: " print textbox rgb1$ textbox rgb2$ textbox rgb3$ textbox rgb4$ textbox rgb5$ textbox rgb6$ button "Set Pos. 1", [sRGB1] button "Set Pos. 1...6", [sRGB16] gosub [aRGB] wait '------------------------------ [mQHaupt] textbox bQuit$ [mHaupt] print button "Hauptauswahl", [prg1] [mAusw] button "Zeit <-> Datum", [anzUm] return '=================================================== [aUhr] befehl$ = "40" gosub [bSend] wait [aDat] befehl$ = "41" gosub [bSend] wait [anzUm] 'Anzeige umschalten Uhr/Datum io(po,pPin,pAkt) delay 100 io(po,pPin,pPass) delay 200 wait [ldr] befehl$ = "9" gosub [bSend] wait '---------- [wSet] if val(wZeit$) > 2400 then wZeit$ = "2400" if val(wZeit$) < 0 then wZeit$ = "0000" befehl$ = "6" & wZeit$ gosub [bSend] wait [wAus] befehl$ = "60000" gosub [bSend] wait [wAnz] befehl$ = "6" gosub [bSend] wait [tSet] if val(tmr$) > 90000 then tmr$ = "90000" if val(tmr$) < 1 then tmr$ = "1" befehl$ = "2" & tmr$ gosub [bSend] wait [tHalt] befehl$ = "20" gosub [bSend] wait [tStart] befehl$ = "2" gosub [bSend] wait '---------- [cCount] if val(count$) < 1 or val(count$) > 11111 then count$ = "1" befehl$ = "0" If count$ <> countA$ then befehl$ = "0" & count$ countA$ = count$ gosub [bSend] wait [cRes] befehl$ = "00" gosub [bSend] wait [cAnz] befehl$ = "0-" gosub [bSend] wait '---------- [sSet] if val(sUhr$) > 90000 then sUhr$ = "90000" if val(sUhr$) < 0 then sUhr = "0" befehl$ = "1" & sUhr$ gosub [bSend] wait [sRes] befehl$ = "11" gosub [bSend] wait [sStop] befehl$ = "10" gosub [bSend] wait [sStart] befehl$ = "1" gosub [bSend] wait '---------- [d1Send] befehl$ = "3" & daten1$ gosub [bSend] wait [d2Send] befehl$ = "3" & daten2$ gosub [bSend] wait [zMust] befehl$ = "8" & zufall$ gosub [bSend] wait [zAA] befehl$ = "80" gosub [bSend] wait [zStop] befehl$ = "8" gosub [bSend] wait '---------- [bEing] befehl$ = bBef$ gosub [bSend] wait [rImp] zD$ = "30" [zImp] gosub [sImp] wait [sImp] if val(zD$) < 25 or val(zD$) > 35 then zD$ = "30" dZ = val(zD$) gosub [tFl] if zD$ <> read(zDF) then write(zDF, zD$) bQuit$ = "Ziff.Impuls = " &zD$ & " ms" return '---------- [uStell] befehl$ = "7" & stell$ gosub [bSend] wait [aStell] gosub [aStellSub] wait [aStellSub] gosub [cTime] befehl$ = "7" & str(nStd) & nMin$ quell$ = "Std.:Min..." gosub [nSend] gosub [tFl] gosub [cTime] nSek = mid(nZeit$,18,2) befehl$ = "7" & nSek quell$ = "Sekunden..." gosub [nSend] return '---------- [hAus] befehl$ = "420" gosub [bSend] wait [h1] befehl$ = "422" gosub [bSend] wait [h5] befehl$ = "423" gosub [bSend] wait [h10] befehl$ = "424" gosub [bSend] wait [h20] befehl$ = "425" gosub [bSend] wait [h33] befehl$ = "426" gosub [bSend] wait [h50] befehl$ = "427" gosub [bSend] wait [h75] befehl$ = "428" gosub [bSend] wait [h99] befehl$ = "429" gosub [bSend] wait [hAmin] befehl$ = "421" gosub [bSend] wait [hAuto] befehl$ = "420" gosub [bSend] wait '---------- [iL] if cIndex > 0 then cIndex = cIndex - 1 gosub [fDispl] wait [iR] if cIndex < 14 then cIndex = cIndex + 1 gosub [fDispl] wait [iZeit] befehl$ = "40" & mid(str(cIndex+100),2,2) if cIndex <> read.val(cIndexF) then write(cIndexF, cIndex) gosub [bSend] wait [iDat] befehl$ = "41" & mid(str(cIndex+100),2,2) if cIndex <> read.val(cIndexF) then write(cIndexF, cIndex) gosub [bSend] gosub [tFl] befehl$ = "41" gosub [bSend] wait [iSet] befehl$ ="" if len(indexF$) < 6 then indexF$ = "440033" befehl$ = "5" & indexF$ if indexF$ <> read(indexFF) then write(indexFF, indexF$) gosub [bSend] wait [fDispl] iFarbe$ = " " & str(cIndex) & " = " & mid(farben$, 5 * cIndex + 1, 4) return '---------- [sRGB1] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "431" & left(rgb1$,3) gosub [bSendP] befehl$ = "4013" gosub [bSend] gosub [fRGB] wait [sRGB2] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "432" & left(rgb1$,3) gosub [bSend] gosub [fRGB] wait [sRGB3] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "433" & left(rgb1$,3) gosub [bSend] gosub [fRGB] wait [sRGB4] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "434" & left(rgb1$,3) gosub [bSend] gosub [fRGB] wait [sRGB5] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "435" & left(rgb1$,3) gosub [bSend] gosub [fRGB] wait [sRGB6] gosub [sRGB] befehl$ = "" if len(rgb1$) < 3 then wait befehl$ = "436" & left(rgb1$,3) gosub [bSend] gosub [fRGB] [sRGB16] gosub [sRGB] if len(cRGB$) <> 18 then wait 'Fehler! befehl$ = "431" & mid(cRGB$,1,3) gosub [bSendP] befehl$ = "432" & mid(cRGB$,4,3) gosub [bSendP] befehl$ = "433" &mid(cRGB$,7,3) gosub [bSendP] befehl$ = "434" &mid(cRGB$,10,3) gosub [bSendP] befehl$ = "435" &mid(cRGB$,13,3) gosub [bSendP] befehl$ = "436" &mid(cRGB$,16,3) gosub [bSendP] bQuit$ = " RGB Farben OK!" gosub [fRGB] wait [aRGB] ' cRGB$ auf rgb_$ verteilen rgb1$ = mid(cRGB$,1,3) rgb2$ = mid(cRGB$,4,3) rgb3$ = mid(cRGB$,7,3) rgb4$ = mid(cRGB$,10,3) rgb5$ = mid(cRGB$,13,3) rgb6$ = mid(cRGB$,16,3) return [sRGB] 'rgb_$ zu cRGB$ sammeln cRGB$ = "090090060060040040" cRGB$ = "000000000000000000" mid(cRGB$,1,3) = left(rgb1$,3) mid(cRGB$,4,3) = left(rgb2$,3) mid(cRGB$,7,3) = left(rgb3$,3) mid(cRGB$,10,3) = left(rgb4$,3) mid(cRGB$,13,3) = left(rgb5$,3) mid(cRGB$,16,3) = left(rgb6$,3) return [fRGB] 'Flash RGB gosub [aRGB] if len(cRGB$) < 18 or cRGB$ == read(cRGBF) then return write(cRGBF, cRGB$) gosub [ledErr] return '---------- '=================================================== [bSend] quell$ = " Befehl " [nSend] gosub [tBusy] if len(befehl$) > 7 then goto [bSendErr] 'Formatprüfung (>RET) for n = 1 to len(befehl$) if instr("0123456789-", (mid(befehl$, n, 1))) == 0 then goto [bSendErr] next bQuit$ = quell$ & befehl$ & "..." aZ = sZ 'Start gosub [ledAkt] for n = 1 to len(befehl$) z = instr("0123456789-", (mid(befehl$, n, 1))) - 1 aZ = tZ 'Ziff.Trenn if n == len(befehl$) then aZ = eZ 'Ziff.Ende pZ = bZ + z * dZ 'Ziff.Bas+Diff gosub [ledPassAkt] 'Aus -> Ein next bQuit$ = quell$ & befehl$ & " OK!" befehl$ = "" gosub [ledPass] 'fertig LED aus gosub [tOk] return [bSendP] quell$ = "sende... " gosub [nSend] gosub [tFl] gosub [aRGB] return [bSendErr] bQuit$ = quell$ & befehl$ & " ???" befehl$ = "" gosub [ledErr] return [ledPassAkt] 'Aus -> Ein io(po,pPin,pPass) delay pZ [ledAkt] io(po,pPin,pAkt) delay aZ return [ledPass] 'Aus (fertig) io(po,pPin,pPass) delay pZ return [ledErr] 'Fehler - flackern for n = 0 to 10 io(po,pPin,pAkt) delay 20 io(po,pPin,pPass) delay 20 next gosub [tOk] return [tFl] 'Tx flackern for n = 0 to 5 io(po,tPin,pAkt) delay 100 io(po,tPin,pPass) delay 100 next [tOk] io(po,tPin,pAkt) 'Tx-LED Ein return [tBusy] io(po,tPin,pPass) 'Tx-LED Aus return '----------------------------------------------- [aTimerON] '--- TIMER --- t = t + 1 io(po,tPin,pPass) 'Tx-LED alive delay 10 io(po,tPin,pAkt) if uZZ$ == read(ZZF) and t < tL then wait 'alle 60 sek. t = 0 gosub [cTime] wait [uMEZ] uZZ$ = "1" gosub [cTime] wait [uMESZ] uZZ$ = "2" gosub [cTime] wait [cTime] 'Zeitzone berechnen nZeit$ = time() nStd = val(mid(nZeit$,12,2)) nMin$ = mid(nZeit$,15,2) nSek$ = mid(nZeit$,18,2) nDat$ = left(nZeit$,11) nStd = nStd + val(uZZ$) if nStd > 23 then nDat$ = "?" + nDat$ if nStd > 23 then nStd = nStd - 24 aZeit$ = " " & nDat$ & str(nStd) & ":" & nMin$ if tL <> 60 then aZeit$ = aZeit$ & ":" & nSek$ if uZZ$ <> read(ZZF) then write(ZZF, uZZ$) return [WifiRes] ' ---- WiFi Reset ----- cls print "Achtung! Reset Wifi-Einstellungen!" txt$ = read(WIFIname) print "WIFIname: " & txt$ & " verwerfen?" txt$ = read(WIFIpass) print "WIFIpass: (" & str(len(txt$)) & ") verwerfen?" txt$ = read(APname) print "APname: " & txt$ & " verwerfen?" txt$ = read(APpass) print "APpass: (" & str(len(txt$)) & ")"& " verwerfen?" print button " wirklich? ", [WifiOK] button " abbrechen! ", [prg5] print wait [WifiOK] cls txt$ = "ESP" print "Ungescherter Access Point: " & txt$ print "Systemadresse 192.168.4.1" print button " umschalten ", [WifiDel] button " abbrechen! ", [prg5] wait [WifiDel] del.dat(WIFIname) del.dat(WIFIpass) del.dat(APname) del.dat(APpass) write(APname, txt$) print "Bitte neu starten..." wait [sUDP] ' ------------ set/initialisiere UDP-Server ------------ gosub [tFl] if val(udpMAdr$) < 224 or val(udpMAdr$) > 239 then udpMAdr$ = "0" if udpMAdr$ <> read(udpMAdrF) then write(udpMAdrF, udpMAdr$) if udpPort$ <> read(udpPortF) then write(udpPortF, udpPort$) gosub [iUDP] goto [prg0] wait [iUDP] Udpstop bQuit$ = " UDP aus" upv = val(udpPort$) if upv == 0 then return if udpMAdr$ > "0" then UdpbeginMultiCast udpMAdr$, upv if udpMAdr$ == "0" then Udpbegin upv udpbranch [rUDP] bQuit$ = " UDP Empf.Port: " & udpPort$ return [rUDP] ' ===== UDP-Empfang ===== befehl$ = udpread() udpRxAdr = udpremote() quell$ = " UDP: " udpreply quell$ & befehl$ & "..." 'Quittung gosub [wSend] udpreply bQuit$ 'Quittung return [msg] ' ===== Message-Empfang ===== udpRxAdr = "" befehl$ = msgget("bef") quell$ = " MSG: " bQuit$ = "MSG: " & befehl$ & "... " & right(aZeit$,5) & " OK!" for n = 1 to len(befehl$) 'Formatcheck if instr("0123456789-", (mid(befehl$, n, 1))) == 0 then bQuit$ = " MSG: " & befehl$ & " ???" next msgreturn bQuit$ if right(bQuit$, 1) == "!" then gosub [wSend] wait ' msgbranch [msg] ' Beispiel: http://192.168.2.105/msg?bef=123@ [wSend] '--- Web-Befehle senden --- if left(befehl$, 1) <> "-" then gosub [nSend] 'keine Sonderbefehle if befehl$ >= "-0" and befehl$ <= "-4" then gosub [wZZ] 'ZZ +0...+4 if befehl$ == "-5" then gosub [waStell] 'Uhr stellen if befehl$ == "-6" then gosub [wTaK] 'Taste kurz if befehl$ == "-7" then gosub [wTaL] 'Taste lang if befehl$ >= "-920" and befehl$ <= "-940" then gosub [wZW] 'Ziffernwert return end [waStell] 'Web Uhr Auto stellen gosub [aStellSub] bQuit$ = " Uhr: " & str(nStd) & ":" & nMin$ & ":" & nSek$ & " OK!" return [wZZ] uZZ$ = mid(befehl$, 2, 1) bQuit$ = " ZZ: +" & uZZ$ & " OK!" return [wTaK] io(po,pPin,pAkt) delay 100 io(po,pPin,pPass) delay 200 bQuit$ = " Taste kurz. OK!" return [wTaL] io(po,pPin,pAkt) delay 1000 io(po,pPin,pPass) delay 200 bQuit$ = " Taste lang. OK!" return [wZW] 'Ziffernimpuls-Adj. zD$ = mid(befehl$, 3, 2) if val(zD$) < 25 or val(zD$) > 35 then zD$ = "30" dZ = val(zD$) gosub [tFl] if zD$ <> read(zDF) then write(zDF, zD$) bQuit$ = " Ziff.Imp." & zD$ & "ms OK!" return