From 4061297c2a41081c374585a6f256a51f1b799058 Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Fri, 22 Apr 2016 21:32:32 +0000 Subject: EX: added get temperature for L3GD20, improved related demos git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9341 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F3xx/SPI-L3GD20/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'testhal/STM32/STM32F3xx/SPI-L3GD20') diff --git a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c index 31ec3004f..a845f92a7 100644 --- a/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c +++ b/testhal/STM32/STM32F3xx/SPI-L3GD20/main.c @@ -38,6 +38,7 @@ static L3GD20Driver L3GD20D1; static int32_t rawdata[L3GD20_NUMBER_OF_AXES]; static float cookeddata[L3GD20_NUMBER_OF_AXES]; +static float temperature; static char axesID[L3GD20_NUMBER_OF_AXES] = {'X', 'Y', 'Z'}; static uint32_t i; @@ -136,7 +137,10 @@ int main(void) { gyroscopeReadCooked(&L3GD20D1, cookeddata); for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) - chprintf(chp, "COOKED-%c:%f\r\n", axesID[i], cookeddata[i]); + chprintf(chp, "COOKED-%c:%.3f\r\n", axesID[i], cookeddata[i]); + + gyroscopeGetTemp(&L3GD20D1, &temperature); + chprintf(chp, "TEMP:%.1f C°\r\n", temperature); chprintf(chp, "Press Button to continue...\r\n"); chThdSleepMilliseconds(150); @@ -167,7 +171,10 @@ int main(void) { gyroscopeReadCooked(&L3GD20D1, cookeddata); for(i = 0; i < L3GD20_NUMBER_OF_AXES; i++) - chprintf(chp, "COOKED-%c:%f\r\n", axesID[i], cookeddata[i]); + chprintf(chp, "COOKED-%c:%.3f\r\n", axesID[i], cookeddata[i]); + + gyroscopeGetTemp(&L3GD20D1, &temperature); + chprintf(chp, "TEMP:%.1f C°\r\n", temperature); chThdSleepMilliseconds(150); #if CHPRINTF_USE_ANSI_CODE -- cgit v1.2.3