PROGMEM problem with structs
this code used work has stopped working , "warning: '__progmem__' attribute ignored [-wattributes]" message:
class commandcodes {
public:
// destructor
~commandcodes() {};
struct commandcode {
int code;
const char *name;
} commandcode;
const commandcode commands[last_command] progmem = {
{ cmd_demo, "demo" } ,
{ cmd_stop, "stop" } ,
{ cmd_forward, "forward" },
{ cmd_backward, "backward" },
{ cmd_turn_left, "turn left" },
{ cmd_turn_right, "turn right" },
{ cmd_spin_left, "spin left" },
{ cmd_spin_right, "spin right" },
{ cmd_left_forward, "left forward" },
{ cmd_left_backward, "left backward" },
{ cmd_left_stop, "left stop" },
{ cmd_right_forward, "right forward" },
{ cmd_right_backward, "right backward" },
{ cmd_right_stop, "right stop" },
{ cmd_wait, "wait" },
{ cmd_wait_done, "wait done" },
{ cmd_motor_diags, "motor diagnostics " },
{ cmd_led_diags, "led diagnostics" },
{ cmd_servo_diags, "servo diagnostics" },
{ cmd_ods_diags, "sensor diagnostics" },
};
class commandcodes {
public:
// destructor
~commandcodes() {};
struct commandcode {
int code;
const char *name;
} commandcode;
const commandcode commands[last_command] progmem = {
{ cmd_demo, "demo" } ,
{ cmd_stop, "stop" } ,
{ cmd_forward, "forward" },
{ cmd_backward, "backward" },
{ cmd_turn_left, "turn left" },
{ cmd_turn_right, "turn right" },
{ cmd_spin_left, "spin left" },
{ cmd_spin_right, "spin right" },
{ cmd_left_forward, "left forward" },
{ cmd_left_backward, "left backward" },
{ cmd_left_stop, "left stop" },
{ cmd_right_forward, "right forward" },
{ cmd_right_backward, "right backward" },
{ cmd_right_stop, "right stop" },
{ cmd_wait, "wait" },
{ cmd_wait_done, "wait done" },
{ cmd_motor_diags, "motor diagnostics " },
{ cmd_led_diags, "led diagnostics" },
{ cmd_servo_diags, "servo diagnostics" },
{ cmd_ods_diags, "sensor diagnostics" },
};
this code used work has stopped working , "warning: '__progmem__' attribute ignored [-wattributes]" message:
this code used work has stopped working , "warning: '__progmem__' attribute ignored [-wattributes]" message:
commandcodes.h:
commandcodes.cpp
i have read nick gammon's great post about progmem. still missing critical.
this code used work has stopped working , "warning: '__progmem__' attribute ignored [-wattributes]" message:
commandcodes.h:
code: [select]
class commandcodes {
public:
// destructor
~commandcodes() {};
struct commandcode {
int code;
const char *name;
} commandcode;
const commandcode commands[last_command] progmem = {
{ cmd_demo, "demo" } ,
{ cmd_stop, "stop" } ,
{ cmd_forward, "forward" },
{ cmd_backward, "backward" },
{ cmd_turn_left, "turn left" },
{ cmd_turn_right, "turn right" },
{ cmd_spin_left, "spin left" },
{ cmd_spin_right, "spin right" },
{ cmd_left_forward, "left forward" },
{ cmd_left_backward, "left backward" },
{ cmd_left_stop, "left stop" },
{ cmd_right_forward, "right forward" },
{ cmd_right_backward, "right backward" },
{ cmd_right_stop, "right stop" },
{ cmd_wait, "wait" },
{ cmd_wait_done, "wait done" },
{ cmd_motor_diags, "motor diagnostics " },
{ cmd_led_diags, "led diagnostics" },
{ cmd_servo_diags, "servo diagnostics" },
{ cmd_ods_diags, "sensor diagnostics" },
};
// checks valid command code
bool isvalid(int code);
// prints name associated code
void name(int code);
// prints commands
void show();
// prints command code , name
void showcommand(commandcode cmd);
// prints command code , name
void showcommand(int code, const char* name);
};
commandcodes.cpp
code: [select]
#include "commandcodes.h"
bool commandcodes::isvalid(int code) {
for (int = first_command; < last_command; i++) {
if (commands[i].code == code) {
return true;
}
}
return false;
}
void commandcodes::name(int code) {
for (int = first_command; < last_command; i++) {
if (commands[i].code == code) {
serial.print (commands[i].name);
return;
}
}
}
void commandcodes::show() {
serial.print(last_command);
serial.println(f(" comands defined:"));
for (int = first_command; < last_command; i++) {
showcommand(commands[i].code, commands[i].name);
}
}
void commandcodes::showcommand(commandcode cmd) {
showcommand(cmd.code, cmd.name);
}
void commandcodes::showcommand(int code, const char* name) {
if (code > first_command) {
serial.print(f("["));
serial.print(code);
serial.print(f("] "));
serial.println(name);
}
}
i have read nick gammon's great post about progmem. still missing critical.
Arduino Forum > Using Arduino > Programming Questions > PROGMEM problem with structs
arduino
Comments
Post a Comment