/* Tiny GPS Speedometer v3 David Johnson-Davies - www.technoblogy.com - 9th March 2017 ATtiny85 @ 8MHz (external crystal; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ // Constants const int DataIn = 0; const int ClockPin = 2; const int DataOut = 1; // Display ********************************************** // Seven segment display setup const int Clear_Display = 0x76; const int Decimal_Control = 0x77; const int Cursor_Control = 0x79; const int Brightness_Control = 0x7A; void SendByte(char data) { shiftOut(DataOut, ClockPin, MSBFIRST, data); } // Clear display void ClearDisplay () { SendByte(Clear_Display); } // Display a four/five digit decimal number void Display (int number) { boolean dig = false; int j; SendByte(Cursor_Control); SendByte(0); SendByte(Decimal_Control); if (number>9999) { j=10000; SendByte(0x04); } else { j=1000; SendByte(0x02); } for (int d=0; d<4 ; d++) { int i = (number/j) % 10; if (!i && !dig && j>100) SendByte(' '); else { SendByte(i); dig = true; } j=j/10; } } // USI UART ********************************************** unsigned char ReverseByte (unsigned char x) { x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); return x; } // Initialise USI for UART reception. void InitialiseUSI (void) { DDRB &= ~(1<