Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR integrates an IR distance sensor (SHARP GP2Y0A21YK0F + MCP3002) into the door lock system to detect door open/close state and trigger auto-lock when the door closes.
- Add a new
distance_sensormodule implementingDoorSensorand calibration logic - Extend domain traits (
DoorSensor,DoorLock) and inject sensor intoTouchCardUseCase - Update
main.rs,infra, and documentation to wire up the sensor and auto-lock flow
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/door_sensor_setup.md | Add setup instructions and Rust examples for the IR distance sensor |
| crates/pasori/src/device/rcs380.rs | Minor refactor on byte-to-u16 conversion |
| crates/app/src/main.rs | Initialize and pass Gp2y0aDistanceSensor to use case |
| crates/app/src/infra/mod.rs | Expose new sensor types and errors |
| crates/app/src/infra/gpio_door_lock.rs | Extend DoorLock with sensor-based auto-lock logic |
| crates/app/src/infra/distance_sensor.rs | New sensor implementation, calibration, and tests |
| crates/app/src/domain/mod.rs | Add DoorSensor trait and extend DoorLock |
| crates/app/src/app/touch_card.rs | Update TouchCardUseCase to perform auto-lock post-exit |
| crates/app/Cargo.toml | Add async-trait dependency |
Comments suppressed due to low confidence (2)
docs/door_sensor_setup.md:47
- The example uses
new(1, 30.0), but the current API providesnew()(default) ornew_with_config(...). Please update the sample to match the actual constructors.
let sensor = Gp2y0aDistanceSensor::new(1, 30.0)?;
crates/app/src/main.rs:71
- The comment states a 30cm threshold, but
new()uses a 5cm default threshold (DOOR_SENSOR_THRESHOLD_DISTANCE). Please update the comment or use a custom config to align with expectations.
let door_sensor = Gp2y0aDistanceSensor::new()?; // チャンネル0、閾値30cm
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
センサの扱いについて
参考
https://rc30-popo.hatenablog.com/entry/2020/10/10/114915