Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from Adafruit_LED_Backpack import SevenSegment
- # Digit value to bitmask mapping:
- DIGIT_VALUES = {
- ' ': 0x00,
- '-': 0x40,
- '0': 0x3F,
- '1': 0x06,
- '2': 0x5B,
- '3': 0x4F,
- '4': 0x66,
- '5': 0x6D,
- '6': 0x7D,
- '7': 0x07,
- '8': 0x7F,
- '9': 0x6F,
- 'A': 0x77,
- 'B': 0x7C,
- 'C': 0x39,
- 'D': 0x5E,
- 'E': 0x79,
- 'F': 0x71
- }
- # ===========================================================================
- # display cpu temperature
- # ===========================================================================
- segment = SevenSegment.SevenSegment(address=0x70)
- # Initialize the display. Must be called once before using the display.
- segment.begin()
- while(True):
- segment.clear()
- with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
- line = f.readline()
- for pos in range(4):
- c = line[pos]
- if c:
- segment.buffer[pos*2] = DIGIT_VALUES.get(str(c).upper())
- segment.write_display()
- time.sleep(0.25)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement