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

📄 housecontrol.c

📁 图像系统uc_GUI
💻 C
📖 第 1 页 / 共 5 页
字号:
  &_bmTouchCursor, 16, 8
};

/*********************************************************************
*
*       static code, serial interface
*       (defined for target hardware only)
*
**********************************************************************
*/
#ifndef WIN32
  /*********************************************************************
  *
  *       _cbReceiveData
  */
  static void _cbReceiveData(OS_U8 Data) {
    *(_RxBuffer.pWrite)++ = Data;
    if (_RxBuffer.pWrite == _RxBuffer.pDataEnd) {
      _RxBuffer.pWrite -= _RxBuffer.Size;
    }
  }

  /*********************************************************************
  *
  *       _SendString
  */
  static void _SendString(const char* pStr) {
    OS_SendString(pStr);
  }

  /*********************************************************************
  *
  *       _ConvIntToStr
  */
  static char* _ConvIntToStr(char* pStr, int Value) {
    char* Ptr = pStr + 4;
    int v = Value;
    *Ptr = 0;
    do {
      *(--Ptr) = (v % 10) + '0';
      v /= 10;
    } while (v && (Ptr != pStr));
    strcpy(pStr, Ptr);
    return pStr;
  }

  /*********************************************************************
  *
  *       _ConvStrToInt
  */
  static int _ConvStrToInt(char* pStr) {
    char* Ptr = pStr;
    int r = 0;
    while (*Ptr) {
      r *= 10;
      r += *(Ptr++) - '0';
    }
    return r;
  }

  /*********************************************************************
  *
  *       _ReceivedString
  */
  static void _ReceivedString(const char* pStr) {
    int v1 = -1, v2 = -1;
    char* Ptr;
    Ptr = strrchr(pStr, ' ');
    if (Ptr != NULL) {
      v1 = _ConvStrToInt(Ptr + 1);
      *Ptr = 0;
    }
    Ptr = strrchr(pStr, ' ');
    if (Ptr != NULL) {
      v2 = v1;
      v1 = _ConvStrToInt(Ptr + 1);
      *Ptr = 0;
    }
    if (_pfcbReceiveCommand) {
      (*_pfcbReceiveCommand)(pStr, v1, v2);
    }
  }

  /*********************************************************************
  *
  *       _ReceivedChar
  */
  static void _ReceivedChar(char c) {
    if (c == EOL) {
      _pString = _acString;
      _ReceivedString(_acString);
    } else {
      if (_pString < (_acString + STRING_SIZE)) {
        if (c >= 'a' && c <= 'z') {
          c -= 'a' - 'A';
        }
        *_pString++     = c;
        *(_pString + 1) = 0;
      }
    }
  }
#endif  /* #ifndef WIN32 */

/*********************************************************************
*
*       static code, serial interface
*
**********************************************************************
*/
/*********************************************************************
*
*       _SerialSendCommand
*/
static void _SerialSendCommand(const char* pStr, int v1, int v2) {
  #ifndef WIN32
    char Str1[STRING_SIZE + 2];
    char Str2[5];
    int Len, i, v;
    Str1[STRING_SIZE] = 0;
    strncpy(Str1, pStr, STRING_SIZE);
    for (i = 0; i < 2; i++) {
      v = (i == 0) ? v1 : v2;
      if (v >= 0 && v <= 999) {
        _ConvIntToStr(Str2, v);
        if ((strlen(Str1) + strlen(Str2) + 1) <= STRING_SIZE) {
          strcat(Str1, " ");
          strcat(Str1, Str2);
        }
      }
    }
    Len = strlen(Str1);
    Str1[Len]   = EOL;
    Str1[Len+1] = 0;
    _SendString(Str1);
  #endif
}

/*********************************************************************
*
*       _SerialExec
*/
static void _SerialExec(void) {
  #ifndef WIN32
    OS_U8 Data;
    while (_RxBuffer.pRead != _RxBuffer.pWrite) {
      Data = *(_RxBuffer.pRead)++;
      if (_RxBuffer.pRead == _RxBuffer.pDataEnd) {
        _RxBuffer.pRead -= _RxBuffer.Size;
      }
      _ReceivedChar((char)Data);
    }
  #endif
}

/*********************************************************************
*
*       _SerialInit
*/
static void _SerialInit(SERIAL_Callback* cb) {
  #ifndef WIN32
    OS_SetRxCallback(&_cbReceiveData);
    _pfcbReceiveCommand = cb;
  #endif
}

/*********************************************************************
*
*       static code, helper functions
*
**********************************************************************
*/
/*********************************************************************
*
*       _SetSliderValue

⌨️ 快捷键说明

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