Exemplo n.º 1
0
def adcMonitorTask(threadName, delay, counter):
    global exitFlag
    while counter:
        if exitFlag:
            counter = 1
        time.sleep(delay)
        print("%s: counter=%s %s" %
              (threadName, counter, time.ctime(time.time())))
        adcMonitor()
        for ch in range(4):
            print("Volt of channel%s is :%05.3f" % (ch, chVolt[ch]))
        lcd.print_string(lcd.LCD_P1, (str(chVolt[3])[:5]), 3)
        lcd.print_string(lcd.LCD_P1, (str(chVolt[2])[:5]), 2)
        lcd.print_string(lcd.LCD_P2, (str(chVolt[1])[:5]), 3)
        #lcd.print_string(lcd.LCD_P2,(str(chVolt[0])[:5]),2)
        try:
            temperature = sensor.get_temperature()
            lcd.print_string(lcd.LCD_P2, (str(temperature)[:5]), 2)
            print("The temperature is %s celsius" % temperature)
        except:
            print("Check GPIO-BCM4 which is pulled up or not")

        while not k.kq.empty():
            keystate = k.kq.get()
            print("state-q %s" % k.keystate)
            if (k.keystate == 1):
                lcd.disp_page_slide(lcd.LCD_P2, lcd.LCD_PAGE_TOG)
                counter = 200
            elif (k.keystate == 2):
                pass
                exitFlag = 1
        counter -= 1
Exemplo n.º 2
0
def adcMonitorTask(threadName, delay, counter, pwm_ser, kq):
    global exitFlag
    while counter:
        if exitFlag:
            counter = 1
        time.sleep(delay)
        print("%s: counter=%s %s" %
              (threadName, counter, time.ctime(time.time())))
        adcMonitor()
        for ch in range(4):
            print("Volt of channel%s is :%05.3f" % (ch, chVolt[ch]))
        lcd.print_string(lcd.C.LCD_P1, (str(chVolt[3])[:5]) + 'v  ', 3)
        lcd.print_string(lcd.C.LCD_P1, (str(chVolt[2])[:5]) + 'v  ', 2)
        lcd.print_string(lcd.C.LCD_P1, (str(chVolt[1])[:5]) + 'v  ', 1)
        lcd.print_string(lcd.C.LCD_P1, (str(chVolt[0])[:5]) + 'v  ', 0)
        try:
            sensor = W1ThermSensor(W1ThermSensor.THERM_SENSOR_DS18B20,
                                   "041702b228ff")
            temperature = sensor.get_temperature()
            lcd.print_string(lcd.C.LCD_P2, (str(temperature)[:5] + 'c'), 0)
            lcd.print_string(lcd.C.LCD_P2, 'CNTR:' + "{:0>3d}".format(counter),
                             1)
            print("The temperature is %s celsius" % temperature)

            f_vaule, d_value = ua.uart_get(pwm_ser)
            lcd.print_string(lcd.C.LCD_P2, str(f_vaule)[2:7], 2)
            lcd.print_string(lcd.C.LCD_P2, str(d_value)[2:6] + '%', 3)
            print(f_vaule, d_value)

        except:
            print("Check GPIO-BCM4 which is pulled up or not")

        while not kq.empty():
            keystate = kq.get()
            print("state-q %s" % keystate)
            if (keystate == k.C.KEYSTATE_PAGE):
                lcd.disp_page_slide(lcd.C.LCD_P2, lcd.LCD_PAGE_TOG)
                counter = 200
            elif (keystate == k.C.KEYSTATE_EXIT):
                pass
                exitFlag = 1
        counter -= 1