Team Kryptonite EE300 Keypad Subsystem
Fork of mbed_can_bus_test1 by
main.cpp
- Committer:
- Googlesomething
- Date:
- 2017-12-01
- Revision:
- 1:907c82f7f923
- Parent:
- 0:f4b73d13d381
- Child:
- 2:02021bd6b07e
File content as of revision 1:907c82f7f923:
#include "mbed.h" #include "Keypad.h" Ticker ticker; DigitalOut led1(LED1); DigitalOut led2(LED2); CAN can1(p9,p10); CAN can2(p30,p29); //Declare KeyPad GPIO pins here char Keytable[] = { '1', '2', '3', //row0, p1, mbedpin21 '4', '5', '6', //row1, p2, mbedpin22 '7', '8', '8', //row2, p3, mbedpin23 '*', '0', '#', //row3, p4, mbedpin24 }; //col0, col1, col2 //p5, p6, p7 //mbedpin25, mbedpin26, mbedpin27 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; byte rowPins[ROWS] = {1,2,3,4}; byte colPins[COLS] = {5,6,7}; Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); //Universal ID: 1337 //CAN Message Info char counter = 0; //keypad system CAN test variable char start = '*'; //Start char stop = '#'; //Stop char amp5 = 5; //Digipot char amp4 = 4; //Digipot char amp3 = 3; //Digipot char amp2 = 2; //Digipot char amp1 = 1; //Digipot char sin10Hz = 'q'; //DAC char sin1Hz = 'w'; //DAC char sqr10Hz = 'o'; //DAC char sqr1Hz = 't'; //DAC char saveUSB = 'u'; //ADC char saveLocal = 'l'; //ADC That's an l as in labeorphily //CAN Send (Parameter = message data) void send(char sendMsg) { if(can1.write(CANMessage(1337, &sendMsg, 1))) { printf("Message sent: %d\n", sendMsg); } led1 = !led1; } /* write Switch statements*/ //Setup Choice Switch Statements int setupChoice = NULL; int main() { printf("Please select the desired function:\n1: DAC Setup\n2: DigiPot Setup\n3: ADC Setup\n"); setupChoice = Keypad[keys] switch(setupChoice) { case 1 ://DAC Setup printf("Please choose waveform:\n1: 1Hz, Square Wave\n2: 1Hz Sine Wave\n3: 10Hz, Square Wave\n4: 10Hz, Sine Wave\n5: Return to previous menu.\n"); if (/*Keypad Input*/ == 1) { } else if (/*Keypad Input*/ == 2) { } else if (/*Keypad Input*/ == 3) { } else if (/*Keypad Input*/ == 4) { } else if (/*Keypad Input*/ == 5) { } break; //optional case 2 ://DigiPot Setup statement(s); break; //optional case 3 ://ADC Setup statement(s); break; //Optional default : //Optional statement(s); }; ticker.attach(&send, 1); CANMessage msg; while(1) { if(can2.read(msg)) { printf("Message Recieved: %d\n\n", msg.data[0]); led2 = !led2; } wait(0.2); } }