cancel
Showing results for 
Search instead for 
Did you mean: 

How do I draw a single point or pixel?

gfxfloro
Senior

Hi,

I'm trying to build my own graph widget, because the one provided slows down with bigger numbers. Now I want to speed it up by not having lines from one to the next datapoint but simply draw the pixels into the graph. Is this an appropriate approach to speed things up?

If so, how do I draw single points on the screen? All I've found are functions like lineTo() which can draw lines. Is there a way to directly write single points to the frameBuffer to speed things up?

4 REPLIES 4
HP
Senior III

you should be able to draw a shape with the size of '1' on each direction but that seems like a cumbersome way to go..

The form of the frame buffer surely shouldn't be that hard to establish and write pixels/bitmaps into.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yeah, I thought about using AbstractShape but as you say this doesn't seem like the best or quickest solution.

I worked out from other widget examples, that you can write to the framebuffer this way:

uint16_t *framebuffer = touchgfx::HAL::getInstance()->lockFrameBuffer();
framebuffer[x +  y* touchgfx::HAL::DISPLAY_WIDTH] = 0xFFFF /*pixel value*/;

however nothing appears on screen. Furthermore I am not using the advantages of DMA and when trying to set a lot of pixels this way the application seems to freeze, because it is not doing anything else than writing to the buffer.