implemented connectivity to startpad
This commit is contained in:
parent
2288064413
commit
6d44da2a25
4 changed files with 46 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <QAuthenticator>
|
||||
#include <QDesktopServices>
|
||||
#include <QDateTime>
|
||||
#include <QtDebug>
|
||||
|
||||
typedef struct strReturnData{
|
||||
int status_code;
|
||||
|
|
|
@ -39,7 +39,7 @@ Item {
|
|||
startpadConn.pushed()
|
||||
|
||||
}
|
||||
if(root.state === "RUNNING"){
|
||||
if(root.state === "RUNNING" || root.state === "STARTING"){
|
||||
running_refresh_timer.start()
|
||||
}
|
||||
}
|
||||
|
|
35
qml/main.qml
35
qml/main.qml
|
@ -79,7 +79,16 @@ Window {
|
|||
|
||||
StartpadConn {
|
||||
id: startpadConn
|
||||
|
||||
onPushed: {
|
||||
console.log("startpad triggered")
|
||||
var offset = _cppStartpadConn.get("offset")
|
||||
var last_pressed = _cppStartpadConn.get("lastpressed")
|
||||
var trigger_time = (last_pressed + offset)
|
||||
root.last_run.react_time = trigger_time - root.startTime
|
||||
if(trigger_time - root.startTime <= 0){
|
||||
root.stop("false")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
@ -167,6 +176,7 @@ Window {
|
|||
onPlayingChanged: {
|
||||
if(!playing && root.state==="STARTING"){
|
||||
root.startTime = _cppBuzzerConn.get("currtime")
|
||||
console.log(root.startTime)
|
||||
|
||||
root.currTime = _cppBuzzerConn.get("currtime")
|
||||
time.text = ( ( root.currTime - root.startTime ) / 1000 ).toFixed(3) + " sec"
|
||||
|
@ -210,6 +220,28 @@ Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: react_time
|
||||
property int rtime: root.last_run.react_time
|
||||
text: qsTr("reaction time (ms): ") + Math.round(rtime)
|
||||
opacity: (root.state === "RUNNING" || root.sate === "STARTING" || root.state === "STOPPED") && rtime !== 0 ? 1:0
|
||||
color: StyleSettings.textColor
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: time.bottom
|
||||
topMargin: parent.height * 0.1
|
||||
}
|
||||
Timer {
|
||||
running: root.state === "RUNNING" || root.sate === "STARTING" || root.state === "STOPPED"
|
||||
repeat: true
|
||||
interval: 1
|
||||
onTriggered: {
|
||||
react_time.rtime = root.last_run.react_time
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ConnectionIcon {
|
||||
|
@ -674,6 +706,7 @@ Window {
|
|||
|
||||
function reset(){
|
||||
root.state = "IDLE"
|
||||
root.last_run.react_time = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,8 +105,8 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
connectToDatabase();
|
||||
BuzzerConn * pBuzzerConn = new BuzzerConn(nullptr, QUrl("http://api.itsblue.de/test/buzzerem.php"));
|
||||
BuzzerConn * pStartpadConn = new BuzzerConn(nullptr, QUrl("http://api.itsblue.de/test/startpadem.php"));
|
||||
BuzzerConn * pBuzzerConn = new BuzzerConn(nullptr, QUrl("http://192.168.4.1"));
|
||||
BuzzerConn * pStartpadConn = new BuzzerConn(nullptr, QUrl("http://192.168.4.2"));
|
||||
AppSettings * pAppSettings = new AppSettings();
|
||||
|
||||
//setup the sql storage model as a qml model
|
||||
|
@ -129,5 +129,12 @@ int main(int argc, char *argv[])
|
|||
engine.rootContext()->setContextProperty("_cppStartpadConn", pStartpadConn);
|
||||
engine.rootContext()->setContextProperty("_cppAppSettings", pAppSettings);
|
||||
|
||||
return app.exec();
|
||||
int iRet = 0;
|
||||
iRet = app.exec();
|
||||
|
||||
delete pBuzzerConn;
|
||||
delete pStartpadConn;
|
||||
delete pAppSettings;
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
|
Reference in a new issue