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.86.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2c930571df2b946bbc62edb74cb57f710b1fe16ca7bd4fac851c0c66024edf5 |
|
MD5 | 91f3001be6f96f02202496061a83a719 |
|
BLAKE2b-256 | 6c87e8df516bec2a0b1b568d23df7ee850188e0f53c5648659bd48ba9a1c2c30 |
Close
Hashes for smartphone_connector-0.0.86-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 356105dc75f5c9876a2fce484df3a69e48125d43cf67883042e121bce2852d86 |
|
MD5 | 2e5bb216c080d6bc39529626e446d883 |
|
BLAKE2b-256 | f186985fe66fddc421ee4c5620d0d13a52bc10b27ab377b85b7c55d3160e5101 |