]> git.tdb.fi Git - model-railway-devices.git/blobdiff - s88w/s88w-r.c
Drop the pretense of C89, put declarations where they make sense
[model-railway-devices.git] / s88w / s88w-r.c
index f94a1be0e0e1038f128c844d5219270d0d6694a8..b508b4fa053b48cfda0bc3cb03a3b18ff676c2f5 100644 (file)
@@ -68,11 +68,9 @@ int main()
 
        while(1)
        {
-               uint8_t i;
-
                check_input();
 
-               i = load_pos;
+               uint8_t i = load_pos;
                if(i!=0xFF)
                {
                        output[i] = latch[i];
@@ -116,11 +114,10 @@ int main()
 
 void check_input()
 {
-       uint8_t c;
        if(!serial_read_available())
                return;
 
-       c = serial_read();
+       uint8_t c = serial_read();
        if(rx_fill==0xFF)
        {
                if(c==':')
@@ -130,16 +127,12 @@ void check_input()
        {
                if(rx_fill>=4)
                {
-                       uint16_t offset;
-                       uint8_t nibbles;
-                       uint8_t i;
-
-                       offset = (decode_hex(rx_buf[0])<<8) | (decode_hex(rx_buf[1])<<4) | decode_hex(rx_buf[2]);
-                       nibbles = (offset&3);
+                       uint8_t offset = (decode_hex(rx_buf[0])<<8) | (decode_hex(rx_buf[1])<<4) | decode_hex(rx_buf[2]);
+                       uint8_t nibbles = (offset&3);
                        offset >>= 2;
                        if(rx_fill>3+nibbles)
                        {
-                               for(i=0; i<=nibbles; ++i)
+                               for(uint8_t i=0; i<=nibbles; ++i)
                                {
                                        uint16_t j = offset+nibbles-i;
                                        uint8_t shift = 4*(j&1);
@@ -151,7 +144,7 @@ void check_input()
                                if(lcd_enabled)
                                {
                                        lcd_gotoxy(19-offset-nibbles, 0);
-                                       for(i=0; i<=nibbles; ++i)
+                                       for(uint8_t i=0; i<=nibbles; ++i)
                                                lcd_write(rx_buf[3+i]);
                                }
                        }