#include #include /** * Display pins should be mapped like this: * a b c d e f g DP * 0 1 2 3 4 5 6 7 * * d1 d2 d3 d4 * 1 2 3 4 */ void set_display_raw(volatile uint8_t * header, uint8_t data) { *header = data; } uint8_t digit_to_binary(uint8_t input, uint8_t digit) { switch(digit) { case 0: return input | 0x3f; case 1: return input | 0x06; case 2: return input | 0x5b; case 3: return input | 0x4f; case 4: return input | 0x66; case 5: return input | 0x6d; case 6: return input | 0x7d; case 7: return input | 0x07; case 8: return input | 0x7f; case 9: return input | 0x6f; // by default only draw the period if it was provided in the input default: return input & (uint8_t) 0x10000000; } } void set_display(volatile uint8_t * header, uint8_t value, bool period) { uint8_t byte = digit_to_binary(period << 7, value); set_display_raw(header, byte); }