code dump 1
This commit is contained in:
parent
e736eb4c60
commit
f0357aa8ec
File diff suppressed because it is too large
Load Diff
|
|
@ -11,7 +11,8 @@ input = { git = "https://github.com/Smithay/input.rs" }
|
|||
udev = "0.2"
|
||||
libc = "0.2"
|
||||
errno = "0.2"
|
||||
csv = "1.1.3"
|
||||
csv = "1.1"
|
||||
druid = "0.6"
|
||||
|
||||
[dependencies.gtk]
|
||||
version = "0.8.1"
|
||||
|
|
@ -24,4 +25,3 @@ features = ["v2_60"]
|
|||
[dependencies.gdk]
|
||||
version = ""
|
||||
features = ["v3_24"]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ def import_csv_data(filename):
|
|||
reader = csv.reader(csv_fp)
|
||||
next(reader) # skip header
|
||||
for row in reader:
|
||||
for i, v in enumerate([stylus_x, stylus_y, stylus_pressure, time]):
|
||||
for i, v in enumerate([stylus_x, stylus_y]): #, stylus_pressure, time]):
|
||||
v.append(float(row[i]))
|
||||
stylus_pos = np.array([stylus_x, stylus_y])
|
||||
time = np.array(time)
|
||||
|
|
|
|||
|
|
@ -46,21 +46,24 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"215"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
"ename": "NameError",
|
||||
"evalue": "name 'pos' is not defined",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-2-85aa0823d467>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;31mNameError\u001b[0m: name 'pos' is not defined"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": []
|
||||
"source": [
|
||||
"pos[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
|
@ -104,7 +107,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.5"
|
||||
"version": "3.8.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
|
|
@ -64,15 +64,11 @@ fn main() {
|
|||
}
|
||||
|
||||
}
|
||||
println!("{} points drawn", state.point_buffer.len());
|
||||
|
||||
gtk::Inhibit(false)
|
||||
});
|
||||
|
||||
let save_button = Button::new_from_icon_name(Some("document-save-symbolic"), gtk::IconSize::Menu);
|
||||
//save_button.connect_clicked(|_| {
|
||||
//
|
||||
//});
|
||||
let clear_button = Button::new_from_icon_name(Some("edit-clear-all-symbolic"), gtk::IconSize::Menu);
|
||||
let check_button = CheckButton::new_with_label("Join Points");
|
||||
|
||||
|
|
@ -96,6 +92,18 @@ fn main() {
|
|||
win_clone.queue_draw();
|
||||
});
|
||||
|
||||
let state_clone_4 = Rc::clone(&app_state);
|
||||
save_button.connect_clicked(move |_| {
|
||||
let writer = csv::Writer::from_path("acquired_data.csv");
|
||||
if let Ok(mut wrt) = writer {
|
||||
wrt.write_record(&["x", "y"]).expect("write error");
|
||||
for pt in &state_clone_4.borrow().point_buffer {
|
||||
wrt.write_record(&[pt.0.to_string(), pt.1.to_string()]).expect("write error");
|
||||
}
|
||||
wrt.flush().unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
let state_clone_3 = Rc::clone(&app_state);
|
||||
let win_clone_2 = Rc::clone(&window);
|
||||
check_button.connect_clicked(move |_| {
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ impl LibinputInterface for SimpleLibinputInterface {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let udev_ctx = udev::Context::new().unwrap();
|
||||
let libinput_interface = SimpleLibinputInterface{};
|
||||
let mut libinput_ctx = Libinput::new_from_udev(libinput_interface, &udev_ctx);
|
||||
let mut libinput_ctx = Libinput::new_with_udev(libinput_interface);
|
||||
|
||||
libinput_ctx.udev_assign_seat("seat0").unwrap();
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ fn main() {
|
|||
while let Some(event) = libinput_ctx.next() {
|
||||
if let Event::Tablet(tablet_evt) = event {
|
||||
if let TabletToolEvent::Axis(axis_evt) = tablet_evt {
|
||||
if axis_evt.pressure() > 1e-3 {
|
||||
if true { //axis_evt.pressure() > 1e-3 {
|
||||
let pressure = axis_evt.pressure();
|
||||
let x_t = axis_evt.x_transformed(1080);
|
||||
let y_t = axis_evt.y_transformed(1920);
|
||||
|
|
|
|||
Loading…
Reference in New Issue