From 13c87eaf8d59cc0ad860003c61b9ccb81f5c8141 Mon Sep 17 00:00:00 2001 From: MatryoshkaLJY <45618648+MatryoshkaLJY@users.noreply.github.com> Date: Thu, 19 Oct 2023 05:06:10 +0800 Subject: [PATCH] feat: Add bi2a-iidx support for aciotest (#263) --- src/main/aciotest/Module.mk | 1 + src/main/aciotest/bi2a-iidx.c | 109 ++++++++++++++++++++++++++++++++++ src/main/aciotest/bi2a-iidx.h | 14 +++++ src/main/aciotest/main.c | 48 ++++++++++++--- 4 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 src/main/aciotest/bi2a-iidx.c create mode 100644 src/main/aciotest/bi2a-iidx.h diff --git a/src/main/aciotest/Module.mk b/src/main/aciotest/Module.mk index 7ec2634..af04652 100644 --- a/src/main/aciotest/Module.mk +++ b/src/main/aciotest/Module.mk @@ -11,5 +11,6 @@ src_aciotest := \ kfca.c \ panb.c \ rvol.c \ + bi2a-iidx.c \ bi2a-sdvx.c \ main.c \ diff --git a/src/main/aciotest/bi2a-iidx.c b/src/main/aciotest/bi2a-iidx.c new file mode 100644 index 0000000..bd391cf --- /dev/null +++ b/src/main/aciotest/bi2a-iidx.c @@ -0,0 +1,109 @@ +#include "aciotest/bi2a-iidx.h" + +#include "acio/acio.h" + +#include +#include +#include + +#include "bio2drv/bi2a-iidx.h" + +bool aciotest_bi2a_iidx_handler_init( + struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx) +{ + *ctx = malloc(sizeof(uint32_t)); + *((uint32_t *) *ctx) = 0; + + return bio2drv_bi2a_iidx_init(device, node_id); +} + +bool aciotest_bi2a_iidx_handler_update( + struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx) +{ + struct bi2a_iidx_state_in pin; + struct bi2a_iidx_state_out pout; + + memset(&pout, 0, sizeof(pout)); + + if (!bio2drv_bi2a_iidx_poll(device, node_id, &pout, &pin)) { + return false; + } + + + + printf( + "|---------------------------------------|\n" + "| R Y G B Neons B G Y R |\n" + "| %d %d %d %d %d %d %d %d %d |\n" + "|---------------------------------------|\n" + "| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n" + "|---------------------------------------|\n" + "| Effect %d S1 S2 S3 S4 S5 Test %d|\n" + "|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n" + "| VEFX %d Service %d|\n" + "_________________________________________\n" + "| __ __ |\n" + "| / \\ _ / \\ |\n" + "| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n" + "| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n" + "| |\n" + "|---------------------------------------|\n" + "|---------------------------------------|\n", + + pout.SPOTLIGHT2[0].l_state, + pout.SPOTLIGHT2[1].l_state, + pout.SPOTLIGHT2[2].l_state, + pout.SPOTLIGHT2[3].l_state, + pout.NEONLAMP.l_state, + pout.SPOTLIGHT1[0].l_state, + pout.SPOTLIGHT1[1].l_state, + pout.SPOTLIGHT1[2].l_state, + pout.SPOTLIGHT1[3].l_state, + + pout.SEG16[0], + pout.SEG16[1], + pout.SEG16[2], + pout.SEG16[3], + pout.SEG16[4], + pout.SEG16[5], + pout.SEG16[6], + pout.SEG16[7], + pout.SEG16[8], + + pin.PANEL.y_effect, + pin.SYSTEM.v_test, + + pin.PANEL.y_start1, + pin.SLIDER1.s_val, + pin.SLIDER2.s_val, + pin.SLIDER3.s_val, + pin.SLIDER4.s_val, + pin.SLIDER5.s_val, + pin.PANEL.y_start2, + + pin.PANEL.y_vefx, + pin.SYSTEM.v_service, + + pin.TURNTABLE1, + pin.P1SW2.b_val, + pin.P1SW4.b_val, + pin.P1SW6.b_val, + pin.SYSTEM.v_coin, + pin.P2SW2.b_val, + pin.P2SW4.b_val, + pin.P2SW6.b_val, + pin.TURNTABLE2, + + pin.P1SW1.b_val, + pin.P1SW3.b_val, + pin.P1SW5.b_val, + pin.P1SW7.b_val, + pin.P2SW1.b_val, + pin.P2SW3.b_val, + pin.P2SW5.b_val, + pin.P2SW7.b_val + + ); + + return true; +} diff --git a/src/main/aciotest/bi2a-iidx.h b/src/main/aciotest/bi2a-iidx.h new file mode 100644 index 0000000..8b1e660 --- /dev/null +++ b/src/main/aciotest/bi2a-iidx.h @@ -0,0 +1,14 @@ +#ifndef ACIOTEST_BI2A_IIDX_H +#define ACIOTEST_BI2A_IIDX_H + +#include +#include + +#include "aciodrv/device.h" + +bool aciotest_bi2a_iidx_handler_init( + struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx); +bool aciotest_bi2a_iidx_handler_update( + struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx); + +#endif diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c index 5f1b8ad..a0da139 100644 --- a/src/main/aciotest/main.c +++ b/src/main/aciotest/main.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -7,6 +8,7 @@ #include "aciodrv/device.h" #include "aciotest/bi2a-sdvx.h" +#include "aciotest/bi2a-iidx.h" #include "aciotest/handler.h" #include "aciotest/icca.h" #include "aciotest/kfca.h" @@ -16,7 +18,7 @@ #include "util/log.h" static uint8_t aciotest_cnt = 0; -static uint8_t bi2a_mode = 0; +static uint8_t bi2a_mode = 255; /** * Enumerate supported ACIO nodes based on their product id. @@ -53,14 +55,30 @@ static bool aciotest_assign_handler( } if (product_type == AC_IO_NODE_TYPE_BI2A) { - if (bi2a_mode == 0) { + if (bi2a_mode == 255) { + printf( + "Unknown BI2A mode specified, please check your command.\n" + "Using bi2a-sdvx mode as default, press ENTER to continue\n" + ); + bi2a_mode = 0; + getchar(); + } + + switch (bi2a_mode) + { + case 0: handler->init = aciotest_bi2a_sdvx_handler_init; handler->update = aciotest_bi2a_sdvx_handler_update; + break; + case 1: + handler->init = aciotest_bi2a_iidx_handler_init; + handler->update = aciotest_bi2a_iidx_handler_update; + break; - return true; - } else { - printf("Unknown BI2A device specified"); + default: + break; } + return true; } return false; @@ -76,13 +94,26 @@ int main(int argc, char **argv) "aciotest, build "__DATE__ " " __TIME__ "\n" - "Usage: %s \n" - "Example for two slotted readers: %s COM1 57600\n", + "Usage: %s \n" + "Example:\n" + "\"%s COM1 57600\" for generic acio device\n" + "\"%s COM1 57600 bi2a-iidx\" for the iidx BI2A mode\n" + "\"%s COM1 57600 bi2a-sdvx\" for the sdvx BI2A mode\n", + argv[0], + argv[0], argv[0], argv[0]); return -1; } + if (argc == 4) { + if(!strcmp(argv[3],"bi2a-iidx")) { + bi2a_mode = 1; + } else if(!strcmp(argv[3],"bi2a-sdvx")) { + bi2a_mode = 0; + } + } + log_to_writer(log_writer_stdout, NULL); struct aciodrv_device_ctx *device = @@ -93,7 +124,8 @@ int main(int argc, char **argv) return -1; } - printf("Opening acio device successful\n"); + printf("Opening acio device successful, press ENTER to continue\n"); + getchar(); uint8_t node_count = aciodrv_device_get_node_count(device); printf("Enumerated %d nodes\n", node_count);