Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example doesnt compile #3

Open
NicoHood opened this issue Nov 18, 2015 · 2 comments
Open

Example doesnt compile #3

NicoHood opened this issue Nov 18, 2015 · 2 comments

Comments

@NicoHood
Copy link

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
Copy link
Owner

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants