Alex Allen / flash
Committer:
AlexAllen
Date:
Sat Oct 13 11:20:18 2012 +0000
Revision:
1:3c829c6b7d39
Parent:
0:8f42ebd85c7a
Child:
2:dfc82b5b4124
A collection of light flashing functions

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AlexAllen 1:3c829c6b7d39 1 /* Copyright (c) <year> <copyright holders>, MIT License
AlexAllen 1:3c829c6b7d39 2 *
AlexAllen 1:3c829c6b7d39 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
AlexAllen 1:3c829c6b7d39 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
AlexAllen 1:3c829c6b7d39 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
AlexAllen 1:3c829c6b7d39 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
AlexAllen 1:3c829c6b7d39 7 * furnished to do so, subject to the following conditions:
AlexAllen 1:3c829c6b7d39 8 *
AlexAllen 1:3c829c6b7d39 9 * The above copyright notice and this permission notice shall be included in all copies or
AlexAllen 1:3c829c6b7d39 10 * substantial portions of the Software.
AlexAllen 1:3c829c6b7d39 11 *
AlexAllen 1:3c829c6b7d39 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
AlexAllen 1:3c829c6b7d39 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
AlexAllen 1:3c829c6b7d39 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
AlexAllen 1:3c829c6b7d39 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AlexAllen 1:3c829c6b7d39 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AlexAllen 1:3c829c6b7d39 17 */
AlexAllen 0:8f42ebd85c7a 18 #include "flash.h"
AlexAllen 0:8f42ebd85c7a 19 #include "mbed.h"
AlexAllen 0:8f42ebd85c7a 20
AlexAllen 0:8f42ebd85c7a 21 DigitalOut led1(LED1);
AlexAllen 0:8f42ebd85c7a 22 DigitalOut led2(LED2);
AlexAllen 0:8f42ebd85c7a 23 DigitalOut led3(LED3);
AlexAllen 0:8f42ebd85c7a 24 DigitalOut led4(LED4);
AlexAllen 0:8f42ebd85c7a 25
AlexAllen 0:8f42ebd85c7a 26 void lightup()
AlexAllen 0:8f42ebd85c7a 27 {
AlexAllen 0:8f42ebd85c7a 28 led1 = 1;
AlexAllen 0:8f42ebd85c7a 29 wait(0.1);
AlexAllen 0:8f42ebd85c7a 30 led1 = 0;
AlexAllen 0:8f42ebd85c7a 31
AlexAllen 0:8f42ebd85c7a 32 led2 = 1;
AlexAllen 0:8f42ebd85c7a 33 wait(0.1);
AlexAllen 0:8f42ebd85c7a 34 led2 = 0;
AlexAllen 0:8f42ebd85c7a 35
AlexAllen 0:8f42ebd85c7a 36 led3 = 1;
AlexAllen 0:8f42ebd85c7a 37 wait(0.1);
AlexAllen 0:8f42ebd85c7a 38 led3 = 0;
AlexAllen 0:8f42ebd85c7a 39
AlexAllen 0:8f42ebd85c7a 40 led4 = 1;
AlexAllen 0:8f42ebd85c7a 41 wait(0.1);
AlexAllen 0:8f42ebd85c7a 42 led4 = 0;
AlexAllen 0:8f42ebd85c7a 43
AlexAllen 0:8f42ebd85c7a 44 led3 = 1;
AlexAllen 0:8f42ebd85c7a 45 wait(0.1);
AlexAllen 0:8f42ebd85c7a 46 led3 = 0;
AlexAllen 0:8f42ebd85c7a 47
AlexAllen 0:8f42ebd85c7a 48 led2 = 1;
AlexAllen 0:8f42ebd85c7a 49 wait(0.1);
AlexAllen 0:8f42ebd85c7a 50 led2 = 0;
AlexAllen 0:8f42ebd85c7a 51
AlexAllen 0:8f42ebd85c7a 52 led1 = 1;
AlexAllen 0:8f42ebd85c7a 53 wait(0.1);
AlexAllen 0:8f42ebd85c7a 54 led1 = 0;
AlexAllen 0:8f42ebd85c7a 55 wait(0.1);
AlexAllen 0:8f42ebd85c7a 56 }
AlexAllen 0:8f42ebd85c7a 57
AlexAllen 0:8f42ebd85c7a 58 void timer()
AlexAllen 0:8f42ebd85c7a 59 {
AlexAllen 0:8f42ebd85c7a 60 led1 = 1;
AlexAllen 0:8f42ebd85c7a 61 led2 = 1;
AlexAllen 0:8f42ebd85c7a 62 led3 = 1;
AlexAllen 0:8f42ebd85c7a 63 led4 = 1;
AlexAllen 0:8f42ebd85c7a 64
AlexAllen 0:8f42ebd85c7a 65 wait(1);
AlexAllen 0:8f42ebd85c7a 66 led4 = 0;
AlexAllen 0:8f42ebd85c7a 67 wait(1);
AlexAllen 0:8f42ebd85c7a 68 led3 = 0;
AlexAllen 0:8f42ebd85c7a 69 wait(1);
AlexAllen 0:8f42ebd85c7a 70 led2 = 0;
AlexAllen 0:8f42ebd85c7a 71 wait(1);
AlexAllen 0:8f42ebd85c7a 72 led1 = 0;
AlexAllen 0:8f42ebd85c7a 73 wait(1);
AlexAllen 0:8f42ebd85c7a 74 }
AlexAllen 0:8f42ebd85c7a 75
AlexAllen 0:8f42ebd85c7a 76 void flash(int times, float gap)
AlexAllen 0:8f42ebd85c7a 77 {
AlexAllen 0:8f42ebd85c7a 78 for(int i=0; i<times; i++)
AlexAllen 0:8f42ebd85c7a 79 {
AlexAllen 0:8f42ebd85c7a 80 led1 = 1;
AlexAllen 0:8f42ebd85c7a 81 led2 = 1;
AlexAllen 0:8f42ebd85c7a 82 led3 = 1;
AlexAllen 0:8f42ebd85c7a 83 led4 = 1;
AlexAllen 0:8f42ebd85c7a 84
AlexAllen 0:8f42ebd85c7a 85 wait(gap);
AlexAllen 0:8f42ebd85c7a 86
AlexAllen 0:8f42ebd85c7a 87 led1 = 0;
AlexAllen 0:8f42ebd85c7a 88 led2 = 0;
AlexAllen 0:8f42ebd85c7a 89 led3 = 0;
AlexAllen 0:8f42ebd85c7a 90 led4 = 0;
AlexAllen 0:8f42ebd85c7a 91
AlexAllen 0:8f42ebd85c7a 92 wait(gap);
AlexAllen 0:8f42ebd85c7a 93 }
AlexAllen 0:8f42ebd85c7a 94 }
AlexAllen 0:8f42ebd85c7a 95
AlexAllen 0:8f42ebd85c7a 96 void flash1(float gap)
AlexAllen 0:8f42ebd85c7a 97 {
AlexAllen 0:8f42ebd85c7a 98 led1 = 1;
AlexAllen 0:8f42ebd85c7a 99 wait(gap);
AlexAllen 0:8f42ebd85c7a 100 led1 = 0;
AlexAllen 0:8f42ebd85c7a 101 wait(gap);
AlexAllen 0:8f42ebd85c7a 102 }
AlexAllen 0:8f42ebd85c7a 103
AlexAllen 0:8f42ebd85c7a 104 void flash2(float gap)
AlexAllen 0:8f42ebd85c7a 105 {
AlexAllen 0:8f42ebd85c7a 106 led2 = 1;
AlexAllen 0:8f42ebd85c7a 107 wait(gap);
AlexAllen 0:8f42ebd85c7a 108 led2 = 0;
AlexAllen 0:8f42ebd85c7a 109 wait(gap);
AlexAllen 0:8f42ebd85c7a 110 }
AlexAllen 0:8f42ebd85c7a 111
AlexAllen 0:8f42ebd85c7a 112 void errormsg1(float gap)
AlexAllen 0:8f42ebd85c7a 113 {
AlexAllen 0:8f42ebd85c7a 114 while(1)
AlexAllen 0:8f42ebd85c7a 115 {
AlexAllen 0:8f42ebd85c7a 116 led2 = led3 = 0;
AlexAllen 0:8f42ebd85c7a 117 led1 = led4 = 1;
AlexAllen 0:8f42ebd85c7a 118 wait(gap);
AlexAllen 0:8f42ebd85c7a 119 led1 = led4 = 0;
AlexAllen 0:8f42ebd85c7a 120 led2 = led3 = 1;
AlexAllen 0:8f42ebd85c7a 121 wait(gap);
AlexAllen 0:8f42ebd85c7a 122 }
AlexAllen 0:8f42ebd85c7a 123 }
AlexAllen 0:8f42ebd85c7a 124
AlexAllen 0:8f42ebd85c7a 125 void errormsg2(float gap)
AlexAllen 0:8f42ebd85c7a 126 {
AlexAllen 0:8f42ebd85c7a 127 while(1)
AlexAllen 0:8f42ebd85c7a 128 {
AlexAllen 0:8f42ebd85c7a 129 led4 = led3 = 0;
AlexAllen 0:8f42ebd85c7a 130 led1 = led2 = 1;
AlexAllen 0:8f42ebd85c7a 131 wait(gap);
AlexAllen 0:8f42ebd85c7a 132 led1 = led2 = 0;
AlexAllen 0:8f42ebd85c7a 133 led4 = led3 = 1;
AlexAllen 0:8f42ebd85c7a 134 wait(gap);
AlexAllen 0:8f42ebd85c7a 135 }
AlexAllen 0:8f42ebd85c7a 136 }
AlexAllen 0:8f42ebd85c7a 137
AlexAllen 0:8f42ebd85c7a 138 void signal(float gap)
AlexAllen 0:8f42ebd85c7a 139 {
AlexAllen 0:8f42ebd85c7a 140 led1 = 1;
AlexAllen 0:8f42ebd85c7a 141 wait(gap);
AlexAllen 0:8f42ebd85c7a 142 led2 = 1;
AlexAllen 0:8f42ebd85c7a 143 wait(gap);
AlexAllen 0:8f42ebd85c7a 144 led3 = 1;
AlexAllen 0:8f42ebd85c7a 145 wait(gap);
AlexAllen 0:8f42ebd85c7a 146 led4 = 1;
AlexAllen 0:8f42ebd85c7a 147 wait(2.0);
AlexAllen 0:8f42ebd85c7a 148 led1 = led2 = led3 = led4 = 0;
AlexAllen 0:8f42ebd85c7a 149 }