Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
common.cpp
- Committer:
- pathfindr
- Date:
- 2019-02-05
- Revision:
- 48:64b1613941d5
- Parent:
- 34:4493c9f6d707
- Child:
- 51:9078e6928412
File content as of revision 48:64b1613941d5:
#include "common.h"
//------------------------------------------------------------------------------
// LED
//------------------------------------------------------------------------------ 
DigitalOut led1(PN_LED);
void LED1on(long milliseconds = 0) {
    GLOBAL_LEDSequenceinProgress = true;
    led1 = 0;
    if (milliseconds > 0) {
        //ThisThread::sleep_for(milliseconds);
        Thread::wait(milliseconds);
        led1 = 1;
        GLOBAL_LEDSequenceinProgress = false;
    }
}
void LED1blink(int count = 2, long milliseconds = 100) {
    GLOBAL_LEDSequenceinProgress = true;
    for (int i = 0; i < (count*2); i++) {
        led1 = !led1;
        if (milliseconds > 0) {
            Thread::wait(milliseconds);
            //ThisThread::sleep_for(milliseconds);
        } else { 
            Thread::wait(100);
            //ThisThread::sleep_for(100); //default if 0 provided
        }
    }
    led1 = 1;
    GLOBAL_LEDSequenceinProgress = false;
}
void LED1blinkRTC(int count) {
    RTCtick_ledflash_count = count;
}
void LED1errorCode(int pattern, int count) {
    GLOBAL_LEDSequenceinProgress = true;
    for (int i = 0; i < count; i++) {
        for (int p = 0; p < pattern; p++) {
            led1 = 0;
            Thread::wait(200);
            led1 = 1;
            Thread::wait(300);
        }
        Thread::wait(1000);
    }
    led1 = 1;
    GLOBAL_LEDSequenceinProgress = false;
}
void LED1off() {
    led1 = 1;
    RTCtick_ledflash_count = 0;
    GLOBAL_LEDSequenceinProgress = false;
}