Author Topic: STM32 bitmap hex tables  (Read 1261 times)

0 Members and 1 Guest are viewing this topic.

Offline strawberryTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: lv
STM32 bitmap hex tables
« on: August 23, 2020, 01:48:24 pm »
how to properly read/call HEX tables?
Code: [Select]
.c
const uint8_t t030rs[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //                                                         ####                                                       
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //                                                       ########                                                     
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //                                                      ###########                                                   
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //                                                    ###############                                                 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //                                                  #############
...
Code: [Select]
.h
extern const t030rs[];
Code: [Select]
void drawBitmap(int16_t x, int16_t y,  uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {

  int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
  uint8_t byte = 0;

 // startWrite();
  for (int16_t j = 0; j < h; j++, y = y + 1 ) {
    for (int16_t i = 0; i < w; i++) {
      if (i & 7)
        byte <<= 1;
     else
     byte = bitmap[j * byteWidth + i / 8];
      if (byte & 0x80)
        writePixel(x + i, y, color);
    }
  }
 // endWrite();
}
« Last Edit: August 24, 2020, 09:41:39 am by strawberry »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->