- if (strncmp(cmdline, "quit", 4) == 0) {
- close(mw_fd);
- exit(0);
- }
-
- 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);
- fprintf(stderr, "OK\n");
- }
- if (strncmp(cmdline, "grtc", 4) == 0) {
- 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);
- }
- if (strncmp(cmdline, "gdtype", 6) == 0) {
- mw_send_frame(mw_fd, MW_GET_DEVICE_TYPE, 0, NULL, 0);
- }
- if (strncmp(cmdline, "rvbat", 5) == 0) {
- mw_send_frame(mw_fd, MW_READ_BATTERY_VOLTAGE_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);
- }
- if (strncmp(cmdline, "rbtcfg", 6) == 0) {
- mdata[0] = 0; /* idle screen */
- mdata[1] = 1; /* button index */
- mdata[2] = 2; /* button press type */
- mdata[3] = 3; /* callback message type */
- mdata[4] = 4; /* callback message option */
- mw_send_frame(mw_fd, MW_READ_BUTTON_CONFIG, 0, NULL, 0);
- }
- if (strncmp(cmdline, "svib", 4) == 0) {
- mw_set_vibrate_mode(mw_fd, 1, 300, 300, 5);
+/* if flip=1 bits in each byte are inverted 7->1, 6->2, 5->3,...
+ if invert=1 each byte is inverted
+ */
+void bmap_buffer_flipinvert(unsigned char flip, unsigned char invert, unsigned char *buf, int len)
+{
+ int i;
+ unsigned char tmp;
+
+ while (len--) {
+ tmp = 0;
+ if (flip) {
+ for (i=0; i<8; i++)
+ tmp |= ((*buf & (1<<i)) >> i) << (7-i);
+ // fprintf(stderr, "0x%02x -> 0x%02x\n", *buf, tmp);
+ } else
+ tmp = *buf;
+ *buf = invert ? ~tmp : tmp;
+ buf++;