]> git.kernelconcepts.de Git - metawatch.git/blobdiff - mw_utility.c
Start OLED support for ana-digi
[metawatch.git] / mw_utility.c
index baf3d0a07d94eb30da3adfc5776403674e77a12e..2ddc12dde098f7e2dafe4f9b9bb2ac0f5ed2893f 100644 (file)
@@ -64,8 +64,10 @@ void mw_free_pbuffer(mw_buffer *mwbuf)
 }
 
 /*
- * 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)
 {
@@ -88,6 +90,27 @@ 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;