mirror of
https://github.com/whowechina/chu_pico.git
synced 2025-02-17 18:49:18 +01:00
Optimization on stability
This commit is contained in:
parent
2f31842136
commit
0482e01fbe
Binary file not shown.
@ -21,9 +21,9 @@
|
|||||||
static const uint8_t TOF_LIST[] = TOF_MUX_LIST;
|
static const uint8_t TOF_LIST[] = TOF_MUX_LIST;
|
||||||
static uint16_t distances[sizeof(TOF_LIST)];
|
static uint16_t distances[sizeof(TOF_LIST)];
|
||||||
|
|
||||||
const int offset_a = 800;
|
const int offset_a = 600;
|
||||||
const int offset_b = 1000;
|
const int offset_b = 800;
|
||||||
const int pitch = 200;
|
const int pitch = 160;
|
||||||
|
|
||||||
void air_init()
|
void air_init()
|
||||||
{
|
{
|
||||||
@ -34,10 +34,8 @@ void air_init()
|
|||||||
gpio_pull_up(TOF_SCL);
|
gpio_pull_up(TOF_SCL);
|
||||||
|
|
||||||
i2c_hub_init();
|
i2c_hub_init();
|
||||||
sleep_us(10);
|
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(TOF_LIST); i++) {
|
for (int i = 0; i < sizeof(TOF_LIST); i++) {
|
||||||
sleep_us(10);
|
|
||||||
i2c_select(TOF_I2C, 1 << TOF_LIST[i]);
|
i2c_select(TOF_I2C, 1 << TOF_LIST[i]);
|
||||||
gp2y0e_write(TOF_I2C, 0xa8, 0); // Accumulation 0:1, 1:5, 2:30, 3:10
|
gp2y0e_write(TOF_I2C, 0xa8, 0); // Accumulation 0:1, 1:5, 2:30, 3:10
|
||||||
gp2y0e_write(TOF_I2C, 0x3f, 0x30); // Filter 0x00:7, 0x10:5, 0x20:9, 0x30:1
|
gp2y0e_write(TOF_I2C, 0x3f, 0x30); // Filter 0x00:7, 0x10:5, 0x20:9, 0x30:1
|
||||||
|
@ -21,9 +21,7 @@ static inline void i2c_hub_init()
|
|||||||
|
|
||||||
static inline void i2c_select(i2c_inst_t *i2c_port, uint8_t chn)
|
static inline void i2c_select(i2c_inst_t *i2c_port, uint8_t chn)
|
||||||
{
|
{
|
||||||
sleep_us(10);
|
|
||||||
i2c_write_blocking_until(i2c_port, I2C_HUB_ADDR, &chn, 1, false, time_us_64() + 1000);
|
i2c_write_blocking_until(i2c_port, I2C_HUB_ADDR, &chn, 1, false, time_us_64() + 1000);
|
||||||
sleep_us(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -186,19 +186,19 @@ static void core1_loop()
|
|||||||
static void core0_loop()
|
static void core0_loop()
|
||||||
{
|
{
|
||||||
while(1) {
|
while(1) {
|
||||||
tud_task();
|
run_lights();
|
||||||
|
fps_count(0);
|
||||||
|
print_fps();
|
||||||
|
|
||||||
|
slider_update_baseline();
|
||||||
|
|
||||||
slider_update();
|
slider_update();
|
||||||
air_update();
|
air_update();
|
||||||
|
|
||||||
gen_joy_report();
|
gen_joy_report();
|
||||||
gen_nkro_report();
|
gen_nkro_report();
|
||||||
report_usb_hid();
|
report_usb_hid();
|
||||||
|
tud_task();
|
||||||
run_lights();
|
|
||||||
|
|
||||||
slider_update_baseline();
|
|
||||||
fps_count(0);
|
|
||||||
print_fps();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "mpr121.h"
|
#include "mpr121.h"
|
||||||
|
|
||||||
#define TOUCH_THRESHOLD 16
|
#define TOUCH_THRESHOLD 17
|
||||||
#define RELEASE_THRESHOLD 8
|
#define RELEASE_THRESHOLD 8
|
||||||
|
|
||||||
#define MPR121_ADDR 0x5A
|
#define MPR121_ADDR 0x5A
|
||||||
@ -68,11 +68,11 @@ void slider_init()
|
|||||||
gpio_set_function(MPR121_SCL, GPIO_FUNC_I2C);
|
gpio_set_function(MPR121_SCL, GPIO_FUNC_I2C);
|
||||||
gpio_pull_up(MPR121_SDA);
|
gpio_pull_up(MPR121_SDA);
|
||||||
gpio_pull_up(MPR121_SCL);
|
gpio_pull_up(MPR121_SCL);
|
||||||
|
|
||||||
for (int m = 0; m < 3; m++) {
|
for (int m = 0; m < 3; m++) {
|
||||||
mpr121_init(MPR121_I2C, MPR121_ADDR + m, mpr121 + m);
|
mpr121_init(MPR121_I2C, MPR121_ADDR + m, mpr121 + m);
|
||||||
}
|
}
|
||||||
|
|
||||||
init_baseline();
|
init_baseline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user