Skip to main content

seeed-python-reterminal

Project description

Python Library for reTerminal

This is a Python library which enables you to use the onboard hardware on the reTerminal. Currently the accelerometer, user LEDs, user buttons and buzzer can be accessed using this Python library.

Installation

From PyPI

  • To install the latest release from PyPI
sudo pip3 install seeed-python-reterminal

From Source

  • To install from source, clone this repository
git clone https://github.com/Seeed-Studio/Seeed_Python_ReTerminal
  • Install the library
cd Seeed_Python_ReTerminal
sudo pip3 install .

Usage

User LEDs Test

import seeed_python_reterminal.core as rt
import time

print("STA ON, USR OFF")
rt.sta_led = True
rt.usr_led = False
time.sleep(1)

print("STA OFF, USR ON")
rt.sta_led = False
rt.usr_led = True
time.sleep(1)

print("STA RED, USR OFF")
rt.sta_led_green = False
rt.sta_led_red = True
rt.usr_led = False
time.sleep(1)

print("STA OFF, USR OFF")
rt.sta_led = False
rt.usr_led = False

Buzzer Test

import seeed_python_reterminal.core as rt
import time

print("BUZZER ON")
rt.buzzer = True
time.sleep(1)

print("BUZZER OFF")
rt.buzzer = False

User Buttons Test

import seeed_python_reterminal.core as rt
import seeed_python_reterminal.button as rt_btn


device = rt.get_button_device()
while True:
    for event in device.read_loop():
        buttonEvent = rt_btn.ButtonEvent(event)
        if buttonEvent.name != None:
            print(f"name={str(buttonEvent.name)} value={buttonEvent.value}")

Accelerometer Test

import seeed_python_reterminal.core as rt
import seeed_python_reterminal.acceleration as rt_accel


device = rt.get_acceleration_device()
while True:
    for event in device.read_loop():
        accelEvent = rt_accel.AccelerationEvent(event)
        if accelEvent.name != None:
            print(f"name={str(accelEvent.name)} value={accelEvent.value}")

Accelerometer and Buttons Test

import asyncio
import seeed_python_reterminal.core as rt
import seeed_python_reterminal.acceleration as rt_accel
import seeed_python_reterminal.button as rt_btn


async def accel_coroutine(device):
    async for event in device.async_read_loop():
        accelEvent = rt_accel.AccelerationEvent(event)
        if accelEvent.name != None:
            print(f"accel name={str(accelEvent.name)} value={accelEvent.value}")


async def btn_coroutine(device):
    async for event in device.async_read_loop():
        buttonEvent = rt_btn.ButtonEvent(event)
        if buttonEvent.name != None:
            print(f"name={str(buttonEvent.name)} value={buttonEvent.value}")


accel_device = rt.get_acceleration_device()
btn_device = rt.get_button_device()

asyncio.ensure_future(accel_coroutine(accel_device))
asyncio.ensure_future(btn_coroutine(btn_device))

loop = asyncio.get_event_loop()
loop.run_forever()

API Reference

  • usr_led: Turn on/off green USR LED
rt.usr_led = True #Turn on green USR LED
rt.usr_led = False #Turn off green USR LED
  • sta_led_red: Turn on/off red STA LED
rt.sta_led_red = True #Turn on red STA LED
rt.sta_led_red = False #Turn off red STA LED
  • sta_led_green: Turn on/off green STA LED
rt.sta_led_green = True #Turn on green STA LED
rt.sta_led_green = False #Turn off green STA LED

Note: If red STA LED is on during this time, the green STA LED will turn on over the red STA LED

  • sta_led: Turn on/off green STA LED
rt.sta_led = True #Turn on green STA LED
rt.sta_led = False #Turn off green STA LED

Note: If red STA LED is on during this time, the green STA LED will turn on and the red STA LED will turn off

  • buzzer : Turn on/off buzzer
rt.buzzer = True #Turn on buzzer
rt.buzzer = False #Turn off buzzer
  • get_button_device(): Obtain information about the buttons including all the events supported by them
device = rt.get_button_device()
  • ButtonEvent(): Calls the ButtonEvent() and returns the EVENT
buttonEvent = rt_btn.ButtonEvent(event)
  • get_acceleration_device(): Obtain information about the accelerometer including all the events supported by it
device = rt.get_acceleration_device()
  • AccelerationEvent(): Calls the AccelerationEvent() and returns the EVENT
accelEvent = rt_accel.AccelerationEvent(event)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seeed-python-reterminal-0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seeed_python_reterminal-0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file seeed-python-reterminal-0.2.tar.gz.

File metadata

  • Download URL: seeed-python-reterminal-0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for seeed-python-reterminal-0.2.tar.gz
Algorithm Hash digest
SHA256 a948cdb5656ed35524531044791ffbfb3493bb3de0a830147f45c6952659441d
MD5 f55738d54aa892d618832f9ad4b693bb
BLAKE2b-256 7df703a320e63172a93bae0d8618e28e281f385df9a378dbedab279b2d4791e2

See more details on using hashes here.

File details

Details for the file seeed_python_reterminal-0.2-py3-none-any.whl.

File metadata

  • Download URL: seeed_python_reterminal-0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5

File hashes

Hashes for seeed_python_reterminal-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 989b425cebad9e0cda7be4cfbfbb08edd95db6f3e0a3796ad9fdd1589bba1406
MD5 c394eaae384f7ec9e34fab98fc287343
BLAKE2b-256 b060bbd14e649d01e85e7035e6c0f780a5a1c1ca99bf91bd7a548ae0d0740aeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page