Add module test folder and light test file

This commit is contained in:
2026-03-26 10:31:28 +01:00
parent 73e7ebc394
commit b76c65a56d

View File

@@ -0,0 +1,85 @@
use std::thread;
use std::time::Duration;
use rppal::gpio::Gpio;
let gpio = Gpio::new()?;
let mut indicatorLeftBack = gpio.get(21)?.into_output();
let mut indicatorRightBack = gpio.get(22)?.into_output();
let mut brakeLeftBack = gpio.get(23)?.into_output();
let mut brakeRightBack = gpio.get(24)?.into_output();
let mut frontLeftHead = gpio.get(25)?.into_output();
let mut frontRightHead = gpio.get(26)?.into_output();
// Blink both indicators
let mut i = 0;
while i < 10 {
indicatorLeftBack.set_high();
indicatorRightBack.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorLeftBack.set_low();
indicatorRightBack.set_low();
i = i + 1;
}
i = 0;
// Blink left indicator thrice
while i < 4 {
indicatorLeftBack.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorLeftBack.set_low();
i = i + 1
}
i = 0;
// Blink right indicator thrice
while i < 4 {
indicatorRightBack.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorRightBack.set_low();
i = i + 1
}
i = 0;
// Hold brake lights and blink twice
brakeLeftBack.set_high();
brakeRightBack.set_high();
thread::sleep(Duration::from_secs(3));
brakeLeftBack.set_low();
brakeRightBack.set_low();
while i < 3 {
brakeLeftBack.set_high();
brakeRightBack.set_high();
thread::sleep(Duration::from_secs(0.7))
brakeLeftBack.set_low();
brakeRigthBack.set_low();
}
i = 0;
// Turn on headlights and flash twice
frontLeftHead.set_high();
frontRightHead.set_high();
thread::sleep(Duration::from_secs(3))
frontLeftHead.set_low();
frontRightHead.set_low();
while i < 3 {
frontLeftHead.set_high();
frontRightHead.set_high();
thread::sleep(Duration::from_secs(0.7))
frontLeftHead.set_low();
frontRightHead.set_low();
}