Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
main.cpp@0:0d5190d379d3, 2014-08-25 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Aug 25 13:15:27 2014 +0000
- Revision:
- 0:0d5190d379d3
- Child:
- 1:47680ec5d783
Baseline for PTP (production test program) for the LPC4088 QSB + Experiment Base Board.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:0d5190d379d3 | 1 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 2 | * Includes |
embeddedartists | 0:0d5190d379d3 | 3 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 4 | #include "mbed.h" |
embeddedartists | 0:0d5190d379d3 | 5 | |
embeddedartists | 0:0d5190d379d3 | 6 | #include "MCIFileSystem.h" |
embeddedartists | 0:0d5190d379d3 | 7 | #include "SDFileSystem.h" |
embeddedartists | 0:0d5190d379d3 | 8 | #include "LM75B.h" |
embeddedartists | 0:0d5190d379d3 | 9 | #include "MMA7455.h" |
embeddedartists | 0:0d5190d379d3 | 10 | #include "WM8731.h" |
embeddedartists | 0:0d5190d379d3 | 11 | #include "TextLCD.h" |
embeddedartists | 0:0d5190d379d3 | 12 | #include "DmTftHX8353C.h" |
embeddedartists | 0:0d5190d379d3 | 13 | #include "BubbleDemo.h" |
embeddedartists | 0:0d5190d379d3 | 14 | |
embeddedartists | 0:0d5190d379d3 | 15 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 16 | * Typedefs and defines |
embeddedartists | 0:0d5190d379d3 | 17 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 18 | |
embeddedartists | 0:0d5190d379d3 | 19 | #define BUTTON_PRESSED 0 |
embeddedartists | 0:0d5190d379d3 | 20 | #define BUTTON_RELEASED 1 |
embeddedartists | 0:0d5190d379d3 | 21 | |
embeddedartists | 0:0d5190d379d3 | 22 | #define LED_ON 0 |
embeddedartists | 0:0d5190d379d3 | 23 | #define LED_OFF 1 |
embeddedartists | 0:0d5190d379d3 | 24 | |
embeddedartists | 0:0d5190d379d3 | 25 | #define handleError(__a, __b) printf("Error: %s\n", (__b)); mbed_die() |
embeddedartists | 0:0d5190d379d3 | 26 | |
embeddedartists | 0:0d5190d379d3 | 27 | #define waitForButtonClick() do {while(button.read() == BUTTON_RELEASED); while(button.read() == BUTTON_PRESSED);} while(false) |
embeddedartists | 0:0d5190d379d3 | 28 | |
embeddedartists | 0:0d5190d379d3 | 29 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 30 | * Local variables |
embeddedartists | 0:0d5190d379d3 | 31 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 32 | |
embeddedartists | 0:0d5190d379d3 | 33 | //MCIFileSystem mcifs("mci");//, P4_16); |
embeddedartists | 0:0d5190d379d3 | 34 | SDFileSystem spifs(p5, p6, p7, p8, "spi"); // mosi, miso, sclk, cs |
embeddedartists | 0:0d5190d379d3 | 35 | |
embeddedartists | 0:0d5190d379d3 | 36 | DigitalOut myled(LED1); |
embeddedartists | 0:0d5190d379d3 | 37 | DigitalIn button(p23); |
embeddedartists | 0:0d5190d379d3 | 38 | |
embeddedartists | 0:0d5190d379d3 | 39 | SPI shiftreg(p5, p6, p7); // mosi, miso, sclk, |
embeddedartists | 0:0d5190d379d3 | 40 | DigitalOut shiftregCS(p30); |
embeddedartists | 0:0d5190d379d3 | 41 | |
embeddedartists | 0:0d5190d379d3 | 42 | DigitalOut ledRed(p25); |
embeddedartists | 0:0d5190d379d3 | 43 | DigitalOut ledGreen(p28); |
embeddedartists | 0:0d5190d379d3 | 44 | DigitalOut ledBlue(p26); |
embeddedartists | 0:0d5190d379d3 | 45 | |
embeddedartists | 0:0d5190d379d3 | 46 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 47 | * Local functions |
embeddedartists | 0:0d5190d379d3 | 48 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 49 | |
embeddedartists | 0:0d5190d379d3 | 50 | static void test_micro_sd_card_mci() |
embeddedartists | 0:0d5190d379d3 | 51 | { |
embeddedartists | 0:0d5190d379d3 | 52 | FILE* fp = fopen("/mci/message.txt", "r"); |
embeddedartists | 0:0d5190d379d3 | 53 | if (fp != NULL) { |
embeddedartists | 0:0d5190d379d3 | 54 | char buf[20]; |
embeddedartists | 0:0d5190d379d3 | 55 | int num = fread(buf, 1, sizeof(buf), fp); |
embeddedartists | 0:0d5190d379d3 | 56 | if (num >= 10) { |
embeddedartists | 0:0d5190d379d3 | 57 | buf[10] = '\0'; |
embeddedartists | 0:0d5190d379d3 | 58 | if (strcmp(buf, "eatest2014") == 0) { |
embeddedartists | 0:0d5190d379d3 | 59 | printf("MCI SD Card works!\n"); |
embeddedartists | 0:0d5190d379d3 | 60 | fclose(fp); |
embeddedartists | 0:0d5190d379d3 | 61 | return; |
embeddedartists | 0:0d5190d379d3 | 62 | } |
embeddedartists | 0:0d5190d379d3 | 63 | handleError(STATE_ERR_MCIFS, "Invalid data read from /mci/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 64 | } |
embeddedartists | 0:0d5190d379d3 | 65 | handleError(STATE_ERR_MCIFS, "Failed to read >= 10 bytes from /mci/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 66 | } |
embeddedartists | 0:0d5190d379d3 | 67 | handleError(STATE_ERR_MCIFS, "Failed to open /mci/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 68 | } |
embeddedartists | 0:0d5190d379d3 | 69 | |
embeddedartists | 0:0d5190d379d3 | 70 | static void test_micro_sd_card_spi() |
embeddedartists | 0:0d5190d379d3 | 71 | { |
embeddedartists | 0:0d5190d379d3 | 72 | FILE* fp = fopen("/spi/message.txt", "r"); |
embeddedartists | 0:0d5190d379d3 | 73 | if (fp != NULL) { |
embeddedartists | 0:0d5190d379d3 | 74 | char buf[20]; |
embeddedartists | 0:0d5190d379d3 | 75 | int num = fread(buf, 1, sizeof(buf), fp); |
embeddedartists | 0:0d5190d379d3 | 76 | if (num >= 10) { |
embeddedartists | 0:0d5190d379d3 | 77 | buf[10] = '\0'; |
embeddedartists | 0:0d5190d379d3 | 78 | if (strcmp(buf, "eatest2014") == 0) { |
embeddedartists | 0:0d5190d379d3 | 79 | printf("SPI SD Card works!\n"); |
embeddedartists | 0:0d5190d379d3 | 80 | fclose(fp); |
embeddedartists | 0:0d5190d379d3 | 81 | return; |
embeddedartists | 0:0d5190d379d3 | 82 | } |
embeddedartists | 0:0d5190d379d3 | 83 | handleError(STATE_ERR_SPIFS, "Invalid data read from /spi/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 84 | } |
embeddedartists | 0:0d5190d379d3 | 85 | handleError(STATE_ERR_SPIFS, "Failed to read >= 10 bytes from /spi/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 86 | } |
embeddedartists | 0:0d5190d379d3 | 87 | handleError(STATE_ERR_SPIFS, "Failed to open /spi/message.txt\n"); |
embeddedartists | 0:0d5190d379d3 | 88 | } |
embeddedartists | 0:0d5190d379d3 | 89 | |
embeddedartists | 0:0d5190d379d3 | 90 | static void test_acc() |
embeddedartists | 0:0d5190d379d3 | 91 | { |
embeddedartists | 0:0d5190d379d3 | 92 | MMA7455 sensor(P0_27, P0_28); |
embeddedartists | 0:0d5190d379d3 | 93 | |
embeddedartists | 0:0d5190d379d3 | 94 | //Try to initialize the accelerometer |
embeddedartists | 0:0d5190d379d3 | 95 | if (!sensor.setMode(MMA7455::ModeMeasurement)) { |
embeddedartists | 0:0d5190d379d3 | 96 | handleError(STATE_ERR_ACC, "Unable to set mode for MMA7455!\n"); |
embeddedartists | 0:0d5190d379d3 | 97 | } |
embeddedartists | 0:0d5190d379d3 | 98 | |
embeddedartists | 0:0d5190d379d3 | 99 | printf("Put on flat surface and press button to calibrate!\n"); |
embeddedartists | 0:0d5190d379d3 | 100 | while (button.read() != BUTTON_PRESSED) {} |
embeddedartists | 0:0d5190d379d3 | 101 | while (button.read() == BUTTON_PRESSED) {} |
embeddedartists | 0:0d5190d379d3 | 102 | |
embeddedartists | 0:0d5190d379d3 | 103 | if (!sensor.calibrate()) { |
embeddedartists | 0:0d5190d379d3 | 104 | handleError(STATE_ERR_ACC, "Failed to calibrate MMA7455!\n"); |
embeddedartists | 0:0d5190d379d3 | 105 | } |
embeddedartists | 0:0d5190d379d3 | 106 | |
embeddedartists | 0:0d5190d379d3 | 107 | printf("Printing values for the next 5 seconds...\n"); |
embeddedartists | 0:0d5190d379d3 | 108 | int x=0, y=0, z=0; |
embeddedartists | 0:0d5190d379d3 | 109 | |
embeddedartists | 0:0d5190d379d3 | 110 | Timer t; |
embeddedartists | 0:0d5190d379d3 | 111 | t.start(); |
embeddedartists | 0:0d5190d379d3 | 112 | while (t.read() < 6) { |
embeddedartists | 0:0d5190d379d3 | 113 | if (!sensor.read(x, y, z)) { |
embeddedartists | 0:0d5190d379d3 | 114 | handleError(STATE_ERR_ACC, "Failed to read accelerometer data!\n"); |
embeddedartists | 0:0d5190d379d3 | 115 | } |
embeddedartists | 0:0d5190d379d3 | 116 | printf("ACC: x,y,z = {%5d, %5d, %5d}\n", x, y, z); |
embeddedartists | 0:0d5190d379d3 | 117 | } |
embeddedartists | 0:0d5190d379d3 | 118 | printf("Done with ACC tests!\n"); |
embeddedartists | 0:0d5190d379d3 | 119 | } |
embeddedartists | 0:0d5190d379d3 | 120 | |
embeddedartists | 0:0d5190d379d3 | 121 | static void test_lm75() |
embeddedartists | 0:0d5190d379d3 | 122 | { |
embeddedartists | 0:0d5190d379d3 | 123 | //Create an LM75B object at 0x92/0x93 (ADDRESS_1) |
embeddedartists | 0:0d5190d379d3 | 124 | LM75B sensor(P0_27, P0_28, LM75B::ADDRESS_1); |
embeddedartists | 0:0d5190d379d3 | 125 | |
embeddedartists | 0:0d5190d379d3 | 126 | //Try to open the LM75B |
embeddedartists | 0:0d5190d379d3 | 127 | if (sensor.open()) { |
embeddedartists | 0:0d5190d379d3 | 128 | printf("LM75 Device detected!\n"); |
embeddedartists | 0:0d5190d379d3 | 129 | |
embeddedartists | 0:0d5190d379d3 | 130 | int i = 10; |
embeddedartists | 0:0d5190d379d3 | 131 | while (i--) { |
embeddedartists | 0:0d5190d379d3 | 132 | //Print the current temperature |
embeddedartists | 0:0d5190d379d3 | 133 | printf("Temp = %.3f\n", (float)sensor); |
embeddedartists | 0:0d5190d379d3 | 134 | |
embeddedartists | 0:0d5190d379d3 | 135 | //Sleep for 0.5 seconds |
embeddedartists | 0:0d5190d379d3 | 136 | wait(0.5); |
embeddedartists | 0:0d5190d379d3 | 137 | } |
embeddedartists | 0:0d5190d379d3 | 138 | } else { |
embeddedartists | 0:0d5190d379d3 | 139 | handleError(STATE_ERR_LM75, "LM75 Device not detected!\n"); |
embeddedartists | 0:0d5190d379d3 | 140 | } |
embeddedartists | 0:0d5190d379d3 | 141 | } |
embeddedartists | 0:0d5190d379d3 | 142 | |
embeddedartists | 0:0d5190d379d3 | 143 | static void test_trimpot() |
embeddedartists | 0:0d5190d379d3 | 144 | { |
embeddedartists | 0:0d5190d379d3 | 145 | AnalogIn trimpot(p15); |
embeddedartists | 0:0d5190d379d3 | 146 | |
embeddedartists | 0:0d5190d379d3 | 147 | printf("Reading trimpot for 5 seconds...\n"); |
embeddedartists | 0:0d5190d379d3 | 148 | |
embeddedartists | 0:0d5190d379d3 | 149 | for (int i = 0; i < 50; i++) { |
embeddedartists | 0:0d5190d379d3 | 150 | printf("Trimpot = %.3f\n", trimpot.read()); |
embeddedartists | 0:0d5190d379d3 | 151 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 152 | } |
embeddedartists | 0:0d5190d379d3 | 153 | } |
embeddedartists | 0:0d5190d379d3 | 154 | |
embeddedartists | 0:0d5190d379d3 | 155 | static void outputShiftReg(uint8_t val) |
embeddedartists | 0:0d5190d379d3 | 156 | { |
embeddedartists | 0:0d5190d379d3 | 157 | shiftregCS = 0; |
embeddedartists | 0:0d5190d379d3 | 158 | shiftreg.write(val); |
embeddedartists | 0:0d5190d379d3 | 159 | shiftregCS = 1; |
embeddedartists | 0:0d5190d379d3 | 160 | } |
embeddedartists | 0:0d5190d379d3 | 161 | static void test_shiftreg() |
embeddedartists | 0:0d5190d379d3 | 162 | { |
embeddedartists | 0:0d5190d379d3 | 163 | outputShiftReg(0x1); |
embeddedartists | 0:0d5190d379d3 | 164 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 165 | outputShiftReg(0x2); |
embeddedartists | 0:0d5190d379d3 | 166 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 167 | outputShiftReg(0x4); |
embeddedartists | 0:0d5190d379d3 | 168 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 169 | outputShiftReg(0x8); |
embeddedartists | 0:0d5190d379d3 | 170 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 171 | outputShiftReg(0x10); |
embeddedartists | 0:0d5190d379d3 | 172 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 173 | outputShiftReg(0x20); |
embeddedartists | 0:0d5190d379d3 | 174 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 175 | outputShiftReg(0x40); |
embeddedartists | 0:0d5190d379d3 | 176 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 177 | outputShiftReg(0x80); |
embeddedartists | 0:0d5190d379d3 | 178 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 179 | outputShiftReg(0x40); |
embeddedartists | 0:0d5190d379d3 | 180 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 181 | outputShiftReg(0x20); |
embeddedartists | 0:0d5190d379d3 | 182 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 183 | outputShiftReg(0x10); |
embeddedartists | 0:0d5190d379d3 | 184 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 185 | outputShiftReg(0x8); |
embeddedartists | 0:0d5190d379d3 | 186 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 187 | outputShiftReg(0x4); |
embeddedartists | 0:0d5190d379d3 | 188 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 189 | outputShiftReg(0x2); |
embeddedartists | 0:0d5190d379d3 | 190 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 191 | outputShiftReg(0x1); |
embeddedartists | 0:0d5190d379d3 | 192 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 193 | outputShiftReg(0x0); |
embeddedartists | 0:0d5190d379d3 | 194 | } |
embeddedartists | 0:0d5190d379d3 | 195 | |
embeddedartists | 0:0d5190d379d3 | 196 | |
embeddedartists | 0:0d5190d379d3 | 197 | static void test_joystick() |
embeddedartists | 0:0d5190d379d3 | 198 | { |
embeddedartists | 0:0d5190d379d3 | 199 | DigitalIn up(p32);//p39); |
embeddedartists | 0:0d5190d379d3 | 200 | DigitalIn down(p38);//p32); |
embeddedartists | 0:0d5190d379d3 | 201 | DigitalIn left(p39);//p38); |
embeddedartists | 0:0d5190d379d3 | 202 | DigitalIn right(p37); |
embeddedartists | 0:0d5190d379d3 | 203 | DigitalIn center(p31); |
embeddedartists | 0:0d5190d379d3 | 204 | |
embeddedartists | 0:0d5190d379d3 | 205 | printf("Reading joystick for 10 seconds or all directions...\n"); |
embeddedartists | 0:0d5190d379d3 | 206 | uint16_t mask = 0; |
embeddedartists | 0:0d5190d379d3 | 207 | |
embeddedartists | 0:0d5190d379d3 | 208 | for (int i = 0; i < 100; i++) { |
embeddedartists | 0:0d5190d379d3 | 209 | bool line = false; |
embeddedartists | 0:0d5190d379d3 | 210 | if (up.read() == 0) { printf("UP "); line = true; mask |= 0x01; } |
embeddedartists | 0:0d5190d379d3 | 211 | if (down.read() == 0) { printf("DOWN "); line = true; mask |= 0x02; } |
embeddedartists | 0:0d5190d379d3 | 212 | if (left.read() == 0) { printf("LEFT "); line = true; mask |= 0x04; } |
embeddedartists | 0:0d5190d379d3 | 213 | if (right.read() == 0) { printf("RIGHT "); line = true; mask |= 0x08; } |
embeddedartists | 0:0d5190d379d3 | 214 | if (center.read() == 0) { printf("CENTER ");line = true; mask |= 0x10; } |
embeddedartists | 0:0d5190d379d3 | 215 | if (line) { |
embeddedartists | 0:0d5190d379d3 | 216 | printf("\n"); |
embeddedartists | 0:0d5190d379d3 | 217 | } |
embeddedartists | 0:0d5190d379d3 | 218 | if (mask == 0x1F) { |
embeddedartists | 0:0d5190d379d3 | 219 | printf("All directions tested. Done!\n"); |
embeddedartists | 0:0d5190d379d3 | 220 | break; |
embeddedartists | 0:0d5190d379d3 | 221 | } |
embeddedartists | 0:0d5190d379d3 | 222 | wait(0.1); |
embeddedartists | 0:0d5190d379d3 | 223 | } |
embeddedartists | 0:0d5190d379d3 | 224 | } |
embeddedartists | 0:0d5190d379d3 | 225 | |
embeddedartists | 0:0d5190d379d3 | 226 | static void test_rgb() |
embeddedartists | 0:0d5190d379d3 | 227 | { |
embeddedartists | 0:0d5190d379d3 | 228 | printf("All off. Press button to continue\n"); |
embeddedartists | 0:0d5190d379d3 | 229 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 230 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 231 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 232 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 233 | |
embeddedartists | 0:0d5190d379d3 | 234 | printf("RED on. Press button to continue\n"); |
embeddedartists | 0:0d5190d379d3 | 235 | ledRed = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 236 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 237 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 238 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 239 | |
embeddedartists | 0:0d5190d379d3 | 240 | printf("GREEN on. Press button to continue\n"); |
embeddedartists | 0:0d5190d379d3 | 241 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 242 | ledGreen = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 243 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 244 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 245 | |
embeddedartists | 0:0d5190d379d3 | 246 | printf("BLUE on. Press button to continue\n"); |
embeddedartists | 0:0d5190d379d3 | 247 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 248 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 249 | ledBlue = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 250 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 251 | |
embeddedartists | 0:0d5190d379d3 | 252 | printf("All on. Press button to continue\n"); |
embeddedartists | 0:0d5190d379d3 | 253 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 254 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 255 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 256 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 257 | } |
embeddedartists | 0:0d5190d379d3 | 258 | |
embeddedartists | 0:0d5190d379d3 | 259 | static void test_audio() |
embeddedartists | 0:0d5190d379d3 | 260 | { |
embeddedartists | 0:0d5190d379d3 | 261 | WM8731 audio(P0_27, P0_28); |
embeddedartists | 0:0d5190d379d3 | 262 | if (!audio.writeCmd(WM8731::REG_R15_RESET, 0x0000)) { |
embeddedartists | 0:0d5190d379d3 | 263 | handleError(STATE_ERR_AUDIO, "Failed to send command to audio codec\n"); |
embeddedartists | 0:0d5190d379d3 | 264 | } |
embeddedartists | 0:0d5190d379d3 | 265 | } |
embeddedartists | 0:0d5190d379d3 | 266 | |
embeddedartists | 0:0d5190d379d3 | 267 | static void test_TextLCD() |
embeddedartists | 0:0d5190d379d3 | 268 | { |
embeddedartists | 0:0d5190d379d3 | 269 | SPI spi_lcd(p5, p6, p7); // MOSI, MISO, SCLK |
embeddedartists | 0:0d5190d379d3 | 270 | TextLCD_SPI lcd(&spi_lcd, p30, TextLCD::LCD16x2); // SPI bus, CS pin, LCD Type ok |
embeddedartists | 0:0d5190d379d3 | 271 | |
embeddedartists | 0:0d5190d379d3 | 272 | lcd.cls(); |
embeddedartists | 0:0d5190d379d3 | 273 | lcd.locate(0, 0); |
embeddedartists | 0:0d5190d379d3 | 274 | lcd.putc('E'); |
embeddedartists | 0:0d5190d379d3 | 275 | lcd.putc('m'); |
embeddedartists | 0:0d5190d379d3 | 276 | lcd.putc('b'); |
embeddedartists | 0:0d5190d379d3 | 277 | lcd.putc('e'); |
embeddedartists | 0:0d5190d379d3 | 278 | lcd.putc('d'); |
embeddedartists | 0:0d5190d379d3 | 279 | lcd.putc('d'); |
embeddedartists | 0:0d5190d379d3 | 280 | lcd.putc('e'); |
embeddedartists | 0:0d5190d379d3 | 281 | lcd.putc('d'); |
embeddedartists | 0:0d5190d379d3 | 282 | lcd.putc(' '); |
embeddedartists | 0:0d5190d379d3 | 283 | lcd.putc('A'); |
embeddedartists | 0:0d5190d379d3 | 284 | lcd.putc('r'); |
embeddedartists | 0:0d5190d379d3 | 285 | lcd.putc('t'); |
embeddedartists | 0:0d5190d379d3 | 286 | lcd.putc('i'); |
embeddedartists | 0:0d5190d379d3 | 287 | lcd.putc('s'); |
embeddedartists | 0:0d5190d379d3 | 288 | lcd.putc('t'); |
embeddedartists | 0:0d5190d379d3 | 289 | lcd.putc('s'); |
embeddedartists | 0:0d5190d379d3 | 290 | lcd.putc('!'); |
embeddedartists | 0:0d5190d379d3 | 291 | lcd.setCursor(TextLCD::CurOff_BlkOn); |
embeddedartists | 0:0d5190d379d3 | 292 | } |
embeddedartists | 0:0d5190d379d3 | 293 | |
embeddedartists | 0:0d5190d379d3 | 294 | static void test_DisplayModule() |
embeddedartists | 0:0d5190d379d3 | 295 | { |
embeddedartists | 0:0d5190d379d3 | 296 | // Test of DM-TFT18-101 display (http://www.displaymodule.com/collections/featured-modules/products/dm-tft18-101) |
embeddedartists | 0:0d5190d379d3 | 297 | DmTftHX8353C tft(p5, p7, p30, p17, p16); // mosi, clk, cs, dc, rst |
embeddedartists | 0:0d5190d379d3 | 298 | tft.init(); |
embeddedartists | 0:0d5190d379d3 | 299 | |
embeddedartists | 0:0d5190d379d3 | 300 | BubbleDemo bubbleDemo(&tft, tft.width(), tft.height()); |
embeddedartists | 0:0d5190d379d3 | 301 | bubbleDemo.run(750, 20); |
embeddedartists | 0:0d5190d379d3 | 302 | } |
embeddedartists | 0:0d5190d379d3 | 303 | |
embeddedartists | 0:0d5190d379d3 | 304 | int main() { |
embeddedartists | 0:0d5190d379d3 | 305 | printf("hello! " __DATE__ " at " __TIME__ "\n"); |
embeddedartists | 0:0d5190d379d3 | 306 | |
embeddedartists | 0:0d5190d379d3 | 307 | shiftregCS = 1; |
embeddedartists | 0:0d5190d379d3 | 308 | button.mode(PullUp); |
embeddedartists | 0:0d5190d379d3 | 309 | |
embeddedartists | 0:0d5190d379d3 | 310 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 311 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 312 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 313 | |
embeddedartists | 0:0d5190d379d3 | 314 | outputShiftReg(0x0); |
embeddedartists | 0:0d5190d379d3 | 315 | |
embeddedartists | 0:0d5190d379d3 | 316 | //startup flash behaviour |
embeddedartists | 0:0d5190d379d3 | 317 | for(int i=0; i<10; i++) |
embeddedartists | 0:0d5190d379d3 | 318 | { |
embeddedartists | 0:0d5190d379d3 | 319 | ledRed = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 320 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 321 | ledRed = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 322 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 323 | } |
embeddedartists | 0:0d5190d379d3 | 324 | wait(1.0); |
embeddedartists | 0:0d5190d379d3 | 325 | for(int i=0; i<10; i++) |
embeddedartists | 0:0d5190d379d3 | 326 | { |
embeddedartists | 0:0d5190d379d3 | 327 | ledGreen = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 328 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 329 | ledGreen = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 330 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 331 | } |
embeddedartists | 0:0d5190d379d3 | 332 | wait(1.0); |
embeddedartists | 0:0d5190d379d3 | 333 | for(int i=0; i<10; i++) |
embeddedartists | 0:0d5190d379d3 | 334 | { |
embeddedartists | 0:0d5190d379d3 | 335 | ledBlue = LED_ON; |
embeddedartists | 0:0d5190d379d3 | 336 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 337 | ledBlue = LED_OFF; |
embeddedartists | 0:0d5190d379d3 | 338 | wait(0.05); |
embeddedartists | 0:0d5190d379d3 | 339 | } |
embeddedartists | 0:0d5190d379d3 | 340 | wait(1.0); |
embeddedartists | 0:0d5190d379d3 | 341 | |
embeddedartists | 0:0d5190d379d3 | 342 | //test_micro_sd_card_mci(); |
embeddedartists | 0:0d5190d379d3 | 343 | // test_micro_sd_card_spi(); |
embeddedartists | 0:0d5190d379d3 | 344 | test_acc(); |
embeddedartists | 0:0d5190d379d3 | 345 | test_lm75(); |
embeddedartists | 0:0d5190d379d3 | 346 | test_trimpot(); |
embeddedartists | 0:0d5190d379d3 | 347 | test_joystick(); |
embeddedartists | 0:0d5190d379d3 | 348 | test_rgb(); |
embeddedartists | 0:0d5190d379d3 | 349 | test_audio(); |
embeddedartists | 0:0d5190d379d3 | 350 | //test_TextLCD(); |
embeddedartists | 0:0d5190d379d3 | 351 | //test_DisplayModule(); |
embeddedartists | 0:0d5190d379d3 | 352 | waitForButtonClick(); |
embeddedartists | 0:0d5190d379d3 | 353 | |
embeddedartists | 0:0d5190d379d3 | 354 | while(1) { |
embeddedartists | 0:0d5190d379d3 | 355 | test_shiftreg(); |
embeddedartists | 0:0d5190d379d3 | 356 | myled = 1; |
embeddedartists | 0:0d5190d379d3 | 357 | wait(0.2); |
embeddedartists | 0:0d5190d379d3 | 358 | myled = 0; |
embeddedartists | 0:0d5190d379d3 | 359 | wait(0.2); |
embeddedartists | 0:0d5190d379d3 | 360 | } |
embeddedartists | 0:0d5190d379d3 | 361 | } |