Skip to main content

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.

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. Gyroscope-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/*

Changelog

  • 0.0.115: fix audio path checking
  • 0.0.113: fix reporting of pos_x and pos_y on collisions
  • 0.0.111: support timer events from socketio_server
  • 0.0.110: add method report(value: int | float, report_type: str, to: '__GAME_RUNNER__')
  • 0.0.109: fix typo in update_ellipse
  • 0.0.108: introduce clean_playground method to remove all sprites and lines from the current playground, but keep the playground config as is. And minor bug fixes.
  • 0.0.107: can mix absolute and relative movements with apply_movements and apply_movement
  • 0.0.106: add possibility to control movement distances
  • 0.0.105: control repeats of movement sequences
  • 0.0.104: add methods to apply movements to objects:
    # single movement
    device.apply_movement(id='circle', direction=[1, 1], time_span=1, speed=3)
    # movement sequence
    with device.apply_movements(id='circle') as movement:
        movement(direction=[1, 0], time_span=1, speed=2)
        movement(direction=[-1, 0], time_span=1, speed=2)
    
  • 0.0.103: change function annotation of set_timeout(callback, time, repeat=1) instead of set_timeout(callback, interval, iteration_count=inf)
  • 0.0.102: add alias methods for subscribe_async: set_timeout, schedule, execute_in
  • 0.0.101: introduce move_to(id: str, pos: [x, y], via: [x, y]) method to make jumps easyier. Event auto_movement_pos is triggered when an auto movement within a sequence finished.
  • 0.0.100: support image formats .gif, .bmp, .webp
  • 0.0.99: introduce method add_svg_to_playground(name: str, raw_svg: str) to upload plain svg source text
  • 0.0.98 fix iteration count
  • 0.0.97: introduce sound - provide a audio_tracks source directory in configure_playground and start/stop sounds with play_sound(name: str, id: Optional[str]) / stop_sound(name: Optional[str], id: Optional[str])
  • 0.0.96 register multiple callback functions with on(event, clbk)
  • 0.0.95 support border_style and border_width for sprites

Metadata

Release files for smartphone-connector 0.0.115

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartphone-connector 0.0.115
File Size Uploaded Provenance Actions
smartphone_connector-0.0.115.tar.gz 30.7 kB Without provenance Details for smartphone_connector-0.0.115.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smartphone-connector 0.0.115
File Interpreter ABI Platform Actions
smartphone_connector-0.0.115-py3-none-any.whl Python 3 none any Details for smartphone_connector-0.0.115-py3-none-any.whl

Total release size: 61.7 kB

Release files / smartphone_connector-0.0.115.tar.gz

Download URL smartphone_connector-0.0.115.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e8146e4b20795ed97a8e85226bc0eaf1c2a989175ba8a986118246ba56587d1f
BLAKE2b-256 checksum
How to use checksums
98d696115de4911fc7c10caf0d969779562a80b85f78417f4437927a03d98dcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release files / smartphone_connector-0.0.115-py3-none-any.whl

Download URL smartphone_connector-0.0.115-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7d5ee113acf0c2200c09dc3087c8aa1e5debe6a4d2c3aa548b83d9db70d5427
BLAKE2b-256 checksum
How to use checksums
dcf2650ec42d9da6831fdfdb2d0525315804ecfb621984c127c0fa227dc2e6ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Security for smartphone-connector 0.0.115

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.115 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page