fremoclock  1_3A01
FREMO Clock - Software for UTG
UserInterfaceLcd.c
Go to the documentation of this file.
1 
27 /*
28  Copyright (C) 2007 Bernd Wisotzki
29 
30  This library is free software; you can redistribute it and/or
31  modify it under the terms of the GNU Lesser General Public
32  License as published by the Free Software Foundation; either
33  version 2.1 of the License, or (at your option) any later version.
34 
35  This library is distributed in the hope that it will be useful,
36  but WITHOUT ANY WARRANTY; without even the implied warranty of
37  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38  Lesser General Public License for more details.
39 
40  You should have received a copy of the GNU Lesser General Public
41  License along with this library; if not, write to the Free Software
42  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43 */
44 
45 /* -- System wide includes -------------------------------------------------- */
46 #include <stdint.h> // typedef uint8_t, typedef uint16_t
47 #include <avr/io.h> // _BV
48 #include <avr/pgmspace.h> // PSTR()
49 
50 /* -- Special Includes e.g. Onboard or direct attached Equipment ------------ */
51 //TODO: cleanup of imports, add comments what is imported
52 #include "sysdef.h" // VERSION
53 #include "ClockKernel.h" // clock kernel
54 #include "lcd.h" // lcd_init(), lcd_goto(), lcd_puts_P(), ..
55  // typedef lcdDisplayMode_t
56 //#include "uart.h" // logging
58 #include "UserInterfaceMenu.h" // typedef menuProg_t, typedef menuShutdown_t
59 #include "UserInterfaceLcd.h"
60 
61 /* -- Standard functions ---------------------------------------------------- */
62 
67 {
69 }
70 
75 {
76  lcd_goto(0, 0);
77  lcd_puts_P(PSTR("Taktgeber "));
78  lcd_puts_P(PSTR(VERSION));
79  lcd_goto(0, 1);
80  lcd_puts_P(PSTR("Enter hilft!"));
81 }
82 
88 void UserInterfaceLcdStartup(menuStartup_t ucbut, uint8_t ucstatus)
89 {
90  lcd_goto(0, 0);
91  lcd_puts_P(PSTR("SysStatus Init "));
92  lcd_goto(0, 1);
93  lcd_puts_P(PSTR("-")); // bit 7 of SysStatus
94  if ((ucstatus & _BV(SYSTEM_STATUS_ENDTIME)) != 0) // bit 6 of SysStatus
95  {
96  lcd_puts_P(PSTR("E"));
97  }
98  else
99  {
100  lcd_puts_P(PSTR("-"));
101  }
102  lcd_puts_P(PSTR("-")); // bit 5 of SysStatus
103  lcd_puts_P(PSTR("-")); // bit 4 of SysStatus
104  lcd_puts_P(PSTR("-")); // bit 3 of SysStatus
105  if ((ucstatus & _BV(SYSTEM_STATUS_EEPROM_ERASED)) != 0) // bit 2 of SysStatus
106  {
107  lcd_puts_P(PSTR("E"));
108  }
109  else
110  {
111  lcd_puts_P(PSTR("-"));
112  }
113  if ((ucstatus & _BV(SYSTEM_STATUS_GOT_DIRTY)) != 0) // bit 1 of SysStatus
114  {
115  lcd_puts_P(PSTR("G"));
116  }
117  else
118  {
119  lcd_puts_P(PSTR("-"));
120  }
121  if ((ucstatus & _BV(SYSTEM_STATUS_DIRTY)) != 0) // bit 0 of SysStatus
122  {
123  lcd_puts_P(PSTR("D"));
124  }
125  else
126  {
127  lcd_puts_P(PSTR("-"));
128  }
129  lcd_puts_P(PSTR(" "));
130  if (ucbut == MENU_STARTUP_NORMAL)
131  {
132  lcd_puts_P(PSTR("Norml"));
133  }
134  else //(ucbut == MENU_STARTUP_PROG)
135  {
136  lcd_puts_P(PSTR("Progr"));
137  }
138 }
139 
145 {
146  lcd_goto(0, 0);
148  lcd_puts_P(PSTR(" "));
150  lcd_puts_P(PSTR(" Norml"));
151  lcd_goto(5, 1);
152  lcd_puts_P(PSTR(" "));
153  switch (ucbut)
154  {
155  case MENUE_NORMAL_CLOCK_OPERATION: lcd_puts_P(PSTR("NmUhr")); break;
156  case MENUE_NORMAL_QUICK_OPERATION: lcd_puts_P(PSTR("NmSvr")); break;
157  case MENUE_NORMAL_TIME_FACTOR : lcd_puts_P(PSTR("NmVkz")); break;
158  case MENUE_NORMAL_START_TIME : lcd_puts_P(PSTR("NmSZt")); break;
159  case MENUE_NORMAL_CURRENT_TIME : lcd_puts_P(PSTR("NmAZt")); break;
160  case MENUE_NORMAL_TARGET_TIME : lcd_puts_P(PSTR("NmZZt")); break;
161  case MENUE_NORMAL_PROG : lcd_puts_P(PSTR("Progr")); break;
162  case MENUE_NORMAL_SHUTDOWN : lcd_puts_P(PSTR("Shutd")); break;
163  default : lcd_puts_P(PSTR("Error")); break;
164  }
165  lcd_goto(0, 1);
166  fclock_t clock = ClockGetTime();
167  UserInterfaceLcdWriteTime(clock.hour, clock.minute);
168 }
169 
175 {
176  lcd_goto(0, 0);
177  lcd_puts_P(PSTR(" Progr"));
178  lcd_goto(0, 1);
179  lcd_puts_P(PSTR(" "));
180  switch (ucbut)
181  {
182  case MENUE_PROGRAM_PULSE_WIDTH: lcd_puts_P(PSTR("PrPuB")); break;
183  case MENUE_PROGRAM_SET0 : lcd_puts_P(PSTR("PrSe0")); break;
184  case MENUE_PROGRAM_NORMAL : lcd_puts_P(PSTR("Norml")); break;
185  case MENUE_PROGRAM_SHUTDOWN : lcd_puts_P(PSTR("Shutd")); break;
186  default : lcd_puts_P(PSTR("Error")); break;
187  }
188 }
189 
195 {
196  lcd_goto(0, 0);
198  lcd_puts_P(PSTR(" "));
200  lcd_puts_P(PSTR(" Shutd"));
201  lcd_goto(5, 1);
202  lcd_puts_P(PSTR(" " ));
203  if (ucbut == MENU_SHUTDOWN_BACK)
204  {
205  lcd_puts_P(PSTR("Zurck"));
206  }
207  else //(ucbut == MENU_SHUTDOWN_SHUTDOWN)
208  {
209  lcd_puts_P(PSTR("Shutd"));
210  }
211 
212  lcd_goto(0, 1);
213  fclock_t clock = ClockGetTime();
214  UserInterfaceLcdWriteTime(clock.hour, clock.minute);
215 }
216 
221 {
222  lcd_goto(0, 0);
223  lcd_puts_P(PSTR(" "));
224  lcd_goto(0, 0);
225  lcd_puts_P(PSTR("Taktgeber "));
226  lcd_puts_P(PSTR(VERSION));
227  lcd_goto(0, 1);
228  lcd_puts_P(PSTR(" "));
229  lcd_goto(0, 1);
230  lcd_puts_P(PSTR("EndOfSoap!"));
231 }
232 
238 void UserInterfaceLcdWriteTime(uint8_t uchour, uint8_t ucminute)
239 {
240  lcd_word( (uint16_t)(uchour + 100), 2);
241  lcd_puts_P(PSTR(":"));
242  lcd_word( (uint16_t)(ucminute + 100), 2);
243 }
244 
249 void UserInterfaceLcdWriteTimeFactor(uint8_t ucfactor)
250 {
251  uint8_t uctmp1 = 0;
252 
253  uctmp1 = ucfactor / 10;
254  lcd_word( (uint16_t)uctmp1, 2);
255  lcd_puts_P(PSTR(","));
256  ucfactor = ucfactor - uctmp1*10;
257  lcd_word( (uint16_t)ucfactor, 1);
258 }
void UserInterfaceLcdProg(menuProg_t ucbut)
Display "Progr" Menu.
"NmSvr" | Schneller Vorlauf bis __
Subroutines for UserInterfaceMenu.
"Norml" | Normalbetrieb
A struct with hour and minute.
Definition: ClockKernel.h:69
"NmVkz" | Zeitverkuerzung
"Shutd" | Shutdown
uint8_t ClockReadTimeFactor(void)
Get time factor.
Definition: ClockKernel.c:350
Subroutines for UserInterfaceCommonData.
"Progr" | Programmierung
#define SYSTEM_STATUS_ENDTIME
end time active? default 0
menuStartup_t
Enum used for startup menu.
#define SYSTEM_STATUS_GOT_DIRTY
got dirty bit fromm eeprom -> no shutdown happend
"PrPuB" | Einstellen Pulsbreite
uint8_t minute
minute value 0..59
Definition: ClockKernel.h:71
void UserInterfaceLcdNormal(menuNormal_t ucbut)
Normal Menu.
"NmSZt" | Startzeit
void UserInterfaceLcdWriteTime(uint8_t uchour, uint8_t ucminute)
Write clock value to lcd.
void lcd_goto(uint8_t x, uint8_t y)
Go to the specified position.
Definition: lcd.c:210
void UserInterfaceLcdWelcome(void)
Welcome.
void UserInterfaceLcdStartup(menuStartup_t ucbut, uint8_t ucstatus)
Startup.
void UserInterfaceLcdEndOfSoap(void)
End of soap.
menuShutdown_t
Enum used for Shutdown Menu.
"PrSe0" | Aktuelle Zeit auf 00:00
menuNormal_t
Enum used for Normal Menu (normal operation).
void lcd_puts_P(const char *s)
Write a string from progmem of chars to the LCD.
Definition: lcd.c:192
Subroutines for UserInterfaceLcd.
void lcd_word(uint16_t value, uint8_t width)
Write numeric value to the LCD.
Definition: lcd.c:232
"NmAZt" | Aktuelle Zeit einstellen
menuProg_t
Enum used for Program Menu.
#define SYSTEM_STATUS_EEPROM_ERASED
eeprom erased; set default parameter.
uint8_t hour
hour value 0..23
Definition: ClockKernel.h:70
LCD interface header file.
#define SYSTEM_STATUS_DIRTY
dirty bit, set by init, cleared by shutdown
"NmUhr" | Normaler Uhrbetrieb
display on, cursor off
Definition: lcd.h:28
System wide Definitions for FREMO Clock.
void UserInterfaceLcdInit(void)
Init.
"Shutd" | Shutdown
uint8_t ClockReadStartTimeHour(void)
Get the hour of the start time.
Definition: ClockKernel.c:398
void lcd_init(lcdDisplayMode_t dispAttr)
Initialize the LCD - call before anything else.
Definition: lcd.c:244
uint8_t ClockReadStartTimeMinute(void)
Get the minute of the start time.
Definition: ClockKernel.c:374
"Norml" | Normalbetrieb
User function called by timer ISR.
"Zurck" | Zurueck
"NmZZt" | Zielzeit
void UserInterfaceLcdWriteTimeFactor(uint8_t ucfactor)
Write time factor to lcd.
void UserInterfaceLcdShutdown(menuShutdown_t ucbut)
Shutdown.
fclock_t ClockGetTime(void)
Get actual time.
Definition: ClockKernel.c:317
#define VERSION
Version String of software package.
Definition: sysdef.h:77