Pathfindr / Mbed OS mbed-os-PF-UWBBEACON_v1_dev

Dependencies:   aconno_I2C Lis2dh12 WatchdogTimer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LED.cpp Source File

LED.cpp

00001 #include "LED.h"
00002 
00003 //------------------------------------------------------------------------------
00004 // LED
00005 //------------------------------------------------------------------------------ 
00006 DigitalOut led1(PN_LED);
00007 DigitalOut led2(PN_LED_BLUE);
00008 
00009 void LED1on(long milliseconds = 0) {
00010     led1 = 0;
00011     if (milliseconds > 0) {
00012         ThisThread::sleep_for(milliseconds);
00013         //Thread::wait(milliseconds);
00014         led1 = 1;
00015     }
00016 }
00017 void LED1blink(int count = 2, long milliseconds = 100) {
00018     for (int i = 0; i < (count*2); i++) {
00019         led1 = !led1;
00020         if (milliseconds > 0) {
00021             //Thread::wait(milliseconds);
00022             ThisThread::sleep_for(milliseconds);
00023         } else { 
00024             //Thread::wait(100);
00025             ThisThread::sleep_for(100); //default if 0 provided
00026         }
00027     }
00028     led1 = 1;
00029 }
00030 void LED1errorCode(int pattern, int count) {
00031     for (int i = 0; i < count; i++) {
00032         for (int p = 0; p < pattern; p++) {
00033             led1 = 0;
00034             //Thread::wait(200);
00035             ThisThread::sleep_for(200);
00036             led1 = 1;
00037             //Thread::wait(300);
00038             ThisThread::sleep_for(300);
00039         }
00040         ThisThread::sleep_for(1000);
00041     }
00042     led1 = 1;
00043 }
00044 void LED1off() {
00045     led1 = 1;
00046 }
00047 
00048 
00049 
00050 
00051 
00052 void LED2on(long milliseconds = 0) {
00053     led2 = 0;
00054     if (milliseconds > 0) {
00055         ThisThread::sleep_for(milliseconds);
00056         led2 = 1;
00057     }
00058 }
00059 void LED2blink(int count = 2, long milliseconds = 100) {
00060     for (int i = 0; i < (count*2); i++) {
00061         led2 = !led2;
00062         if (milliseconds > 0) {
00063             ThisThread::sleep_for(milliseconds);
00064         } else { 
00065             ThisThread::sleep_for(100); //default if 0 provided
00066         }
00067     }
00068     led2 = 1;
00069 }
00070 void LED2errorCode(int pattern, int count) {
00071     for (int i = 0; i < count; i++) {
00072         for (int p = 0; p < pattern; p++) {
00073             led2 = 0;
00074             ThisThread::sleep_for(200);
00075             led2 = 1;
00076             ThisThread::sleep_for(300);
00077         }
00078         ThisThread::sleep_for(1000);
00079     }
00080     led2 = 1;
00081 }
00082 void LED2off() {
00083     led2 = 1;
00084 }