feat: 蜂鸣器和旋钮适配
This commit is contained in:
81
app/main.c
81
app/main.c
@@ -33,66 +33,41 @@
|
||||
#include "by_imu.h"
|
||||
int main(void)
|
||||
{
|
||||
|
||||
int16_t i = 0;
|
||||
clock_init(SYSTEM_CLOCK_120M);
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
mt9v03x_init();
|
||||
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
by_gpio_init();
|
||||
by_exit_init();
|
||||
by_pwm_init();
|
||||
jj_bt_init();
|
||||
|
||||
by_rb_init();
|
||||
by_buzzer_init();
|
||||
while (imu660ra_init())
|
||||
;
|
||||
jj_param_eeprom_init();
|
||||
by_pwm_init();
|
||||
|
||||
Page_Init();
|
||||
sport_pid_init();
|
||||
pit_ms_init(TIM6_PIT, 2);
|
||||
pit_ms_init(TIM1_PIT, 2);
|
||||
// gyroOffset_init();
|
||||
|
||||
while (1) {
|
||||
Page_Run();
|
||||
jj_bt_run();
|
||||
|
||||
// switch (by_get_rb_status()) {
|
||||
// case 3:
|
||||
// i++;
|
||||
// break;
|
||||
// case 4:
|
||||
// i--;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// by_pwm_update_duty(500 + i * 50, 500 + i * 50);
|
||||
// by_pwm_power_duty(500 + i * 50, 500 + i * 50, 500 + i * 50, 500 + i * 50);
|
||||
// // ips200_show_uint(0, 0, 1000, 4);
|
||||
// ips200_draw_rect(0, 0, 50, 50, RGB565_YELLOW);
|
||||
// system_delay_ms(100);
|
||||
// ips200_draw_rect(0, 0, 50, 50, RGB565_BLACK);
|
||||
// system_delay_ms(10);
|
||||
|
||||
queue_pop_read();
|
||||
bt_printf("hello:%f,%f\n",out_M,out_yaw);
|
||||
if (mt9v03x_finish_flag) {
|
||||
// 该操作消耗大概 1970 个 tick,折合约 110us
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
//adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 17);
|
||||
//ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
mt9v03x_finish_flag = 0;
|
||||
|
||||
state_type = COMMON_STATE;
|
||||
img_processing();
|
||||
get_corners();
|
||||
aim_distance = COMMON_AIM;
|
||||
tracking();
|
||||
ElementJudge();
|
||||
ElementRun();
|
||||
MidLineTrack();
|
||||
|
||||
}
|
||||
Page_Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int height, int block, uint8_t clip_value){
|
||||
int half_block = block / 2;
|
||||
for(int y=half_block; y<height-half_block; y++){
|
||||
for(int x=half_block; x<width-half_block; x++){
|
||||
// 计算局部阈值
|
||||
int thres = 0;
|
||||
for(int dy=-half_block; dy<=half_block; dy++){
|
||||
for(int dx=-half_block; dx<=half_block; dx++){
|
||||
thres += img_data[(x+dx)+(y+dy)*width];
|
||||
}
|
||||
}
|
||||
thres = thres / (block * block) - clip_value;
|
||||
// 进行二值化
|
||||
output_data[x+y*width] = img_data[x+y*width]>thres ? 255 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user