From 6aa848fe3ddaeb8daa13bda7cf984170c5479ec7 Mon Sep 17 00:00:00 2001 From: likeanoa Date: Thu, 26 Mar 2026 18:07:47 +0100 Subject: [PATCH] Alter snakecase to camelcase to prevent conflict with rust --- src/moduleTests/fanTest.rs | 2 +- src/moduleTests/lightTest.rs | 56 +++++++++++++++---------------- src/moduleTests/motorTest.rs | 36 ++++++++++---------- src/moduleTests/ultrasonicTest.rs | 16 ++++----- 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/moduleTests/fanTest.rs b/src/moduleTests/fanTest.rs index 5949768..915ed1c 100644 --- a/src/moduleTests/fanTest.rs +++ b/src/moduleTests/fanTest.rs @@ -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 \ No newline at end of file diff --git a/src/moduleTests/lightTest.rs b/src/moduleTests/lightTest.rs index 9d389ef..8329e38 100644 --- a/src/moduleTests/lightTest.rs +++ b/src/moduleTests/lightTest.rs @@ -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(); } diff --git a/src/moduleTests/motorTest.rs b/src/moduleTests/motorTest.rs index b926e9f..2579f61 100644 --- a/src/moduleTests/motorTest.rs +++ b/src/moduleTests/motorTest.rs @@ -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(()) } \ No newline at end of file diff --git a/src/moduleTests/ultrasonicTest.rs b/src/moduleTests/ultrasonicTest.rs index 2858c47..ac2ddd6 100644 --- a/src/moduleTests/ultrasonicTest.rs +++ b/src/moduleTests/ultrasonicTest.rs @@ -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"), } \ No newline at end of file