Alter snakecase to camelcase to prevent conflict with rust

This commit is contained in:
likeanoa
2026-03-26 18:07:47 +01:00
parent 713ff1fd51
commit 6aa848fe3d
4 changed files with 55 additions and 55 deletions

View File

@@ -4,6 +4,6 @@ use std::time::Duration;
use rppal::gpio::Gpio;
let gpio = Gpio::new()?;
let mut examplePin = gpio.get(0)?.into_output();
let mut example_pin = gpio.get(0)?.into_output();
//TODO: Add relay switching

View File

@@ -5,21 +5,21 @@ 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 brakeLights = gpio.get(23)?.into_output();
let mut headLights = gpio.get(25)?.into_output();
let mut indicator_rear_left = gpio.get(21)?.into_output();
let mut indicator_rear_right = gpio.get(22)?.into_output();
let mut brake_lights = gpio.get(23)?.into_output();
let mut headlights = gpio.get(25)?.into_output();
// Blink both indicators
let mut i = 0;
while i < 10 {
indicatorLeftBack.set_high();
indicatorRightBack.set_high();
indicator_rear_left.set_high();
indicator_rear_right.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorLeftBack.set_low();
indicatorRightBack.set_low();
indicator_rear_left.set_low();
indicator_rear_right.set_low();
i = i + 1;
}
@@ -28,9 +28,9 @@ i = 0;
// Blink left indicator thrice
while i < 4 {
indicatorLeftBack.set_high();
indicator_rear_left.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorLeftBack.set_low();
indicator_rear_left.set_low();
i = i + 1
}
@@ -39,9 +39,9 @@ i = 0;
// Blink right indicator thrice
while i < 4 {
indicatorRightBack.set_high();
indicator_rear_right.set_high();
thread::sleep(Duration::from_secs(0.7));
indicatorRightBack.set_low();
indicator_rear_right.set_low();
i = i + 1
}
@@ -49,35 +49,35 @@ i = 0;
// Hold brake lights and blink twice
brakeLights.set_high();
brakeLights.set_high();
brake_lights.set_high();
brake_lights.set_high();
thread::sleep(Duration::from_secs(3));
brakeLights.set_low();
brakeLights.set_low();
brake_lights.set_low();
brake_lights.set_low();
while i < 3 {
brakeLights.set_high();
brakeLights.set_high();
brake_lights.set_high();
brake_lights.set_high();
thread::sleep(Duration::from_secs(0.7))
brakeLights.set_low();
brakeLights.set_low();
brake_lights.set_low();
brake_lights.set_low();
}
i = 0;
// Turn on headlights and flash twice
headLights.set_high();
headLights.set_high();
headlights.set_high();
headlights.set_high();
thread::sleep(Duration::from_secs(3))
headLights.set_low();
headLights.set_low();
headlights.set_low();
headlights.set_low();
while i < 3 {
headLights.set_high();
headLights.set_high();
headlights.set_high();
headlights.set_high();
thread::sleep(Duration::from_secs(0.7))
headLights.set_low();
headLights.set_low();
headlights.set_low();
headlights.set_low();
}

View File

@@ -9,42 +9,42 @@ use std::time::Duration;
// }
fn main() -> Result<(), std::io::Error> {
let mut motorFrontLeft = L298n::new(0, 0, 0);
let mut motorFrontRight = L298n::new(0, 0, 0);
let mut motorBackLeft = L298n::new(0, 0, 0);
let mut motorBackRight = L298n::new(0, 0, 0);
let mut motor_front_left = L298n::new(0, 0, 0);
let mut motor_front_right = L298n::new(0, 0, 0);
let mut motor_rear_left = L298n::new(0, 0, 0);
let mut motor_rear_right = L298n::new(0, 0, 0);
// Front left test
motorFrontLeft.forward()?;
motor_front_left.forward()?;
thread::sleep(Duration::from_secs(2));
motorFrontLeft.backward()?;
motor_front_left.backward()?;
thread::sleep(Duration::from_secs(2));
motorFrontLeft.stop()?;
motor_front_left.stop()?;
// Front right test
motorFrontRight.forward()?;
motor_front_right.forward()?;
thread::sleep(Duration::from_secs(2));
motorFrontRight.backward()?;
motor_front_right.backward()?;
thread::sleep(Duration::from_secs(2));
motorFrontRight.stop()?;
motor_front_right.stop()?;
// Back left test
// Rear left test
motorBackLeft.forward()?;
motor_rear_left.forward()?;
thread::sleep(Duration::from_secs(2));
motorBackLeft.backward()?;
motor_rear_left.backward()?;
thread::sleep(Duration::from_secs(2));
motorBackLeft.stop()?;
motor_rear_left.stop()?;
// Back right test
// Rear right test
motorBackRight.forward()?;
motor_rear_right.forward()?;
thread::sleep(Duration::from_secs(2));
motorBackRight.backward()?;
motor_rear_right.backward()?;
thread::sleep(Duration::from_secs(2));
motorBackRight.stop()?;
motor_rear_right.stop()?;
Ok(())
}

View File

@@ -1,45 +1,45 @@
use hc_sr04::{HcSr04, Unit};
let mut ultrasonicFront = HcSr04::new(
let mut ultrasonic_front = HcSr04::new(
7, // TRIGGER
1, // ECHO
Some(23_f32)
).unwrap();
let mut ultrasonicLeft = HcSr04::new(
let mut ultrasonic_left = HcSr04::new(
0,
4,
Some(23_f32)
).unwrap();
let mut ultrasonicRight = HcSr04::new(
let mut ultrasonic_right = HcSr04::new(
2,
5,
Some(23_f32)
).unwrap();
let mut ultrasonicBack = HcSr04::new(
let mut ultrasonic_rear = HcSr04::new(
3,
6,
Some(23_f32)
).unwrap();
match ultrasonicFront.measure_distance(Unit::Meters).unwrap() {
match ultrasonic_front.measure_distance(Unit::Meters).unwrap() {
Some(dist) => println!("[FRONT] Distance: {.2}m", dist),
None => println!("Object out of range"),
}
match ultrasonicLeft.measure_distance(Unit::Meters).unwrap() {
match ultrasonic_left.measure_distance(Unit::Meters).unwrap() {
Some(dist) => println!("[LEFT] Distance: {.2}m", dist),
None => println!("Object out of range"),
}
match ultrasonicRight.measure_distance(Unit::Meters).unwrap() {
match ultrasonic_right.measure_distance(Unit::Meters).unwrap() {
Some(dist) => println!("[RIGHT] Distance: {.2}m", dist),
None => println!("Object out of range"),
}
match ultrasonicBack.measure_distance(Unit::Meters).unwrap() {
match ultrasonic_rear.measure_distance(Unit::Meters).unwrap() {
Some(dist) => println!("[BACK] Distance: {.2}m", dist),
None => println!("Object out of range"),
}