summaryrefslogtreecommitdiff
path: root/metawatch
diff options
context:
space:
mode:
Diffstat (limited to 'metawatch')
-rw-r--r--metawatch/metawatch.cpp60
-rw-r--r--metawatch/metawatch.h46
-rw-r--r--metawatch/metawatchdigital.cpp32
-rw-r--r--metawatch/metawatchdigital.h1
4 files changed, 58 insertions, 81 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index 4a57174..8c246aa 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -90,12 +90,9 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QSettings* settings, QObj
_sendTimer(new QTimer(this))
{
if (settings) {
+ _notificationTimeout = settings->value("NotificationTimeout", 15).toInt();
_24hMode = settings->value("24hMode", false).toBool();
_dayMonthOrder = settings->value("DayMonthOrder", false).toBool();
- _notificationTimeout = settings->value("NotificationTimeout", 15).toInt();
- _invertedIdle = settings->value("InvertedIdleScreen", false).toBool();
- _invertedNotifications = settings->value("InvertedNotifications", false).toBool();
- _invertedApplications = settings->value("InvertedApplications", false).toBool();
}
_buttonNames << "A" << "B" << "C" << "D" << "E" << "F";
@@ -161,7 +158,7 @@ QDateTime MetaWatch::dateTime()
void MetaWatch::setDateTime(const QDateTime &dateTime)
{
- Message msg(SetRealTimeClock, QByteArray(10, 0));
+ Message msg(SetRealTimeClock, QByteArray(8, 0));
const QDate& date = dateTime.date();
const QTime& time = dateTime.time();
@@ -174,8 +171,6 @@ void MetaWatch::setDateTime(const QDateTime &dateTime)
msg.data[5] = time.hour();
msg.data[6] = time.minute();
msg.data[7] = time.second();
- msg.data[8] = _24hMode ? 1 : 0;
- msg.data[9] = _dayMonthOrder ? 1 : 0;
send(msg);
}
@@ -190,6 +185,13 @@ void MetaWatch::ungrabButton(int button)
ungrabButton(_currentMode, (Button) button);
}
+void MetaWatch::updateNotificationCount(Notification::Type type, int count)
+{
+ Q_UNUSED(type);
+ Q_UNUSED(count);
+ // Default implementation does nothing
+}
+
void MetaWatch::displayIdleScreen()
{
_currentMode = IdleMode;
@@ -294,10 +296,10 @@ void MetaWatch::handleMessage(const Message &msg)
{
switch (msg.type) {
case StatusChangeEvent:
- handleStatusChange(msg);
+ handleStatusChangeMessage(msg);
break;
case ButtonEvent:
- handleButtonEvent(msg);
+ handleButtonEventMessage(msg);
break;
default:
qWarning() << "Unknown message of type" << msg.type << "received";
@@ -319,9 +321,9 @@ void MetaWatch::setVibrateMode(bool enable, uint on, uint off, uint cycles)
send(msg);
}
-void MetaWatch::updateLine(Mode mode, const QImage& image, int line)
+void MetaWatch::updateLcdLine(Mode mode, const QImage& image, int line)
{
- Message msg(WriteBuffer, QByteArray(13, 0), (1 << 4) | (mode & 0xF));
+ Message msg(WriteLcdBuffer, QByteArray(13, 0), (1 << 4) | (mode & 0xF));
const char * scanLine = (const char *) image.constScanLine(line);
msg.data[0] = line;
@@ -330,9 +332,9 @@ void MetaWatch::updateLine(Mode mode, const QImage& image, int line)
send(msg);
}
-void MetaWatch::updateLines(Mode mode, const QImage& image, int lineA, int lineB)
+void MetaWatch::updateLcdLines(Mode mode, const QImage& image, int lineA, int lineB)
{
- Message msg(WriteBuffer, QByteArray(26, 0), mode & 0xF);
+ Message msg(WriteLcdBuffer, QByteArray(26, 0), mode & 0xF);
const char * scanLine = (const char *) image.constScanLine(lineA);
msg.data[0] = lineA;
@@ -345,7 +347,7 @@ void MetaWatch::updateLines(Mode mode, const QImage& image, int lineA, int lineB
send(msg);
}
-void MetaWatch::updateLines(Mode mode, const QImage& image, const QVector<bool>& lines)
+void MetaWatch::updateLcdLines(Mode mode, const QImage& image, const QVector<bool>& lines)
{
int lineCount = lines.count(true);
int lineA = -1;
@@ -358,18 +360,18 @@ void MetaWatch::updateLines(Mode mode, const QImage& image, const QVector<bool>&
if (lines[line]) {
lineCount--;
#if SINGLE_LINE_UPDATE
- updateLine(mode, image, line);
+ updateLcdLine(mode, image, line);
continue;
#endif
if (lineA >= 0) {
// We have a pair of lines to send.
- updateLines(mode, image, lineA, line);
+ updateLcdLines(mode, image, lineA, line);
lineA = -1;
} else if (lineCount > 0) {
// Still another line to send.
lineA = line;
} else {
- updateLine(mode, image, line);
+ updateLcdLine(mode, image, line);
break; // No more lines
}
}
@@ -378,31 +380,23 @@ void MetaWatch::updateLines(Mode mode, const QImage& image, const QVector<bool>&
}
-void MetaWatch::configureWatchMode(Mode mode, int timeout, bool invert)
-{
- Message msg(ConfigureMode, QByteArray(2, 0), mode & 0xF);
- msg.data[0] = timeout;
- msg.data[1] = invert ? 1 : 0;
- send(msg);
-}
-
-void MetaWatch::configureIdleSystemArea(bool entireScreen)
+void MetaWatch::configureLcdIdleSystemArea(bool entireScreen)
{
- Message msg(ConfigureIdleBufferSize, QByteArray(26, 0));
+ Message msg(ConfigureLcdIdleBufferSize, QByteArray(26, 0));
msg.data[0] = entireScreen ? 1 : 0;
send(msg);
}
-void MetaWatch::updateDisplay(Mode mode, bool copy)
+void MetaWatch::updateLcdDisplay(Mode mode, bool copy)
{
- Message msg(UpdateDisplay, QByteArray(),
+ Message msg(UpdateLcdDisplay, QByteArray(),
(copy ? 0x10 : 0) | (mode & 0xF));
send(msg);
}
-void MetaWatch::loadTemplate(Mode mode, int templ)
+void MetaWatch::loadLcdTemplate(Mode mode, int templ)
{
- Message msg(LoadTemplate, QByteArray(1, templ), mode & 0xF);
+ Message msg(LoadLcdTemplate, QByteArray(1, templ), mode & 0xF);
send(msg);
}
@@ -434,13 +428,13 @@ void MetaWatch::disableButton(Mode mode, Button button, ButtonPress press)
send(msg);
}
-void MetaWatch::handleStatusChange(const Message &msg)
+void MetaWatch::handleStatusChangeMessage(const Message &msg)
{
Q_UNUSED(msg);
qDebug() << "got status change message";
}
-void MetaWatch::handleButtonEvent(const Message &msg)
+void MetaWatch::handleButtonEventMessage(const Message &msg)
{
if (!(msg.options & 0x80)) {
// We didn't configure this button, reject.
diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h
index 9c4680b..badfa83 100644
--- a/metawatch/metawatch.h
+++ b/metawatch/metawatch.h
@@ -32,28 +32,33 @@ public:
GetDeviceTypeResponse = 0x02,
GetInformationString = 0x03,
GetInformationStringResponse = 0x04,
+ WriteOledBuffer = 0x10,
+ ChangeOledMode = 0x12,
+ WriteOledScrollBuffer = 0x13,
AdvanceWatchHands = 0x20,
SetVibrateMode = 0x23,
SetRealTimeClock = 0x26,
GetRealTimeClock = 0x27,
GetRealTimeClockResponse = 0x28,
+ NvalOperation = 0x30,
+ NvalOperationResponse = 0x31,
StatusChangeEvent = 0x33,
ButtonEvent = 0x34,
- WriteBuffer = 0x40,
- ConfigureMode = 0x41,
- ConfigureIdleBufferSize = 0x42,
- UpdateDisplay = 0x43,
- LoadTemplate = 0x44,
+ GeneralPurposePhone = 0x35,
+ GeneralPurposeWatch = 0x36,
+ WriteLcdBuffer = 0x40,
+ ConfigureLcdIdleBufferSize = 0x42,
+ UpdateLcdDisplay = 0x43,
+ LoadLcdTemplate = 0x44,
EnableButton = 0x46,
DisableButton = 0x47,
- ReadButtonConfiguration = 0x48,
- ReadButtonConfigurationResponse = 0x49,
BatteryConfiguration = 0x53,
LowBatteryWarning = 0x54,
LowBatteryBluetoothOff = 0x55,
ReadBatteryVoltage = 0x56,
ReadBatteryVoltageResponse = 0x57,
- Accelerometer = 0xea
+ ReadLightSensor = 0x58,
+ ReadLightSensorResponse = 0x59
};
enum Mode {
@@ -113,12 +118,9 @@ public:
protected:
// Some configurable stuff.
+ short _notificationTimeout;
bool _24hMode : 1;
bool _dayMonthOrder : 1;
- bool _invertedIdle : 1;
- bool _invertedNotifications : 1;
- bool _invertedApplications : 1;
- short _notificationTimeout;
// Notifications: timers
QTimer* _idleTimer;
@@ -170,22 +172,22 @@ protected:
void send(const Message& msg);
void setVibrateMode(bool enable, uint on, uint off, uint cycles);
- void updateLine(Mode mode, const QImage& image, int line);
- void updateLines(Mode mode, const QImage& image, int lineA, int lineB);
- void updateLines(Mode mode, const QImage& image, const QVector<bool>& lines);
- void configureWatchMode(Mode mode, int timeout, bool invert);
- void configureIdleSystemArea(bool entireScreen);
- void updateDisplay(Mode mode, bool copy = true);
- void loadTemplate(Mode mode, int templ);
+ void updateLcdLine(Mode mode, const QImage& image, int line);
+ void updateLcdLines(Mode mode, const QImage& image, int lineA, int lineB);
+ void updateLcdLines(Mode mode, const QImage& image, const QVector<bool>& lines);
+ void configureLcdIdleSystemArea(bool entireScreen);
+ void updateLcdDisplay(Mode mode, bool copy = true);
+ void loadLcdTemplate(Mode mode, int templ);
void enableButton(Mode mode, Button button, ButtonPress press);
void disableButton(Mode mode, Button button, ButtonPress press);
+ void handleMessage(const Message& msg);
+ void handleStatusChangeMessage(const Message& msg);
+ void handleButtonEventMessage(const Message& msg);
+
virtual void handleWatchConnected() = 0;
- virtual void handleStatusChange(const Message& msg);
- virtual void handleButtonEvent(const Message& msg);
private slots:
- void handleMessage(const Message& msg);
void socketConnected();
void socketDisconnected();
void socketData();
diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp
index 2a25249..a4bb833 100644
--- a/metawatch/metawatchdigital.cpp
+++ b/metawatch/metawatchdigital.cpp
@@ -12,8 +12,6 @@ MetaWatchDigital::MetaWatchDigital(const QBluetoothAddress& address, QSettings*
_image[IdleMode] = baseImage;
_image[ApplicationMode] = baseImage;
_image[NotificationMode] = baseImage;
-
-
}
int MetaWatchDigital::metric(PaintDeviceMetric metric) const
@@ -81,14 +79,11 @@ void MetaWatchDigital::displayIdleScreen()
MetaWatch::displayIdleScreen();
// Usually, idle screen is kept updated, so we can flip it right away.
- updateDisplay(IdleMode);
+ updateLcdDisplay(IdleMode);
}
void MetaWatchDigital::displayNotification(Notification *n)
{
- const bool isCall = n->type() == Notification::CallNotification;
- configureWatchMode(NotificationMode, isCall ? 120 : 10, _invertedNotifications);
-
qDebug() << "display notification" << n->title() << n->body();
// Render the notification and display it before invoking haptic feedback
@@ -101,7 +96,7 @@ void MetaWatchDigital::displayNotification(Notification *n)
void MetaWatchDigital::displayApplication()
{
qDebug() << "entering application mode";
- configureWatchMode(ApplicationMode, 250, _invertedApplications);
+
MetaWatch::displayApplication();
}
@@ -118,16 +113,16 @@ void MetaWatchDigital::update(Mode mode, const QList<QRect> &rects)
}
}
- updateLines(mode, _image[mode], lines);
+ updateLcdLines(mode, _image[mode], lines);
if (mode == _currentMode) {
- updateDisplay(mode);
+ updateLcdDisplay(mode);
}
}
void MetaWatchDigital::clear(Mode mode, bool black)
{
if (!_connected) return;
- loadTemplate(mode, black ? 1 : 0);
+ loadLcdTemplate(mode, black ? 1 : 0);
}
void MetaWatchDigital::renderIdleScreen()
@@ -198,16 +193,6 @@ void MetaWatchDigital::renderIdleCounts()
_paintMode = _currentMode;
}
-void MetaWatchDigital::renderNotificationScreen()
-{
- _paintMode = NotificationMode;
- QPainter p(this);
-
- p.fillRect(0, 0, screenWidth, screenHeight, Qt::white);
-
- _paintMode = _currentMode;
-}
-
void MetaWatchDigital::renderNotification(Notification *n)
{
_paintMode = NotificationMode;
@@ -301,11 +286,8 @@ QImage MetaWatchDigital::iconForNotification(const Notification *n)
void MetaWatchDigital::handleWatchConnected()
{
// Configure to show watch-rendered clock in idle screen
- configureIdleSystemArea(false);
- // Follow inverted screen user preference
- configureWatchMode(IdleMode, 0, _invertedIdle);
+ configureLcdIdleSystemArea(false);
- // Render the idle screen from zero
+ // Render the idle screen assuming previous contents were lost
renderIdleScreen();
- renderNotificationScreen();
}
diff --git a/metawatch/metawatchdigital.h b/metawatch/metawatchdigital.h
index c75fc40..0754242 100644
--- a/metawatch/metawatchdigital.h
+++ b/metawatch/metawatchdigital.h
@@ -39,7 +39,6 @@ protected:
void renderIdleWeather();
void renderIdleCounts();
- void renderNotificationScreen();
void renderNotification(Notification *n);
QImage iconForNotification(const Notification *n);
};