summaryrefslogtreecommitdiff
path: root/monitor/mon.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-07 15:51:01 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-07 15:51:01 +0100
commit176cc04414d44b9eebdc9627c99f9b6e5e92ba98 (patch)
tree1a3b2e736bb57e05efe43f7e308eaaca8b3e543b /monitor/mon.c
parentd9f8744ea219fb04057059cdcbf7162534c63852 (diff)
downloadSystDigit-Projet-176cc04414d44b9eebdc9627c99f9b6e5e92ba98.tar.gz
SystDigit-Projet-176cc04414d44b9eebdc9627c99f9b6e5e92ba98.zip
Document ; add hlt instruction ; make monitor faster.
Diffstat (limited to 'monitor/mon.c')
-rw-r--r--monitor/mon.c16
1 files changed, 14 insertions, 2 deletions
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);
}