application: use sensor_sr04
This commit is contained in:
parent
b86846e945
commit
8407ed80b0
|
@ -32,6 +32,7 @@
|
|||
#include "usb_cdcacm.h" // USB CDC ACM utilities
|
||||
#include "terminal.h" // handle the terminal interface
|
||||
#include "menu.h" // menu utilities
|
||||
#include "sensor_sr04.h" // range measurement utilities
|
||||
|
||||
/** watchdog period in ms */
|
||||
#define WATCHDOG_PERIOD 10000
|
||||
|
@ -349,7 +350,7 @@ void main(void)
|
|||
board_setup(); // setup board
|
||||
uart_setup(); // setup USART (for printing)
|
||||
usb_cdcacm_setup(); // setup USB CDC ACM (for printing)
|
||||
puts("\nwelcome to the CuVoodoo STM32F4 example firmware\n"); // print welcome message
|
||||
puts("\nwelcome to the CuVoodoo STM32F4 yeast raiser\n"); // print welcome message
|
||||
|
||||
#if DEBUG
|
||||
// show reset cause
|
||||
|
@ -428,6 +429,10 @@ void main(void)
|
|||
// important: do not re-enable backup_domain_write_protect, since this will prevent clearing flags (but RTC registers do not need to be unlocked)
|
||||
puts("OK\n");
|
||||
|
||||
puts("setup HC-SR04 range sensor: ");
|
||||
sensor_sr04_setup(); // setup peripheral
|
||||
puts("OK\n");
|
||||
|
||||
// setup terminal
|
||||
terminal_prefix = ""; // set default prefix
|
||||
terminal_process = &process_command; // set central function to process commands
|
||||
|
@ -457,7 +462,13 @@ void main(void)
|
|||
}
|
||||
if (second_flag) { // one second passed
|
||||
second_flag = false; // clear flag
|
||||
action = true; // action will be performed
|
||||
led_toggle(); // toggle LED to indicate if main function is stuck
|
||||
sensor_sr04_trigger(); // start measurement
|
||||
}
|
||||
if (sensor_sr04_distance) { // distance measurement is available
|
||||
printf("%u\n", sensor_sr04_distance); // start measurement
|
||||
sensor_sr04_distance = 0; // clear flag
|
||||
}
|
||||
if (action) { // go to sleep if nothing had to be done, else recheck for activity
|
||||
action = false;
|
||||
|
|
Loading…
Reference in New Issue