labjack: use symbolic gain values
This reads better in the config file.
This commit is contained in:
parent
0e88022a8d
commit
7105775426
@ -48,8 +48,8 @@ labjack: LabjackConfig = .{
|
||||
},
|
||||
},
|
||||
controller: ControllerConfig = .{
|
||||
.azimuth_input = .{ .channel = .diff_01, .gain_index = 2 },
|
||||
.elevation_input = .{ .channel = .diff_23, .gain_index = 2 },
|
||||
.azimuth_input = .{ .channel = .diff_01, .range = .@"5 V" },
|
||||
.elevation_input = .{ .channel = .diff_23, .range = .@"5 V" },
|
||||
.azimuth_outputs = .{ .increase = .{ .io = 0 }, .decrease = .{ .io = 1 } },
|
||||
.elevation_outputs = .{ .increase = .{ .io = 2 }, .decrease = .{ .io = 3 } },
|
||||
.loop_interval_ns = 50_000_000,
|
||||
|
@ -50,7 +50,7 @@ pub const Labjack = struct {
|
||||
&id,
|
||||
@intFromBool(self.demo),
|
||||
input.channelNumber(),
|
||||
input.gain_index,
|
||||
input.gainIndex(),
|
||||
&over_v,
|
||||
&res.voltage,
|
||||
);
|
||||
@ -93,7 +93,7 @@ pub const Labjack = struct {
|
||||
var gains: [incount]c_long = undefined;
|
||||
for (inputs, &in_channels, &gains) |from, *inc, *gain| {
|
||||
inc.* = from.channelNumber();
|
||||
gain.* = from.gain_index;
|
||||
gain.* = from.gainIndex();
|
||||
}
|
||||
var v_out: [4]f32 = .{0} ** 4;
|
||||
var over_v: c_long = 0;
|
||||
@ -133,11 +133,15 @@ pub const Labjack = struct {
|
||||
|
||||
pub const AnalogInput = struct {
|
||||
channel: AnalogInputChannel,
|
||||
gain_index: GainIndex = 0,
|
||||
range: InputRange = .@"20 V",
|
||||
|
||||
pub fn channelNumber(self: AnalogInput) u4 {
|
||||
return @intFromEnum(self.channel);
|
||||
}
|
||||
|
||||
pub fn gainIndex(self: AnalogInput) GainIndex {
|
||||
return @intFromEnum(self.range);
|
||||
}
|
||||
};
|
||||
|
||||
pub const AnalogReadResult = struct {
|
||||
@ -207,6 +211,17 @@ pub const DigitalOutputChannel = union(enum) {
|
||||
// 7 => G=20 ±1 volt
|
||||
pub const GainIndex = u3;
|
||||
|
||||
pub const InputRange = enum(GainIndex) {
|
||||
@"20 V" = 0,
|
||||
@"10 V" = 1,
|
||||
@"5 V" = 2,
|
||||
@"4 V" = 3,
|
||||
@"2.5 V" = 4,
|
||||
@"2 V" = 5,
|
||||
@"1.25 V" = 6,
|
||||
@"1 V" = 7,
|
||||
};
|
||||
|
||||
pub const PackedOutput = packed struct(u4) {
|
||||
io0: bool,
|
||||
io1: bool,
|
||||
|
Loading…
x
Reference in New Issue
Block a user