arduino - data v PROGMEM

Jaroslav Lukesh lukesh na seznam.cz
Pondělí Listopad 3 20:17:57 CET 2014


http://arduino.cc/en/Reference/PROGMEM

Example

The following code fragments illustrate how to read and write unsigned chars 
(bytes) and ints (2 bytes) to PROGMEM.

#include <avr/pgmspace.h>


// save some unsigned ints
PROGMEM  prog_uint16_t charSet[]  = { 65000, 32796, 16843, 10, 11234};

// save some chars
prog_uchar signMessage[] PROGMEM  = {"I AM PREDATOR,  UNSEEN COMBATANT. 
CREATED BY THE UNITED STATES DEPART"};

unsigned int displayInt;
int k;    // counter variable
char myChar;

// read back a 2-byte int
 displayInt = pgm_read_word_near(charSet + k)

// read back a char
myChar =  pgm_read_byte_near(signMessage + k);




----- Původní zpráva ----- 
Od: "Petr Zapadlo" <zapik na email.cz>


> potřeboval bych popostrčit. Mám displej s řadičem DIGOLE. Byly k němu 
> knihovny  a teď se to pokouším rozdýchat. A havaruji na definici dat v 
> PROGMEM.
>
> Inkriminovaná část kodu z příkladu:
>
> prog_uchar welcomeimage[] PROGMEM = {
>     0, 0, 0, 0, 0, 127
>     , 0, 8, 1, 2, 0, 127
>     , 0, 8, 0, 148, 0, 127
>
> Při kompilaci to hází chybu "variable ‘welcomeimage’ must be const in 
> order to be put into read-only section by means of 
> ‘__attribute__((progmem))’"
>
> Tuším, že to souvisí s blbým zápisem, ale nepovedlo se mi to zapsat tak, 
> aby to prošlo.
>
> Co je blbě?
>
> Díky
>
> Petr
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list na list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list
> 



Další informace o konferenci Hw-list