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:
- 7:860b3a8275cb
- Parent:
- 6:39442d493098
- Child:
- 8:d3d7dca419b3
--- a/src/menu.cpp Mon Dec 03 01:03:14 2018 +0000
+++ b/src/menu.cpp Wed Dec 05 00:20:34 2018 +0000
@@ -29,6 +29,7 @@
#include "Ticker.h"
Ticker drt;
+unsigned int oldTime=0;
/*******************************************************************************
drtInt - Display Refresh Timer interrupt handler
@@ -52,8 +53,28 @@
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);
+ loopTime = masterTimer.read_ms() - oldTime;
+ oldTime = masterTimer.read_ms();
+
+ double v48f = 48*(v48/2048);
+ double v24f = 24*(v48/2048);
+ double v12f = 12*(v48/2048);
+ double i48f = i48/40;
+ double i24f = i24/40;
+ double i12f = i12/40;
+ double pwr_out=v12f*i12f;
+ double pwr_in=v48f*(i48f-0.25);
+ double pwr_eff=100*pwr_out/pwr_in;
+
+ sprintf(strbuf, "V48=%2.2f, I48=%2.2f | V24=%2.2f, I24=%2.2f | V12=%2.2f, I12=%2.2f || loop=%d \r\n", v48f, i48f, v24f, i24f, v12f, i12f, loopTime);
+ sendSerial(strbuf);
+ sprintf(strbuf, "Power Out = %4.1f W, Power In = %4.1f W, ", pwr_out, pwr_in);
+ sendSerial(strbuf);
+ sprintf( strbuf, "%c[34m", 27 ); // ESC=27, Blue Text
+ sendSerial(strbuf);
+ sprintf(strbuf, "Power Efficiency = %2.2f percent\r\n", pwr_eff);
+ sendSerial(strbuf);
+ sprintf( strbuf, "%c[30m", 27 ); // ESC=27, White Text
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);
@@ -94,7 +115,16 @@
// clears terminal and re-draws main menu
void menuRedraw(void){
clrScrn();
- sprintf(strbuf, "Agility Power Systems DCM1 Menu 0.3\r\n");
+
+ sprintf( strbuf, "%c[34m", 27 ); // ESC=27, Blue Text
+ sendSerial(strbuf);
+
+ sprintf(strbuf, "Agility Power Systems DCM1 Menu 0.35\r\n");
+ sendSerial(strbuf);
+
+ sprintf( strbuf, "%c[0m", 27 ); // ESC=27, Normal
+ sendSerial(strbuf);
+ sprintf( strbuf, "%c[30m", 27 ); // ESC=27, White Text
sendSerial(strbuf);
refreshData();