Removed bug from write operations
write_pedal() doesn't throw an error anymore. Did not verify yet if keys are set successfully.
This commit is contained in:
parent
60aa8037fb
commit
6bc9c31ed3
@ -5,7 +5,7 @@ extern crate hidapi;
|
|||||||
pub struct PedalsData {
|
pub struct PedalsData {
|
||||||
header: [u8; 8],
|
header: [u8; 8],
|
||||||
data: [u8; 48],
|
data: [u8; 48],
|
||||||
length: i32,
|
length: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pedals {
|
pub struct Pedals {
|
||||||
@ -55,8 +55,10 @@ impl Pedals {
|
|||||||
|
|
||||||
query[3] += ped;
|
query[3] += ped;
|
||||||
|
|
||||||
|
// Write query to device
|
||||||
dev.write(&query).unwrap();
|
dev.write(&query).unwrap();
|
||||||
|
|
||||||
|
// Read answer
|
||||||
dev.read(&mut buf[..]).unwrap();
|
dev.read(&mut buf[..]).unwrap();
|
||||||
|
|
||||||
buf
|
buf
|
||||||
@ -90,9 +92,10 @@ impl Pedals {
|
|||||||
dev.write(&self.ped_data[ped].header).unwrap();
|
dev.write(&self.ped_data[ped].header).unwrap();
|
||||||
|
|
||||||
// Write data to device in 8 byte chunks
|
// Write data to device in 8 byte chunks
|
||||||
for i in 0..self.ped_data[ped].length {
|
for i in 0..(self.ped_data[ped].length / 8) {
|
||||||
// Set bounds
|
// Set bounds
|
||||||
let low:usize = i as usize;
|
|
||||||
|
let low:usize = (i * 8) as usize;
|
||||||
let up:usize = 8 * (i + 1) as usize;
|
let up:usize = 8 * (i + 1) as usize;
|
||||||
|
|
||||||
// Write to device
|
// Write to device
|
||||||
@ -100,6 +103,7 @@ impl Pedals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This method writes all data from Pedals.peddata to the device
|
||||||
pub fn write_pedals(&self, dev: & hidapi::HidDevice) {
|
pub fn write_pedals(&self, dev: & hidapi::HidDevice) {
|
||||||
dev.write(&self.start).unwrap();
|
dev.write(&self.start).unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user