Compare commits

1 Commits

Author SHA1 Message Date
7a3ea61030 wip 2024-12-08 13:37:43 +01:00
8 changed files with 85 additions and 42 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
/.vscode
/.embuild /.embuild
/target /target
/Cargo.lock /Cargo.lock

26
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "probe-rs-debug",
"request": "launch",
"name": "probe-rs Test",
"cwd": "${workspaceFolder}",
"connectUnderReset": true,
"chip": "ESP32S3",
"flashingConfig": {
"flashingEnabled": true,
"haltAfterReset": true
},
"coreConfigs": [
{
"coreIndex": 0,
"programBinary": "./target/xtensa-esp32s3-espidf/debug/${workspaceFolderBasename}"
}
]
}
]
}

View File

@ -11,11 +11,13 @@ name = "renderbug"
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
[profile.release] [profile.release]
opt-level = "s" opt-level = 3
lto = true
[profile.dev] [profile.dev]
debug = true # Symbols are nice and they don't increase the size on Flash debug = true # Symbols are nice and they don't increase the size on Flash
opt-level = "z" opt-level = "z"
lto = true
[features] [features]
default = ["std", "esp-idf-svc/native", "rmt", "smart-leds"] default = ["std", "esp-idf-svc/native", "rmt", "smart-leds"]
@ -48,6 +50,7 @@ embedded-graphics = { version = "0.8.1", optional = true, features = ["fixed_poi
ansi_term = "0.12.1" ansi_term = "0.12.1"
num = "0.4.3" num = "0.4.3"
chrono = "0.4.38" chrono = "0.4.38"
fugit = "0.3.7"
[build-dependencies] [build-dependencies]
embuild = "0.32.0" embuild = "0.32.0"

View File

@ -1,18 +1,15 @@
[x] cfg macros [x] cfg macros
[ ] warnings [ ] warnings
[x] rgb crate [x] rgb crate
[x] Layer blending [ ] Layer blending
[x] Refactor idle pattern into test pattern [ ] Refactor idle pattern into test pattern
[x] Wifi [ ] Wifi
[ ] JSON surface map loading [ ] JSON surface map loading
[ ] Weather [ ] Weather
[x] Circadian Rhythm [ ] Circadian Rhythm
[x] NTP [ ] NTP
[ ] Config to only start a subset of tasks on startup [ ] Config to only start a subset of tasks on startup
[ ] Serial CLI [ ] Serial CLI
[ ] Surface blending API [ ] Surface blending API
[ ] Layer blending equations [ ] Layer blending equations
[ ] Surface rotation [ ] Surface rotation
[ ] esp8266 port
[ ] event system
[ ] threaded schedulers

View File

@ -38,7 +38,7 @@ fn main() {
log::info!("Creating animations"); log::info!("Creating animations");
let mut animations = FixedSizeScheduler::new([ let mut animations = FixedSizeScheduler::new([
Box::new(animations::IdleTask::new(&mut surfaces)), Box::new(animations::IdleTask::new(&mut surfaces)),
Box::new(animations::TestPattern::new(surfaces.new_surface(&Rectangle::everything()).unwrap())), //Box::new(animations::TestPattern::new(surfaces.new_surface(&Rectangle::everything()).unwrap())),
]); ]);
let mut renderer = FixedSizeScheduler::new([Box::new(Renderer::new(output, surfaces))]); let mut renderer = FixedSizeScheduler::new([Box::new(Renderer::new(output, surfaces))]);

View File

@ -107,24 +107,6 @@ impl<const STRIDE_NUM: usize> StrideMapping<STRIDE_NUM> {
]) ])
} }
pub fn new_cyberplague() -> Self {
Self::from_json(&[
(0, 6, 6, false),
(1, 6, 6, true),
(2, 6, 6, false),
(3, 4, 9, true),
(4, 4, 14, false),
(5, 0, 17, true),
(6, 2, 12, false),
(7, 0, 18, true),
(8, 4, 14, false),
(9, 5, 9, true),
(10, 4, 7, false),
(11, 5, 6, true),
(12, 5, 6, false)
])
}
pub fn new_jar() -> Self { pub fn new_jar() -> Self {
Self::from_json(&[ Self::from_json(&[
(0, 0, 17, false), (0, 0, 17, false),

View File

@ -175,15 +175,7 @@ impl Board for Esp32Board {
std::thread::spawn(move || { FastWs2812Esp32Rmt::new(peripherals.rmt.channel0, pins.gpio5).unwrap() }).join().unwrap(), std::thread::spawn(move || { FastWs2812Esp32Rmt::new(peripherals.rmt.channel0, pins.gpio5).unwrap() }).join().unwrap(),
MAX_POWER_MW MAX_POWER_MW
) )
}, }
[0xfc, 0xf5, 0xc4, 0x05, 0xb8, 0x30, 0x0, 0x0] => { // cyberplague
StrideOutput::new(
Pixbuf::new(),
StrideMapping::new_cyberplague(),
std::thread::spawn(move || { FastWs2812Esp32Rmt::new(peripherals.rmt.channel0, pins.gpio13).unwrap() }).join().unwrap(),
MAX_POWER_MW
)
},
_ => { _ => {
StrideOutput::new( StrideOutput::new(
Pixbuf::new(), Pixbuf::new(),
@ -273,9 +265,9 @@ impl CircadianRhythm {
adjusted_end.hour += 24; adjusted_end.hour += 24;
} }
let start_time = (start.hour as u16).wrapping_mul(60); let start_time = start.hour * 60;
let end_time = (end.hour as u16).wrapping_mul(60); let end_time = end.hour * 60;
let now_time = (hour as u16).wrapping_mul(60).wrapping_add(minute as u16); let now_time = hour * 60 + minute;
let duration = end_time - start_time; let duration = end_time - start_time;
let cur_duration = now_time - start_time; let cur_duration = now_time - start_time;

View File

@ -0,0 +1,44 @@
use rgb::Rgb;
use super::smart_leds_lib::rmt::FastWs2812Esp32Rmt;
use super::smart_leds_lib::StrideOutput;
use crate::task::{FixedSizeScheduler, Task};
use crate::buffers::StaticSurfacePool;
use super::Board;
pub struct Esp32Board<'a> {
output: Option<<Self as Board>::Output>,
surfaces: Option<StaticSurfacePool>,
tasks: Option<[&'a mut dyn Task; 1]>
}
impl<'a> Board for Esp32Board<'a> {
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'a>>;
type Surfaces = StaticSurfacePool;
type Scheduler = FixedSizeScheduler<0>;
fn take() -> Self {
let peripherals = esp_hal::init(esp_hal::Config::default());
//esp_alloc::heap_allocator!(72 * 1024);
const POWER_VOLTS : u32 = 5;
const POWER_MA : u32 = 500;
const MAX_POWER_MW : u32 = POWER_VOLTS * POWER_MA;
let pins = peripherals.pins;
Esp32Board { output: None, surfaces: None, tasks: None }
}
fn output(&mut self) -> Self::Output {
self.output.take().unwrap()
}
fn surfaces(&mut self) -> Self::Surfaces {
self.surfaces.take().unwrap()
}
fn system_tasks(&mut self) -> Self::Scheduler {
FixedSizeScheduler::new([])
}
}