Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: August 13, 2013, 04:02:06 pm
solved smiley-lol
Thanks Nick Gammon,

I controlled my code a couple of times, but I've always overseen this error. Clearly it has to be:
Code:
byte length = pgm_read_byte(&_character [0]);  // first byte Indicates width of character

Sometimes only one line of code can temporarily ruin one's ambition. Now the work on my project can go on  smiley-lol.
2  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: August 13, 2013, 03:35:46 pm
How is your "const byte _character []" declared?  I hope it is:
Code:
const byte _character [] PROGMEM = {...};

Hi Johnwasser,

I don't really get what you mean smiley-red. Should I change my function declaration to this:
Code:
void Display_printChar(byte _x, byte _y,  const byte _character [] PROGMEM, byte _size, int _color, int _background) {

However, my entire code is placed as an attachment some posts earlier (I added the declaration of my characters as a comment at the end of the file).

3  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: August 13, 2013, 03:26:57 pm
My (wild) guess is the bitRead() function isn't able to address PROGMEM.

Thanks tylernt,
I tried out what you suggested, but it didnt solve the probloem. I'm getting random pixels as before.
4  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: August 13, 2013, 08:15:27 am
Any help is welcome  smiley
5  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: July 31, 2013, 02:15:15 pm
The whole display library is in the attachments.
Note that I put the array data at the bottom, it is normally the very first thing in my whole program.

Consider that the code worked perfectely with array in RAM.

However, that's the entire function used to draw a character or symbol:
Note that the first byte of my array data tells the width of the character.

Thanks smiley-wink

Code:
/*
╔═══════════════════════════════════════════════════════════════════════╗
║  print single Char                                                    ║
╚═══════════════════════════════════════════════════════════════════════╝
*/

void Display_printChar(byte _x, byte _y,  const byte _character [], byte _size, int _color, int _background) {
  
  byte length = _character [0];  // first byte indicates width of character
  byte countByte = 1;
  byte countBit = 0;
  
  // Setting the starting pixel
  writeCommand(SSD1331_CMD_SETCOLUMN);
  writeCommand(_x);
  writeCommand(95);

  writeCommand(SSD1331_CMD_SETROW);
  writeCommand(_y);
  writeCommand(63);
  
  
  for (byte row = 0; row < (15- (7 * _size)); row++) {
    
    for (byte column = 0; column < length; column++) {
      
      if ((column < (((length-1)/2)+1)) || (!_size))
      {
        //if (bitRead(_character [countByte], 7 - countBit)) {     // uncomment this line when Array is located in RAM
        if (bitRead(pgm_read_byte(&_character[countByte]), 7 - countBit)) {  // uncomment this line when Array is located in PROGMEM
          writeData(_color);
        }
        else {
          writeData(_background);
        }
      }
      
      countBit = countBit + 1 + _size;
      
      if (countBit == 8)  {
        countBit = 0;
        countByte++;
      }
    }
    
    // next pixel row:
    writeCommand(SSD1331_CMD_SETCOLUMN);
    writeCommand(_x);
    writeCommand(95);
    
    _y++;
    writeCommand(SSD1331_CMD_SETROW);
    writeCommand(_y);
    writeCommand(63);
    
  }
}


6  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: July 31, 2013, 09:18:20 am
Why don't I use only one array? Because the arrays have different sizes. By combining them together I would waste a large amount of data.

You could have an array of pointers that points to your other arrays Numbers, Letters etc. Look at the exemple Arrays of strings in http://arduino.cc/en/Reference/PROGMEM

Thanks, I didn't know that. But what would that change in my example?
7  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: July 31, 2013, 08:57:48 am
I've read this post: http://forum.arduino.cc/index.php?topic=45681.0. So far so good. But how do I use the "pgm_read_byte()"-function In my example, my DrawNumber function gets only one dimension of the font array.     

Maybe change the function prototype to DrawNumber( byte number ) and you call it with DrawNumber(1) instead of DrawNumber(Numbers[1]). Of course you need to modify the function by adding something like..
Code:
byte pixelsData = pgm_read_byte(&(Numbers[number][bytecount]));
boolean _pixel = bitRead(pixelsData, bitcount);

Thanks guix for your answer, but I can't do this because of this reason:
Beside the Numbers Array I have to pass Also other arrays to the Funktion, like letters[] or Symbols[] and so on.
Why don't I use only one array? Because the arrays have different sizes. By combining them together I would waste a large amount of data.

I'll post my entire code as soon as I'm at home.
8  Using Arduino / Programming Questions / Re: problem with two-dimensional array in progmem on: July 30, 2013, 11:47:13 pm
Thanks for your reply, johnwasser

But that doesn't work. I'm only getting garbage pixels on my display.
I think I've used the PROGMEM Keyword correctely:
Code:
const byte Numberss [] [10] PROGMEM = {

Do I have to modify this line too?
Code:
DrawNumber(Numbers[1]); // Im passing only one dimension of the array
9  Using Arduino / Programming Questions / [SOLVED] problem with two-dimensional array in progmem on: July 30, 2013, 03:33:46 pm
Hi arduino fans,

I'm currently working on a project that uses a graphical display. Up to now I've put my array for the fonts in the RAM-space. However the space is getting full now and I decided to move all my font-data to the progmem space. The problem is that I use a two-dimensional Array (One dimension for the Symbol, the other for the pixel-data) and I have to pass the array to different functions.
A (simplified) example:

Code:
const byte Numberss [] [10] = {    
   { 0x3F, 0x65, 0x67, },              // Pixel data for number 0
   { 0x4C, 0x67, 0xE4, },              // Pixel data for number 1
              //...
};

In main loop I call this function:

Code:
DrawNumber(Numbers[1]); // Im passing only one dimension of the array

Then the function does:

Code:
void DrawNumber(const byte _numb[]) {
 
  for(int bytecount = 0; bytecount < 3, bytecount++) {     //scan through all bytes
    for(int bitcount = 0; bitcount < 8, bitcount++) {         //scan through all bits
      boolean _pixel = bitRead(_numb[bytecount], bitcount);
      // Stuff that draws Pixel on display
    }
  }
}

I've read this post: http://forum.arduino.cc/index.php?topic=45681.0. So far so good. But how do I use the "pgm_read_byte()"-function In my example, my DrawNumber function gets only one dimension of the font array.

Any guesses are appreciated.

Thanks in advance, Andy

                                      
              
10  Using Arduino / Microcontrollers / Re: ATmega2560 custom board problem on: March 30, 2013, 03:37:24 am
Hi.
Your problem seems like one I recently had too:

http://arduino.cc/forum/index.php/topic,156818.0.html

Thanks for your feedback, did your firmwares run on the platform even though you got the verification fail error?

Cheers

Yes, on mine the arduino bootloader was installed correctly, even though the error message appeared.
Have you tried to upload an arduino sketch via serial?
11  Using Arduino / Microcontrollers / Re: ATmega2560 custom board problem on: March 29, 2013, 03:04:37 am
Hi.
Your problem seems like one I recently had too:

http://arduino.cc/forum/index.php/topic,156818.0.html
12  Using Arduino / Microcontrollers / Re: ATMEGA2560 bootloading problem on: March 29, 2013, 02:59:48 am
Hi westf,

...that was actually the case  smiley-wink
I tried uploading and it actually works just fine.

However that means I spent about one full day solving a problem that didn't really exist. smiley-sad

Thanks for your explanation.
13  Using Arduino / Microcontrollers / ATMEGA2560 bootloading problem on: March 27, 2013, 12:46:13 pm
Hi everyone,
Today I tried to upload the Arduino bootloader onto my self made arduino-compatible-mega-board. I used my present arduino to upload it. After 4minutes of uploading I got an error: "Error while burning bootloader, avrdude.exe: verification error, first mismatch at byte 0x1e000".
I got the same error after 3 other uploading attempts. However, I tried to find something in the avrdude output. For me it seems like the communication with the ATMEGA2560 is working, avrdude sends the hexfile. But at the data-verification-procedure, the uC seems to send only FFs.
An other hint: The LED on pin 13 "doubleblinks" recurrently after uploading.

The full AVRdude Output is in the attachments.
 
Anybody knows whats going on?

Thanks in advance, Andy
Pages: [1]