VFD modular clock firmware

Dependencies:   DipCortex-EEprom RTC flw mbed

Committer:
Backstr?m
Date:
Tue Feb 24 23:01:40 2015 +0900
Revision:
12:dfb422107412
Parent:
0:f6e68b4ce169
Added tag v1.0.2 for changeset 34b344fdec98

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Backstrom 0:f6e68b4ce169 1 /*
Backstrom 0:f6e68b4ce169 2 * VFD Modular Clock - mbed
Backstrom 0:f6e68b4ce169 3 * (C) 2011-14 Akafugu Corporation
Backstrom 0:f6e68b4ce169 4 *
Backstrom 0:f6e68b4ce169 5 * This program is free software; you can redistribute it and/or modify it under the
Backstrom 0:f6e68b4ce169 6 * terms of the GNU General Public License as published by the Free Software
Backstrom 0:f6e68b4ce169 7 * Foundation; either version 2 of the License, or (at your option) any later
Backstrom 0:f6e68b4ce169 8 * version.
Backstrom 0:f6e68b4ce169 9 *
Backstrom 0:f6e68b4ce169 10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
Backstrom 0:f6e68b4ce169 11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
Backstrom 0:f6e68b4ce169 12 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Backstrom 0:f6e68b4ce169 13 *
Backstrom 0:f6e68b4ce169 14 */
Backstrom 0:f6e68b4ce169 15
Backstrom 0:f6e68b4ce169 16 #ifndef MENU_H_
Backstrom 0:f6e68b4ce169 17 #define MENU_H_
Backstrom 0:f6e68b4ce169 18
Backstrom 0:f6e68b4ce169 19 // menu type
Backstrom 0:f6e68b4ce169 20 //
Backstrom 0:f6e68b4ce169 21 // custom routine (set time, set alarm)
Backstrom 0:f6e68b4ce169 22 // on-off (24h on, off)
Backstrom 0:f6e68b4ce169 23 // array of possible values (flw: off, on, full)
Backstrom 0:f6e68b4ce169 24 // range (brite 1-10)
Backstrom 0:f6e68b4ce169 25 //
Backstrom 0:f6e68b4ce169 26 // values always stored as numbers
Backstrom 0:f6e68b4ce169 27
Backstrom 0:f6e68b4ce169 28 #define MAX_BUF 9
Backstrom 0:f6e68b4ce169 29
Backstrom 0:f6e68b4ce169 30 #include "prefs.h"
Backstrom 0:f6e68b4ce169 31
Backstrom 0:f6e68b4ce169 32 class MenuItemValue {
Backstrom 0:f6e68b4ce169 33 private:
Backstrom 0:f6e68b4ce169 34 int32_t m_min;
Backstrom 0:f6e68b4ce169 35 int32_t m_max;
Backstrom 0:f6e68b4ce169 36 int32_t m_value;
Backstrom 0:f6e68b4ce169 37 bool m_activated;
Backstrom 0:f6e68b4ce169 38 public:
Backstrom 0:f6e68b4ce169 39 MenuItemValue(int32_t min, int32_t max);
Backstrom 0:f6e68b4ce169 40
Backstrom 0:f6e68b4ce169 41 int32_t getValue();
Backstrom 0:f6e68b4ce169 42 int32_t incrementValue();
Backstrom 0:f6e68b4ce169 43 void resetActive();
Backstrom 0:f6e68b4ce169 44 };
Backstrom 0:f6e68b4ce169 45
Backstrom 0:f6e68b4ce169 46 class MenuItem {
Backstrom 0:f6e68b4ce169 47 private:
Backstrom 0:f6e68b4ce169 48 char m_shortName[5];
Backstrom 0:f6e68b4ce169 49 char m_longName[MAX_BUF];
Backstrom 0:f6e68b4ce169 50 bool m_onOff;
Backstrom 0:f6e68b4ce169 51 PREFS m_pref;
Backstrom 0:f6e68b4ce169 52
Backstrom 0:f6e68b4ce169 53 MenuItemValue* m_menuItemValue;
Backstrom 0:f6e68b4ce169 54 public:
Backstrom 0:f6e68b4ce169 55 MenuItem(const char* shortName, const char* longName, bool onOff, PREFS pref);
Backstrom 0:f6e68b4ce169 56 MenuItem(const char* shortName, bool onOff, PREFS pref);
Backstrom 0:f6e68b4ce169 57
Backstrom 0:f6e68b4ce169 58 MenuItem(const char* shortName, const char* longName, int32_t min, int32_t max, PREFS pref);
Backstrom 0:f6e68b4ce169 59 MenuItem(const char* shortName, int32_t min, int32_t max, PREFS pref);
Backstrom 0:f6e68b4ce169 60
Backstrom 0:f6e68b4ce169 61 const char* getName(uint8_t digits) const;
Backstrom 0:f6e68b4ce169 62 const char* selectValue(uint8_t digits) const;
Backstrom 0:f6e68b4ce169 63 void resetActive() const;
Backstrom 0:f6e68b4ce169 64
Backstrom 0:f6e68b4ce169 65 bool isSetTimeTrigger() const { return m_pref == PREF_SET_TIME; }
Backstrom 0:f6e68b4ce169 66 bool isSetAlarmTrigger() const { return m_pref == PREF_SET_ALARM; }
Backstrom 0:f6e68b4ce169 67 };
Backstrom 0:f6e68b4ce169 68
Backstrom 0:f6e68b4ce169 69 class Menu {
Backstrom 0:f6e68b4ce169 70 private:
Backstrom 0:f6e68b4ce169 71 uint8_t m_position;
Backstrom 0:f6e68b4ce169 72 uint8_t m_size;
Backstrom 0:f6e68b4ce169 73 uint8_t m_digits;
Backstrom 0:f6e68b4ce169 74
Backstrom 0:f6e68b4ce169 75 public:
Backstrom 0:f6e68b4ce169 76 Menu();
Backstrom 0:f6e68b4ce169 77
Backstrom 0:f6e68b4ce169 78 void setDigits(uint8_t digits) { m_digits = digits; }
Backstrom 0:f6e68b4ce169 79
Backstrom 0:f6e68b4ce169 80 const char* reset();
Backstrom 0:f6e68b4ce169 81 const char* next();
Backstrom 0:f6e68b4ce169 82 const char* select(bool& enterSetTime, bool& enterSetAlarm);
Backstrom 0:f6e68b4ce169 83 void leave();
Backstrom 0:f6e68b4ce169 84 };
Backstrom 0:f6e68b4ce169 85
Backstrom 0:f6e68b4ce169 86 #endif // MENU_H_