Skip to content

Commit

Permalink
rename ticker.len -> ticker.message_len
Browse files Browse the repository at this point in the history
  • Loading branch information
arosspope committed Dec 22, 2023
1 parent 7b597ab commit 1debc53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ impl DotDisplay<'_> {
pub struct Ticker<'a> {
shift: isize,
index: usize,
pub speed_ms: usize,
pub message_len: usize,
pub message: [u8; 100],
pub display: DotDisplay<'a>,
pub len: usize,
pub speed_ms: usize,
}

impl Ticker<'_> {
pub fn new(display: DotDisplay<'_>) -> Ticker<'_> {
Ticker {
shift: 0,
index: 0,
len: 0,
speed_ms: 70,
message_len: 0,
message: [0; 100],
display,
}
Expand All @@ -120,10 +120,10 @@ impl Ticker<'_> {
bail!("Message too long");
}

self.len = message.len();
self.message[..self.len].copy_from_slice(message.as_bytes());
self.message[self.len] = b' ';
self.len += 1;
self.message_len = message.len();
self.message[..self.message_len].copy_from_slice(message.as_bytes());
self.message[self.message_len] = b' ';
self.message_len += 1;
Ok(())
}

Expand Down Expand Up @@ -151,7 +151,7 @@ impl Ticker<'_> {
pub fn tick(&mut self) {
if self.shift >= 8 {
self.shift = 0;
self.index = (self.index + 1) % self.len;
self.index = (self.index + 1) % self.message_len;
}

let previous = if self.index > 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() -> anyhow::Result<()> {

let config = TickerConfig {
speed: t.speed_ms as u32,
message: t.message.iter().map(|&c| c as char).take(t.len).collect(),
message: t.message.iter().map(|&c| c as char).take(t.message_len).collect(),
brightness: t.display.brightness,
};

Expand Down

0 comments on commit 1debc53

Please sign in to comment.