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:
- 2:924e2280acf4
- Parent:
- 1:7cd9426abb58
- Child:
- 3:f41f244de0b3
--- a/main.cpp Fri Nov 22 14:05:34 2019 +0000 +++ b/main.cpp Fri Nov 22 15:14:38 2019 +0000 @@ -10,7 +10,7 @@ USB_link.baud(115200); USB_link.format(8, SerialBase::None, 1); - uint16_t r,g,b; + uint16_t r,g,b,a; if (GSensor.ginit()) { USB_link.printf("APDS-9960 initialization complete\n\r"); } else { @@ -23,6 +23,7 @@ } else { USB_link.printf("Something went wrong with the light sensor\n\r"); } + /* if(GSensor.setLEDDrive(0x00)) { // led current : 100mA USB_link.printf("led current set at 100 mA\n\r"); } else { @@ -32,30 +33,40 @@ //r = GSensor.getMode(); // USB_link.printf("mode :%hx ",r); if (GSensor.readRedLight(r)) { - // USB_link.printf(" R :%4hu ",r); + // USB_link.printf("R:%4hu ",r); } else { USB_link.printf("Something went wrong during red value reading\n\r"); } + if (GSensor.readGreenLight(g)) { - //USB_link.printf(" G :%4hu ",r); + //USB_link.printf("G:%4hu ",g); } else { USB_link.printf("Something went wrong during green value reading\n\r"); } + if (GSensor.readBlueLight(b)) { - // USB_link.printf(" B :%4hu\r\n",r); + // USB_link.printf("B:%4hu ",b); + } else { + USB_link.printf("Something went wrong during blue value reading\n\r"); + } + + if (GSensor.readAmbientLight(a)) { + // USB_link.printf("light:%4hu\r\n",a); } else { USB_link.printf("Something went wrong during blue value reading\n\r"); } + // affichage couleur - if (r >30) { + if (a>100) { + USB_link.printf("no color \r\n"); + } + else if (r > g ) { USB_link.printf("red \r\n"); } - if (g >30) { + else if (g > r ) { USB_link.printf("green \r\n"); } - if ((g<30)&&(r<30)) { - USB_link.printf("no color \r\n"); - } + }