Commit bc1c219d authored by Federico Vaga's avatar Federico Vaga

freewatch: stop application using library function

Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent b380ebb7
......@@ -24,9 +24,8 @@
/**
* Clock application.
*/
#include <libfwatch.h>
#include "clock.h"
#include "application.h"
#include "widgets/status_bar.h"
#include <drivers/rtc.h>
......@@ -36,6 +35,7 @@
static struct rtc_time rtc;
static struct tm cur_time;
application clock_app;
static void digital_watch_redraw(struct ui_widget *w) {
char buf[32];
......@@ -105,7 +105,7 @@ void clock_main(void* params) {
ui_update(NULL);
// Event loop
while(1) {
while(fwatch_is_application_running(&clock_app)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret == pdFALSE)
continue;
......@@ -115,7 +115,7 @@ void clock_main(void* params) {
case BUTTON_PRESSED:
if (evt.data.button == BUT_TR ||
evt.data.button == BUT_TL)
return; /* Quit Application */
fwatch_application_stop(&clock_app);
// no break; fall through
default: // suppress warnings
......
......@@ -24,6 +24,7 @@
* Compass application.
*/
#include <libfwatch.h>
#include "application.h"
#include <drivers/lsm303c.h>
#include <gfx/ui.h>
......@@ -39,6 +40,8 @@
#define COMP_X0 64
#define COMP_Y0 64
application compass;
static int x_lcd, y_lcd;
static float sina, cosa;
static int calib = 0;
......@@ -139,14 +142,14 @@ void compass_main(void *params)
ui_update(NULL);
/*main loop*/
while(1) {
while(fwatch_is_application_running(&compass)) {
ret = xQueueReceive(appQueue, &evt, 50 / portTICK_RATE_MS);
if(ret == pdTRUE) {
switch(evt.type) {
case BUTTON_PRESSED:
if (evt.data.button == BUT_TR ||
evt.data.button == BUT_TL)
return; /* Quit application */
fwatch_application_stop(&compass);
/*if(evt.data.button == BUT_BR) {
c_min.x = 0x7fff;
......
......@@ -24,6 +24,7 @@
* Very simple "game"
*/
#include <libfwatch.h>
#include "application.h"
#include "widgets/status_bar.h"
#include <drivers/lsm303c.h>
......@@ -44,6 +45,8 @@
#define MODE_NORM 0
#define MODE_HIGH 1
application game;
int win_x0, win_y0, win_x1, win_y1;
int score, highscore;
int mode;
......@@ -126,7 +129,7 @@ void game_main(void *params)
ui_update(NULL);
/*main loop*/
while(1) {
while(fwatch_is_application_running(&game)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret == pdTRUE) {
switch(evt.type) {
......@@ -135,7 +138,7 @@ void game_main(void *params)
evt.data.button == BUT_TL) {
vibra_disable();
buzzer_disable();
return; /* Quit application */
fwatch_application_stop(&game);
}
if(evt.data.button == BUT_BR)
mode = MODE_HIGH;
......
......@@ -33,11 +33,13 @@
#include <bitmaps.h>
#include <drivers/gps.h>
#include <libfwatch.h>
#include "application.h"
#include "settings/settings.h"
application gpscoord;
static struct gps_coord coord;
static int coord_format;
static int gpsscreen = 0;
......@@ -155,7 +157,7 @@ void gpscoord_main(void *params)
ui_update(NULL);
while (1) {
while (fwatch_is_application_running(&gpscoord)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret != pdTRUE)
continue;
......@@ -164,7 +166,7 @@ void gpscoord_main(void *params)
case BUTTON_PRESSED:
if (evt.data.button == BUT_TR ||
evt.data.button == BUT_TL)
return; /* Quit application */
fwatch_application_stop(&gpscoord);
// else if (evt.data.button == BUT_BR) {
// /*
// * Toggle between coordinate and
......
......@@ -24,7 +24,7 @@
/**
* Menu application.
*/
#include <libfwatch.h>
#include "app_list.h"
#include "menu_struct.h"
#include "widgets/status_bar.h"
......@@ -149,6 +149,7 @@ static void menu_ui_init() {
static void run(menu_entry *entry) {
if(entry->type == APP) {
entry->data.app->flags |= APP_FLAGS_RUN;
entry->data.app->main(NULL);
if (entry->data.app->quit)
entry->data.app->quit(entry->data.app);
......
......@@ -28,11 +28,15 @@
#include <drivers/gps.h>
#include <gfx/graphics.h>
#include <gfx/ui.h>
#include <libfwatch.h>
#include "widgets/status_bar.h"
#include "settings/settings.h"
#include "application.h"
application reset;
static void reset_redraw(struct ui_widget *w)
{
gfx_text(&w->dc, &font_helv22b, 10, 50, "Bottom right", 0);
......@@ -62,7 +66,7 @@ void reset_main(void *params)
ui_add_widget(&status_bar);
ui_update(NULL);
while(1) {
while(fwatch_is_application_running(&reset)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if (ret != pdTRUE)
continue;
......@@ -71,7 +75,7 @@ void reset_main(void *params)
case BUTTON_PRESSED:
if (evt.data.button == BUT_TR ||
evt.data.button == BUT_TL)
return; /* Quit application */
fwatch_application_stop(&reset);
/* Reset on bottom right and bottom left buttons
* pressed */
if (evt.data.button == BUT_BR)
......
......@@ -23,13 +23,15 @@
/**
* Settings application.
*/
#include <libfwatch.h>
#include "application.h"
#include "widgets/status_bar.h"
#include "widgets/spinbox.h"
#include "clock.h"
#include <time.h>
application set_date;
static const int DIST_X = 20;
static const int POS_X = 1;
static const int POS_Y = 30;
......@@ -178,7 +180,7 @@ void set_date_main(void* params) {
ui_update(NULL);
// event loop
while(1) {
while(fwatch_is_application_running(&set_date)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret != pdTRUE)
continue;
......@@ -186,7 +188,7 @@ void set_date_main(void* params) {
switch(evt.type) {
case BUTTON_PRESSED:
if(evt.data.button == BUT_TL) {
return; // go back to the main menu
fwatch_application_stop(&set_date);
} else if(evt.data.button == BUT_TR) {
if(sb_index < SPINBOX_NUMBER - 1) {
spinbox_set_active(&sb_date[sb_index], false);
......
......@@ -24,12 +24,14 @@
/**
* Settings application.
*/
#include <libfwatch.h>
#include "application.h"
#include "widgets/status_bar.h"
#include "widgets/spinbox.h"
#include "settings/settings.h"
application set_gmt_ofs;
static const int DIST_X = 24;
static const int POS_X = 10;
static const int POS_Y = 30;
......@@ -164,7 +166,7 @@ void set_gmt_ofs_main(void* params) {
ui_update(NULL);
// event loop
while(1) {
while(fwatch_is_application_running(&set_gmt_ofs)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret != pdTRUE)
continue;
......@@ -172,7 +174,7 @@ void set_gmt_ofs_main(void* params) {
switch(evt.type) {
case BUTTON_PRESSED:
if(evt.data.button == BUT_TL) {
return; // go back to the main menu
fwatch_application_stop(&set_gmt_ofs);
} else if(evt.data.button == BUT_TR) {
if(sb_index < SPINBOX_NUMBER - 1) {
spinbox_set_active(&sb_time[sb_index], false);
......
......@@ -23,13 +23,15 @@
/**
* Settings application.
*/
#include <libfwatch.h>
#include "application.h"
#include "widgets/status_bar.h"
#include "widgets/spinbox.h"
#include "clock.h"
#include <time.h>
application set_time;
static const int DIST_X = 24;
static const int POS_X = 20;
static const int POS_Y = 30;
......@@ -141,7 +143,7 @@ void set_time_main(void* params) {
ui_update(NULL);
// event loop
while(1) {
while(fwatch_is_application_running(&set_time)) {
ret = xQueueReceive(appQueue, &evt, portMAX_DELAY);
if(ret != pdTRUE)
continue;
......@@ -149,7 +151,7 @@ void set_time_main(void* params) {
switch(evt.type) {
case BUTTON_PRESSED:
if(evt.data.button == BUT_TL) {
return; // go back to the main menu
fwatch_application_stop(&set_time);
} else if(evt.data.button == BUT_TR) {
if(sb_index < SPINBOX_NUMBER - 1) {
spinbox_set_active(&sb_time[sb_index], false);
......
......@@ -20,6 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <libfwatch.h>
#include "application.h"
#include <time.h>
......@@ -49,6 +50,8 @@ void set_time_fr_gps_main(void *params)
clock_set_time(&time);
}
fwatch_application_stop(&set_time_fr_gps);
}
application set_time_fr_gps = {
......
......@@ -25,6 +25,7 @@
* USB mass storage mode.
*/
#include <libfwatch.h>
#include "application.h"
#include "widgets/status_bar.h"
......@@ -34,6 +35,8 @@
#include <semphr.h>
application usb_ms;
static bool init_ok;
static int mutexours = 0;
......@@ -90,7 +93,7 @@ void usb_ms_main(void* params) {
ui_update(NULL);
while(1) {
while(fwatch_is_application_running(&usb_ms)) {
ret = xQueueReceive(appQueue, &evt, 0);
if (ret != pdTRUE) {
MSDD_Handler();
......@@ -106,7 +109,7 @@ void usb_ms_main(void* params) {
USBD_Stop();
xSemaphoreGive(mutexSdCardAccess);
}
return; /* Quit application */
fwatch_application_stop(&usb_ms);
}
break;
......
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