/GUI/Core/GUI_AddHex.c

https://github.com/Arakula/Misa-Kitara-AP · C · 55 lines · 14 code · 6 blank · 35 comment · 2 complexity · b7eaf9e4399696245c3cc3070d33ad60 MD5 · raw file

  1. /*
  2. *********************************************************************************************************
  3. * uC/GUI V3.98
  4. * Universal graphic software for embedded applications
  5. *
  6. * (c) Copyright 2002, Micrium Inc., Weston, FL
  7. * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
  8. *
  9. * µC/GUI is protected by international copyright laws. Knowledge of the
  10. * source code may not be used to write a similar product. This file may
  11. * only be used in accordance with a license and should not be redistributed
  12. * in any way. We appreciate your understanding and fairness.
  13. *
  14. ----------------------------------------------------------------------
  15. File : GUI_AddHex.c
  16. Purpose : Converts hex value 2 string
  17. ---------------------------END-OF-HEADER------------------------------
  18. */
  19. #include "GUI_Protected.h"
  20. /*********************************************************************
  21. *
  22. * Static data
  23. *
  24. **********************************************************************
  25. */
  26. static const char acHex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
  27. /*********************************************************************
  28. *
  29. * Public code
  30. *
  31. **********************************************************************
  32. */
  33. /*********************************************************************
  34. *
  35. * GUI_AddHex
  36. */
  37. void GUI_AddHex(U32 v, U8 Len, char**ps) {
  38. char *s = *ps;
  39. if (Len > 8) {
  40. return;
  41. }
  42. (*ps) += Len;
  43. **ps = '\0'; /* Make sure string is 0-terminated */
  44. while(Len--) {
  45. *(s + Len) = acHex[v & 15];
  46. v >>= 4;
  47. }
  48. }
  49. /*************************** End of file ****************************/