Skip to content

Commit

Permalink
fps graph enable/disable
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Dec 11, 2021
1 parent 4b729c7 commit 5c14ee5
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/bb3/conf/eez/gui_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@
#define EEZ_CONF_COLOR_ID_BACKDROP eez::gui::COLOR_ID_BACKDROP

#define EEZ_CONF_GUI_CALC_FPS
#define EEZ_CONF_GUI_DRAW_FPS_GRAPH
#define EEZ_CONF_STYLE_ID_FPS_GRAPH STYLE_ID_FPS_GRAPH
1 change: 0 additions & 1 deletion src/bb3/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <bb3/keyboard.h>
#include <bb3/mouse.h>
#include <eez/gui/gui.h>
#include <eez/gui/display.h>
#include <bb3/psu/psu.h>
#include <bb3/psu/gui/psu.h>

Expand Down
1 change: 0 additions & 1 deletion src/bb3/mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include <eez/gui/gui.h>
#include <eez/gui/display.h>

#include <bb3/keyboard.h>
#include <bb3/mouse.h>
Expand Down
19 changes: 15 additions & 4 deletions src/bb3/psu/scpi/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <main.h>
#endif

#include <eez/gui/gui.h>

#include <bb3/firmware.h>
#include <bb3/system.h>
#include <eez/alloc.h>
Expand All @@ -37,9 +39,7 @@
#include <bb3/psu/ontime.h>
#include <bb3/psu/scpi/psu.h>
#include <bb3/psu/event_queue.h>
#if OPTION_DISPLAY
#include <bb3/psu/gui/psu.h>
#endif

#include <bb3/mcu/eeprom.h>

Expand Down Expand Up @@ -142,8 +142,19 @@ scpi_result_t scpi_cmd_debug(scpi_t *context) {
}
else if (cmd == 34) {
g_startTime = millis();
} else {
SCPI_ErrorPush(context, SCPI_ERROR_HARDWARE_MISSING);
}
#if defined(EEZ_CONF_GUI_CALC_FPS) && defined(EEZ_CONF_STYLE_ID_FPS_GRAPH)
else if (cmd == 35) {
using namespace eez::gui;
using namespace eez::gui::display;
g_drawFpsGraphEnabled = !g_drawFpsGraphEnabled;
g_calcFpsEnabled = g_drawFpsGraphEnabled;
refreshScreen();
return SCPI_RES_OK;
}
#endif
else {
SCPI_ErrorPush(context, SCPI_ERROR_PARAMETER_NOT_ALLOWED);
return SCPI_RES_ERR;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/bb3/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ EEZ_MESSAGE_QUEUE_DECLARE(highPriority, {

void lowPriorityThreadMainLoop(void *);

EEZ_THREAD_DECLARE(lowPriority, Normal, 12 * 1024);
EEZ_THREAD_DECLARE(lowPriority, Normal, 24 * 1024);

EEZ_MESSAGE_QUEUE_DECLARE(lowPriority, {
LowPriorityThreadMessage type;
Expand Down
3 changes: 1 addition & 2 deletions src/bb3/usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
#include <bb3/mouse.h>
#include <bb3/usb.h>

#include <eez/gui/gui.h>
#include <bb3/gui/thread.h>

#include <bb3/psu/psu.h>
#include <bb3/psu/persist_conf.h>
#include <bb3/psu/serial_psu.h>

#include <eez/gui/display.h>

int g_usbMode = USB_MODE_DISABLED;
int g_otgMode = USB_MODE_DISABLED;
int g_usbDeviceClass = USB_DEVICE_CLASS_VIRTUAL_COM_PORT;
Expand Down
28 changes: 20 additions & 8 deletions src/eez/gui/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ void endRendering() {
}
#endif

#ifdef EEZ_CONF_GUI_CALC_FPS
#ifdef EEZ_CONF_GUI_DRAW_FPS_GRAPH
setDirty();
#endif
#if defined(EEZ_CONF_GUI_CALC_FPS) && defined(EEZ_CONF_STYLE_ID_FPS_GRAPH)
if (g_drawFpsGraphEnabled) {
setDirty();
}
#endif

if (isDirty()) {
Expand Down Expand Up @@ -595,10 +595,10 @@ void endRendering() {
bitBlt(g_buffers[bufferIndex].bufferPointer, nullptr, sx, sy, x2 - x1 + 1, y2 - y1 + 1, x1, y1, buffer.opacity);
}

#ifdef EEZ_CONF_GUI_CALC_FPS
#ifdef EEZ_CONF_GUI_DRAW_FPS_GRAPH
drawFpsGraph(getDisplayWidth() - 64 - 4, 4, 64, 32, getStyle(EEZ_CONF_STYLE_ID_FPS_GRAPH));
#endif
#if defined(EEZ_CONF_GUI_CALC_FPS) && defined(EEZ_CONF_STYLE_ID_FPS_GRAPH)
if (g_drawFpsGraphEnabled) {
drawFpsGraph(getDisplayWidth() - 64 - 4, 4, 64, 32, getStyle(EEZ_CONF_STYLE_ID_FPS_GRAPH));
}
#endif

#if OPTION_KEYBOARD
Expand All @@ -612,12 +612,20 @@ void endRendering() {
}

#ifdef EEZ_CONF_GUI_CALC_FPS
bool g_calcFpsEnabled;
#if defined(EEZ_CONF_STYLE_ID_FPS_GRAPH)
bool g_drawFpsGraphEnabled;
#endif
uint32_t g_fpsValues[NUM_FPS_VALUES];
uint32_t g_fpsAvg;
static uint32_t g_fpsTotal;
static uint32_t g_lastTimeFPS;

void startCalcFPS() {
if (!g_calcFpsEnabled) {
return;
}

// calculate last FPS value
g_fpsTotal -= g_fpsValues[0];

Expand All @@ -639,6 +647,10 @@ void startCalcFPS() {
}

void endCalcFPS() {
if (!g_calcFpsEnabled) {
return;
}

g_lastTimeFPS = millis();
}

Expand Down
4 changes: 4 additions & 0 deletions src/eez/gui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ void *getBufferPointer();
const uint8_t * takeScreenshot();

#ifdef EEZ_CONF_GUI_CALC_FPS
extern bool g_calcFpsEnabled;
#if defined(EEZ_CONF_STYLE_ID_FPS_GRAPH)
extern bool g_drawFpsGraphEnabled;
#endif
extern uint32_t g_fpsAvg;
void drawFpsGraph(int x, int y, int w, int h, const Style *style);
#endif
Expand Down
3 changes: 1 addition & 2 deletions src/eez/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

#pragma once

#include <eez/gui_conf.h>
#include <eez/gui/assets.h>
#include <eez/gui/page.h>

#include <eez/gui/display.h>
#include <eez/gui_conf.h>

enum {
PAGE_ID_NONE = 0,
Expand Down
12 changes: 7 additions & 5 deletions src/eez/platform/simulator/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <eez/mouse.h>
#endif

#include <eez/gui/display.h>
#include <eez/gui/display-private.h>

using namespace eez::gui;
Expand Down Expand Up @@ -265,6 +264,10 @@ void sync() {
return;
}

#ifdef EEZ_CONF_GUI_CALC_FPS
startCalcFPS();
#endif

if (g_mainWindow == nullptr) {
init();
}
Expand All @@ -276,9 +279,9 @@ void sync() {
}
clearDirty();
#ifdef EEZ_CONF_GUI_CALC_FPS
calcFPS();
endCalcFPS();
#endif
return;
return;
}

if (g_takeScreenshot) {
Expand All @@ -298,9 +301,8 @@ void sync() {
}

#ifdef EEZ_CONF_GUI_CALC_FPS
calcFPS();
endCalcFPS();
#endif

}

void finishAnimation() {
Expand Down
11 changes: 5 additions & 6 deletions src/eez/platform/stm32/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <eez/os.h>

#include <eez/gui/gui.h>
#include <eez/gui/display.h>
#include <eez/gui/display-private.h>

#include <eez/platform/stm32/display.h>
Expand Down Expand Up @@ -435,11 +434,11 @@ void sync() {
return;
}

static const uint32_t VSYNC_PERIOD = 12;
uint32_t time = millis();
if (time - g_lastSyncTime < VSYNC_PERIOD) {
osDelay(VSYNC_PERIOD - (time - g_lastSyncTime));
}
// static const uint32_t VSYNC_PERIOD = 12;
// uint32_t time = millis();
// if (time - g_lastSyncTime < VSYNC_PERIOD) {
// osDelay(VSYNC_PERIOD - (time - g_lastSyncTime));
// }

if (isDirty()) {
clearDirty();
Expand Down

0 comments on commit 5c14ee5

Please sign in to comment.