儀表板
儀表板是您自行設計、用來顯示資料與控制項的畫面:例如以大字顯示騎車時的速度與功率、心率顯示、傾斜儀,或控制記錄的按鈕。儀表板以 QML 撰寫,也就是應用程式本身的畫面所使用的語言,因此幾乎什麼都能做。
儀表板分為兩種:
- 疊加式(overlay)儀表板是透明的,覆蓋在地圖上。重新啟動應用程式後仍會保持載入。
- 全螢幕(fullscreen)儀表板會覆蓋整個畫面,包括地圖。按 關閉 即可回到地圖。
開啟儀表板
- 點一下 DASH 按鈕(儀表板)。如果還沒有這個按鈕,請先將它加入邊欄,請參閱邊欄按鈕。
- 從清單中選擇一個儀表板。
同一時間只會顯示一個疊加式儀表板。清單中的垃圾桶按鈕會將目前的疊加式儀表板從地圖上移除。開啟全螢幕儀表板也會將它移除。
⋮ 選單中有顯示內建儀表板(可隱藏應用程式隨附的儀表板)和資訊(本頁面)。按住您自己的儀表板即可刪除其檔案。
內建儀表板
| 儀表板 | 類型 |
|---|---|
| Bicycle dashboard | 全螢幕 |
| Inclinometer | 全螢幕(裝置的傾斜角度) |
| Pedal balance | 全螢幕(功率計的左右踏板平衡) |
| Example: All sensor and map data table | 全螢幕 |
| Example: Track recording controls | 全螢幕 |
| Example: Map controls | 疊加式 |
| Example: Speed and Power overlay | 疊加式 |
感測器數值來自感測器管理器:請連線您的藍牙感測器(或將藍牙連線設為應用程式啟動時)才能看到數值。
安裝儀表板
您自己的儀表板是應用程式 Dashboards 資料夾中的 .qml 檔案。新增儀表板的方式:
- 以 Cartograph Maps 開啟
.qml檔案或包含多個這類檔案的 ZIP 檔案(分享到應用程式、使用「開啟方式」,或拖曳到視窗上),或 - 在網站上點一下指向
.qml或.dashboard.zip檔案的cartograph://或cartograph-s://連結。
內建儀表板的檔案,可作為您製作時的起點:ZIP 檔案,或直接在應用程式中安裝。
撰寫您自己的儀表板
儀表板是一個 QML 檔案,前兩行必須是:
//Name=清單中顯示的名稱,//Type=overlay或fullscreen。
其餘部分是一般的 Qt Quick 程式碼。import com.mobwheel 可透過 AppInstance.cartographApplicationManager 存取應用程式。以下這個疊加式儀表板會顯示速度與功率:
//Name=Example: Speed and Power overlay
//Type=overlay
/**
* This example shows how to overlay sensor data on top
* of the map using an "overlay" dashboard.
**/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import com.mobwheel // this is necessary for accessing data from Cartograph Maps
Item {
ColumnLayout {
id: col
anchors.top: parent.top
anchors.topMargin: 100
anchors.horizontalCenter: parent.horizontalCenter
property var unitsHandler: AppInstance.cartographApplicationManager.unitsHandler
property var sensorManager: AppInstance.cartographApplicationManager.sensorManager
// Speed
Label {
font.bold: true
font.pointSize: 20
Layout.fillWidth: true
horizontalAlignment: Label.AlignHCenter
text: col.unitsHandler.getStringForSpeed(col.sensorManager.speed)
background: Rectangle {
color: "black"
opacity: 0.5
radius: 4
}
}
// Power
Label {
font.bold: true
font.pointSize: 20
Layout.fillWidth: true
horizontalAlignment: Label.AlignHCenter
text: col.sensorManager.power.toFixed() + " W"
background: Rectangle {
color: "black"
opacity: 0.5
radius: 4
}
}
}
}
內建儀表板使用的項目:
| 物件 | 屬性與函式 |
|---|---|
sensorManager | speed(m/s)、heartRate、cadence、power、powerPercentageLeftPedal、altitude、compassBearing、currentLocation、gpsHorizontalAccuracy、gpsVerticalAccuracy、gpsState |
unitsHandler | getStringForSpeed()、getStringForDistance()、getStringForAltitude()(以使用者設定的單位表示數值) |
mapManager | mapCenter、zoomLevel、bearing、tilt、visibleRegion;updateZoomLevel()、updateBearing()、updateTilt()、updateMapCenterLatLng() |
trackManager | getPtrTrackRecorder()(及其 getTrack() 與 recordingState)、startOrContinueTrackRecording()、pauseTrackRecording()、stopTrackRecording()、addWaypointToRecordingTrack()、addTrackSegmentToRecordingTrack() |
這些是應用程式的內部物件,並非穩定的介面,可能會隨版本變更。內建儀表板的原始碼(上方的 ZIP 檔案)示範了它們的用法。
