#include "includes.h" #include "hook.h" //////////低功耗控制钩子功能///////////////////// unsigned int pwrSaveTick; unsigned char sendEnableNow=0; unsigned char QueryTime=10;//查询时间 QueryTime/2 unsigned char QueryTick=0;//查询时间计时 ASSIST_DEF uiAssist; void enableDataSend(void) { //此刻可以发GPS数据啦,我们让接下来2秒内可以发心跳或GPS位置包,我们只限制这两个就好了 uTimerStart(&pwrSaveTick,200); sendEnableNow=1; SlwTrace(INF, "Send enable",1); } char isSendDataEnable(void) { if(hgs_poc_type == POC_BND) return 1;//西安POC的话,就一直返回yes,不存在低功耗操作 if(newPara.pwrMode == 1) return 1;//常规模式就一直返回yes if(sendEnableNow==0) return 0; else return 1; } void powerSaveHandle(void) { if(sendEnableNow==0) return; if(uTimerExpired(&pwrSaveTick)==0) return; //未超时返回 sendEnableNow=0; SlwTrace(INF, "Send disable",1); } void SwitchGroupCtrl(void) { if(m_GroupSwitch) { if(++m_GroupSwitchCnt >=5) { //MeSpeak(ENCODE_ASCII, "CDCBB3F6", 0); if(sutUIstatus.Status == UIS_STANDBY) ShowButton(1,107,"菜单"); m_GroupSwitch=0; SlwTrace(INF, "QuitGroupSel",1); } } } void SwitchGroupPre(void) { //让菜单变成:确定 ShowButton(1,107,"确定"); m_GroupSwitch=1; m_GroupSwitchCnt=0; } void SwitchVoicePre(char type) { char buf[20]; //GuiDrawRect(29,110,128,126,1); GuiClearRect(29,110,90,126); switch(m_VoiceStep) { case 0: m_VoiceStep=1; break; case 1: if(type) { if(newPara.VolumLv<8&&(hgs_poc_type==POC_OWN))newPara.VolumLv++; if(newPara.VolumLv<9&&(hgs_poc_type==POC_BND))newPara.VolumLv++; }else{ if(newPara.VolumLv>0){ newPara.VolumLv--; // if(m_VoiceSwitchCnt<=2)GuiFillRect(29+1+newPara.VolumLv*10,110+1,127,126-1,COLOR_WHITE_BACK); // printf("newPara.VolumLv===%d\r\n",newPara.VolumLv); } } break; } //GuiFillRect(29,110+1,29+newPara.VolumLv*10-1,126-1,COLOR_BLUE); GuiShowBmp(29,110,"volume.bmp"); snprintf(buf,sizeof(buf),"音量 %d",newPara.VolumLv); GuiShowStr(45,110,buf,1,0); snprintf(buf,sizeof(buf),"AT+CLVL=%d\r\n",newPara.VolumLv*10); ModemSendAt(buf); if(hgs_poc_type==POC_OWN){ snprintf(buf,sizeof(buf),"AT+CRSL=%d\r\n",newPara.VolumLv*10); ModemSendAt(buf); }else { if(newPara.KeySound!=0){ snprintf(buf,sizeof(buf),"AT+POC=tonevol=%d\r\n",newPara.VolumLv); ModemSendAt(buf); } snprintf(buf,sizeof(buf),"AT+POC=ttsvol=%d\r\n",(newPara.VolumLv)); ModemSendAt(buf); } m_VoiceSwitch=1; m_VoiceSwitchCnt=0; } void SwitchVoiceCtrl(void) { if(m_VoiceSwitch) { if(++m_VoiceSwitchCnt >=2) { if(sutUIstatus.Status == UIS_STANDBY){ //GuiClearRect(29,110,128,126);//GuiDrawRect(29,50+50,128,66+50,1); GuiClearRect(29,110,90,126); ModifyConfigureFile(0); m_VoiceSwitch=0; m_VoiceStep=0; SlwTrace(INF, "QuitVoiceSel",1); } } } } void SpeakerLvlProcess(char update) { char buf[30]; static char lastVolum=0; static char ChangeFlag=0; static short cnt=0; short tempVbat; char i; //0 1 2 3 4 5 6 7 8 9 const short tempVbatArr[10]={0,5,17,27,34,48,122,180,220,280}; char Coe=8; //newPara.VolumLv=(GetPowerVbat()/30);//0~300 tempVbat=GetPowerVbat(); for(i=0;i<10;i++) { if(tempVbat>=tempVbatArr[i])newPara.VolumLv=i; if(newPara.VolumLv<5)Coe=12; else Coe=8; } if(update) goto SETLVL; // printf("VolumLv=====%d\r\n",newPara.VolumLv); if(lastVolum!=newPara.VolumLv){ lastVolum=newPara.VolumLv; ChangeFlag=1; cnt=0; } if(ChangeFlag){ if(cnt++<10)return; SETLVL: snprintf(buf,sizeof(buf),"音量 %d",newPara.VolumLv); printf(buf); snprintf(buf,sizeof(buf),"AT+CLVL=%d\r\n",newPara.VolumLv*Coe);//10 ModemSendAt(buf); if(hgs_poc_type==POC_OWN){ snprintf(buf,sizeof(buf),"AT+CRSL=%d\r\n",newPara.VolumLv*10);//10 ModemSendAt(buf); }else { if(newPara.KeySound!=0){ snprintf(buf,sizeof(buf),"AT+POC=tonevol=%d\r\n",newPara.VolumLv); ModemSendAt(buf); } snprintf(buf,sizeof(buf),"AT+POC=ttsvol=%d\r\n",(newPara.VolumLv)); ModemSendAt(buf); } ChangeFlag=0; cnt=0; } } void HeadsetProcess(char type) { static signed char HeadsetStatue=0; static signed char HeadseLastStatue=0; static unsigned char cnt=0; if(INTERNAL_HEADSET==1) return; if(SET==GPIO_ReadInputDataBit(HEADSET_PORT,HEADSET_PIN))HeadsetStatue=-1; else HeadsetStatue=1; if(HeadseLastStatue!=HeadsetStatue||type){ // if(cnt<100)cnt++; // if(cnt==100||type==1){ // cnt=0; // if(HeadsetStatue==1){ // printf("耳机接入---\r\n"); // ModemSendAt("AT+AUDCH=1,3\r\n"); // sutPocStatus.HeadSetPtt=1; // } // else { // printf("耳机拔出---\r\n"); // ModemSendAt("AT+AUDCH=0,0\r\n"); // sutPocStatus.HeadSetPtt=0; // // } // HeadseLastStatue=HeadsetStatue; // } if(HeadsetStatue==1){ printf("耳机接入---\r\n"); //GuiShowStr(16,STATUS_ITEM_HEIGH+20+20+8+8+16,"接入",0x10,0); ModemSendAt("AT+AUDCH=1,3\r\n"); sutPocStatus.HeadSetPtt=1; } else { printf("耳机拔出---\r\n"); ModemSendAt("AT+AUDCH=0,0\r\n"); // GuiShowStr(16,STATUS_ITEM_HEIGH+20+20+8+8+16,"拔出",0x10,0); sutPocStatus.HeadSetPtt=0; } HeadseLastStatue=HeadsetStatue; }else { if(cnt>0)cnt--; } /*为了规避耳机拔出问题*/ if(HeadsetPress && sutPocStatus.HeadSetPtt){ if(uTimerExpired(&HeadsetPullPress)){ if(hgs_poc_type==POC_BND)ModemSendAt("AT+POC=ptt,1\r\n"); else { ModemSendAt("AT+POC=0B0000\r\n"); } HeadsetPress=0; } } } //开机后的一些控制 void onStartCtl(void){ KeyCount(); SwitchGroupCtrl(); SwitchVoiceCtrl(); if(newPara.lcdParaList[newPara.lcdParaDefaultIndex]>0){ if(++LcdOnTimeCt>=newPara.lcdParaList[newPara.lcdParaDefaultIndex]){ LcdOnTimeCt=0; if(sutPocStatus.FirstLogined==0){ LCDBackLight(1);//没登陆过(刚开机),LCD一直亮着//0 }else LCDBackLight(0); } } } void AtRequest() { static char step=0; switch(step) { case 0: break; } } void UiassistStart(unsigned char type){ uiAssist.type=type; uiAssist.machine=0; uiAssist.status=1; } void UiassistEnd(unsigned char type){ uiAssist.type=type; uiAssist.machine=0; uiAssist.status=0; assistResult=0; } unsigned char assistResult=0; unsigned char getAssistResult(void){ unsigned char ret=0; ret=assistResult; if(assistResult) assistResult=0; return ret; } PT_THREAD (ptUIAssist(struct pt *pt)){ static timer_t ptTimer; PT_BEGIN(pt); while(1){ if(uiAssist.status!=0){ switch(uiAssist.type){ case 0: // //刚进入 switch(uiAssist.machine){ case 0: if(SimpleUserInfoScan(1, 2)){//操作完成了 printf("获取成功了---\r\n"); assistResult=1; uiAssist.status=0; } break; } break; case 1: //上翻 switch(uiAssist.machine){ case 0: if(SimpleUserInfoScan(0,0)){ assistResult=1; uiAssist.status=0; } break; } break; case 2: //下翻 switch(uiAssist.machine){ case 0: if(SimpleUserInfoScan(0,1)){ assistResult=1; uiAssist.status=0; } break; } break; } } PTTimerStart(&pt_timerPool, &ptTimer, 1);//1 PT_WAIT_UNTIL(pt, PTTimerIsExpired(&ptTimer)); } PT_END(pt); }