Skip to content

Commit

Permalink
Merge pull request #61 from 708yamaguchi/readme-for-atom-s3-i2c-display
Browse files Browse the repository at this point in the history
Update README for atom_s3_i2c_display's multi mode
  • Loading branch information
708yamaguchi authored Nov 1, 2024
2 parents 4f01ee9 + de0df14 commit eed9ca6
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions firmware/atom_s3_i2c_display/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,67 @@ If you want to set the I2C address, set the `I2C_ADDR` environment variable to t
```
I2C_ADDR=0x42 pio run -t upload
```

## Control multiple modes

The `atom_s3_i2c_display` includes multiple modes. This feature allows the robot to be controlled using both the `/i2c_button_state` and `/i2c_mode topics`, making control programming easier.

### Program Structure

- The AtomS3 firmware is paired with a corresponding rospy program on the computer. To use any mode, first update the AtomS3 firmware, then launch the matching rospy node.

| AtomS3 Firmware | Computer rospy Node |
| ------------- | ------------- |
| display_information_mode.cpp | display_information.py |
| display_qr_code_mode.cpp | display_information.py |
| servo_control_mode.cpp | servo_control_mode.py |
| pressure_control_mode.cpp | pressure_control_mode.py |
| teaching_mode.cpp | teaching_mode.py |

- `i2c_button_state_publisher.cpp` facilitates communication between these programs.
The following sections provide details on the base code for the AtomS3 firmware.

- `main.cpp` includes instances for each mode and stores them in a list. Each time a long click occurs, the active task switches to another mode. Note that this program does not include instances of Servo Control Mode, Pressure Control Mode and Teachiing Mode by default.

- `atom_s3_lcd.h` is a shared library for the AtomS3, containing functions for drawing on the LCD and holding variables needed for rendering data, such as jpegBuf and qrCodeData.

- `atom_s3_i2c.h` is a shared library for I2C communication with the AtomS3. In the receiveEvent function, data is received from the I2C master and stored in the AtomS3LCD class object. The requestEvent function sends button state and mode information to the I2C master.

- `atom_s3_button.h` is a shared library that detects which button was pressed and identifies the type of press.

### Mode Descriptions

- Display Information Mode

Displays the device's IP address and battery level.

- Display QR Code Mode

Shows a QR code on the screen.

- Servo Control Mode

Controls the Kondo servo. A single click toggles the servo on or off.

- Pressure Control Mode

Controls pressure by toggling the pump and solenoid valve. The current pressure value is shown on the AtomS3 LCD. A single click toggles the vacuum on or off.

- Teaching Mode

This mode includes three states: `WAIT`, `RECORD`, and `PLAY`.

In the `WAIT` state:
- A single click transitions to the `RECORD` state.
- A double click transitions to the `PLAY` state.
- A triple click turns off the servo.

In the `RECORD` state:
- Recording motion automatically starts at the moment of transition from `WAIT` state to `RECORD` state
- A single click stops recording motion.
- After recording, the state automatically returns to `WAIT`.

In the `PLAY` state:
- Playing motion automatically starts at the moment of transition from `WAIT` state to `PLAY` state
- A double click stops playing motion.
- After playback, the state automatically returns to `WAIT`.

0 comments on commit eed9ca6

Please sign in to comment.