Kiibohd Controller
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.

print.h 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 2011 by Jacob Alexander
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. #ifndef print_h__
  22. #define print_h__
  23. // ----- Includes -----
  24. // AVR Includes
  25. #include <avr/pgmspace.h>
  26. // Project Includes
  27. #include "usb_keyboard_debug.h"
  28. // ----- Defines -----
  29. #define NL "\r\n"
  30. // ----- Functions and Corresponding Function Aliases -----
  31. /* XXX
  32. * Note that all the variadic functions below, take comma separated string lists, they are purposely not printf style (simplicity)
  33. */
  34. // Function Aliases
  35. #define dPrint(c) usb_debug_putchar(c)
  36. #define dPrintStr(c) usb_debug_putstr (c)
  37. #define dPrintStrs(...) usb_debug_putstrs(__VA_ARGS__, "\0\0\0") // Convenience Variadic Macro
  38. #define dPrintStrNL(c) dPrintStrs (c, NL) // Appends New Line Macro
  39. #define dPrintStrsNL(...) usb_debug_putstrs(__VA_ARGS__, NL, "\0\0\0") // Appends New Line Macro
  40. // Special Msg Constructs (Uses VT100 tags)
  41. #define dPrintMsg(colour_code_str,msg,...) \
  42. usb_debug_putstrs("\033[", colour_code_str, "m", msg, "\033[0m - ", __VA_ARGS__, NL, "\0\0\0")
  43. #define printMsg(colour_code_str,msg,str) \
  44. print("\033[" colour_code_str "m" msg "\033[0m - " str NL)
  45. // Info Messages
  46. #define info_dPrint(...) dPrintMsg ("1;32", "INFO", __VA_ARGS__) // Info Msg
  47. #define info_print(str) printMsg ("1;32", "INFO", str) // Info Msg
  48. // Warning Messages
  49. #define warn_dPrint(...) dPrintMsg ("1;33", "WARNING", __VA_ARGS__) // Warning Msg
  50. #define warn_print(str) printMsg ("1;33", "WARNING", str) // Warning Msg
  51. // Error Messages
  52. #define erro_dPrint(...) dPrintMsg ("1;5;31", "ERROR", __VA_ARGS__) // Error Msg
  53. #define erro_print(str) printMsg ("1;5;31", "ERROR", str) // Error Msg
  54. // Debug Messages
  55. #define dbug_dPrint(...) dPrintMsg ("1;35", "DEBUG", __VA_ARGS__) // Debug Msg
  56. #define dbug_print(str) printMsg ("1;35", "DEBUG", str) // Debug Msg
  57. // Static String Printing
  58. #define print(s) _print(PSTR(s))
  59. void _print(const char *s);
  60. void usb_debug_putstr( char* s );
  61. void usb_debug_putstrs( char* first, ... );
  62. // String Functions
  63. #define hexToStr(hex, out) hexToStr_op(hex, out, 1)
  64. void int8ToStr ( uint8_t in, char* out );
  65. void int16ToStr ( uint16_t in, char* out );
  66. void hexToStr_op( uint16_t in, char* out, uint8_t op );
  67. void revsStr ( char* in );
  68. uint16_t lenStr ( char* in );
  69. #endif