Skip to content

Commit a4b6167

Browse files
committed
display speed and power
1 parent 90ba2e6 commit a4b6167

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/OpenCOVER/plugins/hlrs/TacxFTMS/TacxFTMS.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using namespace opencover;
3232
TacxFTMS::TacxFTMS()
3333
: coVRPlugin(COVER_PLUGIN_NAME)
3434
, coVRNavigationProvider("TacxFTMS", this)
35+
, ui::Owner("Tacx", cover->ui)
3536
{
3637
ftmsData.speed = 0.0;
3738
ftmsData.cadence = 0.0;
@@ -114,6 +115,18 @@ bool TacxFTMS::init() {
114115

115116
std::cerr << "Init FTMS done" << std::endl;
116117
auto retval = coVRMSController::instance()->syncBool(ret);
118+
119+
TacxMenu = new ui::Menu("Tacx", this);
120+
121+
Speed = new ui::Label(TacxMenu, "speed");
122+
Power = new ui::Label(TacxMenu, "power");
123+
124+
Weight = new ui::EditField(TacxMenu, "weight");
125+
Weight->setValue(ftmsControl.weight);
126+
Weight->setCallback([this](const std::string &w) {
127+
ftmsControl.weight = stof(w);
128+
std::cerr << "weight: " << stof(w)<<std::endl;
129+
});
117130
return retval;
118131
}
119132

@@ -178,6 +191,8 @@ bool TacxFTMS::update() {
178191
speed = 0;
179192
}
180193

194+
Speed->setText(std::to_string(ftmsData.speed)+ " km/h");
195+
Power->setText(std::to_string(ftmsData.power)+ " W");
181196
float s = speed * dT;
182197
// fprintf(stderr, "Displacement: %lf Speed: %lf dt: %lf
183198
// Y-acceleration: %lf\n", s, speed, dT, a);

src/OpenCOVER/plugins/hlrs/TacxFTMS/TacxFTMS.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222
#include <cover/input/deviceDiscovery.h>
2323

2424

25+
#include <cover/ui/Button.h>
26+
#include <cover/ui/Action.h>
27+
#include <cover/ui/Menu.h>
28+
#include <cover/ui/EditField.h>
29+
#include <cover/ui/Label.h>
2530
#define MAX_CALLSIGN_LEN 8
2631

32+
using namespace opencover;
33+
using namespace covise;
2734

2835
class UDPComm;
2936

@@ -54,7 +61,7 @@ struct AlpineData
5461

5562
#pragma pack(pop)
5663

57-
class PLUGINEXPORT TacxFTMS : public opencover::coVRPlugin, public opencover::coVRNavigationProvider, public OpenThreads::Thread
64+
class PLUGINEXPORT TacxFTMS : public opencover::coVRPlugin, public opencover::coVRNavigationProvider, public OpenThreads::Thread, public ui::Owner
5865
{
5966
public:
6067
TacxFTMS();
@@ -70,6 +77,11 @@ class PLUGINEXPORT TacxFTMS : public opencover::coVRPlugin, public opencover::co
7077
bool doStop;
7178

7279
private:
80+
81+
ui::Menu *TacxMenu;
82+
ui::Label *Speed;
83+
ui::Label *Power;
84+
ui::EditField *Weight;
7385
float stepSizeUp;
7486
float stepSizeDown;
7587
const float BrakeThreshold = 1.0;

0 commit comments

Comments
 (0)