Considering approach to an Elmish.Meadow #22
Replies: 5 comments 13 replies
-
Sounds very interesting. If what I'm hearing is that each IoT device runs a mailbox and operates its own Elmish loop to maintain state and handle all IO effects, then yes, I think that would be a great design. |
Beta Was this translation helpful? Give feedback.
-
I took a stab at what an Elmish solution might look like. |
Beta Was this translation helpful? Give feedback.
-
Hey @JordanMarr I just saw your PR for the "JpegLoad" branch which looks really tight. I'll be trying it this morning. The 1.3 updates for Meadow just came through last night and I put them on all of my boards before I called it a night. So this will be one of the first I'll try this morning. 👍 |
Beta Was this translation helpful? Give feedback.
-
FYI - I might have just roped you into an "Amplifying F#" video conf session to talk about Elmish and WildernessLabs (my original topic was going to be my solar tracker but I may digress into the VOC/CO2 project oo) |
Beta Was this translation helpful? Give feedback.
-
One last note before close this out... I updated the app to use the VOC value (the "back half" of the tuple returned from the device driver) instead of CO2. I found two interesting nits that likely carried over from some of my old code.
That was a genuine head-scratcher for a minute. I still think that's some kind of latent bug but I'm not entirely sure I want to put the time in to ferret it out. 😸 |
Beta Was this translation helpful? Give feedback.
-
Since you helped me with getting the example app "AutoUpdate" button status into "the Elmish loop" I thought I'd throw this tanget over the fence to see what you think. I hope you don't mind the minor digression. Thanks! 🙏
So, I've been working with Akka.NET quite a bit for some larger projects - and like any other novelty I see "actors" everywhere I look. One of my interests is to use actors "all the way down" including at the edge. 🔬 I've played around with the idea of using Akkling/Wakka in the WildernessLabs Meadow - understanding that running full Akka.NET on a microcontroller might be a form of "overkill" - unless it's part of a larger code base where Akka is used on the backplane. At least that was my early concept. 🤔
But now - as is the reason for this post - I'm thinking that Elmish likely makes more sense here. The idea of using the F# mailbox as an actor directly in Meadow F# code occurred to me, and now that I've had a brush with Elmish here I'm starting to see it - like my early days with Akka - everywhere I look. 👀 The idea is for a more organized, message-based structure to the code. The "obvious" benefit is to have a form of semantic and mechanical (to borrow a phrase from "Stylish F#") distinction from side-effects. This involves both writing out to Meadow resources/pins/endpoints as well as the plethora of peripherals that are "mutable by default" because of the way that Wildernesslabs.Core is structured to support hardware requirements in a resource-constrained microcontroller.
To skip ahead a bit, here's an example of something I wrote to process values from a CO2 sensor and display changes in various elements of a 'canvas' - which is a GC9A01 display. 📺 Some of these are "easy pickings" (like all of the
CO2value
s that get updated) where I think "oh this would be a great place to use MVU". But then there are others - such as the instantiation ofcanvas
which (along with any other resource on the Meadow) uses direct interfacing under the hood to reduce housekeeping overhead on the processor. Trying to be clever with immutability in those cases just BREAKS. 💥🚧 I'm already starting to "module out" certain things like managing the onboard LED and creating a structure for addressing BLE and handling onboard config. From that bit of head-scratching 🤔 Elmish seems to fit into the logical extension of keeping segmenting the mutable/immutable aspects in a way that will make more complex projects easier to manage. So what I want to do is create some semblance of "managed effects" such as writes to the display, controlling the on-board LED or posting logs/events to a web endpoint for managing telemetry, etc, etc.
My Ask: I'm looking for your perspective on whether you think this might be a worthwhile exercise. And if so, how would you think about creating a "view" distinction where the view might be an LED or relay control to switch an external device?
I know this is a LOT to take in - thanks in advance for letting me bounce this off of you. 🧠
Beta Was this translation helpful? Give feedback.
All reactions