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.80.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b891f40091d70a3acb3e57edd7c285ae9b89c7b489f1a3c838bab949e5d07992 |
|
MD5 | 6180caf2e2f1f33800be20fb4f30c44a |
|
BLAKE2b-256 | 789ee3c22f16a74e854dd044464c6a17d54a6460b194aaeafda497d88ba36afb |
Close
Hashes for smartphone_connector-0.0.80-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27fa1c9097f153d5575c62acd1eadaae74b50b75709e0431d6d461e15f83478b |
|
MD5 | e30435c9588d7c868dd5035cc5cc4e02 |
|
BLAKE2b-256 | 642285f5679d8e1607cb28c560f64c044bfc2f5b8c743e5c99b49a2b83571cc1 |