2019-12-28 21:43:13 -06:00
|
|
|
// external crates getting imported
|
2019-12-29 19:58:49 -06:00
|
|
|
extern crate reqwest;
|
|
|
|
extern crate select;
|
2019-12-28 21:43:13 -06:00
|
|
|
extern crate serde;
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate serde_json;
|
2019-12-30 17:59:00 -06:00
|
|
|
|
|
|
|
// std lib imports
|
|
|
|
use std::{thread, time};
|
2019-12-28 21:43:13 -06:00
|
|
|
|
|
|
|
// actual third party library being imported
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde_json::Result;
|
|
|
|
|
|
|
|
// local files that need to be imported
|
|
|
|
mod app;
|
|
|
|
mod config;
|
|
|
|
mod generate;
|
2020-01-04 14:16:54 -06:00
|
|
|
mod led;
|
2019-12-28 21:43:13 -06:00
|
|
|
|
2019-12-26 21:32:42 -06:00
|
|
|
fn main() {
|
2019-12-28 21:43:13 -06:00
|
|
|
let configuration = config::init_config();
|
2019-12-29 19:58:49 -06:00
|
|
|
println!("{:?}", configuration);
|
|
|
|
|
|
|
|
loop {
|
2020-01-03 22:15:13 -06:00
|
|
|
let app_text = configuration.get_tv_status();
|
|
|
|
let power_text = configuration.get_power_status();
|
2019-12-29 19:58:49 -06:00
|
|
|
|
2020-01-03 22:15:13 -06:00
|
|
|
let activeapp = app::match_to_app(app_text);
|
|
|
|
let tvpower = app::match_to_power_status(power_text);
|
2019-12-29 19:58:49 -06:00
|
|
|
|
|
|
|
match activeapp {
|
|
|
|
app::ActiveApp::Roku => println!("The lights are light purple!"),
|
2020-01-21 16:25:29 -06:00
|
|
|
app::ActiveApp::Netflix => {
|
|
|
|
let mut panel = led::Led::new(256);
|
|
|
|
|
|
|
|
let color: Vec<led::ColorRGB> = [0; 265].iter().map(|val| {
|
|
|
|
match val {
|
|
|
|
0 => led::ColorRGB(0x03, 0x00, 0x00),
|
|
|
|
_ => panic!("Invalid color!"),
|
|
|
|
}
|
|
|
|
}).collect();
|
|
|
|
|
|
|
|
panel.set_leds(&color);
|
|
|
|
},
|
2019-12-29 19:58:49 -06:00
|
|
|
app::ActiveApp::Hulu => println!("The lights are green!"),
|
|
|
|
app::ActiveApp::AmazonPrime => println!("The light are light blue!"),
|
|
|
|
app::ActiveApp::Spotify => println!("The lights are light green!"),
|
|
|
|
_ => println!("Oops!"),
|
|
|
|
}
|
|
|
|
|
2020-01-03 22:15:13 -06:00
|
|
|
match tvpower {
|
|
|
|
app::TVPower::On => println!("TV is on!"),
|
|
|
|
app::TVPower::Off => println!("TV is off!"),
|
|
|
|
_ => println!("We don't know what the power status of the TV is..."),
|
|
|
|
}
|
|
|
|
|
|
|
|
let sec = time::Duration::from_secs(3);
|
2019-12-30 17:59:00 -06:00
|
|
|
thread::sleep(sec);
|
2019-12-29 19:58:49 -06:00
|
|
|
}
|
2019-12-26 21:32:42 -06:00
|
|
|
}
|