/ucGUI_WIN_LIB/GUI/Core/GUI_AddBin.c

https://github.com/Arakula/Misa-Kitara-AP · C · 50 lines · 17 code · 4 blank · 29 comment · 2 complexity · c5f8de3c7ad6b5f78c49efc27fd86275 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_AddBin.c
  16. Purpose : Converts binary value 2 string
  17. ---------------------------END-OF-HEADER------------------------------
  18. */
  19. #include "GUI_Protected.h"
  20. #include "GUIDebug.h"
  21. /*********************************************************************
  22. *
  23. * Public code
  24. *
  25. **********************************************************************
  26. */
  27. /*********************************************************************
  28. *
  29. * GUI_AddBin
  30. */
  31. void GUI_AddBin(U32 v, U8 Len, char** ps) {
  32. char *s = *ps;
  33. #if GUI_DEBUG_LEVEL >1
  34. if (Len > 32) {
  35. GUI_DEBUG_WARN("Can not display more than 32 bin. digits");
  36. Len = 32;
  37. }
  38. #endif
  39. (*ps) += Len;
  40. **ps = '\0'; /* Make sure string is 0-terminated */
  41. while(Len--) {
  42. *(s + Len) = (char)('0' + (v & 1));
  43. v >>= 1;
  44. }
  45. }
  46. /*************************** End of file ****************************/