forked from Scribbler/chuniio-tasoller
Add test program
This commit is contained in:
parent
72545139b5
commit
93c464518e
Binary file not shown.
|
@ -9,7 +9,8 @@ pub fn build(b: *std.build.Builder) void {
|
|||
lib.setTarget(target);
|
||||
lib.install();
|
||||
|
||||
// const exe = b.addExecutable("tasoller_test", "src/main.zig");
|
||||
// exe.setTarget(target);
|
||||
// exe.install();
|
||||
const exe = b.addExecutable("tasoller_test", "src/main.zig");
|
||||
lib.setBuildMode(b.standardReleaseOptions());
|
||||
exe.setTarget(target);
|
||||
exe.install();
|
||||
}
|
||||
|
|
60
src/main.zig
60
src/main.zig
|
@ -40,6 +40,52 @@ const Config = struct {
|
|||
coin_key: i32,
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
var ground = usb_out[4*3 .. 29*3];
|
||||
var left = usb_out[32*3 .. 56*3];
|
||||
var right = usb_out[56*3 .. 80*3];
|
||||
var i: u32 = 0;
|
||||
while(i < 32) : (i += 1) {
|
||||
if(i < ground.len/3) {
|
||||
ground[i*3 + 1] = 0x13;
|
||||
ground[i*3 + 0] = 0x7a;
|
||||
ground[i*3 + 2] = 0x5f;
|
||||
if(i % 2 == 0) {
|
||||
ground[i*3 + 1] = 0x66;
|
||||
ground[i*3 + 0] = 0xee;
|
||||
ground[i*3 + 2] = 0xab;
|
||||
}
|
||||
if(i % 4 == 0) {
|
||||
ground[i*3 + 1] = 0xe1;
|
||||
ground[i*3 + 0] = 0x28;
|
||||
ground[i*3 + 2] = 0x85;
|
||||
}
|
||||
}
|
||||
if(i < left.len/3) {
|
||||
left[i*3 + 1] = 0x13;
|
||||
left[i*3 + 0] = 0x7a;
|
||||
left[i*3 + 2] = 0x5f;
|
||||
}
|
||||
if(i < right.len/3) {
|
||||
right[i*3 + 1] = 0x13;
|
||||
right[i*3 + 0] = 0x7a;
|
||||
right[i*3 + 2] = 0x5f;
|
||||
}
|
||||
}
|
||||
try tasoller_init();
|
||||
while(true) {
|
||||
if(WinUsb_WritePipe(tasoller, 0x03, @ptrCast(*u8, &usb_out), usb_out.len, &i, null) == 0) {
|
||||
std.log.warn("[chuniio] WinUsb_WritePipe: {any}", .{GetLastError()});
|
||||
}
|
||||
if(WinUsb_ReadPipe(tasoller, 0x84, @ptrCast(*u8, &usb_in), usb_in.len, &i, null) == 0) {
|
||||
std.log.warn("[chuniio] WinUsb_ReadPipe: {any}", .{GetLastError()});
|
||||
}
|
||||
std.time.sleep(100_000_000);
|
||||
}
|
||||
}
|
||||
|
||||
// MAIN DRIVER ======================================================================================================
|
||||
|
||||
var cfg: ?Config = null;
|
||||
var thread_op = std.Thread.Mutex{};
|
||||
var slider_active = false;
|
||||
|
@ -128,11 +174,13 @@ fn input_thread_proc() void {
|
|||
fn slider_thread_proc(callback: chuni_io_slider_callback_t) void {
|
||||
var pressure = std.mem.zeroes([32]u8);
|
||||
while(slider_active) {
|
||||
// Tasoller order: top->bottom, left->right
|
||||
// Chunithm order: top->bottom, right->left
|
||||
for(usb_in[4..]) |val, i| pressure[if(i%2 == 0) 30-i else 32-i] = val;
|
||||
for(usb_in[4..]) |byte, i| {
|
||||
// Tasoller order: top->bottom, left->right
|
||||
// Chunithm order: top->bottom, right->left
|
||||
pressure[if(i%2 == 0) 30-i else 32-i] = byte;
|
||||
}
|
||||
callback.?(&pressure);
|
||||
std.time.sleep(1_000_000); // 1ms
|
||||
std.time.sleep(1_000_000); // 1ms, limit reporting to 1kHz max
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,8 +265,4 @@ export fn chuni_io_slider_set_leds(rgb: ?[*]u8) void {
|
|||
if(WinUsb_WritePipe(tasoller, 0x03, @ptrCast(*u8, &usb_out), usb_out.len, &n, null) == 0) {
|
||||
std.log.warn("[chuniio] WinUsb_WritePipe: {any}", .{GetLastError()});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
try tasoller_init();
|
||||
}
|
Loading…
Reference in New Issue