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

📄 housecontrol.c

📁 最新IAR6.4软集成开发环境及破解文件
💻 C
📖 第 1 页 / 共 5 页
字号:
*       static code, drawing functions
*
**********************************************************************
*/
/*********************************************************************
*
*       _DrawRect
*/
static void _DrawRect(int x0, int y0, int x1, int y1, int PenSize) {
  GUI_SetPenSize(PenSize);
  GUI_DrawRect(x0, y0, x1, y1 + PenSize - 1);
}

/*********************************************************************
*
*       _DrawElevator2
*/
static void _DrawElevator2(int x,  int y,  int w,  int h,
                           int x0, int y0, int x1, int y1,
                           int Index, GUI_COLOR Color) {
  if (y0 <= y1 && x0 <= x1) {
    GUI_RECT ClipRect;
    const GUI_RECT* OldClipRect;
    int Door = (w - 2) * (100 - _Elevator.Door.ActV) / 100;
    ClipRect.x0 = x + x0;
    ClipRect.y0 = y + y0;
    ClipRect.x1 = x + x1;
    ClipRect.y1 = y + y1;
    OldClipRect = WM_SetUserClipRect(&ClipRect);
    /* Draw elevator car */
    GUI_SetColor(LCD_MixColors256(Color, GUI_GRAY, Index ? 150 : 0));
    GUI_FillRect(x, y, x + w, y + h);
    /* Draw door frame (inside) */
    GUI_SetColor(LCD_MixColors256(Color, GUI_WHITE, Index ? 150 : 0));
    _DrawRect(x, y, x + w, y + h, 1);
    /* Draw elevator door (inside) */
    GUI_SetColor(LCD_MixColors256(Color, GUI_LIGHTGRAY, Index ? 150 : 0));
    GUI_FillRect(x + 1, y + 1, x + 1 + Door, y + h - 1);
    WM_SetUserClipRect(OldClipRect);
  }
}

/*********************************************************************
*
*       _DrawElevator
*/
static void _DrawElevator(int x, int y, int w, int h, int Level) {
  GUI_COLOR Color1, Color2;
  int yPos, yStart, yEnd, y0, y1;
  int Light = _Level[Level].Light.ActV;
  /* Draw elevator shaft */
  Color1  = (0x8F * Light / 100 + 0x60) << 16;
  Color1 += (0x7F * Light / 100 + 0x0) << 8;
  Color1 += (0x6F * Light / 100 + 0x20);
  GUI_SetColor(Color1);
  GUI_FillRect(x, y, x + w, y + h);
  /* Draw elevator door (outside) */
  Color2 = 0x5F * Light / 100 + 0xA0;
  Color2 = (Color2 << 16 | Color2 << 8 | Color2);
  GUI_SetColor(Color2);
  GUI_FillRect(x + 2, y + 80, x + w - 2, y + h - 2);
  /* Draw elevator car */
  yPos   = _Elevator.Itself.ActV - (5 - Level) * 130 + 80;
  yStart = (yPos < 0) ? -yPos : 0;
  yEnd   = (yPos > 82) ? 125 - yPos : 43;
  if (yPos != 80) {
    y0 = (yPos > 80) ? yStart + 44 - (yPos - 80) : yStart;
    y1 = (yPos > 80) ? yEnd : 79 - yPos;
    _DrawElevator2(x + 2, y + yPos, w - 4, 43, 0, y0, w - 4, y1, 1, Color1);
  }
  y0 = (yPos < 80) ? yStart + (80 - yPos) : yStart;
  y1 = (yPos > 80) ? 43 - (yPos - 80) : 43;
  if (_Elevator.Move) {
    GUI_SetColor(Color2);
    GUI_FillRect(x + 2, y + 80, x + w - 2, y + h - 2);
    _DrawElevator2(x + 2, y + yPos, w - 4, 43, 0, y0, w - 4, y1, 1, Color2);
  } else {
    int Door = (w - 4) * (100 - _Elevator.Door.ActV) / 100;
    _DrawElevator2(x + 2, y + yPos, w - 4, 43, 0, y0, Door, y1, 1, Color2);
    _DrawElevator2(x + 2, y + yPos, w - 4, 43, Door + 1, y0, w - 4, y1, 0, Color2);
  }
  /* Draw door frame (outside) */
  Color2 = 0x7F * Light / 100 + 0x50;
  GUI_SetColor(Color2 << 16);
  _DrawRect(x + 1, y + 79, x + w - 1, y + h - 1, 1);
  /* Draw level number */
  if (_Elevator.Itself.ActV == _Elevator.Itself.NewV &&
      _Elevator.Itself.ActV == ((5 - Level) * 130)) {
    GUI_SetColor(0x00FF40);
  } else {
    Color2 = 0x3F * Light / 100 + 0xC0;
    GUI_SetColor(Color2 << 8 | Color2);
  }
  GUI_SetFont(&GUI_Font8x8);
  GUI_SetTextMode(GUI_TM_TRANS);
  GUI_DispCharAt(Level + 1 + '0', x + (w / 2) - 3, y + 70);
}

/*********************************************************************
*
*       _DrawWindow
*/
static void _DrawWindow(int x, int y, int w, int h, int dy, int Light) {
  GUI_COLOR Color;
  int i;
  Color = 0x80 * Light / 100 + 0x7F;
  GUI_SetColor(Color << 16);
  GUI_FillRect(x, y, x + w, y + h);
  Color = 0x60 * Light / 100 + 0x9F;
  GUI_SetColor(Color << 16 | Color << 8 | Color);
  GUI_DrawVLine(x, y, y + h);
  GUI_DrawVLine(x + w / 2, y, y + h);
  GUI_DrawVLine(x + w, y, y + h);
  for (i = 0; i < h; i += dy) {
    GUI_DrawHLine(y + i, x, x + w);
  }
  GUI_DrawHLine(y + h, x, x + w);
}

/*********************************************************************
*
*       _DrawFrame
*/
static void _DrawFrame(int x, int y, int w, int h, int Light) {
  GUI_COLOR Color;
  Color = 0x88 * Light / 100 + 0x48;
  GUI_SetColor(Color << 16 | Color << 8 | Color);
  GUI_FillRect(x, y, x + w - 1, y + h - 1);
  GUI_SetColor(GUI_WHITE);
  _DrawRect(x, y, x + w - 1, y + h - 1, 2);
  Color = 0xA0 * Light / 100 + 0x5F;
  GUI_SetColor(Color << 16 | Color << 8 | Color);
  GUI_SetPenSize(1);
  GUI_DrawLine(x + 2, y + 2, x + w - 2, y + h - 2);
  GUI_DrawLine(x + w - 2, y + 2, x + 2, y + h - 2);
}

/*********************************************************************
*
*       _DrawMarquee
*/
static void _DrawMarquee(int x, int y, int w, int h, int d, int Status) {
  GUI_RECT ClipRect;
  const GUI_RECT* OldClipRect;
  ClipRect.x0 = (d < 0) ? (x - w - 2) : (x + 1);
  ClipRect.y0 = y - 1;
  ClipRect.x1 = (d < 0) ? (x - 1) : (x + w + 2);
  ClipRect.y1 = y + 61;
  OldClipRect = WM_SetUserClipRect(&ClipRect);
  GUI_AA_SetFactor(4);
  GUI_AA_EnableHiRes();
  x <<= 2;
  y <<= 2;
  w = (w - 2) * (100 - Status) / 25 + 12;
  w = (d > 0) ? w : -w;
  h = h * (100 - Status) / 25 + 4;
  GUI_SetPenSize(3);
  GUI_SetPenShape(GUI_PS_ROUND);
  GUI_SetColor(0xA08080);
  GUI_AA_DrawLine(x + (60 * d), y + 240, x, y + 240); 
  GUI_SetPenShape(GUI_PS_FLAT);
  GUI_SetColor(0x00C0FF);
  GUI_AA_DrawLine(x + w, y + h, x, y);
  GUI_AA_DrawLine(x + w - (3 * d), y + h, x + w - (3 * d), y + h + 20);
  GUI_AA_DisableHiRes();
  WM_SetUserClipRect(OldClipRect);
}

/*********************************************************************
*
*       _DrawJalousie
*/
static void _DrawJalousie(int x, int y, int h, int Status) {
  GUI_SetColor(0x0C0FF);
  GUI_SetPenSize(3);
  GUI_SetPenShape(GUI_PS_ROUND);
  GUI_DrawLine(x, y, x, y + (h * Status / 100) + 2);
}

/*********************************************************************
*
*       _DrawRoof
*/
static void _DrawRoof(int x, int y) {
  GUI_SetBkColor(GUI_BLACK);
  GUI_ClearRect(35, y - 70, 164, y + 59);
  GUI_SetColor(0xD82000);
  GUI_AA_SetFactor(3);
  GUI_AA_FillPolygon(_aRoof, 3, x, y);
  GUI_SetColor(0x0066FF);
  if (_LogoRPM < 0) {
    GUI_FillPolygon(_aArrowLeft,  8, x - 4, y + 9);
  }
  if (_LogoRPM > 0) {
    GUI_FillPolygon(_aArrowRight, 8, x - 4, y + 9);
  }
  GUI_DrawBitmapEx(&_LogoBitmap, x - 1, y - _Logo.YSize / 2 - 3, _Logo.XCenter, _Logo.YCenter, _LogoMulX, LOGOMULY);
}

/*********************************************************************
*
*       _DrawDoor
*/
static void _DrawDoor(int x, int y, int w, int h) {
  GUI_SetColor(GUI_BLUE);
  GUI_FillRect(x, y, x + w, y + h);
  GUI_SetColor(GUI_BLACK);
  _DrawRect(x, y, x + w, y + h, 1);
  GUI_DrawHLine(y + h/2, x + 4, x + 8);
  GUI_DrawVLine(x + 4, y + h/2 - 1, y + h/2 + 3);
}

/*********************************************************************
*

⌨️ 快捷键说明

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