Skip to content

Commit

Permalink
auto trigger: add random delay before triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
maximevince committed Apr 29, 2024
1 parent 5e65f30 commit 627ff2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/xlat.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,13 @@ enum xlat_mode xlat_get_mode(void)

void xlat_auto_trigger_action(void)
{
// random delay, such that we do not always perfectly align with USB timing
srand(xTaskGetTickCount());
int val = rand() & 0xFFF;
for (volatile int i = 0; i < val; i++) {
__NOP();
}
HAL_GPIO_WritePin(ARDUINO_D11_GPIO_Port, ARDUINO_D11_Pin, auto_trigger_level_high ? GPIO_PIN_SET : GPIO_PIN_RESET);
// HAL_Delay(40);
// HAL_GPIO_WritePin(ARDUINO_D11_GPIO_Port, ARDUINO_D11_Pin, auto_trigger_level_high ? GPIO_PIN_RESET : GPIO_PIN_SET);
}

void xlat_auto_trigger_turn_off_action(void)
Expand Down

0 comments on commit 627ff2b

Please sign in to comment.