Skip to content

Commit

Permalink
优化侧键灯和摇杆延迟
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanheiii committed May 20, 2024
1 parent 8c51ef8 commit 9d7d114
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
4 changes: 3 additions & 1 deletion mu3controller/src/components/comio.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "stdinclude.hpp"

#ifdef LED_BOARD
enum io_packet_type_t : uint8_t
{
PACKET_TYPE_REQUEST,
Expand Down Expand Up @@ -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;
}
}
#endif
7 changes: 5 additions & 2 deletions mu3controller/src/components/led_board.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "comio.hpp"
#include <FastLED.h>
#include "serial.hpp"

#ifdef LED_BOARD
namespace component
{
namespace led_board
Expand Down Expand Up @@ -139,7 +141,7 @@ namespace component
{
int i = 0;

for (i = 0; i < 10; i++)
for (i = 0; i < 18; i++)
{
if (mode == 1)
{
Expand Down Expand Up @@ -196,4 +198,5 @@ namespace component
Serial.end();
}
}
}
}
#endif
4 changes: 3 additions & 1 deletion mu3controller/src/components/led_board.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "stdinclude.hpp"
#include "comio.hpp"

#ifdef LED_BOARD
namespace component
{
namespace led_board
Expand All @@ -11,4 +12,5 @@ namespace component
void update();
void end();
}
}
}
#endif
6 changes: 6 additions & 0 deletions mu3controller/src/components/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ namespace component
raw_hid::start();
ongeki_hardware::start();
nfc_setup();
#ifdef LED_BOARD
led_board::start();
#endif
}
running = true;
}
Expand Down Expand Up @@ -104,7 +106,9 @@ namespace component
{
raw_hid::update();
nfc_poll();
#ifdef LED_BOARD
led_board::update();
#endif
}
}

Expand All @@ -120,7 +124,9 @@ namespace component
raw_hid::end();
nfc_end();
ongeki_hardware::end();
#ifdef LED_BOARD
led_board::end();
#endif
}
}

Expand Down
13 changes: 8 additions & 5 deletions mu3controller/src/components/ongeki_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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])
{
Expand Down Expand Up @@ -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++)
{
Expand Down
2 changes: 1 addition & 1 deletion mu3controller/src/components/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace component {
namespace serial {
void init() {
Serial.begin(9600);
Serial.begin(115200);
}

void write(uint8_t byte) {
Expand Down
3 changes: 2 additions & 1 deletion mu3controller/src/stdinclude.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
#include "components/manager.hpp"
#include "eeprom_address.h"

#define HIGH_SIDE
#define HIGH_SIDE
#define LED_BOARD

0 comments on commit 9d7d114

Please sign in to comment.