pingo-io / pingo-py Goto Github PK
View Code? Open in Web Editor NEWGeneric API for controlling boards with programmable IO pins
Home Page: http://pingo.io
License: MIT License
Generic API for controlling boards with programmable IO pins
Home Page: http://pingo.io
License: MIT License
Thanks to Jomar (@homembit), Intel has kindly donated some Intel Edison samples.
We should support Intel Edison too.
Hello,
Pingo should probably provide some examples for Internet Of Things using MQTT (Mosquitto for example http://mosquitto.org/ )
https://github.com/scls19fr/numpy-buffer/blob/master/samples/mqtt_publish.py
https://github.com/scls19fr/numpy-buffer/blob/master/samples/mqtt_subscribe.py
We could read an analog value, send to another board through MQTT
and change on the second board the delay of a blinking led (or something else)
Kind regards
Firmata have in their page a list of host softwares, with firmata support, well, I think the pingo could be in this list.
It is actually not useful to list all the pins together (particularly not the Vdd and Gnd pins).
Perhaps we should have several attributes or methods to list the pins:
(this issue is the result of observing users playing with pingo interactively)
Hello,
I wonder if a signal / slot mechanism shouldn't be more "user friendly".
For example we could write:
class MyApp(object):
def __init__(self):
...
self.switch.pressed.connect(self.do_it_when_pressed)
instead of
class MyApp(object):
def __init__(self):
...
self.switch.set_callback_up(self.do_it_when_pressed)
Some signal / slot library are
https://pythonhosted.org/blinker/
https://github.com/circuits/circuits
https://github.com/shaunduncan/smokesignal
An other pattern to consider may be Pub / sub
http://pubsub.sourceforge.net/
This issue is related to #60
Kind regards
Hello,
in http://www.pingo.io/docs/ we can see
board = pingo.detect.MyBoard()
but in https://github.com/pingo-io/pingo-py/blob/master/README.rst we see
board = pingo.detect.get_board()
When I see https://github.com/pingo-io/pingo-py/blob/master/pingo/detect/detect.py
I noticed
def get_board():
pass
# TODO: deprecate legacy "MyBoard" factory name
MyBoard = get_board
Thks to @lwalter86 for showing me this issue.
The WRTnode is a low-cost device (25,- USD) running OpenWRT, has a WiFi chip and sports 78 pins, see pin map. Many packages, including a stripped-down Python, are available, see WRTnode package list.
ubuntu@ubuntu:~/pingo/pingo/pcduino/tests$ python test_pcduino.py
Using pcDuino...
.EEs......
======================================================================
ERROR: test_200ohmRead (__main__.PcDuinoAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/pingo/pingo/test/level1/cases.py", line 26, in test_200ohmRead
pin.mode = pingo.IN
File "/home/ubuntu/pingo/pingo/board.py", line 266, in mode
self.board._set_analog_mode(self, mode)
AttributeError: 'PcDuino' object has no attribute '_set_analog_mode'
======================================================================
ERROR: test_pin_ratio (__main__.PcDuinoAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/pingo/pingo/test/level1/cases.py", line 34, in test_pin_ratio
pin.mode = pingo.IN
File "/home/ubuntu/pingo/pingo/board.py", line 266, in mode
self.board._set_analog_mode(self, mode)
AttributeError: 'PcDuino' object has no attribute '_set_analog_mode'
----------------------------------------------------------------------
Ran 10 tests in 0.017s
FAILED (errors=2, skipped=1)
ubuntu@ubuntu:~/pingo/pingo/pcduino/tests$
pingo is not available on Debian yet and the first move to have it on official repositories is to create a package. Then, we need to find a Debian Developer to sponsor the packaging of this software and sign the package before uploading it to Debian Mentors Server so it can be approved (or not) by the FTP-Masters team and then enter in the official repositories.
@kretcheu, can you please do the packaging stuff? :) I can help with Python-related stuff.
This will allow code such as board.digital_pins[6:]
GPIO_PATH = os.path.normpath('/sys/devices/virtual/misc/gpio/')
ADC_PATH = os.path.normpath('/proc/')
change to
GPIO_PATH = os.path.normpath('/sys/devices/virtual/misc/mode/')
ADC_PATH = os.path.normpath('/proc')
def pin_mode(pin, mode):
with open(GPIO_PATH+'mode/gpio%s' % pin, 'w') as f:
f.write(mode)
def digital_write(pin, value):
with open(GPIO_PATH+'pin/gpio%s' % pin, 'w') as f:
f.write(str(value))
def analog_read(pin):
with open(ADC_PATH+'adc%d' % pin) as f:
change to
with open(GPIO_PATH+'/gpio%s' % pin, 'w') as f:
with open(GPIO_PATH+'/gpio%s' % pin, 'w') as f:
with open(ADC_PATH+'/adc%d' % pin) as f:
Forcing implementors to create VddPins and GndPins for all boards is a bad idea, but our test_list_pins currently forces it.
This is related to the issue of the definition of the board.pins, .all_pins, .digital_pins, .analog_pins attributes.
This will enable this style of programming:
for pin in my_board: do_something(pin)
However, currently I am not happy with the default of listing the Vcc and Gnd pins...
This should iterate only over the digital pins, which are the most useful for beginners.
v0.1.9 is the last tag on GitHub. It was released on 2014-06-13
https://github.com/garoa/pingo/tags
v0.2.0 was released on 2014-08-13 only on pypi.
https://pypi.python.org/pypi/pingo/0.2.0
Hello,
PollingTask.__init__
should have a time_to_sleep
parameter instead of having a hard code value of 0.05
in run
.
Maybe this time_to_sleep
parameter should be set at Switch.start
(with default value being 0.05
)
Kind regards
The proper way to report an error like this is to raise an exception. When doing interactive demos, exiting causes the loss of the interactive session.
For example, tests/level0/cases.py requires Vdd connected to a digital input pin
In board.py the range is defined 0.0 to 1.0
In servo.py line 20 the range may be 0.0 to 180.0
I don't remember if I've already seen a run_tests.sh
file for a Python project, but trying to run it gave me the same error for each board:
danilo@danilo-P170EM ~/pingo $ ./run_tests.sh
RaspberryPi:
ImportError: No module named pingo
AutoDetect:
ImportError: No module named pingo
GhostBoard:
ImportError: No module named pingo
BeagleBoneBlack:
ImportError: No module named pingo
ArduinoFirmata:
ImportError: No module named pingo
Udoo:
ImportError: No module named pingo
PcDuino:
ImportError: No module named pingo
danilo@danilo-P170EM ~/pingo $ ls pingo
arduino board.pyc ghost pcduino rpi
bbb detect __init__.py pinGUIm test
board.py examples __init__.pyc __pycache__ udoo
There are some issues here:
All test files are Python scripts, yet they're missing a chmod +x
with a proper python2
shebang, since PEP294 tells us that:
[...] Python 2 only scripts should either be updated to be source compatible with Python 3 or else to use python2 in the shebang line.
Anyhow, should them really be scripts or just modules? With py.test the shebang would be !/usr/bin/env py.test
with no need to know whether __name__ == "__main__"
or not (and something alike with nose). With unittest, one can use the TestLoader to generalize it (see the pyNES solution to that).
It's not testing the "pre-staged" pingo package contents being developed. Even in a virtualenv, it's testing the last version which was installed on it. Using something like python -c "$(cat pingo/arduino/tests/test.py)"
from the project root directory runs the test on it, but that's probably not the way we want to do that. Tests should always be done in the development trunk, not in a installed version (if any).
Directory structure for tests is spread everywhere, I can hardly know how many tests are written up to now. There's two common solutions for that: a single subpackage pingo.tests
with all tests matching the specs, or a directory "tests" outside the pingo package directory (I'm not really sure if the directory should be called "test" or "tests').
Perhaps using a py.test approach would be better, where the framework could find the test files by itself, just by typing "py.test". That wouldn't change the unittest-based files, just the way they're called: calling py.test
in the project root dir. The same would happen with tox
. However, a common approach for Python projects is calling python setup.py test
for the setuptools test hook.
At first, no matter the way the tests are done in Pingo, they should work with python setup.py test
, but for now this command is running zero tests. That would be done on the project root directory (as almost everything should). As the test modules themselves don't need to be changed for py.test, calling py.test
at the same directory should also behave nicely without any parameter.
Hi @mantonelli,
We noticed that you started working on PyBoard.
But you seem you to have stopped.
Send us and email on [email protected]
We will be glad to help you.
Thanks.
Running on a RaspberryPi:
(.env)root@rpi-lr-bb400:~/pingo/pingo# python setup.py test
running test
running egg_info
writing pingo.egg-info/PKG-INFO
writing top-level names to pingo.egg-info/top_level.txt
writing dependency_links to pingo.egg-info/dependency_links.txt
reading manifest file 'pingo.egg-info/SOURCES.txt'
writing manifest file 'pingo.egg-info/SOURCES.txt'
running build_ext
==================================== test session starts =====================================
platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2
collected 49 items
pingo/arduino/tests/test_arduino.py ssssssssss
pingo/bbb/tests/test_bbb.py sssssss
pingo/detect/tests/test_detect.py .
pingo/ghost/tests/test_ghost.py sssssss
pingo/pcduino/tests/test_pcduino.py ssss.sssss
pingo/rpi/tests/test_rpi.py sssssss
pingo/udoo/tests/test_udoo.py sssssss
============================ 2 passed, 47 skipped in 6.01 seconds ============================
(.env)root@rpi-lr-bb400:~/pingo/pingo#
All rpi tests were skipped.
We will start writing Pingo Parts.
The first will be the Button.
We should take a look here:
https://github.com/theycallmeswift/BreakfastSerial
It seems to be a popular platform.
http://www.ti.com/tool/msp-exp430g2
Hi everyone.
As I said I'm new to pingo.
I'm trying to use pingo with different card, but I can't get anyone of them working.
Currently, with the Arduino UNO I get this message :
harold@localhost:~/Documents/python$ python essaiPingo
Python Version 2.7.8 (default, Jul 5 2015, 14:16:16)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)]
PyMata version 2.10 Copyright(C) 2013-15 Alan Yorinks All rights reserved.
Opening Arduino Serial port /dev/ttyACM0
Please wait while Arduino is being detected. This can take up to 30 seconds ...
Board Auto Discovery Failed!, Shutting Down
Traceback (most recent call last):
File "essaiPingo", line 8, in
led = b.pins[13]
File "/usr/lib64/python2.7/UserDict.py", line 22, in getitem
return self.class.missing(self, key)
File "/home/harold/pingo/pingo/util.py", line 61, in missing
return self[self.normalize(key)]
File "/usr/lib64/python2.7/UserDict.py", line 22, in getitem
return self.class.missing(self, key)
File "/home/harold/pingo/pingo/util.py", line 60, in missing
raise KeyError(key)
KeyError: '13'
My Arduino code is :
void setup()
{}
void loop()
{}
The "Tx" led on the UNO is blinking while attempting detection
I'm using Ardino IDE 1.0.6 to upload to the UNO.
Any advice ?
We just had an idea to expose the Board via a HTTP Server.
This would take a step further into the Internet of Things concept.
We have some o this on Yun. It has a HTTP server an a REST-like API.
Pingo could provide this server for all supported Boards.
Pingo has several groups of constants used for certain attributes such as pin mode (IN, OUT, ANALOG), pin state etc. Currently they are strings because that makes it easy to inspect their values. Ideally they should be enums, but there was a wide variety of enum implementations in Python, making it hard to choose. Since Python 3.4 has an Enum type in the standard library and it has been backported to work with Python 2 in the Enum34 project, Pingo should use it: https://pypi.python.org/pypi/enum34
pcDuino is a official Logo .
so .please change to pingo.pcDuino.pcDuino()
OR
pingo.pcduino.pcDuino()
Yes. It looks so beautiful.
Thanks
pin_states.json is write protected when installing pingo via pip.
new-host-5:pingo scls$ python drill.py
Using GhostBoard...
Traceback (most recent call last):
File "drill.py", line 7, in <module>
board = pingo.detect.MyBoard() # gets an instance of your board's driver
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/pingo/detect/detect.py", line 51, in MyBoard
return pingo.ghost.GhostBoard()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/pingo/ghost/ghost.py", line 47, in __init__
with open(PIN_STATES_FILEPATH, 'w') as fp:
IOError: [Errno 13] Permission denied: '/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/pingo/ghost/pin_states.json'
GhostBoard: cleaning up.
can you please tag the version 0.2.0, it will be usefull to Debian packaging.
Thanks..
Changing the assert to LOW will fix this? This test assumes that some pins are plugged?
Details below
=================================================== FAILURES ==========================================================================
_____________________________________________________________________________ RaspberryBasics.test_jumpwire _____________________________________________________________________________
self = <pingo.rpi.tests.test_rpi.RaspberryBasics testMethod=test_jumpwire>
def test_jumpwire(self):
''' Wire this DigitalPin directly into VDD '''
pin = self.board.pins[self.digital_input_pin_number]
pin.mode = pingo.IN
output = pin.state
assert output == pingo.HIGH
E AssertionError: assert 'LOW' == 'HIGH'
E - LOW
E + HIGH
pingo/test/level0/cases.py:64: AssertionError
I'm running a x86 Windows system and Arduino can't be detected from this system. Need to find a way to solve this issue without affect the entire detection process.
Currently only "Linux" and "Darwin" systems are implemented in detect/detect.py
So, I think this feature is already partially implemented on the "ghost" directory. I would like to evolve this behaviour. Something like the gpiocrust lib works ( https://github.com/zourtney/gpiocrust/ ) . What is missing? How is this behaviour now?
ps: Great lib! =D
$ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pingo
>>> pi = pingo.rpi.RaspberryPi()
>>> led = pi.pins[12]
>>> led.high()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pingo/board.py", line 48, in high
self.board.set_pin_state(self, HIGH)
File "pingo/rpi.py", line 95, in set_pin_state
fp.write(str(state))
IOError: [Errno 1] Operation not permitted
After running the test above, I was able to light up an LED connected to pin 12 (GPIO #18) using these commands:
$ sudo echo 18 > /sys/class/gpio/export
echo: write error: Device or resource busy
$ sudo echo 18 > /sys/class/gpio/unexport
$ sudo echo 18 > /sys/class/gpio/export
$ sudo echo out > /sys/class/gpio/gpio18/direction
$ sudo echo 1 > /sys/class/gpio/gpio18/value
It has no PwmPin.
self._add_pins(
[DigitalPin(self, location)
for location in range(detected_digital_pins)] +
[AnalogPin(self, 'A%s' % location, resolution=10)
for location in range(detected_analog_pins)]
)
I felt this specific need while I was planning to control a set of servos for a remake of the Golly Ghost arcade.
Hello,
it will be nice to provide interruptions support for Pingo.
see https://groups.google.com/forum/#!topic/pingo-io/7ekBhz7wYQk
Kind regards
(.env)vido@magrela:~/documents/pingo$ which python
/home/vido/documents/pingo/.env/bin/python
(.env)vido@magrela:~/documents/pingo$ pip freeze
argparse==1.2.1
wsgiref==0.1.2
(.env)vido@magrela:~/documents/pingo$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing pingo.egg-info/PKG-INFO
writing top-level names to pingo.egg-info/top_level.txt
writing dependency_links to pingo.egg-info/dependency_links.txt
writing pingo.egg-info/PKG-INFO
writing top-level names to pingo.egg-info/top_level.txt
writing dependency_links to pingo.egg-info/dependency_links.txt
reading manifest file 'pingo.egg-info/SOURCES.txt'
writing manifest file 'pingo.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/pingo
copying build/lib.linux-x86_64-2.7/pingo/board.py -> build/bdist.linux-x86_64/egg/pingo
copying build/lib.linux-x86_64-2.7/pingo/__init__.py -> build/bdist.linux-x86_64/egg/pingo
byte-compiling build/bdist.linux-x86_64/egg/pingo/board.py to board.pyc
byte-compiling build/bdist.linux-x86_64/egg/pingo/__init__.py to __init__.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pingo.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pingo.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pingo.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pingo.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/pingo-0.1.9-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pingo-0.1.9-py2.7.egg
Removing /usr/local/lib/python2.7/dist-packages/pingo-0.1.9-py2.7.egg
Copying pingo-0.1.9-py2.7.egg to /usr/local/lib/python2.7/dist-packages
pingo 0.1.9 is already the active version in easy-install.pth
Installed /usr/local/lib/python2.7/dist-packages/pingo-0.1.9-py2.7.egg
Processing dependencies for pingo==0.1.9
Finished processing dependencies for pingo==0.1.9
(.env)vido@magrela:~/documents/pingo$ pip freeze
argparse==1.2.1
wsgiref==0.1.2
(.env)vido@magrela:~/documents/pingo$
Hello,
last source version of pingo-py
doesn't seems to support Python 3.
$ nosetests3
E
======================================================================
ERROR: Failure: ImportError (No module named 'board')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/lib/python3/dist-packages/nose/loader.py", line 414, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python3/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python3/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/python3.4/imp.py", line 245, in load_module
return load_package(name, filename)
File "/usr/lib/python3.4/imp.py", line 217, in load_package
return methods.load()
File "<frozen importlib._bootstrap>", line 1220, in load
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/pi/github/pingo-py/pingo/__init__.py", line 2, in <module>
from board import ANALOG # noqa
ImportError: No module named 'board'
----------------------------------------------------------------------
Ran 1 test in 0.029s
FAILED (errors=1)
Is there any plan to support Python 3 ?
Kind regards
Pingo does not have a clear debounce/timing policy.
I suggest a decorator to deal with this. Like BreakfastSerial has.
https://github.com/theycallmeswift/BreakfastSerial/blob/master/BreakfastSerial/util.py
Hello,
I noticed a strange behavior with blinking led.
That's maybe a misunderstanding of the Pingo API from my side.
My goal is to have a led on to show user that software is running correctly.
At switch press, led should be blinking foreever (recording a video with picamera module).
At next switch press, led should stop blinking and be on (like before first blinking).
After an other switch press, led should be blinking foreever ... and so on...
I did this:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import atexit
from time import sleep
#import RPi.GPIO as GPIO
import pingo
from pingo.parts.led import Led
from pingo.parts.button import Switch
import time
class App(object):
def __init__(self):
#GPIO.setwarnings(False)
self.board = pingo.detect.get_board()
led_pin = self.board.pins[13]
self.led = Led(led_pin)
self.btn_pin = self.board.pins[7]
self.switch = Switch(self.btn_pin)
self.switch.set_callback_up(self.toggle)
self.recording = False
def loop(self):
self.init_led_and_switch()
try:
while(True):
time.sleep(1)
except KeyboardInterrupt:
print("User Cancelled (Ctrl C)")
self.stop_at_exit()
def toggle(self):
print("press")
self.recording = not self.recording
if self.recording:
self.led.blink(times=0, on_delay=0.8, off_delay=0.2) # blink foreever
self.start_recording()
else:
self.led.stop() # stop blinking
self.led.on() # doesn't seem to work as expected!!!!
self.stop_recording()
def init_led_and_switch(self):
self.led.on()
self.switch.start()
def start_recording(self):
print("start recording")
def stop_recording(self):
print("stop recording")
def stop_at_exit(self):
self.led.off()
self.switch.stop()
self.led.stop()
self.board.cleanup()
def main():
#atexit.register(GPIO.cleanup)
myapp = App()
myapp.loop()
if __name__ == "__main__":
main()
Any idea ?
Kind regards
CC: @lwalter86
write them!
Pingo is not compatible with Python3:
$ pip install pingo
Downloading/unpacking pingo
Downloading pingo-0.1.9.tar.gz
Running setup.py (path:/home/rodolfo/.virtualenvs/pingo-pong/build/pingo/setup.py) egg_info for package pingo
Installing collected packages: pingo
Running setup.py install for pingo
File "/home/rodolfo/.virtualenvs/pingo-pong/lib/python3.4/site-packages/pingo/rpi/spi/mcp3008.py", line 68
print display.format(count, res, volts, ticks)
^
SyntaxError: invalid syntax
Hello,
I think it will be nice to have an API to support short pressed / long pressed events with Switch
(or maybe in an other class like PushButton
).
here is an example
https://github.com/martinohanlon/pelmetcam/blob/master/pelmetcam.py (see ButtonControl
class)
with Raspberry and RPi.GPIO
see also (sorry in french) http://hardware-libre.fr/2014/03/raspberry-pi-plusieurs-fonctions-avec-un-seul-bouton-2/
Kind regards
Does any one can explain that?
The expected value is [0.0, 1.0]
One time it returns: 28.533724340175954
But on the next time: 0.980449657869
junkmen@junkyard2:~/documents/pingo/pingo/arduino/tests$ python test.py
.E.s.s.s..
======================================================================
ERROR: test_200ohmRead (__main__.ArduinoAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/junkmen/documents/pingo/pingo/test/level1/cases.py", line 27, in test_200ohmRead
_input = pin.state
AttributeError: 'AnalogPin' object has no attribute 'state'
----------------------------------------------------------------------
Ran 10 tests in 35.074s
FAILED (errors=1, skipped=3)
junkmen@junkyard2:~/documents/pingo/pingo/arduino/tests$ python test.py
..Fs.s.s..
======================================================================
FAIL: test_pin_ratio (__main__.ArduinoAnalogRead)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/junkmen/documents/pingo/pingo/test/level1/cases.py", line 39, in test_pin_ratio
self.assertAlmostEqual(_input, self.expected_analog_ratio, 2)
AssertionError: 28.533724340175954 != 0.98 within 2 places
----------------------------------------------------------------------
Ran 10 tests in 35.115s
FAILED (failures=1, skipped=3)
junkmen@junkyard2:~/documents/pingo/pingo/arduino/tests$ python test.py
.Value Read: 1003
.Value Read: 0.980449657869
.s.s.s..
----------------------------------------------------------------------
Ran 10 tests in 35.097s
OK (skipped=3)
Hello,
In a project, we are using push button and Pingo.
Unfortunately Swich
class only provides a class with a polling mechanism.
What is your opinion about adding to Switch
class some methods that could be used in a non threading context ?
We could have for example attributes such as pressed
or released
which would return True
or False
.
I also noticed that it's odd to have such a class named Switch
in a file named button.py
CC @lwalter86
I also wonder how this could behave if passed pin at init could come from a GhostBoard.
For unit test, it will be very convenient to add also methods to simulate that a button is being pressed or released.
but.press()
do_something()
but.release()
Kind regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.