fix: etherdream example
This commit is contained in:
parent
e148a1ec5e
commit
ff96bdf6fa
@ -129,7 +129,7 @@ impl Iterator for SineWave {
|
||||
_ => (std::u16::MAX, std::u16::MAX, std::u16::MAX),
|
||||
};
|
||||
let x_min = std::i16::MIN;
|
||||
let x_max = std::i16::MAX;
|
||||
let x_max = std::i8::MAX as i16;
|
||||
let x = (x_min as f32 + fract * (x_max as f32 - x_min as f32)) as i16;
|
||||
let y = (amp * x_max as f32) as i16;
|
||||
let control = 0;
|
||||
|
46
examples/test.rs
Normal file
46
examples/test.rs
Normal file
@ -0,0 +1,46 @@
|
||||
///
|
||||
/// $ cargo run --example simple_client
|
||||
///
|
||||
|
||||
use redis::{
|
||||
//RedisResult,
|
||||
Client,
|
||||
Commands,
|
||||
Connection,
|
||||
};
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
fn do_something() -> redis::RedisResult<()> {
|
||||
let client = Client::open("redis://127.0.0.1/")?;
|
||||
let mut con: Connection = client.get_connection()?;
|
||||
let start = Instant::now();
|
||||
|
||||
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());
|
||||
|
||||
let x = a.cos() * r;
|
||||
let y = a.sin() * r;
|
||||
let col = if i % 8 < 4 {
|
||||
0x000000ff
|
||||
} else {
|
||||
0x00ff0000
|
||||
};
|
||||
v.push((x, y, col));
|
||||
}
|
||||
// println!("{:?}", v);
|
||||
let _ = con.set("/pl/0/0", format!("{:?}", v))?;
|
||||
}
|
||||
// Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
_ = do_something();
|
||||
}
|
Loading…
Reference in New Issue
Block a user