Example #1
0
    def __init__(self, pins, thresholds):
        super(RaspPi,self).__init__(pins, thresholds, "RPi")

        #self.flow_sensor = GroveFlowSensor(self.pins['sensors']['flow-sensor'])
        self.sound_sensor = SoundSensor(self.pins['sensors']['sound-sensor'], self.thresholds['sound'])
        self.temp_sensor = TempSensor(self.pins['sensors']['temp-sensor'], self.thresholds['temp'])
        #self.ultrasonic_ranger = UltraSonicRanger(self.pins['sensors']['ultrasonic-ranger'], self.thresholds['ultrasonic'])
        #self.lcd = GroveRGB()
        self.buttons = {}
        self.leds = {}
        #self.led_bar = GroveLED()
        #self.print_to_screen('IP Address: \n '+Tools.get_ip_address(), [0,128,64])
        time.sleep(10)
Example #2
0
class RaspPi(Board):

    # Initialize the board and all of the devices attached to the board.
    lastMessage = { 'time':time.time(), 'message':0 }
    def __init__(self, pins, thresholds):
        super(RaspPi,self).__init__(pins, thresholds, "RPi")

        #self.flow_sensor = GroveFlowSensor(self.pins['sensors']['flow-sensor'])
        self.sound_sensor = SoundSensor(self.pins['sensors']['sound-sensor'], self.thresholds['sound'])
        self.temp_sensor = TempSensor(self.pins['sensors']['temp-sensor'], self.thresholds['temp'])
        #self.ultrasonic_ranger = UltraSonicRanger(self.pins['sensors']['ultrasonic-ranger'], self.thresholds['ultrasonic'])
        #self.lcd = GroveRGB()
        self.buttons = {}
        self.leds = {}
        #self.led_bar = GroveLED()
        #self.print_to_screen('IP Address: \n '+Tools.get_ip_address(), [0,128,64])
        time.sleep(10)

    #TODO: Make this section more dynamic, so any sensor can be automatically loaded.

    def read_sound_sensor(self):
        return self.sound_sensor.read()

    def read_temp_sensor(self):
        return "{:4.1f}".format(self.temp_sensor.read())

    # The clear function is run when the application halts.
    def clear(self):
        for led in self.leds:
            self.leds[led].off()
        self.lcd.clear()

    def setHelloSBSScreen(self):
        current_time = time.time();
        if (current_time-self.lastMessage['time']>CYCLE_MESSAGES):
            self.lastMessage['message'] += 1
            if (self.lastMessage['message']==5):
                self.lastMessage['message']=0
            #self.print_to_screen(self.sbs_messages(self.lastMessage['message']),RGB['orange'])
            self.lastMessage['time'] = current_time
        #else:
         #   self.print_to_screen(self.sbs_messages(self.lastMessage['message']),RGB['orange'])

    def reset(self):
        return