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.89.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c037d02fb7b6f8e6fdd459900541bb6696b2222c70422a56351cd75fbd990823 |
|
MD5 | f434c681c4a4e4dde92fd3d59196d079 |
|
BLAKE2b-256 | 67d24d4dc916d9cb37249919c46ca581b7e06cf125879455626c4f4e83b4db1e |
Close
Hashes for smartphone_connector-0.0.89-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2659f57b203c7ed146356ff14133c29d8422621d83bcb2af4881a2e9457c4d2b |
|
MD5 | 6a1255c65fdf73ccd017588759025643 |
|
BLAKE2b-256 | 4ed5cb6ce2917b5d0b5f97dd9859ccf6febd8ec75c13234cbdd7ee68f951c96f |