I hate to open up a 'resolved' thread, however, it seems that this library isn't working correctly or that i'm missing something. I've written up a simply menu system and all that is getting returned through serial is jibberish. can anyone help? the library i'm using is the current CMmenus one: http://crazymachine.nicolai-korff.de/downloads/crazymachine_version0.4beta.zip
i've been trying for weeks to get progmem to work with this library and can't seem to get it, i'm about to give up!
#include "CMmenus.h"
#include <avr/pgmspace.h>
PROGMEM const char a[] = "a";
PROGMEM const char b[] = "b";
PROGMEM const char c[] = "c";
PROGMEM const char d[] = "d";
//this controls the menu backend and the event generation
MenuBackend menu = MenuBackend(menuUseEvent,menuChangeEvent);
MenuItem mi_a = MenuItem(a);
MenuItem mi_b = MenuItem(b);
MenuItem mi_c = MenuItem(c);
MenuItem mi_d = MenuItem(d);
//this function builds the menu and connects the correct items together
void menuSetup()
{
Serial.println("Setting up menu...");
menu.getRoot().add(mi_a);
mi_a.add(mi_b).add(mi_c).add(mi_d);
}
void menuUseEvent(MenuUseEvent used)
{
}
void menuChangeEvent(MenuChangeEvent changed)
{
Serial.print("Menu change ");
Serial.print(changed.from.getName());
Serial.print(" ");
Serial.println(changed.to.getName());
}
void setup()
{
Serial.begin(9600);
menuSetup();
Serial.println("Starting navigation:\r\nUp: w Down: s Left: a Right: d Use: e");
}
void loop()
{
if (Serial.available()) {
byte read = Serial.read();
switch (read) {
case 'w': menu.moveUp(); break;
case 's': menu.moveDown(); break;
case 'd': menu.moveRight(); break;
case 'a': menu.moveLeft(); break;
case 'e': menu.use(); break;
}
}
}