-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,105,366 additions
and
9,248 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* ButtonBeep.c | ||
* | ||
* Created on: Nov 25, 2019 | ||
* Author: Standa | ||
* reprogrammed Nov 22, 2021 | ||
* Author Jarin | ||
*/ | ||
|
||
#include <ButtonBeep.h> | ||
#include "stm32f1xx_it.h" | ||
#include <stdint.h> | ||
#include "measurement.h" | ||
#include "tim.h" | ||
#include "main.h" | ||
#include "utility.h" | ||
|
||
static BtnState BtnPUSH = {false,But_None,BPUSH_GPIO_Port, BPUSH_Pin}; | ||
static BtnState BtnPULL = {false,But_None,BPULL_GPIO_Port, BPULL_Pin}; | ||
static BtnState BtnCFG = {false,But_None,BCFG_GPIO_Port, BCFG_Pin}; | ||
BtnState* ButList[] = {&BtnPUSH, &BtnPULL, &BtnCFG}; | ||
|
||
static uint8_t BuzzerActive = 0; | ||
|
||
/* | ||
* Beeps the buzzer with specified tone (0 = off, 1=low, 2=medium, 3=high) for specified time in ms | ||
* tone 0 with time is just delay | ||
*/ | ||
void bbb_Beep(uint8_t tone, uint8_t time){ | ||
volatile uint32_t Stop = HAL_GetTick() + time; | ||
|
||
BuzzerActive = 1; | ||
if(tone > 4) tone = 4; | ||
|
||
if(tone > 0){ | ||
//Start timer | ||
__HAL_TIM_SET_AUTORELOAD(&htim1, 1200 - tone * 200); | ||
__HAL_TIM_SET_COMPARE(&htim1,TIM_CHANNEL_3,(1200 - tone * 200)>>1); | ||
HAL_TIMEx_PWMN_Start (&htim1, TIM_CHANNEL_3); | ||
} | ||
|
||
while(1) if(HAL_GetTick() > Stop) break; | ||
|
||
if(tone > 0){ | ||
//Stop timer | ||
HAL_TIMEx_PWMN_Stop (&htim1, TIM_CHANNEL_3); | ||
} | ||
|
||
|
||
BuzzerActive = 0; | ||
} | ||
|
||
|
||
void bbb_Melody2(uint8_t tone1, uint8_t tone2, uint16_t time){ | ||
bbb_Beep(tone1, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone2, time); | ||
bbb_Beep(0, time); | ||
} | ||
void bbb_Melody3(uint8_t tone1, uint8_t tone2, uint8_t tone3, uint16_t time){ | ||
bbb_Beep(tone1, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone2, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone3, time); | ||
bbb_Beep(0, time); | ||
} | ||
void bbb_Melody4(uint8_t tone1, uint8_t tone2, uint8_t tone3, uint8_t tone4, uint16_t time){ | ||
bbb_Beep(tone1, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone2, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone3, time); | ||
bbb_Beep(0, time); | ||
bbb_Beep(tone4, time); | ||
bbb_Beep(0, time); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* ButtonBeep.c | ||
* | ||
* Created on: Nov 25, 2019 | ||
* Author: Standa | ||
* reprogrammed Nov 22, 2021 | ||
* Author Jarin | ||
*/ | ||
|
||
#ifndef BUTTONBEEP_H_ | ||
#define BUTTONBEEP_H_ | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include "stm32f1xx_hal.h" | ||
|
||
|
||
enum Buttons { | ||
PUSH = 0, | ||
PULL, | ||
CFG, | ||
CountButtons // is not in the set of active elements, only for element count in ENUM | ||
}; | ||
|
||
typedef enum{ | ||
But_None = 0, | ||
But_Pressed, | ||
But_Released, | ||
//EvtTd_LongReleased, | ||
}BtnEvtTd; | ||
|
||
typedef struct{ | ||
bool IntStart; | ||
uint8_t LastState; | ||
GPIO_TypeDef* Port; | ||
uint16_t Pin; | ||
}BtnState; | ||
|
||
typedef enum{ | ||
bbb_ToneTd_None = 0, | ||
bbb_ToneTd_Low = 1, | ||
bbb_ToneTd_Med = 2, | ||
bbb_ToneTd_High = 3, | ||
bbb_ToneTd_VeryHigh = 4 | ||
}bbb_ToneTd; | ||
|
||
extern BtnState* ButList[CountButtons]; | ||
|
||
extern void bbb_Beep(uint8_t tone, uint8_t time); | ||
extern void bbb_Melody2(uint8_t tone1, uint8_t tone2, uint16_t time); | ||
extern void bbb_Melody3(uint8_t tone1, uint8_t tone2, uint8_t tone3, uint16_t time); | ||
extern void bbb_Melody4(uint8_t tone1, uint8_t tone2, uint8_t tone3, uint8_t tone4, uint16_t time); | ||
|
||
#endif /* BUTTONBEEP_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.