VFD modular clock firmware
Dependencies: DipCortex-EEprom RTC flw mbed
global.h@9:4bb5c30a475f, 2015-02-20 (annotated)
- Committer:
- Backstrom
- Date:
- Fri Feb 20 10:08:50 2015 +0000
- Revision:
- 9:4bb5c30a475f
- Parent:
- 0:f6e68b4ce169
Update flw library.
Who changed what in which revision?
User | Revision | Line number | New 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 | #include "mbed.h" |
Backstrom | 0:f6e68b4ce169 | 17 | |
Backstrom | 0:f6e68b4ce169 | 18 | /// VFD Modular Clock - SMT mbed IV-18 |
Backstrom | 0:f6e68b4ce169 | 19 | #if defined(TARGET_LPC11U24) || defined(TARGET_LPC1347) |
Backstrom | 0:f6e68b4ce169 | 20 | |
Backstrom | 0:f6e68b4ce169 | 21 | #define FEATURE_3BUTTON YES |
Backstrom | 0:f6e68b4ce169 | 22 | #define FEATURE_GPS YES |
Backstrom | 0:f6e68b4ce169 | 23 | #define FEATURE_DS1302 NO |
Backstrom | 0:f6e68b4ce169 | 24 | #define FEATURE_DS3231M YES |
Backstrom | 0:f6e68b4ce169 | 25 | |
Backstrom | 0:f6e68b4ce169 | 26 | struct PinMap { |
Backstrom | 0:f6e68b4ce169 | 27 | static const PinName data = P0_18; |
Backstrom | 0:f6e68b4ce169 | 28 | static const PinName clock = P0_17; |
Backstrom | 0:f6e68b4ce169 | 29 | static const PinName latch = P0_19; |
Backstrom | 0:f6e68b4ce169 | 30 | static const PinName blank = P0_13; |
Backstrom | 0:f6e68b4ce169 | 31 | |
Backstrom | 0:f6e68b4ce169 | 32 | static const PinName button2 = P1_28; // button |
Backstrom | 0:f6e68b4ce169 | 33 | static const PinName button1 = P0_7; // button |
Backstrom | 0:f6e68b4ce169 | 34 | static const PinName button3 = P0_1; // button |
Backstrom | 0:f6e68b4ce169 | 35 | |
Backstrom | 0:f6e68b4ce169 | 36 | // RTC |
Backstrom | 0:f6e68b4ce169 | 37 | static const PinName sda = P0_5; |
Backstrom | 0:f6e68b4ce169 | 38 | static const PinName scl = P0_4; |
Backstrom | 0:f6e68b4ce169 | 39 | |
Backstrom | 0:f6e68b4ce169 | 40 | // Other |
Backstrom | 0:f6e68b4ce169 | 41 | static const PinName piezo = P0_9; |
Backstrom | 0:f6e68b4ce169 | 42 | static const PinName led = P1_16; |
Backstrom | 0:f6e68b4ce169 | 43 | //static const PinName tx = P1_13; |
Backstrom | 0:f6e68b4ce169 | 44 | //static const PinName rx = P1_14; |
Backstrom | 0:f6e68b4ce169 | 45 | static const PinName ext1 = P1_19; |
Backstrom | 0:f6e68b4ce169 | 46 | static const PinName ext2 = P1_20; |
Backstrom | 0:f6e68b4ce169 | 47 | }; |
Backstrom | 0:f6e68b4ce169 | 48 | |
Backstrom | 0:f6e68b4ce169 | 49 | #endif |
Backstrom | 0:f6e68b4ce169 | 50 | |
Backstrom | 0:f6e68b4ce169 | 51 | /// VFD Modular Clock - mbed test board |
Backstrom | 0:f6e68b4ce169 | 52 | #ifdef TARGET_LPC1114 |
Backstrom | 0:f6e68b4ce169 | 53 | |
Backstrom | 0:f6e68b4ce169 | 54 | #define FEATURE_3BUTTON NO |
Backstrom | 0:f6e68b4ce169 | 55 | #define FEATURE_GPS YES |
Backstrom | 0:f6e68b4ce169 | 56 | #define FEATURE_DS1302 NO |
Backstrom | 0:f6e68b4ce169 | 57 | #define FEATURE_DS3231M YES |
Backstrom | 0:f6e68b4ce169 | 58 | |
Backstrom | 0:f6e68b4ce169 | 59 | struct PinMap { |
Backstrom | 0:f6e68b4ce169 | 60 | // VFD Driver |
Backstrom | 0:f6e68b4ce169 | 61 | static const PinName data = dp14; |
Backstrom | 0:f6e68b4ce169 | 62 | static const PinName clock = dp10; |
Backstrom | 0:f6e68b4ce169 | 63 | static const PinName latch = dp13; |
Backstrom | 0:f6e68b4ce169 | 64 | static const PinName blank = dp1; |
Backstrom | 0:f6e68b4ce169 | 65 | |
Backstrom | 0:f6e68b4ce169 | 66 | // Buttons / switches |
Backstrom | 0:f6e68b4ce169 | 67 | static const PinName button1 = dp26; // button |
Backstrom | 0:f6e68b4ce169 | 68 | static const PinName button2 = dp24; // button |
Backstrom | 0:f6e68b4ce169 | 69 | static const PinName button3 = dp28; // switch |
Backstrom | 0:f6e68b4ce169 | 70 | |
Backstrom | 0:f6e68b4ce169 | 71 | // Board signature |
Backstrom | 0:f6e68b4ce169 | 72 | static const PinName sig0 = dp4; |
Backstrom | 0:f6e68b4ce169 | 73 | static const PinName sig1 = dp2; |
Backstrom | 0:f6e68b4ce169 | 74 | static const PinName sig2 = dp6; |
Backstrom | 0:f6e68b4ce169 | 75 | |
Backstrom | 0:f6e68b4ce169 | 76 | // Other |
Backstrom | 0:f6e68b4ce169 | 77 | static const PinName piezo = dp18; |
Backstrom | 0:f6e68b4ce169 | 78 | static const PinName led = dp25; |
Backstrom | 0:f6e68b4ce169 | 79 | static const PinName sqw = dp17; |
Backstrom | 0:f6e68b4ce169 | 80 | static const PinName tx = dp16; |
Backstrom | 0:f6e68b4ce169 | 81 | static const PinName rx = dp16; |
Backstrom | 0:f6e68b4ce169 | 82 | static const PinName ext1 = dp9; |
Backstrom | 0:f6e68b4ce169 | 83 | static const PinName ext2 = dp11; |
Backstrom | 0:f6e68b4ce169 | 84 | }; |
Backstrom | 0:f6e68b4ce169 | 85 | |
Backstrom | 0:f6e68b4ce169 | 86 | #endif |
Backstrom | 0:f6e68b4ce169 | 87 | |
Backstrom | 0:f6e68b4ce169 | 88 | /// VFD Modular Clock - mbed test board |
Backstrom | 0:f6e68b4ce169 | 89 | #ifdef TARGET_LPC1549 |
Backstrom | 0:f6e68b4ce169 | 90 | |
Backstrom | 0:f6e68b4ce169 | 91 | #define FEATURE_3BUTTON NO |
Backstrom | 0:f6e68b4ce169 | 92 | #define FEATURE_GPS NO |
Backstrom | 0:f6e68b4ce169 | 93 | #define FEATURE_DS1302 NO |
Backstrom | 0:f6e68b4ce169 | 94 | #define FEATURE_DS3231M YES |
Backstrom | 0:f6e68b4ce169 | 95 | |
Backstrom | 0:f6e68b4ce169 | 96 | struct PinMap { |
Backstrom | 0:f6e68b4ce169 | 97 | // VFD Driver |
Backstrom | 0:f6e68b4ce169 | 98 | static const PinName data = A5; |
Backstrom | 0:f6e68b4ce169 | 99 | static const PinName clock = D13; // P0_16 |
Backstrom | 0:f6e68b4ce169 | 100 | static const PinName latch = A4; |
Backstrom | 0:f6e68b4ce169 | 101 | static const PinName blank = D5; |
Backstrom | 0:f6e68b4ce169 | 102 | /* |
Backstrom | 0:f6e68b4ce169 | 103 | static const PinName data = P0_22; // A5 |
Backstrom | 0:f6e68b4ce169 | 104 | static const PinName clock = P0_16; // D13 |
Backstrom | 0:f6e68b4ce169 | 105 | static const PinName latch = P0_23; // A4 |
Backstrom | 0:f6e68b4ce169 | 106 | static const PinName blank = P0_16; // D5 |
Backstrom | 0:f6e68b4ce169 | 107 | */ |
Backstrom | 0:f6e68b4ce169 | 108 | |
Backstrom | 0:f6e68b4ce169 | 109 | // Buttons / switches |
Backstrom | 0:f6e68b4ce169 | 110 | static const PinName button1 = D8; |
Backstrom | 0:f6e68b4ce169 | 111 | static const PinName button2 = D7; |
Backstrom | 0:f6e68b4ce169 | 112 | static const PinName button3 = D2; |
Backstrom | 0:f6e68b4ce169 | 113 | /* |
Backstrom | 0:f6e68b4ce169 | 114 | static const PinName button1 = P0_24; // button D8 |
Backstrom | 0:f6e68b4ce169 | 115 | static const PinName button2 = P0_0; // button D7 |
Backstrom | 0:f6e68b4ce169 | 116 | static const PinName button3 = P0_29; // switch D2 |
Backstrom | 0:f6e68b4ce169 | 117 | */ |
Backstrom | 0:f6e68b4ce169 | 118 | |
Backstrom | 0:f6e68b4ce169 | 119 | // Board signature |
Backstrom | 0:f6e68b4ce169 | 120 | static const PinName sig0 = A0; //P0_8 |
Backstrom | 0:f6e68b4ce169 | 121 | static const PinName sig1 = A1; //P0_7 |
Backstrom | 0:f6e68b4ce169 | 122 | static const PinName sig2 = A2; //P0_6 |
Backstrom | 0:f6e68b4ce169 | 123 | |
Backstrom | 0:f6e68b4ce169 | 124 | // Other |
Backstrom | 0:f6e68b4ce169 | 125 | static const PinName piezo = D4; // P0_10 |
Backstrom | 0:f6e68b4ce169 | 126 | static const PinName led = D9; // P1_0 |
Backstrom | 0:f6e68b4ce169 | 127 | //static const PinName sqw = P1_3; // D6 |
Backstrom | 0:f6e68b4ce169 | 128 | //static const PinName tx = P0_18; // D1 |
Backstrom | 0:f6e68b4ce169 | 129 | //static const PinName rx = P0_13; // D0 |
Backstrom | 0:f6e68b4ce169 | 130 | static const PinName ext1 = A3; // P0_5 |
Backstrom | 0:f6e68b4ce169 | 131 | static const PinName ext2 = D3; // P1_2 |
Backstrom | 0:f6e68b4ce169 | 132 | |
Backstrom | 0:f6e68b4ce169 | 133 | // I2C |
Backstrom | 0:f6e68b4ce169 | 134 | //static const PinName sda = |
Backstrom | 0:f6e68b4ce169 | 135 | //static const PinName scl = |
Backstrom | 0:f6e68b4ce169 | 136 | }; |
Backstrom | 0:f6e68b4ce169 | 137 | |
Backstrom | 0:f6e68b4ce169 | 138 | #endif |
Backstrom | 0:f6e68b4ce169 | 139 | |
Backstrom | 0:f6e68b4ce169 | 140 | |
Backstrom | 0:f6e68b4ce169 | 141 | /// VFD Modular Clock - BLE |
Backstrom | 0:f6e68b4ce169 | 142 | #ifdef TARGET_NRF51822 |
Backstrom | 0:f6e68b4ce169 | 143 | |
Backstrom | 0:f6e68b4ce169 | 144 | #define FEATURE_3BUTTON NO |
Backstrom | 0:f6e68b4ce169 | 145 | #define FEATURE_GPS NO |
Backstrom | 0:f6e68b4ce169 | 146 | #define FEATURE_DS1302 NO |
Backstrom | 0:f6e68b4ce169 | 147 | #define FEATURE_DS3231M YES |
Backstrom | 0:f6e68b4ce169 | 148 | |
Backstrom | 0:f6e68b4ce169 | 149 | struct PinMap { |
Backstrom | 0:f6e68b4ce169 | 150 | static const PinName data = P0_15; |
Backstrom | 0:f6e68b4ce169 | 151 | static const PinName clock = P0_12; |
Backstrom | 0:f6e68b4ce169 | 152 | static const PinName latch = P0_13; |
Backstrom | 0:f6e68b4ce169 | 153 | static const PinName blank = P0_13; |
Backstrom | 0:f6e68b4ce169 | 154 | |
Backstrom | 0:f6e68b4ce169 | 155 | static const PinName button1 = P0_1; |
Backstrom | 0:f6e68b4ce169 | 156 | static const PinName button2 = P0_1; |
Backstrom | 0:f6e68b4ce169 | 157 | }; |
Backstrom | 0:f6e68b4ce169 | 158 | |
Backstrom | 0:f6e68b4ce169 | 159 | #endif |
Backstrom | 0:f6e68b4ce169 | 160 | |
Backstrom | 0:f6e68b4ce169 | 161 | #include "features.h" |
Backstrom | 0:f6e68b4ce169 | 162 | |
Backstrom | 0:f6e68b4ce169 | 163 | // display state |
Backstrom | 0:f6e68b4ce169 | 164 | typedef enum { |
Backstrom | 0:f6e68b4ce169 | 165 | // basic states |
Backstrom | 0:f6e68b4ce169 | 166 | STATE_CLOCK = 0, // shows hh-mm-ss / hh.mm.ss / hh.mm.ss.x depending on g_display_mode |
Backstrom | 0:f6e68b4ce169 | 167 | STATE_SHOW_ALARM, // shows current alarm for a brief time |
Backstrom | 0:f6e68b4ce169 | 168 | STATE_ALARMING, // alarm is going off |
Backstrom | 0:f6e68b4ce169 | 169 | STATE_AUTO_DATE, // scroll date across the screen |
Backstrom | 0:f6e68b4ce169 | 170 | STATE_AUTO_FLW, // show FLW briefly |
Backstrom | 0:f6e68b4ce169 | 171 | STATE_AUTO_TEMP, // show temperature briefly |
Backstrom | 0:f6e68b4ce169 | 172 | STATE_SET_ALARM_HH, // set alarm, hours |
Backstrom | 0:f6e68b4ce169 | 173 | STATE_SET_ALARM_MM, // set alarm, minutes |
Backstrom | 0:f6e68b4ce169 | 174 | STATE_SET_CLOCK_HH, // set clock, hours |
Backstrom | 0:f6e68b4ce169 | 175 | STATE_SET_CLOCK_MM, // set clock, minutes |
Backstrom | 0:f6e68b4ce169 | 176 | STATE_SET_CLOCK_SS, // set clock, seconds |
Backstrom | 0:f6e68b4ce169 | 177 | STATE_FLW, // four letter word |
Backstrom | 0:f6e68b4ce169 | 178 | STATE_TEMP, // temperature |
Backstrom | 0:f6e68b4ce169 | 179 | STATE_MENU, // menu |
Backstrom | 0:f6e68b4ce169 | 180 | } state_t; |