]> git.kernelconcepts.de Git - metawatch.git/commitdiff
More callbacks, further GUI work
authorNils Faerber <nils.faerber@kernelconcepts.de>
Sat, 27 Aug 2011 18:38:16 +0000 (20:38 +0200)
committerNils Faerber <nils.faerber@kernelconcepts.de>
Sat, 27 Aug 2011 18:38:16 +0000 (20:38 +0200)
Makefile
gtk-gui/Makefile
gtk-gui/mw-client.c
gtk-gui/mw-client.glade
metawatch.c
metawatch.h
mw_main.c
mw_utility.c
mw_utility.h

index 310709872165fd126f5d1cc9b80d07195d941b89..e71d83734479e505b690cf6df5a510c0d0bc417e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 
 # prefix for installation and search path (like icons)
 PREFIX = /usr/local/
 
 # prefix for installation and search path (like icons)
 PREFIX = /usr/local/
-CFLAGS = -Wall -O2 $(CCFLAGS) `pkg-config --cflags glib-2.0` `pkg-config --cflags dbus-glib-1` `pkg-config --cflags dbus-1`
+CFLAGS = -Wall -g -DDEBUG -O2 $(CCFLAGS) `pkg-config --cflags glib-2.0` `pkg-config --cflags dbus-glib-1` `pkg-config --cflags dbus-1`
 #CFLAGS = -Wall -O2 $(CCFLAGS)
 
 LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1`
 #CFLAGS = -Wall -O2 $(CCFLAGS)
 
 LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1`
@@ -30,9 +30,9 @@ $(PRGNAME): $(OBJS)
        $(CC) -o $@ $^ $(LDFLAGS)
 
 libmetawatch.a: metawatch.o crc16ccitt.o mw_utility.o bt_helper.o
        $(CC) -o $@ $^ $(LDFLAGS)
 
 libmetawatch.a: metawatch.o crc16ccitt.o mw_utility.o bt_helper.o
-       ar -cvq libmetawatch.a metawatch.o crc16ccitt.o mw_utility.o bt_helper.o
+       rm -f libmetawatch.a; ar -cvq libmetawatch.a metawatch.o crc16ccitt.o mw_utility.o bt_helper.o
 
 clean:
 
 clean:
-       rm -f *.o *.d $(PRGNAME)
+       rm -f *.o *.d $(PRGNAME) libmetawatch.a
 
 -include $(DEPS)
 
 -include $(DEPS)
index 5de16abb97236339a3c625b756b782f2137e2c03..cb81f8522e050e25506669e5b3259904b12da43c 100644 (file)
@@ -4,7 +4,7 @@
 
 # prefix for installation and search path (like icons)
 PREFIX = /usr/local/
 
 # prefix for installation and search path (like icons)
 PREFIX = /usr/local/
-CFLAGS = -DDEBUG -Wall -O2 -Wl,--export-dynamic $(CCFLAGS) -I.. `pkg-config --cflags glib-2.0` `pkg-config --cflags dbus-glib-1` `pkg-config --cflags dbus-1` `pkg-config --cflags gtk+-2.0`
+CFLAGS = -DDEBUG -g -Wall -O2 -Wl,--export-dynamic $(CCFLAGS) -I.. `pkg-config --cflags glib-2.0` `pkg-config --cflags dbus-glib-1` `pkg-config --cflags dbus-1` `pkg-config --cflags gtk+-2.0`
 #CFLAGS = -Wall -O2 $(CCFLAGS)
 
 LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1` `pkg-config --libs gtk+-2.0` `pkg-config --libs gmodule-export-2.0` -L.. -lmetawatch
 #CFLAGS = -Wall -O2 $(CCFLAGS)
 
 LDFLAGS = `pkg-config --libs glib-2.0` `pkg-config --libs dbus-glib-1` `pkg-config --libs dbus-1` `pkg-config --libs gtk+-2.0` `pkg-config --libs gmodule-export-2.0` -L.. -lmetawatch
index b4dbab98e8b8d0b131595867bf61f1f9980a2d9e..37fdcc5d0a8561c1a3a4436c1568714377450955 100644 (file)
@@ -62,6 +62,38 @@ void mw_get_battery_voltage_response_cb(mwdevice_t *mwdevice, unsigned short *vo
        gtk_progress_bar_set_text(batbar, batstr);
 }
 
        gtk_progress_bar_set_text(batbar, batstr);
 }
 
+void on_notify_ok_clicked (GtkButton *button, gpointer user_data)
+{
+       mwdata_t *mdata = (mwdata_t *)user_data;
+       GtkWidget *notify_win;
+       GtkTextView *tview;
+       GtkTextBuffer *tbuf;
+       GtkTextIter siter, eiter;
+       gchar *text;
+
+       tview = GTK_TEXT_VIEW (gtk_builder_get_object (mdata->builder, "notify_textview"));
+       tbuf = gtk_text_view_get_buffer(tview);
+       gtk_text_buffer_get_start_iter(tbuf, &siter);
+       gtk_text_buffer_get_end_iter(tbuf, &eiter);
+
+       text = gtk_text_buffer_get_text(tbuf, &siter, &eiter, FALSE);
+
+       mw_do_notification(&mdata->mwdevice, "Notification", text, 2);
+
+       notify_win = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "notify_win"));
+       gtk_widget_hide (notify_win);
+}
+
+void on_notify_cancel_clicked (GtkButton *button, gpointer user_data)
+{
+       mwdata_t *mdata = (mwdata_t *)user_data;
+       GtkWidget *notify_win;
+
+       notify_win = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "notify_win"));
+       gtk_widget_hide (notify_win);
+}
+
+
 void on_rtc_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
 void on_rtc_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
@@ -72,7 +104,10 @@ void on_rtc_button_clicked (GtkButton *button, gpointer user_data)
 void on_notify_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
 void on_notify_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
+       GtkWidget *notify_win;
 
 
+       notify_win = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "notify_win"));
+       gtk_widget_show (notify_win);
 }
 
 void bitmap_read(mwdevice_t *mwdevice, char *filename)
 }
 
 void bitmap_read(mwdevice_t *mwdevice, char *filename)
@@ -143,6 +178,28 @@ void bitmap_read(mwdevice_t *mwdevice, char *filename)
        free(bmapbuf);
 }
 
        free(bmapbuf);
 }
 
+void on_vibrate_button_clicked (GtkButton *button, gpointer user_data)
+{
+       mwdata_t *mdata = (mwdata_t *)user_data;
+}
+
+void on_set_hands_clicked (GtkButton *button, gpointer user_data)
+{
+       mwdata_t *mdata = (mwdata_t *)user_data;
+       time_t mtime;
+       struct tm mtm;
+       unsigned short hour;
+
+       mtime = time(NULL);
+       localtime_r(&mtime, &mtm);
+
+       hour = (unsigned char) mtm.tm_hour;
+       if (hour > 12)
+               hour -= 12;
+
+       mw_advance_watch_hands(&mdata->mwdevice, hour, (unsigned char) mtm.tm_min, (unsigned char) mtm.tm_sec);
+}
+
 void on_bitmap_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
 void on_bitmap_button_clicked (GtkButton *button, gpointer user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
@@ -163,6 +220,31 @@ void on_bitmap_button_clicked (GtkButton *button, gpointer user_data)
        gtk_widget_destroy(dialog);
 }
 
        gtk_widget_destroy(dialog);
 }
 
+void setup_watchtype_gui(mwdata_t *mdata)
+{
+       GtkWidget *w;
+
+       if (mdata->mwdevice.devtype == MW_DEVICE_TYPE_DIGITAL || mdata->mwdevice.devtype == MW_DEVICE_TYPE_DEVB_DIGI) {
+               w = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "set_hands"));
+               gtk_widget_hide(w);
+       }
+       if (mdata->mwdevice.devtype == MW_DEVICE_TYPE_ANA_DIGI || mdata->mwdevice.devtype == MW_DEVICE_TYPE_DEVB_ANA_DIGI) { 
+               w = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "F_button_label"));
+               gtk_widget_hide(w);
+               w = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "E_button_label"));
+               gtk_widget_hide(w);
+               w = GTK_WIDGET (gtk_builder_get_object (mdata->builder, "D_button_label"));
+               gtk_widget_hide(w);
+       }
+}
+
+void mw_get_device_type_response_cb(mwdevice_t *mwdevice, unsigned char devtype, void *user_data)
+{
+       mwdata_t *mdata = (mwdata_t *)user_data;
+
+       setup_watchtype_gui(mdata);
+}
+
 void mw_get_real_time_clock_response_cb(mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
 void mw_get_real_time_clock_response_cb(mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data)
 {
        mwdata_t *mdata = (mwdata_t *)user_data;
@@ -182,7 +264,7 @@ gboolean handle_mw_io(GIOChannel *mw_io, GIOCondition condition, gpointer udata)
        int rcvd;
        int processed;
 
        int rcvd;
        int processed;
 
-       rcvd = read(mdata->mwdevice.mw_fd, mdata->rcvbuf+mdata->rcvbuf_pos, 64);
+       rcvd = read(mdata->mwdevice.mw_fd, mdata->rcvbuf/*+mdata->rcvbuf_pos*/, 64);
 #ifdef DEBUG
        fprintf(stderr, "read %d bytes:\n", rcvd);
 #endif
 #ifdef DEBUG
        fprintf(stderr, "read %d bytes:\n", rcvd);
 #endif
@@ -211,9 +293,7 @@ on_window_destroy (GtkObject *object, gpointer user_data)
 }
 
 
 }
 
 
-
-int
-main (int argc, char *argv[])
+int main (int argc, char *argv[])
 {
        GtkBuilder *builder; 
        GtkWidget *window;
 {
        GtkBuilder *builder; 
        GtkWidget *window;
@@ -269,6 +349,7 @@ main (int argc, char *argv[])
 
        mw_init(&mdata.mwdevice, mw_fd);
 
 
        mw_init(&mdata.mwdevice, mw_fd);
 
+       mw_set_get_device_type_response_cb(&mdata.mwdevice, mw_get_device_type_response_cb, &mdata);
        mw_set_get_real_time_clock_response_cb(&mdata.mwdevice, mw_get_real_time_clock_response_cb, &mdata);
        mw_set_get_battery_voltage_response_cb(&mdata.mwdevice, mw_get_battery_voltage_response_cb, &mdata);
 
        mw_set_get_real_time_clock_response_cb(&mdata.mwdevice, mw_get_real_time_clock_response_cb, &mdata);
        mw_set_get_battery_voltage_response_cb(&mdata.mwdevice, mw_get_battery_voltage_response_cb, &mdata);
 
@@ -276,7 +357,9 @@ main (int argc, char *argv[])
 
        mdata.bat_timeout_id = g_timeout_add_seconds(10, battery_level_get_timeout, &mdata);
 
 
        mdata.bat_timeout_id = g_timeout_add_seconds(10, battery_level_get_timeout, &mdata);
 
+       // setup_watchtype_gui(&mdata);
        gtk_main ();
 
        return 0;
 }
        gtk_main ();
 
        return 0;
 }
+
index 34a6559a2e485922ef2b2f80df11f1d12ada6074..e1db3b871b1d6c92e85d7e683ae5f32ffd3be44c 100644 (file)
           <object class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
           <object class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="n_rows">3</property>
+            <property name="n_rows">2</property>
             <property name="n_columns">3</property>
             <child>
               <object class="GtkVButtonBox" id="vbuttonbox1">
             <property name="n_columns">3</property>
             <child>
               <object class="GtkVButtonBox" id="vbuttonbox1">
                 <property name="bottom_attach">2</property>
               </packing>
             </child>
                 <property name="bottom_attach">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="rtc_button">
+                <property name="label" translatable="yes">RTC</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <signal name="clicked" handler="on_rtc_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkProgressBar" id="battery_status_bar">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="show_text">True</property>
+                    <property name="fraction">0.28571428571428592</property>
+                    <property name="text" translatable="yes">Battery</property>
+                    <property name="adjustment">bat_adjust</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="power_status_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">unknown</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkDrawingArea" id="drawingarea1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="info_button">
+                <property name="label">gtk-about</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="on_info_button_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="x_options"></property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbuttonbox2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <child>
               <object class="GtkButton" id="notify_button">
                 <property name="label" translatable="yes">Notification</property>
             <child>
               <object class="GtkButton" id="notify_button">
                 <property name="label" translatable="yes">Notification</property>
                 <signal name="clicked" handler="on_notify_button_clicked" swapped="no"/>
               </object>
               <packing>
                 <signal name="clicked" handler="on_notify_button_clicked" swapped="no"/>
               </object>
               <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
                 <signal name="clicked" handler="on_bitmap_button_clicked" swapped="no"/>
               </object>
               <packing>
                 <signal name="clicked" handler="on_bitmap_button_clicked" swapped="no"/>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
                 <property name="use_action_appearance">False</property>
                 <signal name="clicked" handler="on_vibrate_button_clicked" swapped="no"/>
               </object>
                 <property name="use_action_appearance">False</property>
                 <signal name="clicked" handler="on_vibrate_button_clicked" swapped="no"/>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="set_hands">
+                <property name="label" translatable="yes">Set Hands</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <signal name="clicked" handler="on_set_hands_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkStatusbar" id="statusbar1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">2</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="notify_win">
+    <property name="can_focus">False</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <child>
+      <object class="GtkVBox" id="vbox3">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="ypad">1</property>
+            <property name="label" translatable="yes">&lt;b&gt;Notification text&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="hscrollbar_policy">automatic</property>
+            <property name="vscrollbar_policy">automatic</property>
+            <child>
+              <object class="GtkTextView" id="notify_textview">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbuttonbox1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkButton" id="notify_cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="on_notify_cancel_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="notify_ok">
+                <property name="label">gtk-apply</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+                <signal name="clicked" handler="on_notify_ok_clicked" swapped="no"/>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkVBox" id="vbox4">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">&lt;b&gt;RTC&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="padding">5</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkTable" id="table3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="n_rows">2</property>
+            <property name="n_columns">4</property>
+            <child>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Date</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Time</property>
+              </object>
               <packing>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
               <packing>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="rtc_button">
-                <property name="label" translatable="yes">RTC</property>
+              <object class="GtkRadioButton" id="h12_radio">
+                <property name="label" translatable="yes">12h</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="receives_default">False</property>
                 <property name="use_action_appearance">False</property>
                 <property name="use_action_appearance">False</property>
-                <signal name="clicked" handler="on_rtc_button_clicked" swapped="no"/>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <property name="group">h24_radio</property>
               </object>
               <packing>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="left_attach">2</property>
+                <property name="right_attach">3</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkRadioButton" id="h24_radio">
+                <property name="label" translatable="yes">24h</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_action_appearance">False</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
             </child>
             <child>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox2">
+              <object class="GtkVBox" id="vbox6">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkProgressBar" id="battery_status_bar">
+                  <object class="GtkCalendar" id="calendar1">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="show_text">True</property>
-                    <property name="fraction">0.28571428571428592</property>
-                    <property name="text" translatable="yes">Battery</property>
-                    <property name="adjustment">bat_adjust</property>
+                    <property name="can_focus">True</property>
+                    <property name="year">2011</property>
+                    <property name="month">7</property>
+                    <property name="day">21</property>
+                    <property name="show_week_numbers">True</property>
                   </object>
                   <packing>
                     <property name="expand">True</property>
                   </object>
                   <packing>
                     <property name="expand">True</property>
                   </packing>
                 </child>
                 <child>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="power_status_label">
+                  <object class="GtkHBox" id="hbox1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">unknown</property>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Format</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="mmdd_radio">
+                        <property name="label" translatable="yes">MM/DD</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">ddmm_radio</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="ddmm_radio">
+                        <property name="label" translatable="yes">DD.MM</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">True</property>
                   </object>
                   <packing>
                     <property name="expand">True</property>
                   </packing>
                 </child>
               </object>
                   </packing>
                 </child>
               </object>
-              <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkDrawingArea" id="drawingarea1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
               </packing>
             </child>
               </packing>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </object>
           <packing>
             <property name="expand">True</property>
           </object>
           <packing>
             <property name="expand">True</property>
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <object class="GtkStatusbar" id="statusbar1">
+          <object class="GtkHButtonBox" id="hbuttonbox3">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="spacing">2</property>
+            <child>
+              <object class="GtkVBox" id="vbox5">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkButton" id="get_watch_rtc_button">
+                    <property name="label" translatable="yes">Get RTC from
+watch</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="get_sys_rtc_button">
+                    <property name="label" translatable="yes">Get RTC from
+System</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_action_appearance">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="set_rtc_button">
+                <property name="label" translatable="yes">Set RTC</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="rtc_ok_button">
+                <property name="label">gtk-apply</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
           </object>
           <packing>
           </object>
           <packing>
-            <property name="expand">False</property>
+            <property name="expand">True</property>
             <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
             <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
index 08d5aca2bd08861837a07dd5b6fa64ef273c83e5..5c5b73bfea3c36f3d939cf84d82d251964d56d6d 100644 (file)
@@ -222,6 +222,7 @@ int mw_write_oled_buffer(mwdevice_t *mwdevice,
        if (mwdevice->devtype != MW_DEVICE_TYPE_ANA_DIGI && mwdevice->devtype != MW_DEVICE_TYPE_DEVB_ANA_DIGI)
                return -1;
        
        if (mwdevice->devtype != MW_DEVICE_TYPE_ANA_DIGI && mwdevice->devtype != MW_DEVICE_TYPE_DEVB_ANA_DIGI)
                return -1;
        
+       fprintf(stderr, "write oled buf len = %d\n", buflen);
        /* lower row first since display wil be updated after completion of upper row */
        if (buflen > 80) {
                for (i=80; i<buflen; i+=20) {
        /* lower row first since display wil be updated after completion of upper row */
        if (buflen > 80) {
                for (i=80; i<buflen; i+=20) {
@@ -235,6 +236,7 @@ int mw_write_oled_buffer(mwdevice_t *mwdevice,
                memcpy((mdata+1), (buffer+i), 20);
                mw_send_frame(mwdevice, MW_WRITE_OLED_IDLE_DISPLAY_MSG, 1 | (oled ? 2 : 0), mdata, 21);
        }
                memcpy((mdata+1), (buffer+i), 20);
                mw_send_frame(mwdevice, MW_WRITE_OLED_IDLE_DISPLAY_MSG, 1 | (oled ? 2 : 0), mdata, 21);
        }
+
        return 0;
 }
 
        return 0;
 }
 
@@ -272,11 +274,69 @@ int mw_disable_button(mwdevice_t *mwdevice,
        return mw_send_frame(mwdevice, MW_ENABLE_BUTTON, 0, mdata, 3);
 }
 
        return mw_send_frame(mwdevice, MW_ENABLE_BUTTON, 0, mdata, 3);
 }
 
+int mw_advance_watch_hands(mwdevice_t *mwdevice, unsigned char hours, unsigned char minutes, unsigned char seconds)
+{
+       unsigned char mdata[4];
+       
+       if (hours > 12)
+               return -1;
+       if (minutes > 60)
+               return -1;
+       if (seconds > 60)
+               return -1;
+
+       mdata[0] = hours;
+       mdata[1] = minutes;
+       mdata[2] = seconds;
+
+       return mw_send_frame(mwdevice, MW_ADVANCE_WATCH_HANDS, 0, mdata, 3);
+}
+
 /* ----------------------------------------------------------------------
  * Watch responses, events or notifications
  * ---------------------------------------------------------------------- */
 
 
 /* ----------------------------------------------------------------------
  * Watch responses, events or notifications
  * ---------------------------------------------------------------------- */
 
 
+int mw_get_device_type_response(mwdevice_t *mwdevice, unsigned char devtype)
+{
+#ifdef DEBUG
+       fprintf(stderr, "Got device type ");
+       switch(devtype) {
+               case 0:
+                       fprintf(stderr, "Reserved\n");
+                       break;
+               case 1:
+                       fprintf(stderr, "Ana-Digi\n");
+                       break;
+               case 2:
+                       fprintf(stderr, "Digital\n");
+                       break;
+               case 3:
+                       fprintf(stderr, "Development Board Digital\n");
+                       break;
+               case 4:
+                       fprintf(stderr, "Development Board Ana-Digi\n");
+                       break;
+               default:
+                       fprintf(stderr, "unknown %d\n", devtype);
+                       break;
+       };
+#endif
+       mwdevice->devtype = devtype;
+       if (mwdevice->mw_get_device_type_response_cb != NULL)
+               mwdevice->mw_get_device_type_response_cb(mwdevice, devtype, mwdevice->mw_gdtypersp_data);
+       return 0;
+}
+
+void mw_set_get_device_type_response_cb(mwdevice_t *mwdevice, void (*mw_get_device_type_response_cb) (mwdevice_t *mwdevice, unsigned char devtype, void *user_data), void *user_data)
+{
+       if (mw_get_device_type_response_cb != NULL)
+               mwdevice->mw_get_device_type_response_cb = mw_get_device_type_response_cb;
+       if (user_data != NULL)
+               mwdevice->mw_gdtypersp_data = user_data;
+}
+
+
 int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len)
 {
        struct tm mtm;
 int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len)
 {
        struct tm mtm;
@@ -435,18 +495,10 @@ int decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len)
                fprintf(stderr, "decode frame CRC error\n");
                return -1;
        }
                fprintf(stderr, "decode frame CRC error\n");
                return -1;
        }
-#ifdef DEBUG
-        else
-               fprintf(stderr, "decode frame CRC OK\n");
-#endif
        if (buf[0] != MW_SOF) {
                fprintf(stderr, "decode frame SOF not found\n");
                return -1;
        }
        if (buf[0] != MW_SOF) {
                fprintf(stderr, "decode frame SOF not found\n");
                return -1;
        }
-#ifdef DEBUG
-        else
-       fprintf(stderr, "decode frame found SOF\n");
-#endif
 
        msglen = buf[1];
        msgtype = buf[2];
 
        msglen = buf[1];
        msgtype = buf[2];
@@ -456,28 +508,7 @@ int decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len)
 
        switch (msgtype) {
                case MW_GET_DEVICE_TYPE_RSP:
 
        switch (msgtype) {
                case MW_GET_DEVICE_TYPE_RSP:
-                       fprintf(stderr, "Got device type ");
-                       switch(msgdata[0]) {
-                               case 0:
-                                       fprintf(stderr, "Reserved\n");
-                                       break;
-                               case 1:
-                                       fprintf(stderr, "Ana-Digi\n");
-                                       break;
-                               case 2:
-                                       fprintf(stderr, "Digital\n");
-                                       break;
-                               case 3:
-                                       fprintf(stderr, "Development Board Digital\n");
-                                       break;
-                               case 4:
-                                       fprintf(stderr, "Development Board Ana-Digi\n");
-                                       break;
-                               default:
-                                       fprintf(stderr, "unknown %d\n", msgdata[0]);
-                                       break;
-                       };
-                       mwdevice->devtype = msgdata[0];
+                       mw_get_device_type_response(mwdevice, msgdata[0]);
                        break;
                case MW_GET_INFORMATION_STRING_RSP:
                        msgdata[len-2] = 0;
                        break;
                case MW_GET_INFORMATION_STRING_RSP:
                        msgdata[len-2] = 0;
index eb93784fb86cec92cfcaf13d4d3505eaddf50cb0..5df07a07493d70242c29e29467eece3e5e52204e 100644 (file)
@@ -13,6 +13,9 @@
 typedef struct _mwdevice_t {
        int mw_fd;              /* file decriptor for MW connection */
        unsigned char devtype;  /* the device type of the connected device */
 typedef struct _mwdevice_t {
        int mw_fd;              /* file decriptor for MW connection */
        unsigned char devtype;  /* the device type of the connected device */
+       /* watch message callbacks */
+       void (*mw_get_device_type_response_cb) (struct _mwdevice_t *mwdevice, unsigned char devtype, void *user_data);
+       void *mw_gdtypersp_data;
        void (*mw_get_real_time_clock_response_cb) (struct _mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data);
        void *mw_grtcrsp_data;
        void (*mw_get_battery_voltage_response_cb) (struct _mwdevice_t *mwdevice, unsigned short *voltage, unsigned char *pgood, unsigned char *charging, void *user_data);
        void (*mw_get_real_time_clock_response_cb) (struct _mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data);
        void *mw_grtcrsp_data;
        void (*mw_get_battery_voltage_response_cb) (struct _mwdevice_t *mwdevice, unsigned short *voltage, unsigned char *pgood, unsigned char *charging, void *user_data);
@@ -53,6 +56,9 @@ int mw_write_oled_buffer(mwdevice_t *mwdevice,
        unsigned char col_index, /* starting index */
        unsigned char *buffer, int buflen);
 
        unsigned char col_index, /* starting index */
        unsigned char *buffer, int buflen);
 
+int mw_get_device_type_response(mwdevice_t *mwdevice, unsigned char devtype);
+void mw_set_get_device_type_response_cb(mwdevice_t *mwdevice, void (*mw_get_device_type_response_cb) (mwdevice_t *mwdevice, unsigned char devtype, void *user_data), void *user_data);
+
 int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len);
 void mw_set_get_real_time_clock_response_cb(mwdevice_t *mwdevice, void (*mw_get_real_time_clock_response_cb) (mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data), void *user_data);
 
 int mw_get_real_time_clock_response(mwdevice_t *mwdevice, unsigned char *rtcrsp, int len);
 void mw_set_get_real_time_clock_response_cb(mwdevice_t *mwdevice, void (*mw_get_real_time_clock_response_cb) (mwdevice_t *mwdevice, struct tm *mw_tm, void *user_data), void *user_data);
 
@@ -71,6 +77,8 @@ int mw_enable_button(mwdevice_t *mwdevice, unsigned char mode, unsigned char but
 
 int mw_disable_button(mwdevice_t *mwdevice, unsigned char mode, unsigned char button_index, unsigned char press_type);
 
 
 int mw_disable_button(mwdevice_t *mwdevice, unsigned char mode, unsigned char button_index, unsigned char press_type);
 
+int mw_advance_watch_hands(mwdevice_t *mwdevice, unsigned char hours, unsigned char minutes, unsigned char seconds);
+
 int decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len);
 
 int mw_init(mwdevice_t *mwdevice, int mw_fd);
 int decode_frame(mwdevice_t *mwdevice, unsigned char *buf, int len);
 
 int mw_init(mwdevice_t *mwdevice, int mw_fd);
index c08b2d307320a30233d5a2fac050acf06a591466..dd4e4a418854697272b400113a153aa2888350c8 100644 (file)
--- a/mw_main.c
+++ b/mw_main.c
@@ -343,7 +343,7 @@ void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
        }
        if (strncmp(cmdline, "srtc", 4) == 0) {
                fprintf(stderr, "Setting RTC from system time...");
        }
        if (strncmp(cmdline, "srtc", 4) == 0) {
                fprintf(stderr, "Setting RTC from system time...");
-               mw_set_rtc(&mwdata->mwdevice, MW_RTC_CLOCK_24HR, MW_RTC_DATE_DDMM);
+               mw_set_rtc(&mwdata->mwdevice, MW_RTC_CLOCK_12HR, MW_RTC_DATE_MMDD);
                fprintf(stderr, "OK\n");
        }
        if (strncmp(cmdline, "grtc", 4) == 0) {
                fprintf(stderr, "OK\n");
        }
        if (strncmp(cmdline, "grtc", 4) == 0) {
@@ -399,7 +399,8 @@ void process_cmd(char *cmdline, int clinep, mwdata_t *mwdata)
                bitmap_read(&mwdata->mwdevice);
        }
        if (strncmp(cmdline, "tnote", 5) == 0) {
                bitmap_read(&mwdata->mwdevice);
        }
        if (strncmp(cmdline, "tnote", 5) == 0) {
-               test_notification(&mwdata->mwdevice);
+               // test_notification(&mwdata->mwdevice);
+               mw_do_notification(&mwdata->mwdevice, "TestNotification", "This is a pretty long text that needs to be broken and torn", 1);
        }
        if (strncmp(cmdline, "tapp", 4) == 0) {
                test_application(&mwdata->mwdevice);
        }
        if (strncmp(cmdline, "tapp", 4) == 0) {
                test_application(&mwdata->mwdevice);
@@ -598,6 +599,8 @@ int main(int argc, char **argv)
        memset(mdata.cmdline, 0, 128);
        mdata.cmdline_pos = 0;
 
        memset(mdata.cmdline, 0, 128);
        mdata.cmdline_pos = 0;
 
+       mw_init(&mdata.mwdevice, mw_fd);
+
        g_main_loop_run (mdata.mloop);
 
        fsync(mw_fd);
        g_main_loop_run (mdata.mloop);
 
        fsync(mw_fd);
index 2ddc12dde098f7e2dafe4f9b9bb2ac0f5ed2893f..53c5f7ab3000e401e5d4f511d25eefe6453763f4 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
 #include <string.h>
 #include <stdio.h>
 
-#include "mw_utility.h"
 #include "metawatch.h"
 #include "metawatch.h"
+#include "mw_utility.h"
 
 #include "fonts.h"
 
 
 #include "fonts.h"
 
+/* ----------------------------------------------------------------------
+ * Generic drawing functions
+ * ---------------------------------------------------------------------- */
+
 /*
  * The pixmap buffer has at least one byte per pixel, even for monochrome (bpp=1)
  * bitmaps
 /*
  * The pixmap buffer has at least one byte per pixel, even for monochrome (bpp=1)
  * bitmaps
@@ -252,3 +256,93 @@ void mw_buf_draw_line_bresenham(mw_buffer *mwbuf, unsigned int xstart, unsigned
        }
 }
 
        }
 }
 
+
+/* ----------------------------------------------------------------------
+ * Complex combined functions, for user convenience
+ * ---------------------------------------------------------------------- */
+
+/*
+ * send a text notification, automatically take care of device type (ana/digi)
+ * char *title is displayed inverse in top line
+ * char *text is the notification text
+ * vibrate is the number of 300ms vibrations, 0 for none
+ */
+void mw_do_notification(mwdevice_t *mwdevice, char *title, char *text, unsigned char vibrate)
+{
+       mw_buffer *mwbuf;
+       unsigned char *bbuf;
+       int len,i,c,r;
+       char sstr[32];
+
+       // fprintf(stderr, "do_notify devtype=%d, title='%s', text='%s', vibrate=%d\n", mwdevice->devtype, title, text, vibrate);
+       if (mwdevice->devtype == MW_DEVICE_TYPE_DIGITAL || mwdevice->devtype == MW_DEVICE_TYPE_DEVB_DIGI) {
+               mwbuf = mw_alloc_pbuffer(96, 96, 1);
+               mw_buf_clear(mwbuf, MW_BLACK);
+
+               mw_buf_print(mwbuf, 0,  0, title, 0, MW_BLACK, MW_WHITE);
+
+               i=0;
+               c=0; r=1;
+               memset(sstr,0,32);
+               while (i<strlen(text)) {
+                       sstr[c++] = text[i++];
+                       if (c>=16 || i>=strlen(text)) {
+                               mw_buf_print(mwbuf, 0,  r*9, sstr, 0, MW_WHITE, MW_BLACK);
+                               memset(sstr,0,32);
+                               c=0; r++;
+                               if (r>10)
+                                       break;
+                       };
+               };
+
+               bbuf = mw_make_mw_buffer(mwbuf, &len);
+               mw_send_bitmap(mwdevice, MW_SCREEN_MODE_NOTIFICATION, 96, 96, 0, bbuf, len);
+               mw_update_display(mwdevice, MW_SCREEN_MODE_NOTIFICATION, 1);
+               mw_free_pbuffer(mwbuf);
+       } else if (mwdevice->devtype == MW_DEVICE_TYPE_ANA_DIGI || mwdevice->devtype == MW_DEVICE_TYPE_DEVB_ANA_DIGI) {
+               fprintf(stderr, "do notify OLED\n");
+               mwbuf = mw_alloc_pbuffer(80, 16, 1);
+               mw_buf_clear(mwbuf, MW_BLACK);
+
+               mw_buf_print(mwbuf, 0,  0, title, 0, MW_BLACK, MW_WHITE);
+
+               i=0;
+               c=0; r=1;
+               memset(sstr,0,32);
+               while (i<strlen(text) && r<2) {
+                       sstr[c++] = text[i++];
+                       if (c>=13 || i>=strlen(text)) {
+                               mw_buf_print(mwbuf, 0,  r*9, sstr, 0, MW_WHITE, MW_BLACK);
+                               memset(sstr,0,32);
+                               c=0; r++;
+                       };
+               };
+
+               bbuf = mw_make_mw_oled_buffer(mwbuf, &len);
+               mw_write_oled_buffer(mwdevice, 0, MW_OLED_UPPER, 80, 0, bbuf, len);
+
+               mw_buf_clear(mwbuf, MW_BLACK);
+               c=0; r=0;
+               memset(sstr,0,32);
+               while (i<strlen(text) && r<2) {
+                       sstr[c++] = text[i++];
+                       if (c>=13 || i>=strlen(text)) {
+                               mw_buf_print(mwbuf, 0,  r*9, sstr, 0, MW_WHITE, MW_BLACK);
+                               memset(sstr,0,32);
+                               c=0; r++;
+                               if (r>2)
+                                       break;
+                       };
+               };
+
+               bbuf = mw_make_mw_oled_buffer(mwbuf, &len);
+               mw_write_oled_buffer(mwdevice, 0, MW_OLED_LOWER, 80, 0, bbuf, len);
+
+               mw_free_pbuffer(mwbuf);
+       } else
+               fprintf(stderr, "Watch type not set - forgot to call mw_init()?\n");
+
+       if (vibrate)
+               mw_set_vibrate_mode(mwdevice, 1, 300, 300, vibrate);
+}
+
index 806772955864c199cce5b9186d2e8bcf6116a11c..7092818a86b0e8fd0ec1b53c4f684e0d5bf01b28 100644 (file)
@@ -54,5 +54,8 @@ void mw_buf_print(mw_buffer *mwbuf, unsigned int x, unsigned int y, char *text,
 
 void mw_buf_draw_line_bresenham(mw_buffer *mwbuf, unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, mw_color clr);
 
 
 void mw_buf_draw_line_bresenham(mw_buffer *mwbuf, unsigned int xstart, unsigned int ystart, unsigned int xend, unsigned int yend, mw_color clr);
 
+
+void mw_do_notification(mwdevice_t *mwdevice, char *title, char *text, unsigned char vibrate);
+
 #endif
 
 #endif