EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: PeterFW on February 06, 2016, 09:13:06 am

Title: Wich data type for display buffer
Post by: PeterFW on February 06, 2016, 09:13:06 am
Hello everybody!
On my bench sits a 16x25 pixel LED display i build, after i veryfied that everything works it is now time to write a library and write some proper code.

Each pixel has 8 bit resolution, at the moment i am using a 2D array to store the display data. That makes for nice and easy readable code.

While looking up another library i saw it use a normal array as a display buffer.
Is a reason behind that?

Should i switch to a simple array or can i continue to use a 2D array?

Greetings,
Peter
Title: Re: Wich data type for display buffer
Post by: dom0 on February 06, 2016, 09:39:39 am
Multi-dimensional arrays are folded into a one-dimensional array in virtually every programming language (except maybe shells and probably mathematics software), so there really is no advantage in writing framebuf[WIDTH * y + x] over e.g. framebuf[y]
  • [/i][/i], the latter will be converted by something like the first by the compiler.