Compare commits

..

5 Commits

Author SHA1 Message Date
a9e8819b3e
readme: the Windows situation has been altered
Pray I do not alter it further.
2024-07-15 16:58:33 -07:00
42e15a813a
build: disable libusb logging by default
It is quite verbose and not very useful.
2024-07-15 16:58:33 -07:00
01b66150a3
main: hook up calibration stubs
I guess I will be finishing this later.
2024-07-15 16:58:33 -07:00
5ad5be9c4d
config: make it possible not to leak
Using the GPA is a bit annoying sometimes. The other option would be to
just use page allocator to allocate the config and bypass the GPA.
2024-07-15 16:58:33 -07:00
d0d03b5088
controller: make controller info printout more useful
This has a lot more relevant information now. Anyway, this has been
tested on real hardware, and it appears to work pretty well. I am
considering changing the control loop so that it isn't always
operating on stale feedback (two LabJack calls per loop when actively
controlling pointing). Also the calibration routines need to be
implemented.
2024-07-15 16:58:33 -07:00
3 changed files with 10 additions and 6 deletions

View File

@ -24,7 +24,7 @@ Unfortunately, all platforms have additional steps that must be taken (some easi
#### Windows
This compiles for, and runs on, Windows. However, the Labjack U12 by default gets assigned the Windows USB HID driver, which causes the USB report descriptor control transfer read to get mangled for mystery reasons that presumably made sense to some egghead at Microsoft at some point in time. Fortunately, this can be relatively easily fixed by using a tool like [zadig] to set the Labjack U12 to use the WinUSB driver instead of the HID driver. This is not an endorsement of the above outlined process, but rather an explanation for persons either foolish or desperate.
This compiles for, and runs on, Windows. However, in order for it to work out of the box, it has to link against the (proprietary) Windows LabJack U12 driver instead of the open source libUSB driver. This has two main limitations: the Windows driver is only available for the `x86` and `x86-64` architectures, and it is exclusively distributed as a dynamic library, meaning that `yaes.exe` must be distributed alongside `ljackuw.dll`. When building for Windows targets, the appropriate library file will be copied to the binary installation directory (`zig-out/bin` by default).
#### macOS
@ -33,5 +33,3 @@ This works on macOS, though it has to be run with `sudo`, as access to the USB h
#### Linux
You probably need to install the included udev rules file in order for the USB device to be accessible as a user. This is buried in the source tree as `deps/labjack/exodriver/90-labjack.rules`. These should probably go in `/etc/udev/rules.d` if you are installing them manually and I have properly understood the various Linux folder conventions.
[zadig]: https://zadig.akeo.ie

View File

@ -215,10 +215,10 @@ const Controller = struct {
zero,
positive,
pub fn symbol(self: Sign) u8 {
pub fn symbol(self: Sign) u21 {
return switch (self) {
.negative => '-',
.zero => '=',
.zero => '×',
.positive => '+',
};
}
@ -272,7 +272,8 @@ const Controller = struct {
const angles = lerpAndOffsetAngles(raw);
log.info(
"az: {d:.1}° ({d:.2} V) {d:.1}° => {c}, el: {d:.1}° ({d:.2} V) {d:.1}° => {c}",
// -180.1 is 6 chars. -5.20 is 5 chars
"az: {d: >6.1}° ({d: >5.2} V) Δ {d: >6.1}° => {u}, el: {d: >6.1}° ({d: >5.2} V) Δ {d: >6.1}° => {u}",
.{
angles.azimuth,
raw[0].voltage,

View File

@ -14,6 +14,11 @@ fn printStderr(comptime fmt: []const u8, args: anytype) void {
}
pub fn main() !u8 {
if (comptime builtin.os.tag == .windows) {
// set output to UTF-8 on Windows
_ = std.os.windows.kernel32.SetConsoleOutputCP(65001);
}
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();