⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edithex.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
字号:
C51 COMPILER V8.05a   EDITHEX                                                              04/11/2008 14:19:34 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE EDITHEX
OBJECT MODULE PLACED IN EditHex.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Widget\EditHex.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND
                    - PRINT(.\EditHex.lst) OBJECT(EditHex.obj)

line level    source

   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        : EditHex
  16          Purpose     : Edit hexadecimal values
  17          ---------------------------END-OF-HEADER------------------------------
  18          */
  19          
  20          #include <string.h>
  21          
  22          #include "EDIT.h"
  23          #include "gui\Core\GUIDebug.h"
  24          #include "gui\Core\GUI_Protected.h"
  25          #include "EDIT_Private.h"
  26          
  27          #if GUI_WINSUPPORT
              
              /*********************************************************************
              *
              *        Defaults for config switches
              *
              **********************************************************************
              */
              #ifndef EDIT_HEX_DIGITONLY
                #define EDIT_HEX_DIGITONLY     0
              #endif
              
              /*********************************************************************
              *
              *             Helpers
              *
              **********************************************************************
              */
              
              static int _HexChar2Int(int Char) {
                if ((Char >= '0') && (Char <= '9'))
                  return Char - '0';
                Char &= ~0x20;
                if ((Char >= 'A') && (Char <= 'F'))
                  return Char - 'A' + 10;
                return -1;
              }
              
C51 COMPILER V8.05a   EDITHEX                                                              04/11/2008 14:19:34 PAGE 2   

              static void _UpdateBuffer(EDIT_Obj* pObj) {
                char * s = (char*) WM_HMEM2Ptr(pObj->hpText);
                GUI_AddHex(pObj->CurrentValue, pObj->MaxLen, &s);
              }
              
              static void _EditHex(int Nibble, EDIT_Obj* pObj, EDIT_Handle hObj) {
                int Pos = pObj->MaxLen - pObj->CursorPos - 1;   /* Nibble position */
                U32 AndMask = ~(15     << (Pos << 2));
                U32 OrMask  =   Nibble << (Pos << 2);
                I32 Result  = pObj->CurrentValue & AndMask;
                Result     |= OrMask;
                EDIT_SetValue(hObj, Result);
              }
              
              #if EDIT_HEX_DIGITONLY
                static U8 _GetCurrentNibble(EDIT_Obj* pObj) {
                  int Pos = pObj->MaxLen - pObj->CursorPos - 1;   /* Nibble position */
                  U32 AndMask = 0xf << (Pos << 2);
                  U8 Nibble = (pObj->CurrentValue & AndMask) >> (Pos << 2);
                  return Nibble;
                }
              #endif
              
              static int _GetNumDigits(U32 Value) {
                int Ret;
                for (Ret = 0; Value; Value >>= 4, Ret++);
                return Ret;
              }
              
              static void _AddPosition(EDIT_Obj* pObj, EDIT_Handle hObj, int Sign) {
                int Pos;
                U32 v;
                v = 1;
                Pos = pObj->MaxLen - pObj->CursorPos-1;
                while (Pos--) {
                  v <<= 4;
                }
                if (Sign <0)
                  v = ~v;
                EDIT_SetValue(hObj, pObj->CurrentValue + v);
              }
              
              /*********************************************************************
              *
              *             Handle input
              *
              **********************************************************************
              */
              
              static void AddKeyHex(EDIT_Obj* pObj, EDIT_Handle hObj, int Key) {
                if (pObj) {
                  switch (Key) {
                    #if EDIT_HEX_DIGITONLY
                    case GUI_KEY_UP:
                      {
                        int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
                        _EditHex(Nibble, pObj, hObj);
                      }
                      break;
                    case GUI_KEY_DOWN:
                      {
                        int Nibble = (_GetCurrentNibble(pObj) + 1) & 15;
C51 COMPILER V8.05a   EDITHEX                                                              04/11/2008 14:19:34 PAGE 3   

                        _EditHex(Nibble, pObj, hObj);
                      }
                      break;
                    #else
                    case GUI_KEY_UP:
                      _AddPosition(pObj, hObj, 1);
                      break;
                    case GUI_KEY_DOWN:
                      _AddPosition(pObj, hObj, -1);
                      break;
                    #endif
                    case GUI_KEY_RIGHT:
                      if (pObj->CursorPos < (pObj->MaxLen - 1))
                        pObj->CursorPos++;
                      break;
                    case GUI_KEY_LEFT:
                      if (pObj->CursorPos > 0)
                        pObj->CursorPos--;
                      break;
                    default:
                      {
                        int Nibble = _HexChar2Int(Key);
                        if (Nibble >= 0) {
                          _EditHex(Nibble, pObj, hObj);
                          if (pObj->CursorPos < (pObj->MaxLen - 1))
                            pObj->CursorPos++;
                        }
                      }
                      break;
                  }
                }
                _UpdateBuffer(pObj);
              }
              
              /*********************************************************************
              *
              *             Exported routines
              *
              **********************************************************************
              */
              
              void EDIT_SetHexMode(EDIT_Handle hEdit, U32 Value, U32 Min, U32 Max) {
                EDIT_Obj* pObj;
                int MaxLen;
                WM_LOCK();
                pObj = EDIT_H2P(hEdit);
                pObj->pfAddKeyEx = AddKeyHex;
                pObj->CurrentValue = Value;
                pObj->CursorPos = 0;
                MaxLen = pObj->MaxLen;
                if (MaxLen <= 0 ) {
                  MaxLen = _GetNumDigits(Max);
                }
                if (MaxLen > 8) {
                  MaxLen = 8;
                }
                if (MaxLen != pObj->MaxLen) {
                  EDIT_SetMaxLen(hEdit, MaxLen);
                }
                pObj->Min = Min;
                pObj->Max = Max;
                pObj->EditMode = GUI_EDIT_MODE_OVERWRITE;
C51 COMPILER V8.05a   EDITHEX                                                              04/11/2008 14:19:34 PAGE 4   

                _UpdateBuffer(pObj);
                WM_UNLOCK();
              }
              
              #else  /* avoid empty object files */
 184          
 185          void EditHex_C(void);
 186          
 187          #endif /* GUI_WINSUPPORT */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   ----    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -