Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_B-L475E-IOT01 mbed
Revision 0:00847986b49e, committed 2018-11-14
- Comitter:
- iandil
- Date:
- Wed Nov 14 11:06:11 2018 +0000
- Commit message:
- Formatted printing
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_B-L475E-IOT01.lib Wed Nov 14 11:06:11 2018 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/ST/code/BSP_B-L475E-IOT01/#9dfa42666f03
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 14 11:06:11 2018 +0000
@@ -0,0 +1,84 @@
+#include "mbed.h"
+
+// Sensors drivers present in the BSP library
+#include "stm32l475e_iot01_tsensor.h"
+#include "stm32l475e_iot01_hsensor.h"
+#include "stm32l475e_iot01_psensor.h"
+#include "stm32l475e_iot01_magneto.h"
+#include "stm32l475e_iot01_gyro.h"
+#include "stm32l475e_iot01_accelero.h"
+
+#define SENSORS 6
+
+static int current_sensor = 1;
+
+InterruptIn button(USER_BUTTON);
+DigitalOut led(LED2);
+
+void changeSensor() {
+ printf("\nChanging Sensor\n");
+ if(current_sensor <= SENSORS) {
+ current_sensor++;
+ } else {
+ current_sensor = 1;
+ }
+}
+
+int main() {
+
+ float sensor_value = 0;
+ int16_t pDataXYZ[3] = {0};
+ float pGyroDataXYZ[3] = {0};
+
+ BSP_TSENSOR_Init();
+ BSP_HSENSOR_Init();
+
+ BSP_PSENSOR_Init();
+
+ BSP_MAGNETO_Init();
+ BSP_GYRO_Init();
+ BSP_ACCELERO_Init();
+
+ button.rise(&changeSensor);
+
+ while(1) {
+ led = 1;
+
+ switch(current_sensor){
+ case 1:
+ sensor_value = BSP_TSENSOR_ReadTemp();
+ printf("\nTEMPERATURE = %.2f degC\n", sensor_value);
+ break;
+ case 2:
+ sensor_value = BSP_HSENSOR_ReadHumidity();
+ printf("HUMIDITY = %.2f %%\n", sensor_value);
+ break;
+ case 3:
+ sensor_value = BSP_PSENSOR_ReadPressure();
+ printf("PRESSURE is = %.2f mBar\n", sensor_value);
+ break;
+ case 4:
+ BSP_MAGNETO_GetXYZ(pDataXYZ);
+ printf("\nMAGNETO_X = %d\n", pDataXYZ[0]);
+ printf("MAGNETO_Y = %d\n", pDataXYZ[1]);
+ printf("MAGNETO_Z = %d\n", pDataXYZ[2]);
+ break;
+ case 5:
+ BSP_GYRO_GetXYZ(pGyroDataXYZ);
+ printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]);
+ printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]);
+ printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]);
+ break;
+ case 6:
+ BSP_ACCELERO_AccGetXYZ(pDataXYZ);
+ printf("\nACCELERO_X = %d\n", pDataXYZ[0]);
+ printf("ACCELERO_Y = %d\n", pDataXYZ[1]);
+ printf("ACCELERO_Z = %d\n", pDataXYZ[2]);
+ break;
+ }
+
+ led = 0;
+
+ wait(1);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 14 11:06:11 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file