Commit 298e6b69 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

gpsapp: Add icon to show activity

The GPS icon blinks while searching for signal and is on when fixed
parent 0b6f2bc8
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
enum event_type { enum event_type {
BUTTON_PRESSED, BUTTON_PRESSED,
SENSOR, SENSOR,
RTC_TICK RTC_TICK,
GPS_FIX_LOST,
GPS_FIX_ACQ
}; };
/** /**
......
...@@ -120,7 +120,8 @@ INCLUDEPATHS += \ ...@@ -120,7 +120,8 @@ INCLUDEPATHS += \
-I../common/drivers/usb \ -I../common/drivers/usb \
-I../common/drivers/usb/inc \ -I../common/drivers/usb/inc \
-I../common/drivers/gps/ \ -I../common/drivers/gps/ \
-I../common/drivers/gps/nmealib/include -I../common/drivers/gps/nmealib/include \
-I../bitmaps/
#################################################################### ####################################################################
# Files # # Files #
...@@ -174,6 +175,7 @@ C_SRC += \ ...@@ -174,6 +175,7 @@ C_SRC += \
../common/gfx/font_xm4x6.c \ ../common/gfx/font_xm4x6.c \
../common/gfx/font_xm5x8.c \ ../common/gfx/font_xm5x8.c \
../common/udelay.c \ ../common/udelay.c \
../bitmaps/bitmaps.c \
gpsapp.c gpsapp.c
s_SRC += s_SRC +=
......
...@@ -51,9 +51,12 @@ ...@@ -51,9 +51,12 @@
#include <gfx/graphics.h> #include <gfx/graphics.h>
#include <gfx/ui.h> #include <gfx/ui.h>
#include <bitmaps.h>
#include "gps.h" #include "gps.h"
static int i = 0; static struct rle_bitmap gps_ico;
static int gps_ico_blink = 0;
static void gps_redraw(struct ui_widget *w) static void gps_redraw(struct ui_widget *w)
{ {
...@@ -67,10 +70,21 @@ static void gps_redraw(struct ui_widget *w) ...@@ -67,10 +70,21 @@ static void gps_redraw(struct ui_widget *w)
utc.min, utc.min,
utc.sec); utc.sec);
gfx_text(&w->dc, &font_helv17b, 0, 0, buf, 0); gfx_text(&w->dc, &font_helv17b, 0, 0, buf, 0);
gfx_draw_bitmap(&w->dc, 0, 112, &gps_ico);
} }
static void gps_event(struct ui_widget *w, const struct event *evt) static void gps_event(struct ui_widget *w, const struct event *evt)
{ {
if (evt->type == GPS_FIX_LOST) {
gps_ico_blink ^= 1;
if (gps_ico_blink)
memcpy(&gps_ico, &gps_searching,
sizeof(struct rle_bitmap));
else
memcpy(&gps_ico, 0, sizeof(struct rle_bitmap));
} else if (evt->type == GPS_FIX_ACQ) {
memcpy(&gps_ico, &gps_receiving, sizeof(struct rle_bitmap));
}
w->flags |= WF_DIRTY; w->flags |= WF_DIRTY;
} }
...@@ -87,10 +101,17 @@ static struct ui_widget gps_screen = { ...@@ -87,10 +101,17 @@ static struct ui_widget gps_screen = {
// NULL, // NULL,
//}; //};
static struct ui_widget gps_fix = {
NULL,
NULL,
{0, 112, 15, 112},
0,
WF_ACTIVE | WF_VISIBLE
};
void main(void *params) void main(void *params)
{ {
struct event evt; struct event evt;
evt.type = RTC_TICK;
int i = 0; int i = 0;
/* Init clocks */ /* Init clocks */
...@@ -118,7 +139,14 @@ void main(void *params) ...@@ -118,7 +139,14 @@ void main(void *params)
while (1) { while (1) {
for (i = 0; i < 100000; i++) for (i = 0; i < 100000; i++)
; ;
ui_update(&evt);
if (gps_fixed()) {
evt.type = GPS_FIX_ACQ;
ui_update(&evt);
} else {
evt.type = GPS_FIX_LOST;
ui_update(&evt);
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment