From 176cc04414d44b9eebdc9627c99f9b6e5e92ba98 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 7 Jan 2014 15:51:01 +0100 Subject: Document ; add hlt instruction ; make monitor faster. --- monitor/mon.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'monitor') diff --git a/monitor/mon.c b/monitor/mon.c index 19259a1..19055c7 100644 --- a/monitor/mon.c +++ b/monitor/mon.c @@ -80,6 +80,8 @@ void mon_loop(t_mon *mon) { time_t prev_time = time(NULL); int steps = 0; + int displayer_steps = 0; + while (mon->status != MS_FINISH) { handle_kbd(mon); if (mon->status == MS_AUTO) { @@ -92,6 +94,11 @@ void mon_loop(t_mon *mon) { steps = 0; prev_time = time(NULL); } + displayer_steps++; + if (displayer_steps >= mon->actual_freq / 100) { + disp_display(mon); + displayer_steps = 0; + } } else if (mon->status == MS_FREQ) { if (prev_time != time(NULL)) { mon->actual_freq = steps; @@ -111,6 +118,11 @@ void mon_loop(t_mon *mon) { } mon_step(mon); steps++; + displayer_steps++; + if (displayer_steps >= mon->actual_freq / 100) { + disp_display(mon); + displayer_steps = 0; + } int sleep = 1000000 / mon->target_freq - mon->calc_time_usec; if (sleep > 0) usleep(sleep); } else { @@ -122,6 +134,7 @@ void mon_loop(t_mon *mon) { void mon_handle_command(t_mon *mon, const char *c) { if (c[0] == 0) { // empty command : run step mon_step(mon); + disp_display(mon); } else if (!strcmp(c, "q")) { mon->status = MS_FINISH; } else if (!strcmp(c, "a")) { @@ -134,6 +147,7 @@ void mon_handle_command(t_mon *mon, const char *c) { while (isspace(*p)) p++; while (isdigit(*p)) mon->target_freq = 10 * mon->target_freq + (*(p++) - '0'); if (mon->target_freq == 0) mon->target_freq = 1000; + mon->actual_freq = mon->target_freq; mon->calc_time_usec = 1000; mon->status = MS_FREQ; } else if (c[0] == 'i') { @@ -270,7 +284,5 @@ void mon_step(t_mon *mon) { mon->ser_out_buf = mon->outputs[mon->ser_out].v_int; } - // Display mon->step++; - disp_display(mon); } -- cgit v1.2.3