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.
Diff: main.cpp
- Revision:
- 4:588bc9618fff
- Parent:
- 3:79758cbd4a92
- Child:
- 5:79dc134e6033
--- a/main.cpp Wed May 16 03:48:35 2018 +0000
+++ b/main.cpp Wed May 16 03:59:41 2018 +0000
@@ -1,8 +1,10 @@
#include "mbed.h"
+#include "Si1133.h"
#include "SPI_MIP16.h"
#include "data.h"
+Si1133 uv_sensor(PC4, PC5);
WatchDisp WD(PK0,PK2,PF7,PA5); //PTC12); // mosi,miso,clk,cs,disp,power(EXTMODE)
DigitalOut _lcd_disp(PA8); // DISP
@@ -64,15 +66,23 @@
UV_INT.fall(&uv_init_proc);
test_lcd();
+ if (!uv_sensor.open()) printf("Device Error detected!\n");
+ int i;
while(1){
- for (int i=0; i<0x10000;i++) {
- for (int j=0; j<0x100000;j++) ;
+ i++;
+ for (int j=0; j<0x100000;j++) ;
led1 = (i%8==0)?(1):(0);
// ledR = (i%1==0)?(1):(0);
// ledG = (i%2==0)?(1):(0);
// ledB = (i%4==0)?(1):(0);
- printf("aaa %d\n\r",i);
- }
+ printf("aaa %d\n\r",i);
+ float light_level = (float)uv_sensor.get_light_level();
+ printf("Lux = %.3f\n", (float)light_level);
+ //Print the current UV index
+ float uv_index = (float)uv_sensor.get_uv_index();
+ printf("UV index = %.3f\n", (float) uv_index);
+ //Sleep for 0.5 seconds
+ wait(0.5);
}
}