]> git.kernelconcepts.de Git - metawatch.git/blobdiff - mw_main.c
Fixes and enhancements
[metawatch.git] / mw_main.c
index 5dae442aa9f10780cc4e8af3bb9b0ce2ee0dc4b8..0bcd41cd83c3925b6386d9957833b622e28cb772 100644 (file)
--- a/mw_main.c
+++ b/mw_main.c
@@ -51,7 +51,10 @@ void bitmap_read(int mw_fd)
 {
        int ffd, ret;
        char rbuf[256];
-       unsigned int width, height, i, x, y;
+       unsigned int width, height, i;
+#ifdef DEBUG
+       unsigned int x, y;
+#endif
        unsigned int rowlength;
        unsigned char *bmapbuf;
        // unsigned char mw_buf[24];
@@ -103,7 +106,7 @@ void bitmap_read(int mw_fd)
 #endif
 
        /* reverse bits and invert the bmap */
-       bmap_buffer_flipinvert(1, 0, bmapbuf, rowlength * height);
+       bmap_buffer_flipinvert(1, 1, bmapbuf, rowlength * height);
        /* send the buffer to the watch */
        mw_send_bitmap(mw_fd, MW_SCREEN_MODE_IDLE, width, height, 31, bmapbuf, rowlength * height);
        /* update the display */
@@ -138,8 +141,7 @@ void process_cmd(char *cmdline, int clinep, int mw_fd)
                mw_send_frame(mw_fd, MW_GET_REAL_TIME_CLOCK, 0, NULL, 0);
        }
        if (strncmp(cmdline, "gistr", 5) == 0) {
-               mdata[0] = 0;
-               mw_send_frame(mw_fd, MW_GET_INFORMATION_STRING, 0, mdata, 1);
+               mw_send_frame(mw_fd, MW_GET_INFORMATION_STRING, 0, NULL, 0);
        }
        if (strncmp(cmdline, "gdtype", 6) == 0) {
                mw_send_frame(mw_fd, MW_GET_DEVICE_TYPE, 0, NULL, 0);
@@ -147,6 +149,9 @@ void process_cmd(char *cmdline, int clinep, int mw_fd)
        if (strncmp(cmdline, "rvbat", 5) == 0) {
                mw_send_frame(mw_fd, MW_READ_BATTERY_VOLTAGE_MSG, 0, NULL, 0);
        }
+       if (strncmp(cmdline, "rlight", 6) == 0) {
+               mw_send_frame(mw_fd, MW_READ_LIGHT_SENSOR_MSG, 0, NULL, 0);
+       }
        if (strncmp(cmdline, "modecfg", 6) == 0) {
                mw_configure_watch_mode(mw_fd, MW_SCREEN_MODE_IDLE, 0, 4, 1);
                mw_update_display(mw_fd, MW_SCREEN_MODE_IDLE, 0);
@@ -203,9 +208,13 @@ int menu(int mw_fd)
                if (select(mw_fd+1, &mfds, NULL, NULL, NULL) > 0) {
                        if (FD_ISSET(mw_fd, &mfds)) {
                                rcvd = read(mw_fd, msg_buf, 64);
+#ifdef DEBUG
                                fprintf(stderr, "read %d bytes:\n", rcvd);
+#endif
                                if (rcvd > 0) {
+#ifdef DEBUG
                                        dump_frame(msg_buf, rcvd);
+#endif
                                        decode_frame(mw_fd, msg_buf, rcvd);
                                }
                        };
@@ -241,7 +250,7 @@ int open_socket(bdaddr_t *bdaddr, uint8_t channel)
 {
        struct sockaddr_rc addr;
        int sk, opt;
-       int f;
+       //int f;
 
        sk = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
        if (sk < 0) {
@@ -375,6 +384,8 @@ int main(int argc, char **argv)
        mw_fd = open_socket(&btaddr, 1);
        if (mw_fd < 0) {
                return 1;
+       } else {
+               fprintf(stderr, "connected to %s\n", argv[1]);
        };
 #endif