Libraries, utilities, bootloaders...
by Matrix828 » Mon Aug 25, 2014 5:40 pm
How about, in addition to BLACK and WHITE colours we have an INVERT option?
Eg,
- Code: Select all
gb.display.color = INVERT;
gb.display.drawPixel(x, y);
And obviously, if the pixel at (x, y) is white, then it will be set to black, and vise-versa.
-
Matrix828
-
- Posts: 43
- Joined: Tue Jul 22, 2014 7:44 pm
-
by rodot » Wed Aug 27, 2014 10:06 am
Mmh why not, that could be interesting and wouldn't take a lot more coding at first glance.
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by DFX2KX » Wed Aug 27, 2014 9:39 pm
yeah, that seems useful. It'll be a teeny bit slower because of having to check pixels, but it wouldn't be that bad in the scheme of things.
-
DFX2KX
-
- Posts: 250
- Joined: Mon Apr 14, 2014 3:48 am
by yodasvideoarcade » Wed Sep 03, 2014 12:41 pm
That would definetely be useful, especially when drawing bitmaps. You would easily recognize overlapping images since they come out inverted.
Basically it's just adding the bits together, no checking of pixels neccesary.
-
yodasvideoarcade
-
- Posts: 102
- Joined: Sat Apr 19, 2014 10:48 am
- Location: Frankfurt/Germany
-
by rodot » Thu Sep 04, 2014 6:28 am
yodasvideoarcade wrote:Basically it's just adding the bits together, no checking of pixels neccesary.
You'll have to read the current color of the pixel in the display buffer in order to be able to invert it.
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by rodot » Sun Sep 07, 2014 10:40 am
I added the INVERT color in the last commit to the
beta branch
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by TheTurnipKing » Fri Sep 12, 2014 7:54 pm
Shouldn't you just be able to use a logical operation? The current value doesn't matter. Adding 1 should flip it from 1 to 0 OR 0 to 1.
-
TheTurnipKing
-
- Posts: 13
- Joined: Wed Sep 10, 2014 3:29 am
by rodot » Fri Sep 12, 2014 8:13 pm
Of course the current value matters, how to you want to invert a pixel if you don't know its initial value
Yes it "just use a logical operation" as it's set the pixel to the opposite of its current value.
You can't just add 1 to a pixel because pixels are stored 8 by 8 in bytes (a byte contains 8 bits), and there is no bitwise addition.
But anyway now it's in the library and working, enjoy
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by TheTurnipKing » Sat Sep 13, 2014 6:42 am
The initial value shouldn't matter if the content of the bit is just going to be flipped, especially if you can flip the bit either way with the same operation.
I'm pretty sure Arduino has bitwise operators, but I'm not yet familar with how the Gamebuino library is mapping the screen in memory.
Rightly enough, It probably is more hassle than it's worth on a 16mhz microcontroller though. I just remember a lot of this stuff from my 3.5mhz home micro days.
-
TheTurnipKing
-
- Posts: 13
- Joined: Wed Sep 10, 2014 3:29 am
by rodot » Sat Sep 13, 2014 9:20 am
Well why not but how do you flip a single bit in a byte then ?
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
Return to Software Development
Who is online
Users browsing this forum: No registered users and 50 guests