Added second beep with varying pitch on follow distance change

This commit is contained in:
Julian Metzler 2019-12-22 15:34:32 +01:00
parent 4c5842915d
commit f253e6e29a
1 changed files with 5 additions and 4 deletions

View File

@ -88,7 +88,7 @@ extern I2C_HandleTypeDef hi2c2;
void saveConfig(void); void saveConfig(void);
void longBeep(void); void longBeep(void);
void shortBeep(void); void shortBeep(uint8_t freq);
/* Virtual address defined by the user: 0xFFFF value is prohibited */ /* Virtual address defined by the user: 0xFFFF value is prohibited */
uint16_t VirtAddVarTab[NB_OF_VAR] = {0x1337}; uint16_t VirtAddVarTab[NB_OF_VAR] = {0x1337};
@ -371,7 +371,7 @@ int main(void) {
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
HAL_Delay(10); HAL_Delay(10);
} }
shortBeep(); shortBeep(5);
HAL_Delay(300); HAL_Delay(300);
if (HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { if (HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) { while(HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN)) {
@ -385,6 +385,7 @@ int main(void) {
if (setDistance > 2.6) { if (setDistance > 2.6) {
setDistance = 0.5; setDistance = 0.5;
} }
shortBeep(setDistance / 0.25);
saveValue = setDistance * 1000; saveValue = setDistance * 1000;
saveConfig(); saveConfig();
} }
@ -741,8 +742,8 @@ int main(void) {
buzzerFreq = 0; buzzerFreq = 0;
} }
void shortBeep(){ void shortBeep(uint8_t freq){
buzzerFreq = 5; buzzerFreq = freq;
HAL_Delay(100); HAL_Delay(100);
buzzerFreq = 0; buzzerFreq = 0;
} }