#include "MenuItem.h" #include "Arduino.h" MenuItem::MenuItem() { } MenuItem::MenuItem(const char* name) { MenuItem::name = name; MenuItem::parent = NULL; MenuItem::next = NULL; } MenuItem* MenuItem::goBack() { return MenuItem::parent; } MenuItem* MenuItem::goDown() { return MenuItem::next; } MenuItem* MenuItem::goRight() { return NULL; } void MenuItem::selectLeft() { } void MenuItem::selectRight() { } bool MenuItem::select() { // returns wether it makes sense to 'select' this item return false; } String MenuItem::display() { return MenuItem::name; } BranchMenuItem::BranchMenuItem(const char* name, const MenuItem* child) { BranchMenuItem::name = name; BranchMenuItem::child = child; } MenuItem* BranchMenuItem::goRight() { return BranchMenuItem::child; } String BranchMenuItem::display() { return String(BranchMenuItem::name) + " ->"; } IntValueItem::IntValueItem(char const* name, int initial, int min, int max) { IntValueItem::name = name; IntValueItem::value = initial; IntValueItem::min = min; IntValueItem::max = max; } void IntValueItem::selectRight() { // increment if (IntValueItem::value < IntValueItem::max){ IntValueItem::value++; } } void IntValueItem::selectLeft() { // increment if (IntValueItem::value > IntValueItem::min){ IntValueItem::value--; } } String IntValueItem::display() { return String(IntValueItem::name) + "\n" + String(IntValueItem::value); } bool IntValueItem::select() { return true; } BoolValueItem::BoolValueItem(char const* name, bool initial) { BoolValueItem::name = name; BoolValueItem::value = initial; } void BoolValueItem::selectRight() { // toggle BoolValueItem::value = !BoolValueItem::value; } void BoolValueItem::selectLeft() { // toggle BoolValueItem::value = !BoolValueItem::value; } String BoolValueItem::display() { return String(BoolValueItem::name) + "\n" + (BoolValueItem::value ? "true" : "false"); } bool BoolValueItem::select() { return true; }