mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 10:00:14 +01:00
add suggested frame pacing
This commit is contained in:
parent
6a2ee5fcfa
commit
46c9174d3d
|
@ -1,10 +1,11 @@
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use rand::{distributions, Rng};
|
use rand::{distributions, Rng};
|
||||||
|
|
||||||
use servicepoint2::{Command, CompressionCode, Connection, Origin, PixelGrid};
|
use servicepoint2::{
|
||||||
|
Command, CompressionCode, Connection, Origin, PixelGrid, FRAME_PACING,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
@ -32,7 +33,7 @@ fn main() {
|
||||||
.into(),
|
.into(),
|
||||||
)
|
)
|
||||||
.expect("could not send");
|
.expect("could not send");
|
||||||
thread::sleep(Duration::from_millis(30));
|
thread::sleep(FRAME_PACING);
|
||||||
field = iteration(field);
|
field = iteration(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use servicepoint2::{
|
use servicepoint2::{
|
||||||
Command, CompressionCode, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH,
|
Command, CompressionCode, Connection, Origin, PixelGrid, FRAME_PACING,
|
||||||
PixelGrid,
|
PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
|
@ -36,6 +35,6 @@ fn main() {
|
||||||
.into(),
|
.into(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
thread::sleep(Duration::from_millis(14));
|
thread::sleep(FRAME_PACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ use std::time::Duration;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
|
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
||||||
use servicepoint2::{
|
use servicepoint2::{
|
||||||
ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT,
|
ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT,
|
||||||
TILE_WIDTH,
|
TILE_WIDTH,
|
||||||
};
|
};
|
||||||
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
@ -31,11 +31,8 @@ fn main() {
|
||||||
let mut filled_grid = PixelGrid::max_sized();
|
let mut filled_grid = PixelGrid::max_sized();
|
||||||
filled_grid.fill(true);
|
filled_grid.fill(true);
|
||||||
|
|
||||||
let command = BitmapLinearWin(
|
let command =
|
||||||
Origin(0, 0),
|
BitmapLinearWin(Origin(0, 0), filled_grid, CompressionCode::Lzma);
|
||||||
filled_grid,
|
|
||||||
CompressionCode::Lzma,
|
|
||||||
);
|
|
||||||
connection.send(command.into()).expect("send failed");
|
connection.send(command.into()).expect("send failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ use std::time::Duration;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use servicepoint2::{
|
use servicepoint2::{
|
||||||
BitVec, Command, CompressionCode, Connection, PixelGrid, PIXEL_HEIGHT,
|
BitVec, Command, CompressionCode, Connection, PixelGrid, FRAME_PACING,
|
||||||
PIXEL_WIDTH,
|
PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
|
@ -19,7 +19,11 @@ struct Cli {
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let sleep_duration = Duration::from_millis(cli.time / PIXEL_WIDTH as u64);
|
|
||||||
|
let sleep_duration = Duration::max(
|
||||||
|
FRAME_PACING,
|
||||||
|
Duration::from_millis(cli.time / PIXEL_WIDTH as u64),
|
||||||
|
);
|
||||||
|
|
||||||
let connection = Connection::open(cli.destination).unwrap();
|
let connection = Connection::open(cli.destination).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ pub use crate::compression_code::CompressionCode;
|
||||||
pub use crate::connection::Connection;
|
pub use crate::connection::Connection;
|
||||||
pub use crate::packet::{Header, Packet, Payload};
|
pub use crate::packet::{Header, Packet, Payload};
|
||||||
pub use crate::pixel_grid::PixelGrid;
|
pub use crate::pixel_grid::PixelGrid;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
#[cfg(feature = "c_api")]
|
#[cfg(feature = "c_api")]
|
||||||
pub use crate::c_slice::CByteSlice;
|
pub use crate::c_slice::CByteSlice;
|
||||||
|
@ -32,3 +33,6 @@ pub const PIXEL_WIDTH: u16 = TILE_WIDTH * TILE_SIZE;
|
||||||
pub const PIXEL_HEIGHT: u16 = TILE_HEIGHT * TILE_SIZE;
|
pub const PIXEL_HEIGHT: u16 = TILE_HEIGHT * TILE_SIZE;
|
||||||
/// pixel count on whole screen
|
/// pixel count on whole screen
|
||||||
pub const PIXEL_COUNT: usize = PIXEL_WIDTH as usize * PIXEL_HEIGHT as usize;
|
pub const PIXEL_COUNT: usize = PIXEL_WIDTH as usize * PIXEL_HEIGHT as usize;
|
||||||
|
|
||||||
|
/// Actual hardware limit is around 28-29ms/frame. Rounded up for less dropped packets.
|
||||||
|
pub const FRAME_PACING: Duration = Duration::from_millis(30);
|
||||||
|
|
Loading…
Reference in a new issue