A library to control Cytron Pi StemHat
Project description
StemHat Python Package Documentation
The StemHat Python package provides an easy-to-use interface for controlling the StemHat hardware. It includes functions for managing LEDs, motors, servos, buzzers, and reading sensor data like temperature, humidity, light, and analog inputs. It also supports controlling an OLED display.
Installation
Install the package using pip:
pip install StemHat
Usage
Importing the Package
import StemHat
Functions
LED Control
SetLED(led, red, blue, green)
Sets the color of the specified LED.
Parameters:
led(int): The LED to control (0 or 1).red(int): The red component (0-255).blue(int): The blue component (0-255).green(int): The green component (0-255).
Buzzer Control
SetBuzzer(frequency)
Sets the buzzer frequency.
Parameters:
frequency(int): The frequency in Hz (0-2550).
Motor Control
SetMotors(LeftMotorSpeed, RightMotorSpeed)
Sets the speed of the left and right motors.
Parameters:
LeftMotorSpeed(int): Speed of the left motor (-100 to 100).RightMotorSpeed(int): Speed of the right motor (-100 to 100).
Servo Control
SetServo(servo, angle)
Sets the angle of the specified servo.
Parameters:
servo(int): The servo to control (1, 2, 3, or 4).angle(int): The angle to set (0-180).
Sensor Readings
GetAnalog(analog)
Reads the analog value from the specified analog input.
Parameters:
analog(int): The analog input to read (0 or 1).
Returns:
- (int): The analog value.
GetLightSensor()
Reads the light sensor value.
Returns:
- (int): The light sensor value.
GetVoltage()
Reads the input voltage.
Returns:
- (int): The voltage value.
GetButton(button)
Reads the state of the specified button.
Parameters:
button(int): The button to read (5 or 6).
Returns:
- (bool): The button state (True if pressed, False otherwise).
GetUltrasonic()
Reads the ultrasonic sensor value.
Returns:
- (int): The ultrasonic sensor value.
GetTemperature()
Reads the temperature from the AHT20 sensor.
Returns:
- (float): The temperature in Celsius.
GetHumidity()ne_width` (int): The width of the outline.
OledLine(x1, y1, x2, y2)
Draws a line on the OLED display.
Parameters:
x1(int): The x-coordinate of the start point.y1(int): The y-coordinate of the start point.x2(int): The x-coordinate of the end point.y2(int): The y-coordinate of the end point.
OledPoint(x, y, color)
Draws a point on the OLED display.
Parameters:
x(int): The x-coordinate of the point.y(int): The y-coordinate of the point.color(int): The color of the point (0 for black, 1 for white).
OledCircles(x, y, radius, outline, outline_width)
Draws a circle on the OLED display.
Parameters:
x(int): The x-coordinate of the center.y(int): The y-coordinate of the center.radius(int): The radius of the circle.outline(int): Outline mode (0 for outline, 1 for solid).outline_width(int): The width of the outline.
OledText(x, y, text, size, color)
Draws text on the OLED display.
Parameters:
x(int): The x-coordinate of the text.y(int): The y-coordinate of the text.text(str): The text to display.size(int): The font size.color(int): The text color (0 for black, 1 for white).
OledImage(x, y, img_path, scale, invert)
Draws an image on the OLED display.
Parameters:
x(int): The x-coordinate of the image.y(int): The y-coordinate of the image.img_path(str): The path to the image file.scale(int): Scale mode (0 for no scaling, 1 for scaling).invert(int): Invert mode (0 for no inversion, 1 for inversion).
OledClear()
Clears the OLED display.
OledUpdate()
Updates the OLED display with the current drawing.
🎉 Now you're ready to use StemHat with Python! 🚀
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stemhat-0.2.2.tar.gz.
File metadata
- Download URL: stemhat-0.2.2.tar.gz
- Upload date:
- Size: 163.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7692c8d8ff5c45ba1dc576b5a2bc1e7bae0116c56b0d3b51e7250788b3cb7b56
|
|
| MD5 |
50211dc922f82f054b7928fcd718f7d6
|
|
| BLAKE2b-256 |
985a1e3439429711b40f64df4b488a18f1df8582418714b620f9df3e83137c3b
|
File details
Details for the file stemhat-0.2.2-py3-none-any.whl.
File metadata
- Download URL: stemhat-0.2.2-py3-none-any.whl
- Upload date:
- Size: 161.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1374627402d33e218f7bd7bb207422a862c7c5cc5711ec0c4e0f8f9628405052
|
|
| MD5 |
e60560c630b7b1d2f8dec0f34fa203ab
|
|
| BLAKE2b-256 |
d227bb7de6de9d9f2a8e99a01b551e4b51868f73d89a3647c93dc5842182f9fb
|