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 PREFS_H_
Backstrom 0:f6e68b4ce169 17 #define PREFS_H_
Backstrom 0:f6e68b4ce169 18
Backstrom 0:f6e68b4ce169 19 const uint8_t PREFS_SIZE = 12;
Backstrom 0:f6e68b4ce169 20
Backstrom 0:f6e68b4ce169 21 enum PREFS {
Backstrom 0:f6e68b4ce169 22 PREF_24H = 0,
Backstrom 0:f6e68b4ce169 23 PREF_BRIGHTNESS,
Backstrom 0:f6e68b4ce169 24 PREF_ALARM,
Backstrom 0:f6e68b4ce169 25 PREF_DOTS,
Backstrom 0:f6e68b4ce169 26 PREF_GPS,
Backstrom 0:f6e68b4ce169 27 PREF_GPS_TZH,
Backstrom 0:f6e68b4ce169 28 PREF_GPS_TZM,
Backstrom 0:f6e68b4ce169 29 PREF_AUTODATE,
Backstrom 0:f6e68b4ce169 30 PREF_FLW,
Backstrom 0:f6e68b4ce169 31 // Prefs that are not saved to eeprom
Backstrom 0:f6e68b4ce169 32 PREF_SET_TIME,
Backstrom 0:f6e68b4ce169 33 PREF_SET_ALARM,
Backstrom 0:f6e68b4ce169 34 PREF_YEAR,
Backstrom 0:f6e68b4ce169 35 PREF_MONTH,
Backstrom 0:f6e68b4ce169 36 PREF_DAY,
Backstrom 0:f6e68b4ce169 37 PREF_NULL // placeholder
Backstrom 0:f6e68b4ce169 38 };
Backstrom 0:f6e68b4ce169 39
Backstrom 0:f6e68b4ce169 40 struct prefs_t {
Backstrom 0:f6e68b4ce169 41 uint8_t sig0; // expected 0x42
Backstrom 0:f6e68b4ce169 42 uint8_t sig1; // expected 0x66
Backstrom 0:f6e68b4ce169 43 uint8_t disp_24h;
Backstrom 0:f6e68b4ce169 44 uint8_t brightness;
Backstrom 0:f6e68b4ce169 45 uint8_t alarm;
Backstrom 0:f6e68b4ce169 46 uint8_t dots;
Backstrom 0:f6e68b4ce169 47 uint8_t gps;
Backstrom 0:f6e68b4ce169 48 int8_t gps_tzh;
Backstrom 0:f6e68b4ce169 49 uint8_t gps_tzm;
Backstrom 0:f6e68b4ce169 50 uint8_t auto_date;
Backstrom 0:f6e68b4ce169 51 uint8_t flw;
Backstrom 0:f6e68b4ce169 52 uint8_t crc;
Backstrom 0:f6e68b4ce169 53 };
Backstrom 0:f6e68b4ce169 54
Backstrom 0:f6e68b4ce169 55 union PrefsData {
Backstrom 0:f6e68b4ce169 56 uint8_t buf[12];
Backstrom 0:f6e68b4ce169 57 prefs_t prefs;
Backstrom 0:f6e68b4ce169 58 };
Backstrom 0:f6e68b4ce169 59
Backstrom 0:f6e68b4ce169 60 void init_prefs();
Backstrom 0:f6e68b4ce169 61 void save_prefs();
Backstrom 0:f6e68b4ce169 62 PrefsData* get_prefs();
Backstrom 0:f6e68b4ce169 63
Backstrom 0:f6e68b4ce169 64 // prefs that are not saved to EEPROM
Backstrom 0:f6e68b4ce169 65 void set_year(int year);
Backstrom 0:f6e68b4ce169 66 void set_month(int month);
Backstrom 0:f6e68b4ce169 67 void set_day(int day);
Backstrom 0:f6e68b4ce169 68
Backstrom 0:f6e68b4ce169 69 void set_extra_prefs(int year, int month, int day);
Backstrom 0:f6e68b4ce169 70 void get_extra_prefs(int& year, int& month, int& day);
Backstrom 0:f6e68b4ce169 71
Backstrom 0:f6e68b4ce169 72 void set_pref(PREFS pref, uint32_t value);
Backstrom 0:f6e68b4ce169 73
Backstrom 0:f6e68b4ce169 74 #endif // PREFS_H_