Skip to content

[WIP] 赤外線測距モジュールでとびらの開閉状態を見るように#61

Open
OJII3 wants to merge 20 commits into
mainfrom
feat/ir
Open

[WIP] 赤外線測距モジュールでとびらの開閉状態を見るように#61
OJII3 wants to merge 20 commits into
mainfrom
feat/ir

Conversation

@OJII3

@OJII3 OJII3 commented Jun 4, 2025

Copy link
Copy Markdown
Member
  • feat: wip ir
  • feat: optimise voltage to distance conversion

センサの扱いについて

  • 距離が近すぎると測れないので、センサの位置を工夫して、5cmくらいの状態を「閉じている」状態として扱うことにする。
  • 電圧-距離変換は適当な変換テーブルを用意して変換しているが、データシート上にかかれているグラフより出力電圧が半分ほど低い模様。
  • このACDCコンバーターは出力電圧を2チャンネル読めるが、チャンネル0を使用している

参考
https://rc30-popo.hatenablog.com/entry/2020/10/10/114915

Copilot AI review requested due to automatic review settings June 4, 2025 04:44
@OJII3 OJII3 changed the title feat/ir 赤外線測距モジュールでとびらの開閉状態を見るように Jun 4, 2025

This comment was marked as outdated.

@OJII3 OJII3 changed the title 赤外線測距モジュールでとびらの開閉状態を見るように [WIP] 赤外線測距モジュールでとびらの開閉状態を見るように Jun 4, 2025
@OJII3
OJII3 requested a review from Copilot June 5, 2025 03:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_sensor module implementing DoorSensor and calibration logic
  • Extend domain traits (DoorSensor, DoorLock) and inject sensor into TouchCardUseCase
  • 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 provides new() (default) or new_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

Comment thread crates/app/src/infra/gpio_door_lock.rs Outdated
Comment thread crates/app/src/infra/distance_sensor.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants