Move normalization factor to cli argument
This commit is contained in:
parent
b7b42d95a9
commit
6035e39c05
15
src/main.rs
15
src/main.rs
|
@ -176,6 +176,12 @@ fn main() -> Result<(), String> {
|
|||
.value_name("THRESHOLD")
|
||||
.help("Set a rotation threshold between 0 and 1")
|
||||
.takes_value(true),
|
||||
Arg::with_name("normalization-factor")
|
||||
.default_value("6")
|
||||
.long("normalization-factor")
|
||||
.value_name("NORMALIZATION_FACTOR")
|
||||
.help("Set factor for sensor value normalization")
|
||||
.takes_value(true),
|
||||
];
|
||||
|
||||
match backend {
|
||||
|
@ -203,6 +209,11 @@ fn main() -> Result<(), String> {
|
|||
let old_state_owned = get_window_server_rotation_state(display, &backend)?;
|
||||
let mut old_state = old_state_owned.as_str();
|
||||
|
||||
let normalization_factor = matches
|
||||
.value_of("normalization-factor")
|
||||
.unwrap_or("default.conf");
|
||||
let normalization_factor = normalization_factor.parse::<f32>().unwrap_or(1e6);
|
||||
|
||||
let keyboards = get_keyboards(&backend)?;
|
||||
|
||||
for entry in glob("/sys/bus/iio/devices/iio:device*/in_accel_*_raw").unwrap() {
|
||||
|
@ -258,8 +269,8 @@ fn main() -> Result<(), String> {
|
|||
let y_clean = y_raw.trim_end_matches('\n').parse::<i32>().unwrap_or(0);
|
||||
|
||||
// Normalize vectors
|
||||
let x: f32 = (x_clean as f32) / 1e6;
|
||||
let y: f32 = (y_clean as f32) / 1e6;
|
||||
let x: f32 = (x_clean as f32) / normalization_factor;
|
||||
let y: f32 = (y_clean as f32) / normalization_factor;
|
||||
|
||||
for (_i, orient) in orientations.iter().enumerate() {
|
||||
let d = (x - orient.vector.0).powf(2.0) + (y - orient.vector.1).powf(2.0);
|
||||
|
|
Loading…
Reference in New Issue