better grid

This commit is contained in:
Ruben van de Ven 2025-07-03 13:47:58 +02:00
parent f63b70d218
commit e554dc30d0
2 changed files with 20 additions and 14 deletions

View file

@ -389,14 +389,10 @@ fn laser_frame_producer(model: &mut LaserModel, frame: &mut laser::Frame){
let new_points = model.config.filters.apply(&points); let new_points = model.config.filters.apply(&points);
let new_laser_points = new_points.points; let new_laser_points = new_points.points;
if new_laser_points.len() < pointno { // if new_laser_points.len() < pointno {
println!("Cropped Points {} (was: {})", new_laser_points.len(), pointno); // println!("Cropped Points {} (was: {})", new_laser_points.len(), pointno);
} // }
// on reconnect gives Unknown
// dbg!(&model.config);
// dbg!(&points.points[0]);
// dbg!(&new_laser_points[0]);
frame.add_lines(new_laser_points); frame.add_lines(new_laser_points);
return; return;

View file

@ -172,16 +172,22 @@ impl StreamSource{
LaserPoints { points, space: CoordinateSpace::Laser } LaserPoints { points, space: CoordinateSpace::Laser }
}, },
Self::Grid => { Self::Grid => {
let lines: usize = 5;
let mut points = Vec::new(); let mut points = Vec::new();
for i in (0..=0xFFF).step_by(0xFFF / 5) { // vertical lines
for i in 0..=lines {
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
let x = i * 0xFFF / lines;
points.push(laser::Point{ points.push(laser::Point{
position:[i as f32, 0.], position:[x as f32, offset],
color: [0., 0., 0.], color: [0., 0., 0.],
weight: 0, weight: 0,
}); });
for j in (0..=0xFFF).step_by(0xFFF / 10) { for j in (0..=0xFFF).step_by(0xFFF / 10) {
// go back and forth, so galvo has it easier
let y = if i % 2 == 0 { j } else {0xFFF - j};
points.push(laser::Point{ points.push(laser::Point{
position:[i as f32, j as f32], position:[x as f32, y as f32],
color: [1.,1.,1.], color: [1.,1.,1.],
weight: 0, weight: 0,
}); });
@ -189,15 +195,19 @@ impl StreamSource{
points.push(points[points.len()-1].blanked()); points.push(points[points.len()-1].blanked());
} }
for i in (0..=0xFFF).step_by(0xFFF / 5) { for i in 0..=lines {
let offset = if i % 2 == 0 { 0 } else {0xFFF } as f32;
let y = i * 0xFFF / lines;
points.push(laser::Point{ points.push(laser::Point{
position:[0., i as f32], position:[offset, y as f32],
color: [0., 0., 0.], color: [0., 0., 0.],
weight: 0, weight: 0,
}); });
for j in (0..=0xFFF).step_by(0xFFF / 10) { for j in (0..=0xFFF).step_by(0xFFF / 10) {
// go back and forth, so galvo has it easier
let x = if i % 2 == 0 { j } else {0xFFF - j};
points.push(laser::Point{ points.push(laser::Point{
position:[j as f32, i as f32], position:[x as f32, y as f32],
color: [1.,1.,1.], color: [1.,1.,1.],
weight: 0, weight: 0,
}); });