Greetings,
I'm missing something about changing the colors in a color palette using graphx.h. So I would really appreciate it if someone would be willing to explain it to me.
From the website:
https://ce-programming.github.io/toolchain/libraries/graphx.html
"Overview" I understand that RGB colors are converted into RGB1555 colors using gfx_RGBTo1555(r,g,b); where r,g,b are the red, green, blue intensity values between 0 and 255. I want to change a color in the default color palette. As outline in the website, I would use the following code:

Code:
gfx_palette[index] = gfx_RGBTo1555(r,g,b);

From the Toolchain examples folder /library_examples/keypadc/single keys I modified the function given in that example as follows:

Code:

void FillScreen(uint16_t r,uint16_t g,uint16_t b)
{
    gfx_palette[0] = gfx_RGBTo1555(0, 255, 0);
    memset((void*)lcd_Ram,0, LCD_SIZE);
}

As a test, I replaced the variables r,g,b with the values 0.,255,0 (green).
As I understand it, according to the website,index 0, which was black should now be set to green. But, when I test it, index 0 is still black. Choosing a different index, say 224(red) will display red, not green.
I also included gfx_Begin & gfx_End inside this function which also didn't work.
Anyway, I'm sure it's something simple, but I'm just missing it.
You may want to look at the GraphX examples when it comes to doing things with GraphX.

The palettes are only relevant when the screen is set to a paletted mode, which it isn't by default (it's in a 16-bit color mode instead). The keypadc example is a little misleading in that regard, by setting every byte in the the entire 16-bit buffer to a single value, which somewhat corresponds to how the default GraphX palette is set up.

The paletted mode is only active between the calls to gfx_Begin and gfx_End, so putting those in that function won't keep the screen in that mode. You'll need to instead call them at the start and end of your entire program.

Also, the buffer size when using GraphX is half as large as the default size, so LCD_SIZE doesn't apply. You're better off using the dedicated GraphX function gfx_FillScreen, which also respects the currently configured draw buffer (since it supports double buffering).
Greetings,
I knew it was easy, I forgot that the CE was in the default 16bpp mode. I appreciate your explanation; it was very informative to me.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement