From 7a7516d40ddc00b051dd8dcf8ab38b5f845dcec4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 1 Jan 2017 19:09:25 +0300 Subject: extmod/machine_signal: Implement "signal" abstraction for machine module. A signal is like a pin, but ca also be inverted (active low). As such, it abstracts properties of various physical devices, like LEDs, buttons, relays, buzzers, etc. To instantiate a Signal: pin = machine.Pin(...) signal = machine.Signal(pin, inverted=True) signal has the same .value() and __call__() methods as a pin. --- extmod/machine_signal.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 extmod/machine_signal.h (limited to 'extmod/machine_signal.h') diff --git a/extmod/machine_signal.h b/extmod/machine_signal.h new file mode 100644 index 0000000000..7f88cbaa87 --- /dev/null +++ b/extmod/machine_signal.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Paul Sokolovsky + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + + +#ifndef __MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H__ +#define __MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H__ + +#include "py/obj.h" + +extern const mp_obj_type_t machine_signal_type; + +#endif // __MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H__ -- cgit v1.2.3