From 382eea5079d9e29a1d8e1bf3ec8f49a62335737a Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Mon, 9 Nov 2015 12:03:29 +1100 Subject: [PATCH] Fix building with DEVKIT_0_9 defined. This got broken in the 1.4.0 overhaul, mea culpa. --- app/include/user_config.h | 1 + app/modules/node.c | 83 +++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/app/include/user_config.h b/app/include/user_config.h index b28da199..05334e2c 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -62,6 +62,7 @@ #define LUA_OPTIMIZE_MEMORY 0 #endif /* LUA_OPTRAM */ +#define READLINE_INTERVAL 80 #define LUA_TASK_PRIO USER_TASK_PRIO_0 #define LUA_PROCESS_LINE_SIG 2 diff --git a/app/modules/node.c b/app/modules/node.c index c99e215b..1b195a05 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -152,6 +152,47 @@ static int key_press_count = 0; static bool key_short_pressed = false; static bool key_long_pressed = false; static os_timer_t keyled_timer; +static int long_key_ref = LUA_NOREF; +static int short_key_ref = LUA_NOREF; + +static void default_long_press(void *arg) { + if (led_high_count == 12 && led_low_count == 12) { + led_low_count = led_high_count = 6; + } else { + led_low_count = led_high_count = 12; + } + // led_high_count = 1000 / READLINE_INTERVAL; + // led_low_count = 1000 / READLINE_INTERVAL; + // NODE_DBG("default_long_press is called. hc: %d, lc: %d\n", led_high_count, led_low_count); +} + +static void default_short_press(void *arg) { + system_restart(); +} + +static void key_long_press(void *arg) { + NODE_DBG("key_long_press is called.\n"); + if (long_key_ref == LUA_NOREF) { + default_long_press(arg); + return; + } + if (!gL) + return; + lua_rawgeti(gL, LUA_REGISTRYINDEX, long_key_ref); + lua_call(gL, 0, 0); +} + +static void key_short_press(void *arg) { + NODE_DBG("key_short_press is called.\n"); + if (short_key_ref == LUA_NOREF) { + default_short_press(arg); + return; + } + if (!gL) + return; + lua_rawgeti(gL, LUA_REGISTRYINDEX, short_key_ref); + lua_call(gL, 0, 0); +} static void update_key_led (void *p) { @@ -225,48 +266,6 @@ static int node_led( lua_State* L ) return 0; } -static int long_key_ref = LUA_NOREF; -static int short_key_ref = LUA_NOREF; - -void default_long_press(void *arg) { - if (led_high_count == 12 && led_low_count == 12) { - led_low_count = led_high_count = 6; - } else { - led_low_count = led_high_count = 12; - } - // led_high_count = 1000 / READLINE_INTERVAL; - // led_low_count = 1000 / READLINE_INTERVAL; - // NODE_DBG("default_long_press is called. hc: %d, lc: %d\n", led_high_count, led_low_count); -} - -void default_short_press(void *arg) { - system_restart(); -} - -void key_long_press(void *arg) { - NODE_DBG("key_long_press is called.\n"); - if (long_key_ref == LUA_NOREF) { - default_long_press(arg); - return; - } - if (!gL) - return; - lua_rawgeti(gL, LUA_REGISTRYINDEX, long_key_ref); - lua_call(gL, 0, 0); -} - -void key_short_press(void *arg) { - NODE_DBG("key_short_press is called.\n"); - if (short_key_ref == LUA_NOREF) { - default_short_press(arg); - return; - } - if (!gL) - return; - lua_rawgeti(gL, LUA_REGISTRYINDEX, short_key_ref); - lua_call(gL, 0, 0); -} - // Lua: key(type, function) static int node_key( lua_State* L ) {