Alter snakecase to camelcase to prevent conflict with rust
This commit is contained in:
@@ -4,6 +4,6 @@ use std::time::Duration;
|
|||||||
use rppal::gpio::Gpio;
|
use rppal::gpio::Gpio;
|
||||||
|
|
||||||
let gpio = Gpio::new()?;
|
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
|
//TODO: Add relay switching
|
||||||
@@ -5,21 +5,21 @@ use rppal::gpio::Gpio;
|
|||||||
|
|
||||||
let gpio = Gpio::new()?;
|
let gpio = Gpio::new()?;
|
||||||
|
|
||||||
let mut indicatorLeftBack = gpio.get(21)?.into_output();
|
let mut indicator_rear_left = gpio.get(21)?.into_output();
|
||||||
let mut indicatorRightBack = gpio.get(22)?.into_output();
|
let mut indicator_rear_right = gpio.get(22)?.into_output();
|
||||||
let mut brakeLights = gpio.get(23)?.into_output();
|
let mut brake_lights = gpio.get(23)?.into_output();
|
||||||
let mut headLights = gpio.get(25)?.into_output();
|
let mut headlights = gpio.get(25)?.into_output();
|
||||||
|
|
||||||
// Blink both indicators
|
// Blink both indicators
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
|
||||||
while i < 10 {
|
while i < 10 {
|
||||||
indicatorLeftBack.set_high();
|
indicator_rear_left.set_high();
|
||||||
indicatorRightBack.set_high();
|
indicator_rear_right.set_high();
|
||||||
thread::sleep(Duration::from_secs(0.7));
|
thread::sleep(Duration::from_secs(0.7));
|
||||||
indicatorLeftBack.set_low();
|
indicator_rear_left.set_low();
|
||||||
indicatorRightBack.set_low();
|
indicator_rear_right.set_low();
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,9 +28,9 @@ i = 0;
|
|||||||
// Blink left indicator thrice
|
// Blink left indicator thrice
|
||||||
|
|
||||||
while i < 4 {
|
while i < 4 {
|
||||||
indicatorLeftBack.set_high();
|
indicator_rear_left.set_high();
|
||||||
thread::sleep(Duration::from_secs(0.7));
|
thread::sleep(Duration::from_secs(0.7));
|
||||||
indicatorLeftBack.set_low();
|
indicator_rear_left.set_low();
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ i = 0;
|
|||||||
// Blink right indicator thrice
|
// Blink right indicator thrice
|
||||||
|
|
||||||
while i < 4 {
|
while i < 4 {
|
||||||
indicatorRightBack.set_high();
|
indicator_rear_right.set_high();
|
||||||
thread::sleep(Duration::from_secs(0.7));
|
thread::sleep(Duration::from_secs(0.7));
|
||||||
indicatorRightBack.set_low();
|
indicator_rear_right.set_low();
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,35 +49,35 @@ i = 0;
|
|||||||
|
|
||||||
// Hold brake lights and blink twice
|
// Hold brake lights and blink twice
|
||||||
|
|
||||||
brakeLights.set_high();
|
brake_lights.set_high();
|
||||||
brakeLights.set_high();
|
brake_lights.set_high();
|
||||||
thread::sleep(Duration::from_secs(3));
|
thread::sleep(Duration::from_secs(3));
|
||||||
brakeLights.set_low();
|
brake_lights.set_low();
|
||||||
brakeLights.set_low();
|
brake_lights.set_low();
|
||||||
|
|
||||||
while i < 3 {
|
while i < 3 {
|
||||||
brakeLights.set_high();
|
brake_lights.set_high();
|
||||||
brakeLights.set_high();
|
brake_lights.set_high();
|
||||||
thread::sleep(Duration::from_secs(0.7))
|
thread::sleep(Duration::from_secs(0.7))
|
||||||
brakeLights.set_low();
|
brake_lights.set_low();
|
||||||
brakeLights.set_low();
|
brake_lights.set_low();
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Turn on headlights and flash twice
|
// Turn on headlights and flash twice
|
||||||
|
|
||||||
headLights.set_high();
|
headlights.set_high();
|
||||||
headLights.set_high();
|
headlights.set_high();
|
||||||
thread::sleep(Duration::from_secs(3))
|
thread::sleep(Duration::from_secs(3))
|
||||||
headLights.set_low();
|
headlights.set_low();
|
||||||
headLights.set_low();
|
headlights.set_low();
|
||||||
|
|
||||||
while i < 3 {
|
while i < 3 {
|
||||||
headLights.set_high();
|
headlights.set_high();
|
||||||
headLights.set_high();
|
headlights.set_high();
|
||||||
thread::sleep(Duration::from_secs(0.7))
|
thread::sleep(Duration::from_secs(0.7))
|
||||||
headLights.set_low();
|
headlights.set_low();
|
||||||
headLights.set_low();
|
headlights.set_low();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,42 +9,42 @@ use std::time::Duration;
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
fn main() -> Result<(), std::io::Error> {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
let mut motorFrontLeft = L298n::new(0, 0, 0);
|
let mut motor_front_left = L298n::new(0, 0, 0);
|
||||||
let mut motorFrontRight = L298n::new(0, 0, 0);
|
let mut motor_front_right = L298n::new(0, 0, 0);
|
||||||
let mut motorBackLeft = L298n::new(0, 0, 0);
|
let mut motor_rear_left = L298n::new(0, 0, 0);
|
||||||
let mut motorBackRight = L298n::new(0, 0, 0);
|
let mut motor_rear_right = L298n::new(0, 0, 0);
|
||||||
|
|
||||||
// Front left test
|
// Front left test
|
||||||
|
|
||||||
motorFrontLeft.forward()?;
|
motor_front_left.forward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorFrontLeft.backward()?;
|
motor_front_left.backward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorFrontLeft.stop()?;
|
motor_front_left.stop()?;
|
||||||
|
|
||||||
// Front right test
|
// Front right test
|
||||||
|
|
||||||
motorFrontRight.forward()?;
|
motor_front_right.forward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorFrontRight.backward()?;
|
motor_front_right.backward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
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));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorBackLeft.backward()?;
|
motor_rear_left.backward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
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));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorBackRight.backward()?;
|
motor_rear_right.backward()?;
|
||||||
thread::sleep(Duration::from_secs(2));
|
thread::sleep(Duration::from_secs(2));
|
||||||
motorBackRight.stop()?;
|
motor_rear_right.stop()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1,45 +1,45 @@
|
|||||||
use hc_sr04::{HcSr04, Unit};
|
use hc_sr04::{HcSr04, Unit};
|
||||||
|
|
||||||
let mut ultrasonicFront = HcSr04::new(
|
let mut ultrasonic_front = HcSr04::new(
|
||||||
7, // TRIGGER
|
7, // TRIGGER
|
||||||
1, // ECHO
|
1, // ECHO
|
||||||
Some(23_f32)
|
Some(23_f32)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let mut ultrasonicLeft = HcSr04::new(
|
let mut ultrasonic_left = HcSr04::new(
|
||||||
0,
|
0,
|
||||||
4,
|
4,
|
||||||
Some(23_f32)
|
Some(23_f32)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let mut ultrasonicRight = HcSr04::new(
|
let mut ultrasonic_right = HcSr04::new(
|
||||||
2,
|
2,
|
||||||
5,
|
5,
|
||||||
Some(23_f32)
|
Some(23_f32)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let mut ultrasonicBack = HcSr04::new(
|
let mut ultrasonic_rear = HcSr04::new(
|
||||||
3,
|
3,
|
||||||
6,
|
6,
|
||||||
Some(23_f32)
|
Some(23_f32)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
match ultrasonicFront.measure_distance(Unit::Meters).unwrap() {
|
match ultrasonic_front.measure_distance(Unit::Meters).unwrap() {
|
||||||
Some(dist) => println!("[FRONT] Distance: {.2}m", dist),
|
Some(dist) => println!("[FRONT] Distance: {.2}m", dist),
|
||||||
None => println!("Object out of range"),
|
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),
|
Some(dist) => println!("[LEFT] Distance: {.2}m", dist),
|
||||||
None => println!("Object out of range"),
|
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),
|
Some(dist) => println!("[RIGHT] Distance: {.2}m", dist),
|
||||||
None => println!("Object out of range"),
|
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),
|
Some(dist) => println!("[BACK] Distance: {.2}m", dist),
|
||||||
None => println!("Object out of range"),
|
None => println!("Object out of range"),
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user