This commit is contained in:
Vitalii 2026-02-11 01:48:56 +02:00
parent b89972c5e3
commit cc9d55f160
Signed by: SymbX
GPG Key ID: FF51F4E4BCE459EE
3 changed files with 13 additions and 3 deletions

1
Cargo.lock generated
View File

@ -757,6 +757,7 @@ dependencies = [
"embassy-nrf", "embassy-nrf",
"embassy-sync 0.7.2", "embassy-sync 0.7.2",
"embassy-time", "embassy-time",
"embedded-storage-async",
"futures", "futures",
"nrf-softdevice", "nrf-softdevice",
"panic-halt", "panic-halt",

View File

@ -19,6 +19,7 @@ panic-halt = "1.0.0"
panic-probe = { version = "1.0.0", features = ["print-defmt"], optional = true } panic-probe = { version = "1.0.0", features = ["print-defmt"], optional = true }
nrf-softdevice = { version = "0.1.0", features = ["s140", "ble-peripheral", "nrf52840", "nrf-softdevice-s140", "critical-section-impl", "defmt", "nrf52840-pac", "critical-section", "ble-gatt-server"] } nrf-softdevice = { version = "0.1.0", features = ["s140", "ble-peripheral", "nrf52840", "nrf-softdevice-s140", "critical-section-impl", "defmt", "nrf52840-pac", "critical-section", "ble-gatt-server"] }
futures = { version = "0.3", default-features = false, features = [] } futures = { version = "0.3", default-features = false, features = [] }
embedded-storage-async = "0.4.1"
[[bin]] [[bin]]
name = "odesa" name = "odesa"

View File

@ -27,9 +27,10 @@ use embassy_sync::signal::Signal;
use embassy_time::{with_timeout, Duration, Timer}; use embassy_time::{with_timeout, Duration, Timer};
use futures::future::{select, Either}; use futures::future::{select, Either};
use futures::pin_mut; use futures::pin_mut;
use nrf_softdevice::{raw, Softdevice}; use nrf_softdevice::{raw, Flash, Softdevice};
use nrf_softdevice::ble::advertisement_builder::{Flag, LegacyAdvertisementBuilder, LegacyAdvertisementPayload, ServiceList, ServiceUuid16}; use nrf_softdevice::ble::advertisement_builder::{Flag, LegacyAdvertisementBuilder, LegacyAdvertisementPayload, ServiceList, ServiceUuid16};
use nrf_softdevice::ble::{peripheral, gatt_server, Connection}; use nrf_softdevice::ble::{peripheral, gatt_server, Connection};
use embedded_storage_async::nor_flash::ReadNorFlash;
#[derive(Copy, Clone, Eq, PartialEq, Format)] #[derive(Copy, Clone, Eq, PartialEq, Format)]
enum SysAction { enum SysAction {
@ -152,6 +153,13 @@ async fn main(spawner: Spawner) {
channel_config.reference = Reference::INTERNAL; channel_config.reference = Reference::INTERNAL;
let saadc = Saadc::new(p.SAADC, AdcIrqs, saadc::Config::default(), [channel_config]); let saadc = Saadc::new(p.SAADC, AdcIrqs, saadc::Config::default(), [channel_config]);
saadc.calibrate().await; saadc.calibrate().await;
let flash = Flash::take(sd);
pin_mut!(flash);
let mut data = [0u8; 16];
if let Err(e) = flash.as_mut().read(0x000F9800 - 4096, &mut data).await {
error!("Error reading from flash: {}", e);
}
info!("Data in flash: {:?}", data);
let pwm_text = SimplePwm::new_3ch(p.PWM0, p.P1_00, p.P1_04, p.P1_06, &Default::default()); let pwm_text = SimplePwm::new_3ch(p.PWM0, p.P1_00, p.P1_04, p.P1_06, &Default::default());
let pwm_heart = SimplePwm::new_3ch(p.PWM2, p.P0_17, p.P0_20, p.P0_22, &Default::default()); let pwm_heart = SimplePwm::new_3ch(p.PWM2, p.P0_17, p.P0_20, p.P0_22, &Default::default());
@ -486,11 +494,11 @@ async fn light_task(mut pwm: SimplePwm<'static>) {
match action { match action {
SysAction::PresentenceOn if intensity < 100 => { SysAction::PresentenceOn if intensity < 100 => {
intensity.add_assign(1); intensity.add_assign(1);
info!("Increase intensity to {}", intensity); // info!("Increase intensity to {}", intensity);
}, },
SysAction::PresentenceOff if intensity > 0 => { SysAction::PresentenceOff if intensity > 0 => {
intensity.sub_assign(1); intensity.sub_assign(1);
info!("Decrease intensity to {}", intensity); // info!("Decrease intensity to {}", intensity);
}, },
_ => { _ => {
// ignore // ignore