Difference: SolutionsToSevenSegmentDisplayAndKeyPad (3 vs. 4)

Revision 42021-01-23 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Solutions"

Solutions to exercise 13: Seven Segment display and Keypad

The Seven Segment Display and the TM1637 controller chip

Exercise 1: The driver and its test program

Changed:
<
<
Writing a bit banging driver is a non-trivial task. Not only must you correctly set the signal levels but you also must get the timing of the signals right. All this must be done by programming GPIO pins. But how can you make sure the signals have the shape they should have as described in the chip's data sheet? The best way of course is to observe the signals on an oscilloscope. If you don't have a scope at hand then you can try to log the signals and their timing To files.
>
>
Writing a bit banging driver is a non-trivial task. Not only must you correctly set the signal levels but you also must get the timing of the signals right. All this must be done by programming GPIO pins. But how can you make sure the signals have the shape they should have as described in the chip's data sheet? The best way of course is to observe the signals on an oscilloscope. If you don't have a scope at hand then you can try to log the signals and their timing to files.
  This is the strategy I opted for: Each time I set a signal to either the dio or the clk pin I write this event into a log file. as long as I wait, I copy the current signals levels onto the log file.
Line: 19 to 19
 
  • and finally the stop sequence: dio going from low to high while clk is high
Please compare this plot with the timing diagrams from the TM1637 data sheet.
Changed:
<
<
The driver tm1637.py has the following methods:
>
>
The tricky bit about such a driver is that you are "walking in the dark" until you see the first segment light up. Once you have got this far you are usually not too far away from success.

The driver tm1637.py has the following methods:

 
  • start_transfer: implements the start sequence of the protocol
  • write_bit(bit): write a single bit, cannot be called separately but is used by write_byte
  • write byte(data): write the bit data and check for the acknowledge from the tm1637 chip
  • stop_transfer: implement the stop sequence
Changed:
<
<
The above three methods are foreseen for internal use.
  • display_on: switch the display on. To be call once at the beginning off your code
>
>
The above three methods are foreseen for internal use while the following calls are intended for use by applications:

  • display_on: switch the display on.
  • display_off: switch display off
 
  • clear_digits(colon): blank the display. If colon is True, the colon is switched on
Added:
>
>
  • write_segments(digit_num,segment_code,colon) write the segment code to the digit
 
  • write_digit(digit_num,digit,colon): write the value digit to digit number digit_num. If digit_num is the second digit (digits are counted from zero) and color is true then the colon is also switched on
  • write_hex(number,colon): write the 16 bit hex number number to the display. If colon is true then the colon will also be switched on
  • write_dec(number,colon): same as write_hex but for decimal numbers.
Added:
>
>
  • set brightness(level): level is 0..7. The brightness level is used for all consecutive writing to the display.
 In addition to the driver itself, which must be uploaded to the ESP32 before use

ampy put tm1637.py /lib/tm1637.py

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback