This commit is contained in:
eraden 2024-01-03 12:49:02 +01:00
commit d070ff2f91
7 changed files with 3469 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1986
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

59
Cargo.toml Normal file
View File

@ -0,0 +1,59 @@
[package]
name = "qbd"
version = "0.1.0"
edition = "2021"
[features]
backlight = []
backlight_default_on = ["backlight"]
backlight_on_state = ["backlight"]
backlight_breathing = ["backlight"]
backlight_breathing_default_on = ["backlight", "backlight_breathing"]
default = ["backlight", "backlight_breathing"]
[dependencies]
embassy-embedded-hal = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-sync = { version = "0.5.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-executor = { version = "0.4.0", git = "https://github.com/embassy-rs/embassy.git", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
embassy-time = { version = "0.2", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] }
embassy-usb = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-net = { version = "0.2.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
embassy-net-wiznet = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git", features = ["defmt"] }
embassy-futures = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git" }
embassy-usb-logger = { version = "0.1.0", git = "https://github.com/embassy-rs/embassy.git" }
defmt = "0.3"
defmt-rtt = "0.4"
fixed = "1.23.1"
fixed-macro = "1.2"
#cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m = { version = "0.7.6", features = ["inline-asm"] }
cortex-m-rt = "0.7.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
display-interface-spi = "0.4.1"
embedded-graphics = "0.7.1"
st7789 = "0.6.1"
display-interface = "0.4.1"
byte-slice-cast = { version = "1.2.0", default-features = false }
smart-leds = "0.3.0"
heapless = "0.8"
usbd-hid = "0.6.1"
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" }
embedded-hal-async = "1.0.0-rc.3"
embedded-hal-bus = { version = "0.1.0-rc.3", features = ["async"] }
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
embedded-storage = { version = "0.3" }
static_cell = "2"
portable-atomic = { version = "1.5", features = ["critical-section"] }
log = "0.4"
pio-proc = "0.2"
pio = "0.2.1"
rand = { version = "0.8.5", default-features = false }
[profile.release]
debug = 2

66
src/backlight.rs Normal file
View File

@ -0,0 +1,66 @@
use embassy_rp::gpio::{AnyPin, Output};
pub type BacklightLevel = u8;
#[cfg(feature = "backlight_breathing")]
pub struct BacklightBreathing {
pub enabled: bool,
pub period: std::time::Duration,
}
pub struct Backlight<'d> {
pub pins: Vec<Output<'d, AnyPin>>,
pub on: bool,
pub default_on: bool,
pub lvl: BacklightLevel,
pub default_lvl: BacklightLevel,
#[cfg(feature = "backlight_breathing")]
pub breathing: BacklightBreathing,
}
impl<'d> Backlight<'d> {
pub fn new(pins: Vec<Output<'d, AnyPin>>, default_lvl: BacklightLevel) -> Self {
let mut bl = Self {
pins,
on: cfg!(feature = "backlight_default_on"),
default_on: cfg!(feature = "backlight_default_on"),
lvl: default_lvl,
default_lvl: default_lvl,
#[cfg(feature = "backlight_breathing")]
breathing: BacklightBreathing {
enabled: cfg!(feature = "backlight_breathing_default_on"),
period: std::time::Duration::from_millis(66),
},
};
bl.backlight_pins_off();
bl
}
fn backlight_pin_on<'d>(pin: &mut Output<'d, AnyPin>) {
if cfg!(feature = "backlight_on_state") {
pin.set_high();
} else {
pin.set_low();
}
}
fn backlight_pin_off<'d>(pin: &mut Output<'d, AnyPin>) {
if cfg!(feature = "backlight_on_state") {
pin.set_low();
} else {
pin.set_high();
}
}
pub fn backlight_pins_on<'d>(&mut self) {
for pin in &mut self.pins {
Self::backlight_pin_on(pin);
}
}
pub fn backlight_pins_off<'d>(&mut self) {
for pin in &mut self.pins {
Self::backlight_pin_off(pin);
}
}
pub fn breathing_task() {}
}

1340
src/keycodes.rs Normal file

File diff suppressed because it is too large Load Diff

2
src/lib.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod backlight;
pub mod keycodes;

15
src/main.rs Normal file
View File

@ -0,0 +1,15 @@
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_rp::gpio::Pin;
use embassy_rp::{gpio, init};
use embassy_time::Timer;
use gpio::{Level, Output};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = init(Default::default());
}