Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL

Dependencies:   mbed

Committer:
mfwic
Date:
Tue Nov 27 17:47:57 2018 +0000
Revision:
3:d8948c5b2951
Parent:
1:9f8583ba2431
Child:
5:09be5bbb5020
Menu works

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfwic 1:9f8583ba2431 1 //-------------------------------------------------------------------------------
mfwic 1:9f8583ba2431 2 //
mfwic 1:9f8583ba2431 3 // Treehouse Inc.
mfwic 1:9f8583ba2431 4 // Colorado Springs, Colorado
mfwic 1:9f8583ba2431 5 //
mfwic 1:9f8583ba2431 6 // Copyright (c) 2016 by Treehouse Designs Inc.
mfwic 1:9f8583ba2431 7 //
mfwic 1:9f8583ba2431 8 // This code is the property of Treehouse, Inc. (Treehouse) and may not be redistributed
mfwic 1:9f8583ba2431 9 // in any form without prior written permission from the copyright holder, Treehouse.
mfwic 1:9f8583ba2431 10 //
mfwic 1:9f8583ba2431 11 // The above copyright notice and this permission notice shall be included in
mfwic 1:9f8583ba2431 12 // all copies or substantial portions of the Software.
mfwic 1:9f8583ba2431 13 //
mfwic 1:9f8583ba2431 14 //-------------------------------------------------------------------------------
mfwic 1:9f8583ba2431 15 //
mfwic 1:9f8583ba2431 16 // REVISION HISTORY:
mfwic 1:9f8583ba2431 17 //
mfwic 1:9f8583ba2431 18 // $Author: $
mfwic 1:9f8583ba2431 19 // $Rev: $
mfwic 1:9f8583ba2431 20 // $Date: $
mfwic 1:9f8583ba2431 21 // $URL: $
mfwic 1:9f8583ba2431 22 //
mfwic 1:9f8583ba2431 23 //-------------------------------------------------------------------------------
mfwic 1:9f8583ba2431 24
mfwic 1:9f8583ba2431 25 #include "mbed.h"
mfwic 1:9f8583ba2431 26 #include "serial.h"
mfwic 1:9f8583ba2431 27 #include "menu.h"
mfwic 1:9f8583ba2431 28
mfwic 1:9f8583ba2431 29 // clears terminal
mfwic 1:9f8583ba2431 30 void clrScrn(void){
mfwic 1:9f8583ba2431 31 sprintf( strbuf, "%c[2J", 27 ); // ESC=27, Clear screen = [2J
mfwic 1:9f8583ba2431 32 sendSerial(strbuf);
mfwic 1:9f8583ba2431 33 sprintf( strbuf, "%c[f", 27 ); // ESC=27, Move cursor to upper-left corner = [f
mfwic 1:9f8583ba2431 34 sendSerial(strbuf);
mfwic 1:9f8583ba2431 35 }
mfwic 1:9f8583ba2431 36
mfwic 1:9f8583ba2431 37 // clears terminal and re-draws main menu
mfwic 1:9f8583ba2431 38 void menuRedraw(void){
mfwic 1:9f8583ba2431 39 clrScrn();
mfwic 1:9f8583ba2431 40 sprintf(strbuf, "Agility Power Systems DCM1 Menu 0.1");
mfwic 1:9f8583ba2431 41 sendSerial(strbuf);
mfwic 1:9f8583ba2431 42 sprintf(strbuf, "\r\nMULT");
mfwic 1:9f8583ba2431 43 sendSerial(strbuf);
mfwic 1:9f8583ba2431 44 sprintf(strbuf, "\r\nBRDS");
mfwic 1:9f8583ba2431 45 sendSerial(strbuf);
mfwic 1:9f8583ba2431 46 sprintf(strbuf, "\r\nALLOFF");
mfwic 1:9f8583ba2431 47 sendSerial(strbuf);
mfwic 1:9f8583ba2431 48 sprintf(strbuf, "\r\nRUN [xx]");
mfwic 1:9f8583ba2431 49 sendSerial(strbuf);
mfwic 1:9f8583ba2431 50 sprintf(strbuf, "\r\nSTOP");
mfwic 1:9f8583ba2431 51 sendSerial(strbuf);
mfwic 3:d8948c5b2951 52
mfwic 3:d8948c5b2951 53 menuPrompt(MENU_DCM1);
mfwic 3:d8948c5b2951 54 }
mfwic 3:d8948c5b2951 55
mfwic 3:d8948c5b2951 56 // sends carriage return and linefeed and prompt character
mfwic 3:d8948c5b2951 57 void menuPrompt(int menuType)
mfwic 3:d8948c5b2951 58 {
mfwic 3:d8948c5b2951 59 char strMenu[30] ={0};
mfwic 3:d8948c5b2951 60
mfwic 3:d8948c5b2951 61 switch(menuType)
mfwic 3:d8948c5b2951 62 {
mfwic 3:d8948c5b2951 63 case MENU_DCM1: strcpy(strMenu,"DCM1"); break;
mfwic 3:d8948c5b2951 64 //case MENU_DIFFERENTIAL: strcpy(strMenu,"DIFF"); break;
mfwic 3:d8948c5b2951 65 //case MENU_SINGLE: strcpy(strMenu,"SINGLE"); break;
mfwic 3:d8948c5b2951 66 //case MENU_DUAL: strcpy(strMenu,"DUAL"); break;
mfwic 3:d8948c5b2951 67 //case MENU_INVERT: strcpy(strMenu,"INVERT"); break;
mfwic 3:d8948c5b2951 68 //case MENU_SETTINGS: strcpy(strMenu,"SET"); break;
mfwic 3:d8948c5b2951 69 //case MENU_SETTINGS_CHAN1: strcpy(strMenu,"SET CHAN1"); break;
mfwic 3:d8948c5b2951 70 //case MENU_SETTINGS_CHAN2: strcpy(strMenu,"SET CHAN2"); break;
mfwic 3:d8948c5b2951 71 //case MENU_SETTINGS_CLOCK: strcpy(strMenu,"SET CLOCK"); break;
mfwic 3:d8948c5b2951 72 case MENU_CALIBRATE: strcpy(strMenu,"CAL"); break;
mfwic 3:d8948c5b2951 73 case MENU_TEST: strcpy(strMenu,"TEST"); break;
mfwic 3:d8948c5b2951 74 case MENU_MAIN: strcpy(strMenu,"MAIN"); break;
mfwic 3:d8948c5b2951 75 default: strcpy(strMenu,"UNDF"); break;
mfwic 3:d8948c5b2951 76 }
mfwic 3:d8948c5b2951 77
mfwic 3:d8948c5b2951 78 // append the CR,LF and the ready character
mfwic 3:d8948c5b2951 79 if(serialStatus.computer)
mfwic 3:d8948c5b2951 80 {
mfwic 3:d8948c5b2951 81 sendSerial("\r");
mfwic 3:d8948c5b2951 82 }
mfwic 3:d8948c5b2951 83 else
mfwic 3:d8948c5b2951 84 {
mfwic 3:d8948c5b2951 85 // adds a carrot so you know you are talking in terminal
mfwic 3:d8948c5b2951 86 sprintf(strbuf,"\n\r%s>",strMenu);
mfwic 3:d8948c5b2951 87 sendSerial(strbuf);
mfwic 3:d8948c5b2951 88 // sendSerial("\n\r>");
mfwic 3:d8948c5b2951 89 }
mfwic 1:9f8583ba2431 90 }