better sond measurment, tolerant to static voltage on piezo
This commit is contained in:
parent
f1690c6cd1
commit
5d3c3bcb51
|
@ -44,6 +44,7 @@ void modeswitch_poll(void){
|
||||||
void do_mode0(void){
|
void do_mode0(void){
|
||||||
static timer_t mytimer;
|
static timer_t mytimer;
|
||||||
static uint16_t maxval;
|
static uint16_t maxval;
|
||||||
|
static uint16_t lastmaxval;
|
||||||
uint16_t curval;
|
uint16_t curval;
|
||||||
|
|
||||||
if (ModeChanged){
|
if (ModeChanged){
|
||||||
|
@ -54,10 +55,14 @@ void do_mode0(void){
|
||||||
maxval=0;
|
maxval=0;
|
||||||
};
|
};
|
||||||
if(timer_expired(&mytimer)){
|
if(timer_expired(&mytimer)){
|
||||||
USART0_put_uint16(maxval);
|
if(maxval>lastmaxval){
|
||||||
USART0_crlf();
|
USART0_put_uint16(maxval);
|
||||||
|
USART0_crlf();
|
||||||
|
};
|
||||||
timer_set(&mytimer, 1);
|
timer_set(&mytimer, 1);
|
||||||
if (maxval>0) {led_on(LED_R|LED_L);} else {led_off(LED_R|LED_L);};
|
if (maxval>lastmaxval) {led_on(LED_R|LED_L);} else {led_off(LED_R|LED_L);};
|
||||||
|
|
||||||
|
lastmaxval=maxval;
|
||||||
maxval=0;
|
maxval=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user