3232
3333#include "shared-bindings/microcontroller/Pin.h"
3434#include "shared-bindings/pulseio/PulseOut.h"
35- #include "shared-bindings/pwmio/PWMOut.h"
3635#include "shared-bindings/util.h"
3736
3837//| 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
4140//| for on and off pairs."""
4241//|
4342//| def __init__(
5352//|
5453//| import array
5554//| import pulseio
56- //| import pwmio
5755//| import board
5856//|
5957//| # 50% duty cycle at 38kHz.
6765//| pulse.send(pulses)"""
6866//| ...
6967STATIC 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
7069 enum { ARG_pin , ARG_frequency , ARG_duty_cycle };
7170 static const mp_arg_t allowed_args [] = {
7271 { 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
8483 self -> base .type = & pulseio_pulseout_type ;
8584 common_hal_pulseio_pulseout_construct (self , pin , frequency , duty_cycle );
8685 return MP_OBJ_FROM_PTR (self );
86+ #else
87+ mp_raise_NotImplementedError (NULL );
88+ #endif
8789}
8890
91+ #if CIRCUITPY_PULSEIO_PULSEOUT
8992//| def deinit(self) -> None:
9093//| """Deinitialises the PulseOut and releases any hardware resources for reuse."""
9194//| ...
@@ -138,14 +141,17 @@ STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) {
138141 return mp_const_none ;
139142}
140143MP_DEFINE_CONST_FUN_OBJ_2 (pulseio_pulseout_send_obj , pulseio_pulseout_obj_send );
144+ #endif // CIRCUITPY_PULSEIO_PULSEOUT
141145
142146STATIC const mp_rom_map_elem_t pulseio_pulseout_locals_dict_table [] = {
143147 // Methods
148+ #if CIRCUITPY_PULSEIO_PULSEOUT
144149 { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& pulseio_pulseout_deinit_obj ) },
145150 { MP_ROM_QSTR (MP_QSTR___del__ ), MP_ROM_PTR (& pulseio_pulseout_deinit_obj ) },
146151 { MP_ROM_QSTR (MP_QSTR___enter__ ), MP_ROM_PTR (& default___enter___obj ) },
147152 { MP_ROM_QSTR (MP_QSTR___exit__ ), MP_ROM_PTR (& pulseio_pulseout___exit___obj ) },
148153 { MP_ROM_QSTR (MP_QSTR_send ), MP_ROM_PTR (& pulseio_pulseout_send_obj ) },
154+ #endif // CIRCUITPY_PULSEIO_PULSEOUT
149155};
150156STATIC MP_DEFINE_CONST_DICT (pulseio_pulseout_locals_dict , pulseio_pulseout_locals_dict_table );
151157
0 commit comments