@@ -33,6 +33,27 @@ static byte glyph1[] = {0x0b, 0xfc, 0x4e, 0xac, 0x0b}; //symbol for wh/km part 1
3333static byte glyph2[] = {0xc8 , 0x2f , 0x6a , 0x2e , 0xc8 }; // symbol for wh/km part 2
3434static byte glyph3[] = {0x44 , 0x28 , 0xfe , 0x6c , 0x28 }; // bluetooth-symbol check this out: http://www.carlos-rodrigues.com/projects/pcd8544/
3535
36+ unsigned long show_important_info_until = 0 ;
37+ void display_show_important_info (const char *str, int duration_secs)
38+ {
39+ #if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
40+ unsigned long seconds = 2 ;
41+ if (duration_secs)
42+ seconds = duration_secs;
43+
44+ show_important_info_until = millis () + (seconds*1000 );
45+
46+ #ifdef SUPPORT_DISPLAY_BACKLIGHT
47+ enable_backlight ();
48+ #endif
49+
50+ // TODO: Implement and test 4bit display mode
51+ lcd.clear ();
52+ lcd.setCursor (0 , 2 );
53+ lcd.print (str);
54+ #endif
55+ }
56+
3657static void display_nokia_setup () // first time setup of nokia display
3758{
3859#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
@@ -56,6 +77,37 @@ static void display_nokia_setup() //first time setup of nokia display
5677#endif
5778}
5879
80+ static void display_4bit_setup ()
81+ {
82+ #if (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
83+ lcd.begin (16 , 2 );
84+ #endif
85+ }
86+
87+ // Check if we should show an important info to the user
88+ static bool handle_important_info_expire ()
89+ {
90+ if (show_important_info_until)
91+ {
92+ if (millis () < show_important_info_until)
93+ {
94+ // Important info still active
95+ return true ;
96+ }
97+
98+ // Important info expired
99+ show_important_info_until = 0 ;
100+ #if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
101+ display_nokia_setup ();
102+ #elif (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
103+ display_4bit_setup ();
104+ #endif
105+ }
106+
107+ // No important info shown
108+ return false ;
109+ }
110+
59111static void display_4bit_update ()
60112{
61113#if (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
@@ -75,6 +127,9 @@ static void display_4bit_update()
75127static void display_nokia_update ()
76128{
77129#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
130+ if (handle_important_info_expire ())
131+ return ;
132+
78133 lcd.setCursor (0 ,0 );
79134 lcd.print (voltage_display,1 );
80135
@@ -165,21 +220,19 @@ void display_init()
165220 pinMode (13 ,OUTPUT);
166221 digitalWrite (13 ,LOW);
167222#endif
223+
168224#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
169225 display_nokia_setup ();
170- #endif
171-
172- #if (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
173- lcd.begin (16 , 2 );
226+ #elif (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
227+ display_4bit_setup ();
174228#endif
175229}
176230
177231void display_update ()
178232{
179233#if (DISPLAY_TYPE & DISPLAY_TYPE_NOKIA)
180234 display_nokia_update ();
181- #endif
182- #if (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
235+ #elif (DISPLAY_TYPE & DISPLAY_TYPE_16X2_LCD_4BIT)
183236 display_4bit_update ();
184237#endif
185238}
0 commit comments