Some graphical improvements
This commit is contained in:
parent
6873e8a952
commit
9001272ada
4 changed files with 23 additions and 43 deletions
|
@ -9,7 +9,7 @@ Item {
|
||||||
|
|
||||||
property int size: 200 // The size of the circle in pixel
|
property int size: 200 // The size of the circle in pixel
|
||||||
property real arcBegin: 0 // start arc angle in degree
|
property real arcBegin: 0 // start arc angle in degree
|
||||||
property real arcEnd: 270 // end arc angle in degree
|
property real arcEnd: 1 // end arc angle in degree
|
||||||
property real arcOffset: 0 // rotation
|
property real arcOffset: 0 // rotation
|
||||||
property bool isPie: false // paint a pie instead of an arc
|
property bool isPie: false // paint a pie instead of an arc
|
||||||
property bool showBackground: false // a full circle as a background of the arc
|
property bool showBackground: false // a full circle as a background of the arc
|
||||||
|
@ -20,7 +20,7 @@ Item {
|
||||||
property alias beginAnimation: animationArcBegin.enabled
|
property alias beginAnimation: animationArcBegin.enabled
|
||||||
property alias endAnimation: animationArcEnd.enabled
|
property alias endAnimation: animationArcEnd.enabled
|
||||||
|
|
||||||
property int animationDuration: 20
|
property int animationDuration: 50
|
||||||
|
|
||||||
onArcBeginChanged: canvas.requestPaint()
|
onArcBeginChanged: canvas.requestPaint()
|
||||||
onArcEndChanged: canvas.requestPaint()
|
onArcEndChanged: canvas.requestPaint()
|
||||||
|
@ -45,10 +45,12 @@ Item {
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: 100
|
duration: 200
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Canvas {
|
Canvas {
|
||||||
id: canvas
|
id: canvas
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -9,15 +9,15 @@ Popup {
|
||||||
y: startButt.y
|
y: startButt.y
|
||||||
width: startButt.width
|
width: startButt.width
|
||||||
height: startButt.height
|
height: startButt.height
|
||||||
modal: false
|
modal: true
|
||||||
enabled: false
|
dim: false
|
||||||
|
|
||||||
enter: Transition {
|
enter: Transition {
|
||||||
NumberAnimation { properties: "scale"; from: 0; to: 1; duration: 500; easing.type: Easing.InCubic }
|
NumberAnimation { properties: "scale"; from: 0; to: 1; duration: 300; easing.type: Easing.InCubic }
|
||||||
}
|
}
|
||||||
|
|
||||||
exit: Transition {
|
exit: Transition {
|
||||||
NumberAnimation { properties: "scale"; from: 1; to: 0; duration: 500; easing.type: Easing.OutCubic }
|
NumberAnimation { properties: "scale"; from: 1; to: 0; duration: 300; easing.type: Easing.OutCubic }
|
||||||
}
|
}
|
||||||
|
|
||||||
function delay(delayTime, cb) {
|
function delay(delayTime, cb) {
|
||||||
|
@ -109,8 +109,9 @@ Popup {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.modal = true
|
|
||||||
root.closePolicy = Popup.NoAutoClose
|
root.closePolicy = Popup.NoAutoClose
|
||||||
|
connect_del.opacity = 0
|
||||||
|
prog.arcEnd = 0
|
||||||
prog.colorCircle = "grey"
|
prog.colorCircle = "grey"
|
||||||
prog.opacity = 1
|
prog.opacity = 1
|
||||||
prog.text = "connecting..."
|
prog.text = "connecting..."
|
||||||
|
@ -118,14 +119,11 @@ Popup {
|
||||||
connect_del.enabled = false
|
connect_del.enabled = false
|
||||||
|
|
||||||
if(_cppBuzzerConn.connect()){
|
if(_cppBuzzerConn.connect()){
|
||||||
prog.arcEnd = 360
|
|
||||||
prog.colorCircle = "green"
|
prog.colorCircle = "green"
|
||||||
prog.text = "success!"
|
prog.text = "success!"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
prog.arcEnd = 360
|
|
||||||
prog.colorCircle = "red"
|
prog.colorCircle = "red"
|
||||||
prog.colorBackground = "red"
|
|
||||||
prog.text = "error!"
|
prog.text = "error!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ Popup {
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
connect_del.enabled = true;
|
connect_del.enabled = true;
|
||||||
prog.opacity = 0;
|
prog.opacity = 0;
|
||||||
root.modal = false;
|
connect_del.opacity = 1;
|
||||||
root.closePolicy = Popup.CloseOnPressOutside;
|
root.closePolicy = Popup.CloseOnPressOutside;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,10 @@ bool BuzzerConn::connect()
|
||||||
if(times[0] == 200.0){
|
if(times[0] == 200.0){
|
||||||
this->connected = true;
|
this->connected = true;
|
||||||
this->latest_button_pressed = times[2];
|
this->latest_button_pressed = times[2];
|
||||||
for(int i=0;i<100;i++){
|
for(int i=0;i<=100;i++){
|
||||||
this->connection_progress = i;
|
this->connection_progress = i;
|
||||||
if(!calcoffset()){
|
if(!calcoffset()){
|
||||||
|
this->connection_progress = 100;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +35,9 @@ bool BuzzerConn::connect()
|
||||||
bool BuzzerConn::calcoffset()
|
bool BuzzerConn::calcoffset()
|
||||||
{
|
{
|
||||||
QList<double> times = gettimes();
|
QList<double> times = gettimes();
|
||||||
qDebug() << times[0];
|
if(times.length() != 3){
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
if(times[0] == 200.0 && this->connected){
|
if(times[0] == 200.0 && this->connected){
|
||||||
double offset = date->currentMSecsSinceEpoch() - times[1];
|
double offset = date->currentMSecsSinceEpoch() - times[1];
|
||||||
if(this->latest_offsets.length()>=100){
|
if(this->latest_offsets.length()>=100){
|
||||||
|
@ -46,12 +49,7 @@ bool BuzzerConn::calcoffset()
|
||||||
for(int i=0;i<latest_offsets.length();i++){
|
for(int i=0;i<latest_offsets.length();i++){
|
||||||
mem += latest_offsets[i];
|
mem += latest_offsets[i];
|
||||||
}
|
}
|
||||||
//this->offset = mem / double(latest_offsets.length());
|
this->offset = mem / double(latest_offsets.length());
|
||||||
this->offset = latest_offsets[latest_offsets.length()-1];
|
|
||||||
// qDebug() << latest_offsets.length();
|
|
||||||
// qDebug() << this->latest_offsets;
|
|
||||||
// qDebug() << latest_offsets[latest_offsets.length()-1];
|
|
||||||
// qDebug() << mem / double(latest_offsets.length());
|
|
||||||
qDebug("%20f", this->offset);
|
qDebug("%20f", this->offset);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
28
main.qml
28
main.qml
|
@ -58,19 +58,15 @@ Window {
|
||||||
interval: 1
|
interval: 1
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
//root.stoppedTime = (root.last_button_pressed + root.buzzer_offset) - root.startTime
|
|
||||||
//console.log("STOPPED: "+root.stoppedTime)
|
|
||||||
//time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
|
|
||||||
if(_cppBuzzerConn.buzzer_triggered()){
|
if(_cppBuzzerConn.buzzer_triggered()){
|
||||||
|
//the buzzer was pushed
|
||||||
root.buzzer_offset = _cppBuzzerConn.get("offset")
|
root.buzzer_offset = _cppBuzzerConn.get("offset")
|
||||||
root.last_button_pressed = _cppBuzzerConn.get("lastpressed")
|
root.last_button_pressed = _cppBuzzerConn.get("lastpressed")
|
||||||
console.log(root.startTime);
|
|
||||||
console.log(root.buzzer_offset);
|
|
||||||
root.stoppedTime = (root.last_button_pressed + root.buzzer_offset) - root.startTime
|
root.stoppedTime = (root.last_button_pressed + root.buzzer_offset) - root.startTime
|
||||||
time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
|
|
||||||
console.log("STOPPED: "+root.stoppedTime)
|
|
||||||
root.state = "STOPPED"
|
root.state = "STOPPED"
|
||||||
|
//time.text = ( root.stoppedTime / 1000 ).toFixed(3) + " sec"
|
||||||
|
console.log("STOPPED: "+root.stoppedTime)
|
||||||
|
|
||||||
}
|
}
|
||||||
if(root.state === "RUNNING"){
|
if(root.state === "RUNNING"){
|
||||||
running_refresh_timer.start()
|
running_refresh_timer.start()
|
||||||
|
@ -306,14 +302,7 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(settingsDialog.enabled === false){
|
settingsDialog.open()
|
||||||
settingsDialog.open()
|
|
||||||
settingsDialog.enabled = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
settingsDialog.enabled = false
|
|
||||||
settingsDialog.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
@ -359,13 +348,6 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var theUrl = "http://192.168.4.1";
|
|
||||||
var xmlHttp = null;
|
|
||||||
|
|
||||||
xmlHttp = new XMLHttpRequest();
|
|
||||||
xmlHttp.open( "GET", theUrl, false );
|
|
||||||
xmlHttp.send( null );
|
|
||||||
console.log(xmlHttp.responseText)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
|
Reference in a new issue