Commit 7c40093a authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Add "app" to manually set time from GPS

This app is not yet properly working, it doesn't always properly set time.
To be checked out exactly why.
parent 59d9bd2b
......@@ -200,6 +200,7 @@ src/apps/settings/set_date.c \
src/apps/settings/set_time.c \
src/apps/settings/settings.c \
src/apps/settings/set_gmt_ofs.c \
src/apps/settings/set_time_fr_gps.c \
src/apps/widgets/spinbox.c \
src/apps/widgets/status_bar.c \
src/apps/application.c \
......
......@@ -47,6 +47,7 @@ menu_list settings_menu = {
{ SETTING, NULL, { .setting = &setting_coord_style } },
{ SETTING, NULL, { .setting = &setting_gps_sets_time } },
{ APP, &gps_receiving, { .app = &set_gmt_ofs } },
{ APP, &clock_icon, { .app = &set_time_fr_gps } },
{ END, NULL, { NULL } }
}
};
......
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Theodor Stana <theodor.stana@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......
/*
* Copyright (C) 2014 Julian Lewis
* @author Theodor Stana <theodor.stana@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "application.h"
#include <time.h>
#include <drivers/gps.h>
#include "clock.h"
#include "settings.h"
#include <usbdbg.h>
void set_time_fr_gps_main(void *params)
{
struct tm time;
struct gps_utc gpstime;
char b[32];
if (gps_fixed()) {
gps_get_utc(&gpstime);
sprintf(b, "BEF: %d-%d-%d %d:%d:%d\r\n",
gpstime.yr, gpstime.mon, gpstime.day,
gpstime.hr, gpstime.min, gpstime.sec);
usbdbg_puts(b);
time.tm_year = gpstime.yr;
time.tm_mon = gpstime.mon;
time.tm_wday = gpstime.day;
time.tm_hour = gpstime.hr + setting_gmt_ofs.tm_hour;
time.tm_min = gpstime.min + setting_gmt_ofs.tm_min;
clock_set_time(&time);
}
}
application set_time_fr_gps = {
.name = "Set time fr GPS", // this will be shown in menu
.main = set_time_fr_gps_main
};
......@@ -41,6 +41,7 @@ typedef struct setting {
extern application set_time;
extern application set_date;
extern application set_gmt_ofs;
extern application set_time_fr_gps;
void setting_change(setting_t *setting);
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Theodor Stana <theodor.stana@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -45,8 +46,6 @@ static bool charging;
static struct rle_bitmap gps_ico;
static int gps_ico_blink = 0;
static int cgpson, pgpson;
static void status_bar_event(struct ui_widget *w, const struct event *evt)
{
switch(evt->type) {
......
......@@ -74,10 +74,10 @@ static void gpsbkgnd_task(void *params)
if (setting_gps_sets_time.val && gps_fixed()) {
time = clock_get_time();
sprintf(b, "BEF: %d-%d-%d %d:%d:%d\r\n",
time.tm_year, time.tm_mon, time.tm_wday,
time.tm_hour, time.tm_min, time.tm_sec);
usbdbg_puts(b);
// sprintf(b, "BEF: %d-%d-%d %d:%d:%d\r\n",
// time.tm_year, time.tm_mon, time.tm_wday,
// time.tm_hour, time.tm_min, time.tm_sec);
// usbdbg_puts(b);
if (firstfix ||
((time.tm_hour == 12) && (time.tm_min == 00))) {
......
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