+void mw_load_template(int mw_fd, unsigned char mode, unsigned char template_select)
+{
+ mw_send_frame(mw_fd, MW_LOAD_TEMPLATE, (mode & 0x0f), &template_select, 1);
+}
+
+/*
+ * send line for screen-mode mode from *buffer to watch, starting at display row row_offset
+ */
+void mw_write_buffer(int mw_fd,
+ unsigned char mode,
+ unsigned char numlines, /* number of lines, 0 or 1 */
+ unsigned char row_offset, /* start at row_offset in display, e.g. lower part in idle @31 */
+ unsigned char *buffer, int buflen)
+{
+ unsigned char mdata[32];
+
+ buflen = 12 * (buflen / 12); /* crop to 12 bytes */
+ if ((numlines == 0 && buflen < 12) || (numlines == 1 && buflen < 24)) {
+ fprintf(stderr, "mw_write_buffer: bufferlen does not match number of lines\n");
+ return;
+ };
+ memset(mdata, 0, 32);
+ mdata[0] = row_offset;
+ memcpy((mdata+1), buffer, 12);
+ if (numlines == 1) {
+ mdata[0] = row_offset+1;
+ memcpy((mdata+13), (buffer+12), 12);
+ };
+ mw_send_frame(mw_fd, MW_WRITE_BUFFER, (mode & 0x0f) | (((numlines & 0x01)<< 3) & 0x10), mdata, numlines ? 13 : 26);
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+