X-Git-Url: https://git.donarmstrong.com/?p=kiibohd-controller.git;a=blobdiff_plain;f=Debug%2Fprint%2Fprint.h;h=adeb2c4849ed0286a6c0c0f5f09b82eadc79fc96;hp=801cca1fae86599b4eb7cf79017de5fa101aaae8;hb=5f262ea4b68a07e9b94ce0a49c0f7196e5f32b3b;hpb=4ce6d34cd8dfbcc6fa51a69e42dce38b3416b736 diff --git a/Debug/print/print.h b/Debug/print/print.h index 801cca1..adeb2c4 100644 --- a/Debug/print/print.h +++ b/Debug/print/print.h @@ -1,15 +1,15 @@ -/* Copyright (C) 2011-2013 by Jacob Alexander - * +/* Copyright (C) 2011-2015 by Jacob Alexander + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -19,23 +19,18 @@ * THE SOFTWARE. */ -#ifndef print_h__ -#define print_h__ +#pragma once // ----- Includes ----- // Compiler Includes #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) - #include -#include "avr/usb_keyboard_debug.h" - -#elif defined(_mk20dx128_) - -#include "arm/usb_serial.h" - #endif +// Project Includes +#include + // ----- Defines ----- @@ -50,59 +45,73 @@ */ // Function Aliases -#define dPrint(c) usb_debug_putstr(c) -#define dPrintStr(c) usb_debug_putstr(c) -#define dPrintStrs(...) usb_debug_putstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro -#define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro -#define dPrintStrsNL(...) usb_debug_putstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro +#define dPrint(c) Output_putstr(c) +#define dPrintStr(c) Output_putstr(c) +#define dPrintStrs(...) printstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro +#define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro +#define dPrintStrsNL(...) printstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro // Special Msg Constructs (Uses VT100 tags) #define dPrintMsg(colour_code_str,msg,...) \ - usb_debug_putstrs("\033[", colour_code_str, "m", msg, "\033[0m - ", __VA_ARGS__, NL, "\0\0\0") + printstrs("\033[", colour_code_str, "m", msg, "\033[0m - ", __VA_ARGS__, NL, "\0\0\0") +#define printMsgNL(colour_code_str,msg,str) \ + print("\033[" colour_code_str "m" msg "\033[0m - " str NL) #define printMsg(colour_code_str,msg,str) \ - print("\033[" colour_code_str "m" msg "\033[0m - " str NL) + print("\033[" colour_code_str "m" msg "\033[0m - " str) // Info Messages #define info_dPrint(...) dPrintMsg ("1;32", "INFO", __VA_ARGS__) // Info Msg -#define info_print(str) printMsg ("1;32", "INFO", str) // Info Msg +#define info_print(str) printMsgNL ("1;32", "INFO", str) // Info Msg +#define info_msg(str) printMsg ("1;32", "INFO", str) // Info Msg // Warning Messages #define warn_dPrint(...) dPrintMsg ("1;33", "WARNING", __VA_ARGS__) // Warning Msg -#define warn_print(str) printMsg ("1;33", "WARNING", str) // Warning Msg +#define warn_print(str) printMsgNL ("1;33", "WARNING", str) // Warning Msg +#define warn_msg(str) printMsg ("1;33", "WARNING", str) // Warning Msg // Error Messages #define erro_dPrint(...) dPrintMsg ("1;5;31", "ERROR", __VA_ARGS__) // Error Msg -#define erro_print(str) printMsg ("1;5;31", "ERROR", str) // Error Msg +#define erro_print(str) printMsgNL ("1;5;31", "ERROR", str) // Error Msg +#define erro_msg(str) printMsg ("1;5;31", "ERROR", str) // Error Msg // Debug Messages #define dbug_dPrint(...) dPrintMsg ("1;35", "DEBUG", __VA_ARGS__) // Debug Msg -#define dbug_print(str) printMsg ("1;35", "DEBUG", str) // Debug Msg +#define dbug_print(str) printMsgNL ("1;35", "DEBUG", str) // Debug Msg +#define dbug_msg(str) printMsg ("1;35", "DEBUG", str) // Debug Msg // Static String Printing +#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) #define print(s) _print(PSTR(s)) +#else +#define print(s) _print(s) +#endif -void _print(const char *s); -void usb_debug_putstr( char* s ); -void usb_debug_putstrs( char* first, ... ); +void _print( const char *s ); +void printstrs( char* first, ... ); // Printing numbers -#define printHex(hex) printHex_op(hex, 1) +#define printHex(hex) printHex_op(hex, 1) +#define printHex32(hex) printHex32_op(hex, 1) -void printInt8 ( uint8_t in ); -void printInt16 ( uint16_t in ); -void printHex_op( uint16_t in, uint8_t op ); +void printInt8 ( uint8_t in ); +void printInt16 ( uint16_t in ); +void printInt32 ( uint32_t in ); +void printHex_op ( uint16_t in, uint8_t op ); +void printHex32_op( uint32_t in, uint8_t op ); // String Functions #define hexToStr(hex, out) hexToStr_op(hex, out, 1) -void int8ToStr ( uint8_t in, char* out ); -void int16ToStr ( uint16_t in, char* out ); -void hexToStr_op( uint16_t in, char* out, uint8_t op ); -void revsStr ( char* in ); -uint16_t lenStr ( char* in ); - -#endif +void int8ToStr ( uint8_t in, char* out ); +void int16ToStr ( uint16_t in, char* out ); +void int32ToStr ( uint32_t in, char* out ); +void hexToStr_op ( uint16_t in, char* out, uint8_t op ); +void hex32ToStr_op( uint32_t in, char* out, uint8_t op ); +void revsStr ( char* in ); +uint16_t lenStr ( char* in ); +int16_t eqStr ( char* str1, char* str2 ); // Returns -1 if identical, last character of str1 comparison (0 if str1 is like str2) +int numToInt ( char* in ); // Returns the int representation of a string