| | |
| | | |
| | | if( lux > hal_ctx->lux_threshold ) |
| | | { |
| | | log_nrml("Lux[%.3f] > Treshold[%.3f], don't need light on.\n", lux, hal_ctx->lux_threshold); |
| | | log_nrml("Lux[%.3f] > Treshold[%.3f], don't need light on and sleep now.\n", lux, hal_ctx->lux_threshold); |
| | | if( hal_ctx->gpio.light_intval > 0) |
| | | sleep( hal_ctx->gpio.light_intval ); |
| | | else |
| | | sleep(30); |
| | | |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | rv = infrared_detect(250); |
| | | |
| | | rv = infrared_detect(); |
| | | if( rv & FLAG_INFRARED_INDOOR ) |
| | | { |
| | | log_nrml("Someone incoming detected by indoor infrared\n"); |
| | | thread_start(NULL, light_on_worker, "indoor" ); |
| | | } |
| | | |
| | | if( rv & FLAG_INFRARED_HALLWAY ) |
| | | { |
| | | log_nrml("Someone incoming detected by hallway infrared\n"); |
| | | thread_start(NULL, light_on_worker, "hallway" ); |
| | | } |
| | | } |
| | | |
| | | msleep(500); |
| | | msleep(100); |
| | | } |
| | | } |
| | | |