update tsl2561 code, update delay time to 400ms
| | |
| | | #include <unistd.h> |
| | | #include <math.h> |
| | | #include <errno.h> |
| | | #include <time.h> |
| | | |
| | | #include "tsl2561.h" |
| | | |
| | |
| | | wiringPiI2CWrite(tsl_fd, CONTROL_REG); |
| | | wiringPiI2CWrite(tsl_fd, POWER_UP); |
| | | |
| | | sleep(1); |
| | | delay(410); /* t(CONV) MAX 400ms */ |
| | | |
| | | /* Read register Channel0 and channel1 data from register */ |
| | | for(i=0; i<REG_COUNT; i++) |
| | |
| | | wiringPiI2CWrite(tsl_fd, POWER_DOWN); |
| | | } |
| | | |
| | | void print_datime(void) |
| | | { |
| | | time_t tmp; |
| | | struct tm *p; |
| | | |
| | | time(&tmp); |
| | | |
| | | p=localtime(&tmp); |
| | | |
| | | |
| | | printf("%d-%02d-%02d %02d:%02d:%02d\t", (p->tm_year+1900),(p->tm_mon+1), |
| | | p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); |
| | | |
| | | } |
| | | |
| | | int main(int argc, char **argv) |
| | | { |
| | |
| | | |
| | | while(1) |
| | | { |
| | | print_datime(); |
| | | tsl2561_get_lux(); |
| | | sleep(interval); |
| | | } |