Author Topic: Wich data type for display buffer  (Read 1094 times)

0 Members and 1 Guest are viewing this topic.

Offline PeterFWTopic starter

  • Frequent Contributor
  • **
  • Posts: 577
  • Country: de
    • Stuff that goes boom
Wich data type for display buffer
« 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
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1483
  • Country: 00
Re: Wich data type for display buffer
« Reply #1 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.
,
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf