SimpleDisplay to debug back-end

This commit is contained in:
Louis-Joseph Fournier 2015-12-27 15:59:32 +01:00
parent 18a910595d
commit 4ec3a83db1
8 changed files with 72 additions and 30 deletions

View file

@ -2,15 +2,20 @@ import QtQuick 2.0
import LJTuner 1.0 import LJTuner 1.0
Item { Item {
anchors.fill: parent width: 400
height: 300
Tuner { Tuner {
id: tuner id: tuner
running: true running: true
} }
Text {
text: tuner.freq.toFixed(2) + " Hz" DesktopTheme {
font.pixelSize: parent.height / 4 id: theme
anchors.horizontalCenter: parent.horizontalCenter }
anchors.verticalCenter: parent.verticalCenter
SimpleDisplay {
theme: theme
tuner: tuner
} }
} }

12
qml/DesktopTheme.qml Normal file
View file

@ -0,0 +1,12 @@
import QtQuick 2.0
Item {
property color primaryColor: "#000000"
property color secondaryColor: "#444444"
property int paddingSmall: 4
property int paddingLarge: 20
property int fontSizeSmall: 10
property int fontSizeMedium: 16
property int fontSizeLarge: 25
property int fontSizeExtraLarge: 40
}

View file

@ -16,22 +16,25 @@ ApplicationWindow {
property QtObject tuner property QtObject tuner
initialPage: Component { initialPage: Component {
ApplicationWindow { Page {
id: page
allowedOrientations: Orientation.All
SilicaFlickable {
anchors.fill: parent
SimpleDisplay {
theme: Theme
tuner: app.tuner
}
}
Tuner { Tuner {
id: tunerObject id: tunerObject
running: Qt.application.active && app.userRunning running: Qt.application.active && app.userRunning
} }
property QtObject tuner: tunerObject
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: tuner.freq.toFixed(2) + " Hz"
font.pixelSize: 90
color: Theme.primaryColor
}
Component.onCompleted: { Component.onCompleted: {
app.tuner = tunerObject app.tuner = tunerObject
//togglePause.connect(app.togglePause) //togglePause.connect(app.togglePause)
@ -41,10 +44,9 @@ ApplicationWindow {
cover: Component { cover: Component {
CoverBackground { CoverBackground {
Text { SimpleDisplay {
color: Theme.primaryColor theme: Theme
font.pixelSize: 40 tuner: app.tuner
text: app.tuner.freq.toFixed(2) + " Hz"
} }
} }
} }

View file

@ -9,15 +9,8 @@ Item {
width: 600 width: 600
height: 400 height: 400
Item { DesktopTheme {
id: theme id: theme
property color primaryColor: "#000000"
property color secondaryColor: "#444444"
property int paddingSmall: 4
property int paddingLarge: 20
property int fontSizeSmall: 10
property int fontSizeMedium: 16
property int fontSizeLarge: 25
} }
Item { Item {

27
qml/SimpleDisplay.qml Normal file
View file

@ -0,0 +1,27 @@
import QtQuick 2.0
/**
* Simple display for tuner test without gui
*/
Column {
property QtObject tuner
property QtObject theme
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Component {
id: simpleText
Text {
font.pixelSize: theme.fontSizeExtraLarge
color: theme.primaryColor
anchors.horizontalCenter: parent.horizontalCenter
}
}
Component.onCompleted: {
var freq = simpleText.createObject(this)
freq.text = Qt.binding(function () { return tuner ? tuner.freq.toFixed(2) + " Hz" : "NaN" })
}
}

View file

@ -1,5 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/qml/"> <qresource prefix="/qml/">
<file>Desktop.qml</file> <file>Desktop.qml</file>
<file>SimpleDisplay.qml</file>
<file>DesktopTheme.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -1,5 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/qml/"> <qresource prefix="/qml/">
<file>Sailfish.qml</file> <file>Sailfish.qml</file>
<file>SimpleDisplay.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -69,7 +69,7 @@ pair<double,double> FindPattern(const vector<double> &values, double pattern_min
best = res; best = res;
} }
} }
cerr << " -> " << best.first << " " << best.second << endl; //cerr << " -> " << best.first << " " << best.second << endl;
if (best.second > CORRECT_DEVIATION) return pair<double,double>(0,0); if (best.second > CORRECT_DEVIATION) return pair<double,double>(0,0);
return best; return best;
} }