Skip to content

Commit 6d83002

Browse files
committed
added display
1 parent ff0ca55 commit 6d83002

File tree

16 files changed

+931
-913
lines changed

16 files changed

+931
-913
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build/*
22
!build/hover.hex
33
*.sw*
4+
.vscode*
5+
*.ipch
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Inc/control.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ extern volatile uint16_t ppm_captured_value[PPM_NUM_CHANNELS+1];
1212
void turnOff();
1313
void turnOffWithReset();
1414

15+
void init_Display(uint8_t lines, uint8_t address);
16+
1517
int clean_adc(uint32_t inval);
1618
int calc_torque(int throttle,int breaks);
1719
void calc_torque_per_wheel(int throttle, float steering_eagle, int* torque);

Inc/defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
#define DELAY_TIM_FREQUENCY_US 1000000
125125

126-
#define MOTOR_AMP_CONV_DC_AMP 0.02
126+
#define MOTOR_AMP_CONV_DC_AMP 50
127127
#define ADC_BATTERY_VOLT 0.02647435897435897435897435897436
128128

129129
#define MILLI_R (R * 1000)

Src/bldc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void sensored_brushless_countrol(){
236236
last_pos[x] = real_pos;
237237
} else if(timer[x] > abs(internal_phase_period[x]))
238238
set_phase_lr[x](internal_phase_period[x] = SIGN(internal_phase_period[x])*timer[x]);
239-
set_tim_lr[x]((currentlr[x] = abs(adc_array[5-x] - adc_offset[5-x]) * MOTOR_AMP_CONV_DC_AMP) <= current_limit);
239+
set_tim_lr[x]((currentlr[x] = abs(adc_array[5-x] - adc_offset[5-x]) / MOTOR_AMP_CONV_DC_AMP) <= current_limit); // killed float
240240
RetValWeak tmp = currentWeaking(throttlelr[x],
241241
internal_phase_period[x],
242242
timer[x],

Src/control.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,24 @@ uint8_t scan_i2c_next_address(uint8_t start_address){
3333
}
3434

3535
void init_Display(uint8_t lines, uint8_t address){
36-
lcd.pcf8574.PCF_I2C_ADDRESS = 0x27;
36+
37+
lcd.pcf8574.PCF_I2C_ADDRESS = address;
3738
lcd.pcf8574.PCF_I2C_TIMEOUT = 5;
3839
lcd.pcf8574.i2c = hi2c2;
39-
lcd.NUMBER_OF_LINES = NUMBER_OF_LINES_2;
40+
switch (lines){
41+
case 1:
42+
lcd.NUMBER_OF_LINES = NUMBER_OF_LINES_1;
43+
break;
44+
case 2:
45+
lcd.NUMBER_OF_LINES = NUMBER_OF_LINES_2;
46+
break;
47+
case 3:
48+
lcd.NUMBER_OF_LINES = NUMBER_OF_LINES_3;
49+
break;
50+
case 4:
51+
lcd.NUMBER_OF_LINES = NUMBER_OF_LINES_4;
52+
break;
53+
}
4054
lcd.type = TYPE0;
4155

4256
if(LCD_Init(&lcd)!=LCD_OK){
@@ -47,8 +61,8 @@ void init_Display(uint8_t lines, uint8_t address){
4761
LCD_ClearDisplay(&lcd);
4862
HAL_Delay(5);
4963
LCD_SetLocation(&lcd, 0, 0);
50-
LCD_WriteString(&lcd, "Hover V2.0");
51-
LCD_SetLocation(&lcd, 0, 1);
64+
LCD_WriteString(&lcd, "LDEFWH V2.1");
65+
LCD_SetLocation(&lcd, 0, lines / 2);
5266
LCD_WriteString(&lcd, "Initializing...");
5367
}
5468

Src/generic_device.c

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void device_specific(){
2929
}
3030

3131
void device_init(){
32+
init_Display(4,0x27);
3233
//divisor = 3;
3334
//weak = false;
3435
set_weaking(3);

0 commit comments

Comments
 (0)