Loading...
Searching...
No Matches
baro.c
1/***********************************************************************************
2 * @file launch.c *
3 * @author Matt Ricci *
4 * @addtogroup Shell *
5 * *
6 * @{ *
7 ***********************************************************************************/
8
9#include "stdint.h"
10#include "stdio.h"
11
12#include "shell.h"
13#include "devicelist.h"
14
15#include "bmp581.h"
16
17static void Baro_exec(Shell *shell, uint8_t *);
18
19DEFINE_PROGRAM_HANDLE("baro", Baro_exec)
20
21/* =============================================================================== */
28static void Baro_exec(Shell *shell, uint8_t *flags) {
29 BMP581_t *baro = DeviceList_getDeviceHandle(DEVICE_BARO).device;
30 char str[30];
31 if (!strcmp(flags, "read")) {
32 baro->update(baro);
33 snprintf(str, 50, "Ground pressure: %f\n\r", baro->groundPress);
34 shell->usb.print(&shell->usb, str);
35 snprintf(str, 50, "Current pressure: %f\n\r", baro->press);
36 shell->usb.print(&shell->usb, str);
37 snprintf(str, 50, "Current temperature: %f\n\r", baro->temp);
38 shell->usb.print(&shell->usb, str);
39 }
40}
41
DeviceHandle_t DeviceList_getDeviceHandle(DeviceKey)
Retrieve device handle from list by key.
Definition devicelist.c:36
UART_t usb
UART interface to connect shell I/O.
Definition shell.h:49
Struct definition for shell interface.
Definition shell.h:48
void(* print)(struct UART *, char *)
UART print string method.
Definition uart.h:61