コード例 #1
0
 def __init__(self, loginVo, sensorName):
     logger.info('ProcessLedGreen init')
     self.loginVo = loginVo
     self.sensorName = sensorName
     DAQC.clrLED(0, 0)
     DAQC.clrLED(0, 1)
     DAQC.enableSWint(0)
     DAQC.intEnable(0)
     self.ledColor = 'green'
     self.btnPressed = '0'
コード例 #2
0
    def run(self, *args):
        logger.info("ButtonPushedThread run start")

        DAQC.enableSWint(self.daqcBoard)
        DAQC.intEnable(self.daqcBoard)
        while True:
            if self.isShutdown:
                break
            if DAQC.getINTflags(self.daqcBoard) == 256:
                self.pillDispenser.setDispenseState('CONFIRMING')
                break
            time.sleep(.25)
コード例 #3
0
def leds():
    DAQC.enableSWint(0)
    DAQC.intEnable(0)
    while True:
        DAQC.setLED(0, 0)
        if DAQC.getINTflags(0) == 256:
            break
        time.sleep(.25)
        if DAQC.getINTflags(0) == 256:
            break
        DAQC.clrLED(0, 0)
        if DAQC.getINTflags(0) == 256:
            break
        time.sleep(.25)
        if DAQC.getINTflags(0) == 256:
            break
    for i in range(0, 100):
        DAQC.clrLED(0, 0)
        DAQC.clrLED(0, 1)
    pressure = sensor.read_pressure() / 100.  # convert to hectopascals
    humidity = sensor.read_humidity()
    t = sensor.t_fine

    # measure from the (analog) photo-sensor
    light = DAQC.getADC(0, 0)

    global data
    data.append([t, temp, pressure, humidity, light])

    # turn off LEDs
    DAQC.setDOUTall(0, 0)


# set up GPIO interface for pushbotton on PiDAQC
DAQC.enableSWint(0)  # enable pushbutton interrupt
DAQC.intEnable(0)  # enable global interrupts
DAQC.getINTflags(0)  # clear any flags

# GPIO event detection must be set up AFTER clearing DAQC interrupt flag
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(22, GPIO.FALLING, callback=sample)
DAQC.getINTflags(0)

# set up BME280
sensor = BME280(mode=BME280_OSAMPLE_8)

try:
    while (1):
        # wait for button