Open Jcapehart2 opened 4 years ago
the canvas the LED-matrix has a SetPixel(x, y, color) method that allows you to set any pixel as needed
Very nice, thank you so much. I figured there was but wasn't able to find something on it and didn't want to misinterpret it. Great work you've done here :)
Is there a document I should read you think would show examples of this? Maybe showing using a range or do you have to do 1 pixel at a time?
SetPixel(variablex, variabley, variablecolor)
I guess this would be one way to do it as long as a variable = a traditional value. Would this be the same
variablex = 1 variabley = 2 border = white
same as \/ SetPixel(1, 2, white)
The API is the point where you could start reading https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/include/canvas.h
Also the example codes in examples-api-use/ might be useful: https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/examples-api-use/minimal-example.cc
You provide the color as red, green and blue value.
So thanks for the help. So right now I'm using Python and have it where I scrape a value from the web then calculate the total % of fundraiser complete. Then it fills the gauge based on the % returned. This is all functioning great. I'm trying to avoid just using images and change IMG based on quality, really want to use nothing but code where I can update the parameters for future use. Once I get this final part done I'm more than happy to share how I accomplished what I have thus far.
So now for my question Say I want to use a variable for text and have it print in ONLY this area.
font = graphics.Font()
font.LoadFont("../../../fonts/7x13.bdf")
textColor = graphics.Color(255, 255, 0)
pos = offscreen_canvas.width
my_text = self.args.text
(I Livestream my board so I can work on it remotely from home) How do I tell it to only print that area? SetPixel was easy to use in loops to make a gauge based on the size of my canvas. However, I don't see how I can create a "secondary" canvas so to speak to just print the input text if I wanted to. Don't see any examples to take inspiration from. I see offscreen_canvas.width/height often but correct me if I am wrong that is for the entire canvas.
You can use drawText()
in the same canvas (see the graphics example ).
That functions takes an x and y coordinate where you can tell it where to write things.
If you want to clear the area, you can draw a black rectangle over that (or maybe just write with black text the same text you wrote before).
If you want to do fancy things like clipping, you can implement a Canvas interface which delegates to some underlying canvas. This should be fairly straight-forward in C++, I don't know if the Python wrapper has the concept of Canvas being an interface, you have to explore that.
You can see an example of a delegating 'window' canvas in this comment: https://github.com/hzeller/rpi-rgb-led-matrix/issues/994#issuecomment-599158575
You can use
drawText()
in the same canvas (see the graphics example ). That functions takes an x and y coordinate where you can tell it where to write things. If you want to clear the area, you can draw a black rectangle over that (or maybe just write with black text the same text you wrote before).If you want to do fancy things like clipping, you can implement a Canvas interface which delegates to some underlying canvas. This should be fairly straight-forward in C++, I don't know if the Python wrapper has the concept of Canvas being an interface, you have to explore that.
Could you possibly help with an example to do this using the clipping method in python? I would like to make multiple 'windows' in the main canvas. Similar to the C++ example you attached.
I also cannot find how to draw a rectangle with the graphics example. Just use multiple lines?
Thanks in advance.
Hey everyone, I'm trying to avoid doing an image hack where it just changes the image based on what I want. I want to fill the led board like a thermometer fundraising type ordeal. If 10% of fundraiser fill (x,y)-(x,y). Is there a way to specify what LEDs based on location to light up? I'm not finding anything specific in the docs. Haven't jumped too far into the example API's but if someone knows a specific example in one of those that would be great too.
Using a 16x64 (2x 16x32 boards from adafruit)