GUIValf.c
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:3k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                                uC/GUI
  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. *              礐/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        : GUIValF.C
  16. Purpose     : Displaying floating point values
  17. ----------------------------------------------------------------------
  18. Version-Date---Author-Explanation
  19. ----------------------------------------------------------------------
  20. 1.00.00 990322 RS     First release   
  21. ----------------------------------------------------------------------
  22. Known problems or limitations with current version
  23. ----------------------------------------------------------------------
  24. None.
  25. ---------------------------END-OF-HEADER------------------------------
  26. */
  27. #include "GUI_Protected.H"
  28. #include "math.h"
  29. /*
  30. *******************************************
  31. *                                         *
  32. *          Helper functions               *
  33. *                                         *
  34. *******************************************
  35. */
  36. static void _DispFloatFix(float f, char Len, char Decs, int DrawPlusSign) {
  37.   f *= GUI_Pow10[Decs];
  38.   f += 0.5;
  39.   f = (float) floor (f);
  40.   if (DrawPlusSign)
  41.     GUI_DispSDecShift((long)f, Len, Decs);
  42.   else
  43.     GUI_DispDecShift((long)f, Len, Decs);
  44. }
  45. /*
  46. *******************************************
  47. *                                         *
  48. *     optional sign display routines      *
  49. *                                         *
  50. *******************************************
  51. */
  52. void GUI_DispFloatFix(float f, char Len, char Decs) {
  53.   _DispFloatFix(f, Len, Decs, 0);
  54. }
  55. void GUI_DispFloatMin(float f, char Fract) {
  56.   char Len;
  57.   Len = GUI_Long2Len((long)f);
  58.   _DispFloatFix(f, (char)(Len+Fract+1), (char)Fract, 0);
  59. }
  60. void GUI_DispFloat(float f, char Len) {
  61.   int Decs;
  62.   Decs =  Len - GUI_Long2Len((long)f)-1;
  63.   if (Decs<0)
  64.     Decs =0;
  65.   _DispFloatFix(f, Len, (char)Decs, 0);
  66. }
  67. /*
  68. *******************************************
  69. *                                         *
  70. *    Signed display routines              *
  71. *                                         *
  72. *******************************************
  73. */
  74. void GUI_DispSFloatFix(float f, char Len, char Fract) {
  75.   _DispFloatFix (f, Len, Fract, 1);
  76. }
  77. void GUI_DispSFloatMin(float f, char Fract) {
  78.   char Len;
  79.   Len = GUI_Long2Len((long)f);
  80.   if (f>0)
  81.     Len++;
  82.   _DispFloatFix(f, (char)(Len+Fract+1), (char)Fract, 1);
  83. }