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.93.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71b3af6602296f85a40caa827872f49e747f8acd4b13746bffce3a7384afc8df |
|
MD5 | feca76823325e246db6271f6676a0625 |
|
BLAKE2b-256 | ce6346e0da77078be2f546da9579382b57d5a6a596643dbdbbcf921d372e42f9 |
Close
Hashes for smartphone_connector-0.0.93-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4906b3cfea16a11dc7de98b6c33a38ce29f69c5c6cfc6422cf51eccd321ef6ba |
|
MD5 | ff8f099dd7b1adf3c14e1ade80d50b8d |
|
BLAKE2b-256 | b9319a631400adc8e2fbe565e2858016681d673e30064aaee09f7cd1cb6994f3 |