mw_send_frame(mw_fd, MW_WRITE_BUFFER, (mode & 0x0f) | (((numlines & 0x01)<< 4) & 0x10), mdata, numlines ? 13 : 26);
}
+/*
+ Options:
+ B0 : row select, 0 first row, 1 second row
+ B1 : display select, 0 upper OLED, 1 lower OLED
+ B2 : if 1 send an event upon completion
+ B3..4: scroll type,
+ B5..7: unused
+ Scroll types:
+ B0: First buffer in a chain of scroll buffers
+ B1: Any buffer except first or last
+ B2: Last buffer of a chain
+ B3: reserved / unused
+ Payload:
+ 0: Start index col
+ 1..: data
+*/
+void mw_write_oled_buffer(int mw_fd,
+ unsigned char mode, /* idle or scroll */
+ unsigned char oled, /* which OLED */
+ unsigned char numcols,
+ unsigned char col_index, /* starting index */
+ unsigned char *buffer, int buflen)
+{
+ unsigned char mdata[32];
+ int i;
+
+ /* lower row first since display wil be updated after completion of upper row */
+ if (buflen > 80) {
+ for (i=80; i<buflen; i+=20) {
+ mdata[0] = (i-80);
+ memcpy((mdata+1), (buffer+i), 20);
+ mw_send_frame(mw_fd, MW_WRITE_OLED_IDLE_DISPLAY_MSG, 0 | (oled ? 2 : 0), mdata, 21);
+ }
+ }
+ for (i=0; i<80; i+=20) {
+ mdata[0] = i;
+ memcpy((mdata+1), (buffer+i), 20);
+ mw_send_frame(mw_fd, MW_WRITE_OLED_IDLE_DISPLAY_MSG, 1 | (oled ? 2 : 0), mdata, 21);
+ }
+}
+
void mw_enable_button(int mw_fd,
unsigned char mode,
unsigned char button_index,
--- /dev/null
+/*
+ * (c) 2011 Siegen, Germany by Nils Faerber <nils.faerber@kernelconcepts.de>
+ *
+ * license LGPL
+ */
+
+#ifndef _METAWATCH_H
+#define _METAWATCH_H
+
+#include "metawatch_protocol.h"
+
+void dump_frame(unsigned char *frame, int len);
+
+
+int mw_send_frame(int mw_fd, unsigned char msg_type, unsigned char options, unsigned char *data, unsigned char len);
+
+void mw_set_rtc(int mw_fd, unsigned char clk1224, unsigned char date_fmt);
+
+void mw_set_vibrate_mode(int mw_fd, unsigned char enable, unsigned short on_time, unsigned short off_time, unsigned char cycles);
+
+void mw_configure_watch_mode(int mw_fd, unsigned char mode, unsigned char save, unsigned char timeout, unsigned char invert);
+
+void mw_update_display(int mw_fd, unsigned char mode, unsigned char copy);
+
+void mw_load_template(int mw_fd, unsigned char mode, unsigned char template_select);
+
+void mw_write_buffer(int mw_fd,
+ unsigned char mode,
+ unsigned char numlines, /* number of lines, 0=two lines or 1=one line */
+ unsigned char row_offset, /* start at row_offset in display, e.g. lower part in idle @31 */
+ unsigned char *buffer, int buflen);
+
+void mw_write_oled_buffer(int mw_fd,
+ unsigned char mode, /* idle or scroll */
+ unsigned char oled, /* which OLED */
+ unsigned char numcols,
+ unsigned char col_index, /* starting index */
+ unsigned char *buffer, int buflen);
+
+void mw_get_real_time_clock_response(int mw_fd, unsigned char *rtcrsp, int len);
+
+void mw_get_battery_voltage_response(int mw_fd, unsigned char *batrsp, int len);
+
+void mw_status_change_event(int mw_fd, unsigned char option, unsigned char *statrsp, int len);
+
+void mw_enable_button(int mw_fd, unsigned char mode, unsigned char button_index, unsigned char press_type, unsigned char callback_type, unsigned char callback_option);
+
+void mw_disable_button(int mw_fd, unsigned char mode, unsigned char button_index, unsigned char press_type);
+
+int decode_frame(int mw_fd, unsigned char *buf, int len);
+
+
+void bmap_buffer_flipinvert(unsigned char flip, unsigned char invert, unsigned char *buf, int len);
+void mw_send_bitmap(int mw_fd, unsigned char mode, int width, int height, int offset, unsigned char *bmapbuf, int buflen);
+
+#endif /* _METAWATCH_H */
+
#define MW_SOF 0x01
+/* general */
#define MW_GET_DEVICE_TYPE 0x01
#define MW_GET_DEVICE_TYPE_RSP 0x02
#define MW_GET_INFORMATION_STRING 0x03
#define MW_GET_INFORMATION_STRING_RSP 0x04
+/* specific for ana-digi version */
+#define MW_UPDATE_OLED_DISPLAY_MSG 0x10
+#define MW_WRITE_OLED_IDLE_DISPLAY_MSG 0x11
+#define MW_WRITE_OLED_SCROLL_BUFFER_MSG 0x15
+#define MW_ENABLE_OLED_DISPLAY_MSG 0x16
#define MW_ADVANCE_WATCH_HANDS 0x20
+
#define MW_SET_VIBRATE_MODE 0x23
#define MW_SET_REAL_TIME_CLOCK 0x26
#define MW_STATUS_CHANGE_EVENT 0x33
#define MW_BUTTON_EVENT_MESSAGE 0x34
+/* specific for digital version */
#define MW_WRITE_BUFFER 0x40
#define MW_CONFIGURE_MODE 0x41
#define MW_CONFIGURE_IDLE_BUFFER_SIZE 0x42
#define MW_BUTTON_F 0x06
#define MW_BUTTON_PULLSW 0x07
+/* button events */
#define MW_BUTTON_IMMEDIATE 0x00
#define MW_BUTTON_PRESS_AND_RELEASE 0x01
#define MW_BUTTON_HOLD_RELEASE 0x02
#define MW_BUTTON_LONG_HOLD_RELEASE 0x03
+/* OLEDs */
+
+#define MW_OLED_UPPER 0x00
+#define MW_OLED_LOWER 0x01
#endif
mw_free_pbuffer(mwbuf);
}
+void test_oled(int mw_fd, unsigned char oled)
+{
+ mw_buffer *mwbuf;
+ unsigned char *bbuf;
+ int len, i;
+
+ mwbuf = mw_alloc_pbuffer(80, 16, 1);
+ mw_buf_clear(mwbuf, MW_BLACK);
+
+ mw_buf_print(mwbuf, 0, 0, "ApplicatiO", 0, MW_WHITE, MW_BLACK);
+ mw_buf_print(mwbuf, 0, 8, "0123456789", 0, MW_WHITE, MW_BLACK);
+
+ bbuf = mw_make_mw_oled_buffer(mwbuf, &len);
+ mw_write_oled_buffer(mw_fd, 0, oled, 80, 0, bbuf, len);
+
+ mw_free_pbuffer(mwbuf);
+}
+
void print_help(void)
{
}
if (strncmp(cmdline, "help", 4) == 0) {
print_help();
}
+ if (strncmp(cmdline, "ahand", 5) == 0) {
+ intopt = atoi(cmdline+5);
+ g_print("Advance analog hands by %d minutes\n", intopt);
+ mdata[0] = intopt / 60;
+ mdata[1] = intopt % 60;
+ mdata[2] = 0;
+ mw_send_frame(mw_fd, MW_ADVANCE_WATCH_HANDS, 0, mdata, 3);
+ }
if (strncmp(cmdline, "srtc", 4) == 0) {
fprintf(stderr, "Setting RTC from system time...");
mw_set_rtc(mw_fd, MW_RTC_CLOCK_24HR, MW_RTC_DATE_DDMM);
if (strncmp(cmdline, "tapp", 4) == 0) {
test_application(mw_fd);
}
+ if (strncmp(cmdline, "eoled", 5) == 0) {
+ intopt = cmdline[6]-0x30;
+ if (intopt == MW_OLED_UPPER || intopt == MW_OLED_LOWER)
+ mw_send_frame(mw_fd, MW_ENABLE_OLED_DISPLAY_MSG, intopt, NULL, 0);
+ }
+ if (strncmp(cmdline, "toled", 5) == 0) {
+ intopt = cmdline[6]-0x30;
+ test_oled(mw_fd, intopt);
+ //mw_write_oled_buffer(mw_fd, 0, 80, 0, mdata, 10);
+ //mw_send_frame(mw_fd, MW_UPDATE_OLED_DISPLAY_MSG, 0, NULL, 0);
+ }
}
}
/*
- * makes a buffer for sending to the watch from the drawing buffer, e.g.
+ * makes a buffer for sending to the LCD watch from the drawing buffer, e.g.
* mw_send_bitmap(mw_fd, MW_SCREEN_MODE_IDLE, 96, 65, 31, bbuf, len);
+ *
+ * NOT reentrant !
*/
unsigned char *mw_make_mw_buffer(mw_buffer *mwbuf, int *buflen)
{
return wbuf;
}
+unsigned char *mw_make_mw_oled_buffer(mw_buffer *mwbuf, int *buflen)
+{
+ static unsigned char wbuf[2*80]; /* size of one OLED, two rows */
+ int x, y;
+ unsigned char clr;
+
+ memset(wbuf, 0, 2*80);
+
+ for (x=0; x<mwbuf->res_x; x++) {
+ for (y=0; y<mwbuf->res_y; y++) {
+ clr = *(unsigned char *)(mwbuf->pbuf+((y*mwbuf->res_x)+x));
+ if (clr) {
+ *(unsigned char *)(wbuf+(x+80*(y/8))) |= 1 << (7-(y%8));
+ }
+ }
+ }
+ *buflen = (mwbuf->res_y / 8) * 80;
+
+ return wbuf;
+}
+
void mw_dump_mw_buffer(mw_buffer *mwbuf)
{
int x, y;
/* makes a buffer for sending to the watch from the drawing buffer */
unsigned char *mw_make_mw_buffer(mw_buffer *mwbuf, int *buflen);
+unsigned char *mw_make_mw_oled_buffer(mw_buffer *mwbuf, int *buflen);
void mw_dump_mw_buffer(mw_buffer *mwbuf);