main: hook up calibration stubs
I guess I will be finishing this later.
This commit is contained in:
parent
2194dd4a8c
commit
eb7ad4ef9e
@ -17,6 +17,24 @@ pub const AzEl = struct {
|
|||||||
elevation: f64,
|
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 {
|
pub fn init(allocator: std.mem.Allocator) !YaesuController {
|
||||||
const lock = try allocator.create(std.Thread.Mutex);
|
const lock = try allocator.create(std.Thread.Mutex);
|
||||||
errdefer allocator.destroy(lock);
|
errdefer allocator.destroy(lock);
|
||||||
@ -116,6 +134,18 @@ pub fn startPark(self: YaesuController) void {
|
|||||||
self.setTarget(config.controller.parking_posture) catch unreachable;
|
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 {
|
fn runController(controller: *Controller) void {
|
||||||
controller.run() catch {
|
controller.run() catch {
|
||||||
log.err(
|
log.err(
|
||||||
|
22
src/main.zig
22
src/main.zig
@ -4,6 +4,7 @@ const builtin = @import("builtin");
|
|||||||
const Config = @import("./Config.zig");
|
const Config = @import("./Config.zig");
|
||||||
const lj = @import("./labjack.zig");
|
const lj = @import("./labjack.zig");
|
||||||
const RotCtl = @import("./RotCtl.zig");
|
const RotCtl = @import("./RotCtl.zig");
|
||||||
|
const YaesuController = @import("./YaesuController.zig");
|
||||||
|
|
||||||
const udev = @import("udev_rules");
|
const udev = @import("udev_rules");
|
||||||
|
|
||||||
@ -69,7 +70,26 @@ pub fn main() !u8 {
|
|||||||
log.err("rotator controller ceased unexpectedly! {s}", .{@errorName(err)});
|
log.err("rotator controller ceased unexpectedly! {s}", .{@errorName(err)});
|
||||||
return 1;
|
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)) {
|
} else if (std.mem.eql(u8, args[1], commands.help)) {
|
||||||
if (args.len != 3) {
|
if (args.len != 3) {
|
||||||
printHelp(exename, .help);
|
printHelp(exename, .help);
|
||||||
@ -271,7 +291,7 @@ const command_help = .{
|
|||||||
\\ Perform a calibration routine and write an updated configuration with its results.
|
\\ Perform a calibration routine and write an updated configuration with its results.
|
||||||
\\
|
\\
|
||||||
\\Arguments:
|
\\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
|
\\ different requirements. `orientation` calibration is a sun-pointing-based routine and
|
||||||
\\ should be performed after `feedback` calibration is complete.
|
\\ 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
|
\\ 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