main: hook up calibration stubs
I guess I will be finishing this later.
This commit is contained in:
parent
5ad5be9c4d
commit
01b66150a3
@ -17,6 +17,24 @@ pub const AzEl = struct {
|
||||
elevation: f64,
|
||||
};
|
||||
|
||||
pub const CalibrationRoutine = enum {
|
||||
feedback,
|
||||
orientation,
|
||||
};
|
||||
|
||||
pub fn calibrate(allocator: std.mem.Allocator, routine: CalibrationRoutine) !void {
|
||||
const controller = try YaesuController.init(allocator);
|
||||
defer {
|
||||
controller.quit();
|
||||
controller.control_thread.join();
|
||||
}
|
||||
|
||||
switch (routine) {
|
||||
.feedback => try controller.calibrate_feedback(),
|
||||
.orientation => try controller.calibrate_orientation(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator) !YaesuController {
|
||||
const lock = try allocator.create(std.Thread.Mutex);
|
||||
errdefer allocator.destroy(lock);
|
||||
@ -116,6 +134,18 @@ pub fn startPark(self: YaesuController) void {
|
||||
self.setTarget(config.controller.parking_posture) catch unreachable;
|
||||
}
|
||||
|
||||
fn calibrate_feedback(self: YaesuController) !void {
|
||||
_ = self;
|
||||
log.err("this isn't implemented yet, sorry.", .{});
|
||||
return error.NotImplemented;
|
||||
}
|
||||
|
||||
fn calibrate_orientation(self: YaesuController) !void {
|
||||
_ = self;
|
||||
log.err("this isn't implemented yet, sorry.", .{});
|
||||
return error.NotImplemented;
|
||||
}
|
||||
|
||||
fn runController(controller: *Controller) void {
|
||||
controller.run() catch {
|
||||
log.err(
|
||||
|
22
src/main.zig
22
src/main.zig
@ -3,6 +3,7 @@ const std = @import("std");
|
||||
const Config = @import("./Config.zig");
|
||||
const lj = @import("./labjack.zig");
|
||||
const RotCtl = @import("./RotCtl.zig");
|
||||
const YaesuController = @import("./YaesuController.zig");
|
||||
|
||||
const udev = @import("udev_rules");
|
||||
|
||||
@ -68,7 +69,26 @@ pub fn main() !u8 {
|
||||
log.err("rotator controller ceased unexpectedly! {s}", .{@errorName(err)});
|
||||
return 1;
|
||||
};
|
||||
} else if (std.mem.eql(u8, args[1], commands.calibrate)) {
|
||||
if (args.len < 3 or args.len > 4) {
|
||||
printHelp(exename, .calibrate);
|
||||
return 1;
|
||||
}
|
||||
|
||||
loadConfigOrDefault(allocator, if (args.len == 4) args[3] else null) catch
|
||||
return 1;
|
||||
defer Config.deinit();
|
||||
|
||||
const routine = std.meta.stringToEnum(YaesuController.CalibrationRoutine, args[2]) orelse {
|
||||
log.err("{s} is not a known calibration routine.", .{args[2]});
|
||||
printHelp(exename, .calibrate);
|
||||
return 1;
|
||||
};
|
||||
|
||||
YaesuController.calibrate(allocator, routine) catch |err| {
|
||||
log.err("Calibration failed: {s}", .{@errorName(err)});
|
||||
return 1;
|
||||
};
|
||||
} else if (std.mem.eql(u8, args[1], commands.help)) {
|
||||
if (args.len != 3) {
|
||||
printHelp(exename, .help);
|
||||
@ -270,7 +290,7 @@ const command_help = .{
|
||||
\\ Perform a calibration routine and write an updated configuration with its results.
|
||||
\\
|
||||
\\Arguments:
|
||||
\\ routine Must be one of `feedback` or `orientation`. The different calibration routines have
|
||||
\\ routine Must be either `feedback` or `orientation`. The different calibration routines have
|
||||
\\ different requirements. `orientation` calibration is a sun-pointing-based routine and
|
||||
\\ should be performed after `feedback` calibration is complete.
|
||||
\\ config_file [Optional] the path of a config file to load. This file will be updated with the
|
||||
|
Loading…
x
Reference in New Issue
Block a user