Skip to content

Commit c940f74

Browse files
committed
fix: controller ADC scaling
1 parent 7a09bd3 commit c940f74

File tree

3 files changed

+67
-29
lines changed

3 files changed

+67
-29
lines changed

Cargo.lock

Lines changed: 50 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ cortex-m-semihosting = "0.3.2"
1515
cortex-m-rtfm = "0.4.2"
1616
cortex-m-rt = "0.6.8"
1717
embedded-hal = "0.2.2"
18-
nrf52810-hal = { git = "https://github.com/nrf-rs/nrf52-hal", rev = "6c1ce70", features = ["rt"] }
18+
nrf52810-hal = { git = "https://github.com/nrf-rs/nrf52-hal", rev = "8459b7e", features = ["rt"] }
1919
nb = "0.1.1"
2020
fpa = "0.1.0"
2121
byteorder = { version = "1.3.1", default-features = false }
2222
panic-semihosting = "0.5.1"
2323
bitflags = "1.0.4"
2424
uuid = { version = "0.7.4", default-features = false }
25-
rubble = { git = "https://github.com/jonas-schievink/rubble.git", rev = "640b705" }
26-
rubble-nrf52810 = { git = "https://github.com/jonas-schievink/rubble.git", rev = "640b705" }
25+
rubble = { git = "https://github.com/jonas-schievink/rubble.git", rev = "0e49250" }
26+
rubble-nrf52810 = { git = "https://github.com/jonas-schievink/rubble.git", rev = "0e49250" }
2727
log = "0.4.6"
2828
bbqueue = "0.3.2"

controller/src/main.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ extern crate panic_semihosting;
77
mod logger;
88

99
use {
10-
embedded_hal::adc::OneShot,
1110
crate::logger::{BbqLogger, StampedLogger},
1211
bbqueue::{bbq, BBQueue, Consumer},
1312
core::fmt::Write,
1413
cortex_m_semihosting::hprintln,
14+
embedded_hal::adc::OneShot,
1515
log::{info, LevelFilter},
1616
nrf52810_hal::{
1717
self as hal,
1818
gpio::Level,
1919
nrf52810_pac::{self as pac, UARTE0},
2020
prelude::*,
21-
uarte::{Baudrate, Parity, Uarte},
2221
saadc::Saadc,
22+
uarte::{Baudrate, Parity, Uarte},
2323
},
2424
rtfm::app,
2525
rubble::{
@@ -31,7 +31,7 @@ use {
3131
LinkLayer, Responder, MAX_PDU_SIZE,
3232
},
3333
security_manager::NoSecurity,
34-
time::{Timer},
34+
time::Timer,
3535
},
3636
rubble_nrf52810::{
3737
radio::{BleRadio, PacketBuffer},
@@ -138,7 +138,10 @@ const APP: () = {
138138
let (_rx_prod, rx) = queue::create(bbq![1024].unwrap());
139139

140140
// Create the actual BLE stack objects
141-
let ll = LinkLayer::<HwNRf52810>::new(DeviceAddress::new([169, 255, 235, 206, 50, 121], AddressKind::Random), ble_timer);
141+
let ll = LinkLayer::<HwNRf52810>::new(
142+
DeviceAddress::new([169, 255, 235, 206, 50, 121], AddressKind::Random),
143+
ble_timer,
144+
);
142145

143146
let resp = Responder::new(
144147
tx,
@@ -175,10 +178,14 @@ const APP: () = {
175178

176179
let val: u16 = resources.ADC.read(resources.ADC_PIN).unwrap();
177180

178-
let beacon = Beacon::new(device_address, &[AdStructure::Unknown {
181+
let beacon = Beacon::new(
182+
device_address,
183+
&[AdStructure::Unknown {
179184
ty: 0xFF,
180-
data: &[(val / 38) as u8],
181-
}]).unwrap();
185+
data: &[((val / 13) - 250) as u8],
186+
}],
187+
)
188+
.unwrap();
182189

183190
beacon.broadcast(&mut *resources.RADIO);
184191
}

0 commit comments

Comments
 (0)