Problem
Definition: A clear, concise statement describing the issue to be addressed, including its scope, context, and constraints. It serves as the foundation for analysis, solution design, or decision-making.
So when I say “Problem” that’s what I mean: an issue to be addressed – the clearer the context the simpler it is to come up with a solution.
By the way, Magic Poi and SmartPoi (open source) have a Patreon Support channel . If you would like to keep track of progress – and optionally contribute (mostly to AI Coding Assistant and Server bills) please join up – you can join for free and get updates about the project, paid members get a discount when we start selling the actual project.
The Problem
TLDR: I am working on the best ways to create, save, fetch and display timed sequences of images for Magic Poi. It’s tricky but I am getting there!
Timelines and Sequences – in terms of Magic Poi:
Timeline: a sequence of images each with an attached time to be displayed. The times start at zero.
Sequence: just the sequence, timed at a regular interval.
So in terms of software, we have a User Interface running JavaScript, connected to a back end running on Python (Flask). The back end database is PostreSQL which actually contains all of the arrays of images and metadata (including ownership and relationships – eg Tom owns x.jpg and shared it with Dylan).
The Poi running C++ needs to connect to the Python server API using http requests (authenticated using JWT, so you don’t get someone else’s images!)
Currently how the flow works is:
- User creates timeline and saves – this adds the image ID’s in an array (each image has a number), like [1, 4, 67, 55] and the timeline times in an array (in milliseconds), like [0, 257, 1029, 40005].
- The back end saves the timeline image ID’s and times along with metadata (Timeline name, owner, shared with..)
- Now the hard part, poi fetch the timeline – after selecting “timeline” using buttons (I have created a nice menu system with 2 buttons – LED colours give indication of position in the menu, long press first button for menu, short press first button to select main menu position, short press second button to select sub-menu)
– this is where the hard part comes in. First of all, we need to know how many timelines the user has, so we need to fetch that in order to proceed. Then the sub-menu needs to have exactly that number of options to choose from. But what if we are not connected to WiFi? I have to have fallback options for every error, including Server errors (maybe the data center went down for maintenance, or I borked something in the Cloud..)
Eventually you get to the point of downloading the images (using the timeline image ID array) and then displaying after all the downloading is done in exact millisecond time, according to the timeline times array.
Also, I want the option to have the images display as a regular sequence (using another button menu option) rather than to exact timing – like the original SmartPoi did it. This is rather simpler to achieve thankfully but we still need to incorporate a new time variable which can be changed on the web interface or using buttons (or the offline on-board web interface, yes there is another one also)
Conclusion
So in case you are still following this – the timeline object is created in JavaScript, stored and served by Postgres DB and Python, and consumed by both JavaScript (web page loading) and C++ (Magic Poi download and display)
Status
Right now I have Magic Poi nested menu system which I am quite pleased with. We just finished testing on the new prototype board and everything works! In terms of software I can download and display one timeline in exact millisecond timing – or select a specific image from that timeline to display individually.
Todo
Still todo is the selection of which timeline – and also adding shared timelines to the list (the ones your friends shared with you using the easy to use right click web menu interface). And optional sequence mode, choose to display image each for 0.5 – 3600 seconds at a time before moving to the next.
Also I still need to add in the Flash storage space checks from SmartPoi (make sure we have enough space for the image files before downloading them!)
Maybe
I might even be able to squeeze in multiple timelines at once on the poi? This would require a way to check the Flash size restraints on the poi from the Server side, to enable calculations of size (some timelines might share images, so we don’t have to download multiple copies, sharing image files between timelines…) Right now I’m not worried about this though!
Also: Streaming! I already did this as a fun test but it requires the poi to be connected to WiFi the whole time. With two cores on S3 chip, one takes care of the downloading of images, the other displays. When an image completes downloading, it is immediately passed over to the other core with some cool memory swap code and displayed – while the next image starts downloading. This opens up many possibilities, and bypasses the restraints inherent in ESP32 Flash memory storage size (no I am not adding an SD card for downloads)
Conclusion
Wow that is a lot of words. Sometimes it is just good to outline the Problem in order to focus and get to the solution – which for me will be fast, efficient and reasonably priced Magic Poi, with versatile Timelines!