Dependencies: SSD1306 TSL2561 mbed DHT22 OneWire
main.cpp@0:9904b68365e4, 2017-10-17 (annotated)
- Committer:
- Aureb29
- Date:
- Tue Oct 17 10:18:27 2017 +0000
- Revision:
- 0:9904b68365e4
- Child:
- 2:34f81c0f5176
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Aureb29 | 0:9904b68365e4 | 1 | #include "mbed.h" |
Aureb29 | 0:9904b68365e4 | 2 | #define MOIST_PIN A3 |
Aureb29 | 0:9904b68365e4 | 3 | #define p_scl PA_9 |
Aureb29 | 0:9904b68365e4 | 4 | #define p_sda PA_10 |
Aureb29 | 0:9904b68365e4 | 5 | #include "TSL2561.h" |
Aureb29 | 0:9904b68365e4 | 6 | #include "ssd1306.h" |
Aureb29 | 0:9904b68365e4 | 7 | #include "standard_font.h" |
Aureb29 | 0:9904b68365e4 | 8 | #include "bold_font.h" |
Aureb29 | 0:9904b68365e4 | 9 | |
Aureb29 | 0:9904b68365e4 | 10 | SSD1306 oled(D3 /* cs */, A0 /* reset */, A7 /* dc */, |
Aureb29 | 0:9904b68365e4 | 11 | A1 /* clock */, A6 /* data */); |
Aureb29 | 0:9904b68365e4 | 12 | TSL2561 lum(PA_10,PA_9); |
Aureb29 | 0:9904b68365e4 | 13 | AnalogIn moisture(MOIST_PIN); |
Aureb29 | 0:9904b68365e4 | 14 | |
Aureb29 | 0:9904b68365e4 | 15 | int main() |
Aureb29 | 0:9904b68365e4 | 16 | { |
Aureb29 | 0:9904b68365e4 | 17 | oled.initialise(); |
Aureb29 | 0:9904b68365e4 | 18 | oled.clear(); |
Aureb29 | 0:9904b68365e4 | 19 | oled.set_contrast(255); // max contrast |
Aureb29 | 0:9904b68365e4 | 20 | |
Aureb29 | 0:9904b68365e4 | 21 | oled.set_font(bold_font, 8); |
Aureb29 | 0:9904b68365e4 | 22 | oled.printf("Heading\r\n"); |
Aureb29 | 0:9904b68365e4 | 23 | |
Aureb29 | 0:9904b68365e4 | 24 | oled.set_font(standard_font, 6); |
Aureb29 | 0:9904b68365e4 | 25 | oled.printf("Hello World!\r\n"); |
Aureb29 | 0:9904b68365e4 | 26 | oled.printf("Some more text here..."); |
Aureb29 | 0:9904b68365e4 | 27 | |
Aureb29 | 0:9904b68365e4 | 28 | oled.update(); |
Aureb29 | 0:9904b68365e4 | 29 | |
Aureb29 | 0:9904b68365e4 | 30 | while (1) |
Aureb29 | 0:9904b68365e4 | 31 | { |
Aureb29 | 0:9904b68365e4 | 32 | wait(2); |
Aureb29 | 0:9904b68365e4 | 33 | oled.scroll_up(); |
Aureb29 | 0:9904b68365e4 | 34 | oled.update(); |
Aureb29 | 0:9904b68365e4 | 35 | oled.set_font(bold_font, 8); |
Aureb29 | 0:9904b68365e4 | 36 | //oled.printf("Quentin t cheum!\r\n"); |
Aureb29 | 0:9904b68365e4 | 37 | oled.printf("Moisture is %2.2f\r\n", (float) moisture); |
Aureb29 | 0:9904b68365e4 | 38 | oled.printf("Lum : %+5.1f lux\r\n", lum.lux()); |
Aureb29 | 0:9904b68365e4 | 39 | oled.printf("\n"); |
Aureb29 | 0:9904b68365e4 | 40 | } |
Aureb29 | 0:9904b68365e4 | 41 | } |