type casting is a thing

This commit is contained in:
2025-11-18 13:44:19 -06:00
parent 31d7ce1307
commit 127ee4e919

View File

@@ -35,7 +35,8 @@ extern "C" {
/* USER CODE BEGIN PD */ /* USER CODE BEGIN PD */
#define Print2UART1 int __io_putchar(int data) #define Print2UART1 int __io_putchar(int data)
//float duty = 58.52 // (((2396*4096)*65534)/65534)*100 //float duty = 58.52 // (((2396*4096)*65534)/65534)*100
int duty = 59; //int duty = 59;
float duty = 58.52;
/* USER CODE END PD */ /* USER CODE END PD */
@@ -116,11 +117,12 @@ main(void)
HAL_ADC_Start(&hadc1); HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 100); HAL_ADC_PollForConversion(&hadc1, 100);
rawValue = HAL_ADC_GetValue(&hadc1); rawValue = (float)HAL_ADC_GetValue(&hadc1);
HAL_Delay(500); HAL_Delay(500);
//volts = rawValue; // TODO change this to an actual conversion //volts = rawValue; // TODO change this to an actual conversion
volts = rawValue / duty;
//printf("The value is %hu volts.\r\n", volts); //printf("The value is %hu volts.\r\n", volts);
printf("The value is %f volts.\r\n", volts); printf("The value is %f volts.\r\n", volts);
@@ -129,7 +131,6 @@ main(void)
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, duty); // TODO dude what is going on __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, duty); // TODO dude what is going on
// rawValue/4096*65545 // rawValue/4096*65545
HAL_Delay(100); HAL_Delay(100);
/* USER CODE END WHILE */ /* USER CODE END WHILE */