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::time::Duration;
|
||||
|
||||
use clap::Parser;
|
||||
use rand::{distributions, Rng};
|
||||
|
||||
use servicepoint2::{Command, CompressionCode, Connection, Origin, PixelGrid};
|
||||
use servicepoint2::{
|
||||
Command, CompressionCode, Connection, Origin, PixelGrid, FRAME_PACING,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -32,7 +33,7 @@ fn main() {
|
|||
.into(),
|
||||
)
|
||||
.expect("could not send");
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
thread::sleep(FRAME_PACING);
|
||||
field = iteration(field);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{
|
||||
Command, CompressionCode, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||
PixelGrid,
|
||||
Command, CompressionCode, Connection, Origin, PixelGrid, FRAME_PACING,
|
||||
PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -36,6 +35,6 @@ fn main() {
|
|||
.into(),
|
||||
)
|
||||
.unwrap();
|
||||
thread::sleep(Duration::from_millis(14));
|
||||
thread::sleep(FRAME_PACING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ use std::time::Duration;
|
|||
use clap::Parser;
|
||||
use rand::Rng;
|
||||
|
||||
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
||||
use servicepoint2::{
|
||||
ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT,
|
||||
TILE_WIDTH,
|
||||
};
|
||||
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -31,11 +31,8 @@ fn main() {
|
|||
let mut filled_grid = PixelGrid::max_sized();
|
||||
filled_grid.fill(true);
|
||||
|
||||
let command = BitmapLinearWin(
|
||||
Origin(0, 0),
|
||||
filled_grid,
|
||||
CompressionCode::Lzma,
|
||||
);
|
||||
let command =
|
||||
BitmapLinearWin(Origin(0, 0), filled_grid, CompressionCode::Lzma);
|
||||
connection.send(command.into()).expect("send failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::time::Duration;
|
|||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{
|
||||
BitVec, Command, CompressionCode, Connection, PixelGrid, PIXEL_HEIGHT,
|
||||
PIXEL_WIDTH,
|
||||
BitVec, Command, CompressionCode, Connection, PixelGrid, FRAME_PACING,
|
||||
PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
@ -19,7 +19,11 @@ struct Cli {
|
|||
fn main() {
|
||||
env_logger::init();
|
||||
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();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ pub use crate::compression_code::CompressionCode;
|
|||
pub use crate::connection::Connection;
|
||||
pub use crate::packet::{Header, Packet, Payload};
|
||||
pub use crate::pixel_grid::PixelGrid;
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "c_api")]
|
||||
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;
|
||||
/// pixel count on whole screen
|
||||
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