917 lines
40 KiB
C
917 lines
40 KiB
C
|
|
#include "APPDEF.H"
|
|||
|
|
#include "stdio.h"
|
|||
|
|
#include "string.h"
|
|||
|
|
#include "math.h"
|
|||
|
|
uint8_t pageNum = 13;
|
|||
|
|
extern void DataPrint(uint8_t *buf, uint8_t len);
|
|||
|
|
extern uint8_t DataInbuf[60u];
|
|||
|
|
extern osSemaphoreId semDataBack;
|
|||
|
|
extern float Temperature;
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
struct Pset Set;
|
|||
|
|
uint8_t DataLogValue[100]; // <20><>ǰ<EFBFBD><C7B0><EFBFBD>ݼ<EFBFBD>¼
|
|||
|
|
//
|
|||
|
|
uint8_t MaxWeight;
|
|||
|
|
uint8_t MaxTemp;
|
|||
|
|
float Resolution;
|
|||
|
|
float ResolutionWater;
|
|||
|
|
|
|||
|
|
float StartWeight = 0;
|
|||
|
|
float StopWeight = 0;
|
|||
|
|
float WaterPercent = 0.0f;
|
|||
|
|
float WeightOld = 0.0f;
|
|||
|
|
uint16_t CountNochange = 0;
|
|||
|
|
uint16_t CountDelay = 0;
|
|||
|
|
uint8_t SCount = 0;
|
|||
|
|
uint16_t SRange = 100;
|
|||
|
|
float DisData = 0;
|
|||
|
|
uint8_t NameBuf[40];
|
|||
|
|
uint8_t startTime[20];
|
|||
|
|
bool Finisflag = false;
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
void FM24DataCRC()
|
|||
|
|
{
|
|||
|
|
FM24_Read(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
FM24_Read(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
FM24_Read(CalibrateWeight2Set, (uint8_t *)&CalibrateWeight2, sizeof(CalibrateWeight2));
|
|||
|
|
if (CalibrateWeight2.WeightSlope < 0.0000001) {
|
|||
|
|
CalibrateWeight2.WeightSlope = 0.0000001;
|
|||
|
|
}
|
|||
|
|
if ((CRCHead != Set.CRC_Head) || (CRCEnd != Set.CRC_Tail)) { // <20><><EFBFBD><EFBFBD>EEPROM<4F>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>Ĭ<EFBFBD><C4AC>ֵ
|
|||
|
|
Set.CRC_Head = CRCHead;
|
|||
|
|
Set.AutoTimeStop = 60; // 60<36><30>
|
|||
|
|
Set.AutoWeightChange = 5; // 5mg
|
|||
|
|
Set.TempSet = 105; // 105<30><35>
|
|||
|
|
Set.TimeStop = 5; // 5<><35><EFBFBD><EFBFBD>
|
|||
|
|
Set.AutoStyle = 0; // ͣ<><CDA3><EFBFBD><EFBFBD>ʽ <20>Զ<EFBFBD>ͣ<EFBFBD><CDA3>
|
|||
|
|
Set.FastStyle = 0; // <20><><EFBFBD><EFBFBD>ģʽ <20><><EFBFBD><EFBFBD>
|
|||
|
|
Set.FilterQ = 5; // <20>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>
|
|||
|
|
Set.SensorQ = 2; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>
|
|||
|
|
Set.HoldTime = 5; // <20>ȶ<EFBFBD>ʱ<EFBFBD><CAB1> 5<><35>
|
|||
|
|
Set.RuBianLiang = 6; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Set.RuBianTime = 8; // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
Set.ZeroTrack = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Set.TempDelta = 0; // У<D0A3>¶Ȳ<C2B6>
|
|||
|
|
Set.WeightSet = 0; // У<D0A3><D7BC><EFBFBD><EFBFBD>
|
|||
|
|
Set.BaudRate = 9600; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Set.SW0 = false; // <20>Զ<EFBFBD><D4B6>忪<EFBFBD><E5BFAA>1
|
|||
|
|
Set.SW1 = false; // <20>Զ<EFBFBD><D4B6>忪<EFBFBD><E5BFAA>2
|
|||
|
|
Set.SW2 = false; // <20>Զ<EFBFBD><D4B6>忪<EFBFBD><E5BFAA>3
|
|||
|
|
Set.PercentChange = false; // Ĭ<><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ˮ<EFBFBD><CBAE>
|
|||
|
|
sprintf((char *)Set.Title, "<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>"); // <20><><EFBFBD><EFBFBD>
|
|||
|
|
sprintf((char *)Set.TitleOne, "ɽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾"); // <20><><EFBFBD><EFBFBD>1
|
|||
|
|
sprintf((char *)Set.TitleTwo, ""); // <20><><EFBFBD><EFBFBD>2
|
|||
|
|
sprintf((char *)Set.TitleThree, ""); // <20><><EFBFBD><EFBFBD>3
|
|||
|
|
sprintf((char *)Set.UserName, "ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); // <20>û<EFBFBD><C3BB><EFBFBD>
|
|||
|
|
sprintf((char *)Set.UserPwd, "123456"); // <20><><EFBFBD><EFBFBD>
|
|||
|
|
Set.CRC_Tail = CRCEnd;
|
|||
|
|
// FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
CalibrateWeight2.WeightSlope = 0.0000818f;
|
|||
|
|
CalibrateWeight2.WeightZero = 745430;
|
|||
|
|
// FM24_Write(CalibrateWeight2Set, (uint8_t *)&CalibrateWeight2, sizeof(CalibrateWeight2));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//bool t17Dis = false;
|
|||
|
|
//uint16_t t17DisCount =0;
|
|||
|
|
bool t18Dis = false;
|
|||
|
|
uint16_t t18DisCount =0;
|
|||
|
|
osSemaphoreId semDataChange;
|
|||
|
|
void DataUnpack(const void *p_arg)
|
|||
|
|
{
|
|||
|
|
static uint8_t buf[150]__attribute__((at(0x20000000 + 0x1000)));
|
|||
|
|
osSemaphoreDef(semDataChange);
|
|||
|
|
semDataChange = osSemaphoreCreate(osSemaphore(semDataChange), 0);
|
|||
|
|
uint8_t i, j;
|
|||
|
|
for (;;) //
|
|||
|
|
{
|
|||
|
|
osSemaphoreWait(semDataBack, osWaitForever);
|
|||
|
|
switch ((DataInbuf[1] << 8) | (DataInbuf[2])) // ҳ<><D2B3><EFBFBD>ؼ<EFBFBD>ID
|
|||
|
|
{
|
|||
|
|
case 0x0002: // <20><>ʼ<EFBFBD><CABC>ť
|
|||
|
|
if (weightChanging) {
|
|||
|
|
sprintf((char *)buf, "play 1,3,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// sprintf((char *)buf, "t17.txt=\"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
// DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// t17Dis = true;
|
|||
|
|
// t17DisCount =0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (WeightData2 < 1) {
|
|||
|
|
sprintf((char *)buf, "play 1,6,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// sprintf((char *)buf, "t17.txt=\"<22><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
// DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// t17Dis = true;
|
|||
|
|
// t17DisCount =0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (WeightData2 > MaxWeight) {
|
|||
|
|
sprintf((char *)buf, "play 1,7,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// sprintf((char *)buf, "t17.txt=\"<22><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
// DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// t17Dis = true;
|
|||
|
|
// t17DisCount =0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (SafeCheck())
|
|||
|
|
{ // <20><><EFBFBD>رռ<D8B1><D5BC>Ȳ<EFBFBD>
|
|||
|
|
sprintf((char *)buf, "play 1,8,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// sprintf((char *)buf, "t17.txt=\"<22><><EFBFBD>رռ<D8B1><D5BC>Ȳ<EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
// DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// t17Dis = true;
|
|||
|
|
// t17DisCount =0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sprintf((char *)buf, "play 1,5,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(100);
|
|||
|
|
pageNum = 1;
|
|||
|
|
sprintf((char *)startTime, "%04d-%02d-%02d %02d:%02d", (DataInbuf[4] << 8 | DataInbuf[3]), DataInbuf[5], DataInbuf[6], DataInbuf[7], DataInbuf[8]);
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[9])) - 1; i++) {
|
|||
|
|
NameBuf[i] = DataInbuf[i + 9];
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 0x0016: // <20><>ʱͣ<CAB1><CDA3>ʱ<EFBFBD><CAB1>
|
|||
|
|
{
|
|||
|
|
uint16_t TimeSt = DataInbuf[3] + (DataInbuf[4] << 8);
|
|||
|
|
if (TimeSt == 0) {
|
|||
|
|
Set.TimeStop = 1;
|
|||
|
|
} else if (TimeSt > 99) {
|
|||
|
|
Set.TimeStop = 99;
|
|||
|
|
} else {
|
|||
|
|
Set.TimeStop = TimeSt;
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "main.n0.val=%d\xFF\xFF\xFF\0", Set.TimeStop);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0017: // <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
|||
|
|
{
|
|||
|
|
uint16_t TempSe = DataInbuf[3] + (DataInbuf[4] << 8);
|
|||
|
|
if (TempSe < 40) {
|
|||
|
|
Set.TempSet = 40;
|
|||
|
|
} else if (TempSe > MaxTemp) {
|
|||
|
|
Set.TempSet = MaxTemp;
|
|||
|
|
} else {
|
|||
|
|
Set.TempSet = TempSe;
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "main.n1.val=%d\xFF\xFF\xFF\0", Set.TempSet);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0014: // <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
|
|||
|
|
i = 0;
|
|||
|
|
osDelay(100);
|
|||
|
|
sprintf((char *)buf, "tsw b1,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
do {
|
|||
|
|
i++;
|
|||
|
|
if (fabs(CalibrateWeight2.WeightZero - ADvalue2filter) > 10) {
|
|||
|
|
CalibrateWeight2.WeightZero = ADvalue2filter;
|
|||
|
|
osDelay(600);
|
|||
|
|
} else {
|
|||
|
|
sprintf((char *)buf, "t18.txt=\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
t18Dis = true;
|
|||
|
|
t18DisCount =0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
} while (i < 12);
|
|||
|
|
if( i >= 12)
|
|||
|
|
{
|
|||
|
|
sprintf((char *)buf, "t18.txt=\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
t18Dis = true;
|
|||
|
|
t18DisCount =0;
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "tsw b1,1\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
FM24_Write(CalibrateWeight2Set, (uint8_t *)&CalibrateWeight2, sizeof(CalibrateWeight2));
|
|||
|
|
break;
|
|||
|
|
case 0x0022: // ͣ<><CDA3><EFBFBD><EFBFBD>ʽ
|
|||
|
|
Set.AutoStyle = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0023: // <20><><EFBFBD><EFBFBD>ģʽ
|
|||
|
|
Set.FastStyle = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0101: // ֹͣ/<2F><><EFBFBD>ذ<EFBFBD>ť
|
|||
|
|
if ((Set.AutoStyle == 1) && (!Finisflag)) {
|
|||
|
|
Finisflag = true;
|
|||
|
|
} else {
|
|||
|
|
Finisflag = false;
|
|||
|
|
pageNum = 0;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 0x0129: // <20><><EFBFBD><EFBFBD>
|
|||
|
|
sprintf((char *)buf, "DataDeal.DataLog.insert(\"%s^%s^%.3fg^%.3fg^%.2f%%^%.2f%%\")\xFF\xFF\xFF\0", NameBuf, startTime, StartWeight, StopWeight, WaterPercent, 100.0f - WaterPercent);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.t8.txt=\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x012A: // <20><>ӡ
|
|||
|
|
sprintf((char *)buf, "/****************************/\r\n %s\r\n\0", Set.Title);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
if (Set.SW0) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleOne);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
if (Set.SW1) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleTwo);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
if (Set.SW2) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleThree);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, " <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>%s\r\n <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺%s\r\n <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%.3fg\r\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %.3fg\r\n <20><>ˮ<EFBFBD><CBAE>: %.2f%% \r\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %.2f%%\r\n \0", NameBuf, startTime, StartWeight, StopWeight, WaterPercent, 100.0f - WaterPercent);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "/****************************/\r\n\r\n\r\n\r\n \0");
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x012B: // <20><>ѯ
|
|||
|
|
break;
|
|||
|
|
case 0x012C://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>
|
|||
|
|
Set.PercentChange = !Set.PercentChange;
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0201: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
sprintf((char *)buf, "page WeightSet\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
pageNum = 3;
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb5.val=%d\xFF\xFF\xFF\0", Set.FilterQ);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb4.val=%d\xFF\xFF\xFF\0", Set.RuBianLiang);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb3.val=%d\xFF\xFF\xFF\0", Set.SensorQ);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb2.val=%d\xFF\xFF\xFF\0", Set.RuBianTime);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb1.val=%d\xFF\xFF\xFF\0", Set.HoldTime);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb0.val=%d\xFF\xFF\xFF\0", Set.ZeroTrack);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.n0.val=%d\xFF\xFF\xFF\0", Set.AutoTimeStop);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.n1.val=%d\xFF\xFF\xFF\0", Set.AutoWeightChange);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0202: // <20>궨<EFBFBD><EAB6A8><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 4;
|
|||
|
|
break;
|
|||
|
|
case 0x0203: // <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 5;
|
|||
|
|
break;
|
|||
|
|
case 0x0206: // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 8;
|
|||
|
|
sprintf((char *)buf, "SysSet.t14.txt=\"%s\"\xFF\xFF\xFF\0", Set.UserName);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "SysSet.t0.txt=\"\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0207: // <20><><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 0;
|
|||
|
|
break;
|
|||
|
|
case 0x030C: // <20>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>
|
|||
|
|
Set.FilterQ = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x030A: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>
|
|||
|
|
Set.SensorQ = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0308: // <20>ȶ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
Set.HoldTime = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x030B: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Set.RuBianLiang = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0309: // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
Set.RuBianTime = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0307: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Set.ZeroTrack = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0301: // <20>Զ<EFBFBD>ͣ<EFBFBD><CDA3>ʱ<EFBFBD><CAB1>
|
|||
|
|
if(DataInbuf[3] <= 5)
|
|||
|
|
{
|
|||
|
|
Set.AutoTimeStop = 5;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
if(DataInbuf[3] > 120)
|
|||
|
|
{
|
|||
|
|
Set.AutoTimeStop = 120;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Set.AutoTimeStop = DataInbuf[3];
|
|||
|
|
}
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0302: // <20>Զ<EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(DataInbuf[3] <= 5)
|
|||
|
|
{
|
|||
|
|
Set.AutoWeightChange = 5;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
if(DataInbuf[3] > 200)
|
|||
|
|
{
|
|||
|
|
Set.AutoWeightChange = 200;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Set.AutoWeightChange = DataInbuf[3];
|
|||
|
|
}
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0310: // <20><><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 2;
|
|||
|
|
break;
|
|||
|
|
case 0x0401:
|
|||
|
|
Set.TempDelta = (DataInbuf[3] + (DataInbuf[4] << 8)) / 10.0f - (Temperature - Set.TempDelta);
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0403:
|
|||
|
|
CalibrateWeight2.WeightSlope = ((DataInbuf[3] + (DataInbuf[4] << 8) + (DataInbuf[5] << 16) + (DataInbuf[6] << 24)) / 10000.0f) / ((int32_t)ADvalue2filter - (int32_t)CalibrateWeight2.WeightZero);
|
|||
|
|
FM24_Write(CalibrateWeight2Set, (uint8_t *)&CalibrateWeight2, sizeof(CalibrateWeight2));
|
|||
|
|
break;
|
|||
|
|
case 0x0406:
|
|||
|
|
CalibrateWeight2.WeightZero = ADvalue2filter;
|
|||
|
|
break;
|
|||
|
|
case 0x040A: // <20><><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 2;
|
|||
|
|
break;
|
|||
|
|
case 0x0501:
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[3])) - 1; i++) {
|
|||
|
|
Set.Title[i] = DataInbuf[i + 3];
|
|||
|
|
}
|
|||
|
|
Set.Title[i] = '\0';
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0502:
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[3])) - 1; i++) {
|
|||
|
|
Set.TitleOne[i] = DataInbuf[i + 3];
|
|||
|
|
}
|
|||
|
|
Set.TitleOne[i] = '\0';
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0503:
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[3])) - 1; i++) {
|
|||
|
|
Set.TitleTwo[i] = DataInbuf[i + 3];
|
|||
|
|
}
|
|||
|
|
Set.TitleTwo[i] = '\0';
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0504:
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[3])) - 1; i++) {
|
|||
|
|
Set.TitleThree[i] = DataInbuf[i + 3];
|
|||
|
|
}
|
|||
|
|
Set.TitleThree[i] = '\0';
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0506:
|
|||
|
|
Set.SW0 = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0507:
|
|||
|
|
|
|||
|
|
switch(DataInbuf[3] + (DataInbuf[4] << 8) + (DataInbuf[5] << 16) + (DataInbuf[6] << 24) )
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
Set.BaudRate = 1200;
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
Set.BaudRate = 2400;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
Set.BaudRate = 4800;
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
Set.BaudRate = 9600;
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
Set.BaudRate = 19200;
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
Set.BaudRate = 38400;
|
|||
|
|
break;
|
|||
|
|
case 6:
|
|||
|
|
Set.BaudRate = 57600;
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
default:
|
|||
|
|
Set.BaudRate = 115200;
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
BIOS_USART2_Init(Set.BaudRate);
|
|||
|
|
break;
|
|||
|
|
case 0x0512:
|
|||
|
|
Set.SW1 = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x0513:
|
|||
|
|
Set.SW2 = DataInbuf[3];
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
break;
|
|||
|
|
case 0x050E: // <20><><EFBFBD><EFBFBD>
|
|||
|
|
pageNum = 2;
|
|||
|
|
break;
|
|||
|
|
case 0x0704:
|
|||
|
|
// <20><>ӡ
|
|||
|
|
for (i = 0; i < strlen((const char *)(&DataInbuf[3])) - 1; i++) {
|
|||
|
|
DataLogValue[i] = DataInbuf[i + 3];
|
|||
|
|
}
|
|||
|
|
uint8_t NameBufSelect[30];
|
|||
|
|
uint8_t startTimeSelect[30];
|
|||
|
|
uint8_t StartWeightSelect[20];
|
|||
|
|
uint8_t StopWeightSelect[20];
|
|||
|
|
uint8_t WaterPercentSelect[20];
|
|||
|
|
uint8_t WaterPercentSelect_1[20];
|
|||
|
|
i = 0;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
NameBufSelect[j++] = DataLogValue[i++];
|
|||
|
|
} while (DataLogValue[i] != '^');
|
|||
|
|
i++;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
startTimeSelect[j++] = DataLogValue[i++];
|
|||
|
|
} while (DataLogValue[i] != '^');
|
|||
|
|
i++;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
StartWeightSelect[j++] = DataLogValue[i++];
|
|||
|
|
} while (DataLogValue[i] != '^');
|
|||
|
|
i++;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
StopWeightSelect[j++] = DataLogValue[i++];
|
|||
|
|
} while (DataLogValue[i] != '^');
|
|||
|
|
i++;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
WaterPercentSelect[j++] = DataLogValue[i++];
|
|||
|
|
} while (DataLogValue[i] != '^');
|
|||
|
|
i++;
|
|||
|
|
j = 0;
|
|||
|
|
do {
|
|||
|
|
WaterPercentSelect_1[j++] = DataLogValue[i++];
|
|||
|
|
} while (i < strlen((const char *)DataLogValue));
|
|||
|
|
sprintf((char *)buf, "/****************************/\r\n %s\r\n\0", Set.Title);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(200);
|
|||
|
|
if (Set.SW0) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleOne);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(200);
|
|||
|
|
}
|
|||
|
|
if (Set.SW1) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleTwo);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(200);
|
|||
|
|
}
|
|||
|
|
if (Set.SW2) {
|
|||
|
|
sprintf((char *)buf, " %s\r\n\0", Set.TitleThree);
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(200);
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, " <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>%s\r\n <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺%s\r\n <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s\r\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %s\r\n <20><>ˮ<EFBFBD><CBAE>: %s \r\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %s\r\n \0", NameBufSelect, startTimeSelect, StartWeightSelect, StopWeightSelect, WaterPercentSelect, WaterPercentSelect_1 );
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(200);
|
|||
|
|
sprintf((char *)buf, "/****************************/\r\n\r\n\r\n\r\n \0");
|
|||
|
|
USART2Print(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0801:
|
|||
|
|
sprintf((char *)buf, "page SysSet\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0802:
|
|||
|
|
sprintf((char *)buf, "page VL\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0803:
|
|||
|
|
sprintf((char *)buf, "page About\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0809:
|
|||
|
|
j = 0;
|
|||
|
|
uint8_t NameBuf[16];
|
|||
|
|
uint8_t PwdBuf[16];
|
|||
|
|
i = 3;
|
|||
|
|
do {
|
|||
|
|
NameBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (DataInbuf[i] != '^');
|
|||
|
|
j = 0;
|
|||
|
|
i++;
|
|||
|
|
do {
|
|||
|
|
PwdBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (i < strlen((const char *)DataInbuf) - 1);
|
|||
|
|
if ((strcmp((const char *)NameBuf, (const char *)Set.UserName) == 0) && (strcmp((const char *)PwdBuf, (const char *)Set.UserPwd) == 0)) {
|
|||
|
|
sprintf((char *)buf, "UserLogIn.t14.txt=%s\xFF\xFF\xFF\0", NameBuf);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "UserLogIn.t0.txt=\"\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "UserLogIn.t3.txt=\"\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "page UserLogIn\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
pageNum = 9;
|
|||
|
|
} else {
|
|||
|
|
sprintf((char *)buf, "play 1,1,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 0x0909:
|
|||
|
|
j = 0;
|
|||
|
|
i = 3;
|
|||
|
|
do {
|
|||
|
|
NameBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (DataInbuf[i] != '^');
|
|||
|
|
j = 0;
|
|||
|
|
i++;
|
|||
|
|
do {
|
|||
|
|
PwdBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (i < strlen((const char *)DataInbuf) - 1);
|
|||
|
|
strcpy((char *)Set.UserName, (const char *)NameBuf);
|
|||
|
|
strcpy((char *)Set.UserPwd, (const char *)PwdBuf);
|
|||
|
|
FM24_Write(RW_Set, (uint8_t *)&Set, sizeof(Set));
|
|||
|
|
case 0x0C00:
|
|||
|
|
pageNum = 0;
|
|||
|
|
break;
|
|||
|
|
case 0x0C01:
|
|||
|
|
sprintf((char *)buf, "LogIn.t14.txt=\"%s\"\xFF\xFF\xFF\0", Set.UserName);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
break;
|
|||
|
|
case 0x0D05:
|
|||
|
|
j = 0;
|
|||
|
|
i = 3;
|
|||
|
|
do {
|
|||
|
|
NameBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (DataInbuf[i] != '^');
|
|||
|
|
j = 0;
|
|||
|
|
i++;
|
|||
|
|
do {
|
|||
|
|
PwdBuf[j++] = DataInbuf[i++];
|
|||
|
|
} while (i < strlen((const char *)DataInbuf) - 1);
|
|||
|
|
if ((strcmp((const char *)NameBuf, (const char *)Set.UserName) == 0) && (strcmp((const char *)PwdBuf, (const char *)Set.UserPwd) == 0)) {
|
|||
|
|
sprintf((char *)buf, "page main\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
pageNum = 0;
|
|||
|
|
} else {
|
|||
|
|
sprintf((char *)buf, "play 1,1,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
osSemaphoreRelease(semDataChange);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#include "math.h"
|
|||
|
|
extern float OutputMax; uint32_t LastTick, lostTick;
|
|||
|
|
uint8_t Err = 0;
|
|||
|
|
void Moisturing(const void *p_arg)
|
|||
|
|
{
|
|||
|
|
static uint8_t buf[150]__attribute__((at(0x20000000 + 0x1200)));
|
|||
|
|
uint8_t TempRefresh = 0;
|
|||
|
|
uint16_t SRangeTemp = 100;
|
|||
|
|
bool PercentChg = Set.PercentChange;
|
|||
|
|
FM24DataCRC();
|
|||
|
|
osDelay(1000);
|
|||
|
|
CalibrateWeight2.WeightZero = ADvalue2filter;
|
|||
|
|
BIOS_USART2_Init(Set.BaudRate);
|
|||
|
|
float WeightDataS = 0;
|
|||
|
|
sprintf((char *)buf, "main.t6.txt=\"Max=%dg D=%1.3fg\"\xFF\xFF\xFF\0", MaxWeight, Resolution);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(300);
|
|||
|
|
sprintf((char *)buf, "RunPage.t6.txt=\"Max=%dg D=%1.3fg\"\xFF\xFF\xFF\0", MaxWeight, Resolution);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
for (;;) {
|
|||
|
|
if (pageNum == 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
sprintf((char *)buf, "main.cb1.val=%d\xFF\xFF\xFF\0", Set.FastStyle);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "main.n1.val=%d\xFF\xFF\xFF\0", Set.TempSet);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "main.cb0.val=%d\xFF\xFF\xFF\0", Set.AutoStyle);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "main.n0.val=%d\xFF\xFF\xFF\0", Set.TimeStop);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
WeightDataS = (float)(((int32_t)((WeightData2+Resolution / 2) / Resolution)) * Resolution);
|
|||
|
|
if (WeightDataS <= MaxWeight) {
|
|||
|
|
sprintf((char *)buf, "main.t0.txt=\"%3.3f\"\xFF\xFF\xFF\0", WeightDataS);
|
|||
|
|
} else {
|
|||
|
|
sprintf((char *)buf, "main.t0.txt=\"---.---\"\xFF\xFF\xFF\0");
|
|||
|
|
}
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "main.t5.txt=\"%s\"\xFF\xFF\xFF\0", Set.UserName);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
|
|||
|
|
sprintf((char *)buf, "main.t12.txt=\"%3.0f\"\xFF\xFF\xFF\0", Temperature);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "page main\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
while (pageNum == 0) {
|
|||
|
|
// if(t17Dis == true)
|
|||
|
|
// {
|
|||
|
|
// if(t17DisCount ++ > 5)
|
|||
|
|
// {
|
|||
|
|
// t17Dis = false;
|
|||
|
|
// t17DisCount = 0;
|
|||
|
|
// sprintf((char *)buf, "t17.txt=\" \"\xFF\xFF\xFF\0");
|
|||
|
|
// DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
// osDelay(100);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// t17DisCount = 0;
|
|||
|
|
// }
|
|||
|
|
if(t18Dis == true)
|
|||
|
|
{
|
|||
|
|
if(t18DisCount ++ > 5)
|
|||
|
|
{
|
|||
|
|
t18Dis = false;
|
|||
|
|
t18DisCount = 0;
|
|||
|
|
sprintf((char *)buf, "t18.txt=\" \"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
osDelay(100);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
t18DisCount = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WeightDataS = (float)(((int32_t)((WeightData2+Resolution / 2) / Resolution)) * Resolution);
|
|||
|
|
if (WeightDataS <= MaxWeight) {
|
|||
|
|
sprintf((char *)buf, "main.t0.txt=\"%3.3f\"\xFF\xFF\xFF\0", WeightDataS);
|
|||
|
|
} else {
|
|||
|
|
sprintf((char *)buf, "main.t0.txt=\"---.---\"\xFF\xFF\xFF\0");
|
|||
|
|
}
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
if (TempRefresh++ > 3) {
|
|||
|
|
TempRefresh = 0;
|
|||
|
|
sprintf((char *)buf, "main.t12.txt=\"%3.0f\"\xFF\xFF\xFF\0", Temperature);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
osSemaphoreWait(semDataChange, 300);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (pageNum == 1) // <20><><EFBFBD>н<EFBFBD><D0BD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
CountDelay = 0;
|
|||
|
|
CountNochange = 0;
|
|||
|
|
WeightDataS = (float)(((int32_t)((WeightData2+Resolution / 2) / Resolution)) * Resolution);
|
|||
|
|
StartWeight = WeightDataS;
|
|||
|
|
switch (Set.FastStyle) {
|
|||
|
|
case 0:
|
|||
|
|
OutputMax = 1;
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
OutputMax = 0.75;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
OutputMax = 0.5;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "RunPage.t7.txt=\"%s\"\xFF\xFF\xFF\0", Set.PercentChange?"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>":"<EFBFBD><EFBFBD>ˮ<EFBFBD><EFBFBD>");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.t5.txt=\"%s\"\xFF\xFF\xFF\0", Set.UserName);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.t14.txt=\"%s\"\xFF\xFF\xFF\0", NameBuf);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.cb0.val=%d\xFF\xFF\xFF\0", Set.FastStyle);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.n2.val=%d\xFF\xFF\xFF\0", Set.TempSet);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.cb1.val=%d\xFF\xFF\xFF\0", Set.AutoStyle);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.n3.val=%d\xFF\xFF\xFF\0", Set.TimeStop);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
if (SafeCheck()) { // <20><><EFBFBD>رռ<D8B1><D5BC>Ȳ<EFBFBD>
|
|||
|
|
sprintf((char *)buf, "play 1,8,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
do {
|
|||
|
|
osDelay(300);
|
|||
|
|
} while ((SafeCheck()) && (pageNum == 1));
|
|||
|
|
}
|
|||
|
|
Pump_OutCmd(true);
|
|||
|
|
osSemaphoreWait(semDataChange, 800);
|
|||
|
|
sprintf((char *)buf, "cle s0.id,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "page RunPage\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "cle s0.id,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "va0.val=0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "tm0.en=1\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
DisData = WeightOld = WeightDataS;
|
|||
|
|
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|||
|
|
const uint32_t oneTick = osKernelSysTickMicroSec(1000u); // <><CEA2><EFBFBD><EFBFBD>ʱ oneTick 1ms
|
|||
|
|
|
|||
|
|
LastTick = osKernelSysTick();
|
|||
|
|
// osDelay(60000);
|
|||
|
|
// lostTick = (osKernelSysTick() - LastTick)/oneTick;
|
|||
|
|
do {
|
|||
|
|
if (SafeCheck()) { // <20><><EFBFBD>رռ<D8B1><D5BC>Ȳ<EFBFBD>
|
|||
|
|
sprintf((char *)buf, "play 1,8,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
Pump_OutCmd(false);
|
|||
|
|
do {
|
|||
|
|
osDelay(300);
|
|||
|
|
} while ((SafeCheck()) && (pageNum == 1));
|
|||
|
|
Pump_OutCmd(true);
|
|||
|
|
}
|
|||
|
|
// <09><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>ȥ<EFBFBD><C8A5>tick<63><6B>ʱ<EFBFBD><CAB1>λ
|
|||
|
|
lostTick = (uint32_t)(osKernelSysTick() + oneTick / 2 - LastTick) / oneTick;
|
|||
|
|
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>(<28>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD>ʱ<EFBFBD>䣺300ms)
|
|||
|
|
if (lostTick < 300u) {
|
|||
|
|
osDelay(300u - lostTick);
|
|||
|
|
LastTick = osKernelSysTick();
|
|||
|
|
} else { // <09>Ѿ<EFBFBD><D1BE><EFBFBD>ȥ<EFBFBD><C8A5>ʱ<EFBFBD>䳬<EFBFBD><E4B3AC><EFBFBD>趨<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
osDelay(30);
|
|||
|
|
LastTick = osKernelSysTick();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
StopWeight = DisData;
|
|||
|
|
switch (Set.AutoStyle) {
|
|||
|
|
case 0: // <20>Զ<EFBFBD>ģʽ
|
|||
|
|
if (CountNochange++ > Set.AutoTimeStop * (1000 / 300)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨ʱ<E8B6A8><CAB1>ʱ<EFBFBD><CAB1>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
Finisflag = true;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 1: // <20>ֶ<EFBFBD>ģʽ
|
|||
|
|
break;
|
|||
|
|
case 2: // <20><>ʱģʽ
|
|||
|
|
if (CountDelay++ > Set.TimeStop * 60 * (1000 / 300)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨ʱ<E8B6A8><CAB1>ʱ<EFBFBD><CAB1>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>)
|
|||
|
|
{
|
|||
|
|
Finisflag = true;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (Finisflag) {
|
|||
|
|
sprintf((char *)buf, "RunPage.tm0.en=0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
Pump_OutCmd(false);
|
|||
|
|
sprintf((char *)buf, "RunPage.t8.txt=\"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\"\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "play 1,4,0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "tsw b0,1\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "tsw b3,1\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "tsw b1,1\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
do {
|
|||
|
|
osSemaphoreWait(semDataChange, osWaitForever);
|
|||
|
|
} while (pageNum == 1);
|
|||
|
|
}
|
|||
|
|
WeightDataS = (float)(((int32_t)((WeightData2 + Resolution / 2) / Resolution)) * Resolution);
|
|||
|
|
if( WeightData2 >= 0)
|
|||
|
|
{
|
|||
|
|
if (WeightOld - WeightDataS > Resolution) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>0.001gʱ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ֻ<EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD>ܼӣ<DCBC>
|
|||
|
|
{
|
|||
|
|
DisData = WeightDataS;
|
|||
|
|
}
|
|||
|
|
if (WeightOld - WeightDataS > Set.AutoWeightChange / 1000) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>x.xxxgʱ<67><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
CountNochange = 0;
|
|||
|
|
DisData = WeightOld = WeightDataS;
|
|||
|
|
}
|
|||
|
|
if (StartWeight != 0) {
|
|||
|
|
WaterPercent = (float)(((uint32_t)(((StartWeight - DisData) / StartWeight * 100.0f) / ResolutionWater)) * ResolutionWater);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "RunPage.t0.txt=\"%3.3f\"\xFF\xFF\xFF\0", DisData);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.t12.txt=\"%3.0f\"\xFF\xFF\xFF\0", Temperature);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
if( PercentChg != Set.PercentChange )
|
|||
|
|
{
|
|||
|
|
PercentChg = Set.PercentChange;
|
|||
|
|
sprintf((char *)buf, "RunPage.t7.txt=\"%s\"\xFF\xFF\xFF\0", Set.PercentChange?"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>":"<EFBFBD><EFBFBD>ˮ<EFBFBD><EFBFBD>");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "RunPage.t17.txt=\"%2.2f%%\"\xFF\xFF\xFF\0", Set.PercentChange?100.0f-WaterPercent:WaterPercent);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "RunPage.j0.val=%d\xFF\xFF\xFF\0", (uint8_t)WaterPercent);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
if (SCount++ >= 3) {
|
|||
|
|
SCount = 0;
|
|||
|
|
if (WaterPercent <= 38.0f) {
|
|||
|
|
SRangeTemp = 200;
|
|||
|
|
}
|
|||
|
|
if (WaterPercent > 38.0f && WaterPercent < 76.0f) {
|
|||
|
|
SRangeTemp = 100;
|
|||
|
|
}
|
|||
|
|
if (WaterPercent > 76.0f) {
|
|||
|
|
SRangeTemp = 70;
|
|||
|
|
}
|
|||
|
|
if (SRangeTemp != SRange) {
|
|||
|
|
SRange = SRangeTemp;
|
|||
|
|
sprintf((char *)buf, "s0.dis=%d\xFF\xFF\xFF\0", SRange);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
sprintf((char *)buf, "add s0.id,0,%d\xFF\xFF\xFF\0", (uint8_t)(WaterPercent / 100.0f * 255));
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
} while (pageNum == 1);
|
|||
|
|
sprintf((char *)buf, "tm0.en=0\xFF\xFF\xFF\0");
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
Pump_OutCmd(false);
|
|||
|
|
}
|
|||
|
|
if (pageNum == 3) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
if(osSemaphoreWait(semDataChange, 300) > 0)
|
|||
|
|
{
|
|||
|
|
osDelay(50);
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb5.val=%d\xFF\xFF\xFF\0", Set.FilterQ);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb4.val=%d\xFF\xFF\xFF\0", Set.RuBianLiang);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb3.val=%d\xFF\xFF\xFF\0", Set.SensorQ);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb2.val=%d\xFF\xFF\xFF\0", Set.RuBianTime);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb1.val=%d\xFF\xFF\xFF\0", Set.HoldTime);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.cb0.val=%d\xFF\xFF\xFF\0", Set.ZeroTrack);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.n0.val=%d\xFF\xFF\xFF\0", Set.AutoTimeStop);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "WeightSet.n1.val=%d\xFF\xFF\xFF\0", Set.AutoWeightChange);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (pageNum == 4) // У<D0A3><D7BC><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
sprintf((char *)buf, "Calibration.t8.txt=\"%3.4f\"\xFF\xFF\xFF\0", WeightData2);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Calibration.t6.txt=\"%3.0f\"\xFF\xFF\xFF\0", Temperature);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
osSemaphoreWait(semDataChange, 300);
|
|||
|
|
}
|
|||
|
|
if (pageNum == 5) // <20><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
sprintf((char *)buf, "Print.cb0.txt=\"%d\"\xFF\xFF\xFF\0", Set.BaudRate);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.bt0.val=%d\xFF\xFF\xFF\0", Set.SW0 ? 1 : 0);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.bt1.val=%d\xFF\xFF\xFF\0", Set.SW1 ? 1 : 0);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.bt2.val=%d\xFF\xFF\xFF\0", Set.SW2 ? 1 : 0);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.t5.txt=\"%s\"\xFF\xFF\xFF\0", Set.Title);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.t6.txt=\"%s\"\xFF\xFF\xFF\0", Set.TitleOne);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.t7.txt=\"%s\"\xFF\xFF\xFF\0", Set.TitleTwo);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
sprintf((char *)buf, "Print.t8.txt=\"%s\"\xFF\xFF\xFF\0", Set.TitleThree);
|
|||
|
|
DataPrint(buf, strlen((const char *)buf));
|
|||
|
|
osSemaphoreWait(semDataChange, 300);
|
|||
|
|
}
|
|||
|
|
if (pageNum == 6) // <20><><EFBFBD>ݼ<EFBFBD>¼
|
|||
|
|
{
|
|||
|
|
osSemaphoreWait(semDataChange, 300);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
osThreadDef(Moisturing, osPriorityNormal, 1, 0);
|
|||
|
|
void MoisturingRun()
|
|||
|
|
{
|
|||
|
|
osThreadCreate(osThread(Moisturing), NULL);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
osThreadDef(DataUnpack, osPriorityNormal, 1, 0);
|
|||
|
|
void HMICMDInit()
|
|||
|
|
{
|
|||
|
|
osThreadCreate(osThread(DataUnpack), NULL);
|
|||
|
|
MoisturingRun();
|
|||
|
|
}
|