Write a driver implementing the serial protocol. Implement he driver as class TM1637 with the following methods:
- start_transfer: implements the start sequence (dio going low when clk is high)
- stop transfer: implements the "end of transfer" sequence (dio going high when clk is high)
- write_bit: write a single bit: with clk low, set dio to the bit value, then send a pulse (high followed by low) on the clk pin
- write byte: send 8 bits. After the eights bit, check the acknowledge signal. Switch dio to input, check acq, switch dio back to output after the falling edge of the nineth clock pulse
- display on: switch the display on: start_transfer, send display_on command, stop transfer
- create a table with the led setting of the seven segments. dp means decimal point, which is only used on the second digit, where it controls the following colon.
A
---
F | | B dp,g,f,e, d,c,b,a: the data byte
-G-
E | | C
---
D
- write_digit(digit_num,digit,colon=False): sets digit number digit_num to the value digit. If colon is true and the digit number is 1 (start counting from zero) the switch the colon on.
- clear_digits(colon=False): clear all digits. Only the colon stays on if colon == True
- write_hex(number,colon=False): write a hex number to the display
- write_dec(number,colon=False): write a decimal number to the display.
Write a test routine that exercises all the above methods |