4 ms·
yeaaaaaaah no. Never going this path again for any interactive page. This summer I built an irrigation system for my father's field, with the idea that the sch
by alin23 3y ago
yeaaaaaaah no. Never going this path again for any interactive page.
This summer I built an irrigation system for my father's field, with the idea that the scheduling would be done in relative time (water this zone for 2h) instead of absolute (start watering this zone at 9AM and end at 11AM).
I kept it as simple as possible:
- 16 cheap relays for the 24V AC electric valves
- 1 beefy relay for the pump
- 1 Pi Pico W for controlling the relays
Here's a picture of the "low-tech" build: https://files.alinpanaitiu.com/lowtech-irigation.jpeg https://files.alinpanaitiu.com/lowtech-irigation.jpeg
The Pico W would have a code.py with all the relay and schedule logic, and an index.html which would be a simple list of sliders to set how much time each valve should be open. The Pico W would function as a "hotspot" which the phone would connect to, and the "app" would be available at 192.168.4.1.
It can be added to homescreen and it looks just like a native app as far as my father is concerned. It doesn't feel like one though, he can tell.
The web page looks like this: https://shots.panaitiu.com/lHMGplFn https://shots.panaitiu.com/lHMGplFn
That's all there is to it, really. That simple single page with a few sliders and buttons took weeks to build and test thoroughly with only vanilla JS. I was obviously constrained by the flash memory, but there are KB-sized helper frameworks nowadays which I wasn't aware of.
It's also really hard to refactor. I initially stored the schedules at minute-resolution, but then had to store it in second-resolution to add a repeat schedule feature. Oh boy, so much code to parse and change, so many slider.value calculations to redo... yep, never doing this again
- explaininjs 3y agoThe magic of react is that it handles the entire View part of MVVC and also provides a nice DSL for writing the View Controller. With a lot of architectural planning you can develop as clean of code without it (cleaner, perhaps), but I agree it's better to just embrace it.
- TheRealPomax 3y agoIf you want to use the browser as a user interface for an application, use a user interface library. Knowing what you're building is just as important as picking the right tools after you figured that part out: not all web pages (in fact, man web pages) are not, and don't need to be, user interfaces for applications.
- topspin 3y agoIs the code shared anywhere? I'm thinking that it could benefit from some input from others that have done a lot of vanilla JavaScript work. That application should be pretty concise and DRY using <template>.