Skip to content

Commit ca3be44

Browse files
committed
Merge branch 'dev'
2 parents 3714279 + c159bb0 commit ca3be44

File tree

4 files changed

+329
-161
lines changed

4 files changed

+329
-161
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
.idea
1313

14+
.DS_Store
15+
1416
# AWS User-specific
1517
.idea/**/aws.xml
1618

@@ -933,4 +935,4 @@ cython_debug/
933935
#.idea/
934936

935937

936-
# End of https://www.toptal.com/developers/gitignore/api/python,circuitpython,intellij,vs
938+
# End of https://www.toptal.com/developers/gitignore/api/python,circuitpython,intellij,vs

README.md

Lines changed: 126 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,157 @@
11
# Eliobot Python Library
22

3-
### Version 2.0
4-
### 2024 - ELIO SAS
3+
### Version 3.0 (2023) - ELIO SAS
54

6-
#### Project homepage: [https://eliobot.com](https://eliobot.com)
5+
## Project Homepage
6+
Visit the project homepage at [https://eliobot.com](https://eliobot.com).
77

88
## Introduction
9+
The Eliobot Python library provides an extensive set of functionalities to control the Eliobot robot. This library allows you to interact with the robot's motors, sensors, buzzer, and other components using Python.
910

10-
The Eliobot Python library provides functionality to control the Eliobot robot. It leverages libraries like `time`, `board`, `digitalio`, `analogio` and `pwmio` to interact with various hardware components of the robot, including sensors, motors, LEDs, and more.
11+
**Important:** Please note that the IR receiver and the obstacle sensor cannot be used simultaneously because they both share the same pin on the board. You must choose one functionality to use at a time in your code.
1112

1213
## Installation
14+
To install the Eliobot Python library:
1315

14-
To install the Eliobot Python library, on your Eliobot go to: [https://app.eliobot.com/update/](https://app.eliobot.com/update/) and update Eliobot it will install the latest version of the library.
16+
1. **Automatic Installation:** Go to [https://app.eliobot.com/update/](https://app.eliobot.com/update/) and update your Eliobot. This will automatically install the latest version of the library.
17+
2. **Manual Installation:** Download the library and place it in the `lib` folder of your Eliobot.
1518

16-
Or you can download the library and drop it in the `lib` folder of your Eliobot.
19+
## Documentation
20+
To use the Eliobot Python library in your code, import the necessary modules and create instances of the classes provided:
21+
22+
### Motors Class
23+
Controls the robot's motors.
1724

18-
## Use the library in your Python code
25+
```python
26+
from elio import Motors
27+
import board
28+
import pwmio
29+
import analogio
30+
31+
vBatt_pin = analogio.AnalogIn(board.BATTERY)
32+
AIN1 = pwmio.PWMOut(board.IO36)
33+
AIN2 = pwmio.PWMOut(board.IO38)
34+
BIN1 = pwmio.PWMOut(board.IO35)
35+
BIN2 = pwmio.PWMOut(board.IO37)
36+
37+
motors = Motors(AIN1, AIN2, BIN1, BIN2, vBatt_pin)
38+
```
1939

20-
To use the Eliobot Python library in your Python code, you need to import the `elio` module. Here is an example:
40+
#### Methods:
41+
- **move_forward(speed=100)**: Moves the robot forward at the specified speed.
42+
- **move_backward(speed=100)**: Moves the robot backward at the specified speed.
43+
- **turn_left(speed=100)**: Turns the robot left at the specified speed.
44+
- **turn_right(speed=100)**: Turns the robot right at the specified speed.
45+
- **spin_left_wheel_forward(speed=100)**: Spins the left wheel forward.
46+
- **spin_left_wheel_backward(speed=100)**: Spins the left wheel backward.
47+
- **spin_right_wheel_forward(speed=100)**: Spins the right wheel forward.
48+
- **spin_right_wheel_backward(speed=100)**: Spins the right wheel backward.
49+
- **motor_stop()**: Stops the robot immediately.
50+
- **slow_stop()**: Gradually stops the robot.
51+
- **move_one_step(direction, distance=20)**: Moves the robot a specific distance in centimeters.
52+
- **turn_one_step(direction, angle=90)**: Turns the robot a specific angle in degrees.
53+
- **get_battery_voltage()**: Returns the current battery voltage.
54+
- **rgb_color_wheel(wheel_pos)**: Generates a color based on the given position on the color wheel.
55+
56+
### Buzzer Class
57+
Controls the robot's buzzer for sound output.
2158

2259
```python
23-
from elio import Eliobot
60+
from elio import Buzzer
61+
import board
62+
import pwmio
63+
64+
buzzer = Buzzer(pwmio.PWMOut(board.IO17, variable_frequency=True))
2465
```
2566

26-
now you can create an instance of the `Eliobot` class and start controlling the robot. Here is an example:
67+
#### Methods:
68+
- **play_tone(frequency, duration, volume)**: Plays a tone with the specified frequency, duration, and volume.
69+
- **play_note(note, duration, NOTES_FREQUENCIES, volume)**: Plays a note from a predefined dictionary of frequencies.
70+
71+
### ObstacleSensor Class
72+
Handles obstacle detection using sensors.
2773

2874
```python
29-
from elio import Eliobot # Import the Eliobot class
30-
import board # Import the board module
31-
import time # Import the time module
32-
import digitalio # Import the digitalio module
33-
import analogio # Import the analogio module
34-
import pwmio # Import the pwmio module
75+
from elio import ObstacleSensor
76+
import board
77+
import analogio
3578

36-
vBatt_pin = analogio.AnalogIn(board.BATTERY) # Battery voltage pin
79+
obstacleInput = [analogio.AnalogIn(pin) for pin in
80+
(board.IO4, board.IO5, board.IO6, board.IO7)]
81+
82+
obstacle_sensor = ObstacleSensor(obstacleInput)
83+
```
84+
85+
#### Methods:
86+
- **get_obstacle(obstacle_pos)**: Checks if an obstacle is detected at the specified sensor position.
87+
88+
### LineSensor Class
89+
Manages the line-following capability of the robot.
90+
91+
```python
92+
from elio import LineSensor, Motors
93+
import board
94+
import digitalio
95+
import analogio
96+
import pwmio
3797

38-
obstacleInput = [analogio.AnalogIn(pin) for pin in
39-
(board.IO4, board.IO5, board.IO6, board.IO7)] # Obstacle sensors
98+
vBatt_pin = analogio.AnalogIn(board.BATTERY)
4099

41-
lineCmd = digitalio.DigitalInOut(board.IO33) # Line sensors command pin
42-
lineCmd.direction = digitalio.Direction.OUTPUT # Set the direction of the line command pin
100+
lineCmd = digitalio.DigitalInOut(board.IO33)
101+
lineCmd.direction = digitalio.Direction.OUTPUT
43102

44103
lineInput = [analogio.AnalogIn(pin) for pin in
45-
(board.IO10, board.IO11, board.IO12, board.IO13, board.IO14)] # Line sensors
104+
(board.IO10, board.IO11, board.IO12, board.IO13, board.IO14)]
46105

47-
AIN1 = pwmio.PWMOut(board.IO36) # Motor A input 1
48-
AIN2 = pwmio.PWMOut(board.IO38) # Motor A input 2
49-
BIN1 = pwmio.PWMOut(board.IO35) # Motor B input 1
50-
BIN2 = pwmio.PWMOut(board.IO37) # Motor B input 2
106+
AIN1 = pwmio.PWMOut(board.IO36)
107+
AIN2 = pwmio.PWMOut(board.IO38)
108+
BIN1 = pwmio.PWMOut(board.IO35)
109+
BIN2 = pwmio.PWMOut(board.IO37)
51110

52-
buzzer = pwmio.PWMOut(board.IO17, variable_frequency=True) # Buzzer
111+
motors = Motors(AIN1, AIN2, BIN1, BIN2, vBatt_pin)
53112

54-
# Create an instance of the Eliobot class
55-
elio = Eliobot(AIN1, AIN2, BIN1, BIN2, vBatt_pin, obstacleInput, buzzer, lineInput, lineCmd)
113+
lineSensor = LineSensor(lineInput, lineCmd, motors)
56114
```
57115

58-
## Documentation
116+
#### Methods:
117+
- **get_line(line_pos)**: Returns the value of the line sensor at the given position.
118+
- **follow_line(threshold)**: Enables the robot to follow a line based on a threshold value.
119+
- **calibrate_line_sensors()**: Calibrates the line sensors by moving the robot and collecting sensor data.
120+
- **update_sensor_values(all_values)**: Updates sensor readings for calibration purposes.
121+
- **save_calibration_data(threshold)**: Saves the calibration data to a JSON file.
122+
- **calculate_median(data)**: Calculates the median value from a list of numbers.
123+
124+
### WiFiConnectivity Class
125+
Provides WiFi connectivity features for the robot.
126+
127+
```python
128+
from elio import WiFiConnectivity
129+
130+
wifi = WiFiConnectivity()
131+
```
59132

60-
### Attributes
133+
#### Methods:
134+
- **connect_to_wifi(ssid, password, webpassword)**: Connects the robot to a WiFi network.
135+
- **disconnect_from_wifi()**: Disconnects the robot from the WiFi network.
136+
- **set_access_point(ssid, password)**: Sets up the robot as a WiFi access point.
137+
- **scan_wifi_networks()**: Scans for available WiFi networks and displays the results.
138+
139+
### IRRemote Class
140+
Manages the IR remote control functionality.
141+
142+
```python
143+
from elio import IRRemote
144+
import pulseio
145+
import board
146+
147+
ir_receiver = pulseio.PulseIn(board.IO5, maxlen=200, idle_state=True)
148+
149+
ir_remote = IRRemote(ir_receiver)
150+
```
61151

62-
- `AIN1`: Right Motor input 1 (pwmio.PWMOut)
63-
- `AIN2`: Right Motor input 2 (pwmio.PWMOut)
64-
- `BIN1`: Left Motor input 1 (pwmio.PWMOut)
65-
- `BIN2`: Left Motor input 2 (pwmio.PWMOut)
66-
- `vBatt_pin`: Battery voltage pin (analogio.AnalogIn)
67-
- `obstacleInput`: List of obstacle sensors (analogio.AnalogIn)
68-
- `buzzer`: Buzzer (pwmio.PWMOut)
69-
- `lineInput`: List of line sensors (analogio.AnalogIn)
70-
- `lineCmd`: Line sensors command pin (digitalio.DigitalInOut)
152+
#### Methods:
153+
- **decode_signal()**: Decodes and returns the IR signal received by the IR sensor.
71154

155+
**Important:** Remember that the IR receiver and obstacle sensor share the same pin,
156+
so they cannot be used at the same time.
157+
Ensure that your code only uses one of these features at a time to avoid conflicts.

0 commit comments

Comments
 (0)