Note
Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.
Why Join?
Expert Support: Solve post-sale issues and technical challenges with help from our community and team.
Learn & Share: Exchange tips and tutorials to enhance your skills.
Exclusive Previews: Get early access to new product announcements and sneak peeks.
Special Discounts: Enjoy exclusive discounts on our newest products.
Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.
π Ready to explore and create with us? Click [here] and join today!
module utilsο
- robot_hat.utils.set_volume(value)ο
Set volume
- Parameters:
value (int) β volume(0~100)
- robot_hat.utils.run_command(cmd, user=None, group=None)ο
Run command and return status and output
- Parameters:
cmd (str) β command to run
- Returns:
status, output
- Return type:
tuple
- robot_hat.utils.is_installed(cmd)ο
Check if command is installed
- Parameters:
cmd (str) β command to check
- Returns:
True if installed
- Return type:
bool
- robot_hat.utils.mapping(x, in_min, in_max, out_min, out_max)ο
Map value from one range to another range
- Parameters:
x (float/int) β value to map
in_min (float/int) β input minimum
in_max (float/int) β input maximum
out_min (float/int) β output minimum
out_max (float/int) β output maximum
- Returns:
mapped value
- Return type:
float/int
- robot_hat.utils.get_ip(ifaces=['wlan0', 'eth0'])ο
Get IP address
- Parameters:
ifaces (list) β interfaces to check
- Returns:
IP address or False if not found
- Return type:
str/False
- robot_hat.utils.check_executable(executable)ο
Check if executable is installed
- Parameters:
executable (str) β executable name
- Returns:
True if installed
- Return type:
bool
- class robot_hat.utils.LazyReader(read_function: Callable, interval: int = 10)ο
Lazy reader Read something in a given interval, even if you read it multiple times in a short time. For those who donβt need to read it too frequently.
- read() Anyο
Read the value.
- Returns:
The value.
- Return type:
Any
- robot_hat.utils.reset_mcu()ο
Reset mcu on Robot Hat.
This is helpful if the mcu somehow stuck in a I2C data transfer loop, and Raspberry Pi getting IOError while Reading ADC, manipulating PWM, etc.
- robot_hat.utils.get_battery_voltage()ο
Get battery voltage
- Returns:
battery voltage(V)
- Return type:
float
- robot_hat.utils.set_pin(pin: int, value: bool)ο
Set pin value
- Parameters:
pin (int) β pin number
value (bool) β pin value
- robot_hat.utils.enable_speaker()ο
Enable speaker
- robot_hat.utils.disable_speaker()ο
Disable speaker