/*
*********************************************************************************************************
* 湣/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2000, 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 : Dashboard.c
Purpose : dashboard demo
---------------------------END-OF-HEADER------------------------------
*/
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "GUI.h"
#include "LCDConf.h"
#include "MULTIPAGE.h"
#include "FRAMEWIN.h"
#include "DROPDOWN.h"
#if (GUI_ALLOC_SIZE < 4000000)
#error GUI_ALLOC_SIZE should be at least 4 MB
#endif
/*********************************************************************
*
* defines
*
**********************************************************************
*/
#define SHOW_RECTS 0
#define AA_FACTOR 6
#define HIRES 1
#if HIRES
#define FACTOR AA_FACTOR
#define HIRES_ON(); GUI_AA_EnableHiRes();
#define HIRES_OFF(); GUI_AA_DisableHiRes();
#else
#define FACTOR 1
#define HIRES_ON();
#define HIRES_OFF();
#endif
#define FLAG_SHOW_MARK 0
#define FLAG_SHOW_PITCH 1
#define FLAG_SHOW_GRAD 2
#define FLAG_SHOW_ARC 3 /* needs five bits (3 - 7) */
#define FLAG_SHOW_TEXT 8
#define FLAG_SHOW_SCALE 9
#define FLAG_NEEDLE_FRAME 10
#define FLAG_NEEDLE_LINE 11
#define PI 3.1415926536
#define NEEDLE_GRAD 720
#define ARRAY(aItems) aItems, GUI_COUNTOF(aItems)
/*********************************************************************
*
* structures
*
**********************************************************************
*/
typedef struct {
int x;
int y;
int xHere;
int yHere;
int DirX;
int DirY;
int PPM;
int Dif;
int PrevTime;
const GUI_BITMAP* pBitmap;
} NAVIMAP;
typedef struct {
U8 Sep[4];
} COLOR;
typedef struct {
int x;
int y;
int x0;
int y0;
int ArcStart;
int ArcEnd;
int ArcRadius;
int ArcArea1;
int ArcArea2;
int NumMarkLines;
int NumPitchLines;
int LineLen1;
int LineLen2;
int ArcWidth;
int GradDist;
int PenSize1;
int PenSize2;
int PenSize3;
int NeedleType;
int NeedleRadius;
int NumStep;
int NumStart;
int NumExp;
int LinePos1;
int LinePos2;
int ArcPos;
int AxisRadius;
int TextDist;
U16 Flags;
WM_HWIN hWin;
GUI_MEMDEV_Handle hMemDev;
char acText[33];
const GUI_BITMAP* pBitmap;
int BitmapY;
COLOR Color[7];
} SCALE;
typedef struct {
int NeedlePos;
int NeedleUPM;
int NeedleDir;
int NeedlePrevTime;
} NEEDLE;
static void _DrawScale(SCALE* pObj);
/*********************************************************************
*
* static data
*
**********************************************************************
*/
static int _InitDialog;
static WM_HWIN _hDialogColor;
static WM_HWIN _hDialogMark;
static WM_HWIN _hDialogPitch;
static WM_HWIN _hDialogArc;
static WM_HWIN _hDialogGrad;
static WM_HWIN _hDialogScale;
static WM_HWIN _hDialogMisc;
static DROPDOWN_Handle _hDropDownScale;
static DROPDOWN_Handle _hDropDownColor;
static SCALE _Scale[4];
static SCALE _ScalePrev[4];
static NEEDLE _Needle[4] = {
{0, 3, 1, 0},
{0, 4, 1, 0},
{0, 6, 1, 0},
{0, 9, 1, 0}
};
static const int _Pow10[] = {1, 10, 100, 1000};
/*********************************************************************
*
* static data, presets
*
**********************************************************************
*/
static const SCALE _Presets[4][4] = {
{
{
87, 250, 0, 0, 89, 225, 62, 41, 122, 4, 2, 15, 7, 15, 24,
2, 2, 2, 1, 100, 1, 0, 0, 0, 0, 0, 16, 25, 0x37B, 0, 0, "Fuel", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xFF, 0x64, 0x00, 0xFF},
{0x98, 0x00, 0x00}, {0x90, 0x90, 0x00}, {0x00, 0x50, 0x00}, {0xE8, 0xE8, 0xFF}}
}, {
144, 136, 0, 0, 72, 225, 70, 93, 184, 3, 1, 15, 7, 15, 24,
2, 2, 2, 1, 100, 1, 0, 0, 0, 0, 0, 16, 25, 0x37B, 0, 0, "Oil", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xFF, 0x64, 0x00, 0xFF},
{0x98, 0x00, 0x00}, {0x90, 0x90, 0x00}, {0x00, 0x50, 0x00}, {0xE8, 0xE8, 0xFF}}
}, {
335, 185, 0, 0, 58, 234, 149, 258, 335, 15, 4, 25, 10, 25, 29,
2, 2, 2, 4, 100, 1, 1, 1, 0, 5, 0, 16, 25, 0x77F, 0, 0, "Speed", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0x00, 0x8A, 0xFF, 0x88},
{0x00, 0x70, 0x00}, {0x90, 0x90, 0x00}, {0xAA, 0x00, 0x00}, {0xE8, 0xE8, 0xFF}}
}, {
522, 208, 0, 0, 59, 225, 108, 257, 311, 8, 4, 25, 10, 25, 34,
2, 2, 2, 3, 100, 1, 0, 0, 0, 0, 0, 16, 25, 0x77F, 0, 0, "RPM", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xFF, 0xAA, 0x00, 0xB5},
{0x00, 0x70, 0x00}, {0x90, 0x90, 0x00}, {0xAA, 0x00, 0x00}, {0xE8, 0xE8, 0xFF}}
}
}, {
{
96, 208, 0, 0, 40, 160, 73, 41, 122, 4, 2, 15, 7, 15, 24,
2, 2, 2, 3, 100, 1, 0, 0, 0, 0, 0, 16, 22, 0x74B, 0, 0, "Fuel", 0, 0,
{{0xFF, 0xFF, 0xAC}, {0x00, 0xFF, 0x70}, {0xFF, 0x64, 0x64, 0x80},
{0x98, 0x00, 0x00}, {0x90, 0x90, 0x00}, {0x00, 0x50, 0x00}, {0xE8, 0xE8, 0xFF}}
}, {
395, 247, 0, 0, 90, 270, 75, 93, 184, 3, 1, 15, 7, 15, 24,
2, 2, 2, 1, 100, 1, 0, 0, 0, 0, 0, 16, 22, 0x77B, 0, 0, "Oil", 0, 0,
{{0xFF, 0xFF, 0xAC}, {0x00, 0xFF, 0x70}, {0xFF, 0x64, 0x64, 0x80},
{0x98, 0x00, 0x00}, {0x90, 0x90, 0x00}, {0x00, 0x50, 0x00}, {0xE8, 0xE8, 0xFF}}
}, {
272, 184, 0, 0, 58, 254, 156, 261, 327, 12, 4, 19, 10, 17, 42,
2, 2, 2, 0, 100, 2, 1, 1, 17, 22, 0, 16, 22, 0x7C7, 0, 0, "Speed", 0, 0,
{{0xFF, 0xFF, 0xAC}, {0x00, 0xFF, 0x70}, {0x00, 0xCA, 0xFF, 0x68},
{0x00, 0x8C, 0x00}, {0xC4, 0xC4, 0x00}, {0xD8, 0x00, 0x00}, {0x75, 0xFF, 0xFF}}
}, {
511, 208, 0, 0, 128, 270, 107, 257, 311, 8, 4, 25, 10, 25, 34,
2, 2, 2, 3, 100, 1, 0, 0, 0, 0, 0, 16, 22, 0x777, 0, 0, "RPM", 0, 0,
{{0xFF, 0xFF, 0xAC}, {0x00, 0xFF, 0x70}, {0xFF, 0xAA, 0x00, 0xB5},
{0x00, 0x70, 0x00}, {0x90, 0x90, 0x00}, {0xAA, 0x00, 0x00}, {0xE8, 0xE8, 0xFF}}
}
}, {
{
101, 212, 0, 0, 30, 270, 66, 60, 120, 5, 1, 15, 7, 13, 34,
2, 2, 2, 0, 100, 1, 0, 0, 0, 0, 0, 16, 25, 0xF43, 0, 0, "Fuel", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xA0, 0x7C, 0xFF, 0xA0},
{0x90, 0x00, 0x00}, {0x80, 0x80, 0x00}, {0x00, 0x70, 0x00}, {0xFF, 0xFF, 0xFF}}
}, {
543, 215, 0, 0, 30, 270, 66, 240, 320, 5, 1, 15, 7, 15, 34,
2, 2, 2, 0, 100, 1, 0, 0, 0, 0, 0, 16, 25, 0xF43, 0, 0, "Oil", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xA0, 0x7C, 0xFF, 0xA0},
{0x00, 0x70, 0x00}, {0x90, 0x90, 0x00}, {0xAA, 0x00, 0x00}, {0xFF, 0xFF, 0xFF}}
}, {
325, 155, 0, 0, 30, 270, 95, 269, 317, 5, 1, 16, 8, 9, 34,
2, 2, 2, 1, 100, 1, 0, 0, 0, 0, 0, 16, 40, 0x773, 0, 0, "Speed", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0xFF, 0x4C, 0x38, 0xA0},
{0x00, 0x70, 0x00}, {0x90, 0x90, 0x00}, {0xAA, 0x00, 0x00}, {0xFF, 0xFF, 0xFF}}
}, {
325, 155, 0, 0, 30, 270, 137, 228, 329, 10, 1, 16, 9, 25, 21,
2, 2, 2, 0, 100, 2, 1, 1, 0, 0, 0, 16, 16, 0x747, 0, 0, "RPM", 0, 0,
{{0xFF, 0xFF, 0xFF}, {0x00, 0xFF, 0x00}, {0x00,