Exemple #1
0
    def test_blink_pattern(self):
        expected = [
            0x02, 0x03, 0x00, 0x02, 0x1f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00,
            0x00, 0xf4, 0x01, 0x88, 0x13, 0x0a
        ]
        pattern = Led.Pattern(delay_time_ms=5000, repeat_count=10)

        self.libmetawear.mbl_mw_led_load_preset_pattern(
            byref(pattern), Led.PRESET_BLINK)
        self.libmetawear.mbl_mw_led_write_pattern(self.board, byref(pattern),
                                                  Led.COLOR_GREEN)

        self.assertEqual(self.command, expected)
Exemple #2
0
    def test_pulse_pattern(self):
        expected = [
            0x02, 0x03, 0x02, 0x02, 0x1f, 0x00, 0xd5, 0x02, 0xf4, 0x01, 0xd5,
            0x02, 0xd0, 0x07, 0x00, 0x00, 0x28
        ]
        pattern = Led.Pattern(delay_time_ms=12345, repeat_count=40)

        self.libmetawear.mbl_mw_led_load_preset_pattern(
            byref(pattern), Led.PRESET_PULSE)
        self.libmetawear.mbl_mw_led_write_pattern(self.board, byref(pattern),
                                                  Led.COLOR_BLUE)

        self.assertEqual(self.command, expected)
Exemple #3
0
    def test_solid_pattern(self):
        expected = [
            0x02, 0x03, 0x01, 0x02, 0x1f, 0x1f, 0x00, 0x00, 0xf4, 0x01, 0x00,
            0x00, 0xE8, 0x03, 0x00, 0x00, 0x14
        ]
        pattern = Led.Pattern(delay_time_ms=10000, repeat_count=20)

        self.libmetawear.mbl_mw_led_load_preset_pattern(
            byref(pattern), Led.PRESET_SOLID)
        self.libmetawear.mbl_mw_led_write_pattern(self.board, byref(pattern),
                                                  Led.COLOR_RED)

        self.assertEqual(self.command, expected)
Exemple #4
0
    def comparator_even_created(self, signal):
        pattern = Led.Pattern(pulse_duration_ms=1000,
                              high_time_ms=500,
                              high_intensity=16,
                              low_intensity=16,
                              repeat_count=Led.REPEAT_INDEFINITELY)
        self.libmetawear.mbl_mw_event_record_commands(self.comp_odd_signal)
        self.libmetawear.mbl_mw_led_write_pattern(self.board, byref(pattern),
                                                  Led.COLOR_BLUE)
        self.libmetawear.mbl_mw_led_play(self.board)
        self.libmetawear.mbl_mw_event_end_record(self.comp_odd_signal,
                                                 self.commands_recorded_fn)

        self.libmetawear.mbl_mw_event_record_commands(signal)
        self.libmetawear.mbl_mw_led_stop_and_clear(self.board)
        self.libmetawear.mbl_mw_event_end_record(signal,
                                                 self.cmds_recorded_handler)
Exemple #5
0
    def test_disconnected_event(self):
        expected_cmds = [[0x0a, 0x02, 0x11, 0x0a, 0xff, 0x02, 0x03, 0x0f],
                         [
                             0x0a, 0x03, 0x02, 0x02, 0x1f, 0x00, 0x00, 0x00,
                             0x32, 0x00, 0x00, 0x00, 0xf4, 0x01, 0x00, 0x00,
                             0x0a
                         ], [0x0a, 0x02, 0x11, 0x0a, 0xff, 0x02, 0x01, 0x01],
                         [0x0a, 0x03, 0x01]]

        pattern = Led.Pattern(high_time_ms=50,
                              pulse_duration_ms=500,
                              high_intensity=31,
                              repeat_count=10)
        event = self.libmetawear.mbl_mw_settings_get_disconnect_event(
            self.board)

        self.libmetawear.mbl_mw_event_record_commands(event)
        self.libmetawear.mbl_mw_led_write_pattern(self.board, byref(pattern),
                                                  Led.COLOR_BLUE)
        self.libmetawear.mbl_mw_led_play(self.board)
        self.libmetawear.mbl_mw_event_end_record(
            event,
            Fn_VoidPtr_Int(lambda event, status: self.assertEqual(
                self.command_history, expected_cmds)))