| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- commit c6af690a1490b4945f370433ee182631762c8fa1
- Author: Oliver Fabel <28701799+ofabel@users.noreply.github.com>
- Date: Sat Sep 7 20:00:34 2024 +0200
- library update
- diff --git a/genhdr/qstrdefs.generated.h b/genhdr/qstrdefs.generated.h
- index e48c33345..a6645415c 100644
- --- a/genhdr/qstrdefs.generated.h
- +++ b/genhdr/qstrdefs.generated.h
- @@ -393,6 +393,7 @@ QDEF1(MP_QSTR_gpio_get_pin, 85, 12, "gpio_get_pin")
- QDEF1(MP_QSTR_gpio_init_pin, 185, 13, "gpio_init_pin")
- QDEF1(MP_QSTR_gpio_set_pin, 65, 12, "gpio_set_pin")
- QDEF1(MP_QSTR_hex, 112, 3, "hex")
- +QDEF1(MP_QSTR_infrared_receive, 112, 16, "infrared_receive")
- QDEF1(MP_QSTR_intersection, 40, 12, "intersection")
- QDEF1(MP_QSTR_intersection_update, 6, 19, "intersection_update")
- QDEF1(MP_QSTR_isdisjoint, 247, 10, "isdisjoint")
- diff --git a/mp_flipper_modflipperzero.c b/mp_flipper_modflipperzero.c
- index 343fd31b0..cb7de86e2 100644
- --- a/mp_flipper_modflipperzero.c
- +++ b/mp_flipper_modflipperzero.c
- @@ -575,6 +575,23 @@ static mp_obj_t flipperzero_pwm_is_running(mp_obj_t pin_obj) {
- }
- static MP_DEFINE_CONST_FUN_OBJ_1(flipperzero_pwm_is_running_obj, flipperzero_pwm_is_running);
-
- +static mp_obj_t flipperzero_infrared_receive(size_t n_args, const mp_obj_t* args) {
- + mp_int_t timeout = n_args > 0 ? mp_obj_get_int(args[0]) : MP_FLIPPER_INFRARED_RX_DEFAULT_TIMEOUT;
- +
- + size_t length = 0;
- + uint32_t* buffer = mp_flipper_infrared_receive(timeout, &length);
- + mp_obj_t* signal = malloc(length * sizeof(mp_obj_t));
- +
- + for(uint16_t i = 0; i < length; i++) {
- + signal[i] = mp_obj_new_int(buffer[i]);
- + }
- +
- + free(buffer);
- +
- + return mp_obj_new_list(length, signal);
- +}
- +static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(flipperzero_infrared_receive_obj, 0, 1, flipperzero_infrared_receive);
- +
- static const mp_rom_map_elem_t flipperzero_module_globals_table[] = {
- // light
- {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_flipperzero)},
- @@ -800,6 +817,8 @@ for octave in range(9):
- {MP_ROM_QSTR(MP_QSTR_pwm_start), MP_ROM_PTR(&flipperzero_pwm_start_obj)},
- {MP_ROM_QSTR(MP_QSTR_pwm_stop), MP_ROM_PTR(&flipperzero_pwm_stop_obj)},
- {MP_ROM_QSTR(MP_QSTR_pwm_is_running), MP_ROM_PTR(&flipperzero_pwm_is_running_obj)},
- + // infrared - functions
- + {MP_ROM_QSTR(MP_QSTR_infrared_receive), MP_ROM_PTR(&flipperzero_infrared_receive_obj)},
- };
- static MP_DEFINE_CONST_DICT(flipperzero_module_globals, flipperzero_module_globals_table);
-
- diff --git a/mp_flipper_modflipperzero.h b/mp_flipper_modflipperzero.h
- index 598d1c185..98d7b9ae9 100644
- --- a/mp_flipper_modflipperzero.h
- +++ b/mp_flipper_modflipperzero.h
- @@ -1,5 +1,6 @@
- #pragma once
-
- +#include <stddef.h>
- #include <stdint.h>
- #include <stdbool.h>
-
- @@ -239,3 +240,8 @@ float mp_flipper_adc_convert_to_voltage(uint16_t value);
- bool mp_flipper_pwm_start(uint8_t raw_pin, uint32_t frequency, uint8_t duty);
- void mp_flipper_pwm_stop(uint8_t raw_pin);
- bool mp_flipper_pwm_is_running(uint8_t raw_pin);
- +
- +#define MP_FLIPPER_INFRARED_RX_DEFAULT_TIMEOUT (1000000)
- +#define MP_FLIPPER_INFRARED_RX_BUFFER_SIZE (1024)
- +
- +uint32_t* mp_flipper_infrared_receive(uint32_t timeout, size_t* length);
|