add tick timer and re-factor for app vs interface
This commit is contained in:
parent
51af5c3343
commit
1a714bd907
8 changed files with 164 additions and 27 deletions
|
|
@ -1,15 +1,15 @@
|
|||
use ch32_hal::timer::Channel;
|
||||
|
||||
use crate::insert_coin::services::{ServiceData, Service};
|
||||
use crate::insert_coin::services::{TickServiceData, TickService};
|
||||
|
||||
pub struct LedService {
|
||||
service_data: core::cell::RefCell<ServiceData>,
|
||||
service_data: core::cell::RefCell<TickServiceData>,
|
||||
pub channel: Channel,
|
||||
pub amplitude: u8,
|
||||
}
|
||||
|
||||
impl LedService {
|
||||
pub fn new(channel: Channel, service_data: ServiceData) -> Self {
|
||||
pub fn new(channel: Channel, service_data: TickServiceData) -> Self {
|
||||
Self {
|
||||
service_data: core::cell::RefCell::new(service_data),
|
||||
channel,
|
||||
|
|
@ -23,7 +23,7 @@ impl LedService {
|
|||
}
|
||||
|
||||
|
||||
impl Service for LedService {
|
||||
impl TickService for LedService {
|
||||
fn tick(&self) {
|
||||
let mut tc = self.service_data.borrow_mut();
|
||||
tc.ticks_remaining = tc.ticks_remaining.saturating_sub(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue