Talk to a socketio server
Project description
Smartphone Connector
This simple package exposes methods to interact with smartphones connected to a socket.io server instance.
Examples
All examples and scripts on GitHub
Draw 3x3 checker board
from smartphone_connector import Connector
phone = Connector('https://io.lebalz.ch', 'FooBar')
# draw a 3x3 checker board
phone.set_grid([
['black','white','black'],
['white','black','white'],
['black','white','black']
], broadcast=True)
# print the letter A
phone.set_grid([
[9,9,9,9],
[9,0,0,9],
[9,9,9,9],
[9,0,0,9],
[9,0,0,9],
])
results on all devices in the following screen.
When broadcast
is set to False
(default), only the FooBar
devices display the checker board.
Stream & display gyroscope data
from smartphone_connector import Connector, GyroMsg
import matplotlib.pyplot as plt
phone = Connector('https://io.lebalz.ch', 'FooBar')
MAX_SAMPLES = 300
y = []
x = []
plt.show()
def on_gyro(data: GyroMsg):
if len(x) > MAX_SAMPLES:
x.pop(0)
y.pop(0)
x.append(data.time_stamp)
y.append([data.alpha, data.beta, data.gamma])
def on_intervall():
plt.clf()
plt.plot(x, y)
plt.pause(0.01)
phone.on_gyro = on_gyro
phone.subscribe(on_intervall, interval=0)
Displays gyroscope data from the smartphone on a Matplotlib-Plot.
Package and upload to pip
@see this tutorial
rm -rf build/ dist/ smartphone_connector.egg-info/ && \
python3 setup.py sdist bdist_wheel && \
python3 -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for smartphone_connector-0.0.95.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbe82acaf1aeec12d6bbb13bdbf0fd7b4b457a59f870aec74d7a789b52159b49 |
|
MD5 | 27f1622b9b76eb47a8a2864b2692a070 |
|
BLAKE2b-256 | 06a5a0b3ea6ee4ce651b00e0bba0def159d45d47ccb58b4e2912e59de68a89c8 |
Close
Hashes for smartphone_connector-0.0.95-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d70ad9dac7ab8aba0c1f3486311cebe6d872ff7f9cdc6e8aab98e7b0f28e4c99 |
|
MD5 | 4f5b4f342d63f856ade0de97a30b1a0e |
|
BLAKE2b-256 | 4e45142a36e9882e903641b14241bc265eb6e31dd9d3b3f043de1868ca6dba37 |