From 5b1decf4a42e4f61ca681a5adeb572df354dfcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20Du=C3=9Fin?= Date: Thu, 22 Aug 2024 22:12:37 +0200 Subject: [PATCH] chore: Remove unused main.rs --- src/main.rs | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/main.rs diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e875f91..0000000 --- a/src/main.rs +++ /dev/null @@ -1,39 +0,0 @@ -use core::f64; -use std::f64::consts::TAU; -use std::thread; -use std::time::{Duration, Instant}; - -use rppal::pwm::{Channel, Polarity, Pwm}; - -/// 1 kHz PWM frequency -const PWM_FREQUENCY: f64 = 1000.; - -fn triangle_wave(t: f64) -> f64 { (t - (t + 0.5).floor()).abs() * 2. } -fn sine_wave(t: f64) -> f64 { (f64::sin(TAU * t) + 1.) * 0.5 } -fn square_wave(t: f64, high_time: f64) -> f64 -{ - if t - t.floor() < high_time { - 1. - } - else { - 0. - } -} -fn sawtooth_wave(t: f64) -> f64 { t - t.floor() } - -fn main() -{ - println!("Starting light control"); - - let pwm = Pwm::with_frequency(Channel::Pwm0, PWM_FREQUENCY, 0.5, Polarity::Normal, true) - .expect("Unable to initialise PWM"); - - let start = Instant::now(); - loop { - let time = start.elapsed().as_secs_f64(); - let brightness = sawtooth_wave(time * 0.5); - - pwm.set_duty_cycle(brightness).unwrap(); - thread::sleep(Duration::from_millis(5)); - } -}