From b9720538f58902644a6b69abacf7005a2412a008 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 10 May 2013 22:17:41 +0200 Subject: digital/lcd/src: only redraw on command reception --- digital/lcd/src/main.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'digital/lcd') 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); } } -- cgit v1.2.3