int main(){ SystemInit(); UB_LCD_Init(); UB_LCD_LayerInit_Fullscreen(); UB_LCD_SetLayer_1(); UB_LCD_FillLayer(RGB_COL_WHITE); UB_LCD_SetLayer_2(); UB_LCD_FillLayer(RGB_COL_BLACK); UB_LCD_Rotate_0(); UB_Font_DrawString(5,10,"STM32F429-BH1750 TEST",&Arial_11x18,RGB_COL_BLUE,RGB_COL_BLACK); UB_I2C3_Init(); Delay(5000000); while(1){ int lux; char buf[20]; lux = BH1750_Read(ONE_TIME_H_1LX); if(lux < 0){ return 0; } else{ sprintf(buf,"Lux = %d ",lux); UB_Font_DrawString(10,40,buf,&Arial_11x18,RGB_COL_BLUE,RGB_COL_BLACK); } Delay(5000000); } }
/** * @ Opis Wykonuje pomiar natezenia oswietlenia i odczytuje wynik. * @ Parametry Brak. * @ Zwracana wartosc Natezenia oswietlenia w luksach. */ uint16_t getIlluminance() { uint16_t illuminance; BH1750_Start(BH1750_OTHR_MODE); _delay_ms(150); illuminance = BH1750_Read(); return illuminance; }
int main(){ SystemInit(); I2C1_Init(); BH1750_Init(); while(1){ uint16_t x = BH1750_Read(); delay_ms(200); } }
bool bh1750(unsigned int &value) { byte buffer[2]; value = 0; BH1750_Init(BH1750_ADDR); delay(200); if (BH1750_Read(BH1750_ADDR, buffer) == 2) { value = (((unsigned int)(buffer[0]) << 8) | buffer[1]) / 1.2; return true; } return false; }
float BH1750_GetLumen(void) { BH1750_Read(); BH1750_Convert(); return BH1750_result_lx; }