Chris--A / PGMWrap

A concept library for easy use of PROGMEM data.
18 stars 5 forks source link

Example doesnt compile #3

Open NicoHood opened 8 years ago

NicoHood commented 8 years ago

simple_array doesnt compile. You need to remove the 7 inside the array declaration. Downloaded via library manager 1.0.0

Also this code does not work for me:

// Magic keyword that the host sends via Serial for Adalight
//static const uint8_t magic[] PROGMEM = {'A', 'd', 'a'};

#include <PGMWrap.h>
// Magic keyword that the host sends via Serial for Adalight
uint8_p magic[] = {'A', 'd', 'a'};

It compiles with 2 bytes less and doesnt work. I did not debug it further.

What I want to achieve is to create a progmem array from a class template. Via the class template i pass a number of leds and want to create an array with the led number and other data. Is this possible?

Chris--A commented 8 years ago

Sorry, the examples have been updated and fixed, I just forgot to push a new release. Once I have my next updates finalized (hopefully tomorrow, or later today).

Also your example needs PROGMEM. This works:

#include <PGMWrap.h>

uint8_p magic[] PROGMEM = {'A', 'd', 'a'};

void setup() {

Serial.begin(9600);

  for( char c : magic ){
    Serial.println( c );
  }
}

void loop() {}

The class does not include the updates I've been working on for arrays. I'll have to post this later (after some sleep, its very early morning here...), however it will allow a few different uses which may be what you are looking for.

For now, If the data is outside the class (or static within) you can use pointers like the method shown here: https://github.com/Chris--A/PGMWrap/blob/master/examples/advanced/use_within_classes/use_within_classes.ino

But the array functionality should make things far more intuitive.

Thanks for the report.

NicoHood commented 8 years ago

The problem I am facing is to pass the data which should be inside the progmem array from the class template to the array. Meaning each class instance should have its own progmem data. Looks like this is impossible, I solved it different now.