예제 #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)
예제 #4
0
# ./rm_config.py
# Contains our config file utils
import rm_config
# ./rm_utils.py
# Contains various utility functions
import rm_utils

config = rm_config.rm_read_config()

# Interrupt setup
# NOTE: Not safe to run interupts with callbacks due to MySQL conflicts
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(22, GPIO.RISING, bouncetime=50)
DAQC.enableDINint(0, 0, 'r')
DAQC.intEnable(0)

# Globals
# These are set up in repeatermond.cfg
USER = config['MYSQLD']['USER']
PASSWD = config['MYSQLD']['PASSWD']
DBHOST = config['MYSQLD']['DBHOST']
DBNAME = config['MYSQLD']['DBNAME']

ANTS = [int(str_val) for str_val in config['MONITOR']['ANTS'].split(',')]
ANALOGIO = [
    int(str_val) for str_val in config['MONITOR']['ANALOGIO'].split(',')
]
DIGIN = [int(str_val) for str_val in config['MONITOR']['DIGIN'].split(',')]
ELEMENTS = [
    int(str_val) for str_val in config['MONITOR']['ELEMENTS'].split(',')
    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
        DAQC.setLED(0, 0)
예제 #6
0
		counter1 += 1
	if detector & 0b10:
		counter2 += 1

def storecpm(value1, value2):
	f = open("log.dat", 'a')
	f.write(str(time.time()) + ",")
	f.write(str(value1) + ",")
	f.write( str(value2) + "\n")
	f.close()
 
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(22, GPIO.FALLING, callback=counterDET)  
DAQC.enableDINint(0,0,'r')   #enable the push button interrupt
DAQC.enableDINint(0,1,'f')
DAQC.intEnable(0)     #enable global interrupts


checkpoint = time.time()

try:
           	
	if (checkpoint < time.time()):
		print "Counter is ", counter
		storecpm(counter1, counter2)
		counter1 = 0
		counter2 = 0
		checkpoint = time.time() + 60

except KeyboardInterrupt:  
    GPIO.cleanup()