userland: add error checking to tsl2651 test app
-#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <console.h>
#include <tock.h>
@@ -14,7 +9,12 @@ int main (void) {
// Start a light measurement
int lux = tsl2561_get_lux_sync();
-
+ if (lux == TOCK_ENODEVICE) {
+ printf("ERROR: No TSL2561 on this board.\n");
+ } else if (lux < 0) {
+ printf("ERROR: unable to read the sensor (error code: %i)\n", lux);
+ } else {
// Print the lux value
printf("\tValue(%d lux) [0x%X]\n\n", lux, lux);
}
+}
