Hello la commu !
J'ai un souci avec un projet (relativement gros), qui fait que je dois utiliser PROGMEM car la RAM n'est malheureusement pas infinie :-/
Du coup, je charge mes array() avec PROGMEM mais j'ai un souci "bizarre"...
J'ai isolé le problème avec le bout de code suivant:
#include "Arduino.h"
#include <avr/pgmspace.h>
const unsigned short black_img[0x16] PROGMEM = {
0x0000,0x0000,0x0000,0xF800,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
};
void drawImage(const uint16_t x, const uint16_t y, const unsigned int data[], int size) {
size = size / sizeof(data[0]);
for (int i=0; i<size; i++) {
Serial.print("i="); Serial.print(i); Serial.print (">"); Serial.print(String(data[i])); Serial.print(" ");
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
drawImage(100, 100, black_img, sizeof(black_img));
while(1) {}
}
La sortie debug me donne ça:
i=0>47288 i=1>47288 i=2>47288 i=3>47288 i=4>47288 i=5>47288 i=6>47288 i=7>47288 i=8>47288 i=9>47288 i=10>47288 i=11>47288 i=12>13621 i=13>47288 i=14>120 i=15>0 i=16>0 i=17>0 i=18>256 i=19>0 i=20>47288 i=21>47288
Rien à voir avec l'array d'origine :s
Je me suis planté, c'est sûr mais où ? J'ai jamais utilisé PROGMEM ...
Thanks in advance