Skip to content

Commit

Permalink
Battery ADC fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gissio committed Jan 10, 2023
1 parent 1a6b6c2 commit 1e94ddc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cubeide/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
onBuzzerOff();
}

uint32_t const volatile validCRC __attribute__((section(".crc"))) = 0x2c6aa051;
uint32_t const volatile validCRC __attribute__((section(".crc"))) = 0x6025cf39;

/* USER CODE END 0 */

Expand Down
12 changes: 9 additions & 3 deletions cubeide/Core/fs2011pro/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@ float getBatteryValue()

void initPower()
{
// Sample the batttery voltage initially before turning on the devices
power.batteryValue = getBatteryValue();

setPower(true);
setBacklight(false);
setHighVoltageGenerator(true);

#ifndef SDL_MODE
HAL_ADCEx_Calibration_Start(&hadc);
#endif

float batteryValue = 0;
for (int i = 0; i < 100; i++)
{
batteryValue += getBatteryValue();
HAL_Delay(1);
}

power.batteryValue = batteryValue / 100.0F;
}

void waitForInterrupt()
Expand Down

0 comments on commit 1e94ddc

Please sign in to comment.