summaryrefslogtreecommitdiffhomepage
path: root/digital/lcd/src
diff options
context:
space:
mode:
authorNicolas Schodet2013-05-10 22:17:41 +0200
committerNicolas Schodet2013-05-10 22:17:41 +0200
commitb9720538f58902644a6b69abacf7005a2412a008 (patch)
tree6f1ae1db7daa16aa1911d788bd92c2a456f01165 /digital/lcd/src
parente679cd626352858262e49e8632954b8b4d21d1bb (diff)
digital/lcd/src: only redraw on command reception
Diffstat (limited to 'digital/lcd/src')
-rw-r--r--digital/lcd/src/main.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/digital/lcd/src/main.cc b/digital/lcd/src/main.cc
index 758a4d2f..d93783ce 100644
--- a/digital/lcd/src/main.cc
+++ b/digital/lcd/src/main.cc
@@ -49,6 +49,8 @@ static const int i2c_command_size = 16;
static uint8_t i2c_seq;
+static bool i2c_received;
+
/// Handle a command received by I2C.
void
i2c_handle (LCD &lcd, const char *buf, int size)
@@ -125,6 +127,7 @@ i2c_handle (LCD &lcd, const char *buf, int size)
// Unknown command.
return;
}
+ i2c_received = true;
// Acknowledge.
i2c_seq = buf[1];
}
@@ -264,11 +267,15 @@ main (int argc, const char **argv)
// Wait orders.
while (1)
{
- draw_table (lcd);//draw the table
- draw_robot (lcd);//draw the robot and his destination on the table
+ if (i2c_received)
+ {
+ draw_table (lcd);//draw the table
+ draw_robot (lcd);//draw the robot and his destination on the table
+ i2c_received = false;
+ }
i2c_poll (lcd, i2c_data);
- ucoo::delay_ms (1000);
+ ucoo::delay_ms (4);
}
}