📄 housecontrol.c
字号:
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : HouseControl.c
Purpose : house control demo
---------------------------END-OF-HEADER------------------------------
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "GUI.h"
#include "FRAMEWIN.h"
#include "MULTIPAGE.h"
static void _cbWinAlert(WM_MESSAGE* pMsg);
typedef void SERIAL_Callback(const char* pStr, int v1, int v2);
/*********************************************************************
*
* defines and statics for serial interface
* (defined for target hardware only)
*
**********************************************************************
*/
#ifndef WIN32
#include "RTOS.h"
/*********************************************************************
*
* defines
*/
#define EOL 13 /* sign marking end of line */
#define BUFFER_SIZE 512 /* size of receive buffer */
#define STRING_SIZE 32 /* size of string buffer */
/*********************************************************************
*
* structures
*/
typedef struct {
OS_U8* pDataEnd;
OS_U8* pWrite;
OS_U8* pRead;
U16 Size;
} BUFFER;
/*********************************************************************
*
* static data
*/
static SERIAL_Callback* _pfcbReceiveCommand;
/* buffer to hold string */
static char _acString[STRING_SIZE + 2];
static char* _pString = _acString;
/* buffer for receiving */
static OS_U8 _Buffer[BUFFER_SIZE];
static BUFFER _RxBuffer = {_Buffer + BUFFER_SIZE, _Buffer, _Buffer, BUFFER_SIZE};
#endif /* #ifndef WIN32 */
/*********************************************************************
*
* defines
*
**********************************************************************
*/
#define PI2 6.2831853f
#define RPM 10
#define UPS 100
#define ARRAY(aItems) aItems, GUI_COUNTOF(aItems)
/*********************************************************************
*
* structures
*
**********************************************************************
*/
typedef struct {
I16 XCenter;
I16 YCenter;
I16 XSize;
I16 YSize;
} LOGO;
typedef struct {
I16 ActV;
I16 NewV;
GUI_RECT Rect;
} OBJECT;
typedef struct {
OBJECT Light;
I16 Elevator;
} LEVEL;
typedef struct {
OBJECT Itself;
OBJECT Door;
I16 NumToDo;
I16 ToDo[6];
I16 Move;
I16 Pause;
I16 Level;
I16 LastLevel;
int Time;
WM_HWIN Handle;
} ELEVATOR;
/*********************************************************************
*
* static data
*
**********************************************************************
*/
static WM_CALLBACK* _pfcbFrameWin;
static SCROLLBAR_Handle _hScroll;
static WM_HWIN _hAlert[2];
static WM_HWIN _hDialogLight;
static WM_HWIN _hWinHouse;
static WM_HWIN _hWinControl;
static WM_HWIN _hWinMap;
static const char _acAlertText[2][12] = {"Fire", "Burglary"};
static int _AlertCnt[2];
static int _SlidePrevTime;
static int _ScrollPrevTime;
static int _InitDialog;
static int _ExecuteCommands;
static int _LogoRPM = RPM;
static int _LogoWaitTime = 1000 / UPS;
static int _LogoPrevTime;
static int _LogoPrevMulX;
static int _LogoMulX;
static float _LogoDivisor;
static float _LogoAngle;
static LEVEL _Level[6] = {
{{0, 0, { 35, 650, 164, 780}}, 0},
{{0, 0, { 35, 520, 164, 650}}, 0},
{{0, 0, { 35, 390, 164, 520}}, 0},
{{0, 0, { 35, 260, 164, 390}}, 0},
{{0, 0, { 35, 130, 164, 260}}, 0},
{{0, 0, { 35, 0, 164, 130}}, 0},
};
static ELEVATOR _Elevator = {
{0, 0, { 57, 130, 83, 780}}, // the elevator itself
{0, 0, { 57, 82, 83, 125}}, // the elevator door
0, {0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0
};
static LOGO _Logo;
static OBJECT _Garage = {0, 0, { 40, 732, 90, 776}};
static OBJECT _Jalousie1 = {0, 0, {165, 400, 167, 493}};
static OBJECT _Jalousie2 = {0, 0, { 32, 140, 34, 233}};
static OBJECT _Marquee1 = {0, 0, {165, 549, 196, 566}};
static OBJECT _Marquee2 = {0, 0, { 3, 289, 34, 306}};
static OBJECT _Scroll = {0, 0, { 0, 0, 199, 780}};
static OBJECT _LogoArrow = {0, 0, { 58, 69, 139, 100}};
static OBJECT _LogoLarge = {0, 0, { 58, 46, 139, 69}};
static OBJECT _LogoSmall = {0, 0, { 7, 8, 47, 19}};
static OBJECT _GarageSmall = {0, 0, { 10, 220, 24, 232}};
static OBJECT _Jalousie1Small = {0, 0, { 48, 120, 49, 147}};
static OBJECT _Jalousie2Small = {0, 0, { 6, 42, 7, 69}};
static OBJECT _Marquee1Small = {0, 0, { 48, 166, 55, 170}};
static OBJECT _Marquee2Small = {0, 0, { 0, 88, 7, 92}};
static OBJECT _ElevatorSmall = {0, 0, { 14, 40, 23, 233}};
static OBJECT _LightSmall[6] = {
{0, 0, { 8, 195, 48, 234}},
{0, 0, { 8, 156, 48, 195}},
{0, 0, { 8, 117, 48, 156}},
{0, 0, { 8, 78, 48, 117}},
{0, 0, { 8, 39, 48, 78}},
{0, 0, { 8, 0, 48, 39}},
};
/*********************************************************************
*
* static data, dialog resource
*
**********************************************************************
*/
/*********************************************************************
*
* DialogLight
*/
static const GUI_WIDGET_CREATE_INFO _aDialogLight[] = {
{ WINDOW_CreateIndirect, "", 0, 0, 0, 113, 140, WM_CF_SHOW },
{ TEXT_CreateIndirect, "5.Floor:", 0, 5, 8, 40, 23, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "4.Floor:", 0, 5, 33, 40, 23, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "3.Floor:", 0, 5, 58, 40, 23, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "2.Floor:", 0, 5, 83, 40, 23, TEXT_CF_LEFT },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -