fremoclock  1_3A01
FREMO Clock - Software for UTG
UserInterfaceMenu.c
Go to the documentation of this file.
1 
32 /*
33  Copyright (C) 2007 Bernd Wisotzki
34 
35  This library is free software; you can redistribute it and/or
36  modify it under the terms of the GNU Lesser General Public
37  License as published by the Free Software Foundation; either
38  version 2.1 of the License, or (at your option) any later version.
39 
40  This library is distributed in the hope that it will be useful,
41  but WITHOUT ANY WARRANTY; without even the implied warranty of
42  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43  Lesser General Public License for more details.
44 
45  You should have received a copy of the GNU Lesser General Public
46  License along with this library; if not, write to the Free Software
47  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48 */
49 
50 /* -- System wide includes -------------------------------------------------- */
51 #include <stdint.h> // typedef uint8_t
52 
53 /* -- Special Includes e.g. Onboard or direct attached Equipment ------------ */
54 //TODO: cleanup of imports, add comments what is imported
55 #include <avr/io.h> // _BV()
56 #include "sysdef.h" // #define SERIAL_OUT_ON
57 #include "ClockKernel.h" // clock kernel
58 #include "PushButton.h" // push buttons
59 #include "uart.h" // log_init(), #define LOG(), #define LOG_P()
60 #include "UserInterfaceCommonData.h" // init, shutdown
61 #include "UserInterfaceLcd.h" // LCD
64 #include "UserInterfaceMenu.h"
65 
66 /* -- Standard functions ---------------------------------------------------- */
67 
72 {
73  ClockKernelInit(); //Init pulse generator
74  PushButtonInit(); //Init push buttons
75  UserInterfaceLcdInit(); //Init LCD
76 
77  #if defined SERIAL_OUT_ON
78  log_init();
79  #endif
80 }
81 
86 {
88 
89  LOG_P("\n\r***Welcome*********************************************************:\n\r");
90  LOG_P("Start einer neuen Runde:\n\r");
91  LOG_P("\n\r");
92 
93  // single shot enter
94  for(;;)
95  {
97  {
98  return;
99  }
100  }
101 }
102 
111 {
113  uint8_t ucinitresult = 0;
114 
115  ucinitresult = UserInterfaceCommonDataInit(); //Get the EEPROM data
116  if (ucinitresult != _BV(SYSTEM_STATUS_DIRTY)) //only dirty bit? -> normal
117  {
118  ucbut1 = MENU_STARTUP_PROG; // -> else
119  }
120 
121  LOG_P("\n\rUserInterfaceMenuStartup ");
122  LOG_P("\n\r");
123 
124  for(;;)
125  {
126  UserInterfaceLcdStartup(ucbut1, ucinitresult);
127  ucbut1 = (menuStartup_t) PushButtonGetUpDownValue(ucbut1,
130 
131  // single shot enter
133  {
134  switch (ucbut1) {
136  case MENU_STARTUP_PROG : return MENU_RES_PROG;
137  }
138  }
139  }
140 }
141 
148 {
150 
151  LOG_P("\n\rUserInterfaceMenuNormal");
152  LOG_P("\n\r");
153 
154  for(;;)
155  {
156  UserInterfaceLcdNormal(ucbut1);
157  ucbut1 = (menuNormal_t) PushButtonGetUpDownValue(ucbut1,
160 
161  // single shot enter
163  {
164  switch (ucbut1)
165  {
172  case MENUE_NORMAL_PROG : return MENU_RES_PROG; break;
173  case MENUE_NORMAL_SHUTDOWN : return MENU_RES_SHUTDOWN; break;
174  }
175  }
176  }
177 }
178 
185 {
187 
188  LOG_P("\n\rUserInterfaceMenuProg");
189  LOG_P("\n\r");
190 
191  // single shot enter
192  for(;;)
193  {
194  UserInterfaceLcdProg(ucbut1);
195  ucbut1 = (menuProg_t) PushButtonGetUpDownValue(ucbut1,
198 
200  {
201  switch (ucbut1)
202  {
205  //case MENUE_NORMAL_START_TIME: UserInterfaceMenueNormalStartTime(); break;
206  case MENUE_PROGRAM_NORMAL : return MENU_RES_NORMAL; break;
207  case MENUE_PROGRAM_SHUTDOWN : return MENU_RES_SHUTDOWN; break;
208  }
209  }
210  }
211 }
212 
219 {
221 
222  LOG_P("\n\rAustieg mit: ");
223  LOG_P("\n\r");
224 
225  for(;;)
226  {
227  UserInterfaceLcdShutdown(ucbut1);
228  ucbut1 = (menuShutdown_t) PushButtonGetUpDownValue(ucbut1,
231 
232  // single shot enter
234  {
235  switch(ucbut1)
236  {
237  case MENU_SHUTDOWN_BACK : return MENU_RES_BACK;
239  }
240  }
241  // single shot back
243  {
244  return MENU_RES_BACK;
245  }
246  }
247 }
248 
253 {
254  ClockSetStatus(0);
255 
257 
258  LOG_P("\n\rEndOfSoap!!\n\r\n\r");
259 
261  // program will terminate by reaching end on main()
262 }
Subroutines for UserInterfaceMenu Program.
void UserInterfaceLcdProg(menuProg_t ucbut)
Display "Progr" Menu.
bool PushButtonSingleShotBack(void)
Test if button back is pressed.
Definition: PushButton.c:158
"NmSvr" | Schneller Vorlauf bis __
Minimal uart library with output only for debugging.
menuResult_t UserInterfaceMenuStartup(void)
Display Startup Menu ("Init") and initialize from EEPROM.
Subroutines for UserInterfaceMenu.
"Norml" | Normalbetrieb
"NmVkz" | Zeitverkuerzung
User has selected "Norml" in sub menu.
"Shutd" | Shutdown
void UserInterfaceCommonDataShutDown(void)
Write common data to EEPROM.
void UserInterfaceMenueNormalTimeFactor(void)
Set time factor.
void PushButtonInit(void)
Initialization of module.
Definition: PushButton.c:92
void ClockSetStatus(uint8_t ucStatus)
Set status of pulse generator.
Definition: ClockKernel.c:187
void UserInterfaceMenuEndOfSoap(void)
Shutdown, write to EEPROM and display EndOfSoap.
Subroutines for UserInterfaceCommonData.
"Progr" | Programmierung
menuResult_t UserInterfaceMenuShutdown(void)
Prepare shutdown.
void UserInterfaceMenueNormalCurrentTime(void)
Set current time.
void UserInterfaceMenueNormalClock(void)
Normal clock operation.
void log_init(void)
Call once in start of main to initialize logging to uart with LOG() and LOG_P() macros.
menuStartup_t
Enum used for startup menu.
menuResult_t UserInterfaceMenuNormal(void)
Normal operation.
Subroutines for UserInterfaceMenuNormal.
"PrPuB" | Einstellen Pulsbreite
void UserInterfaceMenuProgramSet0(void)
Set clock to 00:00.
menuResult_t
Enum used for return values from sub menus.
#define LOG_P(FMT,...)
Printf like macro to log to uart.
Definition: uart.h:32
void UserInterfaceLcdNormal(menuNormal_t ucbut)
Normal Menu.
"NmSZt" | Startzeit
void UserInterfaceLcdWelcome(void)
Welcome.
void ClockKernelInit(void)
Initialization of the pulse generator.
Definition: ClockKernel.c:107
void UserInterfaceMenueNormalStartTime(void)
Set start time.
void UserInterfaceLcdStartup(menuStartup_t ucbut, uint8_t ucstatus)
Startup.
void UserInterfaceLcdEndOfSoap(void)
End of soap.
void UserInterfaceMenueNormalTargetTime(void)
Set target time.
menuShutdown_t
Enum used for Shutdown Menu.
"PrSe0" | Aktuelle Zeit auf 00:00
Push button debouncing module for Atmel AVR.
menuNormal_t
Enum used for Normal Menu (normal operation).
Subroutines for UserInterfaceLcd.
"NmAZt" | Aktuelle Zeit einstellen
menuProg_t
Enum used for Program Menu.
uint8_t PushButtonGetUpDownValue(uint8_t ucbut, uint8_t ucmin, uint8_t ucmax)
Get selection value by up and down button.
Definition: PushButton.c:217
User has selected "Zurck" in sub menu.
#define SYSTEM_STATUS_DIRTY
dirty bit, set by init, cleared by shutdown
"NmUhr" | Normaler Uhrbetrieb
System wide Definitions for FREMO Clock.
"Progr" | Programmierung
User has selected "Shutd" in sub menu.
void UserInterfaceMenuWelcome(void)
Send a welcome message to LCD.
void UserInterfaceLcdInit(void)
Init.
"Shutd" | Shutdown
User has selected "Progr" in sub menu.
void UserInterfaceMenueNormalQuick(void)
Quick step forward.
"Shutd" | Shutdown
bool PushButtonSingleShotEnter(void)
Test if button enter is pressed.
Definition: PushButton.c:147
menuResult_t UserInterfaceMenuProg(void)
Display Programming Menu ("Progr").
void UserInterfaceBasicInit(void)
Init all the basic HW and.
"Norml" | Normalbetrieb
User function called by timer ISR.
"Zurck" | Zurueck
"NmZZt" | Zielzeit
void UserInterfaceLcdShutdown(menuShutdown_t ucbut)
Shutdown.
uint8_t UserInterfaceCommonDataInit(void)
Read data from EEPROM and initialize common data.
void UserInterfaceMenueProgramPulseWidth(void)
Set pulse width.