From 714521a4c7a6814c365c061bcf967c4c45692e3d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 7 Jun 2017 14:39:12 -0700 Subject: shared-bindings: Update docs to remove with statements from examples but add more detail to the design guide about their use. --- shared-bindings/pulseio/PulseIn.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'shared-bindings/pulseio/PulseIn.c') diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index a5d5d0c72..89196e841 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -61,22 +61,23 @@ //| import pulseio //| import board //| -//| with pulseio.PulseIn(board.D7) as pulses: -//| # Wait for an active pulse -//| while len(pulses) == 0: -//| pass -//| # Pause while we do something with the pulses -//| pulses.pause() +//| pulses = pulseio.PulseIn(board.D7) //| -//| # Print the pulses. pulses[0] is an active pulse unless the length -//| # reached max length and idle pulses are recorded. -//| print(pulses) +//| # Wait for an active pulse +//| while len(pulses) == 0: +//| pass +//| # Pause while we do something with the pulses +//| pulses.pause() //| -//| # Clear the rest -//| pulse_in.clear() +//| # Print the pulses. pulses[0] is an active pulse unless the length +//| # reached max length and idle pulses are recorded. +//| print(pulses) //| -//| # Resume with an 80 microsecond active pulse -//| pulse_in.resume(80) +//| # Clear the rest +//| pulse_in.clear() +//| +//| # Resume with an 80 microsecond active pulse +//| pulse_in.resume(80) //| STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) { mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); @@ -122,7 +123,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_deinit_obj, pulseio_pulsein_dei //| .. method:: __exit__() //| -//| Automatically deinitializes the hardware when exiting a context. +//| Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info. //| STATIC mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; -- cgit v1.2.3