part of the preparation works for Ina-city Hackerthon
Fork of Wio_3G_example by
main.cpp@72:aa14c091f860, 2018-08-06 (annotated)
- Committer:
- MACRUM
- Date:
- Mon Aug 06 09:28:20 2018 +0000
- Revision:
- 72:aa14c091f860
- Parent:
- 71:7d17edde2e03
- Child:
- 73:d47320bcc568
Update libraries
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:2757d7abb7d9 | 1 | #include "mbed.h" |
MACRUM | 71:7d17edde2e03 | 2 | #include "Grove_LCD_RGB_Backlight.h" |
MACRUM | 72:aa14c091f860 | 3 | #include "Grove_temperature.h" |
MACRUM | 70:cb6d36218441 | 4 | |
MACRUM | 70:cb6d36218441 | 5 | #define D20 (PB_4) |
MACRUM | 70:cb6d36218441 | 6 | #define D19 (PB_3) |
MACRUM | 70:cb6d36218441 | 7 | |
MACRUM | 70:cb6d36218441 | 8 | DigitalOut GrovePower(PB_10, 1); |
MACRUM | 70:cb6d36218441 | 9 | DigitalOut led1(D38); |
MACRUM | 70:cb6d36218441 | 10 | AnalogIn ain(A6); |
MACRUM | 70:cb6d36218441 | 11 | InterruptIn btn(D20); |
MACRUM | 71:7d17edde2e03 | 12 | Grove_LCD_RGB_Backlight rgbLCD(I2C_SDA, I2C_SCL); |
MACRUM | 72:aa14c091f860 | 13 | Grove_temperature temp(A4); |
MACRUM | 70:cb6d36218441 | 14 | |
MACRUM | 71:7d17edde2e03 | 15 | uint32_t button = 0; |
MACRUM | 70:cb6d36218441 | 16 | |
MACRUM | 70:cb6d36218441 | 17 | |
MACRUM | 70:cb6d36218441 | 18 | void push() |
MACRUM | 70:cb6d36218441 | 19 | { |
MACRUM | 71:7d17edde2e03 | 20 | button++; |
MACRUM | 70:cb6d36218441 | 21 | } |
Jonathan Austin |
0:2757d7abb7d9 | 22 | |
Jonathan Austin |
1:846c97078558 | 23 | // main() runs in its own thread in the OS |
MACRUM | 70:cb6d36218441 | 24 | int main() |
MACRUM | 70:cb6d36218441 | 25 | { |
MACRUM | 70:cb6d36218441 | 26 | btn.fall(push); |
MACRUM | 70:cb6d36218441 | 27 | |
MACRUM | 71:7d17edde2e03 | 28 | rgbLCD.clear(); |
MACRUM | 71:7d17edde2e03 | 29 | rgbLCD.setRGB(0xff, 0x00, 0x00); |
MACRUM | 71:7d17edde2e03 | 30 | rgbLCD.locate(0, 0); |
MACRUM | 71:7d17edde2e03 | 31 | rgbLCD.print("Hello World!"); |
MACRUM | 71:7d17edde2e03 | 32 | rgbLCD.locate(0, 1); |
MACRUM | 71:7d17edde2e03 | 33 | rgbLCD.print("This is a test"); |
MACRUM | 71:7d17edde2e03 | 34 | |
MACRUM | 70:cb6d36218441 | 35 | int cnt = 0; |
MACRUM | 70:cb6d36218441 | 36 | printf("hello, Mbed world\n"); |
Jonathan Austin |
0:2757d7abb7d9 | 37 | while (true) { |
MACRUM | 72:aa14c091f860 | 38 | printf("count = %4d, button = %d, analog = %f, temp = %f\n", cnt++, button, ain.read(), temp.getTemperature()); |
Jonathan Austin |
0:2757d7abb7d9 | 39 | led1 = !led1; |
mbed_official | 22:af9dcf379926 | 40 | wait(0.5); |
Jonathan Austin |
0:2757d7abb7d9 | 41 | } |
Jonathan Austin |
0:2757d7abb7d9 | 42 | } |