def initialize(self): #I found if we do not attach ourselves #it will attach as ReadOnly. #shm.attach(0,0) #buf = shm.read(19) #print(buf) #shm.detach() # These are the pins the display is connected to. Adjust accordingly. # In addition to these you need to connect to 5V and ground. DIO = 17 CLK = 27 STB = 22 board = TM1638.TM1638(DIO, CLK, STB) board.enable(1) return board
def __init__(self): threading.Thread.__init__(self) self.setDaemon(True) self._homeDir = os.path.expanduser("~/.sensomatic") self._configFileName = self._homeDir + '/config.ini' self._config = ConfigParser.ConfigParser() self._readConfig() self.tm = TM1638.TM1638(DIO, CLK, STB) self.tm.enable(7) for i in range(8): self.tm.set_segment(i,8,True) self.tm.set_led(i,True) time.sleep(1) for i in range(8): self.tm.set_segment(i,10,False) self.tm.set_led(i,False) self.tm.disable() self.mode = 'nix' self._redis = redis.StrictRedis(host=self._config.get("REDIS", "ServerAddress"), port=self._config.get("REDIS", "ServerPort"), db=0)
#!/usr/bin/env python # TM1638 playground import TM1638 import time # These are the pins the display is connected to. Adjust accordingly. # In addition to these you need to connect to 5V and ground. DIO = 17 CLK = 27 STB = 22 display = TM1638.TM1638(DIO, CLK, STB) display.enable(1) count = 0 while True: display.set_text(str(count)) count += 100 time.sleep(0.02)