def __init__(self):

        super(DfrobotBoard, self).__init__()

        # pin mappings
        self.pin_mappings = PinMappings(
            motion_pin=16,
            screen_register_select_pin=8,
            screen_enable_pin=9,
            screen_data_0_pin=4,
            screen_data_1_pin=5,
            screen_data_2_pin=6,
            screen_data_3_pin=7,
            screen_analog_input_pin=0
        )

        if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata:
            addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0")
            self.pin_mappings += 512

        self.motion = BISS0001(self.pin_mappings.motion_pin)

        self.screen = SAINSMARTKS(
            self.pin_mappings.screen_register_select_pin,
            self.pin_mappings.screen_enable_pin,
            self.pin_mappings.screen_data_0_pin,
            self.pin_mappings.screen_data_1_pin,
            self.pin_mappings.screen_data_2_pin,
            self.pin_mappings.screen_data_3_pin,
            self.pin_mappings.screen_analog_input_pin
        )

        self.last_motion = False
    def __init__(self):

        super(DfrobotBoard, self).__init__()

        # pin mappings
        self.pin_mappings = PinMappings(temperature_pin=2,
                                        buzzer_pin=15,
                                        screen_register_select_pin=8,
                                        screen_enable_pin=9,
                                        screen_data_0_pin=4,
                                        screen_data_1_pin=5,
                                        screen_data_2_pin=6,
                                        screen_data_3_pin=7,
                                        screen_analog_input_pin=0)
        self.voltage_adjust = 1.0

        if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata:
            addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0")
            self.pin_mappings += 512
            self.voltage_adjust = 0.66

        self.screen = SAINSMARTKS(self.pin_mappings.screen_register_select_pin,
                                  self.pin_mappings.screen_enable_pin,
                                  self.pin_mappings.screen_data_0_pin,
                                  self.pin_mappings.screen_data_1_pin,
                                  self.pin_mappings.screen_data_2_pin,
                                  self.pin_mappings.screen_data_3_pin,
                                  self.pin_mappings.screen_analog_input_pin)

        self.temperature = LM35(self.pin_mappings.temperature_pin)
        self.temperature.setScale(self.voltage_adjust)

        self.buzzer = Gpio(self.pin_mappings.buzzer_pin)
        self.buzzer.dir(DIR_OUT)
Пример #3
0
    def __init__(self):

        super(DfrobotBoard, self).__init__()

        # pin mappings
        self.pin_mappings = PinMappings(touch_pin=16,
                                        buzzer_pin=15,
                                        screen_register_select_pin=8,
                                        screen_enable_pin=9,
                                        screen_data_0_pin=4,
                                        screen_data_1_pin=5,
                                        screen_data_2_pin=6,
                                        screen_data_3_pin=7,
                                        screen_analog_input_pin=0)

        if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata:
            addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0")
            self.pin_mappings += 512

        self.screen = SAINSMARTKS(self.pin_mappings.screen_register_select_pin,
                                  self.pin_mappings.screen_enable_pin,
                                  self.pin_mappings.screen_data_0_pin,
                                  self.pin_mappings.screen_data_1_pin,
                                  self.pin_mappings.screen_data_2_pin,
                                  self.pin_mappings.screen_data_3_pin,
                                  self.pin_mappings.screen_analog_input_pin)

        self.touch = Button(self.pin_mappings.touch_pin)
        self.buzzer = Gpio(self.pin_mappings.buzzer_pin)

        self.buzzer.dir(DIR_OUT)

        self.touch_state = False
        self.stop_buzzer()
    def __init__(self):

        super(DfrobotBoard, self).__init__()

        # pin mappings
        self.pin_mappings = PinMappings(accel_x_pin=3,
                                        accel_y_pin=2,
                                        accel_z_pin=1,
                                        screen_register_select_pin=8,
                                        screen_enable_pin=9,
                                        screen_data_0_pin=4,
                                        screen_data_1_pin=5,
                                        screen_data_2_pin=6,
                                        screen_data_3_pin=7,
                                        screen_analog_input_pin=0)

        if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata:
            addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0")
            self.pin_mappings += 512

        self.screen = SAINSMARTKS(self.pin_mappings.screen_register_select_pin,
                                  self.pin_mappings.screen_enable_pin,
                                  self.pin_mappings.screen_data_0_pin,
                                  self.pin_mappings.screen_data_1_pin,
                                  self.pin_mappings.screen_data_2_pin,
                                  self.pin_mappings.screen_data_3_pin,
                                  self.pin_mappings.screen_analog_input_pin)

        # accelerometer setup
        self.ax = Aio(self.pin_mappings.accel_x_pin)
        self.ay = Aio(self.pin_mappings.accel_y_pin)
        self.az = Aio(self.pin_mappings.accel_z_pin)

        self.acceleration_detected = False
Пример #5
0
    def __init__(self):

        super(DfrobotBoard, self).__init__()

        # pin mappings
        self.pin_mappings = PinMappings(
            sound_pin=2,
            vibration_pin=15,
            screen_register_select_pin=8,
            screen_enable_pin=9,
            screen_data_0_pin=4,
            screen_data_1_pin=5,
            screen_data_2_pin=6,
            screen_data_3_pin=7,
            screen_analog_input_pin=0
        )

        if HARDWARE_CONFIG.platform == KNOWN_PLATFORMS.firmata:
            addSubplatform(GENERIC_FIRMATA, "/dev/ttyACM0")
            self.pin_mappings += 512

        self.screen = SAINSMARTKS(
            self.pin_mappings.screen_register_select_pin,
            self.pin_mappings.screen_enable_pin,
            self.pin_mappings.screen_data_0_pin,
            self.pin_mappings.screen_data_1_pin,
            self.pin_mappings.screen_data_2_pin,
            self.pin_mappings.screen_data_3_pin,
            self.pin_mappings.screen_analog_input_pin
        )

        self.sound = Microphone(self.pin_mappings.sound_pin)
        self.sound_ctx = thresholdContext()
        self.sound_ctx.averageReading = 0
        self.sound_ctx.runningAverage = 0
        self.sound_ctx.averagedOver = 2

        self.vibration = Button(self.pin_mappings.vibration_pin)

        self.sample_time = 2
        self.sample_number = 128