Exemplo n.º 1
0
    def cb_enumerate(self, uid, connected_uid, position, hardware_version, 
                 firmware_version, device_identifier, enumeration_type):
        
        if enumeration_type == IPConnection.ENUMERATION_TYPE_CONNECTED or \
           enumeration_type == IPConnection.ENUMERATION_TYPE_AVAILABLE:
            
            # Initialize GPS
            if device_identifier == BrickletGPSV2.DEVICE_IDENTIFIER:
                self.gps = BrickletGPSV2(uid, self.ipcon)

                self.gps.set_date_time_callback_period(TimeServer.GPS_UPDATE_PERIOD)
                self.gps.set_coordinates_callback_period(TimeServer.GPS_UPDATE_PERIOD)

                self.gps.register_callback(BrickletGPSV2.CALLBACK_DATE_TIME, self.cb_time_updated)
                self.gps.register_callback(BrickletGPSV2.CALLBACK_COORDINATES, self.cb_location_updated)

            # Initialize OLED display
            if device_identifier == BrickletOLED128x64.DEVICE_IDENTIFIER:
                self.oled = BrickletOLED128x64(uid, self.ipcon)
                self.oled.clear_display()

            # Initialize RTC
            if device_identifier == BrickletRealTimeClock.DEVICE_IDENTIFIER:
                self.rtc = BrickletRealTimeClock(uid, self.ipcon)

                self.rtc.register_callback(BrickletRealTimeClock.CALLBACK_DATE_TIME, self.cb_rtc_time_update)
                self.rtc.set_date_time_callback_period(TimeServer.RTC_UPDATE_PERIOD)
Exemplo n.º 2
0
    def get_rtc_time(self):
        if self.rtc_uid == None:
            return False

        try:
            # Create Real-Time Clock device object
            self.rtc = BrickletRealTimeClock(self.rtc_uid, self.ipcon)
            year, month, day, hour, minute, second, centisecond, _ = self.rtc.get_date_time(
            )
            self.rtc_time = datetime.datetime(year, month, day, hour, minute,
                                              second, centisecond * 10000)
        except:
            return False

        return True
Exemplo n.º 3
0
    def get_rtc_time(self):
        if self.rtc_uid == None:
            return False

        try:
            # Create Real-Time Clock device object
            if self.rtc_device_identifier == BrickletRealTimeClock.DEVICE_IDENTIFIER:
                self.rtc = BrickletRealTimeClock(self.rtc_uid, self.ipcon)
                year, month, day, hour, minute, second, centisecond, _ = self.rtc.get_date_time(
                )
            else:
                self.rtc = BrickletRealTimeClockV2(self.rtc_uid, self.ipcon)
                year, month, day, hour, minute, second, centisecond, _, _ = self.rtc.get_date_time(
                )

            self.rtc_time = datetime.datetime(year, month, day, hour, minute,
                                              second, centisecond * 10000)
        except:
            return False

        return True
Exemplo n.º 4
0
        else:
            activCH2 = False
        if activCH2 == True:
            dr.set_selected_state(2, False)
            oled.write_line(3, 0, "Beleuchtung:      AUS")
            rlb2.set_color(brightness, 0, 0)
        else:
            dr.set_selected_state(2, True)
            oled.write_line(3, 0, "Beleuchtung:      EIN")
            rlb2.set_color(0, brightness, 0)


if __name__ == "__main__":
    time.sleep(10)
    ipcon = IPConnection()  # Create IP connection
    rtc = BrickletRealTimeClock(UID_RTC, ipcon)  # Create device object
    dr = BrickletDualRelay(UID_DR, ipcon)  # Create device object
    rlb1 = BrickletRGBLEDButton(UID_RLB_1, ipcon)  # Create device object
    rlb2 = BrickletRGBLEDButton(UID_RLB_2, ipcon)  # Create device object
    oled = BrickletOLED128x64(UID_OLED, ipcon)  # Create device object
    temp = BrickletTemperature(UID_TEMP, ipcon)  # Create device object
    mb1 = BrickMaster(UID_MB1, ipcon)  # Create device object
    mb2 = BrickMaster(UID_MB2, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected
    time.sleep(1)
    oled.clear_display()
    oled.write_line(1, 1, "Starting Application...")

    #***********Brick-Config********************************************