@@ -76,12 +76,11 @@ pub fn Stepper(comptime Driver: type) type {
76
76
steps_remaining : u32 = 0 ,
77
77
// Steps remaining in decel
78
78
steps_to_brake : u32 = 0 ,
79
- // TODO: Just `.from_us(0)` with zig 0.14!
80
- step_pulse : mdf.time.Duration = mdf .time .Duration .from_us (0 ),
81
- cruise_step_pulse : mdf.time.Duration = mdf .time .Duration .from_us (0 ),
82
- remainder : mdf.time.Duration = mdf .time .Duration .from_us (0 ),
83
- last_action_end : mdf.time.Absolute = mdf .time .Absolute .from_us (0 ),
84
- next_action_interval : mdf.time.Duration = mdf .time .Duration .from_us (0 ),
79
+ step_pulse : mdf.time.Duration = .from_us (0 ),
80
+ cruise_step_pulse : mdf.time.Duration = .from_us (0 ),
81
+ remainder : mdf.time.Duration = .from_us (0 ),
82
+ last_action_end : mdf.time.Absolute = .from_us (0 ),
83
+ next_action_interval : mdf.time.Duration = .from_us (0 ),
85
84
step_count : u32 = 0 ,
86
85
dir_state : mdf.base.Digital_IO.State = .low ,
87
86
motor_steps : u16 ,
@@ -191,16 +190,16 @@ pub fn Stepper(comptime Driver: type) type {
191
190
}
192
191
193
192
pub fn start_move (self : * Self , steps : i32 ) void {
194
- self .start_move_time (steps , mdf . time . Duration .from_us (0 ));
193
+ self .start_move_time (steps , .from_us (0 ));
195
194
}
196
195
197
196
pub fn start_move_time (self : * Self , steps : i32 , time : mdf.time.Duration ) void {
198
197
// set up new move
199
198
self .dir_state = if (steps >= 0 ) .high else .low ;
200
- self .last_action_end = mdf . time . Absolute .from_us (0 );
199
+ self .last_action_end = .from_us (0 );
201
200
self .steps_remaining = @abs (steps );
202
201
self .step_count = 0 ;
203
- self .remainder = mdf . time . Duration .from_us (0 );
202
+ self .remainder = .from_us (0 );
204
203
switch (self .profile ) {
205
204
.linear_speed = > | p | {
206
205
const microstep_f : f64 = @floatFromInt (self .microsteps );
@@ -237,7 +236,7 @@ pub fn Stepper(comptime Driver: type) type {
237
236
self .cruise_step_pulse = get_step_pulse (self .motor_steps , self .microsteps , self .rpm );
238
237
self .step_pulse = self .cruise_step_pulse ;
239
238
if (@intFromEnum (time ) > self .steps_remaining * @intFromEnum (self .step_pulse )) {
240
- self .step_pulse = mdf . time . Duration .from_us (@intFromFloat (@as (f64 , @floatFromInt (time .to_us ())) /
239
+ self .step_pulse = .from_us (@intFromFloat (@as (f64 , @floatFromInt (time .to_us ())) /
241
240
@as (f64 , @floatFromInt (self .steps_remaining ))));
242
241
}
243
242
},
@@ -272,7 +271,7 @@ pub fn Stepper(comptime Driver: type) type {
272
271
} else {
273
272
// The series approximates target, set the final value to what it should be instead
274
273
self .step_pulse = self .cruise_step_pulse ;
275
- self .remainder = mdf . time . Duration .from_us (0 );
274
+ self .remainder = .from_us (0 );
276
275
}
277
276
},
278
277
.decelerating = > {
@@ -297,7 +296,7 @@ pub fn Stepper(comptime Driver: type) type {
297
296
self .clock .sleep_us (@intFromEnum (delay_us ));
298
297
return ;
299
298
}
300
- const deadline = mdf .time .Deadline .init_relative (start_us , delay_us );
299
+ const deadline : mdf.time.Deadline = .init_relative (start_us , delay_us );
301
300
while (! deadline .is_reached_by (self .clock .get_time_since_boot ())) {}
302
301
}
303
302
@@ -320,8 +319,8 @@ pub fn Stepper(comptime Driver: type) type {
320
319
self .next_action_interval = if (elapsed .less_than (pulse )) pulse .minus (elapsed ) else @enumFromInt (1 );
321
320
} else {
322
321
// end of move
323
- self .last_action_end = mdf . time . Absolute .from_us (0 );
324
- self .next_action_interval = mdf . time . Duration .from_us (0 );
322
+ self .last_action_end = .from_us (0 );
323
+ self .next_action_interval = .from_us (0 );
325
324
}
326
325
return self .next_action_interval ;
327
326
}
0 commit comments