ヌンチャクでコントロールするチョロQ機能に限定した物です。

Fork of StarBoardOrangeExample3 by Shinichiro Nakamura

Committer:
jksoft
Date:
Sat Aug 18 13:21:50 2012 +0000
Revision:
2:1d9c1cd90695
Parent:
1:03c8bc666945
Rev1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shintamainjp 1:03c8bc666945 1 #include "appconf.h"
shintamainjp 1:03c8bc666945 2 #include <ConfigFile.h>
shintamainjp 1:03c8bc666945 3
shintamainjp 1:03c8bc666945 4 LocalFileSystem fs_local("local");
shintamainjp 1:03c8bc666945 5
shintamainjp 1:03c8bc666945 6 #define CONFIG_FILENAME "/local/SETUP.CFG"
shintamainjp 1:03c8bc666945 7
shintamainjp 1:03c8bc666945 8 #define KEY_CHANNEL "Channel"
shintamainjp 1:03c8bc666945 9 #define VALUE_CHANNEL_A "A"
shintamainjp 1:03c8bc666945 10 #define VALUE_CHANNEL_B "B"
shintamainjp 1:03c8bc666945 11 #define VALUE_CHANNEL_C "C"
shintamainjp 1:03c8bc666945 12 #define VALUE_CHANNEL_D "D"
shintamainjp 1:03c8bc666945 13
shintamainjp 1:03c8bc666945 14 /**
shintamainjp 1:03c8bc666945 15 * Initialize a configuration.
shintamainjp 1:03c8bc666945 16 *
shintamainjp 1:03c8bc666945 17 * @param p A pointer to a configuration structure.
shintamainjp 1:03c8bc666945 18 */
shintamainjp 1:03c8bc666945 19 void appconf_init(appconf_t *p) {
shintamainjp 1:03c8bc666945 20 /*
shintamainjp 1:03c8bc666945 21 * Channel default value is a channel C.
shintamainjp 1:03c8bc666945 22 */
shintamainjp 1:03c8bc666945 23 p->channel = ChoroQ::ChC;
shintamainjp 1:03c8bc666945 24 }
shintamainjp 1:03c8bc666945 25
shintamainjp 1:03c8bc666945 26 /**
shintamainjp 1:03c8bc666945 27 * Read a configuration.
shintamainjp 1:03c8bc666945 28 *
shintamainjp 1:03c8bc666945 29 * @param p A pointer to a configuration structure.
shintamainjp 1:03c8bc666945 30 *
shintamainjp 1:03c8bc666945 31 * @return Return 0 if read succeed.
shintamainjp 1:03c8bc666945 32 */
shintamainjp 1:03c8bc666945 33 int appconf_read(appconf_t *p) {
shintamainjp 1:03c8bc666945 34 ConfigFile cfg;
shintamainjp 1:03c8bc666945 35
shintamainjp 1:03c8bc666945 36 if (!cfg.read(CONFIG_FILENAME)) {
shintamainjp 1:03c8bc666945 37 return -1;
shintamainjp 1:03c8bc666945 38 }
shintamainjp 1:03c8bc666945 39
shintamainjp 1:03c8bc666945 40 char *key = KEY_CHANNEL;
shintamainjp 1:03c8bc666945 41 char value[64];
shintamainjp 1:03c8bc666945 42 if (!cfg.getValue(key, value, sizeof(value))) {
shintamainjp 1:03c8bc666945 43 return -2;
shintamainjp 1:03c8bc666945 44 }
shintamainjp 1:03c8bc666945 45
shintamainjp 1:03c8bc666945 46 if (strcmp(value, VALUE_CHANNEL_A) == 0) {
shintamainjp 1:03c8bc666945 47 p->channel = ChoroQ::ChA;
shintamainjp 1:03c8bc666945 48 } else if (strcmp(value, VALUE_CHANNEL_B) == 0) {
shintamainjp 1:03c8bc666945 49 p->channel = ChoroQ::ChB;
shintamainjp 1:03c8bc666945 50 } else if (strcmp(value, VALUE_CHANNEL_C) == 0) {
shintamainjp 1:03c8bc666945 51 p->channel = ChoroQ::ChC;
shintamainjp 1:03c8bc666945 52 } else if (strcmp(value, VALUE_CHANNEL_D) == 0) {
shintamainjp 1:03c8bc666945 53 p->channel = ChoroQ::ChD;
shintamainjp 1:03c8bc666945 54 } else {
shintamainjp 1:03c8bc666945 55 return -3;
shintamainjp 1:03c8bc666945 56 }
shintamainjp 1:03c8bc666945 57
shintamainjp 1:03c8bc666945 58 return 0;
shintamainjp 1:03c8bc666945 59 }