1132,8 → 1132,6 |
!defined(_TEST_LUX) && !defined(_TEST_OLED_CHAR) |
|
void main(void) { |
unsigned int ir, full; |
unsigned long lum; |
|
/* --------------------- Oscillator Configuration --------------------- */ |
// OSCTUNEbits.PLLEN = 1; // Enable 4x PLL |
1145,41 → 1143,21 |
ANCON0 = 0xF8; |
ANCON1 = 0x1F; |
|
// UART1_Init(); |
I2C_Init(); |
NHD_Init(); |
LUX_Init(TSL2561_ADDR_FLOAT); |
UART1_Init(); |
Timer1_Init(); |
|
I2C_Configure_Master(I2C_400KHZ); |
|
|
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts |
interrupt_init(); // Initialize the interrupt priorities |
|
NHD_Begin(16, 2); |
LED_BLUE_TRIS = 0; |
LED_RED_TRIS = 0; |
|
// You can change the gain on the fly, to adapt to brighter/dimmer light situations |
// LUX_SetGain(TSL2561_GAIN_0X); // set no gain (for bright situtations) |
LUX_SetGain(TSL2561_GAIN_16X); // set 16x gain (for dim situations) |
Timer1_Enable(); |
|
// Changing the integration time gives you a longer time over which to sense light |
// longer timelines are slower, but are good in very low light situtations! |
LUX_SetTiming(TSL2561_INTEGRATIONTIME_13MS); // shortest integration time (bright light) |
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_101MS); // medium integration time (medium light) |
// LUX_SetTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light) |
DBG_PRINT_MAIN("\r\nBegin Program\r\n"); |
|
while (1) { |
lum = LUX_GetFullLuminosity(); |
ir = lum >> 16; |
full = lum & 0xFFFF; |
NHD_Clear(); |
NHD_Set_Cursor(0, 0); |
NHD_Write_String("I: %d ", ir); |
NHD_Write_String("V: %d", full - ir); |
NHD_Set_Cursor(0, 1); |
NHD_Write_String("Lux: %ld", LUX_CalculateLux(full, ir)); |
|
Delay10KTCYx(255); |
} |
} |
#endif |