融合许工更新代码

This commit is contained in:
gaoyuhang 2024-07-03 15:15:00 +08:00
commit c32647126a
819 changed files with 261765 additions and 150 deletions

24
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/xushenghao/Desktop/controller-hd/User/application/mode",
"program": "c:/Users/xushenghao/Desktop/controller-hd/User/application/mode/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

View File

@ -1,6 +1,6 @@
/*
* Auto generated Run-Time-Environment Component Configuration File
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'controller-v2'
@ -17,4 +17,5 @@
#define CMSIS_device_header "stm32l4xx.h"
#endif /* RTE_COMPONENTS_H */

View File

@ -103,7 +103,7 @@
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>11</nTsel>
<nTsel>6</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@ -308,6 +308,7 @@
<pMultCmdsp></pMultCmdsp>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
<DbgClock>10000000</DbgClock>

View File

@ -10,14 +10,14 @@
<TargetName>controller-v2</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060061::V5.06 update 1 (build 61)::ARMCC</pCCUsed>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STM32L476VGTx</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32L4xx_DFP.2.1.0</PackID>
<PackURL>http://www.keil.com/pack</PackURL>
<PackID>Keil.STM32L4xx_DFP.2.6.2</PackID>
<PackURL>https://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00018000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
@ -184,6 +184,8 @@
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>1</RvdsVP>
<RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>1</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
@ -350,7 +352,7 @@
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<ClangAsOpt>4</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
@ -1255,7 +1257,7 @@
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<uClangAs>2</uClangAs>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
@ -1339,7 +1341,7 @@
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<uClangAs>2</uClangAs>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>

View File

@ -77,30 +77,22 @@ void mode_test_process(void)
*/
void mode_travel_statistics(void)
{
static float32 loop_current_last = 0.0f; // 上一次的电流
static uint8_t change_count = 0;
static uint8_t internal_count = 0;
float32 loop = 0.0;
// 输入电流
loop = get_current();
rt_data.loop_current = get_current_deal(loop);
// 过滤掉不稳定的电流值
if (loop_current_last != rt_data.loop_current)
loop = get_current_deal(loop);
if (internal_count++ >= 10)
{
if (change_count++ >= 2)
{
loop_current_last = rt_data.loop_current;
change_count = 0;
}
else
{
return;
}
internal_count = 0;
rt_data.loop_current = loop;
}
else
{
change_count = 0;
lpf_window_reset(mode_get()->show_loop_lpf);
lpf_window_reset(mode_get()->show_actual_lpf);
if (ABS(rt_data.loop_current - loop) >= 0.05f)
{
rt_data.loop_current = loop;
}
}
// 获取目标行程

View File

@ -295,7 +295,7 @@ fdb_time_t fal_execution_get_time(void)
tt.minute = hex_format_dec(timestamp.Date.Minute);
tt.second = hex_format_dec(timestamp.Date.Second);
return (int32_t)time2stamp(dd, tt);
return (int32_t)time2stamp(&dd, &tt);
}
/**
* KV

View File

@ -354,7 +354,6 @@ void system_clock_config_hight(void)
*/
void gui_flush(void)
{
}
/**
@ -364,7 +363,6 @@ void gui_flush(void)
*/
void gui_flush_Clear(void)
{
}
/**
@ -374,7 +372,6 @@ void gui_flush_Clear(void)
*/
void gui_clr(void)
{
}
/**
@ -384,7 +381,6 @@ void gui_clr(void)
*/
void gui_set_clear_flag(void)
{
}
/**
@ -404,7 +400,6 @@ BOOL gui_get_clear_flag(void)
*/
void gui_full(void)
{
}
/**
@ -414,7 +409,6 @@ void gui_full(void)
*/
void gui_open()
{
}
/**
@ -424,7 +418,6 @@ void gui_open()
*/
void gui_close()
{
}
/**
@ -434,7 +427,6 @@ void gui_close()
*/
void gui_set_scandir(uint8_t dir)
{
}
/***************************************** 板卡参数相关函数 *****************************************/
@ -692,7 +684,7 @@ float32 get_current(void)
float32 f = 0.0;
// 读取回路电流ADC值
adc_raw[ADC_LOOP_CHANNEL] = adc_result_average(ADCS_1, ADC_LOOP_CHANNEL);
adc_raw[ADC_LOOP_CHANNEL] = adc_result_median_average(ADCS_1, ADC_LOOP_CHANNEL);
f = adc_raw[ADC_LOOP_CHANNEL];
// 计算回路电流
@ -723,7 +715,7 @@ float32 get_current_deal(float32 current)
}
else
{
return (uint16_t)(current * 10) * 0.1f;
return (uint16_t)(current * 100) * 0.01f;
}
}

View File

@ -4,6 +4,8 @@
#include "flash.h"
#include "flow.h"
#define BOOTLOAD_SET_FLAG 0xbb01
#define BOOTLOAD_UNSET_FLAG 0xbb01
/**
* @brief Defines the start address of the application in flash memory.
*/
@ -22,7 +24,7 @@
/**
* @brief Defines the start address of the backup area for the application in flash memory.
*/
#define BOOTLOAD_APP_BACKUP_ADDR_START (BOOTLOAD_APP_START_ADDRESS + LL_FLASH_BANK1_PAGE_NUM * LL_FLASH_PAGE_SIZE)
#define BOOTLOAD_APP_BACKUP_ADDR_START (BOOTLOAD_APP_START_ADDRESS + 256 * LL_FLASH_PAGE_SIZE)
/**
* @brief Defines the timeout for the bootloading process.

View File

@ -17,7 +17,8 @@
#define EEPROM_M95_1_BLOCK_SIZE M95_PAGE_SIZE_128 * 64
#define EEPROM_M95_2_BLOCK_SIZE M95_PAGE_SIZE_256 * 32
#define EEPROM_FM24_BLOCK_SIZE FM24_PAGE_SIZE * 8
#define EEPROM_FM24_BLOCK_SIZE FM24_PAGE_SIZE * 4 // 因为块大小为2的N次方
#define EEPROM_M95_1_SIZE _M95512_
#define EEPROM_M95_2_SIZE _M95M02_

View File

@ -24,7 +24,7 @@ struct fal_flash_dev eeprom_fm24 =
.len = EEPROM_FM24_SIZE,
.blk_size = EEPROM_FM24_BLOCK_SIZE,
.ops = {init, read, write, erase},
.write_gran = 8};
.write_gran = 1};
static int init(void)
{
@ -33,6 +33,10 @@ static int init(void)
static int erase(long offset, size_t size)
{
// uint8_t buf[EEPROM_FM24_BLOCK_SIZE];
// osel_memset(buf, 0x00, EEPROM_FM24_BLOCK_SIZE);
// uint32_t addr = eeprom_fm24.addr + offset;
// eeprom_fm24_write(addr, (uint8_t *)buf, size);
return size;
}

View File

@ -11,7 +11,8 @@
#include <fal.h>
static int init(void);
static int erase(long offset, size_t size);
static int erase1(long offset, size_t size);
static int erase2(long offset, size_t size);
static int read1(long offset, uint8_t *buf, size_t size);
static int write1(long offset, const uint8_t *buf, size_t size);
@ -26,7 +27,7 @@ struct fal_flash_dev eeprom_m95_1 =
.addr = 0x000000,
.len = EEPROM_M95_1_SIZE,
.blk_size = EEPROM_M95_1_BLOCK_SIZE,
.ops = {init, read1, write1, erase},
.ops = {init, read1, write1, erase1},
.write_gran = 8}; // 设置写粒度,单位 bit 0 表示未生效(默认值为 0 ),该成员是 fal 版本大于 0.4.0 的新增成员。各个 flash 写入粒度不尽相同,可通过该成员进行设置,以下列举几种常见 Flash 写粒度
struct fal_flash_dev eeprom_m95_2 =
@ -35,7 +36,7 @@ struct fal_flash_dev eeprom_m95_2 =
.addr = 0x000000,
.len = EEPROM_M95_2_SIZE,
.blk_size = EEPROM_M95_2_BLOCK_SIZE,
.ops = {init, read2, write2, erase},
.ops = {init, read2, write2, erase2},
.write_gran = 8};
static int init(void)
@ -43,9 +44,21 @@ static int init(void)
return 1;
}
static int erase(long offset, size_t size)
static int erase1(long offset, size_t size)
{
__NOP();
// uint8_t buf[EEPROM_M95_1_BLOCK_SIZE];
// osel_memset(buf, 0x00, EEPROM_M95_1_BLOCK_SIZE);
// uint32_t addr = eeprom_m95_1.addr + offset;
// eeprom_m95_write(M95_1, addr, (uint8_t *)buf, size);
return size;
}
static int erase2(long offset, size_t size)
{
// uint8_t buf[EEPROM_M95_2_BLOCK_SIZE];
// osel_memset(buf, 0x00, EEPROM_M95_2_BLOCK_SIZE);
// uint32_t addr = eeprom_m95_2.addr + offset;
// eeprom_m95_write(M95_2, addr, (uint8_t *)buf, size);
return size;
}

View File

@ -50,7 +50,7 @@ extern "C"
/* the file cache table size, it will improve GC speed in file mode when using cache */
#ifndef FDB_FILE_CACHE_TABLE_SIZE
#define FDB_FILE_CACHE_TABLE_SIZE 6
#define FDB_FILE_CACHE_TABLE_SIZE 2
#endif
#ifndef FDB_WRITE_GRAN

View File

@ -43,7 +43,7 @@
/* the total remain empty sector threshold before GC */
#ifndef FDB_GC_EMPTY_SEC_THRESHOLD
#define FDB_GC_EMPTY_SEC_THRESHOLD 6 // https://github.com/armink/FlashDB/issues/156
#define FDB_GC_EMPTY_SEC_THRESHOLD 1 // https://github.com/armink/FlashDB/issues/156 这个值设定大了会有异常
#endif
/* the string KV value buffer size for legacy fdb_get_kv(db, ) function */

View File

@ -11,6 +11,9 @@
#ifndef __DATA_TYPE_DEF_H_
#define __DATA_TYPE_DEF_H_
#include <stdint.h>
#ifndef PI
#define PI (3.14159265358979323846f)
#endif
#ifndef TRUE
#define TRUE 1
@ -73,6 +76,29 @@ typedef union
#pragma pack()
typedef enum
{
DATA_TYPE_INT8 = 0, // 8-bit signed integer
DATA_TYPE_UINT8, // 8-bit unsigned integer
DATA_TYPE_INT16, // 16-bit signed integer
DATA_TYPE_UINT16, // 16-bit unsigned integer
DATA_TYPE_INT32, // 32-bit signed integer
DATA_TYPE_UINT32, // 32-bit unsigned integer
DATA_TYPE_INT64, // 64-bit signed integer
DATA_TYPE_UINT64, // 64-bit unsigned integer
DATA_TYPE_FLOAT, // 32-bit floating point number
DATA_TYPE_DOUBLE, // 64-bit floating point number
DATA_TYPE_STRING, // string
DATA_TYPE_ARRAY, // array
DATA_TYPE_STRUCT, // structure
DATA_TYPE_UNION, // union
DATA_TYPE_ENUM, // enumeration
DATA_TYPE_POINTER, // pointer
DATA_TYPE_FUNCTION, // function
DATA_TYPE_VOID, // void
DATA_TYPE_MAX,
} data_type_e;
typedef uint16_t nwk_id_t;
/**
@ -162,6 +188,15 @@ typedef uint16_t nwk_id_t;
#define RANGE(x, a, b) (MIN(MAX(x, a), b))
#endif
/**
* @brief Macro to check if a value is between a minimum and maximum value (inclusive).
* @param x The value to check.
* @param min The minimum value.
* @param max The maximum value.
* @return Returns 1 if the value is between the minimum and maximum values (inclusive), 0 otherwise.
*/
#define IS_BETWEEN(x, min, max) ((x) >= min && (x) <= max)
#define ARRAY_LEN(arr) (sizeof(arr)) / (sizeof(arr[0]))
#define HI_UINT16(a) (((uint16_t)(a) >> 8) & 0xFF)
@ -237,5 +272,5 @@ static inline float32 S2B_FLOAT32(float fv)
#define ASCII_TO_NUM(c) ((c) >= '0' && (c) <= '9' ? (c) - '0' : (c) - 'A' + 10)
// 数字转换为ASSIC码
#define NUM_TO_ASCII(x) ((x) < 10 ? (x) + '0' : (x)-10 + 'A')
#define NUM_TO_ASCII(x) ((x) < 10 ? (x) + '0' : (x) - 10 + 'A')
#endif /* __DATA_TYPE_DEF_H_ */

View File

@ -40,7 +40,7 @@
typedef struct
{
uint16_t year;
uint8_t year;
uint8_t month;
uint8_t day;
} rtc_date_t;
@ -52,6 +52,7 @@ typedef struct
uint8_t second;
} rtc_time_t;
extern void assic_to_str(uint8_t *assic, uint8_t len, uint8_t *str); // ASCII码转字符串
extern uint32_t cpu_encrypt(void); // CPU加密
extern BOOL cpu_judge_encrypt(uint32_t cupid_encrypt); // CPU判断加密
extern void version_split(uint8_t *version, uint8_t *hi, uint8_t *lo); // 版本号1.0拆解成1和0
@ -63,15 +64,17 @@ extern uint32_t crc32_compute(const uint8_t *const data, uint16_t length); // CR
extern uint8_t xor_compute(const uint8_t *const data, uint16_t length); // 异或校验
extern uint8_t get_bit_num(uint8_t bit); // 获取bit位的值
extern BOOL is_bit_set(int x, int k); // 判断x的第k位是否为1
extern uint8_t isLeap(uint16_t year); // 检查是否是闰年
extern uint8_t is_leap(uint16_t year); // 检查是否是闰年
extern uint16_t dayOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几天
extern uint16_t weekOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几周
extern uint8_t get_weekday(uint16_t year, uint8_t month, uint8_t day); // 获取今天星期几
extern uint8_t hex_format_dec(uint8_t hex); // 十六进制转十进制
extern uint8_t dec_format_hex(uint8_t dec); // 十进制转十六进制
extern void quicksort(uint16_t arr[], int low, int high); // 快速排序
extern void insertion_sort(uint16_t arr[], uint8_t n); // 插入排序
extern uint32_t time2stamp(rtc_date_t date, rtc_time_t time); // 北京时间转时间戳
extern uint32_t time2stamp(rtc_date_t *date, rtc_time_t *time); // 北京时间转时间戳
extern void stamp2time(uint32_t stamp, rtc_date_t *date, rtc_time_t *time); // 时间戳转北京时间
#endif //__LIB_H
extern void convert_seconds(uint32_t total_seconds, char *date); // 秒数转换成时分秒
extern void add_commas(uint32_t num, char *result); // 数字添加逗号
#endif //__LIB_H

View File

@ -15,7 +15,7 @@
// mem1内存参数设定.mem1完全处于内部SRAM里面.(设置内部SARM的内存池和内存表的参数)
#define MEM1_BLOCK_SIZE 32 // 一个内存块大小为32字节
#define MEM1_MAX_SIZE 26 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
#define MEM1_MAX_SIZE 24 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
#define MEM1_ALLOC_TABLE_SIZE MEM1_MAX_SIZE / MEM1_BLOCK_SIZE // 内存表大小(有多少块内存块)
// mem2内存参数设定.mem2的内存池处于外部SRAM里面

View File

@ -0,0 +1,13 @@
@ECHO OFF
ECHO CCGUIAntiAlias.BAT: Compiling GUI\AntiAlias
CALL CC GUIAAArc
CALL CC GUIAAChar
CALL CC GUIAAChar2
CALL CC GUIAAChar4
CALL CC GUIAACircle
CALL CC GUIAALib
CALL CC GUIAALine
CALL CC GUIAAPoly
CALL CC GUIAAPolyOut

View File

@ -0,0 +1,87 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIArcAA.C
Purpose : Draw Arc routines with Antialiasing
---------------------------END-OF-HEADER------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "GUI_Protected.h"
#if GUI_SUPPORT_AA
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _DrawArcAA
*/
static void _DrawArcAA(int x0, int y0, int rx, int ry, int a0, int a1) {
int PenSizePrev = GUI_GetPenSize();
int PenSize_AA;
int Factor;
Factor = GUI_Context.AA_HiResEnable ? 1 : GUI_Context.AA_Factor;
/* Convert into Hires coordinates (if not already done) */
x0 *= Factor;
y0 *= Factor;
rx *= Factor;
ry *= Factor;
PenSize_AA = PenSizePrev * GUI_Context.AA_Factor;
GUI_AA_Init_HiRes(x0 - rx - PenSize_AA, x0 + rx + PenSize_AA);
GUI_SetPenSize(PenSize_AA);
GL_DrawArc(x0, y0, rx, ry,a0,a1);
GUI_SetPenSize(PenSizePrev); /* restore former pen size */
/* Cleanup */
GUI_AA_Exit();
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AA_DrawArc
*/
void GUI_AA_DrawArc(int x0, int y0, int rx, int ry, int a0, int a1) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG_AA(x0,y0);
WM_ITERATE_START(NULL) {
#endif
_DrawArcAA( x0, y0, rx, ry, a0, a1);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
#else /* Avoid problems with empty object modules */
void GUIAAArc_C(void);
void GUIAAArc_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,167 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICharAA.C
Purpose : Display antialiased
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
#if GUI_SUPPORT_AA
#include <stdio.h>
#include <string.h>
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef void tSetPixelAA(int x, int y, U8 Intens);
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static const U8 Bit2Mask0[] = {1<<7, 1<<5, 1<<3, 1<<1};
static const U8 Bit2Mask1[] = {1<<6, 1<<4, 1<<2, 1<<0};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* Draw
*/
static void Draw(int x0, int y0, int XSize, int YSize, int BytesPerLine, const U8*pData) {
int x, y;
tSetPixelAA* pfSetPixelAA;
pfSetPixelAA = (GUI_Context.TextMode & GUI_TM_TRANS)
? LCD_SetPixelAA : LCD_SetPixelAA_NoTrans;
for (y=0; y<YSize; y++) {
const U8* pData0 = pData;
const U8* pData1 = pData+BytesPerLine;
for (x=0; x<XSize; x++) {
int PixelCnt=0;
int Mask0 = Bit2Mask0[x&3];
int Mask1 = Bit2Mask1[x&3];
if ((*pData0) & Mask0)
PixelCnt++;
if ((*pData0) & Mask1)
PixelCnt++;
if ((*pData1) & Mask0)
PixelCnt++;
if ((*pData1) & Mask1)
PixelCnt++;
if ((x&3) ==3) {
pData0++;
pData1++;
}
switch (PixelCnt) {
case 4: LCD_HL_DrawPixel(x0+x,y0+y); break;
case 3: (*pfSetPixelAA) (x0+x,y0+y, 12); break;
case 2: (*pfSetPixelAA) (x0+x,y0+y, 8); break;
case 1: (*pfSetPixelAA) (x0+x,y0+y, 4); break;
}
}
pData+=2*BytesPerLine;
}
}
/*********************************************************************
*
* GUIPROP_FindChar
*/
static const GUI_FONT_PROP* GUIPROP_FindChar(const GUI_FONT_PROP* pProp, U16P c) {
for (pProp = GUI_Context.pAFont->p.pProp; pProp; pProp=(const GUI_FONT_PROP*) pProp->pNext) {
if ((c>=pProp->First) && (c<=pProp->Last))
break;
}
return pProp;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIPROPAA_DispChar
*/
void GUIPROPAA_DispChar(U16P c) {
int BytesPerLine;
GUI_DRAWMODE DrawMode = GUI_Context.TextMode;
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
if (pProp) {
GUI_DRAWMODE OldDrawMode;
const GUI_CHARINFO* pCharInfo = pProp->paCharInfo+(c-pProp->First);
BytesPerLine = pCharInfo->BytesPerLine;
OldDrawMode = LCD_SetDrawMode(DrawMode);
Draw ( GUI_Context.DispPosX, GUI_Context.DispPosY,
(pCharInfo->XSize+1)/2,
GUI_Context.pAFont->YSize,
BytesPerLine,
(U8 const*) pCharInfo->pData
);
LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */
GUI_Context.DispPosX += (pCharInfo->XDist+1)/2;
}
}
/*********************************************************************
*
* GUIPROPAA_GetCharDistX
*/
int GUIPROPAA_GetCharDistX(U16P c) {
int r;
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
r = (pProp) ? (pProp->paCharInfo+(c-pProp->First))->XSize : 0;
return (r+1)/2;
}
/*********************************************************************
*
* GUIPROPAA_GetFontInfo
*/
void GUIPROPAA_GetFontInfo(const GUI_FONT * pFont, GUI_FONTINFO* pfi) {
GUI_USE_PARA(pFont);
pfi->Flags = GUI_FONTINFO_FLAG_PROP | GUI_FONTINFO_FLAG_AA;
}
/*********************************************************************
*
* GUIPROPAA_IsInFont
*/
char GUIPROPAA_IsInFont(const GUI_FONT * pFont, U16 c) {
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(pFont->p.pProp, c);
return (pProp==NULL) ? 0 : 1;
}
#else /* Avoid problems with empty object modules */
void GUIAAChar_C(void);
void GUIAAChar_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,201 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICharAA2.C
Purpose : Display antialiased 2bpp
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
#if GUI_SUPPORT_AA
#include <stdio.h>
#include <string.h>
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define MAX_CHAR_SIZE 100
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
/* used by transparent characters */
static const int aConvTable[4] = {0, 5, 10, 15};
/* used by non transparent characters */
static LCD_COLOR aColor[4];
static LCD_PIXELINDEX OldColorIndex, OldBkColorIndex;
static GUI_LOGPALETTE Palette = {4, 0, &aColor[0]};
static GUI_BITMAP Bitmap = {0, 0, 0, 2, 0, &Palette, 0};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* DrawNoTrans
*/
static void DrawNoTrans(int x0, int y0, int XSize, int YSize, int BytesPerLine, const U8*pData) {
if ((OldColorIndex != LCD_COLORINDEX) ||
(OldBkColorIndex != LCD_BKCOLORINDEX)) {
int i;
LCD_PIXELINDEX BkColorIndex = LCD_BKCOLORINDEX;
LCD_PIXELINDEX ColorIndex = LCD_COLORINDEX;
LCD_COLOR BkColor = LCD_Index2Color(BkColorIndex);
LCD_COLOR Color = LCD_Index2Color(ColorIndex);
aColor[0] = BkColor;
for (i = 1; i < 3; i++) {
U8 Intens;
Intens = 5 * i;
aColor[i] = LCD_AA_MixColors(Color, BkColor, Intens);
}
aColor[3] = Color;
LCD_GetpPalConvTableUncached(&Palette);
OldColorIndex = ColorIndex;
OldBkColorIndex = BkColorIndex;
}
Bitmap.XSize = XSize;
Bitmap.YSize = YSize;
Bitmap.BytesPerLine = BytesPerLine;
Bitmap.pData = pData;
GL_DrawBitmap(&Bitmap, x0, y0);
}
/*********************************************************************
*
* DrawTrans
*/
static void DrawTrans(int x0, int y0, int XSize, int YSize, int BytesPerLine, const U8*pData) {
int x, y;
for (y = 0; y < YSize; y++) {
const U8 *pData0 = pData;
U8 Rem = XSize & 3;
for (x = 0; x < XSize - 1; x += 4) {
LCD_SetPixelAA(x + x0 , y0 + y, aConvTable[((*pData0 ) >> 6) ]);
LCD_SetPixelAA(x + x0 + 1, y0 + y, aConvTable[((*pData0 ) >> 4) & 0x03]);
LCD_SetPixelAA(x + x0 + 2, y0 + y, aConvTable[((*pData0 ) >> 2) & 0x03]);
LCD_SetPixelAA(x + x0 + 3, y0 + y, aConvTable[((*pData0++) ) & 0x03]);
}
if (Rem) {
LCD_SetPixelAA(x + x0 , y0 + y, aConvTable[((*pData0 ) >> 6) ]);
if (Rem > 1) {
LCD_SetPixelAA(x + x0 + 1, y0 + y, aConvTable[((*pData0 ) >> 4) & 0x03]);
if (Rem > 2) {
LCD_SetPixelAA(x + x0 + 2, y0 + y, aConvTable[((*pData0 ) >> 2) & 0x03]);
}
}
}
pData += BytesPerLine;
}
}
/*********************************************************************
*
* GUIPROP_FindChar
*/
static const GUI_FONT_PROP* GUIPROP_FindChar(const GUI_FONT_PROP* pProp, U16P c) {
for (pProp = GUI_Context.pAFont->p.pProp; pProp; pProp=(const GUI_FONT_PROP*) pProp->pNext) {
if ((c>=pProp->First) && (c<=pProp->Last))
break;
}
return pProp;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIPROP_AA2_DispChar
*/
void GUIPROP_AA2_DispChar(U16P c) {
int BytesPerLine;
GUI_DRAWMODE DrawMode = GUI_Context.TextMode;
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
if (pProp) {
GUI_DRAWMODE OldDrawMode;
const GUI_CHARINFO* pCharInfo = pProp->paCharInfo+(c-pProp->First);
BytesPerLine = pCharInfo->BytesPerLine;
OldDrawMode = LCD_SetDrawMode(DrawMode);
if (DrawMode & GUI_TM_TRANS) {
DrawTrans(GUI_Context.DispPosX,
GUI_Context.DispPosY,
pCharInfo->XSize,
GUI_Context.pAFont->YSize,
BytesPerLine,
(U8 const*)pCharInfo->pData
);
} else {
DrawNoTrans(GUI_Context.DispPosX,
GUI_Context.DispPosY,
pCharInfo->XSize,
GUI_Context.pAFont->YSize,
BytesPerLine,
(U8 const*)pCharInfo->pData
);
}
LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */
GUI_Context.DispPosX += pCharInfo->XDist;
}
}
/*********************************************************************
*
* GUIPROP_AA2_GetCharDistX
*/
int GUIPROP_AA2_GetCharDistX(U16P c) {
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
return (pProp) ? (pProp->paCharInfo+(c-pProp->First))->XSize : 0;
}
/*********************************************************************
*
* GUIPROP_AA2_GetFontInfo
*/
void GUIPROP_AA2_GetFontInfo(const GUI_FONT * pFont, GUI_FONTINFO* pfi) {
GUI_USE_PARA(pFont);
pfi->Flags = GUI_FONTINFO_FLAG_PROP | GUI_FONTINFO_FLAG_AA2;
}
/*********************************************************************
*
* GUIPROP_AA2_IsInFont
*/
char GUIPROP_AA2_IsInFont(const GUI_FONT * pFont, U16 c) {
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(pFont->p.pProp, c);
return (pProp==NULL) ? 0 : 1;
}
#else /* Avoid problems with empty object modules */
void GUIAAChar2_C(void);
void GUIAAChar2_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,129 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICharAA.C
Purpose : Display antialiased
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
#if GUI_SUPPORT_AA
#include <stdio.h>
#include <string.h>
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* Draw
*/
static void Draw(int x0, int y0, int XSize, int YSize, int BytesPerLine, const U8*pData) {
int x, y;
tLCD_SetPixelAA* pfSetPixelAA;
pfSetPixelAA = (GUI_Context.TextMode && GUI_TM_TRANS) ?
LCD_SetPixelAA : LCD_SetPixelAA_NoTrans;
for (y=0; y<YSize; y++) {
const U8*pData0 = pData;
for (x=0; x<XSize-1; x+=2) {
(*pfSetPixelAA)(x+x0,y0+y, (*pData0)>>4); /* x0+x changed -> x+x0 to avoid problems with IAR's ICCMC80 */
(*pfSetPixelAA)(x0+x+1,y0+y, (*pData0++)&15);
}
if (XSize&1) {
(*pfSetPixelAA)(x0+x,y0+y, (*pData0)&15);
}
pData+=BytesPerLine;
}
}
/*********************************************************************
*
* GUIPROP_FindChar
*/
static const GUI_FONT_PROP* GUIPROP_FindChar(const GUI_FONT_PROP* pProp, U16P c) {
for (pProp = GUI_Context.pAFont->p.pProp; pProp; pProp=(const GUI_FONT_PROP*) pProp->pNext) {
if ((c>=pProp->First) && (c<=pProp->Last))
break;
}
return pProp;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIPROP_AA4_DispChar
*/
void GUIPROP_AA4_DispChar(U16P c) {
int BytesPerLine;
GUI_DRAWMODE DrawMode = GUI_Context.TextMode;
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
if (pProp) {
GUI_DRAWMODE OldDrawMode;
const GUI_CHARINFO* pCharInfo = pProp->paCharInfo+(c-pProp->First);
BytesPerLine = pCharInfo->BytesPerLine;
OldDrawMode = LCD_SetDrawMode(DrawMode);
Draw ( GUI_Context.DispPosX, GUI_Context.DispPosY,
pCharInfo->XSize,
GUI_Context.pAFont->YSize,
BytesPerLine,
(U8 const*)pCharInfo->pData
);
LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */
GUI_Context.DispPosX += pCharInfo->XDist;
}
}
/*********************************************************************
*
* GUIPROP_AA4_GetCharDistX
*/
int GUIPROP_AA4_GetCharDistX(U16P c) {
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
return (pProp) ? (pProp->paCharInfo+(c-pProp->First))->XSize : 0;
}
/*********************************************************************
*
* GUIPROP_AA4_GetFontInfo
*/
void GUIPROP_AA4_GetFontInfo(const GUI_FONT * pFont, GUI_FONTINFO* pfi) {
GUI_USE_PARA(pFont);
pfi->Flags = GUI_FONTINFO_FLAG_PROP | GUI_FONTINFO_FLAG_AA4;
}
/*********************************************************************
*
* GUIPROP_AA4_IsInFont
*/
char GUIPROP_AA4_IsInFont(const GUI_FONT * pFont, U16 c) {
const GUI_FONT_PROP* pProp = GUIPROP_FindChar(pFont->p.pProp, c);
return (pProp==NULL) ? 0 : 1;
}
#else /* Avoid problems with empty object modules */
void GUIAAChar4_C(void);
void GUIAAChar4_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,133 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICirleAA.C
Purpose : Draw Circle routines with Antialiasing
TBD: Circle needs to be calculated from top to bottom in order
to avoid AA problems at certain positions.
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#if GUI_SUPPORT_AA
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* FillCircle
*/
static void FillCircle(int x0, int y0, int r) {
int i, x;
int sqmax = r*r+r/2;
int yMin, yMax;
/* First step : find uppermost and lowermost coordinates */
yMin = y0 - r;
yMax = y0 + r;
/* Use Clipping rect to reduce calculation (if possible) */
if (GUI_Context.pClipRect_HL) {
if (yMax > GUI_Context.pClipRect_HL->y1)
yMax = GUI_Context.pClipRect_HL->y1;
if (yMin < GUI_Context.pClipRect_HL->y0)
yMin = GUI_Context.pClipRect_HL->y0;
}
/* Draw top half */
for (i=0, x=r; i<r; i++) {
int y = y0-i;
if ((y >= yMin) && (y <= yMax)) {
/* calc proper x-value */
while ((i*i+x*x) >sqmax)
--x;
LCD_HL_DrawHLine (x0-x, y, x0+x);
}
}
/* Draw bottom half */
for (i=0, x=r; i<r; i++) {
int y = y0 + i;
if ((y >= yMin) && (y <= yMax)) {
/* calc proper x-value */
while ((i*i+x*x) >sqmax)
--x;
LCD_HL_DrawHLine (x0-x, y, x0+x);
}
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GL_FillCircleAA_HiRes
*/
void GL_FillCircleAA_HiRes(int x0, int y0, int r) {
/* Init AA Subsystem, pass horizontal limits */
GUI_AA_Init_HiRes(x0-r, x0+r);
/* Do the actual drawing */
FillCircle(x0, y0, r);
/* Cleanup */
GUI_AA_Exit();
}
/*********************************************************************
*
* GUI_AA_FillCircle
*/
void GUI_AA_FillCircle(int x0, int y0, int r) {
#if (GUI_WINSUPPORT)
GUI_RECT Rect;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG_AA(x0,y0);
#endif
if (!GUI_Context.AA_HiResEnable) {
x0 *= GUI_Context.AA_Factor;
y0 *= GUI_Context.AA_Factor;
r *= GUI_Context.AA_Factor;
}
#if (GUI_WINSUPPORT)
Rect.x0 = GUI_AA_HiRes2Pixel(x0 - r);
Rect.x1 = GUI_AA_HiRes2Pixel(x0 + r);
Rect.y0 = GUI_AA_HiRes2Pixel(y0 - r);
Rect.y1 = GUI_AA_HiRes2Pixel(y0 + r);
WM_ITERATE_START(&Rect); {
#endif
GL_FillCircleAA_HiRes(x0, y0, r);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
#else /* Avoid problems with empty object modules */
void GUIAACircle_C(void);
void GUIAACircle_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,280 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIAALib.C
Purpose : Antialiasing library
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
#include "LCD_ConfDefaults.h" /* Required in order to know max. XSize so we do not waste memory */
#if GUI_SUPPORT_AA
#include <stdio.h>
#include <string.h>
/*********************************************************************
*
* Defines, config defaults
*
**********************************************************************
*/
#ifndef GUI_AA_LINEBUFFER_SIZE
#define GUI_AA_LINEBUFFER_SIZE LCD_XSIZE
#endif
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static U8 abAABuffer[GUI_AA_LINEBUFFER_SIZE]; /* This could be changed to dynamic memory ... */
static U8* pabAABuffer;
static int _x0, _x1, _y, _x0_InUse, _x1_InUse;
static GUI_RECT ClipRect_HL;
static tLCD_HL_APIList DrawAPICopy; /* Copy of device function ptr list */
static const tLCD_HL_APIList* pLCD_HLPrev; /* Copy of device function ptr list */
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _CleanLine
*/
static void _CleanLine(void) {
GUI_MEMSET(pabAABuffer,0, _x1 - _x0+1);
_y = -16383; /* Invalidate */
_x0_InUse = 16383;
_x1_InUse = -16383;
}
/*********************************************************************
*
* _FlushLine
*/
static void _FlushLine(void) {
int i;
int iEnd = _x1_InUse-_x0;
int IMax = GUI_Context.AA_Factor * GUI_Context.AA_Factor;
for (i =_x0_InUse-_x0; i<=iEnd; i++) {
int Intens = *(pabAABuffer+i);
if (Intens) {
/* Check we can use line draw */
if (Intens == IMax) {
int j;
for (j=i; j<iEnd; ) {
if (*(pabAABuffer+j+1) != IMax) {
break;
}
j++;
}
/* Draw the full pixel(s) */
if (j!=i) {
pLCD_HLPrev->pfDrawHLine(_x0+i, _y, _x0+j);
i = j; /*xxx*/
} else {
LCD_HL_DrawPixel (_x0+i,_y);
}
} else {
LCD_SetPixelAA(_x0+i,_y, (15*Intens+IMax/2)/IMax);
}
}
}
_CleanLine();
}
/*********************************************************************
*
* _DrawHLine
*
* Purpose:
* This is the redirected DrawHLine routine which is called
* instead of the default output routine. Its job is to do
* antialiasing and then perform the drawing operations.
*/
static void _DrawHLine (int x0, int y, int x1) {
int x0Real, x1Real;
/* Make sure there is something to do */
if (x1<x0)
return;
/* Flush line if we are in an other pixel (real) line */
if (y/GUI_Context.AA_Factor != _y) {
_FlushLine();
_y = y/GUI_Context.AA_Factor;
}
x0Real = x0/GUI_Context.AA_Factor;
x1Real = x1/GUI_Context.AA_Factor;
/* Handle used area (speed optimization for drawing) */
if (x0Real < _x0_InUse)
_x0_InUse = x0Real;
if (x1Real > _x1_InUse)
_x1_InUse = x1Real;
/* Clip (should not be necessary ... Just to be on the safe side ! */
if (x0Real < _x0) {
x0 = _x0 * GUI_Context.AA_Factor;
}
if (x1Real > _x1) {
x1 = (_x1+1)*GUI_Context.AA_Factor-1;
}
/* Make sure there is still something to do (after clipping) */
if (x1<x0)
return;
/* Inc. hit counters in buffer */
{
int x0_Off = x0/GUI_Context.AA_Factor-_x0;
int x1_Off = x1/GUI_Context.AA_Factor-_x0;
int iRem = x1_Off-x0_Off+1;
U8 *pDest = pabAABuffer+x0_Off;
if (iRem ==1) {
*(pDest) += x1-x0+1;
} else {
/* First Pixel */
*pDest++ += ((x0_Off+_x0+1)*GUI_Context.AA_Factor-x0);
/* Middle Pixels */
for (;--iRem>1; ) {
*pDest++ +=GUI_Context.AA_Factor;
}
/* Last Pixel */
*pDest += (1+x1- (x1_Off+_x0) *GUI_Context.AA_Factor);
}
}
}
/*********************************************************************
*
* CalcClipRectHL
*/
static void CalcClipRectHL(void) {
ClipRect_HL.x0 = GUI_Context.ClipRect.x0 * GUI_Context.AA_Factor;
ClipRect_HL.y0 = GUI_Context.ClipRect.y0 * GUI_Context.AA_Factor;
ClipRect_HL.x1 = (GUI_Context.ClipRect.x1+1) * GUI_Context.AA_Factor -1;
ClipRect_HL.y1 = (GUI_Context.ClipRect.y1+1) * GUI_Context.AA_Factor -1;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AA_Init
*/
int GUI_AA_Init(int x0, int x1) {
int r =0;
/* Bounds checking:
Make sure x0, x1 are in legal range ...
(The important point is that they span no more than configured as
buffer size)
*/
if (x0<0)
x0 =0;
if (x1-x0 > GUI_AA_LINEBUFFER_SIZE-1)
x1 = x0+GUI_AA_LINEBUFFER_SIZE-1;
/* Is there anything to do at all ??? */
if (x1 < x0) {
x1 = x0; /* Not really ... */
r =1;
}
DrawAPICopy = *GUI_Context.pLCD_HL; /* Copy API table */
pLCD_HLPrev = GUI_Context.pLCD_HL; /* Remember list ptr (for restore) */
DrawAPICopy.pfDrawHLine = _DrawHLine; /* modify function ptr. for hline */
GUI_Context.pLCD_HL = &DrawAPICopy; /* Use copy of fp-list */
pabAABuffer = abAABuffer;
_x0 = x0;
_x1 = x1;
_CleanLine();
CalcClipRectHL();
GUI_Context.pClipRect_HL = &ClipRect_HL;
return r;
}
/*********************************************************************
*
* GUI_AA_Init_HiRes
*/
int GUI_AA_Init_HiRes(int x0, int x1) {
x0 /= GUI_Context.AA_Factor;
x1 /= GUI_Context.AA_Factor;
return GUI_AA_Init(x0, x1);
}
/*********************************************************************
*
* GUI_AA_SetFactor
*/
void GUI_AA_SetFactor(int Factor) {
GUI_Context.AA_Factor = Factor;
CalcClipRectHL(); /* High level clipping depends on quality factor */
}
/*********************************************************************
*
* GUI_AA_GetFactor
*/
int GUI_AA_GetFactor(void) {
return GUI_Context.AA_Factor;
}
/*********************************************************************
*
* GUI_AA_DisableHiRes
*/
void GUI_AA_DisableHiRes(void) {
GUI_Context.AA_HiResEnable = 0;
}
/*********************************************************************
*
* GUI_AA_EnableHiRes
*/
void GUI_AA_EnableHiRes(void) {
GUI_Context.AA_HiResEnable =1;
}
/*********************************************************************
*
* GUI_AA_HiRes2Pixel
*/
I16 GUI_AA_HiRes2Pixel(int HiRes) {
return GUI_Context.AA_Factor ? (HiRes / GUI_Context.AA_Factor) : HiRes;
}
/*********************************************************************
*
* GUI_AA_Exit
*/
void GUI_AA_Exit(void) {
_FlushLine();
/* restore previous settings */
GUI_Context.pLCD_HL = pLCD_HLPrev;
GUI_Context.pClipRect_HL = &GUI_Context.ClipRect;
}
#else /* Avoid problems with empty object modules */
void GUIAALib_C(void);
void GUIAALib_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,109 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* ľC/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 : GUIAALine.C
Purpose : Drawing lines with antialiasing
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
#include <stddef.h>
#if GUI_SUPPORT_AA
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _AA_DrawLine
*/
static void _AA_DrawLine(int x0, int y0, int x1, int y1) {
int xMin, xMax;
U8 PenSizeOld = GUI_GetPenSize();
U8 PenSizeHR = PenSizeOld * GUI_Context.AA_Factor;
U8 OldPenShape = GUI_SetPenShape(GUI_PS_FLAT);
/* Calculate left and right borders for AA module */
if (x0 < x1) {
xMin = x0;
xMax = x1;
} else {
xMin = x1;
xMax = x0;
}
if (GUI_Context.AA_HiResEnable) {
xMin -= PenSizeHR;
xMax += PenSizeHR;
xMin /= GUI_Context.AA_Factor;
xMax /= GUI_Context.AA_Factor;
} else {
xMin -= PenSizeOld;
xMax += PenSizeOld;
x0 *= GUI_Context.AA_Factor;
x1 *= GUI_Context.AA_Factor;
y0 *= GUI_Context.AA_Factor;
y1 *= GUI_Context.AA_Factor;
}
/* Do the actual drawing */
GUI_AA_Init(xMin, xMax);
GUI_SetPenSize(PenSizeHR);
GL_DrawLine(x0 , y0 , x1 , y1 );
GUI_AA_Exit();
/* Draw end points (can be optimized away in future, TBD*/
switch (OldPenShape) {
case GUI_PS_ROUND:
{
int r = GUI_Context.AA_Factor * PenSizeOld / 2;
GL_FillCircleAA_HiRes(x0 , y0 , r);
GL_FillCircleAA_HiRes(x1 , y1 , r);
}
break;
}
GUI_SetPenSize(PenSizeOld);
GUI_SetPenShape(OldPenShape);
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AA_DrawLine
*/
void GUI_AA_DrawLine(int x0, int y0, int x1, int y1) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG_AA(x0,y0);
WM_ADDORG_AA(x1,y1);
WM_ITERATE_START(NULL); {
#endif
_AA_DrawLine(x0, y0, x1, y1);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
#else /* Avoid problems with empty object modules */
void GUIAALine_C(void);
void GUIAALine_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,112 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIPolyAA.C
Purpose : Draw Polygon routines with Antialiasing
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Private.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#if GUI_SUPPORT_AA
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _FillPolygonAA
*/
static void _FillPolygonAA(GUI_POINT* paPoint, int NumPoints, int x, int y) {
int i;
int Stat;
int x0,x1;
int PosFactor = GUI_Context.AA_HiResEnable ? 1 : GUI_Context.AA_Factor;
/* Calc horizontal limits and init GUI_AA */
x0 = x1 = paPoint[0].x;
for (i=1; i< NumPoints; i++) {
int x = paPoint[i].x;
if (x<x0)
x0 = x;
if (x>x1)
x1 = x;
}
if (!GUI_Context.AA_HiResEnable) {
Stat = GUI_AA_Init(x0+x,x1+x);
} else {
Stat = GUI_AA_Init((x0+x)/GUI_Context.AA_Factor,(x1+x)/GUI_Context.AA_Factor);
}
if (Stat ==0) {
/* Modify pointlist */
if (!GUI_Context.AA_HiResEnable) {
for (i=0; i< NumPoints; i++) {
paPoint[i].x *= GUI_Context.AA_Factor;
paPoint[i].y *= GUI_Context.AA_Factor;
}
}
GL_FillPolygon(paPoint, NumPoints, x * PosFactor, y * PosFactor);
/* Restore pointlist */
if (!GUI_Context.AA_HiResEnable) {
for (i=0; i< NumPoints; i++) {
paPoint[i].x /= GUI_Context.AA_Factor;
paPoint[i].y /= GUI_Context.AA_Factor;
}
}
/* Cleanup */
}
GUI_AA_Exit();
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AA_FillPolygon
*/
void GUI_AA_FillPolygon(/*const*/ GUI_POINT* pPoints, int NumPoints, int x0, int y0) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG_AA(x0,y0);
WM_ITERATE_START(NULL); {
#endif
/* Variables in MEMDEV module (with memory devices only) */
#if GUI_SUPPORT_MEMDEV
if (GUI_Context.pDeviceAPI->pfFillPolygonAA)
GUI_Context.pDeviceAPI->pfFillPolygonAA(pPoints, NumPoints, x0, y0);
else
#endif
_FillPolygonAA (pPoints, NumPoints, x0, y0);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
#else /* Avoid problems with empty object modules */
void GUIAAPoly_C(void);
void GUIAAPoly_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

View File

@ -0,0 +1,54 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIPolyOutAA.C
Purpose : Draw Polygon outline routines with Antialiasing
---------------------------END-OF-HEADER------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "GUI.h"
#if GUI_SUPPORT_AA
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AA_DrawPolyOutline
*/
void GUI_AA_DrawPolyOutline(const GUI_POINT* pSrc, int NumPoints, int Thickness, int x, int y) {
U8 PrevDraw;
GUI_POINT aiTemp[10];
GUI_EnlargePolygon(&aiTemp[0], pSrc, NumPoints, Thickness);
GUI_AA_FillPolygon( &aiTemp[0], NumPoints, x, y );
PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV);
/* Copy points due to const qualifier */
memcpy(aiTemp, pSrc, NumPoints*2*sizeof(GUI_POINT));
GUI_AA_FillPolygon( aiTemp, NumPoints, x, y );
LCD_SetDrawMode(PrevDraw);
}
#else /* Avoid problems with empty object modules */
void GUIAAPolyOut_C(void);
void GUIAAPolyOut_C(void) {}
#endif /* GUI_SUPPORT_AA */
/*************************** End of file ****************************/

Binary file not shown.

View File

@ -0,0 +1,39 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* <EFBFBD>C/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 : GUIConf.h
Purpose : Configures abilities, fonts etc.
----------------------------------------------------------------------
*/
#ifndef GUICONF_H
#define GUICONF_H
#define GUI_OS (0) /* Compile with multitasking support */
#define GUI_SUPPORT_TOUCH (0) /* Support a touch screen (req. win-manager) */
#define GUI_SUPPORT_UNICODE (1) /* Support mixed ASCII/UNICODE strings */
#define GUI_DEFAULT_FONT &GUI_FontHZ16x16
#define GUI_ALLOC_SIZE 5000 /* Size of dynamic memory ... For WM and memory devices*/
/*********************************************************************
*
* Configuration of available packages
*/
#define GUI_WINSUPPORT 0 /* Window manager package available */
#define GUI_SUPPORT_MEMDEV 0 /* Memory devices available */
#define GUI_SUPPORT_AA 1 /* Anti aliasing available */
#endif /* Avoid multiple inclusion */

View File

@ -0,0 +1,31 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUITouch.Conf.h
Purpose : Configures touch screen module
----------------------------------------------------------------------
*/
#ifndef GUITOUCH_CONF_H
#define GUITOUCH_CONF_H
#define GUI_TOUCH_AD_LEFT 20
#define GUI_TOUCH_AD_RIGHT 240
#define GUI_TOUCH_SWAP_XY 1
#define GUI_TOUCH_MIRROR_X 0
#define GUI_TOUCH_MIRROR_Y 1
#endif /* GUITOUCH_CONF_H */

View File

@ -0,0 +1,90 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_X.C
Purpose : Config / System dependent externals for GUI
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI.h"
#include "GUI_X.h"
/*********************************************************************
*
* Global data
*/
volatile int OS_TimeMS;
/*********************************************************************
*
* Timing:
* GUI_X_GetTime()
* GUI_X_Delay(int)
Some timing dependent routines require a GetTime
and delay function. Default time unit (tick), normally is
1 ms.
*/
int GUI_X_GetTime(void)
{
return OS_TimeMS;
}
void GUI_X_Delay(int ms)
{
int tEnd = OS_TimeMS + ms;
while ((tEnd - OS_TimeMS) > 0)
;
}
/*********************************************************************
*
* GUI_X_Init()
*
* Note:
* GUI_X_Init() is called from GUI_Init is a possibility to init
* some hardware which needs to be up and running before the GUI.
* If not required, leave this routine blank.
*/
void GUI_X_Init(void) {}
/*********************************************************************
*
* GUI_X_ExecIdle
*
* Note:
* Called if WM is in idle state
*/
void GUI_X_ExecIdle(void) {}
/*********************************************************************
*
* Logging: OS dependent
Note:
Logging is used in higher debug levels only. The typical target
build does not use logging and does therefor not require any of
the logging routines below. For a release build without logging
the routines below may be eliminated to save some space.
(If the linker is not function aware and eliminates unreferenced
functions automatically)
*/
void GUI_X_Log(const char *s) { GUI_USE_PARA(s); }
void GUI_X_Warn(const char *s) { GUI_USE_PARA(s); }
void GUI_X_ErrorOut(const char *s) { GUI_USE_PARA(s); }

View File

@ -0,0 +1,40 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* <EFBFBD>C/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 : LCDConf_1375_C8_C320x240.h
Purpose : Sample configuration file
----------------------------------------------------------------------
*/
#ifndef LCDCONF_H
#define LCDCONF_H
#include "board.h" // user defined
/*********************************************************************
*
* General configuration of LCD
*
**********************************************************************
*/
#define LCD_XSIZE (400) /* X-resolution of LCD, Logical coor. */
#define LCD_YSIZE (240) /* Y-resolution of LCD, Logical coor. */
#define LCD_BITSPERPIXEL (8)
#define LCD_CONTROLLER (-1)
#define LCD_INIT_CONTROLLER() lcd_init();
#endif /* LCDCONF_H */

Binary file not shown.

View File

@ -0,0 +1,25 @@
@ECHO OFF
ECHO CCConvertColor.bat: Compiling GUI\ConvertColor
CALL CC LCDP111
CALL CC LCDP222
CALL CC LCDP233
CALL CC LCDP323
CALL CC LCDP332
CALL CC LCDP444_12
CALL CC LCDP444_12_1
CALL CC LCDP444_16
CALL CC LCDP555
CALL CC LCDP556
CALL CC LCDP565
CALL CC LCDP655
CALL CC LCDP8666
CALL CC LCDP8666_1
CALL CC LCDPM233
CALL CC LCDPM323
CALL CC LCDPM332
CALL CC LCDPM444_12
CALL CC LCDPM444_16
CALL CC LCDPM555
CALL CC LCDPM556
CALL CC LCDPM565
CALL CC LCDPM655

View File

@ -0,0 +1,98 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCD111.C
Purpose : Color conversion routines for 111 color mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code, LCD_FIXEDPALETTE == 111, 8 basic colors
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_111
*/
unsigned LCD_Color2Index_111(LCD_COLOR Color) {
int r,g,b;
r = (Color>>(0+7)) &1;
g = (Color>>(8+7)) &1;
b = (Color>>(16+7)) &1;
return r+(g<<1)+(b<<2);
}
/*********************************************************************
*
* LCD_Index2Color_111
*/
LCD_COLOR LCD_Index2Color_111(int Index) {
U16 r,g,b;
r = (((Index>>0)&1)*0xff);
g = (((Index>>1)&1)*0xff);
b = (Index>>2) *0xff;
return r | (g<<8) | ((U32)b<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_111
*/
unsigned LCD_GetIndexMask_111(void) {
return 0x0007;
}
/*********************************************************************
*
* Public code, LCD_FIXEDPALETTE == 111, 8 basic colors, SWAP_RB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M111
*/
unsigned LCD_Color2Index_M111(LCD_COLOR Color) {
int r,g,b;
r = (Color>>(0+7)) &1;
g = (Color>>(8+7)) &1;
b = (Color>>(16+7)) &1;
return b+(g<<1)+(r<<2);
}
/*********************************************************************
*
* LCD_Index2Color_M111
*/
LCD_COLOR LCD_Index2Color_M111(int Index) {
U16 r,g,b;
r = (((Index>>0)&1)*0xff);
g = (((Index>>1)&1)*0xff);
b = (Index>>2) *0xff;
return b | (g<<8) | ((U32)r<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M111
*/
unsigned LCD_GetIndexMask_M111(void) {
return 0x0007;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,98 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCD222.C
Purpose : Color conversion routines for 222 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code, LCD_FIXEDPALETTE == 222, 64 colors
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_222
*/
unsigned LCD_Color2Index_222(LCD_COLOR Color) {
int r,g,b;
r = ((Color&255) +0x2a)/0x55;
g = (((Color>>8)&255) +0x2a)/0x55;
b = (((Color>>16)&255)+0x2a)/0x55;
return r+(g<<2)+(b<<4);
}
/*********************************************************************
*
* LCD_Index2Color_222
*/
LCD_COLOR LCD_Index2Color_222(int Index) {
U16P r,g,b;
r = ((Index>>0)&3)*0x55;
g = ((Index>>2)&3)*0x55;
b = (Index>>4) *0x55;
return (((U32)b)<<16)|(g<<8)|r;
}
/*********************************************************************
*
* LCD_GetIndexMask_222
*/
unsigned LCD_GetIndexMask_222(void) {
return 0x0003f;
}
/*********************************************************************
*
* Public code, LCD_FIXEDPALETTE == 222, 64 colors, SWAP_RB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M222
*/
unsigned LCD_Color2Index_M222(LCD_COLOR Color) {
int r,g,b;
r = ((Color&255) +0x2a)/0x55;
g = (((Color>>8)&255) +0x2a)/0x55;
b = (((Color>>16)&255)+0x2a)/0x55;
return b+(g<<2)+(r<<4);
}
/*********************************************************************
*
* LCD_Index2Color_M222
*/
LCD_COLOR LCD_Index2Color_M222(int Index) {
U16P r,g,b;
r = ((Index>>0)&3)*0x55;
g = ((Index>>2)&3)*0x55;
b = (Index>>4) *0x55;
return (((U32)r)<<16)|(g<<8)|b;
}
/*********************************************************************
*
* LCD_GetIndexMask_M222
*/
unsigned LCD_GetIndexMask_M222(void) {
return 0x003f;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP233.C
Purpose : Color conversion routines for 233 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 233, 256 colors, BBGGGRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_233
*/
unsigned LCD_Color2Index_233(LCD_COLOR Color) {
int r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r * 7 + 127) / 255;
g = (g * 7 + 127) / 255;
b = (b + 42) / 85;
return r + (g << 3) + (b << 6);
}
/*********************************************************************
*
* LCD_Index2Color_233
*/
LCD_COLOR LCD_Index2Color_233(int Index) {
int r, g, b;
r = (Index & 7) * 255 / 7;
g = ((Index >> 3) & 7) * 255 / 7;
b = ((Index >> 6) & 3) * 85;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_233
*/
unsigned LCD_GetIndexMask_233(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP323.C
Purpose : Color conversion routines for 323 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 323, 256 colors, BBBGGRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_323
*/
unsigned LCD_Color2Index_323(LCD_COLOR Color) {
int r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r * 7 + 127) / 255;
g = (g + 42) / 85;
b = (b * 7 + 127) / 255;
return r + (g << 3) + (b << 5);
}
/*********************************************************************
*
* LCD_Index2Color_323
*/
LCD_COLOR LCD_Index2Color_323(int Index) {
int r, g, b;
r = (Index & 7) * 255 / 7;
g = ((Index >> 3) & 3) * 85;
b = ((Index >> 5) & 7) * 255 / 7;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_323
*/
unsigned LCD_GetIndexMask_323(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP332.C
Purpose : Color conversion routines for 332 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 332, 256 colors, BBBGGGRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_332
*/
unsigned LCD_Color2Index_332(LCD_COLOR Color) {
int r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r + 42) / 85;
g = (g * 7 + 127) / 255;
b = (b * 7 + 127) / 255;
return r + (g << 2) + (b << 5);
}
/*********************************************************************
*
* LCD_Index2Color_332
*/
LCD_COLOR LCD_Index2Color_332(int Index) {
unsigned r, g, b;
r = (Index & 3) * 85;
g = ((Index >> 2) & 7) * 255 / 7;
b = ((Index >> 5) & 7) * 255 / 7;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_332
*/
unsigned LCD_GetIndexMask_332(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,70 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP444_12.c
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 444, 4096 colors, 0000BBBBGGGGRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_444_12
*/
unsigned LCD_Color2Index_444_12(LCD_COLOR Color) {
unsigned int r,g,b;
r = Color & 255;
g = (Color >> 8) & 255;
b = (Color >> 16) & 255;
r = (r + 8) / 17;
g = (g + 8) / 17;
b = (b + 8) / 17;
return r + (g << 4) + (b << 8);
}
/*********************************************************************
*
* LCD_Index2Color_444_12
*/
LCD_COLOR LCD_Index2Color_444_12(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
r = Index & 0xf;
g = (Index >> 4) & 0xf;
b = ((unsigned)Index >> 8) & 0xf;
/* Convert the color masks */
r = r * 17;
g = g * 17;
b = b * 17;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_444_12
*/
unsigned LCD_GetIndexMask_444_12(void) {
return 0x0fff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,70 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP444_12_1.c
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 444, 4096 colors, RRRRGGGGBBBB----
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_444_12_1
*/
unsigned LCD_Color2Index_444_12_1(LCD_COLOR Color) {
unsigned int r,g,b;
r = Color & 255;
g = (Color >> 8) & 255;
b = (Color >> 16) & 255;
r = (r + 8) / 17;
g = (g + 8) / 17;
b = (b + 8) / 17;
return (b << 4) + (g << 8) + (r << 12);
}
/*********************************************************************
*
* LCD_Index2Color_444_12_1
*/
LCD_COLOR LCD_Index2Color_444_12_1(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
r = ((unsigned)Index >> 12) & 0xf;
g = ((unsigned)Index >> 8) & 0xf;
b = ((unsigned)Index >> 4) & 0xf;
/* Convert the color masks */
r = r * 17;
g = g * 17;
b = b * 17;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_444_12_1
*/
unsigned LCD_GetIndexMask_444_12_1(void) {
return 0xfff0;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,70 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP444_16.C
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 444, 4096 colors, 0BBBB0GGGG0RRRR0
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_444_16
*/
unsigned LCD_Color2Index_444_16(LCD_COLOR Color) {
unsigned int r,g,b;
r = Color & 255;
g = (Color >> 8) & 255;
b = (Color >> 16) & 255;
r = (r + 8) / 17;
g = (g + 8) / 17;
b = (b + 8) / 17;
return (r << 1) + (g << 6) + (b << 11);
}
/*********************************************************************
*
* LCD_Index2Color_444_16
*/
LCD_COLOR LCD_Index2Color_444_16(int Index) {
unsigned int r,g,b;
/* Separate the color masks */
r = (Index >> 1) & 0xf;
g = (Index >> 6) & 0xf;
b = ((unsigned)Index >> 11) & 0xf;
/* Convert the color masks */
r = r * 17;
g = g * 17;
b = b * 17;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_444_16
*/
unsigned LCD_GetIndexMask_444_16(void) {
return 0x7bde;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP555.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 5
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 555, 32768 colors, 0BBBBBGGGGGRRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_555
*/
unsigned LCD_Color2Index_555(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return r + (g << R_BITS) + (b << (G_BITS + R_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_555
*/
LCD_COLOR LCD_Index2Color_555(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
r = Index & R_MASK;
g = (Index >> R_BITS) & G_MASK;
b = ((unsigned)Index >> (R_BITS + G_BITS)) & B_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_555
*/
unsigned LCD_GetIndexMask_555(void) {
return 0x7fff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP556.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 5
#define R_BITS 6
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 556, 65536 colors, BBBBBGGGGGRRRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_556
*/
unsigned LCD_Color2Index_556(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return r + (g << R_BITS) + (b << (G_BITS + R_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_556
*/
LCD_COLOR LCD_Index2Color_556(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
r = Index & R_MASK;
g = (Index >> R_BITS) & G_MASK;
b = ((unsigned)Index >> (R_BITS + G_BITS)) & B_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_556
*/
unsigned LCD_GetIndexMask_556(void) {
return 0xffff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP565.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 6
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 565, 65536 colors, BBBBBGGGGGGRRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_565
*/
unsigned LCD_Color2Index_565(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return r + (g << R_BITS) + (b << (G_BITS + R_BITS));
}
/*********************************************************************
*
* LCD_GetIndexMask_565
*/
unsigned LCD_GetIndexMask_565(void) {
return 0xffff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP655.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 6
#define G_BITS 5
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 655, 65536 colors, BBBBBBGGGGGRRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_655
*/
unsigned LCD_Color2Index_655(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return r + (g << R_BITS) + (b << (G_BITS + R_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_655
*/
LCD_COLOR LCD_Index2Color_655(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
r = Index & R_MASK;
g = (Index >> R_BITS) & G_MASK;
b = ((unsigned)Index >> (R_BITS + G_BITS)) & B_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_655
*/
unsigned LCD_GetIndexMask_655(void) {
return 0xffff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,104 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCD866.C
Purpose : Color conversion routines for 866 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public data
*
**********************************************************************
*/
#if GUI_SUPPORT_MEMDEV
/*********************************************************************
*
* LCD_Color2Index_8666
*
* Purpose
* API table for this color conversion mode. Only used by memory
* devices in this mode.
*/
const LCD_API_COLOR_CONV LCD_API_ColorConv_8666 = {
LCD_Color2Index_8666,
LCD_Index2Color_8666,
LCD_GetIndexMask_8666
};
#endif
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_8666
*/
unsigned LCD_Color2Index_8666(LCD_COLOR Color) {
int r,g,b,Index;
r = Color&255;
g = (Color>>8)&255;
b = Color>>16;
/* Check if image is a gray scale ... */
if ((r==g) && (g==b)) {
return 120+ (r+8)/17; /* Convert into colors from 120 - 135*/
}
/* Convert into the 6*6*6 colors ... */
r = (r*5+127)/255;
g = (g*5+127)/255;
b = (b*5+127)/255;
Index = r+6*g+36*b;
return (Index<108) ? Index : Index+40;
}
/*********************************************************************
*
* LCD_Index2Color_8666
*/
LCD_COLOR LCD_Index2Color_8666(int Index) {
unsigned int r,g;
U32 b;
/* 16 Gray scale range ? */
if ((Index>=120) && (Index<136)) {
return (U32)0x111111 * (U32)(Index-120);
}
if (Index>=108) {
if (Index<148)
return 0; /* Black for illegal indices */
Index -= 40;
}
r = (Index%6)*(255/5);
g = ((Index/6)%6)*(255/5);
b = (Index/36)*(255/5);
return r+(g<<8)+((U32)b<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_8666
*/
unsigned LCD_GetIndexMask_8666(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP8666_1.C
Purpose : Color conversion routines for 86661 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_8666_1
*/
unsigned LCD_Color2Index_8666_1(LCD_COLOR Color) {
int r, g, b, Index;
r = Color & 255;
g = (Color >> 8) & 255;
b = Color >> 16;
/* Check if image is a gray scale ... */
if ((r == g) && (g == b)) {
return 120 + (r + 8) / 17; /* Convert into colors from 120 - 135 */
}
/* Convert into the 6*6*6 colors ... */
r = (r * 5 + 127) / 255;
g = (g * 5 + 127) / 255;
b = (b * 5 + 127) / 255;
Index = r + 6 * g + 36 * b;
return (Index < 108) ? Index + 12 : Index + 28;
}
/*********************************************************************
*
* LCD_Index2Color_8666_1
*/
LCD_COLOR LCD_Index2Color_8666_1(int Index) {
unsigned int r,g;
U32 b;
/* 16 Gray scale range ? */
if ((Index >= 120) && (Index < 136)) {
return (U32)0x111111 * (U32)(Index - 120);
}
if ((Index < 12) || (Index > 243)) {
return 0; /* Black for illegal indices */
}
if (Index >= 120) {
Index -= 28;
} else {
Index -= 12;
}
r = (Index % 6) * (255 / 5);
g = ((Index / 6) % 6) * (255 / 5);
b = (Index / 36) * (255 / 5);
return r + (g << 8) + ((U32)b << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_8666_1
*/
unsigned LCD_GetIndexMask_8666_1(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM233.C
Purpose : Color conversion routines for -233 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == -233, 256 colors, RRGGGBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M233
*/
unsigned LCD_Color2Index_M233(LCD_COLOR Color) {
unsigned r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r + 42 ) / 85;
g = (g * 7 + 127) / 255;
b = (b * 7 + 127) / 255;
return b + (g << 3) + (r << 6);
}
/*********************************************************************
*
* LCD_Index2Color_M233
*/
LCD_COLOR LCD_Index2Color_M233(int Index) {
unsigned r, g, b;
b = (Index & 7) * 255 / 7;
g = ((Index >> 3) & 7) * 255 / 7;
r = ((Index >> 6) & 3) * 85;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M233
*/
unsigned LCD_GetIndexMask_M233(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM323.C
Purpose : Color conversion routines for -323 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == -323, 256 colors, RRRGGBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M323
*/
unsigned LCD_Color2Index_M323(LCD_COLOR Color) {
unsigned r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r * 7 + 127) / 255;
g = (g + 42) / 85;
b = (b * 7 + 127) / 255;
return b + (g << 3) + (r << 5);
}
/*********************************************************************
*
* LCD_Index2Color_M323
*/
LCD_COLOR LCD_Index2Color_M323(int Index) {
unsigned r, g, b;
b = (Index & 7) * 255 / 7;
g = ((Index >> 3) & 3) * 85;
r = ((Index >> 5) & 7) * 255 / 7;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M323
*/
unsigned LCD_GetIndexMask_M323(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM332.C
Purpose : Color conversion routines for -332 mode
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == -332, 256 colors, RRRGGGBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M332
*/
unsigned LCD_Color2Index_M332(LCD_COLOR Color) {
unsigned r, g, b;
r = Color & 255;
g = (Color >> 8 ) & 255;
b = Color >> 16;
r = (r * 7 + 127) / 255;
g = (g * 7 + 127) / 255;
b = (b + 42) / 85;
return b + (g << 2) + (r << 5);
}
/*********************************************************************
*
* LCD_Index2Color_M332
*/
LCD_COLOR LCD_Index2Color_M332(int Index) {
unsigned r, g, b;
b = (Index & 3) * 85;
g = ((Index >> 2) & 7) * 255 / 7;
r = ((Index >> 5) & 7) * 255 / 7;
return r + (g << 8) + (((U32)b) << 16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M332
*/
unsigned LCD_GetIndexMask_M332(void) {
return 0xff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,70 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM444_12.c
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 444, 4096 colors, RRRRGGGGBBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M444_12
*/
unsigned LCD_Color2Index_M444_12(LCD_COLOR Color) {
unsigned int r,g,b;
r = Color & 255;
g = (Color >> 8) & 255;
b = (Color >> 16) & 255;
r = (r + 8) / 17;
g = (g + 8) / 17;
b = (b + 8) / 17;
return b + (g << 4) + (r << 8);
}
/*********************************************************************
*
* LCD_Index2Color_M444_12
*/
LCD_COLOR LCD_Index2Color_M444_12(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
b = Index & 0xf;
g = (Index >> 4) & 0xf;
r = ((unsigned)Index >> 8) & 0xf;
/* Convert the color masks */
r = r * 17;
g = g * 17;
b = b * 17;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M444_12
*/
unsigned LCD_GetIndexMask_M444_12(void) {
return 0x0fff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,70 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM444_16.C
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 444, 4096 colors, 0RRRR0GGGG0BBBB0
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M444_16
*/
unsigned LCD_Color2Index_M444_16(LCD_COLOR Color) {
unsigned int r,g,b;
r = Color & 255;
g = (Color >> 8) & 255;
b = (Color >> 16) & 255;
r = (r + 8) / 17;
g = (g + 8) / 17;
b = (b + 8) / 17;
return (b << 1) + (g << 6) + (r << 11);
}
/*********************************************************************
*
* LCD_Index2Color_M444_16
*/
LCD_COLOR LCD_Index2Color_M444_16(int Index) {
unsigned int r,g,b;
/* Separate the color masks */
b = (Index >> 1) & 0xf;
g = (Index >> 6) & 0xf;
r = ((unsigned)Index >> 11) & 0xf;
/* Convert the color masks */
r = r * 17;
g = g * 17;
b = b * 17;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M444_16
*/
unsigned LCD_GetIndexMask_M444_16(void) {
return 0x7bde;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDM555.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 5
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 555, 32768 colors, 0RRRRRGGGGGBBBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M555
*/
unsigned LCD_Color2Index_M555(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return b + (g << B_BITS) + (r << (G_BITS + B_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_M555
*/
LCD_COLOR LCD_Index2Color_M555(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
b = Index & B_MASK;
g = (Index >> B_BITS) & G_MASK;
r = ((unsigned)Index >> (B_BITS + G_BITS)) & R_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M555
*/
unsigned LCD_GetIndexMask_M555(void) {
return 0x7fff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDM556.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 5
#define R_BITS 6
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 556, 65536 colors, RRRRRRGGGGGBBBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M556
*/
unsigned LCD_Color2Index_M556(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return b + (g << B_BITS) + (r << (G_BITS + B_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_M556
*/
LCD_COLOR LCD_Index2Color_M556(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
b = Index & B_MASK;
g = (Index >> B_BITS) & G_MASK;
r = ((unsigned)Index >> (B_BITS + G_BITS)) & R_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M556
*/
unsigned LCD_GetIndexMask_M556(void) {
return 0xffff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDM565.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 6
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 565, 65536 colors, RRRRRGGGGGGBBBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M565
*/
unsigned LCD_Color2Index_M565(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return b + (g << B_BITS) + (r << (G_BITS + B_BITS));
}
/*********************************************************************
*
* LCD_GetIndexMask_M565
*/
unsigned LCD_GetIndexMask_M565(void) {
return 0xffff;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,82 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDPM655.C
Purpose : Color conversion routines
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define B_BITS 6
#define G_BITS 5
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 655, 65536 colors, RRRRRGGGGGBBBBBB
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_M655
*/
unsigned LCD_Color2Index_M655(LCD_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return b + (g << B_BITS) + (r << (G_BITS + B_BITS));
}
/*********************************************************************
*
* LCD_Index2Color_M655
*/
LCD_COLOR LCD_Index2Color_M655(int Index) {
unsigned int r,g,b;
/* Seperate the color masks */
b = Index & B_MASK;
g = (Index >> B_BITS) & G_MASK;
r = ((unsigned)Index >> (B_BITS + G_BITS)) & R_MASK;
/* Convert the color masks */
r = r * 255 / R_MASK;
g = g * 255 / G_MASK;
b = b * 255 / B_MASK;
return r + (g<<8) + (((U32)b)<<16);
}
/*********************************************************************
*
* LCD_GetIndexMask_M655
*/
unsigned LCD_GetIndexMask_M655(void) {
return 0xffff;
}
/*************************** End of file ****************************/

Binary file not shown.

View File

@ -0,0 +1,5 @@
@ECHO OFF
ECHO CCConvertMono.BAT: Compiling GUI\ConvertMono
CALL CC LCDP0
CALL CC LCDP2
CALL CC LCDP4

View File

@ -0,0 +1,76 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCDP0.C
Purpose : Color conversion routines for LCD-drivers
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Private.h" /* inter modul definitions */
#include "GUI.h"
/*********************************************************************
*
* Public code, 1/2/4/8 bpp color, LUT
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_0
*/
unsigned LCD_Color2Index_0(LCD_COLOR Color, const LCD_PHYSPALETTE* pPhysPal) {
int i;
int NumEntries = pPhysPal->NumEntries;
int BestIndex = 0;
U32 BestDiff = 0xffffff; /* Initialize to worst match */
const LCD_COLOR* pPalEntry;
/* Try to find perfect match */
i=0; pPalEntry = &pPhysPal->pPalEntries[0];
do {
if (Color==*(pPalEntry+i))
return i;
} while (++i<NumEntries);
/* Find best match */
i=0; pPalEntry = &pPhysPal->pPalEntries[0];
do {
U32 Diff = GUI_CalcColorDist (Color, *(pPalEntry+i));
if (Diff < BestDiff) {
BestDiff = Diff;
BestIndex = i;
}
} while (++i<NumEntries);
return BestIndex;
}
/*********************************************************************
*
* LCD_Index2Color_0
*/
LCD_COLOR LCD_Index2Color_0(int Index, const LCD_PHYSPALETTE* pPhysPal) {
if ((unsigned)Index >= (unsigned) pPhysPal->NumEntries) {
return 0; /* Illegal index */
}
return *(pPhysPal->pPalEntries+Index);
}
/*********************************************************************
*
* LCD_GetIndexMask_0
*/
unsigned LCD_GetIndexMask_0(void) {
return ((1 << LCD_BITSPERPIXEL) - 1);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,81 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCD2.C
Purpose : Color conversion routines for 4 bpp gray LCDs
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public data
*
**********************************************************************
*/
#if GUI_SUPPORT_MEMDEV
/*********************************************************************
*
* LCD_Color2Index_2
*
* Purpose
* API table for this color conversion mode. Only used by memory
* devices in this mode.
*/
const LCD_API_COLOR_CONV LCD_API_ColorConv_2 = {
LCD_Color2Index_2,
LCD_Index2Color_2,
LCD_GetIndexMask_2
};
#endif
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_2
*/
unsigned LCD_Color2Index_2(LCD_COLOR Color) {
int r,g,b;
r = Color &255;
g = (Color>>8) &255;
b = Color>>16;
return (r+g+b+127) /255;
}
/*********************************************************************
*
* LCD_Index2Color_2
*/
LCD_COLOR LCD_Index2Color_2(int Index) {
return ((U32)Index)*0x555555;
}
/*********************************************************************
*
* LCD_GetIndexMask_2
*/
unsigned LCD_GetIndexMask_2(void) {
return 0x03;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,81 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : LCD4.C
Purpose : Color conversion routines for 4 bpp gray LCDs
---------------------------END-OF-HEADER------------------------------
*/
#include "LCD_Protected.h" /* inter modul definitions */
/*********************************************************************
*
* Public data
*
**********************************************************************
*/
#if GUI_SUPPORT_MEMDEV
/*********************************************************************
*
* LCD_Color2Index_4
*
* Purpose
* API table for this color conversion mode. Only used by memory
* devices in this mode.
*/
const LCD_API_COLOR_CONV LCD_API_ColorConv_4 = {
LCD_Color2Index_4,
LCD_Index2Color_4,
LCD_GetIndexMask_4
};
#endif
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_4
*/
unsigned LCD_Color2Index_4(LCD_COLOR Color) {
int r,g,b;
r = (Color>>(0+4)) &15;
g = (Color>>(8+4)) &15;
b = (Color>>(16+4)) &15;
return (r+g+b+1) /3;
}
/*********************************************************************
*
* LCD_Index2Color_4
*/
LCD_COLOR LCD_Index2Color_4(int Index) {
return ((U32)Index)*0x111111;
}
/*********************************************************************
*
* LCD_GetIndexMask_4
*/
unsigned LCD_GetIndexMask_4(void) {
return 0x0f;
}
/*************************** End of file ****************************/

Binary file not shown.

View File

@ -0,0 +1,199 @@
@ECHO OFF
ECHO CCGUICore.BAT: Compiling GUI\Core
CALL CC GUI2DLib
CALL CC GUI__AddSpaceHex
CALL CC GUI__CalcTextRect
CALL CC GUI__DivideRound
CALL CC GUI__DivideRound32
CALL CC GUI__GetFontSizeY
CALL CC GUI__GetNumChars
CALL CC GUI__HandleEOLine
CALL CC GUI__IntersectRect
CALL CC GUI__IntersectRects
CALL CC GUI__memset
CALL CC GUI__memset16
CALL CC GUI__Read
CALL CC GUI__ReduceRect
CALL CC GUI__SetText
CALL CC GUI__strcmp
CALL CC GUI__strlen
CALL CC GUI__Wrap
CALL CC GUI_AddBin
CALL CC GUI_AddDec
CALL CC GUI_AddDecMin
CALL CC GUI_AddDecShift
CALL CC GUI_AddHex
CALL CC GUI_ALLOC_AllocInit
CALL CC GUI_ALLOC_AllocZero
CALL CC GUI_BMP
CALL CC GUI_BMP_Serialize
CALL CC GUI_CalcColorDist
CALL CC GUI_ClearRectEx
CALL CC GUI_Color2VisColor
CALL CC GUI_CursorArrowL
CALL CC GUI_CursorArrowLI
CALL CC GUI_CursorArrowLPx
CALL CC GUI_CursorArrowM
CALL CC GUI_CursorArrowMI
CALL CC GUI_CursorArrowMPx
CALL CC GUI_CursorArrowS
CALL CC GUI_CursorArrowSI
CALL CC GUI_CursorArrowSPx
CALL CC GUI_CursorCrossL
CALL CC GUI_CursorCrossLI
CALL CC GUI_CursorCrossLPx
CALL CC GUI_CursorCrossM
CALL CC GUI_CursorCrossMI
CALL CC GUI_CursorCrossMPx
CALL CC GUI_CursorCrossS
CALL CC GUI_CursorCrossSI
CALL CC GUI_CursorCrossSPx
CALL CC GUI_CursorHeaderM
CALL CC GUI_CursorHeaderMI
CALL CC GUI_CursorHeaderMPx
CALL CC GUI_CursorPal
CALL CC GUI_CursorPalI
CALL CC GUI_DispBin
CALL CC GUI_DispCEOL
CALL CC GUI_DispChar
CALL CC GUI_DispChars
CALL CC GUI_DispHex
CALL CC GUI_DispString
CALL CC GUI_DispStringAt
CALL CC GUI_DispStringAtCEOL
CALL CC GUI_DispStringHCenter
CALL CC GUI_DispStringInRect
CALL CC GUI_DispStringInRectEx
CALL CC GUI_DispStringLen
CALL CC GUI_DrawBitmap
CALL CC GUI_DrawBitmapEx
CALL CC GUI_DrawBitmapExp
CALL CC GUI_DrawBitmapMag
CALL CC GUI_DrawFocusRect
CALL CC GUI_DrawGraph
CALL CC GUI_DrawHLine
CALL CC GUI_DrawPie
CALL CC GUI_DrawPixel
CALL CC GUI_DrawPolyline
CALL CC GUI_DrawRectEx
CALL CC GUI_DrawVLine
CALL CC GUI_ErrorOut
CALL CC GUI_Exec
CALL CC GUI_FillPolygon
CALL CC GUI_FillRect
CALL CC GUI_FillRectEx
CALL CC GUI_GetBitmapPixelColor
CALL CC GUI_GetBitmapPixelIndex
CALL CC GUI_GetClientRect
CALL CC GUI_GetColor
CALL CC GUI_GetDispPos
CALL CC GUI_GetFont
CALL CC GUI_GetFontInfo
CALL CC GUI_GetFontSizeY
CALL CC GUI_GetLineStyle
CALL CC GUI_GetStringDistX
CALL CC GUI_GetTextAlign
CALL CC GUI_GetTextExtend
CALL CC GUI_GetTextMode
CALL CC GUI_GetVersionString
CALL CC GUI_GetYSizeOfFont
CALL CC GUI_Goto
CALL CC GUI_InvertRect
CALL CC GUI_IsInFont
CALL CC GUI_Log
CALL CC GUI_MergeRect
CALL CC GUI_MOUSE
CALL CC GUI_MOUSE_DriverPS2
CALL CC GUI_MoveRect
CALL CC GUI_OnKey
CALL CC GUI_Pen
CALL CC GUI_PID
CALL CC GUI_RectsIntersect
CALL CC GUI_SaveContext
CALL CC GUI_SelectLayer
CALL CC GUI_SelectLCD
CALL CC GUI_SetColor
CALL CC GUI_SetColorIndex
CALL CC GUI_SetDecChar
CALL CC GUI_SetDefault
CALL CC GUI_SetDrawMode
CALL CC GUI_SetFont
CALL CC GUI_SetLBorder
CALL CC GUI_SetLineStyle
CALL CC GUI_SetLUTColor
CALL CC GUI_SetLUTColorEx
CALL CC GUI_SetLUTEntry
CALL CC GUI_SetOrg
CALL CC GUI_SetPixelIndex
CALL CC GUI_SetTextAlign
CALL CC GUI_SetTextMode
CALL CC GUI_SetTextStyle
CALL CC GUI_SIF
CALL CC GUI_SIF_Prop
CALL CC GUI_TOUCH
CALL CC GUI_TOUCH_DriverAnalog
CALL CC GUI_TOUCH_StoreState
CALL CC GUI_TOUCH_StoreUnstable
CALL CC GUI_UC
CALL CC GUI_UC_DispString
CALL CC GUI_UC_EncodeNone
CALL CC GUI_UC_EncodeUTF8
CALL CC GUI_WaitKey
CALL CC GUI_WaitEvent
CALL CC GUI_Warn
CALL CC GUIAlloc
CALL CC GUIArc
CALL CC GUIChar
CALL CC GUICharLine
CALL CC GUICharM
CALL CC GUICharP
CALL CC GUICirc
CALL CC GUIColor2Index
CALL CC GUICore
CALL CC GUICurs
CALL CC GUIEncJS
CALL CC GUIIndex2Color
CALL CC GUIPolyE
CALL CC GUIPolyM
CALL CC GUIPolyR
CALL CC GUIRealloc
CALL CC GUIStream
CALL CC GUITask
CALL CC GUITime
CALL CC GUITimer
CALL CC GUIUC0
CALL CC GUIVal
CALL CC GUIValf
CALL CC LCD
CALL CC LCD_API
CALL CC LCD_DrawBitmap_565
CALL CC LCD_DrawBitmap_M565
CALL CC LCD_DrawVLine
CALL CC LCD_GetColorIndex
CALL CC LCD_GetEx
CALL CC LCD_GetNumDisplays
CALL CC LCD_GetPixelColor
CALL CC LCD_Index2ColorEx
CALL CC LCD_L0_Generic
CALL CC LCD_MixColors256
CALL CC LCD_Mirror
CALL CC LCD_Rotate180
CALL CC LCD_RotateCW
CALL CC LCD_RotateCCW
CALL CC LCD_SelectLCD
CALL CC LCD_SetClipRectEx
CALL CC LCD_SetAPI
CALL CC LCD_UpdateColorIndices
CALL CC LCDAA
CALL CC LCDColor
CALL CC LCDGetP
CALL CC LCDInfo
CALL CC LCDInfo0
CALL CC LCDInfo1
CALL CC LCDL0Delta
CALL CC LCDL0Mag
CALL CC LCDP1
CALL CC LCDP565_Index2Color
CALL CC LCDPM565_Index2Color
CALL CC LCDRLE4
CALL CC LCDRLE8

1419
User/lib/lcd/gui/Core/GUI.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,689 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI2DLib.C
Purpose : Main part of the 2D graphics library
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* defines
*
**********************************************************************
*/
#define ABS(v) ((v>0) ? v : -v)
/*********************************************************************
*
* static code, helper functions
*
**********************************************************************
*/
/*********************************************************************
*
* _SwapInt
*/
static void _SwapInt(int* pa, int* pb) {
int t;
t = *pa;
*pa = *pb;
*pb = t;
}
/*********************************************************************
*
* Abs
*/
static int Abs(int v) {
return ABS(v);
}
/*********************************************************************
*
* trigonometric functions
*
* NOTE:
* All trigonometric functions are for internal usage only and
* use the following conventions:
*
* Angles: 4096 <==> 360°
*
**********************************************************************
*/
#if GUI_45DEG != 512
#error Wrong define for this library !
#endif
/*********************************************************************
*
* sin / cos (internal)
*
* Angle : 90/1024°
* Data : 1/1024
*/
static const U16 aSin[] = {
0, /* 1/16 *90° */
100, /* 1/16 *90° */
200, /* 2/16 *90° */
297, /* 3/16 *90° */
392, /* 4/16 *90° */
483, /* 5/16 *90° */
569, /* 6/16 *90° */
650, /* 7/16 *90° */
724, /* 8/16 *90° */
792, /* 9/16 *90° */
851, /* 10/16 *90° */
903, /* 11/16 *90° */
946, /* 12/16 *90° */
980, /* 13/16 *90° */
1004, /* 14/16 *90° */
1019, /* 15/16 *90° */
1024 /* 16/16 *90° */
};
/*********************************************************************
*
* GUI_sin
*/
int GUI_sin(int angle) {
char IsNeg =0;
int i;
U16 Faktor;
U32 t;
angle &= ((1<<12)-1); /* reduce to 0-360 degrees */
if (angle> 2* GUI_90DEG) {
angle -= 2* GUI_90DEG;
IsNeg =1;
}
if (angle> GUI_90DEG) { /* between 90-180 */
angle = 2*GUI_90DEG-angle; /* use sine symetry */
}
/* Now angle is reduced to 0° <= <= 90° */
#if 0
angle >>=2; /* make sure we do not exceed 16 bits in calculations */
i = angle>>4;
Faktor = (1<<4)-(angle&((1<<4)-1));
r = aSin[i]*Faktor;
if (Faktor !=(1<<4)) {
r += aSin[i+1]*((1<<4)-Faktor);
}
r = (r+(1<<3)) >>4; /* divide,incl. rounding */
#else
i = angle>>6;
{
Faktor = (U16)((1<<6)-(angle&((1<<6)-1)));
t = aSin[i]*(U32)Faktor;
if (Faktor !=(1<<6)) {
t += aSin[i+1]*((1<<6)-Faktor);
}
}
t = (t+(1<<5)) >>6; /* divide,incl. rounding */
#endif
return (IsNeg) ? 0-t : t;
}
/*********************************************************************
*
* GUI_cos
*/
int GUI_cos(int angle) {
return GUI_sin(angle+GUI_90DEG);
}
/*********************************************************************
*
* atan() (internal)
*
* Angle : 360/4096°
*/
const I16 aTan[] = {
0, /* atan(0/16) */
41, /* atan(1/16) */
81, /* atan(2/16) */
121, /* atan(3/16) */
160, /* atan(4/16) */
197, /* atan(5/16) */
234, /* atan(6/16) */
269, /* atan(7/16) */
302, /* atan(8/16) */
334, /* atan(9/16) */
364, /* atan(10/16) */
393, /* atan(11/16) */
419, /* atan(12/16) */
445, /* atan(13/16) */
469, /* atan(14/16) */
491, /* atan(15/16) */
512 /* atan(1) = 45° = 512/1024 */
};
/*********************************************************************
*
* _atan0_45
*
* Calculate arctan of q, where q is any where between 0 and 1024
*/
static int _atan0_45(int q) {
int r;
int i, Faktor;
/* Now angle is reduced to 0° <= <= 90° ==> 0 <= <= 256*/
q >>=2; /* make sure we do not exceed 16 bits in calculations */
i = q>>4;
Faktor = (1<<4)-(q&((1<<4)-1));
r = aTan[i]*Faktor;
if (Faktor !=(1<<4)) {
r += aTan[i+1]*((1<<4)-Faktor);
}
r = (r+(1<<3))/(1<<4); /* divide incl. rounding */
return r;
}
/*********************************************************************
*
* _atan2
*/
static int _atan2(I32 x, I32 y) {
U8 q =0;
int angle;
/* first make sure we are in angle between 0 and 45° */
if (x<0) {
q=1;
x=-x;
}
if (y<0) {
q |= (1<<1);
y=-y;
}
if (y>x) {
int t = y;
y=x;
x=t;
q |= (1<<2);
}
y <<=10;
y += (x/2);
y /= x;
angle = _atan0_45(y);
if (q&(1<<2)) { /* y/x reverse ? */
angle = GUI_90DEG-angle;
}
if (q&1) { /* xreverse ? */
angle = GUI_180DEG-angle;
}
if (q&(1<<1)) { /* y-reverse ? */
angle = GUI_360DEG-angle;
}
return angle;
}
/*********************************************************************
*
* _SetLineColor
*/
static int _SetLineColor(int i) {
switch (GUI_Context.LineStyle) {
case GUI_LS_DASH:
i = (i+6)%16;
return (i<12);
case GUI_LS_DOT:
i %= 4;
return (i<2);
case GUI_LS_DASHDOT:
i %= 20;
if (i<12)
return 1;
else if ((i>=16) && (i<18))
return 1;
return 0;
case GUI_LS_DASHDOTDOT:
i %= 24;
if (i<12)
return 1;
else if ((i>=16) && (i<18))
return 1;
else if ((i>=20) && (i<22))
return 1;
else
return 0;
}
return 0;
}
/*********************************************************************
*
* _atan2
*/
#if 0
int _atan2(int xDiff, int yDiff) {
double atanf = atan2(xDiff, yDiff);
return (int)(atanf*(16384.0/6.2831852));
}
#endif
/*********************************************************************
*
* _CalcOrto
*/
static void _CalcOrto(int xDiff, int yDiff, I32 r, int*px, int*py) {
I32 x,y;
/*
int Angle = _atan2(xDiff, yDiff);
*/
#if 0
double Angle = atan2(xDiff, yDiff);
x = (int)(-r*cos(Angle));
y = (int)(r*sin(Angle));
#else
int Angle = _atan2(xDiff, yDiff);
Angle+= GUI_90DEG;
x = ( r*(I32)GUI_cos(Angle));
y = ( r*(I32)GUI_sin(Angle));
#endif
x = (x<0) ? -((-x+512)>>10) : ((x+512)>>10);
y = (y<0) ? -((-y+512)>>10) : ((y+512)>>10);
*px = x;
*py = y;
}
/*********************************************************************
*
* DrawLine, public
*
* Draw end points of the line.
* In most cases, this is a circle.
*
**********************************************************************
*/
/*********************************************************************
*
* _DrawLineEnd
*/
static void _DrawLineEnd(int x0, int y0) {
switch (GUI_Context.PenShape) {
case GUI_PS_ROUND:
GL_DrawPoint(x0,y0);
break;
case GUI_PS_FLAT:
break;
}
}
/*********************************************************************
*
* DrawLine, public
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawLine
*/
void GL_DrawLine(int x0, int y0, int x1, int y1) {
if (GUI_Context.PenSize ==1) {
GL_DrawLine1(x0,y0,x1,y1);
} else {
int xdiff, ydiff;
xdiff = x0-x1;
ydiff = y0-y1;
if (xdiff | ydiff) {
GUI_POINT Poly[4];
int xOff, yOff;
int xOffP, yOffP, xOffM, yOffM;
_CalcOrto(x0-x1,y0-y1, (I32)(GUI_Context.PenSize-1), &xOff, &yOff);
/* Do rounding for offsets */
if (xOff >0) {
xOffP = (xOff+1)/2;
xOffM = xOff /2;
} else {
xOffP = xOff/2;
xOffM = (xOff-1) /2;
}
if (yOff >0) {
yOffP = (yOff+1)/2;
yOffM = yOff /2;
} else {
yOffP = yOff/2;
yOffM = (yOff-1) /2;
}
Poly[0].x = x0+xOffP;
Poly[0].y = y0+yOffP;
Poly[1].x = x0-xOffM;
Poly[1].y = y0-yOffM;
Poly[2].x = x1-xOffM;
Poly[2].y = y1-yOffM;
Poly[3].x = x1+xOffP;
Poly[3].y = y1+yOffP;
GL_FillPolygon(&Poly[0], 4, 0,0);
_DrawLineEnd(x0,y0);
_DrawLineEnd(x1,y1);
}
}
}
/*********************************************************************
*
* GUI_DrawLine
*/
void GUI_DrawLine(int x0, int y0, int x1, int y1) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
WM_ADDORG(x1,y1);
WM_ITERATE_START(NULL); {
#endif
GL_DrawLine (x0, y0, x1, y1);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_DrawPolygon
*/
void GL_DrawPolygon(const GUI_POINT*pPoints, int NumPoints, int x0, int y0) {
const GUI_POINT* pPoint = pPoints;
GL_MoveTo(pPoint->x+x0, pPoint->y+y0);
while (--NumPoints >0) {
pPoint++;
GL_DrawLineTo(pPoint->x+x0, pPoint->y+y0);
}
/* Now draw closing line unless it has already been closed */
if ( (pPoint->x != pPoints->x)
||(pPoint->y != pPoints->y))
{
GL_DrawLineTo(pPoints->x+x0, pPoints->y+y0);
}
}
/*********************************************************************
*
* GUI_DrawPolygon
*/
void GUI_DrawPolygon(const GUI_POINT* pPoints, int NumPoints, int x0, int y0) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
WM_ITERATE_START(NULL); {
#endif
GL_DrawPolygon (pPoints, NumPoints, x0, y0);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* Draw Line to group
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawLineRelNM
*/
static void GL_DrawLineRelNM(int dx, int dy) {
GL_DrawLine (GUI_Context.DrawPosX, GUI_Context.DrawPosY,
GUI_Context.DrawPosX+dx, GUI_Context.DrawPosY+dy);
}
/*********************************************************************
*
* GUI_DrawLineRel
*/
void GUI_DrawLineRel(int dx, int dy) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ITERATE_START(NULL); {
#endif
GL_DrawLineRelNM(dx,dy);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_MoveRel(dx,dy);
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_DrawLineTo
*/
void GL_DrawLineTo(int x, int y) {
GL_DrawLine (GUI_Context.DrawPosX, GUI_Context.DrawPosY, x, y);
GUI_Context.DrawPosX = x;
GUI_Context.DrawPosY = y;
}
/*********************************************************************
*
* GL_DrawLineToNM
*/
static void GL_DrawLineToNM(int x, int y) {
GL_DrawLine (GUI_Context.DrawPosX, GUI_Context.DrawPosY, x, y);
}
/*********************************************************************
*
* GUI_DrawLineTo
*/
void GUI_DrawLineTo(int x, int y) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x,y);
WM_ITERATE_START(NULL); {
#endif
GL_DrawLineToNM(x,y);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GL_MoveTo(x,y);
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_MoveRel
*/
void GUI_MoveRel(int dx, int dy) { /*tbd: GL_LinePos. */
GUI_LOCK();
GUI_Context.DrawPosX += dx;
GUI_Context.DrawPosY += dy;
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_MoveTo
*/
void GL_MoveTo(int x, int y) {
GUI_Context.DrawPosX = x;
GUI_Context.DrawPosY = y;
}
/*********************************************************************
*
* GUI_MoveTo
*/
void GUI_MoveTo(int x, int y) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x,y);
#endif
GL_MoveTo(x,y);
GUI_UNLOCK();
}
/*********************************************************************
*
* Rectangle filling / inverting
*
**********************************************************************
*/
/*********************************************************************
*
* _DrawRect
*/
static void _DrawRect(int x0, int y0, int x1, int y1) {
LCD_DrawHLine(x0, y0, x1);
LCD_DrawHLine(x0, y1, x1);
LCD_DrawVLine(x0, y0 + 1, y1 - 1);
LCD_DrawVLine(x1, y0 + 1, y1 - 1);
}
/*********************************************************************
*
* GUI_DrawRect
*/
void GUI_DrawRect(int x0, int y0, int x1, int y1) {
#if (GUI_WINSUPPORT)
int Off;
GUI_RECT r;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
Off = GUI_Context.PenSize -1;
WM_ADDORG(x0,y0);
WM_ADDORG(x1,y1);
r.x0 = x0 - Off;
r.x1 = x1 + Off;
r.y0 = y0 - Off;
r.y1 = y1 + Off;
WM_ITERATE_START(&r); {
#endif
_DrawRect(x0, y0, x1, y1);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* DrawLine, internal, 1 pixel
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawLine1
*/
void GL_DrawLine1(int x0, int y0, int x1, int y1) {
int xdiff = x1-x0;
int ydiff = y1-y0;
int xdiffby2;
int i;
char Swapped =0;
/* check if no line */
if (!(xdiff|ydiff)) {
GL_DrawPoint(x0,y0);
return;
}
#if 0
/* check if horizontal line */
if (!xdiff) {
GL_DrawVLine(x0,y0,y1);
return;
}
/* check if vertical line */
if (!ydiff) {
GL_DrawHLine(y0,x0,x1);
return;
}
#endif
/* check if we swap x and y for calculation */
if (Abs(xdiff) < Abs(ydiff)) {
_SwapInt(&xdiff,&ydiff);
_SwapInt(&x0,&y0);
_SwapInt(&x1,&y1);
Swapped =1;
}
/* make sure line direction is positive */
if (xdiff!=Abs(xdiff)) {
xdiff = -xdiff;
ydiff = -ydiff;
_SwapInt(&x0,&x1);
_SwapInt(&y0,&y1);
}
xdiffby2 = xdiff/2;
if (ydiff<0)
xdiffby2 = -xdiffby2;
/* Draw pixel by pixel solid*/
if (GUI_Context.LineStyle == GUI_LS_SOLID) {
for (i=0; i<=xdiff; i++) {
I32 l = ((I32)ydiff)*i+xdiffby2;
int y = (ABS(l)<32767) ? (y0 + ((int)l)/xdiff) : (y0 + l/xdiff);
if (!Swapped)
LCD_HL_DrawPixel(x0+i, y);
else
LCD_HL_DrawPixel(y, x0+i);
}
/* Draw pixel by pixel with fill style */
} else {
for (i=0; i<=xdiff; i++) {
long l = ((long)ydiff)*i+xdiffby2;
int y = (ABS(l)<32767) ? (y0 + ((int)l)/xdiff) : (y0 + l/xdiff);
if (!_SetLineColor(i)) {
if (!Swapped)
LCD_HL_DrawPixel(x0+i, y);
else
LCD_HL_DrawPixel(y, x0+i);
}
}
}
}
/*********************************************************************
*
* Draw point
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawPoint
*/
void GL_DrawPoint(int x, int y) {
if (GUI_Context.PenSize == 1) {
LCD_HL_DrawPixel(x, y);
} else {
GL_FillCircle(x, y, (GUI_Context.PenSize - 1) / 2);
}
}
/*********************************************************************
*
* GUI_DrawPoint
*/
void GUI_DrawPoint(int x, int y) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x, y);
WM_ITERATE_START(NULL); {
#endif
GL_DrawPoint(x, y);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,548 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIAlloc.C
Purpose : Dynamic memory management
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <string.h> /* for memcpy, memset */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Internal memory management
*
**********************************************************************
*/
#ifndef GUI_ALLOC_ALLOC
#if GUI_ALLOC_SIZE==0
#error GUI_ALLOC_SIZE needs to be > 0 when using this module
#endif
/*********************************************************************
*
* Defines, config defaults
*
**********************************************************************
*/
/* Permit automatic defragmentation when necessary */
#ifndef GUI_ALLOC_AUTDEFRAG
#define GUI_ALLOC_AUTDEFRAG 1
#endif
#ifndef GUI_BLOCK_ALIGN /* 2 means 4 bytes, 1 means 2 bytes */
#define GUI_BLOCK_ALIGN 2 /* 1 can be used on 16-bit CPUs and CPUs */
#endif /* which do not require aligned 32-bit */
/* values (such as x86) */
#ifndef GUI_MAXBLOCKS
#define GUI_MAXBLOCKS (2 + GUI_ALLOC_SIZE / 32)
#endif
#ifndef GUI_ALLOC_LOCATION
#define GUI_ALLOC_LOCATION
#endif
#ifndef GUI_MEM_ALLOC /* Allows us in some systems to place the GUI memory */
#define GUI_MEM_ALLOC /* in a different memory space ... eg "__far" */
#endif
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define Min(v0,v1) ((v0>v1) ? v1 : v0)
#define Max(v0,v1) ((v0>v1) ? v0 : v1)
#define ASSIGN_IF_LESS(v0,v1) if (v1<v0) v0=v1
#define HMEM2PTR(hMem) (void*)&GUI_Heap.abHeap[aBlock[hMem].Off]
#if GUI_MAXBLOCKS >= 256
#define HANDLE U16
#else
#define HANDLE U8
#endif
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef union {
int aintHeap[GUI_ALLOC_SIZE / 4]; /* required for proper alignement */
U8 abHeap[GUI_ALLOC_SIZE];
} GUI_HEAP;
typedef struct {
GUI_ALLOC_DATATYPE Off; /* Offset of memory area */
GUI_ALLOC_DATATYPE Size; /* usable size of allocated block */
HANDLE Next; /* next handle in linked list */
HANDLE Prev;
} tBlock;
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
GUI_MEM_ALLOC GUI_HEAP GUI_Heap GUI_ALLOC_LOCATION; /* Public for debugging only */
static tBlock aBlock[GUI_MAXBLOCKS];
struct {
int NumUsedBlocks, NumFreeBlocks, NumFreeBlocksMin; /* For statistical purposes only */
GUI_ALLOC_DATATYPE NumUsedBytes, NumFreeBytes, NumFreeBytesMin;
} GUI_ALLOC;
static char IsInitialized =0;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _Size2LegalSize
*
* Return value:
* Legal allocation size
*/
static GUI_ALLOC_DATATYPE _Size2LegalSize(GUI_ALLOC_DATATYPE size) {
return (size + ((1 << GUI_BLOCK_ALIGN) - 1)) & ~((1 << GUI_BLOCK_ALIGN) - 1);
}
/*********************************************************************
*
* _GetSize
*/
static GUI_ALLOC_DATATYPE _GetSize(GUI_HMEM hMem) {
return aBlock[hMem].Size;
}
/*********************************************************************
*
* _Free
*/
static void _Free(GUI_HMEM hMem) {
GUI_ALLOC_DATATYPE Size;
GUI_DEBUG_LOG1("\nGUI_ALLOC_Free(%d)", hMem);
/* Do some error checking ... */
#if GUI_DEBUG_LEVEL>0
/* Block not allocated ? */
if (aBlock[hMem].Size == 0) {
GUI_DEBUG_ERROROUT("GUI_ALLOC_Free(): Invalid hMem");
return;
}
#endif
Size = aBlock[hMem].Size;
#ifdef WIN32
GUI_MEMSET(&GUI_Heap.abHeap[aBlock[hMem].Off], 0xcc, Size);
#endif
GUI_ALLOC.NumFreeBytes += Size;
GUI_ALLOC.NumUsedBytes -= Size;
aBlock[hMem].Size = 0;
{
int Next = aBlock[hMem].Next;
int Prev = aBlock[hMem].Prev;
aBlock[Prev].Next = Next;
if (Next) {
aBlock[Next].Prev = Prev;
}
}
GUI_ALLOC.NumFreeBlocks++;
GUI_ALLOC.NumUsedBlocks--;
}
/*********************************************************************
*
* _FindFreeHandle
*
* Return value:
* Free handle
*/
static GUI_HMEM _FindFreeHandle(void) {
int i;
for (i=1; i< GUI_MAXBLOCKS; i++) {
if (aBlock[i].Size ==0)
return i;
}
GUI_DEBUG_ERROROUT1("Insufficient memory handles configured (GUI_MAXBLOCKS == %d (See GUIConf.h))", GUI_MAXBLOCKS);
return GUI_HMEM_NULL;
}
/*********************************************************************
*
* _FindHole
*
* Return value:
* Offset to the memory hole (if available)
* -1 if not available
*/
static GUI_HMEM _FindHole(GUI_ALLOC_DATATYPE Size) {
int i, iNext;
for (i=0; (iNext = aBlock[i].Next) != 0; i = iNext) {
int NumFreeBytes = aBlock[iNext].Off- (aBlock[i].Off+aBlock[i].Size);
if (NumFreeBytes>=Size) {
return i;
}
}
/* Check last block */
if (GUI_ALLOC_SIZE - (aBlock[i].Off+aBlock[i].Size) >= Size) {
return i;
}
return -1;
}
/*********************************************************************
*
* _CreateHole
*
* Return value:
* Offset to the memory hole (if available)
* -1 if not available
*/
static GUI_HMEM _CreateHole(GUI_ALLOC_DATATYPE Size) {
int i, iNext;
int r = -1;
for (i=0; (iNext =aBlock[i].Next) !=0; i= iNext) {
GUI_ALLOC_DATATYPE NumFreeBytes = aBlock[iNext].Off- (aBlock[i].Off+aBlock[i].Size);
if (NumFreeBytes < Size) {
GUI_ALLOC_DATATYPE NumBytesBeforeBlock = aBlock[iNext].Off - (aBlock[i].Off+aBlock[i].Size);
if (NumBytesBeforeBlock) {
U8* pData = &GUI_Heap.abHeap[aBlock[iNext].Off];
memmove(pData-NumBytesBeforeBlock, pData, aBlock[iNext].Size);
aBlock[iNext].Off -=NumBytesBeforeBlock;
}
}
}
/* Check last block */
if (GUI_ALLOC_SIZE - (aBlock[i].Off+aBlock[i].Size) >= Size) {
r = i;
}
return r;
}
/*********************************************************************
*
* _CheckInit
*/
static void _CheckInit(void) {
if (!IsInitialized) {
GUI_ALLOC_Init();
}
}
/*********************************************************************
*
* _Alloc
*/
static GUI_HMEM _Alloc(GUI_ALLOC_DATATYPE size) {
GUI_HMEM hMemNew, hMemIns;
_CheckInit();
size = _Size2LegalSize(size);
/* Check if memory is available at all ...*/
if (size > GUI_ALLOC.NumFreeBytes) {
GUI_DEBUG_WARN1("GUI_ALLOC_Alloc: Insufficient memory configured (Trying to alloc % bytes)", size);
return 0;
}
/* Locate free handle */
if ((hMemNew = _FindFreeHandle()) == 0)
return 0;
/* Locate or Create hole of sufficient size */
hMemIns = _FindHole(size);
#if GUI_ALLOC_AUTDEFRAG
if (hMemIns == -1) {
hMemIns = _CreateHole(size);
}
#endif
/* Occupy hole */
if (hMemIns==-1) {
GUI_DEBUG_ERROROUT1("GUI_ALLOC_Alloc: Could not allocate %d bytes",size);
return 0;
}
{
GUI_ALLOC_DATATYPE Off = aBlock[hMemIns].Off + aBlock[hMemIns].Size;
int Next = aBlock[hMemIns].Next;
aBlock[hMemNew].Size = size;
aBlock[hMemNew].Off = Off;
if ((aBlock[hMemNew].Next = Next) >0) {
aBlock[Next].Prev = hMemNew;
}
aBlock[hMemNew].Prev = hMemIns;
aBlock[hMemIns].Next = hMemNew;
}
/* Keep track of number of blocks and av. memory */
GUI_ALLOC.NumUsedBlocks++;
GUI_ALLOC.NumFreeBlocks--;
if (GUI_ALLOC.NumFreeBlocksMin > GUI_ALLOC.NumFreeBlocks) {
GUI_ALLOC.NumFreeBlocksMin = GUI_ALLOC.NumFreeBlocks;
}
GUI_ALLOC.NumUsedBytes += size;
GUI_ALLOC.NumFreeBytes -= size;
if (GUI_ALLOC.NumFreeBytesMin > GUI_ALLOC.NumFreeBytes) {
GUI_ALLOC.NumFreeBytesMin = GUI_ALLOC.NumFreeBytes;
}
return hMemNew;
}
/*********************************************************************
*
* Exported routines
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ALLOC_Init
*/
void GUI_ALLOC_Init(void) {
GUI_DEBUG_LOG("\nGUI_ALLOC_Init...");
GUI_ALLOC.NumFreeBlocksMin = GUI_ALLOC.NumFreeBlocks = GUI_MAXBLOCKS-1;
GUI_ALLOC.NumFreeBytesMin = GUI_ALLOC.NumFreeBytes = GUI_ALLOC_SIZE;
GUI_ALLOC.NumUsedBlocks = 0;
GUI_ALLOC.NumUsedBytes = 0;
aBlock[0].Size = (1<<GUI_BLOCK_ALIGN); /* occupy minimum for a block */
aBlock[0].Off = 0;
aBlock[0].Next = 0;
IsInitialized =1;
}
/*********************************************************************
*
* GUI_ALLOC_AllocNoInit
*/
GUI_HMEM GUI_ALLOC_AllocNoInit(GUI_ALLOC_DATATYPE Size) {
GUI_HMEM hMem;
if (Size == 0) {
return (GUI_HMEM)0;
}
GUI_LOCK();
GUI_DEBUG_LOG2("\nGUI_ALLOC_AllocNoInit... requesting %d, %d avail", Size, GUI_ALLOC.NumFreeBytes);
hMem = _Alloc(Size);
GUI_DEBUG_LOG1("\nGUI_ALLOC_AllocNoInit : Handle", hMem);
GUI_UNLOCK();
return hMem;
}
/*********************************************************************
*
* GUI_ALLOC_h2p
*/
void* GUI_ALLOC_h2p(GUI_HMEM hMem) {
GUI_ASSERT_LOCK();
#if GUI_DEBUG_LEVEL > 0
if (!hMem) {
GUI_DEBUG_ERROROUT("\n"__FILE__ " GUI_ALLOC_h2p: illegal argument (0 handle)");
return 0;
}
if (aBlock[hMem].Size == 0) {
GUI_DEBUG_ERROROUT("Dereferencing free block");
}
#endif
return HMEM2PTR(hMem);
}
/*********************************************************************
*
* GUI_ALLOC_GetNumFreeBytes
*/
GUI_ALLOC_DATATYPE GUI_ALLOC_GetNumFreeBytes(void) {
_CheckInit();
return GUI_ALLOC.NumFreeBytes;
}
/*********************************************************************
*
* GUI_ALLOC_GetMaxSize
*
* Purpose:
* Returns the biggest available blocksize (without relocation).
*/
GUI_ALLOC_DATATYPE GUI_ALLOC_GetMaxSize(void) {
GUI_ALLOC_DATATYPE r = 0;
GUI_ALLOC_DATATYPE NumFreeBytes;
int i, iNext;
GUI_LOCK();
_CheckInit();
for (i=0; (iNext =aBlock[i].Next) !=0; i= iNext) {
NumFreeBytes = aBlock[iNext].Off- (aBlock[i].Off+aBlock[i].Size);
if (NumFreeBytes > r) {
r = NumFreeBytes;
}
}
/* Check last block */
NumFreeBytes = (GUI_ALLOC_SIZE - (aBlock[i].Off+aBlock[i].Size));
if (NumFreeBytes > r) {
r = NumFreeBytes;
}
GUI_UNLOCK();
return r;
}
#else
/*********************************************************************
*
* External memory management functions
*
* The functions below will generate code only if the GUI memory
* management is not used (GUI_ALLOC_ALLOC defined).
*
* Note:
* The memory block allocated is bigger than the requested one, as we
* store some add. information (size of the memory block) there.
*
**********************************************************************
*/
typedef struct {
union {
GUI_ALLOC_DATATYPE Size;
int Dummy; /* Needed to guarantee alignment on 32 / 64 bit CPUs */
} Info; /* Unnamed would be best, but is not supported by all compilers */
} INFO;
/*********************************************************************
*
* _GetSize
*/
static GUI_ALLOC_DATATYPE _GetSize(GUI_HMEM hMem) {
INFO * pInfo;
pInfo = (INFO *)GUI_ALLOC_H2P(hMem);
return pInfo->Info.Size;
}
/*********************************************************************
*
* _Free
*/
static void _Free(GUI_HMEM hMem) {
GUI_ALLOC_FREE(hMem);
}
/*********************************************************************
*
* GUI_ALLOC_AllocNoInit
*/
GUI_HMEM GUI_ALLOC_AllocNoInit(GUI_ALLOC_DATATYPE Size) {
GUI_HMEM hMem;
if (Size == 0) {
return (GUI_HMEM)0;
}
hMem= GUI_ALLOC_ALLOC(Size + sizeof(INFO));
/* Init info structure */
if (hMem) {
INFO * pInfo;
pInfo = (INFO *)GUI_ALLOC_H2P(hMem);
pInfo->Info.Size = Size;
}
return hMem;
}
/*********************************************************************
*
* GUI_ALLOC_h2p
*/
void* GUI_ALLOC_h2p(GUI_HMEM hMem) {
U8* p = (U8*)GUI_ALLOC_H2P(hMem); /* Pointer to memory block from memory manager */
p += sizeof(INFO); /* Convert to pointer to usable area */
return p;
}
/*********************************************************************
*
* GUI_ALLOC_GetMaxSize
*/
GUI_ALLOC_DATATYPE GUI_ALLOC_GetMaxSize(void) {
return GUI_ALLOC_GETMAXSIZE();
}
/*********************************************************************
*
* GUI_ALLOC_Init
*/
void GUI_ALLOC_Init(void) {
#ifdef GUI_ALLOC_INIT
GUI_ALLOC_INIT();
#endif
}
#endif
/*********************************************************************
*
* Public code, common memory management functions
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ALLOC_GetSize
*/
GUI_ALLOC_DATATYPE GUI_ALLOC_GetSize(GUI_HMEM hMem) {
/* Do the error checking first */
#if GUI_DEBUG_LEVEL>0
if (!hMem) {
GUI_DEBUG_ERROROUT("\n"__FILE__ " GUI_ALLOC_h2p: illegal argument (0 handle)");
return 0;
}
#endif
return _GetSize(hMem);
}
/*********************************************************************
*
* GUI_ALLOC_Free
*/
void GUI_ALLOC_Free(GUI_HMEM hMem) {
if (hMem == GUI_HMEM_NULL) { /* Note: This is not an error, it is permitted */
return;
}
GUI_LOCK();
GUI_DEBUG_LOG1("\nGUI_ALLOC_Free(%d)", hMem);
_Free(hMem);
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_ALLOC_FreePtr
*/
void GUI_ALLOC_FreePtr(GUI_HMEM *ph) {
GUI_LOCK();
GUI_ALLOC_Free(*ph);
*ph =0;
GUI_UNLOCK();
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,262 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIARCFloat.C
Purpose : Draw Arc routines based on floating point
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
2.00.00 000325 RS First release of the new algorithm
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
None.
----------------------------------------------------------------------
Open issues
----------------------------------------------------------------------
None
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "arm_math.h"
#include "GUI_Protected.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _CalcX
*/
static void _CalcX(int *px, int y, U32 r2)
{
int x = *px;
U32 y2 = (U32)y * (U32)y;
U32 r2y2 = r2 - y2;
U32 x2;
if (y2 >= r2)
{
*px = 0;
return;
}
/* x2 = r2-y2 */
do
{
x++;
x2 = (U32)x * (U32)x;
} while (x2 < r2y2);
*px = x - 1;
}
/*********************************************************************
*
* _CalcInterSectLin
*/
static float _CalcInterSectLin(float y, float y0, float y1, float x0, float x1)
{
if (y1 == y0)
{
return y0;
}
else
{
float Slope = (x1 - x0) / (y1 - y0);
return (y - y0) * Slope + x0;
}
}
/*********************************************************************
*
* _DrawArc
*/
static void _DrawArc(int x0, int y0, int rx, int ry, int Angle0, int Angle1, int xMul, int yMul)
{
float afx[4];
float afy[4];
float ri = rx - (GUI_Context.PenSize + 1.5) / 2;
float ro = rx + (GUI_Context.PenSize + 1.5) / 2;
float fAngle0 = Angle0 * 3.1415926 / 180;
float fAngle1 = Angle1 * 3.1415926 / 180;
float sin0 = arm_sin_f32(fAngle0);
float sin1 = arm_sin_f32(fAngle1);
float cos0 = arm_cos_f32(fAngle0);
float cos1 = arm_cos_f32(fAngle1);
U32 ri2 = ri * ri;
U32 ro2 = ro * ro;
int y, yMax, yMin;
afy[0] = ri * sin0;
afy[1] = ro * sin0;
afy[2] = ri * sin1;
afy[3] = ro * sin1;
afx[0] = ri * cos0;
afx[1] = ro * cos0;
afx[2] = ri * cos1;
afx[3] = ro * cos1;
yMin = ceil(afy[0]);
yMax = floor(afy[3]);
/* Use Clipping rect to reduce calculation (if possible) */
if (GUI_Context.pClipRect_HL)
{
if (yMul == 1)
{
if (yMax > (GUI_Context.pClipRect_HL->y1 - y0))
yMax = (GUI_Context.pClipRect_HL->y1 - y0);
if (yMin < (GUI_Context.pClipRect_HL->y0 - y0))
yMin = (GUI_Context.pClipRect_HL->y0 - y0);
}
if (yMul == -1)
{
if (yMin > (GUI_Context.pClipRect_HL->y1 - y0))
yMin = (GUI_Context.pClipRect_HL->y1 - y0);
if (yMax < (GUI_Context.pClipRect_HL->y0 - y0))
yMax = (GUI_Context.pClipRect_HL->y0 - y0);
}
}
/* Start drawing lines ... */
{
int xMinDisp, xMaxDisp, xMin = 0, xMax = 0;
for (y = yMax; y >= yMin; y--)
{
_CalcX(&xMin, y, ri2);
_CalcX(&xMax, y, ro2);
if ((float)y < afy[1])
{
xMaxDisp = _CalcInterSectLin(y, afy[0], afy[1], afx[0], afx[1]);
}
else
{
xMaxDisp = xMax;
}
if ((float)y > afy[2])
{
xMinDisp = _CalcInterSectLin(y, afy[2], afy[3], afx[2], afx[3]);
}
else
{
xMinDisp = xMin;
}
if (xMul > 0)
LCD_HL_DrawHLine(xMinDisp + x0, yMul * y + y0, xMaxDisp + x0);
else
LCD_HL_DrawHLine(-xMaxDisp + x0, yMul * y + y0, -xMinDisp + x0);
}
}
#if 0 /* Test code */
{
int i;
GUI_SetColor( GUI_WHITE );
for (i=0; i<4; i++)
LCD_HL_DrawPixel(afx[i]+x0, afy[i]+y0);
}
#endif
GUI_USE_PARA(ry);
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawArc
*/
void GL_DrawArc(int x0, int y0, int rx, int ry, int a0, int a1)
{
int aEnd;
a0 += 360;
a1 += 360;
while (a0 >= 360)
{
a0 -= 360;
a1 -= 360;
}
/* Do first quadrant 0-90 degree */
DoFirst:
if (a1 <= 0)
return;
if (a0 < 90)
{
if (a0 < 0)
a0 = 0;
aEnd = (a1 < 90) ? a1 : 90;
_DrawArc(x0, y0, rx, ry, a0, aEnd, 1, -1);
}
a1 -= 90;
a0 -= 90;
/* Do second quadrant 90-180 degree */
if (a1 <= 0)
return;
if (a0 < 90)
{
if (a0 < 0)
a0 = 0;
aEnd = (a1 < 90) ? a1 : 90;
_DrawArc(x0, y0, rx, ry, 90 - aEnd, 90 - a0, -1, -1);
}
a1 -= 90;
a0 -= 90;
/* Do third quadrant 180-270 degree */
if (a1 <= 0)
return;
if (a0 < 90)
{
if (a0 < 0)
a0 = 0;
aEnd = (a1 < 90) ? a1 : 90;
_DrawArc(x0, y0, rx, ry, a0, aEnd, -1, 1);
}
a1 -= 90;
a0 -= 90;
/* Do last quadrant 270-360 degree */
if (a1 <= 0)
return;
if (a0 < 90)
{
if (a0 < 0)
a0 = 0;
aEnd = (a1 < 90) ? a1 : 90;
_DrawArc(x0, y0, rx, ry, 90 - aEnd, 90 - a0, 1, 1);
}
a1 -= 90;
a0 -= 90;
goto DoFirst;
}
/*********************************************************************
*
* GUI_DrawArc
*/
void GUI_DrawArc(int x0, int y0, int rx, int ry, int a0, int a1)
{
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0, y0);
WM_ITERATE_START(NULL)
{
#endif
GL_DrawArc(x0, y0, rx, ry, a0, a1);
#if (GUI_WINSUPPORT)
}
WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,113 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIChar.C
Purpose : Implementation of character and string services
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <stdio.h>
#include "GUI_Protected.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_DispNextLine
*/
void GUI_DispNextLine(void) {
GUI_LOCK();
GUI_Context.DispPosY += GUI_GetFontDistY();
GUI_Context.DispPosX = GUI_Context.LBorder;
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_DispChar
*/
void GL_DispChar(U16 c) {
/* check for control characters */
if (c == '\n') {
GUI_DispNextLine();
} else {
if (c != '\r') {
GUI_LOCK();
GUI_Context.pAFont->pfDispChar(c);
if (GUI_pfDispCharStyle) {
GUI_pfDispCharStyle(c);
}
GUI_UNLOCK();
}
}
}
/*********************************************************************
*
* GUI_GetYAdjust
*
* Returns adjustment in vertical (Y) direction
*
* Note: The return value needs to be subtracted from
* the y-position of the character.
*/
int GUI_GetYAdjust(void) {
int r = 0;
GUI_LOCK();
switch (GUI_Context.TextAlign & GUI_TA_VERTICAL) {
case GUI_TA_BOTTOM:
r = GUI_Context.pAFont->YSize - 1;
break;
case GUI_TA_VCENTER:
r = GUI_Context.pAFont->YSize / 2;
break;
case GUI_TA_BASELINE:
r = GUI_Context.pAFont->YSize / 2;
}
GUI_UNLOCK();
return r;
}
/*********************************************************************
*
* GUI_GetFontDistY
*/
int GUI_GetFontDistY(void) {
int r;
GUI_LOCK();
// r = GUI_Context.pAFont->YDist;
r = GUI_Context.pAFont->YDist * GUI_Context.pAFont->YMag;
GUI_UNLOCK();
return r;
}
/*********************************************************************
*
* GUI_GetCharDistX
*/
int GUI_GetCharDistX(U16 c) {
int r;
GUI_LOCK();
r = GUI_Context.pAFont->pfGetCharDistX(c);
GUI_UNLOCK();
return r;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,145 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICharLine.C
Purpose : Implementation of character and string services
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <stdio.h>
#include "GUI_Protected.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _DispLine
*/
static void _DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT *pRect) {
/* Check if we have anything to do at all ... */
if (GUI_Context.pClipRect_HL) {
if (GUI_RectsIntersect(GUI_Context.pClipRect_HL, pRect) == 0)
return;
}
#if GUI_COMPILER_SUPPORTS_FP
if (GUI_Context.pAFont->pafEncode) {
GUI_Context.pAFont->pafEncode->pfDispLine(s, MaxNumChars);
} else {
#else
{
#endif
U16 Char;
while (--MaxNumChars >= 0) {
Char = GUI_UC__GetCharCodeInc(&s);
GUI_Context.pAFont->pfDispChar(Char);
if (GUI_pfDispCharStyle) {
GUI_pfDispCharStyle(Char);
}
}
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI__GetLineNumChars
*/
int GUI__GetLineNumChars(const char GUI_UNI_PTR *s, int MaxNumChars) {
int NumChars = 0;
if (s) {
#if GUI_COMPILER_SUPPORTS_FP
if (GUI_Context.pAFont->pafEncode) {
return GUI_Context.pAFont->pafEncode->pfGetLineLen(s, MaxNumChars);
}
#endif
for (; NumChars < MaxNumChars; NumChars++) {
U16 Data = GUI_UC__GetCharCodeInc(&s);
if ((Data == 0) || (Data == '\n')) {
break;
}
}
}
return NumChars;
}
/*********************************************************************
*
* GUI_GetLineDistX
*
* This routine is used to calculate the length of a line in pixels.
*/
int GUI__GetLineDistX(const char GUI_UNI_PTR *s, int MaxNumChars) {
int Dist = 0;
if (s) {
U16 Char;
#if GUI_COMPILER_SUPPORTS_FP
if (GUI_Context.pAFont->pafEncode) {
return GUI_Context.pAFont->pafEncode->pfGetLineDistX(s, MaxNumChars);
}
#endif
while (--MaxNumChars >= 0) {
Char = GUI_UC__GetCharCodeInc(&s);
Dist += GUI_GetCharDistX(Char);
}
}
return Dist;
}
/*********************************************************************
*
* GUI__DispLine
*/
void GUI__DispLine(const char GUI_UNI_PTR *s, int MaxNumChars, const GUI_RECT* pr) {
GUI_RECT r;
#if GUI_SUPPORT_ROTATION
if (GUI_pLCD_APIList) {
#if GUI_WINSUPPORT
WM_ITERATE_START(NULL) {
#endif
/* Do the actual drawing via routine call. */
_DispLine(s, MaxNumChars, &r);
#if GUI_WINSUPPORT
} WM_ITERATE_END();
#endif
} else
#endif
{
r = *pr;
#if GUI_WINSUPPORT
WM_ADDORG(r.x0, r.y0);
WM_ADDORG(r.x1, r.y1);
WM_ITERATE_START(&r) {
#endif
GUI_Context.DispPosX = r.x0;
GUI_Context.DispPosY = r.y0;
/* Do the actual drawing via routine call. */
_DispLine(s, MaxNumChars, &r);
#if GUI_WINSUPPORT
} WM_ITERATE_END();
WM_SUBORG(GUI_Context.DispPosX, GUI_Context.DispPosY);
#endif
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,167 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIChar.C
Purpose : Implementation of memory devices
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Private.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIMONO_DispChar
*
* Purpose:
* This is the routine that displays a character. It is used by all
* other routines which display characters as a subroutine.
*/
void GUIMONO_DispChar(U16P c) {
int c0, c1;
const unsigned char GUI_UNI_PTR * pd;
int x = GUI_Context.DispPosX;
int y = GUI_Context.DispPosY;
/* do some checking if drawing is actually necessary ... */
const GUI_FONT_MONO GUI_UNI_PTR * pMono = GUI_Context.pAFont->p.pMono;
unsigned int FirstChar = pMono->FirstChar;
/* translate character into 2 characters to display : c0,c1 */
/* Check if regular character first. */
if ((c >= (U16P)FirstChar) &&(c <= (U16P)pMono->LastChar)) {
pd = pMono->pData;
c0 = ((int)c) - FirstChar;
c1 = -1;
} else {
/* Check if character is in translation table */
GUI_FONT_TRANSINFO const GUI_UNI_PTR * pti = pMono->pTrans;
pd = pMono->pTransData;
if (pti) {
FirstChar = pti->FirstChar;
if ((c >= (U16P)FirstChar) && (c <= (U16P)pti->LastChar)) {
GUI_FONT_TRANSLIST const GUI_UNI_PTR * ptl;
c -= pti->FirstChar;
ptl = pti->pList;
ptl += c;
c0 = ptl->c0;
c1 = ptl->c1;
} else {
c0 = c1 = -1;
}
} else {
c0 = c1 = -1;
}
}
/* Draw first character if it is valid */
if (c0!=-1) {
int BytesPerChar = GUI_Context.pAFont->YSize*pMono->BytesPerLine;
GUI_DRAWMODE DrawMode;
int XSize = pMono->XSize;
int YSize = GUI_Context.pAFont->YSize;
/* Select the right drawing mode */
DrawMode = GUI_Context.TextMode;
/* call drawing routine */
{
U8 OldMode = LCD_SetDrawMode(DrawMode);
LCD_DrawBitmap( x, y,
XSize, YSize,
GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag,
1, /* Bits per Pixel */
pMono->BytesPerLine,
pd + c0* BytesPerChar,
&LCD_BKCOLORINDEX
);
if (c1 != -1) {
LCD_SetDrawMode(DrawMode | LCD_DRAWMODE_TRANS);
LCD_DrawBitmap( x, y,
XSize, YSize,
GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag,
1, /* Bits per Pixel */
pMono->BytesPerLine,
pd + c1* BytesPerChar,
&LCD_BKCOLORINDEX
);
}
/* Fill empty pixel lines */
if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) {
if (DrawMode != LCD_DRAWMODE_TRANS) {
LCD_SetDrawMode(DrawMode ^ LCD_DRAWMODE_REV); /* Reverse so we can fill with BkColor */
LCD_FillRect(x,
y + GUI_Context.pAFont->YSize * GUI_Context.pAFont->YDist,
x + XSize * GUI_Context.pAFont->XMag,
y + GUI_Context.pAFont->YDist);
}
}
LCD_SetDrawMode(OldMode);
}
}
//houhh 20061119...
// GUI_Context.DispPosX+=pMono->XDist;
GUI_Context.DispPosX+=pMono->XDist * GUI_Context.pAFont->XMag;
}
/*********************************************************************
*
* GUIMONO_GetCharDistX
*/
int GUIMONO_GetCharDistX(U16P c) {
const GUI_FONT_MONO GUI_UNI_PTR * pMono = GUI_Context.pAFont->p.pMono;
GUI_USE_PARA(c);
// return pMono->XDist;
//houhh 20061119...
return pMono->XDist*GUI_Context.pAFont->XMag;
}
/*********************************************************************
*
* GUIMONO_GetFontInfo
*/
void GUIMONO_GetFontInfo(const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO* pfi) {
GUI_USE_PARA(pFont);
pfi->Flags = GUI_FONTINFO_FLAG_MONO;
}
/*********************************************************************
*
* GUIMONO_IsInFont
*/
char GUIMONO_IsInFont(const GUI_FONT GUI_UNI_PTR * pFont, U16 c) {
const GUI_FONT_MONO GUI_UNI_PTR * pMono = pFont->p.pMono;
unsigned int FirstChar = pMono->FirstChar;
/* Check if regular character first. */
if ((c >= (U16P)FirstChar) &&(c <= (U16P)pMono->LastChar)) {
return 1; /* Yes, we have it ! */
} else {
/* Check if character is in translation table */
GUI_FONT_TRANSINFO const GUI_UNI_PTR * pti;
pti = pMono->pTrans;
if (pti) {
if ((c >= pti->FirstChar) && (c <= pti->LastChar)) {
return 1; /* Yes, we have it ! */
}
}
}
return 0; /* No, we can not display this character */
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,121 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICharP.C
Purpose : Implementation of Proportional fonts
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Private.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIPROP_FindChar
*/
static const GUI_FONT_PROP GUI_UNI_PTR * GUIPROP_FindChar(const GUI_FONT_PROP GUI_UNI_PTR* pProp, U16P c) {
for (; pProp; pProp = pProp->pNext) {
if ((c>=pProp->First) && (c<=pProp->Last))
break;
}
return pProp;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIPROP_DispChar
*
* Purpose:
* This is the routine that displays a character. It is used by all
* other routines which display characters as a subroutine.
*/
void GUIPROP_DispChar(U16P c) {
int BytesPerLine;
GUI_DRAWMODE DrawMode = GUI_Context.TextMode;
const GUI_FONT_PROP GUI_UNI_PTR * pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
if (pProp) {
GUI_DRAWMODE OldDrawMode;
const GUI_CHARINFO GUI_UNI_PTR * pCharInfo = pProp->paCharInfo+(c-pProp->First);
BytesPerLine = pCharInfo->BytesPerLine;
OldDrawMode = LCD_SetDrawMode(DrawMode);
LCD_DrawBitmap( GUI_Context.DispPosX, GUI_Context.DispPosY,
pCharInfo->XSize,
GUI_Context.pAFont->YSize,
GUI_Context.pAFont->XMag,
GUI_Context.pAFont->YMag,
1, /* Bits per Pixel */
BytesPerLine,
pCharInfo->pData,
&LCD_BKCOLORINDEX
);
/* Fill empty pixel lines */
if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) {
int YMag = GUI_Context.pAFont->YMag;
int YDist = GUI_Context.pAFont->YDist * YMag;
int YSize = GUI_Context.pAFont->YSize * YMag;
if (DrawMode != LCD_DRAWMODE_TRANS) {
LCD_COLOR OldColor = GUI_GetColor();
GUI_SetColor(GUI_GetBkColor());
LCD_FillRect(GUI_Context.DispPosX,
GUI_Context.DispPosY + YSize,
GUI_Context.DispPosX + pCharInfo->XSize,
GUI_Context.DispPosY + YDist);
GUI_SetColor(OldColor);
}
}
LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */
GUI_Context.DispPosX += pCharInfo->XDist * GUI_Context.pAFont->XMag;
}
}
/*********************************************************************
*
* GUIPROP_GetCharDistX
*/
int GUIPROP_GetCharDistX(U16P c) {
const GUI_FONT_PROP GUI_UNI_PTR * pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c);
return (pProp) ? (pProp->paCharInfo+(c-pProp->First))->XSize * GUI_Context.pAFont->XMag : 0;
}
/*********************************************************************
*
* GUIPROP_GetFontInfo
*/
void GUIPROP_GetFontInfo(const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO* pfi) {
GUI_USE_PARA(pFont);
pfi->Flags = GUI_FONTINFO_FLAG_PROP;
}
/*********************************************************************
*
* GUIPROP_IsInFont
*/
char GUIPROP_IsInFont(const GUI_FONT GUI_UNI_PTR * pFont, U16 c) {
const GUI_FONT_PROP GUI_UNI_PTR * pProp = GUIPROP_FindChar(pFont->p.pProp, c);
return (pProp==NULL) ? 0 : 1;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,271 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICirc.C
Purpose : Circle and ellipse drawing functions
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
1.00.02 011115 JE a) GL_FillEllipse, GL_FillCircle, GL_DrawCircle changed
1.00.01 011113 JE a) GL_DrawEllipse changed
1.00.00 991206 RS First release
----------------------------------------------------------------------
Known problems or limitations with current version
----------------------------------------------------------------------
None.
----------------------------------------------------------------------
Open issues
----------------------------------------------------------------------
None
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Private.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* Draw8Point
*/
static void Draw8Point(int x0,int y0, int xoff, int yoff) {
LCD_HL_DrawPixel(x0+xoff,y0+yoff);
LCD_HL_DrawPixel(x0-xoff,y0+yoff);
LCD_HL_DrawPixel(x0+yoff,y0+xoff);
LCD_HL_DrawPixel(x0+yoff,y0-xoff);
if (yoff) {
LCD_HL_DrawPixel(x0+xoff,y0-yoff);
LCD_HL_DrawPixel(x0-xoff,y0-yoff);
LCD_HL_DrawPixel(x0-yoff,y0+xoff);
LCD_HL_DrawPixel(x0-yoff,y0-xoff);
}
}
/*********************************************************************
*
* Public code, circle
*
**********************************************************************
*/
/*********************************************************************
*
* GL_DrawCircle
*/
void GL_DrawCircle(int x0, int y0, int r) {
I32 i;
int imax = ((I32)((I32)r*707))/1000+1;
I32 sqmax = (I32)r*(I32)r+(I32)r/2;
I32 y=r;
Draw8Point(x0,y0,r,0);
for (i=1; i<= imax; i++) {
if ((i*i+y*y) >sqmax) {
Draw8Point(x0,y0,i,y);
y--;
}
Draw8Point(x0,y0,i,y);
}
}
/*********************************************************************
*
* GUI_DrawCircle
*/
void GUI_DrawCircle(int x0, int y0, int r) {
#if (GUI_WINSUPPORT)
GUI_RECT Rect;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
Rect.x0 = x0-r;
Rect.x1 = x0+r;
Rect.y0 = y0-r;
Rect.y1 = y0+r;
WM_ITERATE_START(&Rect); {
#endif
GL_DrawCircle( x0, y0, r);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_FillCircle
*/
void GL_FillCircle(int x0, int y0, int r) {
I32 i;
int imax = ((I32)((I32)r*707))/1000+1;
I32 sqmax = (I32)r*(I32)r+(I32)r/2;
I32 x=r;
LCD_HL_DrawHLine(x0-r,y0,x0+r);
for (i=1; i<= imax; i++) {
if ((i*i+x*x) >sqmax) {
/* draw lines from outside */
if (x>imax) {
LCD_HL_DrawHLine (x0-i+1,y0+x, x0+i-1);
LCD_HL_DrawHLine (x0-i+1,y0-x, x0+i-1);
}
x--;
}
/* draw lines from inside (center) */
LCD_HL_DrawHLine(x0-x,y0+i, x0+x);
LCD_HL_DrawHLine(x0-x,y0-i, x0+x);
}
}
/*********************************************************************
*
* GUI_FillCircle
*/
void GUI_FillCircle(int x0, int y0, int r) {
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
WM_ITERATE_START(NULL); {
#endif
GL_FillCircle(x0,y0,r);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* Public code, ellipse
*
* The most efficient way to calculate the ellipse positions is using
* the knowledge that the ellipse is just circle which has compressed
* (or stretched) in one direction. For a circle, the following
* equation holds true for all points located on the border of it:
*
* x^2 + y(x)^2 = r^2 = const
*
* Therefor, for an ellipse we can make use of the following equation:
*
* (ry*x)^2 + (rx*y(x))^2 = (ry*rx)^2 = const
*
**********************************************************************
*/
/*********************************************************************
*
* GL_FillEllipse
*/
void GL_FillEllipse(int x0, int y0, int rx, int ry) {
I32 OutConst, Sum, SumY;
int x,y;
U32 _rx = rx;
U32 _ry = ry;
OutConst = _rx*_rx*_ry*_ry /* Constant as explaint above */
+(_rx*_rx*_ry>>1); /* To compensate for rounding */
x = rx;
for (y=0; y<=ry; y++) {
SumY =((I32)(rx*rx))*((I32)(y*y)); /* Does not change in loop */
while (Sum = SumY + ((I32)(ry*ry))*((I32)(x*x)),
(x>0) && (Sum>OutConst))
{
x--;
}
LCD_HL_DrawHLine(x0-x, y0+y, x0+x);
if (y)
LCD_HL_DrawHLine(x0-x, y0-y, x0+x);
}
}
/*********************************************************************
*
* GUI_FillEllipse
*/
void GUI_FillEllipse(int x0, int y0, int rx, int ry) {
#if (GUI_WINSUPPORT)
GUI_RECT r;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
/* Calc rectangle in order to avoid unnecessary drawing ops. */
r.x0 = x0-rx; r.x1 = x0+rx; r.y0 = y0-ry; r.y1 = y0+ry;
WM_ITERATE_START(&r); {
#endif
GL_FillEllipse (x0,y0, rx, ry);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*********************************************************************
*
* GL_DrawEllipse
*/
void GL_DrawEllipse(int x0, int y0, int rx, int ry) {
I32 OutConst, Sum, SumY;
int x,y;
int xOld;
U32 _rx = rx;
U32 _ry = ry;
OutConst = _rx*_rx*_ry*_ry /* Constant as explaint above */
+(_rx*_rx*_ry>>1); /* To compensate for rounding */
xOld = x = rx;
for (y=0; y<=ry; y++) {
if (y==ry) {
x=0;
} else {
SumY =((I32)(rx*rx))*((I32)(y*y)); /* Does not change in loop */
while (Sum = SumY + ((I32)(ry*ry))*((I32)(x*x)),
(x>0) && (Sum>OutConst)) x--;
}
/* Since we draw lines, we can not draw on the first
iteration
*/
if (y) {
GL_DrawLine1(x0-xOld,y0-y+1,x0-x,y0-y);
GL_DrawLine1(x0-xOld,y0+y-1,x0-x,y0+y);
GL_DrawLine1(x0+xOld,y0-y+1,x0+x,y0-y);
GL_DrawLine1(x0+xOld,y0+y-1,x0+x,y0+y);
}
xOld = x;
}
}
/*********************************************************************
*
* GUI_DrawEllipse
*/
void GUI_DrawEllipse(int x0, int y0, int rx, int ry) {
#if (GUI_WINSUPPORT)
GUI_RECT r;
#endif
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
/* Calc rectangle in order to avoid unnecessary drawing ops. */
r.x0 = x0-rx; r.x1 = x0+rx; r.y0 = y0-ry; r.y1 = y0+ry;
WM_ITERATE_START(&r); {
#endif
GL_DrawEllipse(x0, y0, rx, ry);
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,40 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIColor2Index.C
Purpose : Converts a RGB-value to a color index
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_Color2Index
*/
int GUI_Color2Index(GUI_COLOR Color) {
int Index;
GUI_LOCK();
Index = LCD_Color2Index(Color);
GUI_UNLOCK();
return Index;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,179 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICore.C
Purpose : Core routines
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#define GL_CORE_C
#include "GUI_Private.h"
#include "GUIDebug.h"
#if GUI_WINSUPPORT
#include "WM_GUI.h"
#include "WM.h"
#endif
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
#if GUI_SUPPORT_AA
static const tLCD_HL_APIList _HL_APIList = {
LCD_DrawHLine,
LCD_DrawPixel};
#endif
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _InitContext
*
* Purpose
* Initializes the given context.
*
* Special considerations
* Make sure that no GUI functions are called, because locking is
* not allowed here (GUITASK_INIT not yet called).
*/
static void _InitContext(GUI_CONTEXT *pContext)
{
/* memset(..,0,..) is not required, as this function is called only at startup of the GUI when data is 0 */
#if GUI_SUPPORT_DEVICES
pContext->pDeviceAPI = LCD_aAPI[0]; /* &LCD_L0_APIList; */
#endif
pContext->pClipRect_HL = &GUI_Context.ClipRect;
LCD_L0_GetRect(&pContext->ClipRect);
#if GUI_SUPPORT_AA
pContext->pLCD_HL = &_HL_APIList;
#endif
pContext->pAFont = GUI_DEFAULT_FONT;
pContext->pClipRect_HL = &GUI_Context.ClipRect;
pContext->PenSize = 1;
/* Variables in WM module */
#if GUI_WINSUPPORT
pContext->hAWin = WM_GetDesktopWindow();
#endif
/* Variables in GUI_AA module */
#if GUI_SUPPORT_AA
pContext->AA_Factor = 3;
#endif
pContext->Color = GUI_INVALID_COLOR;
pContext->BkColor = GUI_INVALID_COLOR;
LCD_SetBkColor(GUI_DEFAULT_BKCOLOR);
LCD_SetColor(GUI_DEFAULT_COLOR);
pContext->pUC_API = &GUI__API_TableNone;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ClearRect
*/
void GUI_ClearRect(int x0, int y0, int x1, int y1)
{
GUI_DRAWMODE PrevDraw;
#if GUI_WINSUPPORT
GUI_RECT r;
#endif
GUI_LOCK();
PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV);
#if GUI_WINSUPPORT
WM_ADDORG(x0, y0);
WM_ADDORG(x1, y1);
r.x0 = x0;
r.x1 = x1;
r.y0 = y0;
r.y1 = y1;
WM_ITERATE_START(&r)
{
#endif
LCD_FillRect(x0, y0, x1, y1);
#if GUI_WINSUPPORT
}
WM_ITERATE_END();
#endif
LCD_SetDrawMode(PrevDraw);
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_Clear
*/
void GUI_Clear(void)
{
GUI_GotoXY(0, 0); /* Reset text cursor to upper left */
GUI_ClearRect(GUI_XMIN, GUI_YMIN, GUI_XMAX, GUI_YMAX);
}
/*********************************************************************
*
* GUI_Init
*
* Purpose:
* Init of GUI internal data structures & variables
*/
int GUI_Init(void)
{
int r;
GUI_DEBUG_LOG("\nGUI_Init()");
/* Init system wide globals first */
GUI_DecChar = '.';
GUI_X_Init();
/* Init context */
_InitContext(&GUI_Context);
GUITASK_INIT();
r = LCD_Init();
#if GUI_WINSUPPORT
WM_Init();
#endif
GUITASK_COPY_CONTEXT();
#if defined(GUI_TRIAL_VERSION)
{
int i;
for (i = 0; i < 10; i++)
{
GUI_DispString("This uC-GUI library\n"
"is for evaluation\n"
"purpose only.\n"
"A license is\n"
"required to use\n"
"it in a product\n\n"
"www.micrium.com\n");
GUI_GotoXY(0, 0);
}
}
GUI_Clear();
#endif
return r;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,423 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUICurs.C
Purpose : Cursor routines of the graphics library
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Private.h"
#if GUI_SUPPORT_CURSOR
/*********************************************************************
*
* static data
*
**********************************************************************
*/
static GUI_HMEM _hBuffer;
static GUI_RECT _Rect;
static char _CursorIsVis; /* Currently visible ? */
static char _CursorOn;
static const GUI_CURSOR GUI_UNI_PTR * _pCursor;
static U8 _CursorDeActCnt;
static int _AllocSize;
static int _x, _y; /* Position of hot spot */
static GUI_RECT _ClipRect;
static LCD_PIXELINDEX _ColorIndex[4]; /* Color-Cache */
/*********************************************************************
*
* static code, helper functions
*
**********************************************************************
*/
/*********************************************************************
*
* _SetPixelIndex
*
* Purpose
* Sets the pixel index for the Cursor.
* Note the following:
* - We do the clipping in this routine
* - We do NOT call the driver directly, but thru its API table.
* This allows others (e.g. the VNC server) to be in the loop-
*/
static void _SetPixelIndex(int x, int y, int Index) {
if ((y >= _ClipRect.y0) && (y <= _ClipRect.y1)) {
if ((x >= _ClipRect.x0) && (x <= _ClipRect.x1)) {
LCD_aAPI[0]->pfSetPixelIndex(x, y, Index);
}
}
}
/*********************************************************************
*
* _GetPixelIndex
*
* Purpose
* Gets a pixel index for the Cursor.
*/
static int _GetPixelIndex(int x, int y) {
if ((y >= _ClipRect.y0) && (y <= _ClipRect.y1)) {
if ((x >= _ClipRect.x0) && (x <= _ClipRect.x1)) {
return LCD_L0_GetPixelIndex(x, y);
}
}
return 0;
}
/*********************************************************************
*
* _Undraw
*
* Purpose
* Remove the cursors
*/
static void _Undraw(void) {
int x, y, xSize, ySize;
LCD_PIXELINDEX* pData;
/* Save bitmap data */
GUI_LOCK();
if (_hBuffer) {
pData = (LCD_PIXELINDEX*)GUI_ALLOC_h2p(_hBuffer);
xSize = _Rect.x1 - _Rect.x0 + 1;
ySize = _Rect.y1 - _Rect.y0 + 1;
for (y = 0; y < ySize; y++) {
for (x = 0; x < xSize; x++) {
_SetPixelIndex(x + _Rect.x0, y + _Rect.y0, *(pData + x));
}
pData += _pCursor->pBitmap->XSize;
}
}
GUI_UNLOCK();
}
/*********************************************************************
*
* _Log2Phys
*/
static int _Log2Phys(int Index) {
if (Index < 4) {
return _ColorIndex[Index];
} else {
LCD_COLOR Color = *(_pCursor->pBitmap->pPal->pPalEntries + Index);
return LCD_Color2Index(Color);
}
}
/*********************************************************************
*
* _Draw
*/
static void _Draw(void) {
int x, y, xSize, ySize;
LCD_PIXELINDEX* pData;
const GUI_BITMAP GUI_UNI_PTR * pBM;
GUI_LOCK();
if (_hBuffer) {
/* Save bitmap data */
pBM = _pCursor->pBitmap;
pData = (LCD_PIXELINDEX*)GUI_ALLOC_h2p(_hBuffer);
xSize = _Rect.x1 - _Rect.x0 + 1;
ySize = _Rect.y1 - _Rect.y0 + 1;
for (y = 0; y < ySize; y++) {
for (x = 0; x < xSize; x++) {
int BitmapPixel;
*(pData + x) = _GetPixelIndex(_Rect.x0 + x, _Rect.y0 + y);
BitmapPixel = GUI_GetBitmapPixelIndex(pBM, x, y);
if (BitmapPixel) {
_SetPixelIndex(_Rect.x0 + x, _Rect.y0 + y, _Log2Phys(BitmapPixel));
}
}
pData += pBM->XSize;
}
}
GUI_UNLOCK();
}
/*********************************************************************
*
* _CalcRect
*/
static void _CalcRect(void) {
if (_pCursor) {
_Rect.x0 = _x - _pCursor->xHot;
_Rect.y0 = _y - _pCursor->yHot;
_Rect.x1 = _Rect.x0 + _pCursor->pBitmap->XSize - 1;
_Rect.y1 = _Rect.y0 + _pCursor->pBitmap->YSize - 1;
}
}
/*********************************************************************
*
* _Hide
*/
static void _Hide(void) {
if (_CursorIsVis) {
_Undraw();
_CursorIsVis = 0;
}
}
/*********************************************************************
*
* _Show
*/
static void _Show(void) {
if (_CursorOn && (_CursorDeActCnt==0)) {
_CursorIsVis = 1;
_Draw();
}
}
/*********************************************************************
*
* _TempHide
*
* Purpose:
* Hide cursor if a part of the given rectangle is located in the
* rectangle used for the cursor. This routine is called automatically
* by the window manager. This way the window manager can
* automatically make sure that the cursor is always displayed
* correctly.
*
* Params:
* pRect Rectangle under consideration
*
* Return value:
* 0: No action taken
* Cursor was not visible or not affected because rectangles
* did not overlap
* 1: Cursor hidden -> WM needs to restore cursor after
* drawing operation
*/
static char _TempHide(const GUI_RECT* pRect) {
if (!_CursorIsVis) {
return 0; /* Cursor not visible -> nothing to do */
}
if ((pRect == NULL) || GUI_RectsIntersect(pRect, &_Rect)) {
_Hide(); /* Cursor needs to be hidden */
return 1;
}
return 0; /* Cursor not affected -> nothing to do */
}
/*********************************************************************
*
* _TempUnhide
*/
static void _TempUnhide(void) {
_Show();
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_CURSOR_Activate
*/
void GUI_CURSOR_Activate(void) {
GUI_LOCK();
if ((--_CursorDeActCnt) ==0) {
_Show();
}
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_CURSOR_Deactivate
*/
void GUI_CURSOR_Deactivate(void) {
GUI_LOCK();
if (_CursorDeActCnt++ ==0)
_Hide();
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_CURSOR_Select
*/
const GUI_CURSOR GUI_UNI_PTR * GUI_CURSOR_Select(const GUI_CURSOR GUI_UNI_PTR * pCursor) {
int AllocSize;
const GUI_BITMAP GUI_UNI_PTR * pBM;
const GUI_CURSOR GUI_UNI_PTR * pOldCursor;
GUI_LOCK();
pOldCursor = _pCursor;
if (pCursor != _pCursor) {
int i;
pBM = pCursor->pBitmap;
i = pBM->pPal->NumEntries > 4 ? 4 : pBM->pPal->NumEntries;
while (i--) {
LCD_COLOR Color = *(pBM->pPal->pPalEntries + i);
_ColorIndex[i] = LCD_Color2Index(Color);
}
_Hide();
AllocSize = pBM->XSize * pBM->YSize * sizeof(LCD_PIXELINDEX);
if (AllocSize != _AllocSize) {
GUI_ALLOC_Free(_hBuffer);
_hBuffer = 0;
}
_hBuffer = GUI_ALLOC_AllocZero(AllocSize);
_CursorOn = 1;
_pCursor = pCursor;
_CalcRect();
_Show();
}
GUI_UNLOCK();
return pOldCursor;
}
/*********************************************************************
*
* GUI_CURSOR_Hide
*/
void GUI_CURSOR_Hide(void) {
GUI_LOCK();
_Hide();
_CursorOn = 0;
/* Set function pointer which window manager can use */
GUI_CURSOR_pfTempHide = NULL;
GUI_CURSOR_pfTempUnhide = NULL;
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_CURSOR_Show
*/
void GUI_CURSOR_Show(void) {
GUI_LOCK();
LCDDEV_L0_GetRect(&_ClipRect);
_Hide();
_CursorOn = 1;
/* Set function pointer which window manager can use */
GUI_CURSOR_pfTempHide = _TempHide;
GUI_CURSOR_pfTempUnhide = _TempUnhide;
if (!_pCursor) {
GUI_CURSOR_Select(GUI_DEFAULT_CURSOR);
} else {
_Show();
}
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_CURSOR_SetPosition
*/
void GUI_CURSOR_SetPosition(int xNewPos, int yNewPos) {
int x, xStart, xStep, xEnd, xOff, xOverlapMin, xOverlapMax;
int y, yStart, yStep, yEnd, yOff, yOverlapMin, yOverlapMax;
int xSize;
LCD_PIXELINDEX* pData;
GUI_LOCK();
if (_hBuffer) {
if ((_x != xNewPos) | (_y != yNewPos)) {
if (_CursorOn) {
const GUI_BITMAP GUI_UNI_PTR * pBM = _pCursor->pBitmap;
/* Save & set clip rect */
/* Compute helper variables */
pData = (LCD_PIXELINDEX*)GUI_ALLOC_h2p(_hBuffer);
xSize = _pCursor->pBitmap->XSize;
xOff = xNewPos - _x;
if (xOff > 0) {
xStep = 1;
xStart = 0;
xEnd = _pCursor->pBitmap->XSize;
xOverlapMax = xEnd -1;
xOverlapMin = xOff;
} else {
xStep = -1;
xStart = xSize - 1;
xEnd = -1;
xOverlapMin = 0;
xOverlapMax = xStart + xOff;
}
yOff = yNewPos - _y;
if (yOff > 0) {
yStep = 1;
yStart = 0;
yEnd = _pCursor->pBitmap->YSize;
yOverlapMax = yEnd -1;
yOverlapMin = yOff;
} else {
yStep = -1;
yStart = _pCursor->pBitmap->YSize - 1;
yEnd = -1;
yOverlapMin = 0;
yOverlapMax = yStart + yOff;
}
/* Restore & Draw */
for (y = yStart; y != yEnd; y += yStep) {
char yOverlaps;
char yNewOverlaps;
int yNew = y + yOff;
yOverlaps = (y >= yOverlapMin) && (y <= yOverlapMax);
yNewOverlaps = (yNew >= yOverlapMin) && (yNew <= yOverlapMax);
for (x= xStart; x != xEnd; x += xStep) {
char xyOverlaps, xyNewOverlaps;
int BitmapPixel;
LCD_PIXELINDEX Pixel;
LCD_PIXELINDEX* pSave = pData + x + y * xSize;
int xNew = x + xOff;
BitmapPixel = GUI_GetBitmapPixelIndex(pBM, x, y);
xyOverlaps = (x >= xOverlapMin) && (x <= xOverlapMax) && yOverlaps;
xyNewOverlaps = (xNew >= xOverlapMin) && (xNew <= xOverlapMax) && yNewOverlaps;
/* Restore old pixel if it was not transparent */
if (BitmapPixel) {
if (!xyOverlaps || (GUI_GetBitmapPixelIndex(pBM, x - xOff, y - yOff) == 0)) {
_SetPixelIndex(x + _Rect.x0, y + _Rect.y0, *(pSave));
}
}
/* Save */
if (xyNewOverlaps) {
Pixel = *(pData + xNew + yNew * xSize);
} else {
Pixel = _GetPixelIndex(_Rect.x0 + xNew, _Rect.y0 + yNew);
}
*pSave = Pixel;
/* Write new ... We could write pixel by pixel here */
if (BitmapPixel) {
LCD_PIXELINDEX NewPixel = _Log2Phys(BitmapPixel);
_SetPixelIndex(_Rect.x0 + xNew, _Rect.y0 + yNew, NewPixel);
}
}
}
}
_x = xNewPos;
_y = yNewPos;
_CalcRect();
}
}
GUI_UNLOCK();
}
#else
void GUICurs_C(void);
void GUICurs_C(void) {} /* avoid empty object files */
#endif /* GUI_SUPPORT_CURSOR */
/*************************** End of file ****************************/

View File

@ -0,0 +1,173 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* ľC/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 : GUIDebug.h
Purpose : Debug macros
----------------------------------------------------------------------
Debug macros for logging
In the GUI Simulation, all output is transferred into the log window.
*/
#ifndef GUI_DEBUG_H
#define GUI_DEBUG_H
#include "GUI.h"
#include "GUI_X.h"
#define GUI_DEBUG_LEVEL_NOCHECK 0 /* No run time checks are performed */
#define GUI_DEBUG_LEVEL_CHECK_PARA 1 /* Parameter checks are performed to avoid crashes */
#define GUI_DEBUG_LEVEL_CHECK_ALL 2 /* Parameter checks and consistency checks are performed */
#define GUI_DEBUG_LEVEL_LOG_ERRORS 3 /* Errors are recorded */
#define GUI_DEBUG_LEVEL_LOG_WARNINGS 4 /* Errors & Warnings are recorded */
#define GUI_DEBUG_LEVEL_LOG_ALL 5 /* Errors, Warnings and Messages are recorded. */
#ifndef GUI_DEBUG_LEVEL
#ifdef WIN32
// #define GUI_DEBUG_LEVEL GUI_DEBUG_LEVEL_LOG_WARNINGS /* Simulation should log all warnings */
#define GUI_DEBUG_LEVEL GUI_DEBUG_LEVEL_LOG_ALL /* Simulation should log all warnings */
#else
#define GUI_DEBUG_LEVEL GUI_DEBUG_LEVEL_CHECK_PARA /* For most targets, min. size is important */
#endif
#endif
/*******************************************************************
*
* Commandline
*
********************************************************************
*/
#ifdef WIN32
#define GUI_DEBUG_GETCMDLINE() SIM_GetCmdLine()
#else
#define GUI_DEBUG_GETCMDLINE() 0
#endif
/*******************************************************************
*
* Error macros
*
********************************************************************
*/
/* Make sure the macros are actually defined */
#if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_LOG_ERRORS
#define GUI_DEBUG_ERROROUT(s) GUI_ErrorOut(s)
#define GUI_DEBUG_ERROROUT1(s,p0) GUI_ErrorOut1(s,p0)
#define GUI_DEBUG_ERROROUT2(s,p0,p1) GUI_ErrorOut2(s,p0,p1)
#define GUI_DEBUG_ERROROUT3(s,p0,p1,p2) GUI_ErrorOut3(s,p0,p1,p2)
#define GUI_DEBUG_ERROROUT4(s,p0,p1,p2,p3) GUI_ErrorOut4(s,p0,p1,p2,p3)
#define GUI_DEBUG_ERROROUT_IF(exp,s) { if (exp) GUI_DEBUG_ERROROUT(s); }
#define GUI_DEBUG_ERROROUT1_IF(exp,s,p0) { if (exp) GUI_DEBUG_ERROROUT1(s,p0); }
#define GUI_DEBUG_ERROROUT2_IF(exp,s,p0,p1) { if (exp) GUI_DEBUG_ERROROUT2(s,p0,p1); }
#define GUI_DEBUG_ERROROUT3_IF(exp,s,p0,p1,p2) { if (exp) GUI_DEBUG_ERROROUT3(s,p0,p1,p2); }
#define GUI_DEBUG_ERROROUT4_IF(exp,s,p0,p1,p2,p3) { if (exp) GUI_DEBUG_ERROROUT4(s,p0,p1,p2,p3); }
#else
#define GUI_DEBUG_ERROROUT(s)
#define GUI_DEBUG_ERROROUT1(s,p0)
#define GUI_DEBUG_ERROROUT2(s,p0,p1)
#define GUI_DEBUG_ERROROUT3(s,p0,p1,p2)
#define GUI_DEBUG_ERROROUT4(s,p0,p1,p2,p3)
#define GUI_DEBUG_ERROROUT_IF(exp,s)
#define GUI_DEBUG_ERROROUT1_IF(exp,s,p0)
#define GUI_DEBUG_ERROROUT2_IF(exp,s,p0,p1)
#define GUI_DEBUG_ERROROUT3_IF(exp,s,p0,p1,p2)
#define GUI_DEBUG_ERROROUT4_IF(exp,s,p0,p1,p2,p3)
#endif
/*******************************************************************
*
* Warning macros
*
********************************************************************
*/
/* Make sure the macros are actually defined */
#if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_LOG_WARNINGS
#define GUI_DEBUG_WARN(s) GUI_Warn(s)
#define GUI_DEBUG_WARN1(s,p0) GUI_Warn1(s,p0)
#define GUI_DEBUG_WARN2(s,p0,p1) GUI_Warn2(s,p0,p1)
#define GUI_DEBUG_WARN3(s,p0,p1,p2) GUI_Warn3(s,p0,p1,p2)
#define GUI_DEBUG_WARN4(s,p0,p1,p2,p3) GUI_Warn4(s,p0,p1,p2,p3)
#define GUI_DEBUG_WARN_IF(exp,s) { if (exp) GUI_DEBUG_WARN(s); }
#define GUI_DEBUG_WARN1_IF(exp,s,p0) { if (exp) GUI_DEBUG_WARN1(s,p0); }
#define GUI_DEBUG_WARN2_IF(exp,s,p0,p1) { if (exp) GUI_DEBUG_WARN2(s,p0,p1); }
#define GUI_DEBUG_WARN3_IF(exp,s,p0,p1,p2) { if (exp) GUI_DEBUG_WARN3(s,p0,p1,p2); }
#define GUI_DEBUG_WARN4_IF(exp,s,p0,p1,p2,p3) { if (exp) GUI_DEBUG_WARN4(s,p0,p1,p2,p3); }
#else
#define GUI_DEBUG_WARN(s)
#define GUI_DEBUG_WARN1(s,p0)
#define GUI_DEBUG_WARN2(s,p0,p1)
#define GUI_DEBUG_WARN3(s,p0,p1,p2)
#define GUI_DEBUG_WARN4(s,p0,p1,p2,p3)
#define GUI_DEBUG_WARN_IF(exp,s)
#define GUI_DEBUG_WARN1_IF(exp,s,p0)
#define GUI_DEBUG_WARN2_IF(exp,s,p0,p1)
#define GUI_DEBUG_WARN3_IF(exp,s,p0,p1,p2)
#define GUI_DEBUG_WARN4_IF(exp,s,p0,p1,p2,p3)
#endif
/*******************************************************************
*
* Logging macros
*
********************************************************************
*/
/* Make sure the macros are actually defined */
#if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_LOG_ALL
#define GUI_DEBUG_LOG(s) GUI_Log(s)
#define GUI_DEBUG_LOG1(s,p0) GUI_Warn1(s,p0)
#define GUI_DEBUG_LOG2(s,p0,p1) GUI_Warn2(s,p0,p1)
#define GUI_DEBUG_LOG3(s,p0,p1,p2) GUI_Warn3(s,p0,p1,p2)
#define GUI_DEBUG_LOG4(s,p0,p1,p2,p3) GUI_Warn4(s,p0,p1,p2,p3)
#define GUI_DEBUG_LOG_IF(exp,s) { if (exp) GUI_DEBUG_LOG(s); }
#define GUI_DEBUG_LOG1_IF(exp,s,p0) { if (exp) GUI_DEBUG_LOG1(s,p0); }
#define GUI_DEBUG_LOG2_IF(exp,s,p0,p1) { if (exp) GUI_DEBUG_LOG2(s,p0,p1); }
#define GUI_DEBUG_LOG3_IF(exp,s,p0,p1,p2) { if (exp) GUI_DEBUG_LOG3(s,p0,p1,p2); }
#define GUI_DEBUG_LOG4_IF(exp,s,p0,p1,p2,p3) { if (exp) GUI_DEBUG_LOG4(s,p0,p1,p2,p3); }
#else
#define GUI_DEBUG_LOG(s)
#define GUI_DEBUG_LOG1(s,p0)
#define GUI_DEBUG_LOG2(s,p0,p1)
#define GUI_DEBUG_LOG3(s,p0,p1,p2)
#define GUI_DEBUG_LOG4(s,p0,p1,p2,p3)
#define GUI_DEBUG_LOG_IF(exp,s)
#define GUI_DEBUG_LOG1_IF(exp,s,p0)
#define GUI_DEBUG_LOG2_IF(exp,s,p0,p1)
#define GUI_DEBUG_LOG3_IF(exp,s,p0,p1,p2)
#define GUI_DEBUG_LOG4_IF(exp,s,p0,p1,p2,p3)
#endif
/*******************************************************************
*
* Asserts
*
********************************************************************
*/
#if GUI_DEBUG_LEVEL >= GUI_DEBUG_LEVEL_LOG_ERRORS
#define GUI_DEBUG_ASSERT(exp) { if (!exp) GUI_DEBUG_ERROROUT(#exp); }
#else
#define GUI_DEBUG_ASSERT(exp)
#endif
#endif /* LCD_H */
/*************************** End of file ****************************/

View File

@ -0,0 +1,116 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIEncSJ.C
Purpose : Implementation of Shift JIS decoding
----------------------------------------------------------------------
Version-Date---Author-Explanation
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Protected.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* DB2SJIS
*/
static U16 DB2SJIS(U8 Byte0, U8 Byte1) {
return Byte1 | (((U16)Byte0)<<8);
}
/*********************************************************************
*
* _GetLineDistX_SJIS
*/
static int _GetLineDistX_SJIS(const char GUI_UNI_PTR *s, int Len) {
int Dist =0;
if (s) {
U8 c0;
while (((c0=*(const U8*)s) !=0) && Len >=0) {
s++; Len--;
if (c0 > 127) {
U8 c1 = *(const U8*)s++;
Len--;
Dist += GUI_GetCharDistX(DB2SJIS(c0, c1));
} else {
Dist += GUI_GetCharDistX(c0);
}
}
}
return Dist;
}
/*********************************************************************
*
* _GetLineLen_SJIS
* Purpose:
* Returns the number of characters in a string.
*
* NOTE:
* The return value can be used as offset into the
* string, which means that double characters count double
*/
static int _GetLineLen_SJIS(const char GUI_UNI_PTR *s, int MaxLen) {
int Len =0;
U8 c0;
while (((c0=*(const U8*)s) !=0) && Len < MaxLen) {
s++;
if (c0 > 127) {
Len++; s++;
} else {
switch (c0) {
case '\n': return Len;
}
}
Len++;
}
return Len;
}
/*********************************************************************
*
* _DispLine_SJIS
*/
static void _DispLine_SJIS(const char GUI_UNI_PTR *s, int Len) {
U8 c0;
while (--Len >=0) {
c0=*(const U8*)s++;
if (c0 > 127) {
U8 c1 = *(const U8*)s++;
Len--;
GL_DispChar (DB2SJIS(c0, c1));
} else {
GL_DispChar(c0);
}
}
}
/*********************************************************************
*
* GUI_ENC_APIList_SJIS, API list
*/
const tGUI_ENC_APIList GUI_ENC_APIList_SJIS = {
_GetLineDistX_SJIS,
_GetLineLen_SJIS,
_DispLine_SJIS
};
/*************************** End of file ****************************/

View File

@ -0,0 +1,40 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIIndex2Color.C
Purpose : Converts a color index to a RGB-value
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_Index2Color
*/
GUI_COLOR GUI_Index2Color(int Index) {
GUI_COLOR Color;
GUI_LOCK();
Color = LCD_Index2Color(Index);
GUI_UNLOCK();
return Color;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,152 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIPolyE.c
Purpose : Polygon enlarge
----------------------------------------------------------------------
*/
#include <math.h>
#include "GUI.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
float x, y;
} tfPoint;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _fround
*/
static int _fround(float f) {
if (f>0)
return f+0.5f;
return f-0.5f;
}
/*********************************************************************
*
* _Normalize
*/
static void _Normalize(tfPoint* pfPoint) {
float fx = pfPoint->x;
float fy = pfPoint->y;
float r = sqrt(fx*fx + fy*fy);
if (r > 0) {
pfPoint->x = fx/r;
pfPoint->y = fy/r;
}
}
/*********************************************************************
*
* _ReverseLen
*/
static void _ReverseLen(tfPoint* pfPoint) {
float fx = pfPoint->x;
float fy = pfPoint->y;
float r = sqrt(fx*fx/2 + fy*fy/2);
if (r > 0) {
pfPoint->x = fx/r/r;
pfPoint->y = fy/r/r;
}
}
/*********************************************************************
*
* _GetVect
*/
static void _GetVect(tfPoint* pfPoint, const GUI_POINT* pSrc, int NumPoints, int Index) {
int Off0 = (Index + NumPoints-1) % NumPoints;
int Off1 = Index % NumPoints;
pfPoint->x = pSrc[Off1].x - pSrc[Off0].x;
pfPoint->y = pSrc[Off1].y - pSrc[Off0].y;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_EnlargePolygon
*/
#if 0
void GUI_EnlargePolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, int Len) {
int j;
/* Calc destination points */
for (j=0; j<NumPoints; j++) {
int x, y;
tfPoint aVect[2];
/* Get the vectors */
_GetVect(&aVect[0], pSrc, NumPoints, j);
_GetVect(&aVect[1], pSrc, NumPoints, j+1);
/* Normalize the vectors and add vectors */
_Normalize(&aVect[0]);
_Normalize(&aVect[1]);
aVect[0].x += aVect[1].x;
aVect[0].y += aVect[1].y;
/* Resulting vector needs to be normalized again */
_Normalize(&aVect[0]);
x = _fround(aVect[0].y * Len);
y = -_fround(aVect[0].x * Len);
/* Store destination */
(pDest+j)->x = (pSrc+j)->x + x;
(pDest+j)->y = (pSrc+j)->y + y;
}
}
#else
void GUI_EnlargePolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, int Len) {
int j;
/* Calc destination points */
for (j=0; j<NumPoints; j++) {
int x, y;
tfPoint aVect[2];
/* Get the vectors */
_GetVect(&aVect[0], pSrc, NumPoints, j);
_GetVect(&aVect[1], pSrc, NumPoints, j+1);
/* Normalize the vectors and add vectors */
_Normalize(&aVect[0]);
_Normalize(&aVect[1]);
aVect[0].x += aVect[1].x;
aVect[0].y += aVect[1].y;
/* Resulting vector needs to be normalized again */
_ReverseLen(&aVect[0]);
x = _fround(aVect[0].y * Len);
y = -_fround(aVect[0].x * Len);
/* Store destination */
(pDest+j)->x = (pSrc+j)->x + x;
(pDest+j)->y = (pSrc+j)->y + y;
}
}
#endif
/*************************** End of file ****************************/

View File

@ -0,0 +1,41 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIPolyR.c
Purpose : Polygon rotation
----------------------------------------------------------------------
*/
#include <math.h>
#include "GUI.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_MagnifyPolygon
*/
void GUI_MagnifyPolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, int Mag) {
int j;
for (j=0; j<NumPoints; j++) {
(pDest+j)->x = (pSrc+j)->x * Mag;
(pDest+j)->y = (pSrc+j)->y * Mag;
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,47 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIPolyR.c
Purpose : Polygon rotation
----------------------------------------------------------------------
*/
#include "arm_math.h"
#include "GUI.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_RotatePolygon
*/
void GUI_RotatePolygon(GUI_POINT *pDest, const GUI_POINT *pSrc, int NumPoints, float Angle)
{
int j;
float fcos = arm_cos_f32(Angle);
float fsin = arm_sin_f32(Angle);
for (j = 0; j < NumPoints; j++)
{
int x = (pSrc + j)->x;
int y = (pSrc + j)->y;
(pDest + j)->x = x * fcos + y * fsin;
(pDest + j)->y = -x * fsin + y * fcos;
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,65 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIRealloc.C
Purpose : Dynamic memory management
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <string.h> /* for memcpy, memset */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Public routines: Using internal memory management
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ALLOC_Realloc
*
* Purpose:
* Reallocate a memory block. This is typically used to grow memory
* blocks. The contents of the old memory block are copied into the
* new block (or as much as fits in case of shrinkage).
* In case of error the old memory block (and its handle) remain
* unchanged.
*
* Return value:
* On success: Handle of newly allocated memory block
* On error: 0
*/
GUI_HMEM GUI_ALLOC_Realloc(GUI_HMEM hOld, int NewSize) {
GUI_HMEM hNew;
hNew = GUI_ALLOC_AllocNoInit(NewSize);
if (hNew && hOld) {
void *pNew, *pOld;
int Size, OldSize;
OldSize = GUI_ALLOC_GetSize(hOld);
Size = (OldSize < NewSize) ? OldSize : NewSize;
GUI_LOCK();
pNew = GUI_ALLOC_h2p(hNew);
pOld = GUI_ALLOC_h2p(hOld);
memcpy(pNew, pOld, Size);
GUI_UNLOCK();
GUI_ALLOC_Free(hOld);
}
return hNew;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,48 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIStream.c
Purpose : Support for streamed bitmaps
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_DrawStreamedBitmap
*/
void GUI_DrawStreamedBitmap(const GUI_BITMAP_STREAM *pBitmapHeader, int x, int y) {
GUI_BITMAP Bitmap = {0};
GUI_LOGPALETTE Palette;
Bitmap.BitsPerPixel = pBitmapHeader->BitsPerPixel;
Bitmap.BytesPerLine = pBitmapHeader->BytesPerLine;
Bitmap.pData = ((const U8*)pBitmapHeader)+16+4*pBitmapHeader->NumColors;
Bitmap.pPal = &Palette;
Bitmap.XSize = pBitmapHeader->XSize;
Bitmap.YSize = pBitmapHeader->YSize;
Palette.HasTrans = pBitmapHeader->HasTrans;
Palette.NumEntries = pBitmapHeader->NumColors;
Palette.pPalEntries = (const LCD_COLOR*)((const U8*)pBitmapHeader+16);
GUI_DrawBitmap(&Bitmap, x, y);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,231 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUITASK.C
Purpose : Saves/Restores task context with supported OSs.
It also uses a resource semaphore.
The following externals are used and should typically be defined
in GUI_X.c:
U32 GUI_X_GetTaskId();
void GUI_X_Unlock();
void GUI_X_Lock();
----------------------------------------------------------------------
Version-Date---Author-Explanation
----------------------------------------------------------------------
3.70 031016 TQ GUI_MAXTASK set to 4
3.60 030902 TQ GUI_MAXTASK increased to 6
3.52 030618 RS GUI_MAX_LOCK_NESTING increased
3.40 030228 RS GUI_MAX_LOCK_NESTING introduced
3.02a 020722 RS Use of macro GUI_DEBUG_ERROROUT_IF in order
to simplify th code.
3.02 020514 RS Avoided nested calls of GUI_X_Lock, GUI_X_Unlock
(because some RTOSes, such as CMX and u/C-OS
could not handle this easily)
3.00 010425 RS Cleanup for Version 3.00
a) Dummy routines added to avoid link errors
in case some modules are compiled with
different settings
1.00.01 990926 RS Fix in order to make sure init task has no
context of its own (_CurrentTaskNo =-1)
1.00.00 990918 RS Initial version for version control purposes.
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Configuration defaults
*
**********************************************************************
*/
#ifndef GUI_MAXTASK
#define GUI_MAXTASK (4)
#endif
#ifndef GUI_MAX_LOCK_NESTING
#define GUI_MAX_LOCK_NESTING 48 /* If a lot of nested dialogs are used, this may not be sufficient. */
#endif
#if GUI_OS
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static struct {
U32 TaskID;
GUI_CONTEXT Context;
} _Save[GUI_MAXTASK];
static int _CurrentTaskNo = -1;
static int _EntranceCnt = 0;
static U32 _TaskIDLock = 0;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetTaskNo
*/
static int _GetTaskNo(void) {
int i;
for (i=0; i< GUI_MAXTASK; i++) {
U32 TaskId = GUI_X_GetTaskId();
if (_Save[i].TaskID == TaskId)
return i;
if (_Save[i].TaskID == 0) {
_Save[i].TaskID = TaskId;
return i;
}
}
GUI_DEBUG_ERROROUT("No Context available for task ... (increase GUI_MAXTASK)");
return 0;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_Unlock
*/
void GUI_Unlock(void) {
if (--_EntranceCnt == 0) {
GUI_X_Unlock();
}
/* Test if _EntranceCnt is in reasonable range ... Not required in release builds */
GUI_DEBUG_ERROROUT_IF((_EntranceCnt < 0), "GUITASK.c: GUI_Unlock() _EntranceCnt underflow ");
}
/*********************************************************************
*
* GUI_Lock
*/
void GUI_Lock(void) {
if (_EntranceCnt == 0) {
GUI_X_Lock();
_TaskIDLock = GUI_X_GetTaskId(); /* Save task ID */
} else {
if (_TaskIDLock != GUI_X_GetTaskId()) {
GUI_X_Lock();
_TaskIDLock = GUI_X_GetTaskId(); /* Save task ID */
}
}
if (++_EntranceCnt == 1) {
int TaskNo = _GetTaskNo();
if (TaskNo != _CurrentTaskNo) {
/* Save data of current task */
if (_CurrentTaskNo>=0) { /* Make sure _CurrentTaskNo is valid */
_Save[_CurrentTaskNo].Context = GUI_Context;
/* Load data of this task */
GUI_Context = _Save[TaskNo].Context;
}
_CurrentTaskNo = TaskNo;
}
}
/* Test if _EntranceCnt is in reasonable range ... Not required in release builds */
GUI_DEBUG_ERROROUT_IF((_EntranceCnt > GUI_MAX_LOCK_NESTING), "GUITASK.c: GUI_Lock() _EntranceCnt overflow ");
}
/*********************************************************************
*
* GUITASK_Init
*/
void GUITASK_Init(void) {
_CurrentTaskNo =-1; /* Invalidate */
GUI_X_InitOS();
}
/*********************************************************************
*
* GUITASK_CopyContext
*/
void GUITASK_CopyContext(void) {
int i;
for (i = 0; i < GUI_MAXTASK; i++) {
_Save[i].Context = GUI_Context;
_Save[i].TaskID = 0;
}
}
#if defined(WIN32) && defined(_DEBUG)
/*********************************************************************
*
* GUITASK_AssertLock
*
*/
void GUITASK_AssertLock(void) {
if (!_EntranceCnt) {
GUI_DEBUG_ERROROUT("GUITASK.c: GUITASK_AssertLock failed!");
}
}
/*********************************************************************
*
* GUITASK_AssertNoLock
*
*/
void GUITASK_AssertNoLock(void) {
GUI_Lock();
if (_EntranceCnt > 1) {
GUI_DEBUG_ERROROUT("GUITASK.c: GUITASK_AssertNoLock failed!");
}
GUI_Unlock();
}
#endif
#else
/*********************************************************************
*
* Dummy Kernel routines
*
* The routines below are dummies in case configuration tells us not
* to use any kernel. In this case the routines below should
* not be required, but it can not hurt to have them. The linker
* will eliminate them anyhow.
*/
void GUI_Unlock(void);
void GUI_Unlock(void) {}
void GUI_Lock(void);
void GUI_Lock(void) {}
void GUITASK_Init(void);
void GUITASK_Init(void) {}
void GUITASK_StoreDefaultContext(void);
void GUITASK_StoreDefaultContext(void) {}
#endif
/*************************** End of file ****************************/

View File

@ -0,0 +1,51 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUITime.C
Purpose : Time related routines
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Protected.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_GetTime
*/
int GUI_GetTime(void) {
return GUI_X_GetTime();
}
/*********************************************************************
*
* GUI_Delay
*/
void GUI_Delay(int Period) {
int EndTime = GUI_GetTime()+Period;
int tRem; /* remaining Time */
GUI_ASSERT_NO_LOCK();
while (tRem = EndTime- GUI_GetTime(), tRem>0) {
GUI_Exec();
GUI_X_Delay((tRem >5) ? 5 : tRem);
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,273 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUITimer.c
Purpose : Supplies timers
----------------------------------------------------------------------
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI_Protected.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define GUI_TIMER_H2P(h) (GUI_TIMER_Obj*)GUI_ALLOC_h2p(h)
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
GUI_TIMER_CALLBACK* cb;
GUI_TIMER_HANDLE hNext;
int Flags;
U32 Context;
GUI_TIMER_TIME t0;
GUI_TIMER_TIME Period;
} GUI_TIMER_Obj;
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
GUI_TIMER_HANDLE hFirstTimer;
GUI_TIMER_HANDLE _hActiveTimer;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _Unlink
*/
static void _Unlink(GUI_TIMER_HANDLE hTimer) {
GUI_TIMER_Obj* pTimer = GUI_TIMER_H2P(hTimer);
GUI_TIMER_HANDLE hi;
GUI_TIMER_Obj* pi;
/* Check if it is the first element */
if (hFirstTimer == hTimer) {
hFirstTimer = pTimer->hNext;
return;
}
hi = hFirstTimer;
/* Try to find it in the list ... */
while(hi) {
/* GUI_ASSERT(hi<1000,0); */
pi = GUI_TIMER_H2P(hi);
if (pi->hNext == hTimer) {
pi->hNext = pTimer->hNext;
break;
}
hi = pi->hNext;
}
}
/*********************************************************************
*
* _Link
*
* Purpose:
* This routine inserts the new timer (referenced by its handle) into
* the linked list. The linked list is sorted according to timestamps.
* The first element is the timer which expires first.
*/
static void _Link(GUI_TIMER_HANDLE hNew) {
GUI_TIMER_Obj* pNew = GUI_TIMER_H2P(hNew);
GUI_TIMER_Obj* pTimer;
GUI_TIMER_Obj* pNext;
GUI_TIMER_HANDLE hNext;
if (hFirstTimer ==0) { /* List is empty, make it the only element */
hFirstTimer = hNew;
pNew->hNext = 0;
} else {
GUI_TIMER_Obj* pFirstTimer = GUI_TIMER_H2P(hFirstTimer);
/* Check if we have to make it the first element */
if ((pNew->t0 - pFirstTimer->t0) <=0) {
pNew->hNext = hFirstTimer;
hFirstTimer = hNew;
return;
} else {
GUI_TIMER_HANDLE hTimer = hFirstTimer;
/* Put it into the list */
do {
pTimer = GUI_TIMER_H2P(hTimer);
hNext = pTimer->hNext;
if (hNext ==0)
goto Append;
pNext = GUI_TIMER_H2P(hNext);
if ((pNew->t0 - pNext->t0) <=0) {
pNew->hNext = hNext;
pTimer->hNext= hNew;
return;
}
} while(1);
/* Put it at the end of the list */
Append:
pNew->hNext = hNext;
pTimer->hNext= hNew;
return;
}
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_TIMER_Exec
*/
int GUI_TIMER_Exec(void) {
int r = 0;
GUI_TIMER_TIME t = GUI_GetTime();
GUI_LOCK(); {
while (hFirstTimer) {
GUI_TIMER_Obj* pTimer = GUI_TIMER_H2P(hFirstTimer);
if ((pTimer->t0-t) <=0) {
GUI_TIMER_MESSAGE tm;
tm.Time = t;
tm.Context = pTimer->Context;
_hActiveTimer = hFirstTimer;
hFirstTimer = pTimer->hNext;
pTimer->cb(&tm);
r = 1;
} else
break;
}
/*
GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
pObj->t0 = Time;
*/
} GUI_UNLOCK();
return r;
}
/*********************************************************************
*
* GUI_TIMER_Create
*/
GUI_TIMER_HANDLE GUI_TIMER_Create(GUI_TIMER_CALLBACK* cb, int Time, U32 Context, int Flags) {
GUI_TIMER_HANDLE hObj;
GUI_TIMER_Obj* pObj;
GUI_LOCK();
GUI_USE_PARA(Flags);
GUI_USE_PARA(Time);
GUI_pfTimerExec = GUI_TIMER_Exec;
{
/* Alloc memory for obj */
hObj = GUI_ALLOC_AllocZero(sizeof(GUI_TIMER_Obj));
pObj = GUI_TIMER_H2P(hObj);
/* init member variables */
pObj->cb = cb;
pObj->Context = Context;
pObj->t0 = Time; //houhh 20061018...
/* Link it */
_Link(hObj);
} GUI_UNLOCK();
return hObj;
}
/*********************************************************************
*
* GUI_TIMER_Delete
*/
void GUI_TIMER_Delete(GUI_TIMER_HANDLE hObj) {
/* Unlink Timer */
GUI_LOCK();
_Unlink(hObj);
GUI_ALLOC_Free(hObj);
GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_TIMER_SetPeriod
*/
void GUI_TIMER_SetPeriod(GUI_TIMER_HANDLE hObj, GUI_TIMER_TIME Period) {
GUI_LOCK(); {
GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
pObj->Period = Period;
} GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_TIMER_SetTime
*/
void GUI_TIMER_SetTime(GUI_TIMER_HANDLE hObj, GUI_TIMER_TIME Time) {
GUI_LOCK(); {
GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
pObj->t0 = Time;
} GUI_UNLOCK();
}
//////
void GUI_TIMER_Context(GUI_TIMER_HANDLE hObj, U32 Context) {
GUI_LOCK(); {
GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
pObj->Context = Context;
} GUI_UNLOCK();
}
//////
/*********************************************************************
*
* GUI_TIMER_SetDelay
*/
void GUI_TIMER_SetDelay(GUI_TIMER_HANDLE hObj, GUI_TIMER_TIME Delay) {
GUI_LOCK(); {
GUI_TIMER_Obj* pObj = GUI_TIMER_H2P(hObj);
pObj->t0 = Delay;
_Unlink(hObj);
_Link(hObj);
} GUI_UNLOCK();
}
/*********************************************************************
*
* GUI_TIMER_Restart
*/
void GUI_TIMER_Restart(GUI_TIMER_HANDLE hObj) {
GUI_TIMER_Obj* pObj;
GUI_LOCK();
{
if (hObj == 0) {
hObj = _hActiveTimer;
}
pObj = GUI_TIMER_H2P(hObj);
pObj->t0 = GUI_GetTime() +pObj->Period;
_Unlink(hObj);
_Link(hObj);
} GUI_UNLOCK();
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,385 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIType.h
Purpose : Include file define the types used for GUI
---------------------------END-OF-HEADER------------------------------
Attention : Do not modify this file ! If you do, you will not
be able do update to a later GUI version !
*/
#ifndef GUITYPE_H_INCLUDED
#define GUITYPE_H_INCLUDED
#include "LCD.h"
#include "GUIConf.h"
/* *************************************************************
* *
* Simple types *
* *
*************************************************************
*/
typedef const char * GUI_ConstString;
/* *************************************************************
* *
* Structures *
* *
*************************************************************
*/
typedef LCD_COLOR GUI_COLOR;
typedef LCD_LOGPALETTE GUI_LOGPALETTE;
typedef LCD_DRAWMODE GUI_DRAWMODE;
typedef LCD_RECT GUI_RECT;
typedef struct {
void (* pfDraw)(int x0,int y0,int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag);
GUI_COLOR (* pfIndex2Color)(int Index);
} GUI_BITMAP_METHODS;
typedef struct {
U16P XSize;
U16P YSize;
U16P BytesPerLine;
U16P BitsPerPixel;
const U8 GUI_UNI_PTR * pData;
const GUI_LOGPALETTE GUI_UNI_PTR * pPal;
const GUI_BITMAP_METHODS * pMethods;
} GUI_BITMAP;
/* This structure may not be changed because the data that it
expects is read in binary form (via any kind of interface,
at runtime).
This structure should therefor not be changed.
*/
typedef struct {
U16 ID; /* Version 1.00 => 100*/
U16 Version;
U16 XSize;
U16 YSize;
U16 BytesPerLine;
U16 BitsPerPixel;
U16 NumColors;
U16 HasTrans;
} GUI_BITMAP_STREAM;
typedef struct {
int x,y;
unsigned char Pressed;
} GUI_PID_STATE;
/*
****************************************
* *
* FONT structures (new in V1.10) *
* *
****************************************
*/
/* Translation list. Translates a character code into up to 2
indices of images to display on top of each other;
'á' -> index('a'), index('´') */
typedef struct {
I16P c0;
I16P c1;
} GUI_FONT_TRANSLIST;
typedef struct {
U16P FirstChar;
U16P LastChar;
const GUI_FONT_TRANSLIST GUI_UNI_PTR * pList;
} GUI_FONT_TRANSINFO;
typedef struct {
U8 XSize;
U8 XDist;
U8 BytesPerLine;
const unsigned char GUI_UNI_PTR * pData;
} GUI_CHARINFO;
typedef struct GUI_FONT_PROP {
U16P First; /* first character */
U16P Last; /* last character */
const GUI_CHARINFO GUI_UNI_PTR * paCharInfo; /* address of first character */
const struct GUI_FONT_PROP GUI_UNI_PTR * pNext; /* pointer to next */
} GUI_FONT_PROP;
typedef struct {
const unsigned char GUI_UNI_PTR * pData;
const U8 GUI_UNI_PTR * pTransData;
const GUI_FONT_TRANSINFO GUI_UNI_PTR * pTrans;
U16P FirstChar;
U16P LastChar;
U8 XSize;
U8 XDist;
U8 BytesPerLine;
} GUI_FONT_MONO;
typedef struct GUI_FONT_INFO {
U16P First; /* first character */
U16P Last; /* last character */
const GUI_CHARINFO* paCharInfo; /* address of first character */
const struct GUI_FONT_INFO* pNext; /* pointer to next */
} GUI_FONT_INFO;
/*
****************************************
* *
* FONT info structure *
* *
****************************************
This structure is used when retrieving information about a font.
It is designed for future expansion without incompatibilities.
*/
typedef struct {
U16 Flags;
U8 Baseline;
U8 LHeight; /* height of a small lower case character (a,x) */
U8 CHeight; /* height of a small upper case character (A,X) */
} GUI_FONTINFO;
#define GUI_FONTINFO_FLAG_PROP (1<<0) /* Is proportional */
#define GUI_FONTINFO_FLAG_MONO (1<<1) /* Is monospaced */
#define GUI_FONTINFO_FLAG_AA (1<<2) /* Is an antialiased font */
#define GUI_FONTINFO_FLAG_AA2 (1<<3) /* Is an antialiased font, 2bpp */
#define GUI_FONTINFO_FLAG_AA4 (1<<4) /* Is an antialiased font, 4bpp */
/**********************************************************************
*
* UNICODE Encoding
*
***********************************************************************
*/
typedef U16 tGUI_GetCharCode(const char GUI_UNI_PTR *s);
typedef int tGUI_GetCharSize(const char GUI_UNI_PTR *s);
typedef int tGUI_CalcSizeOfChar(U16 Char);
typedef int tGUI_Encode(char *s, U16 Char);
typedef struct {
tGUI_GetCharCode* pfGetCharCode;
tGUI_GetCharSize* pfGetCharSize;
tGUI_CalcSizeOfChar* pfCalcSizeOfChar;
tGUI_Encode* pfEncode;
} GUI_UC_ENC_APILIST;
/**********************************************************************
*
* FONT Encoding
*
***********************************************************************
*/
typedef int tGUI_GetLineDistX(const char GUI_UNI_PTR *s, int Len);
typedef int tGUI_GetLineLen(const char GUI_UNI_PTR *s, int MaxLen);
typedef void tGL_DispLine(const char GUI_UNI_PTR *s, int Len);
typedef struct {
tGUI_GetLineDistX* pfGetLineDistX;
tGUI_GetLineLen* pfGetLineLen;
tGL_DispLine* pfDispLine;
} tGUI_ENC_APIList;
extern const tGUI_ENC_APIList GUI_ENC_APIList_SJIS;
/*
****************************************
* *
* FONT methods *
* *
****************************************
The parameter to the methods called pFont should be of type
GUI_FONT, but unfortunately a lot of compilers can not handle
forward declarations right ...
So it ends up to be a void pointer.
*/
typedef struct GUI_FONT GUI_FONT;
typedef void GUI_DISPCHAR(U16 c);
typedef int GUI_GETCHARDISTX(U16P c);
typedef void GUI_GETFONTINFO(const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO * pfi);
typedef char GUI_ISINFONT (const GUI_FONT GUI_UNI_PTR * pFont, U16 c);
#define DECLARE_FONT(Type) \
void GUI##Type##_DispChar (U16P c); \
int GUI##Type##_GetCharDistX(U16P c); \
void GUI##Type##_GetFontInfo (const GUI_FONT GUI_UNI_PTR * pFont, GUI_FONTINFO * pfi); \
char GUI##Type##_IsInFont (const GUI_FONT GUI_UNI_PTR * pFont, U16 c)
#if defined(__cplusplus)
extern "C" { /* Make sure we have C-declarations in C++ programs */
#endif
/* MONO: Monospaced fonts */
DECLARE_FONT(MONO);
#define GUI_FONTTYPE_MONO \
GUIMONO_DispChar, \
GUIMONO_GetCharDistX, \
GUIMONO_GetFontInfo, \
GUIMONO_IsInFont, \
(tGUI_ENC_APIList*)0
/* PROP: Proportional fonts */
DECLARE_FONT(PROP);
#define GUI_FONTTYPE_PROP \
GUIPROP_DispChar, \
GUIPROP_GetCharDistX, \
GUIPROP_GetFontInfo, \
GUIPROP_IsInFont, \
(tGUI_ENC_APIList*)0
/* PROP: Proportional fonts SJIS */
DECLARE_FONT(PROP);
#define GUI_FONTTYPE_PROP_SJIS \
GUIPROP_DispChar, \
GUIPROP_GetCharDistX, \
GUIPROP_GetFontInfo, \
GUIPROP_IsInFont, \
&GUI_ENC_APIList_SJIS
/* PROPAA: Proportional, antialiased fonts */
DECLARE_FONT(PROPAA);
#define GUI_FONTTYPE_PROPAA \
GUIPROPAA_DispChar, \
GUIPROPAA_GetCharDistX, \
GUIPROPAA_GetFontInfo, \
GUIPROPAA_IsInFont, \
(tGUI_ENC_APIList*)0
/* PROPAA: Proportional, antialiased fonts, 2bpp */
DECLARE_FONT(PROP_AA2);
#define GUI_FONTTYPE_PROP_AA2 \
GUIPROP_AA2_DispChar, \
GUIPROP_AA2_GetCharDistX, \
GUIPROP_AA2_GetFontInfo, \
GUIPROP_AA2_IsInFont, \
(tGUI_ENC_APIList*)0
/* PROPAA: Proportional, antialiased fonts, 2bpp, SJIS encoding */
DECLARE_FONT(PROP_AA2);
#define GUI_FONTTYPE_PROP_AA2_SJIS \
GUIPROP_AA2_DispChar, \
GUIPROP_AA2_GetCharDistX, \
GUIPROP_AA2_GetFontInfo, \
GUIPROP_AA2_IsInFont, \
GUI_ENCODE_SJIS
/* PROPAA: Proportional, antialiased fonts, 4bpp */
DECLARE_FONT(PROP_AA4);
#define GUI_FONTTYPE_PROP_AA4 \
GUIPROP_AA4_DispChar, \
GUIPROP_AA4_GetCharDistX, \
GUIPROP_AA4_GetFontInfo, \
GUIPROP_AA4_IsInFont, \
(tGUI_ENC_APIList*)0
/* PROPAA: Proportional, antialiased fonts, 4bpp, SJIS encoding */
DECLARE_FONT(PROP_AA4);
#define GUI_FONTTYPE_PROP_AA4_SJIS \
GUIPROP_AA4_DispChar, \
GUIPROP_AA4_GetCharDistX, \
GUIPROP_AA4_GetFontInfo, \
GUIPROP_AA4_IsInFont, \
GUI_ENCODE_SJIS
#if defined(__cplusplus)
}
#endif
struct GUI_FONT {
GUI_DISPCHAR* pfDispChar;
GUI_GETCHARDISTX* pfGetCharDistX;
GUI_GETFONTINFO* pfGetFontInfo;
GUI_ISINFONT* pfIsInFont;
const tGUI_ENC_APIList* pafEncode;
U8 YSize;
U8 YDist;
char XMag;
char YMag;
union {
const void GUI_UNI_PTR * pFontData;
const GUI_FONT_MONO GUI_UNI_PTR * pMono;
const GUI_FONT_PROP GUI_UNI_PTR * pProp;
} p;
U8 Baseline;
U8 LHeight; /* height of a small lower case character (a,x) */
U8 CHeight; /* height of a small upper case character (A,X) */
};
/*********************************************************************
*
* Position independent font structures
*/
typedef struct {
U32 ID; /* Font file ID */
U16 YSize; /* Height of font */
U16 YDist; /* Space of font Y */
U16 Baseline; /* Index of baseline */
U16 LHeight; /* Height of a small lower case character (a) */
U16 CHeight; /* Height of a upper case character (A) */
U16 NumAreas; /* Number of character areas */
} GUI_SI_FONT;
typedef struct {
U16 First; /* Index of first character */
U16 Last; /* Index of last character */
} GUI_SIF_CHAR_AREA;
typedef struct {
U16 XSize; /* Size of bitmap data in X */
U16 XDist; /* Number of pixels for increment cursor in X */
U16 BytesPerLine; /* Number of bytes per line */
U16 Dummy;
U32 OffData; /* Offset of pixel data */
} GUI_SIF_CHARINFO;
typedef struct tGUI_SIF_APIList_struct {
GUI_DISPCHAR * pDispChar;
GUI_GETCHARDISTX * pGetCharDistX;
GUI_GETFONTINFO * pGetFontInfo;
GUI_ISINFONT * pIsInFont;
} tGUI_SIF_APIList;
#define GUI_SIF_TYPE tGUI_SIF_APIList
#define GUI_SIF_TYPE_PROP &GUI_SIF_APIList_Prop
extern const tGUI_SIF_APIList GUI_SIF_APIList_Prop;
/*
*********************************
* *
* Typedefs *
* *
*********************************
*/
#ifndef GUI_HMEM
#define GUI_HMEM I16P
#endif
#define GUI_HMEM_NULL (0)
typedef GUI_HMEM GUI_HWIN;
#endif /* GUITYPE_H_INCLUDED */
/*************************** End of file ****************************/

View File

@ -0,0 +1,74 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIUC0.C
Purpose : Implementation of character and string services
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include "GUI.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_UC2DB
*
* Purpose:
* Convert Convert UNICODE 16-bit value into double byte version
* - Byte0: First byte, msb
* - Byte1: Last byte, lsb
*/
void GUI_UC2DB(U16 Code, U8* pOut) {
/* move regular ASCII to (unused) 0xE000-0xE0ff area */
if (Code < 0x100) {
if (Code !=0) /* end marker ? */
Code += 0xe000;
} else {
/* If Low byte 0: Move to (unused) 0xE100-0xE1ff area */
if ((Code&0xff) == 0) {
Code = (Code>>8) +0xe100;
}
}
/* Convert into double byte, putting msb first*/
*pOut++ = Code >> 8; /* Save msb first */
*pOut = Code & 0xff;
}
/*********************************************************************
*
* GUI_DB2UC
*
* Purpose:
* Convert Unicode double byte into UNICODE.
* - Byte0: First byte, msb
* - Byte1: Last byte, lsb
*/
U16 GUI_DB2UC(U8 Byte0, U8 Byte1) {
if (Byte0==0)
return 0;
if ((Byte0&0xfe) == 0xe0) {
if (Byte0 == 0xe0) /* ASCII */
return Byte1;
return ((U16)Byte1)<<8; /* low byte was zero */
}
return Byte1 | (((U16)Byte0)<<8);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,111 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* ľC/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 : GUIVAL.C
Purpose : Routines to display values as dec, binary or hex
----------------------------------------------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
#include "string.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_DispDecShift
*/
void GUI_DispDecShift(I32 v, U8 Len, U8 Shift) {
char ac[12];
char* s = ac;
GUI_AddDecShift(v, Len, Shift, &s);
GUI_DispString(ac);
}
/*********************************************************************
*
* GUI_DispSDecShift
*/
void GUI_DispSDecShift(I32 v, U8 Len, U8 Shift) {
char ac[12];
char* s = ac;
v = GUI_AddSign(v, &s);
GUI_AddDecShift(v, --Len, Shift, &s);
GUI_DispString(ac);
}
/*********************************************************************
*
* GUI_DispDecMin
*/
void GUI_DispDecMin(I32 v) {
char ac[12];
char* s = ac;
GUI_AddDecMin(v, &s);
GUI_DispString(ac);
}
/*********************************************************************
*
* GUI_DispDecSpace
*/
void GUI_DispDecSpace(I32 v, U8 MaxDigits) {
char ac[12];
char* s = ac;
U8 Len;
if (v < 0) {
v = GUI_AddSign(v, &s);
MaxDigits--;
}
Len = GUI_Long2Len(v);
while (Len++ < MaxDigits) {
*s++ = ' ';
}
GUI_AddDecMin(v, &s);
GUI_DispString(ac);
}
/*********************************************************************
*
* GUI_DispSDec
*/
void GUI_DispSDec(I32 v, U8 Len) {
GUI_DispSDecShift(v,Len,0);
}
/*********************************************************************
*
* GUI_DispDec
*/
void GUI_DispDec(I32 v, U8 Len) {
GUI_DispDecShift(v, Len,0);
}
/*********************************************************************
*
* GUI_DispDecAt
*/
void GUI_DispDecAt(I32 v, I16P x, I16P y, U8 Len) {
char ac[12];
char* s = ac;
GUI_AddDecShift(v, Len, 0, &s);
GUI_DispStringAt(ac, x, y);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,110 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIValF.C
Purpose : Displaying floating point values
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
#include "math.h"
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _DispFloatFix
*/
static void _DispFloatFix(float f, char Len, char Decs, int DrawPlusSign) {
f *= GUI_Pow10[(unsigned)Decs];
f += 0.5f;
f = (float) floor (f);
if (DrawPlusSign) {
GUI_DispSDecShift((long)f, Len, Decs);
} else {
GUI_DispDecShift((long)f, Len, Decs);
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_DispFloatFix
*/
void GUI_DispFloatFix(float f, char Len, char Decs) {
_DispFloatFix(f, Len, Decs, 0);
}
/*********************************************************************
*
* GUI_DispFloatMin
*/
void GUI_DispFloatMin(float f, char Fract) {
char Len;
Len = GUI_Long2Len((long)f);
if ((f < 0) && (f > -1)) { /* If value < 0 and > -1 (e.g. -0.123) increment length by 1 */
Len++;
}
_DispFloatFix(f, (char)(Len + Fract + (Fract ? 1 : 0)), (char)Fract, 0);
}
/*********************************************************************
*
* GUI_DispFloat
*/
void GUI_DispFloat(float f, char Len) {
int Decs;
Decs = Len - GUI_Long2Len((long)f)-1;
if ((f < 0) && (f > -1)) { /* If value < 0 and > -1 (e.g. -0.123) decrement Decs */
Decs--;
}
if (Decs<0)
Decs =0;
_DispFloatFix(f, Len, (char)Decs, 0);
}
/*********************************************************************
*
* GUI_DispSFloatFix
*/
void GUI_DispSFloatFix(float f, char Len, char Fract) {
_DispFloatFix (f, Len, Fract, 1);
}
/*********************************************************************
*
* GUI_DispSFloatMin
*/
void GUI_DispSFloatMin(float f, char Fract) {
char Len;
Len = GUI_Long2Len((long)f);
if ((f < 0) && (f > -1)) { /* If value < 0 and > -1 (e.g. -0.123) increment length by 1 */
Len++;
}
if (f>0) {
Len++;
}
_DispFloatFix(f, (char)(Len + Fract + (Fract ? 1 : 0)), (char)Fract, 1);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,27 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIVersion.h
Purpose : Include file defining current GUI version
---------------------------END-OF-HEADER------------------------------
*/
#ifndef GUI_VERSION_H
#define GUI_VERSION_H
#define GUI_VERSION 39001
#endif /* Avoid multiple inclusion */
/*************************** End of file ****************************/

View File

@ -0,0 +1,61 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIAlloc.C
Purpose : Dynamic memory management
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <string.h> /* for memcpy, memset */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Internal memory management
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ALLOC_AllocInit
*
* Purpose:
* Alloc memory block of the given size and initialize from the given pointer.
* If the pointer is a NULL pointer, zeroinit
*/
GUI_HMEM GUI_ALLOC_AllocInit(const void *pInitData, GUI_ALLOC_DATATYPE Size) {
GUI_HMEM hMem;
GUI_LOCK();
if (Size == 0) {
return (GUI_HMEM)0;
}
hMem = GUI_ALLOC_AllocNoInit(Size);
if (hMem) {
void *pMem;
pMem = GUI_ALLOC_h2p(hMem);
if (pInitData) {
memcpy(pMem, pInitData, Size);
} else {
GUI_MEMSET((U8*)pMem, 0, Size);
}
}
GUI_UNLOCK();
return hMem;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,49 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUIAlloc.C
Purpose : Dynamic memory management
----------------------------------------------------------------------
*/
#include <stddef.h> /* needed for definition of NULL */
#include <string.h> /* for memcpy, memset */
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Internal memory management
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_ALLOC_AllocZero
*/
GUI_HMEM GUI_ALLOC_AllocZero(GUI_ALLOC_DATATYPE Size) {
GUI_HMEM hMem;
GUI_LOCK();
GUI_DEBUG_LOG2("\nGUI_ALLOC_Alloc... requesting %d, %d avail", Size, GUI_ALLOC_GetMaxSize());
hMem = GUI_ALLOC_AllocNoInit(Size);
if (hMem) {
GUI_MEMSET((U8*)GUI_ALLOC_h2p(hMem), 0, Size); /* Zeroinit ! */
}
GUI_UNLOCK();
return hMem;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,49 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_AddBin.c
Purpose : Converts binary value 2 string
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AddBin
*/
void GUI_AddBin(U32 v, U8 Len, char** ps) {
char *s = *ps;
#if GUI_DEBUG_LEVEL >1
if (Len > 32) {
GUI_DEBUG_WARN("Can not display more than 32 bin. digits");
Len = 32;
}
#endif
(*ps) += Len;
**ps = '\0'; /* Make sure string is 0-terminated */
while(Len--) {
*(s + Len) = (char)('0' + (v & 1));
v >>= 1;
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,38 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_AddDec.c
Purpose : Routines to display values in decimal form
----------------------------------------------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
#include "string.h"
/*********************************************************************
*
* Public routines
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AddDec
*/
void GUI_AddDec(I32 v, U8 Len, char**ps) {
GUI_AddDecShift(v, Len, 0, ps);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,39 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_AddDecMin.c
Purpose : Routines to display values in decimal form
----------------------------------------------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
#include "string.h"
/*********************************************************************
*
* Public routines
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AddDecMin
*/
void GUI_AddDecMin(I32 v, char**ps) {
U8 Len = GUI_Long2Len(v);
GUI_AddDecShift(v, Len, 0, ps);
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,137 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_AddDecShift.c
Purpose : Routines to display values as dec
----------------------------------------------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
#include "string.h"
/*********************************************************************
*
* Public data
*
**********************************************************************
*/
const U32 GUI_Pow10[10] = {
1 , 10, 100, 1000, 10000,
100000, 1000000, 10000000, 100000000, 1000000000
};
/*********************************************************************
*
* Static routines
*
**********************************************************************
*/
/*********************************************************************
*
* _Check_NegLong
*/
static int _Check_NegLong(I32 *pv, char**ps) {
if (*pv < 0) {
*(*ps)++ = '-';
*pv = -*pv;
return 1;
}
return 0;
}
/*********************************************************************
*
* Module internal routines
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_Long2Len
*/
int GUI_Long2Len(I32 vSign) {
int Len = 1;
I32 v = (vSign > 0) ? vSign : -vSign;
while (( ((U32)v) >= GUI_Pow10[Len]) && (Len < 9)) {
Len++;
}
if (vSign < 0) {
Len++;
}
return Len;
}
/*********************************************************************
*
* GUI_AddSign
*/
long GUI_AddSign(long v, char**ps) {
char c;
if (v < 0) {
c = '-';
v = -v;
} else {
c = '+';
}
*(*ps)++ = c;
**ps = '\0';
return v;
}
/*********************************************************************
*
* Public routines
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AddDecShift
*/
void GUI_AddDecShift(I32 v, U8 Len, U8 Shift, char**ps) {
char c;
long d;
#ifndef _CM16C
Len -= _Check_NegLong(&v, ps); /* TASKING: Tool internal error S003: asertion failed - please report */
#else
if (v < 0) {
*(*ps)++ = '-';
v = -v;
}
#endif
if (Shift) {
Len--;
}
#if GUI_DEBUG_LEVEL >1
if (Len > 9) {
Len = 9;
GUI_DEBUG_ERROROUT("Can not display more than 9 dec. digits");
}
#endif
if ((U32)v >= GUI_Pow10[Len])
v = GUI_Pow10[Len] - 1;
while (Len) {
if (Len-- == Shift)
*(*ps)++ = GUI_DecChar;
d = GUI_Pow10[Len];
c = (char) (v / d);
v -= c * d;
*(*ps)++ = c + '0';
}
**ps = 0;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,54 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_AddHex.c
Purpose : Converts hex value 2 string
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static const char acHex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_AddHex
*/
void GUI_AddHex(U32 v, U8 Len, char**ps) {
char *s = *ps;
if (Len > 8) {
return;
}
(*ps) += Len;
**ps = '\0'; /* Make sure string is 0-terminated */
while(Len--) {
*(s + Len) = acHex[v & 15];
v >>= 4;
}
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,40 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_SetKeyMsgHook.c
Purpose : Implementation of GUI_SetKeyMsgHook
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI_Protected.h"
#include "GUIDebug.h"
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_SetKeyMsgHook
*/
GUI_KEY_MSG_HOOK* GUI_SetKeyMsgHook(GUI_KEY_MSG_HOOK* pHook) {
GUI_KEY_MSG_HOOK* r;
r = GUI_pfKeyMsgHook;
GUI_pfKeyMsgHook = pHook;
return r;
}
/*************************** End of file ****************************/

View File

@ -0,0 +1,214 @@
/*
*********************************************************************************************************
* uC/GUI
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* µC/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 : GUI_BMP.c
Purpose : Implementation of GUI_BMP... functions
---------------------------END-OF-HEADER------------------------------
*/
#include <stdlib.h>
#include "GUI_Private.h"
/*********************************************************************
*
* Static functions
*
**********************************************************************
*/
/*********************************************************************
*
* _GetStep
*/
static int _GetStep(int * pYSize, int * pY) {
if (*pYSize > 0) {
*pY = *pYSize - 1;
return -1;
} else if (*pYSize < 0) {
*pYSize = -*pYSize;
*pY = 0;
return 1;
} else {
return 0;
}
}
/*********************************************************************
*
* _DrawBitmap_Pal
*/
static int _DrawBitmap_Pal(const U8 * pData, int x0, int y0, int XSize, int YSize, int Bpp, int NumColors) {
int i, y, Step;
int BytesPerLine = 0;
Step = _GetStep(&YSize, &y);
if (!Step) {
return 1;
}
for (i = 0; i < NumColors; i++) {
U8 r, g, b;
b = *(pData);
g = *(pData + 1);
r = *(pData + 2);
pData += 4;
LCD__aConvTable[i] = LCD_Color2Index(((U32)b << 16) | (g << 8) | r);
}
switch (Bpp) {
case 1:
BytesPerLine = ((XSize + 31) >> 5) << 2;
break;
case 4:
BytesPerLine = (((XSize << 2) + 31) >> 5) << 2;
break;
case 8:
BytesPerLine = ((XSize + 3) >> 2) << 2;
break;
}
for (; (y < YSize) && (y >= 0); y += Step) {
LCD_DrawBitmap(x0, y0 + y, XSize, 1, 1, 1, Bpp, XSize, pData, LCD__aConvTable);
pData += BytesPerLine;
}
return 0;
}
/*********************************************************************
*
* _DrawBitmap_24bpp
*/
static int _DrawBitmap_24bpp(const U8 * pData, int x0, int y0, int XSize, int YSize) {
int x, y, BytesPerLine, Step;
Step = _GetStep(&YSize, &y);
if (!Step) {
return 1;
}
BytesPerLine = ((24 * XSize + 31) >> 5) << 2;
for (; (y < YSize) && (y >= 0); y += Step) {
for (x = 0; x < XSize; x++) {
const U8 * pColor = pData + 3 * x;
U8 r, g, b;
b = *(pColor);
g = *(pColor + 1);
r = *(pColor + 2);
LCD_SetPixelIndex(x0 + x, y0 + y, LCD_Color2Index(((U32)b << 16) | (g << 8) | r));
}
pData += BytesPerLine;
}
return 0;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_BMP_GetXSize
*/
int GUI_BMP_GetXSize(const void * pBMP) {
const U8 * pSrc = (const U8 *)pBMP;
if (!pBMP) {
return 0;
}
pSrc += 18; /* skip rest of BITMAPFILEHEADER */
return GUI__Read32(&pSrc);
}
/*********************************************************************
*
* GUI_BMP_GetYSize
*/
int GUI_BMP_GetYSize(const void * pBMP) {
const U8 * pSrc = (const U8 *)pBMP;
if (!pBMP) {
return 0;
}
pSrc += 22;
return labs((int)GUI__Read32(&pSrc));
}
/*********************************************************************
*
* GUI_BMP_Draw
*/
int GUI_BMP_Draw(const void * pBMP, int x0, int y0) {
#if (GUI_WINSUPPORT)
GUI_RECT r;
#endif
int Ret = 0;
I32 Width, Height;
U16 BitCount, Type;
U32 ClrUsed, Compression;
int NumColors;
const U8 * pSrc = (const U8 *)pBMP;
Type = GUI__Read16(&pSrc); /* get type from BITMAPFILEHEADER */
pSrc += 12; /* skip rest of BITMAPFILEHEADER */
/* get values from BITMAPINFOHEADER */
pSrc += 4;
Width = GUI__Read32(&pSrc);
Height = GUI__Read32(&pSrc);
pSrc += 2;
BitCount = GUI__Read16(&pSrc);
Compression = GUI__Read32(&pSrc);
pSrc += 12;
ClrUsed = GUI__Read32(&pSrc);
pSrc += 4;
/* calculate number of colors */
switch (BitCount) {
case 0: return 1; /* biBitCount = 0 (JPEG format) not supported. Please convert image ! */
case 1: NumColors = 2; break;
case 4: NumColors = 16; break;
case 8: NumColors = 256; break;
case 24: NumColors = 0; break;
default:
return 1; /* biBitCount should be 1, 4, 8 or 24 */
}
if (NumColors && ClrUsed) {
NumColors = ClrUsed;
}
/* check validity of bmp */
if ((NumColors > LCD_MAX_LOG_COLORS) ||
(Type != 0x4d42) || /* 'BM' */
(Compression) || /* only uncompressed bitmaps */
(Width > 1024) ||
(Height > 1024)) {
return 1;
}
/* start output */
GUI_LOCK();
#if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
r.x1 = (r.x0 = x0) + Width - 1;
r.y1 = (r.y0 = y0) + Height - 1;
WM_ITERATE_START(&r) {
#endif
/* Show bitmap */
switch (BitCount) {
case 1:
case 4:
case 8:
Ret = _DrawBitmap_Pal(pSrc, x0, y0, Width, Height, BitCount, NumColors);
break;
case 24:
Ret = _DrawBitmap_24bpp(pSrc, x0, y0, Width, Height);
break;
}
#if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
GUI_UNLOCK();
return Ret;
}
/*************************** End of file ****************************/

Some files were not shown because too many files have changed in this diff Show More