]> git.tdb.fi Git - model-railway-devices.git/blobdiff - firmware/s88w-r.c
Change the input filtering for better suitability for unreliable track circuits
[model-railway-devices.git] / firmware / s88w-r.c
index dbd1ef175d9a7ea95279dc5bccfe85fe12c557f5..730ac10f3a5337ba2ec31e51ef79a3e8fbac27b6 100644 (file)
@@ -44,7 +44,8 @@ volatile uint8_t rx_buf[7];
 volatile uint8_t rx_fill = 0xFF;
 volatile uint8_t input[128] = { 0 };
 volatile uint8_t latch[128] = { 0 };
-uint8_t log_pos = 0;
+uint8_t log_row = 0;
+uint8_t log_col = 0;
 
 int main()
 {
@@ -147,7 +148,6 @@ void receive(uint8_t c)
                                lcd_gotoxy(19-offset-nibbles, 0);
                                for(i=0; i<=nibbles; ++i)
                                        lcd_write(rx_buf[3+i]);
-                               log_pos |= 0x80;
                        }
                }
                rx_fill = 0xFF;
@@ -160,13 +160,17 @@ void receive(uint8_t c)
                        rx_fill = 0xFF;
        }
 
-       lcd_gotoxy(log_pos%20, 1+log_pos/20);
+       lcd_gotoxy(log_col, 1+log_row);
        lcd_write(c);
-       ++log_pos;
-       if(log_pos>=60)
-               log_pos = 0;
-       if(log_pos%20==0)
-               lcd_gotoxy(log_pos%20, 1+log_pos/20);
+       ++log_col;
+       if(log_col>=20)
+       {
+               log_col = 0;
+               ++log_row;
+               if(log_row>=3)
+                       log_row = 0;
+               lcd_gotoxy(log_col, 1+log_row);
+       }
        lcd_write(255);
 }