summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsowatch/watch.h6
-rw-r--r--libsowatch/watchserver.cpp50
-rw-r--r--libsowatch/watchserver.h5
-rw-r--r--liveview/liveview.cpp25
-rw-r--r--liveview/liveview.h7
-rw-r--r--liveview/liveviewpaintengine.cpp1
-rw-r--r--metawatch/metawatch.cpp6
-rw-r--r--metawatch/metawatchscanner.cpp2
-rw-r--r--nekowatchlet/liveview.qml7
-rw-r--r--nekowatchlet/neko-inv.pngbin0 -> 2426 bytes
-rwxr-xr-xprepare_debug_dir.sh9
-rw-r--r--sowatchd/watchhandler.cpp20
12 files changed, 82 insertions, 56 deletions
diff --git a/libsowatch/watch.h b/libsowatch/watch.h
index 27e3d04..6a24d3e 100644
--- a/libsowatch/watch.h
+++ b/libsowatch/watch.h
@@ -91,8 +91,12 @@ signals:
void buttonPressed(int button);
/** A button has been pressed and then released. */
void buttonReleased(int button);
- /** Emitted when e.g. either via the watch menu, or similar, a watchlet is requested. */
+ /** Emitted when e.g. either via the watch menu, or similar, advancing watchlet carrousel is requested. */
+ void nextWatchletRequested();
+ /** Emitted when e.g. either via the watch menu, or similar, a given watchlet is requested. */
void watchletRequested(const QString& id);
+ /** Emitted when closing the current watchlet is requested. */
+ void closeWatchledRequested();
};
}
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index c82c3ee..06a8189 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -11,7 +11,6 @@ using namespace sowatch;
WatchServer::WatchServer(Watch* watch, QObject* parent) :
QObject(parent), _watch(watch),
- _nextWatchletButton(-1),
_oldNotificationThreshold(300),
_idleWatchlet(0), _notificationWatchlet(0),
_watchlets(new WatchletsModel(this)),
@@ -22,9 +21,10 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) :
connect(_watch, SIGNAL(connected()), SLOT(handleWatchConnected()));
connect(_watch, SIGNAL(disconnected()), SLOT(handleWatchDisconnected()));
connect(_watch, SIGNAL(idling()), SLOT(handleWatchIdling()));
- connect(_watch, SIGNAL(buttonPressed(int)), SLOT(handleWatchButtonPress(int)));
+ connect(_watch, SIGNAL(nextWatchletRequested()), SLOT(handleNextWatchletRequested()));
connect(_watch, SIGNAL(watchletRequested(QString)),
SLOT(handleWatchletRequested(QString)));
+ connect(_watch, SIGNAL(closeWatchledRequested()), SLOT(handleCloseWatchletRequested()));
connect(_syncTimeTimer, SIGNAL(timeout()), SLOT(syncTime()));
_syncTimeTimer->setSingleShot(true);
@@ -43,27 +43,6 @@ const Watch* WatchServer::watch() const
return _watch;
}
-QString WatchServer::nextWatchletButton() const
-{
- if (_nextWatchletButton >= 0) {
- return _watch->buttons().at(_nextWatchletButton);
- } else {
- return QString();
- }
-}
-
-void WatchServer::setNextWatchletButton(const QString& value)
-{
- if (value.isEmpty()) {
- _nextWatchletButton = -1;
- return;
- }
- _nextWatchletButton = _watch->buttons().indexOf(value);
- if (_nextWatchletButton < 0) {
- qWarning() << "Invalid watch button" << value;
- }
-}
-
Watchlet * WatchServer::idleWatchlet()
{
return _idleWatchlet;
@@ -392,18 +371,16 @@ void WatchServer::handleWatchIdling()
}
}
-void WatchServer::handleWatchButtonPress(int button)
+void WatchServer::handleNextWatchletRequested()
{
- if (button == _nextWatchletButton) {
- qDebug() << "next watchlet button pressed";
- if (_pendingNotifications.empty()) {
- // No notifications: either app or idle mode.
- nextWatchlet();
- } else {
- // Skip to next notification if any
- _pendingNotifications.dequeue();
- nextNotification();
- }
+ qDebug() << "next watchlet button pressed";
+ if (_pendingNotifications.empty()) {
+ // No notifications: either app or idle mode.
+ nextWatchlet();
+ } else {
+ // Skip to next notification if any
+ _pendingNotifications.dequeue();
+ nextNotification();
}
}
@@ -412,6 +389,11 @@ void WatchServer::handleWatchletRequested(const QString &id)
openWatchlet(id);
}
+void WatchServer::handleCloseWatchletRequested()
+{
+ closeWatchlet();
+}
+
void WatchServer::handleNotificationChanged()
{
QObject *obj = sender();
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index a1cda45..06f4e4b 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -79,8 +79,6 @@ signals:
private:
Watch* _watch;
- /** The watch button that causes next watchlet to be run. */
- int _nextWatchletButton;
/** The amount of seconds that have to pass for a notification to be considered "outdated" and not shown. */
int _oldNotificationThreshold;
@@ -125,8 +123,9 @@ private slots:
void handleWatchConnected();
void handleWatchDisconnected();
void handleWatchIdling();
- void handleWatchButtonPress(int button);
+ void handleNextWatchletRequested();
void handleWatchletRequested(const QString& id);
+ void handleCloseWatchletRequested();
void handleNotificationChanged();
void handleNotificationDismissed();
diff --git a/liveview/liveview.cpp b/liveview/liveview.cpp
index aa8a472..746c04a 100644
--- a/liveview/liveview.cpp
+++ b/liveview/liveview.cpp
@@ -14,6 +14,8 @@ LiveView::LiveView(ConfigKey* settings, QObject* parent) :
_watchlets(0),
_24hMode(settings->value("24h-mode", false).toBool()),
_screenWidth(0), _screenHeight(0),
+ _mode(RootMenuMode),
+ _paintEngine(0),
_sendTimer(new QTimer(this))
{
_sendTimer->setInterval(DelayBetweenMessages);
@@ -166,7 +168,7 @@ void LiveView::renderImage(int x, int y, const QImage &image)
buffer.open(QIODevice::WriteOnly);
if (image.save(&buffer, "PNG")) {
displayBitmap(x, y, buffer.buffer());
- qDebug() << "render image " << x << 'x' << y << "size" << image.size();
+ qDebug() << "render image at" << x << 'x' << y << "size" << image.size();
} else {
qWarning() << "Failed to encode image";
}
@@ -188,7 +190,8 @@ void LiveView::setupBluetoothWatch()
void LiveView::desetupBluetoothWatch()
{
-
+ _sendTimer->stop();
+ _sendingMsgs.clear();
}
void LiveView::refreshMenu()
@@ -361,14 +364,24 @@ void LiveView::handleNavigation(const Message &msg)
int event = msg.data[2];
qDebug() << "navigation" << event << item_id << menu_id;
- sendResponse(NavigationResponse, ResponseOk);
- // TODO
- if (event == 32) {
- qDebug() << "Navigation, requesting watchlet";
+ switch (event) {
+ case SelectLongPress:
+ if (_mode == ApplicationMode) {
+ sendResponse(NavigationResponse, ResponseCancel);
+ emit closeWatchledRequested();
+ return;
+ }
+ break;
+ case SelectMenu:
+ sendResponse(NavigationResponse, ResponseOk);
emit watchletRequested("com.javispedro.sowatch.neko");
+ return;
}
+
+ // Fallback case
+ sendResponse(NavigationResponse, ResponseOk);
}
void LiveView::handleMenuItemsRequest(const Message &msg)
diff --git a/liveview/liveview.h b/liveview/liveview.h
index 65ce523..bd8a3ac 100644
--- a/liveview/liveview.h
+++ b/liveview/liveview.h
@@ -105,6 +105,13 @@ protected:
ApplicationMode
};
+ enum NavigationEvent {
+ SelectPress = 13,
+ SelectLongPress = 14,
+ SelectDoublePress = 15,
+ SelectMenu = 32
+ };
+
struct Message {
MessageType type;
QByteArray data;
diff --git a/liveview/liveviewpaintengine.cpp b/liveview/liveviewpaintengine.cpp
index f774884..1caa1e3 100644
--- a/liveview/liveviewpaintengine.cpp
+++ b/liveview/liveviewpaintengine.cpp
@@ -7,7 +7,6 @@ using namespace sowatch;
LiveViewPaintEngine::LiveViewPaintEngine() :
WatchPaintEngine(), _watch(0)
{
- qDebug() << "SE CCONS";
}
bool LiveViewPaintEngine::begin(QPaintDevice *pdev)
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index c7e0db3..b5aec49 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -576,7 +576,11 @@ void MetaWatch::handleButtonEventMessage(const Message &msg)
qDebug() << "button event" << button << " (" << press << ")";
if (press == PressOnly) {
- emit buttonPressed(button);
+ if (button == BtnA) { // This is the next watchlet button
+ emit nextWatchletRequested();
+ } else {
+ emit buttonPressed(button);
+ }
} else if (press == PressAndRelease) {
emit buttonReleased(button);
}
diff --git a/metawatch/metawatchscanner.cpp b/metawatch/metawatchscanner.cpp
index 3742092..822f41e 100644
--- a/metawatch/metawatchscanner.cpp
+++ b/metawatch/metawatchscanner.cpp
@@ -24,12 +24,10 @@ void MetaWatchScanner::handleDiscoveredService(const QBluetoothServiceInfo &info
if (deviceName.contains("Analog")) {
// This is Analog metawatch.
foundInfo["driver"] = QString("metawatch-analog");
- foundInfo["next-watchlet-button"] = QString("A");
emit watchFound(foundInfo);
} else {
// For now, assume Digital metawatch.
foundInfo["driver"] = QString("metawatch-digital");
- foundInfo["next-watchlet-button"] = QString("A");
foundInfo["idle-watchlet"] = QString("com.javispedro.sowatch.metawatch.watchface");
foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.metawatch.notification");
emit watchFound(foundInfo);
diff --git a/nekowatchlet/liveview.qml b/nekowatchlet/liveview.qml
index a9c5712..fcfb5ff 100644
--- a/nekowatchlet/liveview.qml
+++ b/nekowatchlet/liveview.qml
@@ -1,8 +1,11 @@
import QtQuick 1.0
-Item {
+Rectangle {
+ color: "black"
+
Neko {
id: neko
+ imageSource: "neko-inv.png"
running: watch.active
targetX: goal.x
@@ -13,7 +16,7 @@ Item {
id: goal
width: 2
height: 2
- color: "black"
+ color: "white"
Behavior on x { SmoothedAnimation { velocity: 80; }}
Behavior on y { SmoothedAnimation { velocity: 80; }}
diff --git a/nekowatchlet/neko-inv.png b/nekowatchlet/neko-inv.png
new file mode 100644
index 0000000..bbc80ad
--- /dev/null
+++ b/nekowatchlet/neko-inv.png
Binary files differ
diff --git a/prepare_debug_dir.sh b/prepare_debug_dir.sh
index 7e9e18a..04dd8df 100755
--- a/prepare_debug_dir.sh
+++ b/prepare_debug_dir.sh
@@ -3,7 +3,13 @@
function make_symlink {
local src="$1"
local target="$2"
- ln -sf "$src" "$target"
+ if [ -L "$target/$(basename "$src")" ]; then
+ # Overwrite existing symlinks
+ ln -sf "$src" "$target"
+ else
+ # But nothing else
+ ln -s "$src" "$target"
+ fi
}
function make_symlinks {
@@ -23,7 +29,6 @@ SOWATCH_ROOT=$(dirname "$SCRIPT_PATH")
BUILD_ROOT=$(pwd)
rm -r drivers notifications watchlets
-
mkdir -p drivers notifications watchlets
make_symlinks $BUILD_ROOT/*/lib*driver.so drivers
diff --git a/sowatchd/watchhandler.cpp b/sowatchd/watchhandler.cpp
index cdd520d..20d49f9 100644
--- a/sowatchd/watchhandler.cpp
+++ b/sowatchd/watchhandler.cpp
@@ -57,8 +57,6 @@ WatchHandler::WatchHandler(ConfigKey *config, QObject *parent)
_server = new WatchServer(_watch, this);
// Configure the server
- _server->setNextWatchletButton(_config->value("next-watchlet-button").toString());
-
QString idle_watchlet_id = _config->value("idle-watchlet").toString();
if (!idle_watchlet_id.isEmpty()) {
Watchlet *watchlet = createWatchlet(idle_watchlet_id);
@@ -217,8 +215,22 @@ void WatchHandler::handleConfigSubkeyChanged(const QString &subkey)
} else if (subkey == "providers") {
qDebug() << "Providers list changed";
updateProviders();
- } else if (subkey == "next-watchlet-button" && _server) {
- _server->setNextWatchletButton(_config->value("next-watchlet-button").toString());
+ } else if (subkey == "idle-watchlet" && _server) {
+ qDebug() << "Idle watchlet changed";
+ QString id(_config->value("idle-watchlet").toString());
+ if (!id.isEmpty()) {
+ _server->setIdleWatchlet(createWatchlet(id));
+ } else {
+ _server->setIdleWatchlet(0);
+ }
+ } else if (subkey == "notification-watchlet" && _server) {
+ qDebug() << "Notification watchlet changed";
+ QString id(_config->value("notification-watchlet").toString());
+ if (!id.isEmpty()) {
+ _server->setNotificationWatchlet(createWatchlet(id));
+ } else {
+ _server->setNotificationWatchlet(0);
+ }
}
}