Test fork nhi
Dependencies: SDFileSystem mbed-rtos mbed emic2
Fork of BAT_senior_design by
buttonArray.cpp
- Committer:
- aismail1997
- Date:
- 2017-11-01
- Revision:
- 21:c5df903f068a
- Parent:
- 20:abbc12fca525
- Child:
- 22:6931917c70cd
File content as of revision 21:c5df903f068a:
#include "mbed.h"
#include "buttonArray.h"
// buttonArray constructor
buttonArray::buttonArray(button b1, button b2, button b3, button b4, button b5, button b6)
: button1(b1), button2(b2), button3(b3), button4(b4), button5(b5), button6(b6) {}
// FUNCTIONS
// map input braille to ascii
// braille respresentation here - https://en.wikipedia.org/wiki/Braille_ASCII
char buttonArray::checkVal()
{
char* input;
char val = NULL;
sprintf(input, "%d%d%d%d%d%d", button1.getPress(), button2.getPress(),
button3.getPress(), button4.getPress(), button5.getPress(), button6.getPress());
if (strcmp(input, "000000") == 0) val = NULL;
if (strcmp(input, "011111") == 0) val = 'A';
if (strcmp(input, "001101") == 0) val = 'M';
if (strcmp(input, "011001") == 0) val = 'O';
// check if reset
if (strcmp(input, "111111") == 0) val = ' ';
return val;
}
// return feedback on which pin to correct
// release buttons
void buttonArray::releaseButtons()
{
if (button1.getPress()) {
button1.moveServoOut();
button1.setState(3);
button1.setPress(0);
}
}
//
