Jump to content
  • 0

Pmod OLEDrgb really OLEDgrb???


KingJL

Question

I have just got the Pmod OLEDrgb running on my Cmod-A7_35t. in a microblaze application.  During testing I have noticed that the OLEDrgb_BuildRGB( R, G, B )  function is building a u16 that really results in GRB being displayed.  I assume this is related to the endianess assumed by the function.  It is no big deal... for my purposes, I can deal with it in my code, but someone might want to change the demo and documentation .

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

I just verified that it an endianess issue.  I modified the function OLEDrgb_BuildRGB( R, G, B ) in PmodOLEDrgb.c from:

u16 OLEDrgb_BuildRGB(u8 R, u8 G, u8 B) {
   return ((R >> 3) << 11) | ((G >> 2) << 5) | (B >> 3);
}
to:

u16 OLEDrgb_BuildRGB(u8 R, u8 G, u8 B) {
    u16 rgb_tmp;
    rgb_tmp = ((R >> 3) << 11) | ((G >> 2) << 5) | (B >> 3);
   return ((((rgb_tmp) >> 8 & 0xff) | (((rgb_tmp) & 0xff) << 8));
}
 Now the output colors follow what was specified in RGB order.

The code probably could use a "#ifdef { endianess }" for conditional code.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...