mb1242read.c
Go to the documentation of this file.
1 /*
2  mb1242read.c : read values from MaxBotix MB1242 I^2C sonar
3 
4  Don't forget to supply external power to the board!
5 
6  Copyright (C) 2016 Simon D. Levy
7 
8  This file is part of BreezySTM32.
9 
10  BreezySTM32 is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  BreezySTM32 is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include <breezystm32.h>
25 
26 static bool sonar_present;
27 
28 void setup(void)
29 {
31  delay(500);
33 }
34 
35 void loop(void)
36 {
38  delay(25);
41  {
42  float distance = mb1242_async_read();
43  printf("distance = %d.%dm\n", (uint32_t)distance, (uint32_t)(distance*1000)%1000);
44  }
45  else
46  printf("no sonar\n");
47 }
void i2cInit(I2CDevice index)
Definition: drv_i2c.c:420
void mb1242_async_update()
Definition: drv_mb1242.c:76
static bool sonar_present
Definition: mb1242read.c:26
void loop(void)
Definition: mb1242read.c:35
bool mb1242_init()
Definition: drv_mb1242.c:57
bool mb1242_present()
Definition: drv_mb1242.c:69
static float distance
Definition: drv_sen13680.c:34
void setup(void)
Definition: mb1242read.c:28
#define LED1_TOGGLE
Definition: drv_system.h:51
float mb1242_async_read()
Definition: drv_mb1242.c:99
void delay(uint32_t ms)
Definition: system.c:101


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:47