32
32
33
33
#include "shared-bindings/microcontroller/Pin.h"
34
34
#include "shared-bindings/pulseio/PulseOut.h"
35
- #include "shared-bindings/pwmio/PWMOut.h"
36
35
#include "shared-bindings/util.h"
37
36
38
37
//| class PulseOut:
39
- //| """Pulse PWM "carrier" output on and off. This is commonly used in infrared remotes. The
40
- //| pulsed signal consists of timed on and off periods. Unlike PWM , there is no set duration
38
+ //| """Pulse PWM-modulated "carrier" output on and off. This is commonly used in infrared remotes. The
39
+ //| pulsed signal consists of timed on and off periods. Unlike `pwmio.PWMOut` , there is no set duration
41
40
//| for on and off pairs."""
42
41
//|
43
42
//| def __init__(
53
52
//|
54
53
//| import array
55
54
//| import pulseio
56
- //| import pwmio
57
55
//| import board
58
56
//|
59
57
//| # 50% duty cycle at 38kHz.
67
65
//| pulse.send(pulses)"""
68
66
//| ...
69
67
STATIC mp_obj_t pulseio_pulseout_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
68
+ #if CIRCUITPY_PULSEIO_PULSEOUT
70
69
enum { ARG_pin , ARG_frequency , ARG_duty_cycle };
71
70
static const mp_arg_t allowed_args [] = {
72
71
{ MP_QSTR_pin , MP_ARG_REQUIRED | MP_ARG_OBJ },
@@ -84,8 +83,12 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
84
83
self -> base .type = & pulseio_pulseout_type ;
85
84
common_hal_pulseio_pulseout_construct (self , pin , frequency , duty_cycle );
86
85
return MP_OBJ_FROM_PTR (self );
86
+ #else
87
+ mp_raise_NotImplementedError (NULL );
88
+ #endif
87
89
}
88
90
91
+ #if CIRCUITPY_PULSEIO_PULSEOUT
89
92
//| def deinit(self) -> None:
90
93
//| """Deinitialises the PulseOut and releases any hardware resources for reuse."""
91
94
//| ...
@@ -138,14 +141,17 @@ STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) {
138
141
return mp_const_none ;
139
142
}
140
143
MP_DEFINE_CONST_FUN_OBJ_2 (pulseio_pulseout_send_obj , pulseio_pulseout_obj_send );
144
+ #endif // CIRCUITPY_PULSEIO_PULSEOUT
141
145
142
146
STATIC const mp_rom_map_elem_t pulseio_pulseout_locals_dict_table [] = {
143
147
// Methods
148
+ #if CIRCUITPY_PULSEIO_PULSEOUT
144
149
{ MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& pulseio_pulseout_deinit_obj ) },
145
150
{ MP_ROM_QSTR (MP_QSTR___del__ ), MP_ROM_PTR (& pulseio_pulseout_deinit_obj ) },
146
151
{ MP_ROM_QSTR (MP_QSTR___enter__ ), MP_ROM_PTR (& default___enter___obj ) },
147
152
{ MP_ROM_QSTR (MP_QSTR___exit__ ), MP_ROM_PTR (& pulseio_pulseout___exit___obj ) },
148
153
{ MP_ROM_QSTR (MP_QSTR_send ), MP_ROM_PTR (& pulseio_pulseout_send_obj ) },
154
+ #endif // CIRCUITPY_PULSEIO_PULSEOUT
149
155
};
150
156
STATIC MP_DEFINE_CONST_DICT (pulseio_pulseout_locals_dict , pulseio_pulseout_locals_dict_table );
151
157
0 commit comments