From 9d7d11434bca9c67f4add47d8596a939136a07f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E9=BB=91?= Date: Fri, 27 Oct 2023 00:40:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BE=A7=E9=94=AE=E7=81=AF?= =?UTF-8?q?=E5=92=8C=E6=91=87=E6=9D=86=E5=BB=B6=E8=BF=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mu3controller/src/components/comio.hpp | 4 +++- mu3controller/src/components/led_board.cpp | 7 +++++-- mu3controller/src/components/led_board.hpp | 4 +++- mu3controller/src/components/manager.cpp | 6 ++++++ mu3controller/src/components/ongeki_hardware.cpp | 13 ++++++++----- mu3controller/src/components/serial.cpp | 2 +- mu3controller/src/stdinclude.hpp | 3 ++- 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/mu3controller/src/components/comio.hpp b/mu3controller/src/components/comio.hpp index 177b2e8..318e3e5 100644 --- a/mu3controller/src/components/comio.hpp +++ b/mu3controller/src/components/comio.hpp @@ -1,5 +1,6 @@ #include "stdinclude.hpp" +#ifdef LED_BOARD enum io_packet_type_t : uint8_t { PACKET_TYPE_REQUEST, @@ -200,4 +201,5 @@ inline size_t io_build_set_disable(uint8_t* buffer, size_t bufferSize, uint8_t d buffer[0] = disable; return totalLen; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mu3controller/src/components/led_board.cpp b/mu3controller/src/components/led_board.cpp index a5f0817..e05b95c 100644 --- a/mu3controller/src/components/led_board.cpp +++ b/mu3controller/src/components/led_board.cpp @@ -1,6 +1,8 @@ #include "comio.hpp" #include #include "serial.hpp" + +#ifdef LED_BOARD namespace component { namespace led_board @@ -139,7 +141,7 @@ namespace component { int i = 0; - for (i = 0; i < 10; i++) + for (i = 0; i < 18; i++) { if (mode == 1) { @@ -196,4 +198,5 @@ namespace component Serial.end(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mu3controller/src/components/led_board.hpp b/mu3controller/src/components/led_board.hpp index c7b2e69..96f7561 100644 --- a/mu3controller/src/components/led_board.hpp +++ b/mu3controller/src/components/led_board.hpp @@ -1,6 +1,7 @@ #include "stdinclude.hpp" #include "comio.hpp" +#ifdef LED_BOARD namespace component { namespace led_board @@ -11,4 +12,5 @@ namespace component void update(); void end(); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/mu3controller/src/components/manager.cpp b/mu3controller/src/components/manager.cpp index ae95c90..a718d3e 100644 --- a/mu3controller/src/components/manager.cpp +++ b/mu3controller/src/components/manager.cpp @@ -47,7 +47,9 @@ namespace component raw_hid::start(); ongeki_hardware::start(); nfc_setup(); + #ifdef LED_BOARD led_board::start(); + #endif } running = true; } @@ -104,7 +106,9 @@ namespace component { raw_hid::update(); nfc_poll(); + #ifdef LED_BOARD led_board::update(); + #endif } } @@ -120,7 +124,9 @@ namespace component raw_hid::end(); nfc_end(); ongeki_hardware::end(); + #ifdef LED_BOARD led_board::end(); + #endif } } diff --git a/mu3controller/src/components/ongeki_hardware.cpp b/mu3controller/src/components/ongeki_hardware.cpp index 8298fbb..b8d302d 100644 --- a/mu3controller/src/components/ongeki_hardware.cpp +++ b/mu3controller/src/components/ongeki_hardware.cpp @@ -13,10 +13,10 @@ namespace component const int LEVER = PIN_A0; const int LED_PIN = PIN_A1; - ResponsiveAnalogRead analog(LEVER, false); + ResponsiveAnalogRead analog(LEVER, true, 0.1F); uint16_t lever_limit1 = 0; - uint16_t lever_limit2= 1023; + uint16_t lever_limit2 = 1023; uint16_t lever_limit_left; uint16_t lever_limit_right; @@ -32,9 +32,12 @@ namespace component void read_io(raw_hid::output_data_t *data) { - analog.update(); + for (int i = 0; i < 10; i++) + { + analog.update(); + } uint16_t lever = analog.getValue(); - + // 设定摇杆范围 if (manager::key_status[10] && manager::key_status[5]) { @@ -78,7 +81,7 @@ namespace component uint8_t service_pressed = manager::key_status[10] && manager::key_status[1]; uint8_t coin_pressed = manager::key_status[11]; data->opt_buttons = (test_pressed << 0) | (service_pressed << 1) | (coin_pressed << 2); - + // 读取按钮状态 for (auto i = 0; i < 10; i++) { diff --git a/mu3controller/src/components/serial.cpp b/mu3controller/src/components/serial.cpp index c1fa8b2..db03cc8 100644 --- a/mu3controller/src/components/serial.cpp +++ b/mu3controller/src/components/serial.cpp @@ -5,7 +5,7 @@ namespace component { namespace serial { void init() { - Serial.begin(9600); + Serial.begin(115200); } void write(uint8_t byte) { diff --git a/mu3controller/src/stdinclude.hpp b/mu3controller/src/stdinclude.hpp index 67fd913..40888d2 100644 --- a/mu3controller/src/stdinclude.hpp +++ b/mu3controller/src/stdinclude.hpp @@ -7,4 +7,5 @@ #include "components/manager.hpp" #include "eeprom_address.h" -#define HIGH_SIDE \ No newline at end of file +#define HIGH_SIDE +#define LED_BOARD \ No newline at end of file