Skip to content

Instantly share code, notes, and snippets.

@Harakan
Last active March 11, 2016 22:56
Show Gist options
  • Save Harakan/64126de77cc83bf6f161 to your computer and use it in GitHub Desktop.
Save Harakan/64126de77cc83bf6f161 to your computer and use it in GitHub Desktop.
why won't this work, m_flags doesn't work
#ifndef _FLAGGER_H
#define _FLAGGER_H
#include <stdint.h>
#define MAX_NUM_FLAGS 8
struct Flag_info{
uint8_t id;
uint16_t trig_count;
uint8_t flag_state;
};
class Flagger
{
public:
Flagger(){
for (int i=0; i<MAX_NUM_FLAGS; i++){
m_flags[i].id=0;
m_flags[i].trig_count=0;
m_flags[i].flag_state=1;
}
m_num_flags=0;
m_max_flags=MAX_NUM_FLAGS;
};
uint8_t registerFlag(uint16_t trig_count){
m_flags[m_num_flags].id=m_num_flags;
m_flags[m_num_flags].trig_count=trig_count;
m_flags[m_num_flags].flag_state=0;
m_num_flags++;
}
uint8_t getFlag(uint8_t id){
return m_flags[id].flag_state;
}
private:
Flag_info m_flags[MAX_NUM_FLAGS];
uint8_t m_num_flags;
uint8_t m_max_flags;
};
#endif
@Harakan
Copy link
Author

Harakan commented Mar 11, 2016

g++ Flagger.cpp -o testFlag

it works now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment