Dynamically add or position images on a matrix

Ruskin

New elf
Joined
Dec 28, 2020
Messages
7
Not sure how to put in a development request, but I would love it if the xSchedule APIs could include an option to dynamically add images into a pixel matrix.

I have a few games in my lights (naughts and crosses, hangman, connect four, master mind and memory).

All of these use xSchedule APIs and most can easily be played with a few calls, which include "Set current text" (where I have 9 texts which I set to "X" or "O" for naughts and crosses, or 4 to 6 numbers for mastermind, or 6 to 8 texts for hangman letters), plus "Set pixels" or "Set pixel range" for drawing the hangman scaffold or the connect 4 tokens.

But the memory game involves showing/hiding 4 or 6 images (in 8 or 12 squares).
If I choose 4 images they are 9 pixels wide by 11 high. If I choose 6 images, they are 9 pixels wide by 7 high.
(my matrix is only 48 wide by 24 high, so am limited with the image size).

Without the ability to call an API to set an image (position it on the matrix in a given location), I need to use the "Set pixels" API and call it 99 times (for the 9x11 image) or 63 times (for the 9x7 image), rather than once to say place the image at location x/y.

It just means, the overhead when showing/hiding images takes quite a few seconds each time.


By the way; I think there is a bug in the "Set pixel range" API call when passing a channel count of zero. It doesn't clear the pixel data.
It works fine in "Set pixels" when passing zero.
 

Rick33

New elf
Joined
May 29, 2021
Messages
8
Location
Northgate
Awesome ideas, having the interactive games. I like the idea of adding the images, would be interested to see how difficult this would be to implement.
 

Ruskin

New elf
Joined
Dec 28, 2020
Messages
7
I recommend the github issue tracker.
Thanks.
I'll use that to record the "Set pixel range" issue.
But not sure I can use that for an enhancement request, as it isn't an issue but a new feature.
 

Ruskin

New elf
Joined
Dec 28, 2020
Messages
7
Awesome ideas, having the interactive games. I like the idea of adding the images, would be interested to see how difficult this would be to implement.
Implemented and working fine.
It's a combination of a show page on my website which the audience can interact with. Plus a scheduling script which processes all of the interactions and show schedule (which reads the schedule for the day as well as the interaction requests and activates features in xSchedule with the APIs they provide).
Wasn't that difficult to put together. But some of the logic was challenging, such as the AI for the Connect 4 game.

Unless you mean how difficult adding images to xSchedule would be?
In which case, I would imagine quite difficult as it wouldn't just be x/y position, but also resizing/cropping/stretching options.
 

merryoncherry

Senior elf
Generous elf
Joined
Apr 2, 2022
Messages
633
Location
Cherry St., Hudson MA USA
But not sure I can use that for an enhancement request, as it isn't an issue but a new feature.
When you click "New Issue" you'll get the choice. There's also an "enhancement" tag that can get added to existing issues to change them.

I think I see the obvious problem with the "Set pixel range" command, so if you file it I'll put in a PR for you.
 

Ruskin

New elf
Joined
Dec 28, 2020
Messages
7
When you click "New Issue" you'll get the choice. There's also an "enhancement" tag that can get added to existing issues to change them.

I think I see the obvious problem with the "Set pixel range" command, so if you file it I'll put in a PR for you.
Thanks.
I suspect it's line 3278 in ScheduleManager.cpp

(images didn't paste in the original, but green works, red doesn't);
1657489662915.png
1657489687316.png
 
Last edited:

merryoncherry

Senior elf
Generous elf
Joined
Apr 2, 2022
Messages
633
Location
Cherry St., Hudson MA USA
So... the image on matrix.
It seems an ideal solution, xSchedule knowing about the image, matrix, scaling, etc., may be quite hard.
Using the xSchedule matrix definition (which doesn't come from layout, support alternate nodes, color order, etc.), 1:1, may be a bit easier.
Having the web API supply the image data is a bit easier yet.
Quite doable would be one API command to set multiple pixel ranges. In fact, you currently only need one call per channel range (image row, for horizontal matrix, so mabe 11 calls instead of 99 in your example above), not one per pixel.
We could make a call that essentially moves your whole draw loop to xSchedule. That'd be easy enough to code+test.
Thoughts?
 

Ruskin

New elf
Joined
Dec 28, 2020
Messages
7
So... the image on matrix.
:
Quite doable would be one API command to set multiple pixel ranges. In fact, you currently only need one call per channel range (image row, for horizontal matrix, so mabe 11 calls instead of 99 in your example above), not one per pixel.

Yeah, I was thinking about the complexities of this.
I thought it might be easy to say here's the image file which is already the right width/height place it at this top/left position.
BUT: it would need to know the layout as when it does the second row, it would have to know which channels they are (which isn't simple if you run horizontally or vertically, strings are left to right and then right to left or all are left to right, etc).

So dropping it down to 9 calls, where I pass 11 colors (or 11 calls with 9 colors), would definitely be an improvement.

Unless there was a way to submit a packet (eg: JSON) which has all of the channels and colors in one request.
But that would mean "posting" data to the API instead of something simple in a "get" query.

The "set multiple pixel ranges" might be the easiest solution.

PS: of course, it'd also need a parameter to clear them
 
Top