📄 housecontrol.c
字号:
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(&_NEC_Logo, x - 1, y - 13, 40, 12, _LogoMulX, 1000);}/*********************************************************************** _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);}/*********************************************************************** _DrawGarage*/static void _DrawGarage(int x, int y, int w, int h, int Status) { GUI_SetColor(GUI_YELLOW); GUI_FillRect(x, y + 1, x + w, y + ((h - 2) * (100 - Status) / 100) + 1); GUI_SetColor(GUI_BLACK); _DrawRect(x, y, x + w, y + h, 1);}/*********************************************************************** _DrawSmallLevel*/static void _DrawSmallLevel(int Level, int x0, int y0, int Light) { GUI_COLOR Color; int i; y0 += (4 - Level) * 39; /* Draw frame of levels (background) */ Color = 0x78 * Light / 100 + 0x58; GUI_SetColor(Color << 16 | Color << 8 | Color); GUI_FillRect(x0 + 9, y0 + 40, x0 + 46, y0 + 78); /* Draw frame of levels (rear bracing)*/ Color = 0xA0 * Light / 100 + 0x5F; GUI_SetColor(Color << 16 | Color << 8 | Color); GUI_DrawLine(x0 + 9, y0 + 40, x0 + 46, y0 + 77); GUI_DrawLine(x0 + 9, y0 + 77, x0 + 46, y0 + 40); /* Draw windows */ Color = 0x80 * Light / 100 + 0x7F; GUI_SetColor(Color << 16); GUI_FillRect(x0 + 32, y0 + 42, x0 + 40, y0 + 75); Color = 0x60 * Light / 100 + 0x9F; GUI_SetColor(Color << 16 | Color << 8 | Color); GUI_DrawVLine(x0 + 31, y0 + 41, y0 + 76); GUI_DrawVLine(x0 + 36, y0 + 41, y0 + 76); GUI_DrawVLine(x0 + 41, y0 + 41, y0 + 76); for (i = 0; i < ((Level) ? 8 : 5); i++) { GUI_DrawHLine(y0 + (i * 5) + 41, x0 + 31, x0 + 40); } /* Draw elevator shaft*/ Color = (0x8F * Light / 100 + 0x60) << 16; Color += (0x7F * Light / 100 + 0x0) << 8; Color += (0x6F * Light / 100 + 0x20); GUI_SetColor(Color); GUI_FillRect(x0 + 14, y0 + 40, x0 + 23, y0 + 77); Color = 0x5F * Light / 100 + 0xA0; GUI_SetColor(Color << 16 | Color << 8 | Color); GUI_FillRect(x0 + 15, y0 + 64, x0 + 22, y0 + 76);}/*********************************************************************** _DrawSmallElevatorDoor*/static void _DrawSmallElevatorDoor(int Level, int x0, int y0, int Light) { GUI_COLOR Color; y0 += (4 - Level) * 39; Color = 0x7F * Light / 100 + 0x50; GUI_SetColor(Color << 16); _DrawRect(x0 + 14, y0 + 63, x0 + 23, y0 + 77, 1); if (_Elevator.Itself.ActV == _Elevator.Itself.NewV && _Elevator.Itself.ActV == ((5 - Level) * 130)) { GUI_SetColor(0x00FF60); //GUI_SetColor(0x00FF40); } else { Color = 0x2F * Light / 100 + 0xD0; GUI_SetColor(Color << 8 | Color); } GUI_DrawHLine(y0 + 61, x0 + 18, x0 + 19);}/*********************************************************************** _DrawRotateLogo*/static int _DrawRotateLogo(void) { if (_LogoRPM != 0) { if ((GUI_GetTime() - _LogoPrevTime) >= _LogoWaitTime) { _LogoDivisor = 60000 / _LogoRPM / PI2; _LogoAngle += (GUI_GetTime() - _LogoPrevTime) / _LogoDivisor; _LogoPrevTime = GUI_GetTime(); _LogoMulX = cos(_LogoAngle) * 1000; if (_LogoMulX != _LogoPrevMulX) { _LogoPrevMulX = _LogoMulX; return 1; } } } return 0;}/*********************************************************************** _DrawLevel*/static void _DrawLevel(int n, int y) { if (n != 5) { _DrawFrame(35, y, 129, 129, _Level[n].Light.ActV); _DrawElevator(55, y + 2, 30, 125, n); if (n != 0) { _DrawWindow(115, y + 5, 30, 119, 17, _Level[n].Light.ActV); } } switch (n) { case 0: _DrawWindow(115, y + 5, 30, 76, 17, _Level[0].Light.ActV); _DrawDoor(115, y + 82, 30, 45); _DrawGarage(40, y + 82, 50, 45, _Garage.ActV); break; case 1: _DrawMarquee(164, y + 30, 30, 10, 1, _Marquee1.ActV); break; case 2: _DrawJalousie(166, y + 10, 90, _Jalousie1.ActV); break; case 3: _DrawMarquee(35, y + 30, 30, 10, -1, _Marquee2.ActV); break; case 4: _DrawJalousie(33, y + 10, 90, _Jalousie2.ActV); break; case 5: _DrawRoof(99, y + 70); }}/*********************************************************************** _DrawHouseMap*/static void _DrawHouseMap(int x0, int y0) { int i, ElevatorY, Status; /* Draw roof of house */ GUI_AA_SetFactor(5); GUI_AA_EnableHiRes(); GUI_SetColor(0xD82000); GUI_AA_FillPolygon(_aRoofMini, 3, (x0 * 5) + 138, (y0 * 5) + 105); GUI_AA_DisableHiRes(); GUI_DrawBitmapEx(&_NEC_Logo, x0 + 27, y0 + 13, 40, 12, _LogoMulX >> 1, 500); /* Draw levels*/ for (i = 0; i < 5; i++) { _DrawSmallLevel(i, x0, y0, _Level[i].Light.ActV); } /* Draw elevator car */ GUI_SetColor(0xD0D0D0); ElevatorY = y0 + (_Elevator.Itself.ActV / (10. / 3.)) + 25; GUI_FillRect(x0 + 15, ElevatorY, x0 + 22, ElevatorY + 12); /* Draw elevator doors */ for (i = 0; i < 5; i++) { _DrawSmallElevatorDoor(i, x0, y0, _Level[i].Light.ActV); } /* Draw door */ GUI_SetColor(GUI_BLUE); GUI_FillRect(x0 + 32, y0 + 220, x0 + 40, y0 + 232); GUI_SetColor(GUI_BLACK); _DrawRect(x0 + 31, y0 + 219, x0 + 41, y0 + 233, 1); GUI_SetColor(0x707070); GUI_DrawHLine(y0 + 219, x0 + 31, x0 + 41); /* Draw Garage */ Status = ((100 - _Garage.ActV) * 12 / 100); GUI_SetColor(GUI_YELLOW); GUI_FillRect(x0 + 10, y0 + 220, x0 + 24, y0 + 220 + Status); GUI_SetColor(GUI_BLACK); _DrawRect(x0 + 9, y0 + 219, x0 + 25, y0 + 233, 1); /* Draw Jalousie 1 */ Status = (_Jalousie1.ActV * 23 / 100); GUI_SetColor(0x00C0FF); GUI_DrawVLine(x0 + 48, y0 + 120, y0 + 124 + Status); GUI_SetColor(0x006C90); GUI_DrawVLine(x0 + 49, y0 + 120, y0 + 124 + Status); /* Draw Jalousie 2 */ Status = (_Jalousie2.ActV * 23 / 100); GUI_SetColor(0x00C0FF); GUI_DrawVLine(x0 + 7, y0 + 42, y0 + 46 + Status); GUI_SetColor(0x006C90); GUI_DrawVLine(x0 + 6, y0 + 42, y0 + 46 + Status); /* Draw Marquee 1*/ GUI_AA_SetFactor(5); GUI_AA_EnableHiRes(); GUI_SetPenSize(2); Status = ((100 - _Marquee1.ActV) * 28 / 100) + 5; GUI_SetColor(0x0C0FF); GUI_AA_DrawLine(240, 835, 240 + Status, 835 + Status/2.5); GUI_SetColor(0xA08080); GUI_DrawHLine(183, 47, 51); GUI_DrawHLine(184, 47, 51); /* Draw Marquee 2*/ Status = ((100 - _Marquee2.ActV) * 28 / 100) + 5; GUI_SetColor(0x0C0FF); GUI_AA_DrawLine(40, 445, 40 - Status, 445 + Status/2.5); GUI_SetColor(0xA08080); GUI_DrawHLine(105, 4, 8); GUI_DrawHLine(106, 4, 8); GUI_SetPenSize(1); GUI_AA_DisableHiRes(); /* Draw frame of levels (front bracing)*/ GUI_SetColor(0xFFFFFF); GUI_DrawVLine(x0 + 8, y0 + 39, y0 + 234); GUI_DrawVLine(x0 + 47, y0 + 39, y0 + 234); GUI_DrawHLine(y0 + 39, x0 + 9, x0 + 46); GUI_DrawHLine(y0 + 78, x0 + 9, x0 + 46); GUI_DrawHLine(y0 + 117, x0 + 9, x0 + 46); GUI_DrawHLine(y0 + 156, x0 + 9, x0 + 46); GUI_DrawHLine(y0 + 195, x0 + 9, x0 + 46); GUI_DrawHLine(y0 + 234, x0 + 9, x0 + 46);}/*********************************************************************** static code, elevator functions************************************************************************//*********************************************************************** _ElevatorOpenDoor*/static void _ElevatorOpenDoor(void) { _Elevator.Door.NewV = 100; _Elevator.Time = GUI_GetTime() + 4000; _SerialSendCommand("LIFT_OPEN", -1, -1);}/*********************************************************************** _ElevatorCloseDoor*/static void _ElevatorCloseDoor(void) { _Elevator.Door.NewV = 0; _Elevator.Time = GUI_GetTime() + 2000; _SerialSendCommand("LIFT_CLOSE", -1, -1);}/*********************************************************************** _ElevatorMoveTo*/static void _ElevatorMoveTo(int Level) { if (Level < 5) { _Elevator.Itself.NewV = (5 - Level) * 130; _Elevator.Move = (_Elevator.Itself.ActV > _Elevator.Itself.NewV) ? 1 : -1; WM_InvalidateWindow(_Elevator.Handle); _SerialSendCommand("LIFT", Level, -1); }}/*********************************************************************** _ElevatorStop*/static void _ElevatorStop(void) { _Elevator.Move = 0; _Elevator.Itself.NewV = _Elevator.Itself.ActV; WM_InvalidateWindow(_Elevator.Handle);}/*********************************************************************** _ElevatorAddLevel*/static void _ElevatorAddLevel(int Level) { if (_Level[Level].Elevator == 0 && Level < 5) { _Level[Level].Elevator = 1; _Elevator.ToDo[_Elevator.NumToDo++] = Level; WM_InvalidateWindow(_Elevator.Handle); }}/*********************************************************************** _ElevatorDelLevel*/static void _ElevatorDelLevel(int Level) { int i; if (_Level[Level].Elevator != 0 && Level < 5) { _Level[Level].Elevator = 0; for (i = 0; i < _Elevator.NumToDo; i++) { if (_Elevator.ToDo[i] == Level) break; } for (; i < (_Elevator.NumToDo - 1); i++) { _Elevator.ToDo[i] = _Elevator.ToDo[i + 1]; } _Elevator.NumToDo--; }}/*********************************************************************** _ElevatorGetLevel*/static void _ElevatorGetLevel(void) { _Elevator.Level = 5 - ((_Elevator.Itself.ActV + 65) / 130); if (_Elevator.Level != _Elevator.LastLevel) { WM_InvalidateWindow(_Elevator.Handle); _Elevator.LastLevel = _Elevator.Level; }}/*********************************************************************** _ElevatorOptimize*/static void _ElevatorOptimize(void) { int EndLevel = 5 - (_Elevator.Itself.NewV / 130); int Diff, i, Level; if (_Elevator.Itself.ActV < _Elevator.Itself.NewV) { Level = (5 - ((_Elevator.Itself.ActV + 130) / 130)); } else { Level = (5 - ((_Elevator.Itself.ActV - 1) / 130)); } Diff = (Level < EndLevel) ? 1 : -1; for (i = Level; i != EndLevel; i += Diff) { if (_Level[i].Elevator) { _ElevatorMoveTo(i); break; } }}/*********************************************************************** _ElevatorPause*/static void _ElevatorPause(void) { _Elevator.Pause = ~_Elevator.Pause; if (_Elevator.Pause) { _Elevator.Itself.NewV = _Elevator.Itself.ActV; _SerialSendCommand("LIFT_STOP", -1 , -1); } else { if (_Elevator.Door.ActV == 0) { if (_Elevator.NumToDo > 0) { _ElevatorMoveTo(_Elevator.ToDo[0]); } } } WM_InvalidateWindow(_Elevator.Handle);}/*********************************************************************** _ElevatorMove*/static void _ElevatorMove(int Level) { int yPos; if (_Level[Level].Elevator == 0) { yPos = (5 - Level) * 130; if (yPos != _Elevator.Itself.ActV || _Elevator.Itself.ActV != _Elevator.Itself.NewV) { _ElevatorAddLevel(Level); } else { _ElevatorOpenDoor(); } }}/*********************************************************************** _ElevatorExec*/static void _ElevatorExec(void) { if (GUI_GetTime() < _Elevator.Time) return; if (_Elevator.Door.ActV == _Elevator.Door.NewV) { if (_Elevator.Door.ActV == 100) { _ElevatorCloseDoor(); } else { if (!_Elevator.Pause) { if (_Elevator.Move) { if (_Elevator.Itself.ActV == _Elevator.Itself.NewV) { _ElevatorDelLevel(_Elevator.Level); _ElevatorStop(); _ElevatorOpenDoor(); } else { _ElevatorOptimize(); _ElevatorGetLevel(); } } else { if (_Elevator.NumToDo > 0) { _ElevatorMoveTo(_Elevator.ToDo[0]); } else { _Elevator.Time = GUI_GetTime() + 250; } } } } }}/*********************************************************************** static code, callbacks************************************************************************//*********************************************************************** _cbReceiveCommand*/static void _cbReceiveCommand(const char* pStr, int v1, int v2) { if (_ExecuteCommands) { if (strcmp(pStr, "LIGHT") == 0) { if (v1 >= 0 && v1 <= 4) { _Level[v1].Light.ActV = _Clip(v2); _InvalidateObject(_hWinHouse, _Level[v1].Light.Rect); _InvalidateObject2(_hWinMap, _LightSmall[v1].Rect); _SetDialogLight(); } return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -