Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
TestRGBLed.cpp
00001 /* 00002 * Copyright 2013 Embedded Artists AB 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /****************************************************************************** 00018 * Includes 00019 *****************************************************************************/ 00020 00021 #include "mbed.h" 00022 #include "TestRGBLed.h" 00023 00024 /****************************************************************************** 00025 * Defines and typedefs 00026 *****************************************************************************/ 00027 00028 #define LED_ON 0 00029 #define LED_OFF 1 00030 00031 #define BUTTON_PRESSED 0 00032 #define BUTTON_RELEASED 1 00033 00034 /****************************************************************************** 00035 * Public Functions 00036 *****************************************************************************/ 00037 00038 TestRGBLed::TestRGBLed(PinName red, PinName green, PinName blue, PinName button) : 00039 _redPin(red), _greenPin(green), _bluePin(blue), _button(button) { 00040 00041 _button.mode(PullUp); 00042 } 00043 00044 void TestRGBLed::showStartupPattern() { 00045 // Have to create the DigitalOut instances here (as opposed to 00046 // create them in the constructor) as some of the pins are shared 00047 // with other functionality on the LPC4088 Experiment Base Board 00048 DigitalOut ledRed(_redPin); 00049 DigitalOut ledGreen(_greenPin); 00050 DigitalOut ledBlue(_bluePin); 00051 00052 ledRed = LED_OFF; 00053 ledGreen = LED_OFF; 00054 ledBlue = LED_OFF; 00055 00056 #if 1 00057 for (int i = 0; i < 2; i++) { 00058 ledRed = LED_ON; 00059 wait(0.1); 00060 ledRed = LED_OFF; 00061 ledGreen = LED_ON; 00062 wait(0.1); 00063 ledGreen = LED_OFF; 00064 ledBlue = LED_ON; 00065 wait(0.1); 00066 ledBlue = LED_OFF; 00067 } 00068 #else 00069 for(int i=0; i<10; i++) 00070 { 00071 ledRed = LED_ON; 00072 wait(0.05); 00073 ledRed = LED_OFF; 00074 wait(0.05); 00075 } 00076 wait(0.5); 00077 for(int i=0; i<10; i++) 00078 { 00079 ledGreen = LED_ON; 00080 wait(0.05); 00081 ledGreen = LED_OFF; 00082 wait(0.05); 00083 } 00084 wait(0.5); 00085 for(int i=0; i<10; i++) 00086 { 00087 ledBlue = LED_ON; 00088 wait(0.05); 00089 ledBlue = LED_OFF; 00090 wait(0.05); 00091 } 00092 wait(0.5); 00093 #endif 00094 } 00095 00096 void TestRGBLed::showStatus(bool success) { 00097 // Have to create the DigitalOut instances here (as opposed to 00098 // create them in the constructor) as some of the pins are shared 00099 // with other functionality on the LPC4088 Experiment Base Board 00100 DigitalOut ledRed(_redPin); 00101 DigitalOut ledGreen(_greenPin); 00102 DigitalOut ledBlue(_bluePin); 00103 00104 ledRed = LED_OFF; 00105 ledGreen = LED_OFF; 00106 ledBlue = LED_OFF; 00107 if (success) { 00108 ledGreen = LED_ON; 00109 } else { 00110 ledRed = LED_ON; 00111 } 00112 } 00113 00114 void TestRGBLed::waitForButtonClick() { 00115 // wait for button to be pressed 00116 while(_button.read() == BUTTON_RELEASED); 00117 00118 // small delay to avoid contact bounce 00119 wait_ms(40); 00120 00121 // wait for button to be released 00122 while(_button.read() == BUTTON_PRESSED); 00123 } 00124 00125 bool TestRGBLed::runTest() { 00126 // Have to create the DigitalOut instances here (as opposed to 00127 // create them in the constructor) as some of the pins are shared 00128 // with other functionality on the LPC4088 Experiment Base Board 00129 DigitalOut ledRed(_redPin); 00130 DigitalOut ledGreen(_greenPin); 00131 DigitalOut ledBlue(_bluePin); 00132 00133 //printf("LED Tests: All off. Press button to continue\n"); 00134 //ledRed = LED_OFF; 00135 //ledGreen = LED_OFF; 00136 //ledBlue = LED_OFF; 00137 //waitForButtonClick(); 00138 00139 printf("LED Tests: RED on. Press button to continue\n"); 00140 ledRed = LED_ON; 00141 ledGreen = LED_OFF; 00142 ledBlue = LED_OFF; 00143 waitForButtonClick(); 00144 00145 printf("LED Tests: GREEN on. Press button to continue\n"); 00146 ledRed = LED_OFF; 00147 ledGreen = LED_ON; 00148 ledBlue = LED_OFF; 00149 waitForButtonClick(); 00150 00151 printf("LED Tests: BLUE on. Press button to continue\n"); 00152 ledRed = LED_OFF; 00153 ledGreen = LED_OFF; 00154 ledBlue = LED_ON; 00155 waitForButtonClick(); 00156 00157 //printf("LED Tests: All on. Press button to continue\n"); 00158 //ledRed = LED_ON; 00159 //ledGreen = LED_ON; 00160 //ledBlue = LED_ON; 00161 //waitForButtonClick(); 00162 00163 // Turn them off again 00164 ledRed = LED_OFF; 00165 ledGreen = LED_OFF; 00166 ledBlue = LED_OFF; 00167 00168 return true; 00169 } 00170 00171
Generated on Sun Jul 17 2022 08:29:10 by 1.7.2