![]() |
Forum Index : Microcontroller and PC projects : Webmite driving me crackers...
![]() ![]() |
|||||
Author | Message | ||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7871 |
I've abandoned Webmite for the moment. I decided that it was easier to redesign the Aquarium Controller to have a display as it doesn't need much control. It gives me an excuse to put SMD MOSFETs in instead of the ULN chip too, and to introduce backlighting using a WS2812B strip. :) All done on a RP2040-Zero this time. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Malibu Senior Member ![]() Joined: 07/07/2018 Location: AustraliaPosts: 260 |
Don't give up yet Mick... Try this and it might help out OPTION EXPLICIT 'basic web server dim string Off$, Onn$ dim Integer CurrentTemp 'get the time WEB ntp Pause 1000 Print "Server started at "Time$ Dim buff%(4096/8) Off$ = "checked" Onn$ = "" WEB TCP INTERRUPT WebInterrupt Do '<do your processing here>' CurrentTemp=26 Loop ' sub to handle all web server requests Sub WebInterrupt Local a%, p%, t%, s$ For a%=1 To MM.Info(max connections) WEB tcp read a%, buff%() if llen(buff%()) > 0 then 'LongString print buff%() If (linstr(buff%(), "GET / HTTP") > 0) or (linstr(buff%(), "GET /index") > 0) then WEB transmit page a%,"/index.html" elseif linstr(buff%(), "favicon.ico") > 0 then web transmit code a%, 205 elseif linstr(buff%(), "RB=ON") > 0 then ? "Turning RB to ON" Off$ = "" Onn$ = "checked" WEB transmit page a%,"/index.html" elseif linstr(buff%(), "RB=OFF") > 0 then ? "Turning RB to Off" Onn$ = "" Off$ = "checked" WEB transmit page a%,"/index.html" else ? "Other request found, sending 205 code" web transmit code a%, 205 endif endif Next a% End Sub <html> <head> <title>WebMite</title> </head> <body> <h1>Aquarium Control</h1> <h2>{date$} {time$}</h2> <p>The tank temperature is {ttemp}C <br> The current lighting preset is number {colr} </p> <br> <br> <br> <form id="radiotest" name="radiotest" method="post" action=""> Coloured Lighting <input type="radio" id="RB" name="RB" value="OFF" onclick="submit(this.value)"{off$}>Off <input type="radio" id="RB" name="RB" value="ON" onclick="submit(this.value)"{onn$}>On </form> </body> </html> Works on Opera and Firefox for me - I don't use Chrome, but see how it goes for you ![]() For the Favicon request, I've just added the 205 code, but you can use a real favicon if needed John |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7871 |
Thanks John. I'll give it a try, but just at the moment I'm a little busy. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Malibu Senior Member ![]() Joined: 07/07/2018 Location: AustraliaPosts: 260 |
No worries, it's there when/if you need it... and yeah, it's the busy season, so totally understood! I've been playing with the UDP comms instead of TCP. It seems to be more stable - maybe that's another option for your controls? John |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |