Chat freely about anything...

User avatar
By Tiggr
#47196 Hello everyone
This is ny first post so please forgive me for any infringements or lack of etiquette
I have been using Arduino IDE for the last year or so and has recently converted to ESP8266
I have been trying to write byte arrays to flash using PROGMEM and I am struggling
no matter how I word my issue I cannot find anything about this anywhere (so far)
I have been trying to make Poi and can convert gifs to arrays using python quite easily
I have found I can get them to work if I omit 'PROGMEM' but rapidly run out of RAM

I am using Arduino 1.6.8
NodeMCU v1.0 ESP8266 12-E

not using PROGMEM compiles fine and runs

Sketch uses 223,733 bytes (21%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 33,488 bytes (40%) of dynamic memory, leaving 48,432 bytes for local variables. Maximum is 81,920 bytes.

changing
const uint8_t pixels02[] = {
to const uint8_t pixels02[] PROGMEM = {
and
const uint8_t pixels02[] = {
to const uint8_t pixels02[] PROGMEM = {
compiles fine
repeatedly resets

Sketch uses 223,737 bytes (21%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 31,220 bytes (38%) of dynamic memory, leaving 50,700 bytes for local variables. Maximum is 81,920 bytes.
only a 4 byte increase in used flash and a 2,268 byte decrease in ram
I have no idea what I am doing wrong
I have tried various combinations of including <pgmspace.h> and <Arduino.h> as seen on forums but to no avail

#include <Adafruit_DotStar.h>
#include <SPI.h>
//#include <Arduino.h>
//#include <pgmspace.h>
#define NUM_LEDS 36
#define DATAPIN 4
#define CLOCKPIN 5
Adafruit_DotStar strip = Adafruit_DotStar(
NUM_LEDS, DATAPIN, CLOCKPIN, DOTSTAR_BGR);
// flame1s.gif -------------------------------------------------------------
const uint8_t palette02[][3] PROGMEM = {
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 1, 0, 0 },
// array cut down so as not to take up too much space on the forum
{ 54, 54, 14 },
{ 54, 54, 29 },
{ 54, 54, 54 } };

const uint8_t pixels02[] PROGMEM = {
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00,
0X02, 0X16, 0X18, 0X10, 0X00, 0X00, 0X00, 0X00,
// array cut down so as not to take up too much space on the forum
0X1E, 0X1E, 0X18, 0X1F, 0X17, 0X16, 0X18, 0X17,
0X18, 0X17, 0X1A, 0X18, 0X00, 0X18, 0X16, 0X17,
0X17, 0X18, 0X0B, 0X00, 0X11, 0X18, 0X16, 0X1A };

byte col;
byte r;
byte g;
byte b;

void setup() {
strip.begin();
strip.show();
}

void loop() {
//Pat2
for(int Pagea = 0; Pagea < sizeof(pixels02); Pagea = Pagea + NUM_LEDS)
{
for(byte Strip = 0; Strip < NUM_LEDS; Strip++)
{
col = pixels02[Pagea + Strip];
r = palette02[col] [0];
g = palette02[col] [1];
b = palette02[col] [2];
strip.setPixelColor(Strip, r, g, b);
}
strip.show();
yield();
}
}