Skip to content

Commit

Permalink
Dead time for sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
PTDreamer committed Feb 25, 2018
1 parent d31017a commit 6c4cd63
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ static void MX_TIM3_Init(void);
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
RE_State_t RE1_Data;

static uint32_t lastActivity;

static uint8_t activity = 1;
static uint32_t pwmStoppedSince = 0;
static uint32_t startOfNoActivityTime = 0;
static uint8_t startOfNoActivity = 0;
#define ADC_MEASURE_DELAY 0
int main(void)
{
Expand Down Expand Up @@ -151,10 +151,17 @@ int main(void)
if(iron_temp_measure_state == iron_temp_measure_ready) {
readTipTemperatureCompensated(1);

if(HAL_GPIO_ReadPin(WAKE_GPIO_Port, WAKE_Pin) == GPIO_PIN_RESET)
activity = 0;
else
if(HAL_GPIO_ReadPin(WAKE_GPIO_Port, WAKE_Pin) == GPIO_PIN_RESET) {
if(startOfNoActivity == 0)
startOfNoActivityTime = HAL_GetTick();
startOfNoActivity = 1;
if((HAL_GetTick() - startOfNoActivityTime) > 500)
activity = 0;
}
else {
activity = 1;
startOfNoActivity = 0;
}

handleIron(activity);
iron_temp_measure_state = iron_temp_measure_idle;
Expand Down

0 comments on commit 6c4cd63

Please sign in to comment.