Commit 21c04678 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Add locally configurable settings to settings menu

Tested with the GPS coordinate style in gpscoord.c
parent 833bddc8
......@@ -36,8 +36,10 @@
#include "application.h"
#include "settings/settings.h"
static struct gps_coord coord;
static int coord_format = 1;
static int coord_format;
static int gpsscreen = 0;
static void gps_redraw(struct ui_widget *w)
......@@ -50,6 +52,8 @@ static void gps_redraw(struct ui_widget *w)
float lonmin;
float lonsec;
coord_format = setting_coord_style.val;
if (gps_fixed())
gps_get_coord(&coord, coord_format);
......
......@@ -28,6 +28,9 @@
#include "app_list.h"
#include "menu_struct.h"
#include "widgets/status_bar.h"
#include "settings/settings.h"
#include <stdio.h>
static int selected_item = 0;
static int offset = 0;
......@@ -80,9 +83,13 @@ static void menu_screen_redraw(struct ui_widget *w)
gfx_text(&w->dc, &font_helv17, LEFT_MARGIN,
i * LINE_HEIGHT, l->name, i != selected_item);
} else if (ent->type == SETTING) {
setting_t *s = ent->data.setting;
char s[16];
setting_t *set = ent->data.setting;
sprintf(s, "%s: %d", set->name, set->val);
// strcat(s, ": ")
// strcat(s, set->val);
gfx_text(&w->dc, &font_helv17, LEFT_MARGIN,
i * LINE_HEIGHT, s->name, i != selected_item);
i * LINE_HEIGHT, s, i != selected_item);
}
}
}
......
......@@ -26,6 +26,7 @@
#include "menu_struct.h"
#include "app_list.h"
#include "settings/settings.h"
int get_menu_size(const menu_list *menu) {
int len = 0;
......@@ -40,9 +41,11 @@ int get_menu_size(const menu_list *menu) {
menu_list settings_menu = {
"Settings",
{
{ APP, &clock_icon, { .app = &set_time } },
{ APP, &date_icon, { .app = &set_date } },
{ END, NULL, { NULL } }
{ APP, &clock_icon, { .app = &set_time } },
{ APP, &date_icon, { .app = &set_date } },
{ SETTING, NULL, { .setting = &setting_gps_on } },
{ SETTING, NULL, { .setting = &setting_coord_style } },
{ END, NULL, { NULL } }
}
};
......
......@@ -25,6 +25,9 @@
#include <stdio.h>
#include <string.h>
setting_t setting_gps_on = { "GPS on", 0, 2 };
setting_t setting_coord_style = {"Coord style", 1, 3};
void setting_change(setting_t *setting)
{
uint32_t v = setting->val;
......@@ -36,5 +39,4 @@ void setting_change(setting_t *setting)
sprintf(s, ": %d", v);
setting->val = v;
strcat(setting->name, s);
}
/*
* 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
......@@ -35,6 +36,9 @@ extern application set_date;
void setting_change(setting_t *setting);
extern setting_t setting_gps_on;
extern setting_t setting_coord_style;
#endif /* SETTINGS_H */
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