| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322 | #include <rtthread.h>#include "main.h"#include "flash.h"#include "display.h"#include "buffer.h"#include "button.h"#include "usart.h"#include <stdlib.h>#include "weight.h"#include "plan.h"#include "daScreen.h"#include "xBeeAppEscapingMode.h"rt_sem_t display_lock = RT_NULL;struct rt_event display_event;uint8_t MenuItem=0; //当前菜单uint8_t WeightConst_Feed_display[40];   //显示标题uint8_t WeightConst_Weight_display[8] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};   //显示重量uint8_t WeightConst_WeightCur_display[5] = {0x20,0x20,0x20,0x20,0x20};   //显示重量uint8_t WeightConst_Weight_display_old[8] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};   //显示重量static signed long WeightConst_Weight_displayW;   //显示重量static signed long WeightConst_Weight_displayCurW;   //显示重量unsigned char WeightConst_displayTotal = 0;  //0差重,1实重unsigned char WeightConst_remoteDisplay = 0;unsigned char RemoteSendDisplay = 1;extern unsigned char  iscowweight;extern unsigned char  remote_sumweight;const uint8_t MenuItemList[12][8] = {{0xC9,0xE8,0xB1,0xB8,0xB5,0xD8,0xD6,0xB7}, //设备地址    {0xCC,0xE1,0xC8,0xA1,0xB7,0xBD,0xCA,0xBD}, //提取方式    {0xCD,0xF8,0xC2,0xE7,0xB1,0xE0,0xBA,0xC5}, //网络编号    {0xC9,0xE8,0xB1,0xB8,0xC0,0xE0,0xD0,0xCD}, //设备类型    {0x54,0x4D,0x52,0xCA,0xFD,0xC1,0xBF,0x20}, //铲车数量    {0x41,0x50,0x49,0x20,0x20,0x20,0x20,0x20}, //API    {0xD0,0xA3,0xD5,0xFD,0xD6,0xD8,0xC1,0xBF}, //校正重量    {0xD7,0xEE,0xB4,0xF3,0xB3,0xC6,0xC1,0xBF}, //最大称量    {0xC2,0xCB,0xB2,0xA8,0xC9,0xEE,0xB6,0xC8}, //滤波深度    {0xD0,0xA1,0xCA,0xFD,0xB5,0xE3,0x20,0x20}, //小数点    {0xB7,0xD6,0xB6,0xC8,0xD6,0xB5,0x20,0x20}, //分度值    {0xB8,0xF4,0xC0,0xEB,0xD6,0xD8,0xC1,0xBF}  //重量隔离};const uint8_t MenuTQTypeList[15][8] = {    {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20},    {0x4E,0x45,0x57,0x4C,0x61,0x62,0x65,0x6C}, //NewLabel    {0x5A,0x4D,0x33,0x30,0x33,0x20,0x20,0x20}, //AWT_ZM303    {0x58,0x4B,0x33,0x31,0x39,0x30,0x20,0x20}, //XK3190_A27E()    {0x54,0x4D,0x52,0x20,0x32,0x20,0x20,0x20}, //TMR2    {0x54,0x4D,0x52,0x20,0x33,0x20,0x20,0x20}, //TMR3    {0x45,0x5A,0x33,0x34,0x30,0x30,0x20,0x20}, //EZ3400    {0x41,0x44,0x32,0x35,0x30,0x20,0x20,0x20}, //AD250  TQ    {0x50,0x54,0x4D,0x20,0x20,0x20,0x20,0x20}, //PTM    {0x54,0x2D,0x32,0x30,0x30,0x30,0x20,0x20}, //T_2000    {0x53,0x4C,0x31,0x30,0x30,0x30,0x30,0x20}, //XL10000    {0x58,0x4B,0x33,0x31,0x39,0x30,0x43,0x38}, //P_XK3190_C8();    {0x54,0x44,0x49,0x32,0x30,0x30,0x49,0x20}, //TDI200I    {0x49,0x44,0x35,0x31,0x31,0x20,0x20,0x20}, //ID511;    {0xD7,0xD4,0xB6,0xAF,0x20,0x20,0x20,0x20} //自动};const uint8_t MenuSBTypeList[5][8] = {    {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20},    {0xBF,0xD8,0xD6,0xC6,0xC6,0xF7,0x20,0x20}, //控制器    {0xD4,0xB6,0xB3,0xCC,0xCF,0xD4,0xCA,0xBE}, //远程显示    {0xB4,0xF3,0xC6,0xC1,0x20,0x20,0x20,0x20},  //大屏    {0xB4,0xF3,0xC6,0xC1,0x31,0x20,0x20,0x20}  //LED大屏	};static uint8_t TDisplay = 1;	// CRC 高位字节值表const unsigned char auchCRCHi[] = {    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,    0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,    0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,    0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,    0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,    0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,    0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,    0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,    0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,    0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,    0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,    0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,    0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,    0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,    0x80, 0x41, 0x00, 0xC1, 0x81, 0x40} ;// CRC 低位字节值表const unsigned char auchCRCLo[] = {    0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,    0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,    0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,    0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,    0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,    0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,    0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,    0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,    0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,    0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,    0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,    0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,    0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,    0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,    0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,    0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,    0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,    0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,    0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,    0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,    0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,    0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,    0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,    0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,    0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,    0x43, 0x83, 0x41, 0x81, 0x80, 0x40};			static void MenuDisplay_entry(void *parameter) {		extern IWDG_HandleTypeDef hiwdg;	while(1)	{		if (MenuItem<11)				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示重量						WeightConst_Weight_display[SendDisplay_i]=0x20;		if (MenuItem==0)		{		  	if (XbeeConst_DeviceAddress>9) {					WeightConst_Weight_display[6] = (XbeeConst_DeviceAddress/10)%10 + 0x30;					WeightConst_Weight_display[5] = XbeeConst_DeviceAddress%10 + 0x30;				}			  else WeightConst_Weight_display[6] = XbeeConst_DeviceAddress + 0x30;		}		else if (MenuItem==1)		{				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示标题						WeightConst_Weight_display[SendDisplay_i] = MenuTQTypeList[WeightConst_TQ][7-SendDisplay_i];		}		else if (MenuItem==2)		{				if (XbeeConst_NetAddress>99) WeightConst_Weight_display[7] = XbeeConst_NetAddress/100 + 0x30;				if (XbeeConst_NetAddress>9) WeightConst_Weight_display[6] = (XbeeConst_NetAddress/10)%10 + 0x30;				WeightConst_Weight_display[5] = XbeeConst_NetAddress%10 + 0x30;		}		else if (MenuItem==3)		{				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示标题						WeightConst_Weight_display[SendDisplay_i] = MenuSBTypeList[WeightConst_SBType][7-SendDisplay_i];		}		else if (MenuItem==4)		{			if (WeightConst_ChanCheShu>9) {					WeightConst_Weight_display[6] = (WeightConst_ChanCheShu/10)%10 + 0x30;					WeightConst_Weight_display[5] = WeightConst_ChanCheShu%10 + 0x30;			}			else WeightConst_Weight_display[6] = WeightConst_ChanCheShu + 0x30;		}		else if (MenuItem==5)		{				WeightConst_Weight_display[6] = XbeeConst_UseAPI + 0x30;		}		else if (MenuItem==6)		{   TDisplay++;				WeightConst_Weight_display[4] = (WeightConst_JZZ_==4 && TDisplay%2? 0x20:(WeightConst_JZZ>9999 ? (WeightConst_JZZ/10000)%10 : 0x00) + 0x30);				WeightConst_Weight_display[3] = (WeightConst_JZZ_==3 && TDisplay%2? 0x20:(WeightConst_JZZ>999 ? (WeightConst_JZZ/1000)%10 : 0x00) + 0x30);				WeightConst_Weight_display[2] = (WeightConst_JZZ_==2 && TDisplay%2? 0x20:(WeightConst_JZZ>99 ? (WeightConst_JZZ/100)%10 : 0x00) + 0x30);				WeightConst_Weight_display[1] = (WeightConst_JZZ_==1 && TDisplay%2? 0x20:(WeightConst_JZZ>9 ? (WeightConst_JZZ/10)%10 : 0x00) + 0x30);				WeightConst_Weight_display[0] = (WeightConst_JZZ_==0 && TDisplay%2? 0x20:(WeightConst_JZZ%10 + 0x30));		}		else if (MenuItem==7)		{   TDisplay++;				WeightConst_Weight_display[4] = (WeightConst_ZD_==4 && TDisplay%2? 0x20:(Maxval>9999 ? (Maxval/10000)%10 : 0x00) + 0x30);				WeightConst_Weight_display[3] = (WeightConst_ZD_==3 && TDisplay%2? 0x20:(Maxval>999 ? (Maxval/1000)%10 : 0x00) + 0x30);				WeightConst_Weight_display[2] = (WeightConst_ZD_==2 && TDisplay%2? 0x20:(Maxval>99 ? (Maxval/100)%10 : 0x00) + 0x30);				WeightConst_Weight_display[1] = (WeightConst_ZD_==1 && TDisplay%2? 0x20:(Maxval>9 ? (Maxval/10)%10 : 0x00) + 0x30);				WeightConst_Weight_display[0] = (WeightConst_ZD_==0 && TDisplay%2? 0x20:(Maxval%10 + 0x30));		}		else if (MenuItem==8)		{				WeightConst_Weight_display[6] = ad_FS + 0x30;		}		else if (MenuItem==9)		{				WeightConst_Weight_display[6] = ad_Point + 0x30;		}		else if (MenuItem==10)		{				WeightConst_Weight_display[6] = ad_Inteval + 0x30;		}		else if (MenuItem==11)		{				WeightConst_Weight_display[6] = WeightConst_BLE + 0x30;		}		if (WeightConst_SBType<3 || WeightConst_SBType==6) {				uart4_send_data[0] = 0x7E;				uart4_send_data[1] = 0x45;				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示标题						uart4_send_data[2 + SendDisplay_i] =  MenuItemList[MenuItem][SendDisplay_i];				for (int SendDisplay_i = 7; SendDisplay_i >=0; SendDisplay_i--)   //显示重量						uart4_send_data[10 + SendDisplay_i] =  WeightConst_Weight_display[7-SendDisplay_i];				// USART_Send_DMA(displaySerial,18);				uart4_send_data[18]=0;				for (int i = 2; i <18; i++)   //校验和						uart4_send_data[18]=uart4_send_data[18]+uart4_send_data[i];				rt_sem_take(uart4_lock, RT_WAITING_FOREVER);		    HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 19);				rt_sem_release(uart4_lock);		}		else if (WeightConst_SBType==3||WeightConst_SBType==7) {								for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示菜单标题				{						WeightConst_feed[ SendDisplay_i] =  MenuItemList[MenuItem][SendDisplay_i];				}				for (int SendDisplay_i = 7; SendDisplay_i >=0; SendDisplay_i--)   //显示当前值				{						WeightConst_feed[8 + SendDisplay_i] =  WeightConst_Weight_display[7-SendDisplay_i];				}				//----------------------------				get_msg(0,//Xstart								12,//Ystart								1,//size								0,//reset								0,//speed								8,//字符个数								3,//界面数								0,//id								0xbF,//Xend								0,								&WeightConst_feed[0]//字码							 );				get_msg(0,//Xstart								12,//Ystart								2,//size								0,//reset								0,//speed								8,//字符个数								3,//界面数								1,//id								0xbF,//Xend								0,								&WeightConst_feed[8]//字码							 );		}		else {				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示标题						WeightConst_feed[SendDisplay_i] =  MenuItemList[MenuItem][SendDisplay_i];			//----------------------------				//display_menu();				if(isn==0) 				{							clearScreenAll();					    display_Current_noweight();				      display_Now();							for (int j=0; j<39; j++)	uart4_send_data[j] = display_productName_v[j];							send_uart4_send_data();																	for (int j=0; j<39; j++)	uart4_send_data[j] = display_Current_v[j];								send_uart4_send_data();														for (int j=0; j<39; j++)	uart4_send_data[j] = display_Process_v[j];								send_uart4_send_data();														for (int j=0; j<39; j++)	uart4_send_data[j] = display_Total_v[j];								send_uart4_send_data();														for (int j=0; j<39; j++)	uart4_send_data[j] = display_Next_v[j];							send_uart4_send_data();				}				else {						display_Current_noweight_();						display_Now_(WeightConst_WeightCurTem);				}		}//	  HAL_IWDG_Refresh(&hiwdg);		rt_thread_mdelay(400);	}}static rt_thread_t display_tid = RT_NULL;void threadMenuDisplay_init(void){		  //thread_EmptyBuffer_sem = rt_sem_create("thread_EmptyBuffer_sem", 0, RT_IPC_FLAG_FIFO);    display_tid = rt_thread_create("MenuDisp",                            MenuDisplay_entry, RT_NULL,                            0x200,                            4, 5);    /* 如果获得线程控制块,启动这个线程 */    if (display_tid != RT_NULL) rt_thread_startup(display_tid);}void getDisplay(void){	  rt_uint8_t nullindex;	  rt_sem_take(display_lock, RT_WAITING_FOREVER);		if	(tsdb_recordcount('k')>0 || XbeeConst_CanSend==0)				TDisplay++;  //是否有按键需要传输		else  				TDisplay = 1;				rt_memset(WeightConst_Feed_display, 0x20, 40);			if(WeightConst_DELAYON>0)		{				WeightConst_Feed_display[0]=0xC7;				WeightConst_Feed_display[1]=0xEB;				WeightConst_Feed_display[2]=0xBD;				WeightConst_Feed_display[3]=0xC1;				WeightConst_Feed_display[4]=0xB0;				WeightConst_Feed_display[5]=0xE8;				WeightConst_Feed_display[6]=0x20;				WeightConst_Feed_display[7]=0x20;		}		else if (!isWeight){					nullindex = 0;							for (int i = 0; i < 40; i++)   //显示标题				{				  	WeightConst_Feed_display[i] = WeightConst_feed[i];					  if (i>0 && nullindex==0 && WeightConst_feed[i]==0x20 &&  WeightConst_feed[i-1]==0x20 &&  WeightConst_feed[i-2]==0x20) {							nullindex = i-2;						}						if ((nullindex>8 && nullindex<14)||(nullindex<7 && nullindex>0)) nullindex=nullindex+2;						if (nullindex>1){							if(TDisplay%2==0) {								WeightConst_Feed_display[nullindex-1]=0x3E;								WeightConst_Feed_display[nullindex-2]=0x3E;							}							else {								WeightConst_Feed_display[nullindex-1]=WeightConst_feed[nullindex-1];								WeightConst_Feed_display[nullindex-2]=WeightConst_feed[nullindex-2];							}						}										}						}				if(WeightConst_DELAYON>0)		{				WeightConst_Weight_display[0]=0xEB;				WeightConst_Weight_display[1]=0xC3;				WeightConst_Weight_display[2]=0x20;				WeightConst_Weight_display[3]=0x20;				WeightConst_Weight_display[4]=0x20;				WeightConst_Weight_display[5]=0x20;				WeightConst_Weight_display[6]=0x20;				WeightConst_Weight_display[7]=0x20;				WeightConst_Weight_displayW = (pf_comp.data.delaytime * 60 - WeightConst_DELAYTIME);				for (int SendDisplay_i = 2; SendDisplay_i < 8; SendDisplay_i++) {						if (SendDisplay_i>2)	WeightConst_Weight_displayW=WeightConst_Weight_displayW/10;						if (abs(WeightConst_Weight_displayW)>0)								WeightConst_Weight_display[SendDisplay_i] = abs((WeightConst_Weight_displayW)%10)+'0';						else break;				}		}		else		{				if (WeightConst_Product_Run>0 && WeightConst_displayTotal==0  && pf_comp.data.pfsort!=0xFE && WeightConst_WeightHaveBegin==1)						WeightConst_Weight_displayW = WeightConst_WeightCurTem - WeightConst_WeightTarget;				else						WeightConst_Weight_displayW = WeightConst_WeightCurTem;        WeightConst_Weight_displayCurW = WeightConst_WeightCurTem;				for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示重量						WeightConst_Weight_display[SendDisplay_i]=0x20;					if (WeightConst_Product_Run>0 && WeightConst_displayTotal==0  && pf_comp.data.pfsort!=0xFE && WeightConst_WeightHaveBegin==1)				{						if ((WeightConst_Weight_displayW<=0 && pf_comp.data.addorout==0) ||										(WeightConst_Weight_displayW>=0 && pf_comp.data.addorout == 1)							 ) {  //少								WeightConst_Weight_display[6]=0xD9;								WeightConst_Weight_display[7]=0xC9;						}						else {								WeightConst_Weight_display[6]=0xE0;  //多								WeightConst_Weight_display[7]=0xB6;						}				}				else	{						if (WeightConst_Weight_displayW<0) {								WeightConst_Weight_display[6]=0x2D;  //-								WeightConst_Weight_display[7]=0x20;						}						else {								WeightConst_Weight_display[6]=0x20;  //								WeightConst_Weight_display[7]=0x20;						}				}				if (WeightConst_Weight_displayW==0) {						WeightConst_Weight_display[0]=0x30;				}				else				{						for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++) {								if (SendDisplay_i>0)										WeightConst_Weight_displayW=WeightConst_Weight_displayW/10;								if (abs(WeightConst_Weight_displayW)>0)										WeightConst_Weight_display[SendDisplay_i] = abs(WeightConst_Weight_displayW%10)+'0';								else break;						}						if (WeightConst_WeightWS>0) {								for (int SendDisplay_i = 4; SendDisplay_i >= WeightConst_WeightWS; SendDisplay_i--)										if (WeightConst_Weight_display[SendDisplay_i]!=0x20)												WeightConst_Weight_display[SendDisplay_i+1]=WeightConst_Weight_display[SendDisplay_i];								WeightConst_Weight_display[WeightConst_WeightWS]=0x2E;								if (WeightConst_Weight_display[WeightConst_WeightWS+1]==0x20) WeightConst_Weight_display[WeightConst_WeightWS+1] = 0x30;								for (int SendDisplay_i = 0; SendDisplay_i < WeightConst_WeightWS; SendDisplay_i++)										if (WeightConst_Weight_display[SendDisplay_i]==0x20) WeightConst_Weight_display[SendDisplay_i] = 0x30;						}	            				}				/////////////////广泽				if (remote_sumweight==1)				{            for (int SendDisplay_i = 0; SendDisplay_i < 5; SendDisplay_i++)            {										 	WeightConst_WeightCur_display[SendDisplay_i] = 0x20; 						};						if (WeightConst_Weight_displayCurW==0){						  WeightConst_WeightCur_display[0] = 0x30; 						}						else						{							if (WeightConst_Weight_displayCurW<0) {									WeightConst_WeightCur_display[4]=0x2D;  //-							}							for (int SendDisplay_i = 0; SendDisplay_i < 5; SendDisplay_i++) {									if (SendDisplay_i>0)											WeightConst_Weight_displayCurW=WeightConst_Weight_displayCurW/10;									if (abs(WeightConst_Weight_displayCurW)>0)											WeightConst_WeightCur_display[SendDisplay_i] = abs(WeightConst_Weight_displayCurW%10)+'0';									else break;							}							if (WeightConst_WeightWS>0) {									for (int SendDisplay_i = 4; SendDisplay_i >= WeightConst_WeightWS; SendDisplay_i--)											if (WeightConst_WeightCur_display[SendDisplay_i]!=0x20)													WeightConst_WeightCur_display[SendDisplay_i+1]=WeightConst_WeightCur_display[SendDisplay_i];									WeightConst_WeightCur_display[WeightConst_WeightWS]=0x2E;									if (WeightConst_WeightCur_display[WeightConst_WeightWS+1]==0x20) WeightConst_WeightCur_display[WeightConst_WeightWS+1] = 0x30;									for (int SendDisplay_i = 0; SendDisplay_i < WeightConst_WeightWS; SendDisplay_i++)											if (WeightConst_WeightCur_display[SendDisplay_i]==0x20) WeightConst_WeightCur_display[SendDisplay_i] = 0x30;							}					}				}						/////////////////广泽  end				if (WeightConst_WeightHaveBegin==0 && pf_comp.data.needBegin == 1)				{						if (WeightConst_SBType==1||WeightConst_SBType==6) {								//for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //如果没有开始则空显示重量								//	WeightConst_Weight_display[SendDisplay_i]=0x20;								WeightConst_Weight_display[5]=WeightConst_Weight_display[6];								WeightConst_Weight_display[6]=0xF8;								WeightConst_Weight_display[7]=0xCB;						}						else if (WeightConst_SBType==3) {								WeightConst_Weight_display[5]=WeightConst_Weight_display[6];								WeightConst_Weight_display[6]=0xF8;								WeightConst_Weight_display[7]=0xCB;								/*								WeightConst_Weight_display[0]=0xCC;								WeightConst_Weight_display[1]=0xC5;								WeightConst_Weight_display[2]=0xD3;								WeightConst_Weight_display[3]=0xB3;								WeightConst_Weight_display[4]=0xD5;								WeightConst_Weight_display[5]=0xBF;								WeightConst_Weight_display[6]=0xE5;								WeightConst_Weight_display[7]=0xC7;//清空秤盘								*/						}						else if (WeightConst_SBType==4||WeightConst_SBType==6) {								WeightConst_Weight_display[0]=0xBC;								WeightConst_Weight_display[1]=0xCA;								WeightConst_Weight_display[2]=0xAA;								WeightConst_Weight_display[3]=0xBF;								WeightConst_Weight_display[4]=0xCF;								WeightConst_Weight_display[5]=0xC8;								WeightConst_Weight_display[6]=0xB7;								WeightConst_Weight_display[7]=0xC8;//确认开始						};				};		}				rt_sem_release(display_lock);}static void sendRemote(void *parameter){	rt_uint8_t displayrow = 0,ismulti = 0,forcount = 0,haveAscii=0;	 	while(1)	{    if (RemoteSendDisplay == 1 )    {        if ((flag_uart2_send==0 && (XbeeConst_UseAPI==1 || XbeeConst_UseAPI>=3))||                (flag_uart3_send==0 && XbeeConst_UseAPI==0))        {            if(remote_sumweight==1)	XbeeConst_FRemoteTxBuf[0] = 28;            else 	XbeeConst_FRemoteTxBuf[0] = 23;				            XbeeConst_FRemoteTxBuf[1] = 0x7E;            XbeeConst_FRemoteTxBuf[2] = 0x15;					  if(remote_sumweight==1)	XbeeConst_FRemoteTxBuf[2] = 0x1A;            else 	XbeeConst_FRemoteTxBuf[2] = 0x15;		            XbeeConst_FRemoteTxBuf[3] = XbeeConst_DeviceAddress;            if (XbeeConst_UseAPI==1 || XbeeConst_UseAPI==3)                XbeeConst_FRemoteTxBuf[4] = 0xA1;            else            {                if (WeightConst_ChanCheShu>9)                    XbeeConst_FRemoteTxBuf[4] = 0xA1;                else                    XbeeConst_FRemoteTxBuf[4] = 0xF1;            }            XbeeConst_FRemoteTxBuf[5] = 0x7E;            XbeeConst_FRemoteTxBuf[6] = 0x45;									      haveAscii=0;						for(rt_uint8_t i=0; i<8; i++){							if ( WeightConst_Feed_display[i] < 0x80) { haveAscii = ((haveAscii + 1) & 0x01); }						}										ismulti = 0;						for(rt_uint8_t i=8;i<16;i++){							if ( WeightConst_Feed_display[i] > 0x20) { ismulti=1; break; }						}						if (ismulti==0) displayrow = 0;						if (forcount<1) forcount++;						else{							forcount = 0;							if (ismulti==1 && displayrow==1) displayrow = 0;							else if (ismulti==1 && displayrow==0) displayrow = 1;						}												for (rt_uint8_t i = 0; i < 8; i++)   //显示标题						{ 								if (haveAscii==1 && displayrow==1)										XbeeConst_FRemoteTxBuf[7+i] =  WeightConst_Feed_display[i+displayrow*8-1];//显示标题								else if (haveAscii==1 && displayrow==0){										if (i==7)											XbeeConst_FRemoteTxBuf[7+i] =  0x20;										else											XbeeConst_FRemoteTxBuf[7+i] = WeightConst_Feed_display[i + displayrow * 8];						    								}								else XbeeConst_FRemoteTxBuf[7+i] = WeightConst_Feed_display[i + displayrow * 8];						};						            for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++) {                XbeeConst_FRemoteTxBuf[15+SendDisplay_i] =  WeightConst_Weight_display[7-SendDisplay_i];//显示重量            }					////////////广泽							if(remote_sumweight==1){							for (int SendDisplay_i = 0; SendDisplay_i < 5; SendDisplay_i++) {									XbeeConst_FRemoteTxBuf[23+SendDisplay_i] =  WeightConst_WeightCur_display[4-SendDisplay_i];//显示重量							}					  } 						////////////广泽	            XbeeConst_FRemoteTxBuf[XbeeConst_FRemoteTxBuf[0]] = 0x00;            for (int SendDisplay_i = 1; SendDisplay_i < XbeeConst_FRemoteTxBuf[0]; SendDisplay_i++) {                XbeeConst_FRemoteTxBuf[XbeeConst_FRemoteTxBuf[0]] =                    XbeeConst_FRemoteTxBuf[XbeeConst_FRemoteTxBuf[0]]+XbeeConst_FRemoteTxBuf[SendDisplay_i];            }            XbeeConst_FRemoteTxBuf[XbeeConst_FRemoteTxBuf[0]] = 0xFF - XbeeConst_FRemoteTxBuf[XbeeConst_FRemoteTxBuf[0]];            if (XbeeConst_UseAPI==1 || XbeeConst_UseAPI==3) {							  rt_sem_take(uart2_lock, RT_WAITING_FOREVER);			                if (XbeeConst_UseAPI==1)                    setSendFrame_t(0x01,0x02,0x40);                else setSendFrame_t(0x02,0x02,0x40);								XbeeConst_PRemoteTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FRemoteTxBuf);                for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PRemoteTxBuf0[0]; SendWifi_i++)  //将缓冲区发出                    usart2_send_data[SendWifi_i-1] = XbeeConst_PRemoteTxBuf0[SendWifi_i];															                  if (XbeeConst_UseAPI==1 || (XbeeConst_UseAPI==3 && ccsend==1))								{	                    HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PRemoteTxBuf0[0]);//xbeeSerial													rt_thread_mdelay(50);															}																rt_sem_release(uart2_lock);														    rt_thread_mdelay(XbeeConst_DeviceAddress*30);					//			rt_thread_mdelay(200);            }            else  if (XbeeConst_UseAPI>3) {							  rt_sem_take(uart3_lock, RT_WAITING_FOREVER);									AT_on();									for(int xcount=0;xcount<2;xcount++){									XbeeConst_PRemoteTxBuf0 = BleApp2MakeFrame(0xFFFF, 0x00, xcount, XbeeConst_FRemoteTxBuf);									for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PRemoteTxBuf0[0]; SendWifi_i++)  //将缓冲区发出											usart3_send_data[SendWifi_i-1] = XbeeConst_PRemoteTxBuf0[SendWifi_i];																	HAL_UART_Transmit_DMA(&huart3, usart3_send_data, XbeeConst_PRemoteTxBuf0[0]);//xbeeSerial												rt_thread_mdelay(100);											}														 													AT_off();								rt_sem_release(uart3_lock);														}						else            {							if (iscowweight<1 )							{							  rt_sem_take(uart3_lock, RT_WAITING_FOREVER);                for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FRemoteTxBuf[0]; SendWifi_i++)  //将缓冲区发出                    usart3_send_data[SendWifi_i-1] = XbeeConst_FRemoteTxBuf[SendWifi_i];															                HAL_UART_Transmit_DMA(&huart3, usart3_send_data, XbeeConst_FRemoteTxBuf[0]); //remoteSerial								rt_thread_mdelay(50);								rt_sem_release(uart3_lock);							}            }        }    }		 if (XbeeConst_UseAPI<4)		rt_thread_mdelay(500);		 else rt_thread_mdelay(250);	}}void ChancheShow(void) {    uart4_send_data[0] = 0x7E;    uart4_send_data[1] = 0x45;    uart4_send_data[2] = XbeeConst_RemoteAddress + '0';    for (int i = 3; i < 18; i++) //将缓冲区发出        uart4_send_data[i] = 0x20;			rt_sem_take(uart4_lock, RT_WAITING_FOREVER);					  HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 12);	  rt_sem_release(uart4_lock);}void send_uart4_send_data(void){	rt_sem_take(uart4_lock, RT_WAITING_FOREVER);	HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 39);	rt_sem_release(uart4_lock); 							rt_thread_mdelay(100);//	rt_sem_take(uart4_lock, RT_WAITING_FOREVER);//	HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 39);//	rt_sem_release(uart4_lock); 						//	rt_thread_mdelay(100);}extern unsigned char inMenu;static void Display_entry(void *parameter) {	  rt_uint32_t e;		rt_uint8_t displayrow = 0,ismulti = 0,forcount = 0,haveAscii=0,row=0,rowx=5;		  extern IWDG_HandleTypeDef hiwdg;	    while (1) {			        getDisplay();			  ismulti = 0;			  haveAscii=0;			  for(rt_uint8_t i=0;i<8;i++){				  if ( WeightConst_Feed_display[i] < 0x80) { haveAscii = ((haveAscii + 1) & 0x01); }				}			  for(rt_uint8_t i=8;i<16;i++){				  if ( WeightConst_Feed_display[i] > 0x20) { ismulti=1; break; }				}				if (ismulti==0) displayrow = 0;        if (forcount<2) forcount++;				else{					forcount = 0;					if (ismulti==1 && displayrow==1) displayrow = 0;					else if (ismulti==1 && displayrow==0) displayrow = 1;				}        if (WeightConst_SBType<3||WeightConst_SBType==6) {									  uart4_send_data[0] = 0x7E;            uart4_send_data[1] = 0x45;								  	for (int i = 0; i < 8; i++)   //显示标题						{ 								if (haveAscii==1 && displayrow==1)										uart4_send_data[i+2] = WeightConst_Feed_display[i + displayrow * 8 - 1];								else if (haveAscii==1 && displayrow==0){										if (i==7)											uart4_send_data[i+2] =  0x20;										else											uart4_send_data[i+2] = WeightConst_Feed_display[i + displayrow * 8];						    								}								else uart4_send_data[i+2] = WeightConst_Feed_display[i + displayrow * 8];						};						            for (int i = 7; i >=0; i--)   //显示重量                uart4_send_data[i + 10] = WeightConst_Weight_display[7-i];            uart4_send_data[18]=0;            for (int i = 2; i <18; i++)   //校验和                uart4_send_data[18] = uart4_send_data[18] + uart4_send_data[i];											rt_sem_take(uart4_lock, RT_WAITING_FOREVER);		        HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 19);						rt_sem_release(uart4_lock);			//			HAL_IWDG_Refresh(&hiwdg);						rt_thread_mdelay(500);        }				else if (WeightConst_SBType==4)				{						if (rt_event_recv(&display_event, (EVENT_clearall | EVENT_Current_noweight 																 | EVENT_PlanName | EVENT_Current | EVENT_Stop | EVENT_Next) , 												       RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, 10, &e) == RT_EOK)						{														if (e & EVENT_clearall)								{										if(isn>=1 ) {												clearScreenAll_();										}										else										{											clearScreenAll();										}								}								if (e & EVENT_Current_noweight)								{										if(isn>=1 ) {												display_Current_noweight_();										}										else										{											display_Current_noweight();;										}								}								if (e & EVENT_PlanName)								{										if(isn>=1 ) {												display_productName_(0);										}										else										{											display_productName();										}								}								if (e & EVENT_Current)								{										if(isn>=1 ) {												 display_Current_(WeightConst_WeightTargetTemp);										}										else										{											display_Current(WeightConst_WeightTargetTemp);										}								}																if (e & EVENT_Stop)								{										if(isn>=1 ) {												;										}										else										{											;										}								}																		if (e & EVENT_Next)								{										if(isn>=1) {												display_Next_();										}										else										{											display_Next();										}								}												}					//	if(WeightConst_Run || inMenu==1)						{							if (isn>=1)							{								display_Now_(WeightConst_WeightCurTem);							}							else{															display_Now();								display_Total(WeightConst_WeightCurTem);								row++;								if (row%rowx==0){									for (int j=0; j<39; j++)	uart4_send_data[j] = display_productName_v[j];									send_uart4_send_data();								}																							for (int j=0; j<39; j++)	uart4_send_data[j] = display_Current_v[j];									send_uart4_send_data();																for (int j=0; j<39; j++)	uart4_send_data[j] = display_Process_v[j];									send_uart4_send_data();																for (int j=0; j<39; j++)	uart4_send_data[j] = display_Total_v[j];									send_uart4_send_data();																if (row%rowx==0){									for (int j=0; j<39; j++)	uart4_send_data[j] = display_Next_v[j];									send_uart4_send_data();								}								if (row%rowx==0){									for (int j=0; j<39; j++)	uart4_send_data[j] = display_Stop_v[j];									send_uart4_send_data();								}									}					  }						if (isn>=1){								rt_thread_mdelay(500);							 						}						else{				        rt_thread_mdelay(300);						}			//		  HAL_IWDG_Refresh(&hiwdg);				}				else if (WeightConst_SBType==3){// || WeightConst_SBType==7) {            						// if (WeightConst_Weight_display_old[SendDisplay_i] != WeightConst_Weight_display[SendDisplay_i])						{																				get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												16,//字符个数												3,//界面数												0,//id												0xBF,//Xend												0,												&WeightConst_feed[0]//字码											 );																						get_msg(92,//Xstart												4,//Ystart												2,//size												0,//reset												0,//speed												8,//字符个数												3,//界面数												1,//id												0xBF,//Xend												1,												&WeightConst_Weight_display[0]//字码											 );							if(WeightConst_Product_Run)							{								rt_uint8_t index = 0,value = 0;	                signed long WeightConst_WeightCurTem_ = 0;										uart4_send_data[0]=0x20;uart4_send_data[1]=0x20;uart4_send_data[2]=0x20;								uart4_send_data[3]=0x20;uart4_send_data[4]=0x30;	                if 	(WeightConst_WeightCurTem<0)								{																		 WeightConst_WeightCurTem_ = WeightConst_WeightCurTem*-1;									 uart4_send_data[0] = 0x2D;								}                else 	WeightConst_WeightCurTem_ = WeightConst_WeightCurTem;																											for (int SendDisplay_i = 0; SendDisplay_i < 5; SendDisplay_i++) {										if (SendDisplay_i>0)	WeightConst_WeightCurTem_=WeightConst_WeightCurTem_/10;										if (WeightConst_WeightCurTem_>0)												uart4_send_data[4-SendDisplay_i] = (WeightConst_WeightCurTem_)%10+'0';										else break;								}								get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												5,//字符个数												3,//界面数												4,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );								index = 0;                for(int i = 0;i< 22;i++)								{									if(WeightConst_product[i] >= 0xA0) {									   uart4_send_data[index++] = WeightConst_product[i++];										 uart4_send_data[index++] = WeightConst_product[i];//									   uart4_send_data[index++] = 0xA1;	//										 uart4_send_data[index++] = 0xA2;										}                  else {										if(WeightConst_product[i] != 0x20 && WeightConst_product[i] != 0)										{                      uart4_send_data[index++] = WeightConst_product[i];//									    uart4_send_data[index++] = 0xA1;	//										  uart4_send_data[index++] = 0xA2;											}									}																		}																uart4_send_data[index++] = 0x10;					//								//								value = (plan_comp.data .sumweight / 10000) % 10;//								if(value != 0) {//									uart4_send_data[index++] = value + 0x30;//									uart4_send_data[index++] = (plan_comp.data .sumweight / 1000) % 10 + 0x30;//									uart4_send_data[index++] = (plan_comp.data .sumweight / 100) % 10 + 0x30;//									uart4_send_data[index++] = (plan_comp.data .sumweight / 10) % 10 + 0x30;//									uart4_send_data[index++] = plan_comp.data .sumweight % 10 + 0x30;//								}//								else {//									  value = (plan_comp.data .sumweight / 1000) % 10;//										if(value != 0) {//											uart4_send_data[index++] = value + 0x30;//											uart4_send_data[index++] = (plan_comp.data .sumweight / 100) % 10 + 0x30;//											uart4_send_data[index++] = (plan_comp.data .sumweight / 10) % 10 + 0x30;//											uart4_send_data[index++] = plan_comp.data .sumweight % 10 + 0x30;//										}//									  else {//											value = (plan_comp.data .sumweight / 100) % 10;//											if(value != 0) {//												uart4_send_data[index++] = value + 0x30;//												uart4_send_data[index++] = (plan_comp.data .sumweight / 10) % 10 + 0x30;//												uart4_send_data[index++] = plan_comp.data .sumweight % 10 + 0x30;//											}//											else {//												value = (plan_comp.data .sumweight / 10) % 10;//												if(value != 0) {//													uart4_send_data[index++] = value + 0x30;//												  uart4_send_data[index++] = plan_comp.data .sumweight % 10 + 0x30;//												}//												else {//													 uart4_send_data[index++] = plan_comp.data .sumweight % 10 + 0x30;//												}//											}//										}//								}								uart4_send_data[index++] =  0x10;																                WeightConst_WeightCurTem_ = WeightConst_WeightTargetTemp;									value = (WeightConst_WeightCurTem_ / 10000) % 10;								if(value != 0) {									uart4_send_data[index++] = value + 0x30;									uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 1000) % 10 + 0x30;									uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 100) % 10 + 0x30;									uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 10) % 10 + 0x30;									uart4_send_data[index++] = WeightConst_WeightCurTem_ % 10 + 0x30;								}								else {									  value = (WeightConst_WeightCurTem_ / 1000) % 10;										if(value != 0) {											uart4_send_data[index++] = value + 0x30;											uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 100) % 10 + 0x30;											uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 10) % 10 + 0x30;											uart4_send_data[index++] = WeightConst_WeightCurTem_ % 10 + 0x30;										}									  else {											value = (WeightConst_WeightCurTem_ / 100) % 10;											if(value != 0) {												uart4_send_data[index++] = value + 0x30;												uart4_send_data[index++] = (WeightConst_WeightCurTem_ / 10) % 10 + 0x30;												uart4_send_data[index++] = WeightConst_WeightCurTem_ % 10 + 0x30;											}											else {												value = (WeightConst_WeightCurTem_ / 10) % 10;												if(value != 0) {													uart4_send_data[index++] = value + 0x30;												  uart4_send_data[index++] = WeightConst_WeightCurTem_ % 10 + 0x30;												}												else {													 uart4_send_data[index++] = WeightConst_WeightCurTem_ % 10 + 0x30;												}											}										}								}								uart4_send_data[index++] =  0x10;									for(int i = 0;i< 16;i++)								{									uart4_send_data[index++] = WeightConst_Nextfeed[i];									if (WeightConst_Nextfeed[i] ==0x20)  break;								}										uart4_send_data[index++] =  0x10;								if (pf_comp.data.isMix==1){															uart4_send_data[index++] =  0xD7;											uart4_send_data[index++] =  0xE9;											uart4_send_data[index++] =  0xBA;													uart4_send_data[index++] =  0xCF;											uart4_send_data[index++] =  0xC1;													uart4_send_data[index++] =  0xCF;																}									uart4_send_data[index++] =  0x10;										get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												3,//speed												index,//字符个数												3,//界面数												2,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );						if (WeightConst_Product_Run>0 && WeightConst_displayTotal==0  && pf_comp.data.pfsort!=0xFE && WeightConst_WeightHaveBegin==1)						{							int tempw;														uart4_send_data[1]=0;							uart4_send_data[2]=0;							uart4_send_data[3]=0;							if ((WeightConst_WeightTarget < WeightConst_WeightCurTem && pf_comp.data.addorout==0)								|| (WeightConst_WeightTarget > WeightConst_WeightCurTem && pf_comp.data.addorout==1))							{									uart4_send_data[0]= 100;								 uart4_send_data[1]=0xFF;															}							else							{		                  if (WeightConst_WeightCurTem<(WeightConst_WeightTarget-WeightConst_WeightTargetTemp) &&  pf_comp.data.addorout==0)                    tempw=0;									else if (WeightConst_WeightCurTem>(WeightConst_WeightTargetTemp+WeightConst_WeightTarget) &&  pf_comp.data.addorout==1)                    tempw=0;                  else if (pf_comp.data.addorout==0)																		 tempw = ( WeightConst_WeightCurTem-(WeightConst_WeightTarget-WeightConst_WeightTargetTemp));									else 										tempw = ((WeightConst_WeightTarget+WeightConst_WeightTargetTemp)-WeightConst_WeightCurTem);								  uart4_send_data[0]=tempw*100/WeightConst_WeightTargetTemp;																						if ((WeightConst_WeightCurTem>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0) ||									(WeightConst_WeightCurTem<WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==1)								)								{								   uart4_send_data[2]=0xFF;								}								else if ((WeightConst_WeightCurTem+30>WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==0)||									(WeightConst_WeightCurTem-30<WeightConst_WeightTargetAllowMin && pf_comp.data.addorout==1))									{uart4_send_data[1]=0xFF;		uart4_send_data[3]=0xFF;									}                else 								  uart4_send_data[3]=0xFF;							}																 									get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												4,//字符个数												3,//界面数												3,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );						}							}														else{													uart4_send_data[0]=0;							uart4_send_data[1]=0;							uart4_send_data[2]=0;							uart4_send_data[3]=0;								 							get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												4,//字符个数												3,//界面数												3,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );							uart4_send_data[0]=0x20;													 							get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												1,//字符个数												3,//界面数												4,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );														uart4_send_data[0]=0x10;														uart4_send_data[0]=0x10;														uart4_send_data[0]=0x10;														uart4_send_data[0]=0x10;							get_msg(0,//Xstart												0,//Ystart												1,//size												0,//reset												0,//speed												4,//字符个数												3,//界面数												2,//id												0xBF,//Xend												0,												&uart4_send_data[0]//字码											 );						}						}												            for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示原料名称            {                WeightConst_Weight_display_old[SendDisplay_i] = WeightConst_Weight_display[SendDisplay_i];            }												rt_thread_mdelay(300);			//			HAL_IWDG_Refresh(&hiwdg);        }//        if (WeightConst_SBType==3 || WeightConst_SBType==7) {            //						// if (WeightConst_Weight_display_old[SendDisplay_i] != WeightConst_Weight_display[SendDisplay_i])//						{//								get_msg(92,//Xstart//												4,//Ystart//												2,//size//												0,//reset//												0,//speed//												8,//字符个数//												3,//界面数//												1,//id//												0xBF,//Xend//												1,//												&WeightConst_Weight_display[0]//字码//											 );//								break;//						}//            for (int SendDisplay_i = 0; SendDisplay_i < 8; SendDisplay_i++)   //显示原料名称//            {//                WeightConst_Weight_display_old[SendDisplay_i] = WeightConst_Weight_display[SendDisplay_i];//            }//        }//        if (WeightConst_SBType==4||WeightConst_SBType==6)  {//            if (WeightConst_Product_Run) {//                if(isn!=1 && (ScreenBufSize()<100)) {//                    display_Now();//                    display_Total(WeightConst_WeightCurTem);//                }//                else if(isn==1) display_Now_(WeightConst_WeightCurTem);//            }//            else if(isn==1 && WeightConst_Run==1) display_Now_(WeightConst_WeightCurTem);//        }//        if (SendRemote_timer>700 && RemoteSendDisplay &&//                ((flag_uart2_send==0 && (XbeeConst_UseAPI==1 || XbeeConst_UseAPI==3))||//                 (flag_uart3_send==0 && XbeeConst_UseAPI==0)))//        {//            SendRemote_timer = 0;          //        } 			}}static void Display_clear_entry(void *parameter) {	  uint8_t i=0;    while (i<10) {	  // while (WeightConst_Run<1) {       if (WeightConst_Run<1){				 if (isn>=1) display_KPT_TMRWatch_();  				// if (isn>=1) display_KPT_TMRWatch_weight_(); 				 else display_KPT_TMRWatch(); 			 }   						 rt_thread_mdelay(1000);			 i++;		}}void threadDisplay_init(void){			if (WeightConst_SBType == 4)       { 	     	 if(isn>=1) clearScreenAll_();			  	 else clearScreenAll();			}  	  //thread_EmptyBuffer_sem = rt_sem_create("thread_EmptyBuffer_sem", 0, RT_IPC_FLAG_FIFO);    display_tid = rt_thread_create("Display",                            Display_entry, RT_NULL,                            0x400,                            5, 5);    /* 如果获得线程控制块,启动这个线程 */    if (display_tid != RT_NULL) rt_thread_startup(display_tid);}		static rt_thread_t display_clear_tid = RT_NULL;void threadDisplay_delay_init(void){			display_clear_tid = rt_thread_create("Displaydelay",														Display_clear_entry, RT_NULL,														0x100,														5, 5);		/* 如果获得线程控制块,启动这个线程 */		if (display_clear_tid != RT_NULL) rt_thread_startup(display_clear_tid);}static rt_thread_t remotedisplay_tid = RT_NULL;void threadRemoteDisplay_init(void){		  //thread_EmptyBuffer_sem = rt_sem_create("thread_EmptyBuffer_sem", 0, RT_IPC_FLAG_FIFO);    remotedisplay_tid = rt_thread_create("RemoteD",                            sendRemote, RT_NULL,                            0x300,                            5, 5);    /* 如果获得线程控制块,启动这个线程 */    if (remotedisplay_tid != RT_NULL) rt_thread_startup(remotedisplay_tid);}void display_usart_Init(UART_HandleTypeDef* uartHandle){		extern unsigned char WeightConst_TQ;		if ((uartHandle->Instance==UART4 && (WeightConst_SBType==0x04 && isn==0)))		{			 uartHandle->Init.BaudRate = 9600;		}					else			 uartHandle->Init.BaudRate = 57600;			}//CRC校验的函数unsigned short CRC16(unsigned char *puchMsg, unsigned short usDataLen){    unsigned char uchCRCHi = 0xFF ;    unsigned char uchCRCLo = 0xFF ;    unsigned uIndex ;	    while (usDataLen--)    {        uIndex = uchCRCHi ^ *puchMsg++ ; /* 计算CRC */        uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex] ;        uchCRCLo = auchCRCLo[uIndex] ;    }    return (uchCRCHi << 8 | uchCRCLo) ;}unsigned char uart_send_buf_cp[100];unsigned char get_msg(  unsigned char Xstart,// 0 - 191                        unsigned char Ystart, //0 - 47                        unsigned char ZiTiSize,//1 or 2 or 3                        unsigned char reset_enable,//0 or 1                        unsigned char speed,//速度 0 or 1 or 2 or 3                        unsigned char ZiFuCount,//字符个数                        unsigned char JieMianCount,//3                        unsigned char JieMianID,//0 or 1 or 2                        unsigned char Xend,                        unsigned char f,                        unsigned char * ASCII_buf){    unsigned char i=0;    unsigned char len=0;    unsigned short int calcCRC;		  extern IWDG_HandleTypeDef hiwdg;	    uart_send_buf_cp[0] = 0x7E;    uart_send_buf_cp[1] = Xstart;    uart_send_buf_cp[2] = (Ystart<<2) |(ZiTiSize & 0x03);//    uart_send_buf_cp[3] = ((reset_enable<<7)&0x80)|((speed<<5)&0x60);	  uart_send_buf_cp[3] = ((reset_enable<<7)&0x80)|(speed & 0x0F);    uart_send_buf_cp[4] = ZiFuCount;    uart_send_buf_cp[5] = ((JieMianCount<<4)&0xF0)|(JieMianID&0x0F);    uart_send_buf_cp[6] = Xend;    if (f==0)        for(i=0; i<ZiFuCount; i++)  uart_send_buf_cp[7+i] = ASCII_buf[i];    else        for(i=ZiFuCount; i>0; i--)  uart_send_buf_cp[7+i-1] = ASCII_buf[ZiFuCount-i];    len = ZiFuCount + 7;    calcCRC = CRC16(uart_send_buf_cp, len);    uart_send_buf_cp[7+ZiFuCount] = (unsigned char)(calcCRC>>8);  //低位    uart_send_buf_cp[7+ZiFuCount+1] = (unsigned char)(calcCRC);  //高位    for(i=0; i<=8+ZiFuCount; i++) uart4_send_data[i] = uart_send_buf_cp[i];	 	rt_sem_take(uart4_lock, RT_WAITING_FOREVER);	  HAL_UART_Transmit_DMA(&huart4, uart4_send_data, 9+ZiFuCount);	  rt_sem_release(uart4_lock); 		rt_thread_mdelay(150);    return 0;}
 |