David Estévez
/
ABBlind_hardware_test
Hardware test for ABBlind pedal shield
Revision 0:a0be5f15a662, committed 2015-12-05
- Comitter:
- def
- Date:
- Sat Dec 05 20:52:50 2015 +0000
- Child:
- 1:33de2dfc6e25
- Commit message:
- First version of test program
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ABBlind.lib Sat Dec 05 20:52:50 2015 +0000 @@ -0,0 +1,1 @@ +ABBlind#f7490f118213
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PinDetect.lib Sat Dec 05 20:52:50 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/xeta05/code/PinDetect/#cb6051b90a52
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 05 20:52:50 2015 +0000 @@ -0,0 +1,110 @@ +/********************************************************** + * ABBlind test + ********************************************************** + * + * Program to test that all the hardware works correctly + * + ********************************************************** + * Author: David Estévez Fernández (DEF) + * License: GPLv3 + * + * A UC3Music project! Check out our website: + * http://uc3music.github.io/ + */ +#include "mbed.h" +#include "PinDetect.h" + + +//-- Peripherals definition +DigitalOut LED_01[] = {P1_24, P1_17}; +DigitalOut LED_02[] = {P1_27, P1_25}; +DigitalOut LED_03[] = {P0_9, P0_2}; +DigitalOut AUDIO_SWITCH(P0_14); +PinDetect PUSH_BUTTON(P0_17, PullUp); + +//-- Other constant definitions +static const uint8_t COLOR1 = 0; +static const uint8_t COLOR2 = 1; + + +//-- Other definitions +volatile uint8_t state = 0; + +void start_sequence(uint16_t ms = 200) +{ + DigitalOut* leds[] = {&LED_01[0], &LED_02[0], + &LED_03[0], &LED_01[1], + &LED_02[1], &LED_03[1]}; + + for (uint8_t i = 0; i < 6; i++) + { + for (uint8_t j = 0; j < 6; j++) + { + i == j ? *leds[j] = 1 : *leds[j] = 0; + } + wait_ms(ms); + } +} + +void button_pressed() +{ + state = (state+1) % 4; +} + + +int main() { + + //-- Setup button + PUSH_BUTTON.attach_asserted(&button_pressed()); + + //- Setup audio switch + AUDIO_SWITCH = 0; + + start_sequence(); + start_sequence(); + + while(1) { + if (state == 0) + { + LED_01[0] = 0; + LED_02[0] = 0; + LED_03[0] = 0; + LED_01[1] = 0; + LED_02[1] = 0; + LED_03[1] = 0; + AUDIO_SWITCH = 0; + } + else if (state == 1) + { + LED_01[0] = 1; + LED_02[0] = 1; + LED_03[0] = 1; + LED_01[1] = 0; + LED_02[1] = 0; + LED_03[1] = 0; + AUDIO_SWITCH = 0; + } + else if (state == 2) + { + LED_01[0] = 0; + LED_02[0] = 0; + LED_03[0] = 0; + LED_01[1] = 1; + LED_02[1] = 1; + LED_03[1] = 1; + AUDIO_SWITCH = 0; + } + else if (state == 3) + { + LED_01[0] = 1; + LED_02[0] = 1; + LED_03[0] = 1; + LED_01[1] = 1; + LED_02[1] = 1; + LED_03[1] = 1; + AUDIO_SWITCH = 0; + } + + wait_ms(500); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 05 20:52:50 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file