Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: src/menu.cpp
- Revision:
- 6:39442d493098
- Parent:
- 5:09be5bbb5020
- Child:
- 7:860b3a8275cb
diff -r 09be5bbb5020 -r 39442d493098 src/menu.cpp
--- a/src/menu.cpp Sat Dec 01 00:08:53 2018 +0000
+++ b/src/menu.cpp Mon Dec 03 01:03:14 2018 +0000
@@ -23,9 +23,63 @@
//-------------------------------------------------------------------------------
#include "mbed.h"
+#include "globals.h"
#include "serial.h"
#include "menu.h"
+#include "Ticker.h"
+Ticker drt;
+
+/*******************************************************************************
+ drtInt - Display Refresh Timer interrupt handler
+*******************************************************************************/
+// real time clock interrupt to flash the LED
+void drtInt(void)
+{
+ updateReady = TRUE;
+}
+
+/*******************************************************************************
+ initDRT - Create Display Refresh Timer interrupt
+*******************************************************************************/
+// initialize display refresh timer (DRT)
+void initDRT(void)
+{
+ drt.attach_us(&drtInt, UPDATE_REFRESH_DELAY_US);
+}
+
+/*******************************************************************************
+ refreshData - Refresh voltage and current readings to the terminal
+*******************************************************************************/
+void refreshData(void){
+ //loopTime = masterTimer.read_ms() - loopTime;
+ sprintf(strbuf, "V48=%d, I48=%d | V24=%d, I24=%d | V12=%d, I12=%d || loop=%d\r\n", v48, i48, v24, i24, v12, i12, loopTime);
+ sendSerial(strbuf);
+ //sprintf(strbuf, "thermCode=%d, binCode=%d", thermCode[17], binCode[6]);
+ sprintf(strbuf, "wr_out_code=%d, en_out_code=%d", wr_out_code, en_out_code);
+ sendSerial(strbuf);
+}
+
+/*******************************************************************************
+ updateTerminal - Save cursor, write data, restore cursor.
+*******************************************************************************/
+void updateTerminal(void){
+ //get cursor pos, store in CUR_POS
+ sprintf( strbuf, "%c7", 27 ); // ESC=27, Save cursor position = [s
+ sendSerial(strbuf);
+ //move cursor to DATA_ROW
+ sprintf( strbuf, "%c[2;0f", 27 ); // ESC=27, Move cursor position = [line;columnf
+ sendSerial(strbuf);
+ //write data
+ refreshData();
+ //move cursor to CUR_POS
+ sprintf( strbuf, "%c8", 27 ); // ESC=27, Save cursor position = [s
+ sendSerial(strbuf);
+}
+
+/*******************************************************************************
+ clrScrn - clears terminal and moves cursor to upper-left corner
+*******************************************************************************/
// clears terminal
void clrScrn(void){
sprintf( strbuf, "%c[2J", 27 ); // ESC=27, Clear screen = [2J
@@ -34,11 +88,17 @@
sendSerial(strbuf);
}
+/*******************************************************************************
+ menuRedraw - Write menu to terminal
+*******************************************************************************/
// clears terminal and re-draws main menu
void menuRedraw(void){
clrScrn();
- sprintf(strbuf, "Agility Power Systems DCM1 Menu 0.3");
+ sprintf(strbuf, "Agility Power Systems DCM1 Menu 0.3\r\n");
sendSerial(strbuf);
+
+ refreshData();
+
sprintf(strbuf, "\r\nMULT");
sendSerial(strbuf);
sprintf(strbuf, "\r\nBRDS");
@@ -53,6 +113,9 @@
menuPrompt(MENU_DCM1);
}
+/*******************************************************************************
+ menuPrompt - Write menu prompt to terminal
+*******************************************************************************/
// sends carriage return and linefeed and prompt character
void menuPrompt(int menuType)
{