11/**
22 * @file guiNodes.c
33 * @Author Andreas Dahlberg (andreas.dahlberg90@gmail.com)
4- * @date 2018-04-09 (Last edit)
4+ * @date 2018-04-20 (Last edit)
55 * @brief Implementation of GUI for remote nodes.
66 */
77
@@ -47,8 +47,9 @@ along with SillyCat firmware. If not, see <http://www.gnu.org/licenses/>.
4747
4848#define MAX_NR_NODE_VIEWS 3
4949
50- #define BATT_INDICATOR_X 2
51- #define BATT_INDICATOR_Y 23
50+ #define BATT_INDICATOR_X 2
51+ #define BATT_INDICATOR_Y 23
52+ #define BATT_INDICATOR_ANIMATION_DELAY 400
5253
5354//////////////////////////////////////////////////////////////////////////
5455//TYPE DEFINITIONS
@@ -65,7 +66,11 @@ struct node_view_t
6566struct module_t
6667{
6768 struct node_view_t views [MAX_NR_NODE_VIEWS ];
68- uint8_t tick ;
69+ struct
70+ {
71+ uint8_t nr_bars ;
72+ uint32_t timer ;
73+ } battery_indicator ;
6974};
7075
7176//////////////////////////////////////////////////////////////////////////
@@ -112,7 +117,8 @@ void guiNodes_Init(void)
112117 Interface_AddChild (& view_p -> overview , & view_p -> details );
113118 }
114119
115- module .tick = 0 ;
120+ module .battery_indicator .nr_bars = 0 ;
121+ module .battery_indicator .timer = 0 ;
116122}
117123
118124//////////////////////////////////////////////////////////////////////////
@@ -291,7 +297,13 @@ static void DrawBatteryIndicator(struct node_t *node_p)
291297{
292298 if (Node_IsBatteryCharging (node_p ))
293299 {
294- DrawBattery (module .tick % 6 );
300+ if (Timer_TimeDifference (module .battery_indicator .timer ) >
301+ BATT_INDICATOR_ANIMATION_DELAY )
302+ {
303+ ++ module .battery_indicator .nr_bars ;
304+ module .battery_indicator .timer = Timer_GetMilliseconds ();
305+ }
306+ DrawBattery (module .battery_indicator .nr_bars % 6 );
295307 }
296308 else if (Node_IsBatteryChargerConnected (node_p ))
297309 {
@@ -301,8 +313,6 @@ static void DrawBatteryIndicator(struct node_t *node_p)
301313 {
302314 DrawBattery (0 );
303315 }
304-
305- ++ module .tick ;
306316}
307317
308318static void ClearAction (uint16_t context __attribute__ ((unused )))
0 commit comments