Skip to content

Commit b0c659c

Browse files
author
chenzhjie
committed
style: code formatting
1 parent 1ccda00 commit b0c659c

File tree

4 files changed

+0
-637
lines changed

4 files changed

+0
-637
lines changed

code/ROLLER485/Core/Src/main.c

Lines changed: 0 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -359,128 +359,6 @@ void Slave_Complete_Callback(uint8_t *rx_data, uint16_t len)
359359
}
360360
}
361361
}
362-
// if (rx_data[0] == 0) {
363-
// motor_output = rx_data[1];
364-
// if (motor_output) {
365-
// if (!over_vol_flag && !err_stalled_flag) {
366-
// motor_disable_flag = 0;
367-
// if (motor_mode == MODE_DIAL) {
368-
// init_smart_knob();
369-
// }
370-
// MotorDriverSetMode(MDRV_MODE_RUN);
371-
// }
372-
// }
373-
// else {
374-
// motor_disable_flag = 1;
375-
// MotorDriverSetMode(MDRV_MODE_OFF);
376-
// }
377-
// }
378-
// else if (rx_data[0] == 1) {
379-
// if (rx_data[1] && rx_data[1] < MODE_MAX && !err_stalled_flag) {
380-
// motor_mode = rx_data[1];
381-
// if (last_motor_mode != motor_mode) {
382-
// if (motor_mode < MODE_DIAL) {
383-
// MotorDriverSetCurrentReal(0);
384-
// init_pid();
385-
// pid_ctrl_speed_t.iTerm = 0;
386-
// pid_ctrl_pos_t.iTerm = 0;
387-
// }
388-
// else if (motor_mode == MODE_DIAL) {
389-
// init_smart_knob();
390-
// }
391-
// else if (motor_mode == MODE_POS_SPEED) {
392-
// MotorDriverSetCurrentReal(0);
393-
// PIDTuningsSet(&pid_ctrl_speed_t, speed_pid_plus_float[0], speed_pid_plus_float[1], speed_pid_plus_float[2]);
394-
// PIDTuningsSet(&pid_ctrl_pos_t, pos_pid_plus_float[0], pos_pid_plus_float[1], pos_pid_plus_float[2]);
395-
// pid_ctrl_speed_t.iTerm = 0;
396-
// pid_ctrl_pos_t.iTerm = 0;
397-
// }
398-
// last_motor_mode = motor_mode;
399-
// }
400-
// }
401-
// }
402-
// else if (rx_data[0] == 0x02) {
403-
// if (rx_data[1])
404-
// over_vol_protect_mode = 1;
405-
// else
406-
// over_vol_protect_mode = 0;
407-
// }
408-
// else if (rx_data[0] == 0x03) {
409-
// if (rx_data[1]) {
410-
// if (over_vol_flag)
411-
// sys_status = SYS_STANDBY;
412-
// over_vol_flag = 0;
413-
// error_code &= ~ERR_OVER_VOLTAGE;
414-
// }
415-
// }
416-
// else if (rx_data[0] == 0x0B) {
417-
// if (rx_data[1]) {
418-
// speed_err_recover_try_counter = 0;
419-
// pos_err_recover_try_counter = 0;
420-
// if (motor_mode == MODE_SPEED_ERR_PROTECT) {
421-
// sys_status = SYS_STANDBY;
422-
// motor_mode = MODE_SPEED;
423-
// }
424-
// else if (motor_mode == MODE_POS_ERR_PROTECT) {
425-
// sys_status = SYS_STANDBY;
426-
// motor_mode = MODE_POS;
427-
// }
428-
// error_code &= ~ERR_STALLED;
429-
// speed_err_count_flag = 0;
430-
// speed_err_auto_flag = 0;
431-
// pos_err_count_flag = 0;
432-
// pos_err_auto_flag = 0;
433-
// err_stalled_flag = 0;
434-
// }
435-
// }
436-
// else if (rx_data[0] >= 0x04 && rx_data[0] <= 0x0A) {
437-
// for(int i = 0; i < len - 1; i++) {
438-
// rx_buf[rx_data[0]-0x04+i] = rx_data[1+i];
439-
// rx_mark[rx_data[0]-0x04+i] = 1;
440-
// }
441-
442-
// if (rx_mark[0]) {
443-
// speed_err_value &= ~0x00ff;
444-
// speed_err_value |= rx_buf[0];
445-
// }
446-
// if (rx_mark[1]) {
447-
// speed_err_value &= ~0xff00;
448-
// speed_err_value |= (rx_buf[1] << 8);
449-
// }
450-
// if (rx_mark[2]) {
451-
// speed_err_timeout = rx_buf[2];
452-
// }
453-
// if (rx_mark[3]) {
454-
// pos_err_value &= ~0x00ff;
455-
// pos_err_value |= rx_buf[3];
456-
// }
457-
// if (rx_mark[4]) {
458-
// pos_err_value &= ~0xff00;
459-
// pos_err_value |= (rx_buf[4] << 8);
460-
// }
461-
// if (rx_mark[5]) {
462-
// pos_err_timeout = rx_buf[5];
463-
// }
464-
// if (rx_mark[6]) {
465-
// err_recover_try_max = rx_buf[6];
466-
// }
467-
// }
468-
// else if (rx_data[0] == 0x0E) {
469-
// if (rx_data[1]) {
470-
// mode_switch_flag = 1;
471-
// }
472-
// else {
473-
// mode_switch_flag = 0;
474-
// }
475-
// }
476-
// else if (rx_data[0] == 0x0F) {
477-
// if (rx_data[1]) {
478-
// motor_stall_protection_flag = 1;
479-
// }
480-
// else {
481-
// motor_stall_protection_flag = 0;
482-
// }
483-
// }
484362
else if (rx_data[0] == 0xF1) {
485363
if (rx_data[1]) {
486364
if (!over_vol_flag)
@@ -518,7 +396,6 @@ void Slave_Complete_Callback(uint8_t *rx_data, uint16_t len)
518396
speed_point |= (rx_buf[3] << 24);
519397
}
520398

521-
// pid_ctrl_speed_t.iTerm = 0;
522399
if (speed_point > MY_INT32_MAX)
523400
speed_point = MY_INT32_MAX;
524401
else if (speed_point < MY_INT32_MIN)
@@ -922,35 +799,12 @@ void Slave_Complete_Callback(uint8_t *rx_data, uint16_t len)
922799
tx_buf[0x0F] = motor_stall_protection_flag;
923800
i2c1_set_send_data((uint8_t *)&tx_buf[rx_data[0]], 0x0F-rx_data[0]+1);
924801
}
925-
// else if (rx_data[0] == 0) {
926-
// motor_output ? (motor_output = 1) : (motor_output = 0);
927-
// i2c1_set_send_data(&motor_output, 1);
928-
// }
929-
// else if (rx_data[0] == 1) {
930-
// uint8_t motor_mode_temp = motor_mode;
931-
// if (motor_mode == MODE_SPEED_ERR_PROTECT) {
932-
// motor_mode_temp = MODE_SPEED;
933-
// }
934-
// else if (motor_mode == MODE_POS_ERR_PROTECT) {
935-
// motor_mode_temp = MODE_POS;
936-
// }
937-
// i2c1_set_send_data(&motor_mode_temp, 1);
938-
// }
939-
// else if (rx_data[0] == 0x02) {
940-
// i2c1_set_send_data(&over_vol_protect_mode, 1);
941-
// }
942802
else if (rx_data[0] >= 0x10 && rx_data[0] <= 0x12) {
943803
tx_buf[0] = motor_id;
944804
tx_buf[1] = bps_index;
945805
tx_buf[2] = brightness_index;
946806
i2c1_set_send_data((uint8_t *)&tx_buf[rx_data[0]-0x10], 0x12-rx_data[0]+1);
947807
}
948-
// else if (rx_data[0] == 0x0C) {
949-
// i2c1_set_send_data(&sys_status, 1);
950-
// }
951-
// else if (rx_data[0] == 0x0D) {
952-
// i2c1_set_send_data(&error_code, 1);
953-
// }
954808
else if ((rx_data[0] >= 0x30) && (rx_data[0] <= 0x3F))
955809
{
956810
int32_t vol_int32 = (int32_t)vol_lpf;
@@ -961,16 +815,6 @@ void Slave_Complete_Callback(uint8_t *rx_data, uint16_t len)
961815
memcpy(&tx_buf[12], (uint8_t *)&current_position, 4);
962816
i2c1_set_send_data((uint8_t *)&tx_buf[rx_data[0]-0x30], 0x3F-rx_data[0]+1);
963817
}
964-
// else if (rx_data[0] >= 0x34 && rx_data[0] <= 0x37) {
965-
// int32_t vol_int32 = (int32_t)vol_lpf;
966-
// i2c1_set_send_data((uint8_t *)&vol_int32, 4);
967-
// }
968-
// else if (rx_data[0] >= 0x38 && rx_data[0] <= 0x3B) {
969-
// i2c1_set_send_data((uint8_t *)&internal_temp, 4);
970-
// }
971-
// else if (rx_data[0] >= 0x3C && rx_data[0] <= 0x3F) {
972-
// i2c1_set_send_data((uint8_t *)&current_position, 4);
973-
// }
974818
else if (rx_data[0] >= 0x40 && rx_data[0] <= 0x43) {
975819
i2c1_set_send_data((uint8_t *)&speed_point, 4);
976820
}
@@ -1045,20 +889,6 @@ void Slave_Complete_Callback(uint8_t *rx_data, uint16_t len)
1045889
else if (rx_data[0] == 0xFF) {
1046890
i2c1_set_send_data((uint8_t *)&i2c_address[0], 1);
1047891
}
1048-
// else if (rx_data[0] >= 0x04 && rx_data[0] <= 0x0A) {
1049-
// memcpy(tx_buf, (uint8_t *)&speed_err_value, 2);
1050-
// memcpy(tx_buf+2, (uint8_t *)&speed_err_timeout, 1);
1051-
// memcpy(tx_buf+3, (uint8_t *)&pos_err_value, 2);
1052-
// memcpy(tx_buf+5, (uint8_t *)&pos_err_timeout, 1);
1053-
// memcpy(tx_buf+6, (uint8_t *)&err_recover_try_max, 1);
1054-
// i2c1_set_send_data((uint8_t *)&tx_buf[rx_data[0]-0x04], 0x0A-rx_data[0]+1);
1055-
// }
1056-
// else if (rx_data[0] == 0x0E) {
1057-
// i2c1_set_send_data((uint8_t *)&mode_switch_flag, 1);
1058-
// }
1059-
// else if (rx_data[0] == 0x0F) {
1060-
// i2c1_set_send_data((uint8_t *)&motor_stall_protection_flag, 1);
1061-
// }
1062892
}
1063893
}
1064894
/* USER CODE END 0 */

code/ROLLER485/MyFile/src/mysys.c

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -522,32 +522,6 @@ void InitMysys(void)
522522

523523
EncoderInit();
524524
HAL_Delay(300);
525-
526-
// //wait for encoder calibration 等待编码器校准,此处临时使用阻塞式,实际使用不要阻塞
527-
// while(IsMotorDriverEncCalBusy())
528-
// {
529-
// ;
530-
// }
531-
532-
533-
534-
//start motor driver 配置驱动为正常输出模式
535-
// MotorDriverSetMode(MDRV_MODE_RUN);
536-
537-
//以下为实际使用:
538-
//正常运行时调用方式二选一均可
539-
540-
541-
//配置电机电流目标值,此为ADC值,范围-1500 ~ +1500,对应最大相电流约为+-1.2A(非母线电流,即电源输入电流)
542-
//数据类型int32_t
543-
544-
//MotorDriverSetCurrentAdc(200);
545-
546-
547-
//配置电机电流目标值,此为实际值,范围-1200.0 ~ +1200.0, 对应最大相电流约为+-1.2A(非母线电流,即电源输入电流)
548-
//数据类型float32_t
549-
550-
// MotorDriverSetCurrentReal(1000.0f);
551525
init_flash_data();
552526
u8g2Init(&u8g2);
553527
if (!HAL_GPIO_ReadPin(SYS_SW_GPIO_Port, SYS_SW_Pin)) {
@@ -571,12 +545,6 @@ void InitMysys(void)
571545
}
572546

573547
u8g2_disp_init();
574-
// pid_ctrl_speed_t.setpoint = 50;
575-
// pid_ctrl_pos_t.setpoint = 0.0f;
576-
// u8g2_disp_speed();
577-
// u8g2_disp_pos();
578-
// u8g2_disp_current();
579-
// u8g2_disp_all();
580548
}
581549

582550

@@ -586,14 +554,6 @@ void LoopMysys(void)
586554
{
587555
while(1)
588556
{
589-
// if (over_vol_protect_auto_flag && over_vol_protect_mode) {
590-
// if (HAL_GetTick() - over_vol_protect_auto_counter > 2000) {
591-
// over_vol_protect_auto_flag = 0;
592-
// over_vol_flag = 0;
593-
// error_code &= ~ERR_OVER_VOLTAGE;
594-
// sys_status = SYS_STANDBY;
595-
// }
596-
// }
597557
i2c_timeout_counter = 0;
598558
if (i2c_stop_timeout_flag) {
599559
if (i2c_stop_timeout_delay < HAL_GetTick()) {
@@ -708,32 +668,6 @@ void LoopMysys(void)
708668
break;
709669
}
710670
ws2812_flash();
711-
// u8g2_disp_update_status();
712-
// u8g2_disp_update_vin(vol_input);
713-
//voltage
714-
// OLED_ShowNum(30,16, vol_input/100,2,8,1);
715-
// OLED_ShowNum(48,16, vol_input/10%10,1,8,1);
716-
717-
// //current
718-
// OLED_ShowNum(30,24, ph_current_max/1000,1,8,1);
719-
// OLED_ShowNum(42,24, ph_current_max/10%100,2,8,1);
720-
721-
// //angle
722-
// OLED_ShowNum(30,32,MotorDriverGetMechanicalAngle()/10,3,8,1);
723-
// OLED_ShowNum(53,32,MotorDriverGetMechanicalAngle()%10,1,8,1);
724-
// OLED_Refresh();
725-
726-
// if (angle_error > 0.2f) {
727-
// neopixel_set_color(0, ((0x10 << 16) | (0 << 8) | 0));
728-
// neopixel_set_color(1, ((0x10 << 16) | (0 << 8) | 0));
729-
730-
// ws2812_show();
731-
// } else {
732-
// neopixel_set_color(0, ((0 << 16) | (0x10 << 8) | 0));
733-
// neopixel_set_color(1, ((0 << 16) | (0x10 << 8) | 0));
734-
735-
// ws2812_show();
736-
// }
737671

738672
if (act_delay < HAL_GetTick()) {
739673
running_index++;
@@ -747,14 +681,6 @@ void LoopMysys(void)
747681
status_flag = 1;
748682
// OLED_ShowString(0,0," M5 BLDC *",8,1);
749683
}
750-
// if (act_flag == 1) {
751-
// angle_target += 360.0f;
752-
// } else if (act_flag == 3) {
753-
// angle_target = 180.0f;
754-
// }
755-
// if (angle_target > 540.0f) {
756-
// angle_target = 180.0f;
757-
// }
758684
act_delay = HAL_GetTick() + 1000;
759685
}
760686
}
@@ -789,15 +715,6 @@ void Loop_Control(void)
789715

790716
mechanical_rad = mechanical_angle * PI / 180.0f;
791717

792-
// angle_error = angle_target - mechanical_angle ;
793-
794-
// uq_output = angle_error * angle_kp;
795-
796-
// if(uq_output > uq_limit) uq_output = uq_limit;
797-
// if(uq_output < -uq_limit) uq_output = -uq_limit;
798-
799-
// MotorDriverSetCurrentReal(uq_output);
800-
801718
//lpfdata += (1.0 / (1.0 + 1.0/(2.0f * 3.14f *T*fc)))*(rawdata - lpfdata );
802719
//lpfdata : 滤波后的数据。
803720
//rawdata : 滤波前的原始数据。
@@ -900,14 +817,6 @@ void Rpm_Count_100us(void)
900817
if (speed_encoder_value_t.encoder_value != speed_encoder_value_t.last_encoder_value) {
901818
diff_encoder_value = speed_encoder_value_t.encoder_value - speed_encoder_value_t.last_encoder_value;
902819
diff_encoder_value_lpf += (1.0f / (1.0f + 1.0f/(2.0f * 3.14f *0.00017857142857f*2.0f)))*(diff_encoder_value - diff_encoder_value_lpf );
903-
// if (avg_filter_level != 0) {
904-
// speed_record[record_index] = diff_encoder_value_lpf;
905-
// record_index++;
906-
// if (record_index >= avg_filter_level) {
907-
// record_index = 0;
908-
// }
909-
// diff_encoder_value_lpf = avg_filter(speed_record, avg_filter_level);
910-
// }
911820
motor_rpm = diff_encoder_value_lpf / 16383.0f * 336000;
912821
speed_encoder_value_t.last_encoder_value = speed_encoder_value_t.encoder_value;
913822
}

code/ROLLER485/MyFile/src/oled_u8g2.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,6 @@
5252

5353
u8g2_t u8g2;
5454

55-
void OLED_U8G2_Init(void)
56-
{
57-
// GPIO_InitTypeDef GPIO_InitStruct = {0};
58-
59-
// /* GPIOB/GPIOC clock enable */
60-
// __HAL_RCC_GPIOB_CLK_ENABLE();
61-
// __HAL_RCC_GPIOC_CLK_ENABLE();
62-
63-
// /*Configure GPIO pin Output Level */
64-
// HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET);
65-
// /*Configure GPIO pin Output Level */
66-
// HAL_GPIO_WritePin(GPIOB, LED_Pin|OLED_RST_Pin|OLED_SDA_Pin|OLED_SCL_Pin, GPIO_PIN_RESET);
67-
// /*Configure GPIO pin : PtPin */
68-
// GPIO_InitStruct.Pin = OLED_DC_Pin;
69-
// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
70-
// GPIO_InitStruct.Pull = GPIO_NOPULL;
71-
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
72-
// HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct);
73-
// /*Configure GPIO pins : PBPin PBPin PBPin PBPin
74-
// PBPin */
75-
// GPIO_InitStruct.Pin = OLED_RST_Pin|OLED_SDA_Pin|OLED_SCL_Pin;
76-
// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
77-
// GPIO_InitStruct.Pull = GPIO_NOPULL;
78-
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
79-
// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
80-
81-
}
82-
8355
uint8_t u8x8_stm32_gpio_and_delay(U8X8_UNUSED u8x8_t *u8x8,
8456
U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int,
8557
U8X8_UNUSED void *arg_ptr)

0 commit comments

Comments
 (0)