From f2ad741c915120c8cbeda7f3938af5285a2c7e8f Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Wed, 7 Jul 2010 12:22:20 +0200 Subject: [PATCH] make testmode configurable allow test mode to toggle add ifndef safty option in config generator --- ezchronos.c | 6 +++++- logic/test.c | 3 +++ logic/test.h | 3 +++ tools/config.py | 25 +++++++++++++++++++------ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ezchronos.c b/ezchronos.c index 78b832b..ae7c70d 100644 --- a/ezchronos.c +++ b/ezchronos.c @@ -70,7 +70,9 @@ #endif #include "rfsimpliciti.h" #include "simpliciti.h" +#ifdef CONFIG_TEST #include "test.h" +#endif // ************************************************************************************************* @@ -136,9 +138,11 @@ int main(void) // Assign initial value to global variables init_global_variables(); - + +#if CONFIG_TEST // Branch to welcome screen test_mode(); +#endif // Main control loop: wait in low power mode until some event needs to be processed while(1) diff --git a/logic/test.c b/logic/test.c index b218954..03486e6 100644 --- a/logic/test.c +++ b/logic/test.c @@ -35,6 +35,7 @@ // Test functions. // ************************************************************************************************* +#ifdef CONFIG_TEST // ************************************************************************************************* // Include section @@ -290,3 +291,5 @@ void display_all_off(void) lcdptr++; } } + +#endif // CONFIG_TEST \ No newline at end of file diff --git a/logic/test.h b/logic/test.h index ca62f45..6041856 100644 --- a/logic/test.h +++ b/logic/test.h @@ -34,6 +34,7 @@ // ************************************************************************************************* // Test functions. // ************************************************************************************************* +#ifdef CONFIG_TEST #ifndef TEST_H_ #define TEST_H_ @@ -43,3 +44,5 @@ extern void test_mode(void); #endif /*TEST_H_*/ + +#endif \ No newline at end of file diff --git a/tools/config.py b/tools/config.py index 4955082..c344a6e 100755 --- a/tools/config.py +++ b/tools/config.py @@ -32,7 +32,8 @@ DATA = { "THIS_DEVICE_ADDRESS": { "name": "Hardware address", "type": "text", - "default": rand_hw() + "default": rand_hw(), + "ifndef": True }, "DEBUG": { @@ -41,6 +42,18 @@ DATA = { # modules +"CONFIG_DAY_OF_WEEK": { + "name": "Date: Day of Week", + "depends": [], + "default": True}, + +"CONFIG_TEST": { + "name": "Test Mode", + "depends": [], + "default": True}, + +# not yet working + "CONFIG_ACCEL": { "name": "Accleration", "depends": [], @@ -65,10 +78,6 @@ DATA = { "name": "Date", "depends": [], "default": True}, -"CONFIG_DAY_OF_WEEK": { - "name": "Date: Day of Week", - "depends": [], - "default": True}, "CONFIG_PHASE_CLOCK": { "name": "Phase Clock", "depends": [], @@ -81,7 +90,7 @@ DATA = { "name": "Stop Watch", "depends": [], "default": True}, -"CONFIG_STOP_TEMP": { +"CONFIG_TEMP": { "name": "Temperature", "depends": [], "default": True}, @@ -163,6 +172,8 @@ class OpenChronosApp(npyscreen.NPSApp): fp.write("// !!!! DO NOT EDIT !!!, use: make config\n") fp.write(HEADER) for key,dat in DATA.iteritems(): + if DATA[key].get("ifndef", False): + fp.write("#ifndef %s\n" %key) if isinstance(dat["value"], bool): if dat["value"]: fp.write("#define %s\n" %key) @@ -170,6 +181,8 @@ class OpenChronosApp(npyscreen.NPSApp): fp.write("// %s is not set\n" %key) else: fp.write("#define %s %s\n" %(key, dat["value"])) + if DATA[key].get("ifndef", False): + fp.write("#endif // %s\n" %key) fp.write(FOOTER)