summaryrefslogtreecommitdiff
path: root/src/metawatch.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <dev.git@javispedro.com>2014-09-14 14:11:26 +0200
committerJavier S. Pedro <dev.git@javispedro.com>2014-09-14 14:11:26 +0200
commitb9b1829dbc50534190c8b81f91ee477af6971834 (patch)
tree360f09061f43a247a5afdc2c83df2b9a03d86a4a /src/metawatch.cpp
parent85fb48bc51fed06a50b6178727fdf9e96aea4fc4 (diff)
downloadsalmeta-b9b1829dbc50534190c8b81f91ee477af6971834.tar.gz
salmeta-b9b1829dbc50534190c8b81f91ee477af6971834.zip
addign watch properties, starting notification work
Diffstat (limited to 'src/metawatch.cpp')
-rw-r--r--src/metawatch.cpp56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/metawatch.cpp b/src/metawatch.cpp
index b1ea8af..b6042af 100644
--- a/src/metawatch.cpp
+++ b/src/metawatch.cpp
@@ -59,8 +59,16 @@ void MetaWatch::updateBatteryStatus()
void MetaWatch::updateLcdDisplay()
{
- // Switches to UiGen2 mode and to page 0.
- _transport->sendMessage(MessageUpdateLcdDisplay, 0x80, QByteArray());
+ _transport->sendMessage(MessageUpdateLcdDisplay,
+ 1 << 7,
+ QByteArray());
+}
+
+void MetaWatch::updateLcdDisplayPage(int page)
+{
+ _transport->sendMessage(MessageUpdateLcdDisplay,
+ 1 << 7 | 1 << 5 | ((page << 2) & 0xC),
+ QByteArray());
}
void MetaWatch::updateWidgetList(const QList<WidgetInfo> &widgets)
@@ -69,8 +77,8 @@ void MetaWatch::updateWidgetList(const QList<WidgetInfo> &widgets)
// Count valid widgets
for (int w = 0; w < widgets.size(); w++) {
- const WidgetInfo *info = widgets[w];
- if (info->valid()) num_widgets++;
+ const WidgetInfo &info = widgets[w];
+ if (info.valid()) num_widgets++;
}
const int max_widgets_in_one_msg = 7;
@@ -82,6 +90,8 @@ void MetaWatch::updateWidgetList(const QList<WidgetInfo> &widgets)
msg.reserve(max_widgets_in_one_msg * 2);
+ qDebug() << "Sending widget list:" << num_widgets << "widgets," << num_messages << "messages";
+
if (num_widgets == 0) {
msg.append(static_cast<char>(0xFF));
msg.append(static_cast<char>(0x00));
@@ -92,27 +102,24 @@ void MetaWatch::updateWidgetList(const QList<WidgetInfo> &widgets)
return;
}
- qDebug() << "Msgs" << num_messages << num_message;
-
- for (int w = 0; w < num_widgets; w++) {
- WidgetInfo *info = widgets[w];
- if (!info->valid()) continue; // Skip disabled/empty widget
+ for (int i = 0; i < widgets.size(); i++) {
+ const WidgetInfo &info = widgets[i];
+ if (!info.valid()) continue; // Skip disabled/empty widget
- quint8 id = w;
- quint8 options = ((info->page() << 4) & 0x30)
- | ((info->size() << 2) & 0xC) | ((info->position() << 2) & 0x3);
+ quint8 id = i;
+ quint8 options = ((info.page() << 4) & 0x30)
+ | ((info.size() << 2) & 0xC) | ((info.position() << 2) & 0x3);
- if (info->url().scheme() == "clock") {
- id |= (clockUrlToClockId(info->url()) << 4) & 0xF0;
+ int clockFace = info.builtinClockfaceId();
+ if (clockFace >= 0) {
+ id |= (clockFace << 4) & 0xF0;
options |= 0x80;
}
- if (info->invert()) {
+ if (info.invert()) {
options |= 0x40;
}
- qDebug() << QString::number(id, 16) << QString::number(options, 16);
-
msg.append(id);
msg.append(options);
@@ -166,6 +173,21 @@ void MetaWatch::handleTransportMessage(quint8 type, quint8 options, const QByteA
break;
case MessageModeChangeIndication:
qDebug() << "Got mode change indication";
+ if (payload.size() < 1) {
+ qWarning() << "Invalid mode change indicator size";
+ }
+ switch (payload.at(0)) {
+ case 1:
+ emit modeChange(WatchMode(options & 0xF), (options >> 4) & 0xF);
+ break;
+ default:
+ qWarning() << "Unknown mode change indicator: " << payload.toHex();
+ break;
+ }
+
+ break;
+ case MessageWatchPropertyOperationResponse:
+ qDebug() << "Got watch property operation response";
break;
case MessageReadBatteryStatusResponse:
if (payload.size() < 6) {