I2C BME280 Screen
Dependencies: BSP_DISCO_F746NG BME280
main.cpp@0:3f09104467d2, 2020-01-13 (annotated)
- Committer:
- inistol
- Date:
- Mon Jan 13 15:09:07 2020 +0000
- Revision:
- 0:3f09104467d2
Test I2C TEMP BME280;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inistol | 0:3f09104467d2 | 1 | #include "mbed.h" |
inistol | 0:3f09104467d2 | 2 | #include "stm32746g_discovery_lcd.h" |
inistol | 0:3f09104467d2 | 3 | #include "stm32746g_discovery_ts.h" |
inistol | 0:3f09104467d2 | 4 | #include "BME280.h" |
inistol | 0:3f09104467d2 | 5 | |
inistol | 0:3f09104467d2 | 6 | Serial pc(USBTX, USBRX); |
inistol | 0:3f09104467d2 | 7 | |
inistol | 0:3f09104467d2 | 8 | #if defined(TARGET_LPC1768) |
inistol | 0:3f09104467d2 | 9 | BME280 sensor(PB_9, PB_8); |
inistol | 0:3f09104467d2 | 10 | #else |
inistol | 0:3f09104467d2 | 11 | BME280 sensor(I2C_SDA, I2C_SCL); |
inistol | 0:3f09104467d2 | 12 | #endif |
inistol | 0:3f09104467d2 | 13 | TS_StateTypeDef TS_State; |
inistol | 0:3f09104467d2 | 14 | |
inistol | 0:3f09104467d2 | 15 | float x=0; |
inistol | 0:3f09104467d2 | 16 | uint8_t y=0; |
inistol | 0:3f09104467d2 | 17 | uint8_t text[30]; |
inistol | 0:3f09104467d2 | 18 | uint8_t idx; |
inistol | 0:3f09104467d2 | 19 | |
inistol | 0:3f09104467d2 | 20 | int main() |
inistol | 0:3f09104467d2 | 21 | { |
inistol | 0:3f09104467d2 | 22 | BSP_LCD_Init(); |
inistol | 0:3f09104467d2 | 23 | BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); |
inistol | 0:3f09104467d2 | 24 | BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); |
inistol | 0:3f09104467d2 | 25 | BSP_LCD_Clear(LCD_COLOR_BLACK); |
inistol | 0:3f09104467d2 | 26 | |
inistol | 0:3f09104467d2 | 27 | |
inistol | 0:3f09104467d2 | 28 | while (1) { |
inistol | 0:3f09104467d2 | 29 | |
inistol | 0:3f09104467d2 | 30 | |
inistol | 0:3f09104467d2 | 31 | BSP_LCD_SetBackColor(LCD_COLOR_BLACK); |
inistol | 0:3f09104467d2 | 32 | BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); |
inistol | 0:3f09104467d2 | 33 | |
inistol | 0:3f09104467d2 | 34 | x = sensor.getTemperature(); |
inistol | 0:3f09104467d2 | 35 | y = sensor.getPressure(); |
inistol | 0:3f09104467d2 | 36 | sprintf((char*)text, "%2.2f degC",x); |
inistol | 0:3f09104467d2 | 37 | BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, CENTER_MODE); |
inistol | 0:3f09104467d2 | 38 | |
inistol | 0:3f09104467d2 | 39 | //HAL_Delay(500); |
inistol | 0:3f09104467d2 | 40 | |
inistol | 0:3f09104467d2 | 41 | } |
inistol | 0:3f09104467d2 | 42 | } |