forked from len0rd/rockbox
Now uses the new config file framework
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4913 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
897fb63ec8
commit
8057d79202
1 changed files with 26 additions and 49 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
#include "configfile.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_CHARCELLS
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
|
|
||||||
|
|
@ -43,7 +44,7 @@ To do:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Name and path of the config file*/
|
/* Name and path of the config file*/
|
||||||
#define CFGFILE "/.rockbox/euroconverter.cfg"
|
#define CFGFILE "euroconverter.cfg"
|
||||||
|
|
||||||
/*Pattern for the converter*/
|
/*Pattern for the converter*/
|
||||||
static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */
|
static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */
|
||||||
|
|
@ -134,10 +135,30 @@ static unsigned char heuro,hhome; /*Handles for the new patterns*/
|
||||||
|
|
||||||
static struct plugin_api* rb;
|
static struct plugin_api* rb;
|
||||||
|
|
||||||
|
static char *currency_str[12] = {
|
||||||
|
"France",
|
||||||
|
"Germany",
|
||||||
|
"Austria",
|
||||||
|
"Belgium",
|
||||||
|
"Spain",
|
||||||
|
"Finland",
|
||||||
|
"Irland",
|
||||||
|
"Italy",
|
||||||
|
"Luxemburg",
|
||||||
|
"Netherlands",
|
||||||
|
"Portugal",
|
||||||
|
"Greece"
|
||||||
|
};
|
||||||
|
|
||||||
static int country; /*Country selected*/
|
static int country; /*Country selected*/
|
||||||
static int cur_pos; /*Cursor position*/
|
static int cur_pos; /*Cursor position*/
|
||||||
static long long inc;
|
static long long inc;
|
||||||
|
|
||||||
|
/* Persistent settings */
|
||||||
|
static struct configdata config[] = {
|
||||||
|
{ TYPE_ENUM, 0, 12, &country, "country", currency_str, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 64bits*64 bits with 5 digits after the . */
|
/* 64bits*64 bits with 5 digits after the . */
|
||||||
static long long mul(long long a, long long b)
|
static long long mul(long long a, long long b)
|
||||||
|
|
@ -278,66 +299,20 @@ static void show_abbrev(void)
|
||||||
/* Save the config to disk */
|
/* Save the config to disk */
|
||||||
static void save_config(void)
|
static void save_config(void)
|
||||||
{
|
{
|
||||||
int fd;
|
configfile_save(CFGFILE, config, 1);
|
||||||
|
|
||||||
fd = rb->creat(CFGFILE,0);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
rb->lcd_clear_display();
|
|
||||||
rb->splash(HZ, false, "Failed to save config");
|
|
||||||
rb->sleep(HZ);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rb->fprintf(fd, "last currency: %d\n", country);
|
|
||||||
rb->close(fd);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Load the config from disk */
|
/* Load the config from disk */
|
||||||
static void load_config(void)
|
static void load_config(void)
|
||||||
{
|
{
|
||||||
int fd;
|
configfile_load(CFGFILE, config, 1);
|
||||||
char line[128];
|
|
||||||
char *name, *value;
|
|
||||||
|
|
||||||
fd = rb->open(CFGFILE, O_RDONLY);
|
|
||||||
if (fd < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rb->read_line(fd, line, 128);
|
|
||||||
rb->settings_parseline(line, &name, &value);
|
|
||||||
|
|
||||||
if(!rb->strcmp("last currency", name))
|
|
||||||
country = rb->atoi(value);
|
|
||||||
|
|
||||||
if ((country>11)|| (country<0))
|
|
||||||
country=0;
|
|
||||||
|
|
||||||
rb->close(fd);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*Currency choice*/
|
/*Currency choice*/
|
||||||
static void currency_menu(void)
|
static void currency_menu(void)
|
||||||
{
|
{
|
||||||
unsigned char *currency_str[12] = {
|
|
||||||
"France",
|
|
||||||
"Germany",
|
|
||||||
"Austria",
|
|
||||||
"Belgium",
|
|
||||||
"Spain",
|
|
||||||
"Finland",
|
|
||||||
"Irland",
|
|
||||||
"Italy",
|
|
||||||
"Luxemburg",
|
|
||||||
"Netherlands",
|
|
||||||
"Portugal",
|
|
||||||
"Greece"
|
|
||||||
};
|
|
||||||
int c=country;
|
int c=country;
|
||||||
|
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
|
|
@ -448,6 +423,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
cur_pos=3;
|
cur_pos=3;
|
||||||
inc=100000;
|
inc=100000;
|
||||||
|
|
||||||
|
configfile_init(rb);
|
||||||
|
|
||||||
load_config();
|
load_config();
|
||||||
|
|
||||||
/*Empty the event queue*/
|
/*Empty the event queue*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue