Merge branch 'master' of git.interhacker.space:corpsmoderne/lazer_rust
This commit is contained in:
commit
256599095f
@ -1,3 +1,7 @@
|
|||||||
|
///
|
||||||
|
/// $ cargo run --example simple_client
|
||||||
|
///
|
||||||
|
|
||||||
use redis::{
|
use redis::{
|
||||||
//RedisResult,
|
//RedisResult,
|
||||||
Client,
|
Client,
|
||||||
@ -5,23 +9,36 @@ use redis::{
|
|||||||
Connection,
|
Connection,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
fn do_something() -> redis::RedisResult<()> {
|
fn do_something() -> redis::RedisResult<()> {
|
||||||
let client = Client::open("redis://127.0.0.1/")?;
|
let client = Client::open("redis://127.0.0.1/")?;
|
||||||
let mut con: Connection = client.get_connection()?;
|
let mut con: Connection = client.get_connection()?;
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
let _ = con.set("/order/0", 0)?;
|
loop {
|
||||||
|
let elapsed = start.elapsed();
|
||||||
|
let time = 60.0 * elapsed.as_millis() as f32 / 1000.0;
|
||||||
|
|
||||||
|
let mut v : Vec<(f32,f32,u32)> = vec![];
|
||||||
|
|
||||||
|
for i in 0..128 {
|
||||||
|
let a = (time + i as f32) / 128.0 * std::f32::consts::PI * 2.0;
|
||||||
|
let r = 1200.0 + (a*5.0).cos() * (500.0 * (time/5.0).cos());
|
||||||
|
|
||||||
/* do something here */
|
let x = a.cos() * r;
|
||||||
//let val : String = con.get("/pl/0/0")?;
|
let y = a.sin() * r;
|
||||||
let _ = con.set("/pl/0/0", "[(150.0, 230.0, 65280), \
|
let col = if i % 8 < 4 {
|
||||||
(170.0, 170.0, 65280), \
|
0x000000ff
|
||||||
(230.0, 170.0, 65280), \
|
} else {
|
||||||
(210.0, 230.0, 65280), \
|
0x00ff0000
|
||||||
(150.0, 230.0, 65280)]")?;
|
};
|
||||||
|
v.push((x,y,col));
|
||||||
Ok(())
|
}
|
||||||
|
// println!("{:?}", v);
|
||||||
|
let _ = con.set("/pl/0/0", format!("{:?}", v))?;
|
||||||
|
}
|
||||||
|
// Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -72,9 +72,8 @@ fn run_all() -> LJResult<()> {
|
|||||||
|
|
||||||
let frame = get_next_frame(&config, &transformers,
|
let frame = get_next_frame(&config, &transformers,
|
||||||
&mut rs, order == Order::Black)?;
|
&mut rs, order == Order::Black)?;
|
||||||
|
|
||||||
// For now, draw all the time
|
// For now, draw all the time
|
||||||
tracer.draw(frame, 1000)?;
|
tracer.draw(frame, 10_000)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Exiting, stoping device.");
|
info!("Exiting, stoping device.");
|
||||||
|
Loading…
Reference in New Issue
Block a user