diff options
Diffstat (limited to 'instr-daemon.c')
-rw-r--r-- | instr-daemon.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/instr-daemon.c b/instr-daemon.c index 24bfe45..c2992fc 100644 --- a/instr-daemon.c +++ b/instr-daemon.c @@ -20,6 +20,7 @@ static gboolean periodic_poll (void); +static gboolean finish_boot (void); int port=3333; //port to listen @@ -187,6 +188,7 @@ handler (GThreadedSocketService *service, return TRUE; } + int main(int argc, char **argv) { GSocketService *service = NULL; @@ -241,33 +243,6 @@ int main(int argc, char **argv) Main_Rst(); -#define MIN_STARTUP_DELAY 2 -#define MAX_STARTUP_DELAY 120 - - long on_delay = (long)globals.Flash.turn_on_dly; - if (on_delay < MIN_STARTUP_DELAY) { - on_delay = MIN_STARTUP_DELAY; - } - if (on_delay > MAX_STARTUP_DELAY) { - on_delay = MAX_STARTUP_DELAY; - } - - long timer_count; - while ((timer_count=sec_timer()-globals.Timers.startup_timer_value) < on_delay) { - message = g_strdup_printf ("%ld ", on_delay - timer_count); - LCD_write(3,27,message); - g_free (message); - } - LCD_write(3,27,"OK"); - - I2C_Setup_Monitor(); - - Show_Main_Menu(); - - globals.Flags.startup_complete = 1; - - // FIXME - self-cal here - or in thread beside user sessions? - //register stdin channel stdinChannel = g_io_channel_unix_new(0); if(stdinChannel == NULL) { @@ -308,6 +283,7 @@ int main(int argc, char **argv) GMainLoop *loop = g_main_loop_new (NULL, FALSE); g_timeout_add (20, (GSourceFunc) periodic_poll, NULL); + g_timeout_add (100, (GSourceFunc) finish_boot, NULL); g_main_loop_run (loop); @@ -320,6 +296,41 @@ int main(int argc, char **argv) } +static gboolean finish_boot (void) { + +#define MIN_STARTUP_DELAY 2 +#define MAX_STARTUP_DELAY 120 + + long on_delay = (long)globals.Flash.turn_on_dly; + if (on_delay < MIN_STARTUP_DELAY) { + on_delay = MIN_STARTUP_DELAY; + } + if (on_delay > MAX_STARTUP_DELAY) { + on_delay = MAX_STARTUP_DELAY; + } + + long timer_count; + + if ((timer_count=sec_timer()-globals.Timers.startup_timer_value) < on_delay) { + gchar *message = g_strdup_printf ("%ld ", on_delay - timer_count); + LCD_write(3,27,message); + g_free (message); + return TRUE; // exit and call by timeout again + } + + LCD_write(3,27,"OK"); + + I2C_Setup_Monitor(); + + Show_Main_Menu(); + + // FIXME - self-cal here - or in thread beside user sessions? + + globals.Flags.startup_complete = 1; + return FALSE; // no more calls to this function are needed +} + + static gboolean periodic_poll (void) { if (globals.HWDetect.beaglebone && bus_getpin (POWER_FAIL)) { |