Workshop example
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Diff: main.cpp
- Revision:
- 15:a0430d40a918
- Parent:
- 13:42b49a0caade
- Child:
- 16:70374ab2404f
--- a/main.cpp Mon Dec 10 19:06:42 2018 +0000 +++ b/main.cpp Mon Dec 10 22:06:50 2018 +0000 @@ -33,8 +33,6 @@ static DigitalOut shutdown_pin(PC_6); // static VL53L0X sen_distance(&devI2c, &shutdown_pin, PC_7); -InterruptIn button(USER_BUTTON); - #define SENSORS_POLL_INTERVAL 1.0 //#define SEND_ALL_SENSORS @@ -50,7 +48,9 @@ SlicingBlockDevice sd(bd, 0, 2*1024*1024); LittleFileSystem fs("fs", &sd); -// Default LED to use for PUT/POST +// Default User button for GET example +InterruptIn button(BUTTON1); +// Default LED to use for PUT/POST example DigitalOut led(LED1); // Declaring pointers for access to Pelion Client resources outside of main() @@ -220,7 +220,7 @@ int main(void) { printf("Starting Simple Pelion Device Management Client example\n"); - // If the User button is pressed, then format storage. + // If the User button is pressed ons start, then format storage. const int PRESSED = 0; DigitalIn *user_button = new DigitalIn(USER_BUTTON); if (user_button->read() == PRESSED) { @@ -340,8 +340,8 @@ button.fall(eventQueue.event(&button_press)); + // The timer fires on an interrupt context, but debounces it to the eventqueue, so it's safe to do network operations Ticker timer; - // The timer fires on an interrupt context, but debounces it to the eventqueue, so it's safe to do network operations timer.attach(eventQueue.event(&sensors_update), SENSORS_POLL_INTERVAL); // You can easily run the eventQueue in a separate thread if required