Split from: Storing large, lookup table arrays in FLASH only

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I am making lookup table for all alphabets(to be stored in flash memory) and making an array of 26x8 (26 alphabets and 8 hex code per alphabet for 8x8 alphabet on screen) . As we know pixel will get coloured there, where the value of pixel is high (in lookup table) and will remain of back ground color where value is low. So now my doubt is that by pgm_read_byte function, we are able to read lookup table at byte level (like 0xf0) but i want it to read at the bit level (1,1,1,1,0,0,0,0) , only then the pixel will be given the corresponding color value. So how will I do it? one possible method is by creating lookup table for all alphabet in form of 0 and 1 but that will be too lengthy for all characters.My aim is to display any string of user choice on tft screen 7inch (ssd1963 uC with atmega128). Please help for the sake of this discussion platform of avr freaks. thanks in advance as well!

This topic has a solution.

Kunal

Last Edited: Tue. Jul 12, 2016 - 08:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The thread is 12 years old.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You read a byte and then extract the bit(s) you want. Isn't this obvious? It's the way computers have always worked!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sir, can you please elaborate(may be by giving some example) ?!  thanks!

 

Kunal

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

KUNAL GARG wrote:

sir, can you please elaborate(may be by giving some example) ?!  thanks!

const __flash pixels[] = {
    0b10010110,
    0b01110110,
    0b11010011
};

bit = pixels[1] & (1 << 3); // get bit3 of 2nd byte

or if you insist on using PROGMEM:

#include <avr/pgmspace.h>

const PROGMEM pixels[] = {
    0b10010110,
    0b01110110,
    0b11010011
};

bit = pgm_read_byte(&pixels[1]) & (1 << 3); // get bit3 of 2nd byte

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Most Patient Man In The World. Bless You.

 

Imagecraft compiler user