/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: SYSSetPage.c
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: System settings view and set
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: System settings view and set
|
**
|
***************************************************************************/
|
//
|
|
#include "Delay.h"
|
#include <avr/eeprom.h>
|
#include "SYSSetPage.h"
|
#include "AD7843_Driver.h"
|
#include "TFT_Driver.h"
|
#include "MessageBox.h"
|
#include "NRF905_Driver.h"
|
#include "DS1302_Driver.h"
|
#include "AD7843_Driver.h"
|
#include "AdjustValuePage.h"
|
#include "CRC16.h"
|
|
extern SYS_State GB_SYS_State;
|
extern unsigned int ButtonIsBeep __attribute__((section(".eeprom")));
|
extern unsigned int GB_ButtonIsBeep ;
|
extern unsigned int ExtClamprange __attribute__((section(".eeprom"))) ;
|
extern unsigned int GB_ExtClamprange ;
|
#if(SoftLanguage == CN)
|
/*
|
//###################### Çë×¢ÒâÔ¤±àÒëÇø ####################################
|
#if(MashineType == FBO48CT)
|
//---------------------- ´ó×ÖºÅÏÔʾµÄÐòÁкŠ---------------------------
|
const prog_uchar SNText[1][20] =
|
{
|
"SN:YC-FBO-0901-0001"
|
};
|
//---------------------- С×ÖºÅÏÔʾµÄÐòÁкŠ---------------------------
|
const prog_uchar SNTextEx[2][14] =
|
{
|
{28,23,59,34,12,115,15,11,24,115,0,0,0,0,},
|
{115,0,0,0,1,},//SN:YC-FBO-0901-0001
|
};
|
|
#else
|
//---------------------- ´ó×ÖºÅÏÔʾµÄÐòÁкŠ---------------------------
|
const prog_uchar SNText[1][21] =
|
{
|
"SN:YC-IDCE-0901-0001"
|
};
|
//---------------------- С×ÖºÅÏÔʾµÄÐòÁкŠ---------------------------
|
|
const prog_uchar SNTextEx[2][15] =
|
{
|
{28,23,59,34,12,115,18,13,12,14,115,0,0,0,0,},
|
{115,0,0,0,1,},//SN:YC-IDCE-0901-0001
|
};
|
#endif
|
//###################### Çë×¢ÒâÔ¤±àÒëÇø ####################################
|
*/
|
|
const prog_uchar SYSSPText[9][9] =
|
{
|
{160, 161, 164, 94}, //ϵͳÉèÖÃ
|
{162, 163, 59, 101}, //ÈÕÆÚ:
|
{ 64, 65, 59, 101}, //ʱ¼ä:
|
{208, 139, 50, 51, 59}, //¼üÅÌÑ¡Ôñ:
|
{70, 71, 48, 72, 108,59,101},//µ¥ÌåÏÂÏÞµ½:
|
{70, 71, 228, 229, 59, 101}, //µ¥Ìå±àºÅ:
|
{237,238,158,159,186,187,191,192,59},//±¸ÓÃÄ£¿éµØÖ·ÅäÖÃ:
|
};
|
//
|
//--------------------- ÅäÖõ¥ÌåÄ£¿éµØÖ·½á¹ûÐÅÏ¢ ---------------------------
|
const prog_uchar SetModuleAddrResText[3][11] =
|
{
|
{70,71,158,159,186,187,191,192,219,220,137},//µ¥ÌåÄ£¿éµØÖ·ÅäÖóɹ¦!
|
{70,71,158,159,186,187,191,192,221,222,137},//µ¥ÌåÄ£¿éµØÖ·ÅäÖÃʧ°Ü!
|
{143,144,70,71,158,159,221,222,137,101,101},//Á¬½Óµ¥ÌåÄ£¿éʧ°Ü£¡
|
};
|
//
|
//---------------------- µ¥ÌåÏÂÏÞµ½ËùÖ´Ðе͝×÷ÄÚÈÝ ------------------------
|
const prog_uchar SYSParmText[4][2] =
|
{
|
{ 80, 81},//Í£Ö¹
|
{124, 80},//ÔÝÍ£
|
};
|
//
|
//---------------------- ¸Ã½çÃæ°´Å¥Îı¾ ------------------------------------
|
const prog_uchar SYSSPButtonItem[7][2] =
|
{
|
{ 95, 96},//ÐÞ¸Ä
|
{114, 101},//+
|
{115, 101},//-
|
{ 52, 53},//Í˳ö
|
{202, 203},//У׼
|
{ 50, 51},//Ñ¡Ôñ
|
{191, 192},//ÅäÖÃ
|
};
|
//
|
#else
|
const prog_uchar SYSSPText[11][26] =
|
{
|
{106,59,77,78,76,74,69,70,68}, //ϵͳÉèÖÃ10
|
{96,59,78,59,26}, //ÈÕÆÚ:5
|
{94,76,64,72,91,26}, //ʱ¼ä6
|
{112,75,76,59,61,71,64,73,68,64,26}, //¼üÅÌÑ¡Ôñ:11
|
{106,68,67,70,14,73,59,75,76,14,92,103,93,26},//µ¥ÌåÏÂÏÞµ½:14
|
{108,74,76,91,63,14,77,83,64,78,59,14,92,103,93,26}, //µ¥Ìå±àºÅ:16
|
{112,77,78,59,73,74,61,68,78,88,0,59,63,76,64,77},//16
|
{0,0,0,0,0,0,0,0,63,59,78,83,68,70,59,26}, //±¸ÓÃÄ£¿éµØÖ·ÅäÖÃ:16
|
{103,59,73,59,71,26}, //Ƶ¶ÎÑ¡Ôñ¡£6
|
{100,61,79,70,0,75,76,68,0,73,59,66,59,78,68,68,26},//°´¼ü°éËæÉùÒô
|
{96,59,78,83,68,70,0,78,74,70,59,26},//ÍⲿµçÁ÷ǯÁ¿³Ì
|
};
|
//
|
//--------------------- ÅäÖõ¥ÌåÄ£¿éµØÖ·½á¹ûÐÅÏ¢ ---------------------------
|
const prog_uchar SetModuleAddrResText[3][36] =
|
{
|
{96,59,78,83,68,70,79,0,75,76,68,77,61,74,64,73,0,73,74,72,64,76,1},//110,64,73,77,74,76,79
|
//"Module addr config OK!",µ¥ÌåÄ£¿éµØÖ·ÅäÖóɹ¦!23
|
{106,64,0,79,63,59,71,74,77,88,0,75,76,68,77,61,74,68,78,88,0,73,74,72,64,76,0,63,59,78,83,68,70,79,1},//77,64,73,77,74,76,79,1},
|
//"Module addr config failed!",µ¥ÌåÄ£¿éµØÖ·ÅäÖÃʧ°Ü!35
|
{110,64,73,77,74,76,0,46,74,16,0,73,64,0,68,77,75,76,59,61,64,73,1},
|
//"0# wireless module error!",Á¬½Óµ¥ÌåÄ£¿éʧ°Ü£¡23
|
};
|
//
|
//---------------------- µ¥ÌåÏÂÏÞµ½ËùÖ´Ðе͝×÷ÄÚÈÝ ------------------------
|
const prog_uchar SYSParmText[4][12] =
|
{
|
{107,77,78,59,73,74,61,68,78,88},//Í£Ö¹11
|
{108,59,79,67,59,0,0,0,0,0,0}, //ÔÝÍ£11
|
};
|
//
|
//---------------------- ¸Ã½çÃæ°´Å¥Îı¾ ------------------------------------
|
const prog_uchar SYSSPButtonItem[7][8] =
|
{
|
{101,67,72,64,73,68,78,88}, //ÐÞ¸Ä8
|
{11},//+1
|
{13},//-1
|
{94,87,81,74,63}, //Í˳ö5
|
{103,59,71,68,60,76}, //У׼6
|
{94,87,60,74,76}, //Ñ¡Ôñ5
|
{110,74,81,76,59,73}, //ÅäÖÃ6
|
};
|
const prog_uchar buttonbeep[2][4]=
|
{
|
{94,87,70,71}, //¾²Òô
|
{94,70,71,0}, //·äÃù
|
};
|
const prog_uchar SPNumber[] =
|
{
|
"#",//No
|
};
|
#endif
|
//
|
|
static unsigned char (*SYSSPParentPage)(void) = DSPSYSSetPage;
|
static unsigned char (*SYSSPChildPage)(void) = DSPSYSSetPage;
|
static unsigned char TargetModelADDR = 0; //¿Õ°×Ä£¿éËùÅäÖõÄÄ¿±êµØÖ·
|
static unsigned char PassWordTrue = 0; //½øÈëУ׼ËùʹÓõÄÃÜÂëÑéÖ¤
|
static unsigned char SSPModifyItemIndex = 0;//µ±Ç°ÐÞ¸ÄÏîµÄË÷Òý
|
static unsigned char MonomerLowLimitAction = 0;
|
static unsigned char MonomerFreq = 0; //µ¥ÌåÄ£¿éÎÞÏ߯µÂÊÀàÐÍ
|
//static unsigned char DataSaveInterval = 1;
|
|
//-------------------------- ÏÔʾ¸Ã½çÃæ ------------------------------------
|
unsigned char DSPSYSSetPage(void)
|
{
|
DisableCustomInput();
|
if(SYSSPChildPage != GB_SYS_State.CurrentPage)
|
{
|
SYSSPParentPage = GB_SYS_State.CurrentPage; //±£´æ¸¸Ò³ÃæÖ¸Õë
|
}
|
GB_SYS_State.CurrentPage = DSPSYSSetPage;
|
SYSSPChildPage = DSPSYSSetPage;
|
GB_SYS_State.GetInput = GetSYSSetPageButtonDown;
|
SSPModifyItemIndex = 0;
|
|
DSP16x24Str(SYSSPText[0], 9, 16, 24, 16, blue, yellow); //ϵͳÉèÖÃ
|
#if(SoftLanguage == CN)
|
DrawLine(24, 42, 12, 0, blue, white, linebold, 2);
|
#else
|
DrawLine(24, 42, 18, 0, blue, white, linebold, 2);
|
#endif
|
|
// GetAndDSPSN(24, 412, 0); //ÐòÁкÅ
|
|
DSPSYSSetPageText();
|
UpdateSYSSetPageText();
|
|
// DSP24x24Str(SYSSPText[7], 7, 24, 160, 272, blue, white);//Ä£¿éÆðʼµØÖ·:
|
// GetAndDSPModuleStartIndex();
|
// DSP24x24Str(SYSSPText[4], 7, 24, 160, 176, blue, white);//ÔÚÏßµçѹÒì³£:
|
// GetAndDSPMasterADDR();
|
/*
|
DSP24x24Str(SYSSPText[7], 7, 24, 160, 272, blue, white);//Êý¾Ý±£´æ¼ä¸ô:
|
GetAndDspDataSaveInterval();
|
DSP24x24Str(SYSSPText[8], 7, 24, 160, 304, blue, white);//µ¥ÌåÏÂÏÞÊýÁ¿:
|
GetAndDspStopMVolCountSet();
|
*/
|
GetDateTime(&(GB_SYS_State.DateTime));
|
UpdateTimeValue(&(GB_SYS_State.DateTime)); //ÈÕÆÚʱ¼ä
|
|
DrawSYSSPControlButton(); //ÏÔʾ´¥ÃþÆÁ°´Å¥
|
|
return 0;
|
}
|
//
|
|
void DSPSYSSetPageText(void)
|
{
|
if((SSPModifyItemIndex>0) && (SSPModifyItemIndex<=3))
|
DSP16x24Str(SYSSPText[1], 5, 16, 80, 80, white, blue); //ÈÕÆÚ:
|
else DSP16x24Str(SYSSPText[1], 5, 16, 80, 80, blue, green7);
|
|
if((SSPModifyItemIndex>3) && (SSPModifyItemIndex<=6))
|
DSP16x24Str(SYSSPText[2], 6, 16, 80, 112, white, blue);//ʱ¼ä:
|
else DSP16x24Str(SYSSPText[2], 6, 16, 80, 112, blue, green7);//ʱ¼ä:
|
/*
|
if(SSPModifyItemIndex == 7)
|
DSP16x24Str(SYSSPText[3], 11, 16, 80, 144, white, blue);//¼üÅÌÑ¡Ôñ:
|
else DSP16x24Str(SYSSPText[3], 11, 16, 80, 144, blue, green7);//¼üÅÌÑ¡Ôñ:
|
*/
|
|
if(SSPModifyItemIndex == 7)
|
DSP16x24Str(SYSSPText[4], 14, 16, 80, 144, white, blue);//µ¥ÌåÏÂÏÞµ½:
|
else DSP16x24Str(SYSSPText[4], 14, 16,80, 144, blue, green7);//µ¥ÌåÏÂÏÞµ½:
|
|
if(SSPModifyItemIndex == 8)
|
DSP16x24Str(SYSSPText[5], 16, 16, 80, 176, white, blue);//µ¥Ìå±àºÅ:
|
else DSP16x24Str(SYSSPText[5],16, 16, 80, 176, blue, green7);//µ¥Ìå±àºÅ:
|
|
if(SSPModifyItemIndex == 9)
|
{
|
DSP16x24Str(SYSSPText[6], 16, 16, 80, 208, white, blue);//ÐÞ¸ÄÄ£¿éµØÖ·:
|
DSP16x24Str(SYSSPText[7], 16, 16, 80, 232, white, blue);//ÐÞ¸ÄÄ£¿éµØÖ·:
|
}
|
else
|
{
|
DSP16x24Str(SYSSPText[6], 16, 16, 80, 208, blue, green7);//ÐÞ¸ÄÄ£¿éµØÖ·:
|
DSP16x24Str(SYSSPText[7], 16, 16, 80, 232, blue, green7);//ÐÞ¸ÄÄ£¿éµØÖ·:
|
}
|
if(SSPModifyItemIndex == 10)
|
DSP16x24Str(SYSSPText[8], 6, 16, 80, 264, white, blue);//µ¥Ì寵¶Î£º
|
else DSP16x24Str(SYSSPText[8], 6, 16, 80, 264, blue, green7);//µ¥Ì寵¶Î£º
|
if(SSPModifyItemIndex == 11)
|
DSP16x24Str(SYSSPText[9], 17, 16, 80, 296, white, blue);//°´¼üÒô
|
else DSP16x24Str(SYSSPText[9], 17, 16, 80, 296, blue, green7);//°´¼üÒô
|
|
if(SSPModifyItemIndex == 12)
|
DSP16x24Str(SYSSPText[10], 12, 16, 80, 328, white, blue);//µçÁ÷ǯÁ¿³Ì
|
else DSP16x24Str(SYSSPText[10], 12, 16, 80, 328, blue, green7);
|
}
|
//
|
void UpdateSYSSetPageText(void)
|
{
|
UpdateTimeValue(&(GB_SYS_State.DateTime)); //ÈÕÆÚʱ¼ä
|
GetAndDSPKeyboardSel();
|
GetAndDSPMonomerLimitAction();
|
GetAndDSPMonomerOrder();
|
GetAndDSPModuleADDR(TargetModelADDR);
|
GetAndDspMonomerFreq();
|
SetButtonIsBeep(GetButtonIsBeep(1));
|
SetExtClamprange(GetExtClamprange(1));
|
}
|
//
|
|
/*
|
//--------------------------- Êý¾Ý²É¼¯¼ä¸ô ---------------------------------
|
unsigned char GetDataSaveInterval(void)
|
{
|
return DataSaveInterval;
|
}
|
void GetAndDspDataSaveInterval(void)
|
{
|
PrintValue(2, 0, DataSaveInterval, "M", 16, 328, 272, blue, yellow); //XXXM
|
}
|
void SetDataSaveInterval(const unsigned char value)
|
{
|
if(value == 0)
|
{
|
if(DataSaveInterval < 99)
|
{
|
DataSaveInterval++;
|
return;
|
}
|
}
|
else
|
{
|
if(DataSaveInterval > 1)
|
{
|
DataSaveInterval--;
|
return;
|
}
|
}
|
BuzzerBeep(50);
|
}
|
*/
|
//
|
|
/*
|
//###################### Çë×¢ÒâÔ¤±àÒëÇø ####################################
|
#if(MashineType == FBO48CT)
|
//-------------------------- ÏÔʾ±¾»úÐòÁкŠ--------------------------------
|
void GetAndDSPSN(const unsigned int x, const unsigned int y, const unsigned char type)
|
{
|
unsigned long sn;
|
unsigned long *psn = (unsigned long *)0x0ffc;
|
eeprom_busy_wait();
|
eeprom_read_block(&sn, psn, sizeof(sn));
|
if(sn == 0xFFFFFFFF)
|
{
|
sn = 0;
|
}
|
if(type == 0)//ÏÔʾ´ó×ֺŵÄÐòÁкÅ
|
{
|
DSP16x24Str(SNText[0], 19, 16, x, y, blue, yellow);//SN
|
PrintValue(1, 0, (unsigned int)(sn>>16), "", 16, x+160, y, blue, yellow); //
|
PrintValue(1, 0, (unsigned int)(sn), "", 16, x+240, y, blue, yellow); //
|
}
|
else //ÏÔʾС×ֺŵÄÐòÁкÅ
|
{
|
#if(SoftLanguage == CN)
|
DSP24x24Str(SNTextEx[0], 14, 12, x, y, blue, white);//SN
|
PrintValueEx(1, 0, (unsigned int)(sn>>16), 12, x+120, y, blue, white);
|
DSP24x24Str(SNTextEx[1], 5, 12, x+168, y, blue, white);//SN
|
PrintValueEx(1, 0, (unsigned int)(sn), 12, x+180, y, blue, white);
|
#else
|
// DSP24x24Str(SNTextEx, 14, 12, x, y, blue, white);//SN
|
#endif
|
}
|
}
|
//
|
#else
|
//-------------------------- ÏÔʾ±¾»úÐòÁкŠ--------------------------------
|
void GetAndDSPSN(const unsigned int x, const unsigned int y, const unsigned char type)
|
{
|
unsigned long sn;
|
unsigned long *psn = (unsigned long *)0x0ffc;
|
eeprom_busy_wait();
|
eeprom_read_block(&sn, psn, sizeof(sn));
|
if(sn == 0xFFFFFFFF)
|
{
|
sn = 0;
|
}
|
if(type == 0)//ÏÔʾ´ó×ֺŵÄÐòÁкÅ
|
{
|
DSP16x24Str(SNText[0], 20, 16, x, y, blue, yellow);//SN
|
PrintValue(1, 0, (unsigned int)(sn>>16), "", 16, x+176, y, blue, yellow); //
|
PrintValue(1, 0, (unsigned int)(sn), "", 16, x+256, y, blue, yellow); //
|
}
|
else //ÏÔʾС×ֺŵÄÐòÁкÅ
|
{
|
#if(SoftLanguage == CN)
|
DSP24x24Str(SNTextEx[0], 15, 12, x, y, blue, white);//SN
|
PrintValueEx(1, 0, (unsigned int)(sn>>16), 12, x+132, y, blue, white);
|
DSP24x24Str(SNTextEx[1], 5, 12, x+180, y, blue, white);//SN
|
PrintValueEx(1, 0, (unsigned int)(sn), 12, x+192, y, blue, white);
|
#else
|
// DSP24x24Str(SNTextEx, 14, 12, x, y, blue, white);//SN
|
#endif
|
}
|
}
|
#endif
|
//###################### Çë×¢ÒâÔ¤±àÒëÇø ####################################
|
*/
|
//
|
|
//------------------------ ÉèÖÃϵͳµÄÈÕÆÚʱ¼ä ------------------------------
|
void SetTimeValue(Date_Time *time, const unsigned char index, const unsigned char settype)
|
{
|
if(settype == 0)//Ö´ÐмӲÙ×÷
|
{
|
switch(index)
|
{
|
case 3: if(++time->year > 99)
|
time->year = 0;
|
break;
|
case 2: if(++time->month > 12)
|
time->month = 1;
|
break;
|
case 1: if(++time->day > 31)
|
time->day = 1;
|
break;
|
case 4: if(++time->hour > 23)
|
time->hour = 0;
|
break;
|
case 5: if(++time->minute > 59)
|
time->minute = 0;
|
break;
|
case 6: if(++time->second > 59)
|
time->second = 0;
|
break;
|
default:break;
|
}
|
}
|
else //Ö´Ðмõ²Ù×÷
|
{
|
switch(index)
|
{
|
case 3: if(time->year-- == 0)
|
time->year = 99;
|
break;
|
case 2: if(time->month-- == 1)
|
time->month = 12;
|
break;
|
case 1: if(time->day-- == 1)
|
time->day = 31;
|
break;
|
case 4: if(time->hour-- == 0)
|
time->hour = 23;
|
break;
|
case 5: if(time->minute-- == 0)
|
time->minute = 59;
|
break;
|
case 6: if(time->second-- == 0)
|
time->second = 59;
|
break;
|
default:break;
|
}
|
}
|
}
|
//-------------------------- ¸üÐÂÏÔʾϵͳµÄÈÕÆÚʱ¼ä ------------------------
|
void UpdateTimeValue(const Date_Time *time)
|
{
|
PrintTime(time, '-', YYMD, 232, 80, blue, white);
|
PrintTime(time, ':', YMD_HMS, 232, 112, blue, white);
|
//--------------- ¸ù¾ÝÊäÈëµÄ(ÄêÔÂ)ÃÜÂëÏÔʾ"У׼"µÄ״̬ -----------------
|
if((time->year==99) && (time->month==12) && (PassWordTrue==0))
|
{
|
PassWordTrue = 1;
|
DrawButtonH48(2, SYSSPButtonItem[4], 6, 14, 2, 524, 306, gray1, white); //У׼
|
}
|
else if((PassWordTrue==1) && ((time->year!=99)||(time->month!=12)))
|
{
|
PassWordTrue = 0;
|
DrawButtonH48(2, SYSSPButtonItem[4], 6, 14, 2, 524, 306, gray1, gray2); //У׼
|
}
|
}
|
//
|
//--------------------------------------------------------------------------------------------------
|
//-------------------------- ¸ü¸ÄÎÞÏßµ¥ÌåÄ£¿éƵ¶Î --------------------------
|
void GetAndDspMonomerFreq(void)
|
{
|
PrintValue(3, 0, MonomerFreq+1, "FM", 16, 200, 264, blue, white);
|
}
|
void SetMonomerFreq(const unsigned char value)
|
{
|
if(value == 0)
|
{
|
if(MonomerFreq < 3)
|
MonomerFreq++;
|
}
|
else
|
{
|
if(MonomerFreq > 0)
|
MonomerFreq--;
|
}
|
|
switch(MonomerFreq)
|
{
|
case 0: Set905Fre(0x6B); break; //433.1M
|
case 1: Set905Fre(0x6E); break; //433.4M
|
case 2: Set905Fre(0x72); break; //433.8M
|
case 3: Set905Fre(0x76); break; //434.2M
|
}
|
|
Write_Config905();
|
BuzzerBeep(50);
|
}
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%ÒÔÉÏ¶àÆµ¶Î%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//
|
//----------------------- ÏÔʾÐèÅäÖõÄÄ¿±êÄ£¿éµØÖ· -------------------------
|
void GetAndDSPModuleADDR(const unsigned char addr)
|
{
|
PrintValue(2, 0, addr, " ", 16, 380, 232, blue, white); //XXX#
|
DSP24x24Str(SPNumber, 10, 16, 345, 232, blue, white);//NO
|
}
|
//----------------------- ÉèÖÃÐèÅäÖõÄÄ¿±êÄ£¿éµØÖ· ---------------------------------
|
void SetModelADDR(unsigned char settype)
|
{
|
if(settype == 0)
|
{
|
if(++TargetModelADDR > 254)
|
TargetModelADDR = 0;
|
}
|
else
|
{
|
if(TargetModelADDR > 0)
|
{
|
TargetModelADDR--;
|
}
|
else
|
{
|
TargetModelADDR = 254;
|
}
|
}
|
}
|
//--------------------- Ö´Ðпհ×Ä£¿éµØÖ·ÅäÖà -------------------------------
|
void ExeModelADDRModification(const unsigned char addr)
|
{
|
unsigned char TX_ADDR[4] = {0xAB,0xCD,0x00,0x00};//slave addr
|
RFData m_RFDataTX,m_RFDataRX;
|
unsigned char error;
|
unsigned int crc;
|
|
m_RFDataTX.Addr[0] = 0xAB;
|
m_RFDataTX.Addr[1] = 0xCD;
|
m_RFDataTX.Addr[2] = 0xFF;
|
m_RFDataTX.Addr[3] = 0xF0;
|
m_RFDataTX.CMD = 0x00A2;
|
|
m_RFDataTX.VolData[0] = 0xCDAB;
|
m_RFDataTX.VolData[1] = (addr<<8);
|
m_RFDataTX.VolData[2] = 0;
|
m_RFDataTX.VolData[3] = 0;
|
|
error = ExchangeMonomerData(TX_ADDR, &m_RFDataTX, &m_RFDataRX);
|
|
crc = CalCRC16(&m_RFDataRX, sizeof(RFData)-2);
|
if((crc == m_RFDataRX.CRC) && ((m_RFDataRX.Addr[3])==TargetModelADDR))
|
{
|
error = 0;
|
}
|
else
|
{
|
error = 1;
|
}
|
|
//-------------------- ÏÔʾµ¥ÌåÄ£¿éµØÖ·ÅäÖýá¹û ------------------------
|
SYSSPChildPage = DSPMessageBoxNull;
|
if(error > 0)
|
{
|
BuzzerBeep(500);
|
}
|
if(error <= 1)
|
{
|
if(error == 0)
|
DSPMessageBox(SetModuleAddrResText[error], 23, MB_OK, BeepNull);
|
else
|
DSPMessageBox(SetModuleAddrResText[error], 35, MB_OK, BeepNull);
|
}
|
else
|
DSPMessageBox(SetModuleAddrResText[error], 23, MB_OK, BeepNull);
|
}
|
//
|
|
//-------------------ÉèÖð´¼üÒô¡ª¡ª---------------------------------------------------------
|
void SetButtonIsBeep(unsigned int state)
|
{
|
GB_ButtonIsBeep = state;
|
eeprom_busy_wait();
|
eeprom_write_word(&ButtonIsBeep,GB_ButtonIsBeep);
|
eeprom_busy_wait();
|
GB_ButtonIsBeep = eeprom_read_word(&ButtonIsBeep);
|
if(GB_ButtonIsBeep == BeepDisWork)
|
DSP16x24Str(buttonbeep[0], 4, 16, 368, 296, blue, white);//°´¼üÒô
|
else
|
DSP16x24Str(buttonbeep[1], 4, 16, 368, 296, blue, white);//°´¼üÒô
|
}
|
unsigned int GetButtonIsBeep(unsigned char isread)
|
{
|
if(isread == 1)
|
{
|
eeprom_busy_wait();
|
GB_ButtonIsBeep = eeprom_read_word(&ButtonIsBeep);
|
}
|
|
return GB_ButtonIsBeep;
|
}
|
//-------------------ÉèÖÃÍⲿµçÁ÷ǯÁ¿³Ì¡ª---------------------------------------------------------
|
void SetExtClamprange(unsigned int rang)
|
{
|
switch(rang)
|
{
|
case 0 :
|
if(GB_ExtClamprange == 100)
|
GB_ExtClamprange = 200;
|
else if(GB_ExtClamprange == 200)
|
GB_ExtClamprange = 600;
|
break;
|
case 1 :
|
if(GB_ExtClamprange == 600)
|
GB_ExtClamprange = 200;
|
else if(GB_ExtClamprange == 200)
|
GB_ExtClamprange = 100;
|
break;
|
default: GB_ExtClamprange = rang;
|
break;
|
}
|
eeprom_busy_wait();
|
eeprom_write_word(&ExtClamprange,GB_ExtClamprange);
|
eeprom_busy_wait();
|
GB_ExtClamprange = eeprom_read_word(&ExtClamprange);
|
|
PrintValue(2, 0, GB_ExtClamprange, "A", 16, 288, 328, blue, white);
|
}
|
unsigned int GetExtClamprange(unsigned char isread)
|
{
|
if(isread == 1)
|
{
|
eeprom_busy_wait();
|
GB_ExtClamprange = eeprom_read_word(&ExtClamprange);
|
}
|
|
return GB_ExtClamprange;
|
}
|
//----------------- ÉèÖúÍÏÔʾµ¥ÌåÏÔÏÖµ½ËùÖ´Ðе͝×÷ -----------------------
|
void GetAndDSPMonomerLimitAction(void)
|
{
|
DSP16x24Str(SYSParmText[MonomerLowLimitAction], 11, 14, 345, 144, blue, white);//
|
}
|
unsigned char GetMonomerLowLimitAction(void)
|
{
|
return MonomerLowLimitAction;
|
}
|
void SetAndUpdateMonomerLimitAction(void)
|
{
|
if(MonomerLowLimitAction == 0)
|
MonomerLowLimitAction = 1;
|
else MonomerLowLimitAction = 0;
|
}
|
//
|
|
//----------------------- ÏÔʾ¸Ã½çÃæÀïµÄ°´Å¥ -------------------------------
|
void DrawSYSSPControlButton(void)
|
{
|
unsigned char fcl;
|
|
if(SSPModifyItemIndex == 0)
|
{
|
fcl = gray2;
|
DrawButtonH481(2, SYSSPButtonItem[0], 8, 11, 2, 524, 48, gray1, white); //ÐÞ¸Ä
|
}
|
else
|
{
|
fcl = white;
|
DrawButtonH48(2, SYSSPButtonItem[5], 5, 14, 12, 524, 48, gray1, white); //Ñ¡Ôñ
|
}
|
|
if((SSPModifyItemIndex==9) && (TargetModelADDR!=0))
|
{
|
DrawButtonH48(2, SYSSPButtonItem[6], 6, 14, 3, 399, 400, gray1, white);//ÅäÖÃ
|
}
|
else
|
{
|
DrawButtonH48(2, SYSSPButtonItem[6], 6, 14, 3, 399, 400, gray1, gray2);//ÅäÖÃ
|
}
|
|
DrawButtonH48(2, SYSSPButtonItem[1], 1, 30, 40, 524, 134, gray1, fcl);//+
|
DrawButtonH48(2, SYSSPButtonItem[2], 1, 30, 40, 524, 220, gray1, fcl);//-
|
DrawButtonH48(2, SYSSPButtonItem[3], 5, 14, 10, 524, 400, gray1, red); //Í˳ö
|
|
if((GB_SYS_State.DateTime.year==99) && (GB_SYS_State.DateTime.month==12))
|
{
|
DrawButtonH48(2, SYSSPButtonItem[4],6, 14, 2, 524, 306, gray1, white);//У׼
|
}
|
else
|
{
|
DrawButtonH48(2, SYSSPButtonItem[4],6, 14, 2, 524, 306, gray1, gray2);//У׼
|
}
|
}
|
//
|
|
//------------------------- »æÖƸ÷ÏîÄ¿µÄÏ»®Ïß -----------------------------
|
void DrawTimeSetUnderLine(const unsigned char index)
|
{
|
DrawLine(232, 106, 20, 0, blue, blue, linebold, 4);
|
DrawLine(232, 138, 20, 0, blue, blue, linebold, 4);
|
|
if((index>0) && (index<3))
|
{
|
DrawLine(184+48*index, 106, 4, 0, blue, green7, linebold, 4);
|
}
|
else if(index == 3)
|
{
|
DrawLine(184+48*3+32, 106, 4, 0, blue, green7, linebold, 4);
|
}
|
else if((index>3) && (index<=6))
|
{
|
DrawLine(184+48*(index-3), 138, 4, 0, blue, green7, linebold, 4);
|
}
|
}
|
//
|
|
//--------------------- »ñÈ¡²¢´¦Àí¼üÅÌ»ò´¥ÃþÆÁµÄÊäÈë -----------------------
|
void GetSYSSetPageButtonDown(void)
|
{
|
static unsigned char lastkey = ButtonNull;
|
static unsigned char getlastkeycount = 0;
|
static unsigned char count = 0;
|
unsigned char touched_item;
|
|
if(count++ % 32 == 0)
|
{
|
GetDateTime(&(GB_SYS_State.DateTime));
|
UpdateTimeValue(&(GB_SYS_State.DateTime));
|
}
|
|
touched_item = GetTouchLocal();
|
if(touched_item == ButtonNull)//Èç¹û°´¼üΪ¿ÕÔòÖ±½Ó·µ»Ø;
|
{
|
lastkey = ButtonNull;
|
getlastkeycount = 0;
|
return;
|
}
|
else if(touched_item != lastkey)
|
{
|
getlastkeycount = 0;
|
}
|
lastkey = touched_item;
|
if(getlastkeycount<60)
|
getlastkeycount++;
|
|
//---------------- "ÐÞ¸Ä"¼ü --------------------------------------------
|
if(touched_item == Button8)
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
SSPModifyItemIndex++;
|
if(SSPModifyItemIndex >= 13)
|
SSPModifyItemIndex = 0;
|
DrawTimeSetUnderLine(SSPModifyItemIndex);
|
DSPSYSSetPageText();
|
DrawSYSSPControlButton();
|
_delay_ms(100);
|
}
|
//---------------- "+1"¼ü -----------------------------------------------
|
else if((touched_item==Button7) && (SSPModifyItemIndex>0))
|
{
|
if(getlastkeycount == 1)
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
}
|
//------------------ ÉèÖÃϵͳʱ¼äÈÕÆÚ ------------------
|
if((SSPModifyItemIndex>0) && (SSPModifyItemIndex<=6))
|
{
|
if((getlastkeycount == 1) || (getlastkeycount>=50))
|
{
|
SetTimeValue(&(GB_SYS_State.DateTime), SSPModifyItemIndex, 0);
|
SetDateTime(&(GB_SYS_State.DateTime));
|
UpdateTimeValue(&(GB_SYS_State.DateTime));
|
_delay_ms(20);
|
}
|
}
|
//------------- ÊäÈ뷽ʽѡÔñ(¼üÅÌ»ò´¥ÃþÆÁ) -------------
|
/*
|
else if(SSPModifyItemIndex == 7)
|
{
|
SetKeyboardSel(0);
|
GetAndDSPKeyboardSel();
|
_delay_ms(100);
|
}*/
|
//------ ÉèÖõ¥ÌåÏÂÏÞµ½ËùÒªÖ´Ðе͝×÷(ÔÝÍ£»òÍ£Ö¹) ------
|
else if(SSPModifyItemIndex == 7)
|
{
|
SetAndUpdateMonomerLimitAction();
|
GetAndDSPMonomerLimitAction();
|
_delay_ms(100);
|
}
|
//--------- ÉèÖõ¥ÌåÄ£¿éµÄµç³ØÐòºÅ(ÉýÐò»ò½µÐò) ---------
|
else if(SSPModifyItemIndex == 8)
|
{
|
SetMonomerOrder();
|
GetAndDSPMonomerOrder();
|
_delay_ms(100);
|
}
|
//--------- ÅäÖÿհ׵¥ÌåÄ£¿éµØÖ· -----------------------
|
else if(SSPModifyItemIndex == 9)
|
{
|
SetModelADDR(0);
|
GetAndDSPModuleADDR(TargetModelADDR);
|
DrawSYSSPControlButton();
|
_delay_ms(50);
|
}
|
//--------------ÉèÖõ¥Ì寵¶Î -------------------------
|
else if(SSPModifyItemIndex == 10)
|
{
|
SetMonomerFreq(0);
|
GetAndDspMonomerFreq();
|
_delay_ms(100);
|
}
|
//--------------ÉèÖð´¼üÒô-------------------------
|
else if(SSPModifyItemIndex == 11)
|
{
|
SetButtonIsBeep(BeepDisWork);
|
_delay_ms(100);
|
}
|
//--------------ÉèÖÃÍⲿµçÁ÷ǯÁ¿³Ì-------------------------
|
else if(SSPModifyItemIndex == 12)
|
{
|
SetExtClamprange(0);
|
_delay_ms(100);
|
}
|
/*--------------- µ¥ÌåÏÂÏÞÊýÁ¿ -------------------------
|
else if(SSPModifyItemIndex == 12)
|
{
|
SetStopMVolCountSet(0);
|
GetAndDspStopMVolCountSet();
|
_delay_ms(50);
|
}
|
*/
|
}
|
//------------------ "-1"¼ü ---------------------------------------------
|
else if((touched_item==Button6) && (SSPModifyItemIndex>0))
|
{
|
if(getlastkeycount == 1)
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
}
|
//------------------ ÉèÖÃϵͳʱ¼äÈÕÆÚ ------------------
|
if((SSPModifyItemIndex > 0) && (SSPModifyItemIndex<=6))
|
{
|
if((getlastkeycount==1) || (getlastkeycount>=50))
|
{
|
SetTimeValue(&(GB_SYS_State.DateTime), SSPModifyItemIndex, 1);
|
SetDateTime(&(GB_SYS_State.DateTime));
|
UpdateTimeValue(&(GB_SYS_State.DateTime));
|
_delay_ms(20);
|
}
|
}
|
//------------- ÊäÈ뷽ʽѡÔñ(¼üÅÌ»ò´¥ÃþÆÁ) -------------
|
/*
|
else if(SSPModifyItemIndex == 7)
|
{
|
SetKeyboardSel(1);
|
GetAndDSPKeyboardSel();
|
_delay_ms(100);
|
}*/
|
//------ ÉèÖõ¥ÌåÏÂÏÞµ½ËùÒªÖ´Ðе͝×÷(ÔÝÍ£»òÍ£Ö¹) ------
|
else if(SSPModifyItemIndex == 7)
|
{
|
SetAndUpdateMonomerLimitAction();
|
GetAndDSPMonomerLimitAction();
|
_delay_ms(100);
|
}
|
//--------- ÉèÖõ¥ÌåÄ£¿éµÄµç³ØÐòºÅ(ÉýÐò»ò½µÐò) ---------
|
else if(SSPModifyItemIndex == 8)
|
{
|
SetMonomerOrder();
|
GetAndDSPMonomerOrder();
|
_delay_ms(100);
|
}
|
//--------- ÅäÖÿհ׵¥ÌåÄ£¿éµØÖ· -----------------------
|
else if(SSPModifyItemIndex == 9)
|
{
|
SetModelADDR(1);
|
GetAndDSPModuleADDR(TargetModelADDR);
|
DrawSYSSPControlButton();
|
_delay_ms(50);
|
}
|
//--------------- µ¥Ì寵¶ÎÉèÖÃ-------------------------
|
else if(SSPModifyItemIndex == 10)
|
{
|
SetMonomerFreq(1);
|
GetAndDspMonomerFreq();
|
_delay_ms(100);
|
}
|
//--------------ÉèÖð´¼üÒô-------------------------
|
else if(SSPModifyItemIndex == 11)
|
{
|
SetButtonIsBeep(BeepIsWork);
|
_delay_ms(100);
|
}
|
//--------------ÉèÖÃÍⲿµçÁ÷ǯÁ¿³Ì-------------------------
|
else if(SSPModifyItemIndex == 12)
|
{
|
SetExtClamprange(1);
|
_delay_ms(100);
|
}
|
/*--------------- µ¥ÌåÏÂÏÞÊýÁ¿ -------------------------
|
else if(SSPModifyItemIndex == 12)
|
{
|
SetStopMVolCountSet(1);
|
GetAndDspStopMVolCountSet();
|
_delay_ms(50);
|
}
|
*/
|
}
|
//------------------ "Í˳ö"¼ü ------------------------------------------
|
else if(touched_item == Button4)
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
BackColorCH();
|
SYSSPParentPage();
|
SYSSPParentPage = DSPSYSSetPage;//»Ö¸´¸¸Ò³ÃæÖ¸ÕëΪ×Ô¼ºµÄÒ³Ãæ
|
}
|
//------------------ "У׼"¼ü ------------------------------------------
|
else if((touched_item==Button5) && (PassWordTrue==1))
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
SYSSPChildPage = DSPAdjVPage;
|
BackColorCH();
|
SYSSPChildPage();
|
}
|
//------------------ "ÅäÖÃ"¼ü ------------------------------------------
|
else if((touched_item==Button3) && (SSPModifyItemIndex==9) && (TargetModelADDR!=0))
|
{
|
if(GetButtonIsBeep(0) == BeepIsWork)
|
BuzzerBeep(100);
|
ExeModelADDRModification(TargetModelADDR);
|
}
|
}
|
//
|
|
/********************** END OF FILE (SYSSetPage.c)*************************/
|