Beispiel #1
0
    def __init__(self):

        self.sr = ShiftRegister()
        self.sr.clear()
        #this system is composed of four fans, belonging to 2 different categories
        #Category1: fans that cool the heat dissipator on the peltier element
        #Category2: fan that circulates air inside the incubator

        #address to turn all fans on
        self.allOn = 0b00001111
        #address to turn all fans off
        self.allOff = 0b00000000
Beispiel #2
0
def tester():
    shiftreg = ShiftRegister(num_registers=1)
    chars = cycle(numerals)

    while True:
        bytelist = []

        char = segment_map[str(next(chars))]
        bytelist.append(char)
        logging.warning(str_rep(char))
        #shiftreg.write(bytelist)
        
        time.sleep(1)
Beispiel #3
0
def clock(args):
    shiftreg = ShiftRegister(num_registers=args.numtubes)
    ishour = False
    ispm = False

    while True:
        if args.numtubes == 2:
            chars, ishour = get_twotube()
        elif args.numtubes == 4:
            chars, ispm = get_fourtube(args.miltime)

        bytelist = []

        #Reverse the order of the string - clocks into the clock backwards.
        for c in chars[::-1]:
            char = segment_map[str(c)]
            bytelist.append(char)
            logging.info(str_rep(char))

        #Map Periods.
        if args.numtubes == 2:
            if ishour:
                bytelist[1] = bytelist[1] | 0x80
            else:
                bytelist[0] = bytelist[0] | 0x80

        if args.numtubes == 4:
            if args.ampm:
                if ispm:
                    bytelist[2] = bytelist[2] | 0x80
                else:
                    bytelist[3] = bytelist[3] | 0x80

            if args.seconds and datetime.datetime.now().second % 2:
                bytelist[1] = bytelist[1] | 0x80

        shiftreg.write(bytelist)

        time.sleep(0.1)
Beispiel #4
0
 def test_values(self):
     register = ShiftRegister(10, 9, 11)
     register.values = [1, 0, 1, 0, 1, 0, 1, 0]
     self.assertSequenceEqual(register.values, [1, 0, 1, 0, 1, 0, 1, 0])
     register.close()
Beispiel #5
0
 def test_show(self):
     register = ShiftRegister(10, 9, 11)
     register.shift(1)
     register.shift(0)
     register.show()
     self.assertSequenceEqual(register.values, [0, 1, 0, 0, 0, 0, 0, 0])
Beispiel #6
0
def get_register():
    return ShiftRegister(10, 9, 11)