]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - print.c
host interface for pjrc
[tmk_firmware.git] / print.c
diff --git a/print.c b/print.c
index e6aa1fe52b9bf389a2086cd84f0b9e1afe7c4852..d9152971b99c8818ebf1bf5a7dea2c8a273554f5 100644 (file)
--- a/print.c
+++ b/print.c
  * THE SOFTWARE.
  */
 
-// Version 1.0: Initial Release
-
 #include <avr/io.h>
 #include <avr/pgmspace.h>
-
 #include "print.h"
+#include "sendchar.h"
+
+
+bool print_enable = false;
 
 void print_P(const char *s)
 {
+       if (!print_enable) return;
        char c;
 
        while (1) {
                c = pgm_read_byte(s++);
                if (!c) break;
-               if (c == '\n') usb_debug_putchar('\r');
-               usb_debug_putchar(c);
+               if (c == '\n') sendchar('\r');
+               sendchar(c);
        }
 }
 
 void phex1(unsigned char c)
 {
-       usb_debug_putchar(c + ((c < 10) ? '0' : 'A' - 10));
+       if (!print_enable) return;
+       sendchar(c + ((c < 10) ? '0' : 'A' - 10));
 }
 
 void phex(unsigned char c)
 {
+       if (!print_enable) return;
        phex1(c >> 4);
        phex1(c & 15);
 }
 
 void phex16(unsigned int i)
 {
+       if (!print_enable) return;
        phex(i >> 8);
        phex(i);
 }
 
 
+void pbin(unsigned char c)
+{
+    if (!print_enable) return;
+    for (int i = 7; i >= 0; i--) {
+        sendchar((c & (1<<i)) ? '1' : '0');
+    }
+}
 
-
+void pbin_reverse(unsigned char c)
+{
+    if (!print_enable) return;
+    for (int i = 0; i < 8; i++) {
+        sendchar((c & (1<<i)) ? '1' : '0');
+    }
+}