PGMWrap icon indicating copy to clipboard operation
PGMWrap copied to clipboard

Example doesnt compile

Open NicoHood opened this issue 9 years ago • 2 comments

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?

NicoHood avatar Nov 18 '15 16:11 NicoHood

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.

Chris--A avatar Nov 18 '15 17:11 Chris--A

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.

NicoHood avatar Nov 19 '15 15:11 NicoHood