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
Built Distribution
Close
Hashes for seeed-python-reterminal-0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b0c2c42d790b7424034f2ddbb1d4c13f5b5a015202ba3fabf93c234fdec9ecb |
|
MD5 | 4b0baadfdb1d91fc7c488c6e28d24c68 |
|
BLAKE2b-256 | 52cbc117992c2dd21360331f488365c95b9f7915c105b8ef3bfb8b7765cba6dc |
Close
Hashes for seeed_python_reterminal-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40c804ce8b91048750ac23e0cdcbaaef06bdca7695eabacb81cfa40db47a63a8 |
|
MD5 | 00c10d455742874ba82be94ce5ad67cb |
|
BLAKE2b-256 | 9f1e21fd0d75330a36831292adadeb6414df159246879d6b6f34de7d7f4b1839 |