Go Down

Topic: Printing fonts on HT1632 LED matrix (bitwise math and PROGMEM help!) (Read 710 times) previous topic - next topic

UKHeliBob

Start with the Arduino reference installed with the IDE.  Do a find on the main page and look for bitwise

You can't find anything about bitwise operators on the Internet ?
How about http://bit.ly/XraSG4 ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Abfahrt

Thanks for all the replies, my problem was easier than I thought when I was creating the post (I blame it on sleep) ]:D

I'm stuck on another problem now. I also had this problem in the past and I never solved it. My array is stored in PROGMEM, so I need to use pgm_read_byte to get the data. All I get is garbare, not what I expect and get when not using PROGMEM and pgm_read_byte (aka a simple array).

This is the routine I wrote (I don't use the panel yet). The array definition is at the top of the file.
Code: [Select]
void print_char(char c, byte height, byte width) {
  c = c - 32;
  c = c * 6;

  for (int j = 0; j < height; j++) {
    for (int i = 7; i >= 0 ; i--) {
      if ((pgm_read_byte(&font4x6[c + j + 3]) & (1 << i)) != 0) {
        Serial.print("# ");
      }
      else {
        Serial.print("@ ");
      }
    }
    Serial.println("");
  }
}


Thanks for your answers :)

PaulS

Quote
This is the routine I wrote (I don't use the panel yet). The array definition is at the top of the file.

Well, that's just ducky. You don't suppose that we need to see it, to confirm that the code is accessing the data correctly?

Quote
All I get is garbare, not what I expect and get when not using PROGMEM and pgm_read_byte (aka a simple array).

We can't confirm that you are reading the data correctly. In fact this statement implies that you are not. Without seeing the declaration, all we can do is wish you luck.

Abfahrt

The array declaration is at the first post, if that's what you mean!

EDIT: Oops, I meant at the declaration is at the top of the thread, not the file.

PaulS

If I was doing the debugging, I'd want to know that I could read the first three elements correctly.

Then, I'd want to know what c was on input to the function.

Then, I'd want to know what index I was computing for the array.

Then, I'd want to know what value I actually read from the array.

Only then would I do the bit shifting and anding.

Go Up