Draw a circle! Seems simple enough,

Draw a circle!

Seems simple enough, but i’m failing to get my head around it!

I have the TiM, which is 8 strips in parallel, but i have it coded like a single long length folded back on itself, (like you would have if you made your own led matrix from scratch

To plot a circle in a matrix of leds.

I’ve found this, which helps that the code is java and quite easily adaptable.


void circlesimple(int xCenter, int yCenter, int radius) {
int xC, yC, r2;

    r2 = radius * radius;
    for (xC = -radius; xC <= radius; xC++) {
        yC = (int) (sqrt(r2 - xC*xC) + 0.5);
        x = (xCenter + xC, yCenter + yC);
        y = (xCenter + xC, yCenter - yC);



void edgeconstraint() {
if(y%2 == 1) { // row is odd
leds[allleds[(y * xmax) + ((xmax-1)-x)]].setRGB(255,255,255);
} else { // row is even
leds[allleds[(y*xmax) + x]].setRGB(255,255,255);

any ideas or direction?

now then, i’ve managed a circle! and its not pretty!

y = (3sin(z))+ymax/2;
x = (3
xyconversion(255, 255, 255);

its also a bit lumpy!

I’m not surprised with so few pixels. You can improve things by ‘blending’ some pixels near the rough bits. The same way laser and inkjet printers smooth the edges of fonts.

But you could spend more time blending than the results give. You’re back in the realm of the old 8x8 fonts on early computers.

Try looking at your circle at 10m away and I bet it looks much better…

Anyway back to your original problem: You might find it better to ‘union’ two sets of variables over each other. The first for your LED matrix as it is laid out. The second over the top for how the LED strip is actually wired.

Then you can write to the matrix as you wish it to appear. Once you have finished writing, you can directly read out the union directly to the LED strip. That should simplify your coding and make it simpler to understand or scale to a larger array. This is because you have the two different mappings using the same memory.