Skip to content

add blit to mqtt functions#31

Closed
neonsignal wants to merge 4 commits intogeekscape:masterfrom
neonsignal:gdm-npixel-blit
Closed

add blit to mqtt functions#31
neonsignal wants to merge 4 commits intogeekscape:masterfrom
neonsignal:gdm-npixel-blit

Conversation

@neonsignal
Copy link

@neonsignal neonsignal commented Jan 24, 2021

Andy - these are the changes I made to oled.py to allow for the oled:blit0 and oled:blit1 functions - I must confess I don't really know how to Python.
The blit arguments are base64 encoded strings, one string per line, and it is blitted starting at the top left corner of the chosen screen.

example usage
(oled:blit1 ////////+ ////9v//+ ////ff//+ ///9////+ ///3/9//+ ////////+ ////r///+ ///5+9//+ ////3r//+ ////33//+ ///+i///+ ///z/X//+ ///f/9//+ //+6qvf/+ //7ASBv/+ //3Cqp3/+ //uVVQ7/+ //2FVUd/+ //cEqo//+ //eKpUq/+ //6GvUe/+ /+eHnqq/+ //4Pt0f/+ /++Fs6e/+ //cMVk2/+ //eFV0f/+ //2FUK5/+ //uCrqf/+ //2KoU7/+ //7JWq3/+ //9kpFv/+ //++t+f/+ ///H/RP/+ //+0hdX/+ //8v/yr/+ //6l/9V/+ //6vbar/+ //yv79I/+ //qtfdW/+ //pf7tSf+ //q3e+lf+ //K933Vf+ //S3deiv+ /+q/v3av+ //Tt7fVP+ /+p/f7Fv+ /+Vq1c0v+ /+k//uVf+ /+qu95VP+ /+qnv9E3+ /xUr9VSn+ /qqpv1a3+ /VVX/1VP+ /qqS11Vj+ /qqr/yqV+ /qqje6rV+ /qqq3FVX+ /VVVRqqn+ /VqpUlVf+ /1VVKVV/+ //VV/1T/+ //1X/9X/+ ///f/6f/+ ////////+)

To do the screen capture, I just used some dirty C++ code https://pastebin.com/cyPbdUNF to snapshot, reduce down and dither, and ran it from a script which called mosquitto_pub to periodically publish the capture.

@neonsignal neonsignal changed the title add npixel and blit to mqtt functions add blit to mqtt functions Jan 25, 2021
@neonsignal
Copy link
Author

neonsignal commented Jan 26, 2021

I'm also experimenting (not in this patch set) with just blitting the whole image in one big base64 string. This is significantly faster again (I'm getting more than 10fps over MQTT to the swagbadge). In the experimental version, I send:
(oled:blit x y width height base64data)
And where x >= 128, I put it on the second screen.
This has the advantage of being much faster and allowing images be placed anywhere, but forces the width to be a multiple of 8 pixels.
The other problem with the blit command as I have it is that it is not device agnostic; a color screen would need a different depth and data format. I could also include the color depth, though this means that the external source of data now has to be aware of the screen it is using in order to create the base64 part, so it still isn't particularly generic. Maybe a 'blit mono' and a 'blit color', to tradeoff between speed and genericity.

@marcmerlin
Copy link
Collaborator

were there issues with this? it seemed like a good idea

@neonsignal
Copy link
Author

Marc, I've replaced this with a version which I think has a cleaner API (and is significantly faster, I didn't realized early on that the speed bottleneck was the parsing). The new one just sends the entire image as a single blob, rather than line by line.
#41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants