I dread writing embedded GUIs
blog.benjamin-cabe.com
blog.benjamin-cabe.com
Recommend, would use again.
If you have the budget for it, this is a great architecture since creating a website GUI is much easier than an embedded GUI. Also, you could very easily pull up the machine control panel remotely from any web browser (with proper remote vs local security enabled of course).
You end up with some ancient 68000 or PowerPC processor running all the performance-critical logic with - if you're lucky - a megabyte of SRAM. It's expected to hit one millisecond scan times every single millisecond for ten years straight. And it does so, until you miss your SRAM battery maintenance interval or drive a forklift through the panel; it will probably keep running through any lesser hiccup.
The PLC communicates over that serial interface (or an Ethernet socket which emulates a serial interface) with the HMI, which probably has a multicore x86 CPU and literally a thousand times more memory. It runs a pared-down desktop operating system. It's not made to hit one-millisecond scan times, it probably has visible lag while merely changing the background color of an indicator. Good luck creating a usable GUI with the IDE, which might be decades old.
An Arm Cortex microcontroller for the embedded system, and a Linux touchscreen displaying a NodeJS website would be a convergent way to develop such a machine if you didn't have 50 years of legacy code and trundling along behind you....
I've pushed for web interfaces but it's weird how even embedded developers with broad backgrounds get when you bring it up. I think there's a psychological barrier some people have to using webpages on an embedded system.
I wish so, but Google kind-of wrecks that proposition, introducing new stuff to the point that some developers might (unknowingly) use something that is not available on the embedded browser.
Bear in mind that what I'm talking about here is making UI's for embedded systems easier to design by using web technologies. That means that we're only leveraging web tech for local use: there is no connectivity farther than (maybe) to another device on the same circuit board.
Something like BoneScript (javascript for the BeagleBone) takes this step farther by building I/O extensions into the language so your system controller and webserver can be the same process.
Honestly running a node.js website with a Redis cache and a Python script for an embedded GUI sounds like a completely insane and fragile mess!
Qt or Flutter are clearly the best options for embedded touchscreen devices where you can run Linux.
The constraints he talks about (hardware and memory) I find to be a lot easier to program for because they really put a hard stop to useless abstractions - I find myself just wiring straightforward code and getting things up and running immediately instead of wasting lots of time on design and architecture.
The nature of embedded with interrupts (e.g. from buttons) and trying to mix in MQTT events and nice multi-layered UI made me completely question my programming abilities.
I really wanted to have modals/pop-ups (e.g. to show current volume on change) and it ended up so messy. Not only it is about control flow but about memory too (as the author mentioned). I couldn't just store a stack of "screens" to fall back to.
I'm watching this library recently: https://github.com/peterhinch/micropython-micro-gui
It seems promising to solve many of the common issues that you get, once you move from simple static information display.
Source: my own raytracer vs microsoft teams and 90% of all other electron apps or otherwise very javascript heavy frontends.
Wrote my whole stack in C# / Winforms and deploy to a Mono running on a Raspberry Pi 4.
UI runs on main thread and is purely viewing and event generation. On a background thread, I have a homegrown cooperative multitasking state machine driven kernel that handles all interaction with the machinery. Works awesome. Plenty of CPU to spare. And event response is < 5ms typically, which is based on the timer interval.
Only two downsides, only printf debugging. I gave up after a couple of days of following SO and various tutorials on how to get the remote Mono / .NET debugger working. Maybe if I switch to WPF…but I avoided that because the Interface Designer for VS was half-baked (and sucked) at the time.
Second downside, some weird point map scaling variation between the Interface Designer and Mono placing with the window under the WM. I worked around by incorporating a build script to parse the source of the form and write out an initialization routine to fix the size and location of all screen elements. It’s definitely sketchy but it works.
The end result says it all though. My UI and responsiveness beats the snot out of machines we’ve spent multiple $100K on that run Win Embedded + PLC architecture.
I'm thinking for washing machines, dishwashers, aircon, things like that.
Unless simple, embedded UIs are usually bad and usually make complex interactions (e.g. setting timers) especially horrible. Whereas android/apple/the web have been optimized for UX.
It's oddly not as common as I'd have expected, though.
Let me configure it physically, or do it over a web browser, but preferably the later. Especially for when the servers are shutdown because the product is no longer profitable (looking at you sonos)
Another thing, has anyone seen a well designed software made by a hardware company? They seem very rare. Just look at any printers.
If you put Apple on your hardware product's critical path, they may capriciously change their app store rules at some point to invalidate your whole product or business model.
If you put Google on your hardware product's critical path, they may just get bored of supporting whatever Google product(s) you are using, and kill your whole product or business model without even realizing they're doing it.
These companies should be treated as forces to be reckoned with, not (just) as friends to partner with.
There is one area where gadgets and appliances are the most cumbersome to use, and that is their electronic UI. They have always been terrible (eg programming VCRs).
Graphical UIs won't make them better.
And all those screens and buttons will be the first things to fail, will be very hard to source replacements for, and will be too expensive to bother repairing anyway, not to mention, an expensive addition to The Thing in the first place.
Please, just add a bluetooth LE interface, and a web app, for control and programming with cheap, ubiquitous, and designed-for-UI mobile phones, and open-source it.
The Thing itself should only have the most minimal physical interface, eg on/off button and led. Keep the embedded mcu (and embedded programmers) for low-level device control mechanisms and some policy enforcement for safety.
This is mostly because, in reality, manufacturers not only will they never open source those apps, most probably they will never provide APIs and the Thing and associated apps will depend on some server. Such a dependency I find unacceptable, but it is the trend of all things IoT.
If this were not the case, if by law all IoT Things had to provide open APIs, I would be all for it.
'Right to repair' laws should extend to 'right to program' , thus forcing open APIs of some kind.
There should be some kind of standard, defacto, or official.
Its HTTPS over Bluetooth. I could list Bluetooth devices like ACs and TVs in range, and open paired devices as a web app. It could be server rendered with JS sprinkled, a PWA I could install like an app, or even streaming video.
Also, lvgl is a very good toolkit.
[0] https://blog.benjamin-cabe.com/wp-content/uploads/2021/10/re...
Possibly different teams contracted out to do both jobs. The design is done by one team, finished, and then handed off to the next.
I'm sure the interface could be tweaked (remove some animations, lower the resolution, etc) to make it usable but instead there was a complete failure of management and it was shipped as-is.
- UI toolkit is cross platform (cough cough Qt, or Altia, or Crank) and runs great on the UX developer's x86 box. The UX guy loves fancy CSS transitions.
- Graphic assets are delivered in 32bit RGBA and the data cache chokes on the massive bit maps. And the cheap LCD is 565BGR so the CPU is constantly mixing channels. Then we discover the hardware has no alpha blending capability. More software load.
- Hardware gets cost reduced. Or the flagship platform gets the beefy CPU and the consumer versions get a Rockchip.
- RAM gets downsized or the project grows out of bounds and now we're blitting from QSPI flash.
- The whole system runs in JavaScript because that's what they can get out of the overseas development team, or it's too expensive to buy 2 more Qt seat licenses (or whatever the hell they want now. I think we're up to first-born children)
It all repeats, over and over.
He seems to have compiled an arbitrary list of 'hard things' or 'problems you may encounter'. But these are presented so shallow, I find it hard to believe he ever struggled with them.
Although he seems to push the opensource Renode at the end, I feel it is mostly an Azure submarine.