测试图表可以跳动

This commit is contained in:
zogodo
2019-10-10 23:14:32 +08:00
parent 470a7af3ee
commit bb3ea7ae0d
6 changed files with 27 additions and 45 deletions

View File

@@ -109,6 +109,7 @@ static int HttpGetPowerInfo(httpd_request_t *req)
char* powers = GetPowerRecord(idx); char* powers = GetPowerRecord(idx);
sprintf(power_info_json, POWER_INFO_JSON, power_record.idx, PW_NUM, powers); sprintf(power_info_json, POWER_INFO_JSON, power_record.idx, PW_NUM, powers);
power_record.idx++; //test
send_http(power_info_json, strlen(power_info_json), exit, &err); send_http(power_info_json, strlen(power_info_json), exit, &err);
exit: exit:
return err; return err;
@@ -118,7 +119,7 @@ static int HttpGetWifiConfig(httpd_request_t *req)
{ {
OSStatus err = kNoErr; OSStatus err = kNoErr;
const unsigned char* status = GetSocketStatus(); const unsigned char* status = GetSocketStatus();
send_http(status, strlen(status), exit, &err); send_http(status, strlen((char*)status), exit, &err);
exit: exit:
return err; return err;
} }

View File

@@ -56,7 +56,7 @@
'gateway':'%s'\ 'gateway':'%s'\
}" }"
#define POWER_INFO_JSON "{'idx':%d,'len':%d,'powers:[%s]'}" #define POWER_INFO_JSON "{'idx':%d,'len':%d,'powers':[%s]}"
int AppHttpdStart(void); int AppHttpdStart(void);
int AppHttpdStop(); int AppHttpdStop();

View File

@@ -81,41 +81,7 @@
<div class="line"></div> <div class="line"></div>
</div> </div>
<div id="power_line"> <div id="power_line">
<div class="power_pre" style="height:70px;left:20px;"></div> <!-- <div class="power_pre" style="height:70px;left:20px;"></div> -->
<div class="power_pre" style="height:75px;left:40px;"></div>
<div class="power_pre" style="height:80px;left:60px;"></div>
<div class="power_pre" style="height:85px;left:80px;"></div>
<div class="power_pre" style="height:80px;left:100px;"></div>
<div class="power_pre" style="height:75px;left:120px;"></div>
<div class="power_pre" style="height:70px;left:140px;"></div>
<div class="power_pre" style="height:65px;left:160px;"></div>
<div class="power_pre" style="height:70px;left:180px;"></div>
<div class="power_pre" style="height:75px;left:200px;"></div>
<div class="power_pre" style="height:80px;left:220px;"></div>
<div class="power_pre" style="height:85px;left:240px;"></div>
<div class="power_pre" style="height:90px;left:260px;"></div>
<div class="power_pre" style="height:85px;left:280px;"></div>
<div class="power_pre" style="height:80px;left:300px;"></div>
<div class="power_pre" style="height:78px;left:320px;"></div>
<div class="power_pre" style="height:76px;left:340px;"></div>
<div class="power_pre" style="height:72px;left:360px;"></div>
<div class="power_pre" style="height:85px;left:380px;"></div>
<div class="power_pre" style="height:80px;left:400px;"></div>
<div class="power_pre" style="height:75px;left:420px;"></div>
<div class="power_pre" style="height:70px;left:440px;"></div>
<div class="power_pre" style="height:65px;left:460px;"></div>
<div class="power_pre" style="height:70px;left:480px;"></div>
<div class="power_pre" style="height:75px;left:500px;"></div>
<div class="power_pre" style="height:80px;left:520px;"></div>
<div class="power_pre" style="height:85px;left:540px;"></div>
<div class="power_pre" style="height:90px;left:560px;"></div>
<div class="power_pre" style="height:85px;left:580px;"></div>
<div class="power_pre" style="height:80px;left:600px;"></div>
<div class="power_pre" style="height:78px;left:620px;"></div>
<div class="power_pre" style="height:76px;left:640px;"></div>
<div class="power_pre" style="height:72px;left:660px;"></div>
<div class="power_pre" style="height:85px;left:680px;"></div>
<div class="power_pre" style="height:80px;left:700px;"></div>
</div> </div>
</fieldset> </fieldset>
@@ -259,14 +225,19 @@ function GetPowerRecord() {
var power = JSON.parse(re); var power = JSON.parse(re);
power_idx = power.idx + 1; power_idx = power.idx + 1;
var html = ""; var html = "";
for (var i = 0; i <= power.idx; i++) { for (var i = 0; i < power.powers.length; i++) {
html += "<div class='power_pre' style='height:"+power.powers[i]+"px;left:"+position+"px;'></div>"; html += "<div class='power_pre' style='height:"+power.powers[i]+"px;left:"+position+"px;'></div>";
position += 10; position += 10;
} }
if (power.powers.length != 0) {
power_line.innerHTML += html; power_line.innerHTML += html;
power_line.scrollTo(power_line.scrollWidth, 0);
}
//滑动到最后 //滑动到最后
}, idx.toString()); window.setTimeout(GetPowerRecord, 3000);
}, power_idx.toString());
} }
GetPowerRecord();
function SetOK(i) { function SetOK(i) {
submit_bts[i].disabled = false; submit_bts[i].disabled = false;

File diff suppressed because one or more lines are too long

View File

@@ -161,7 +161,7 @@ int application_start(void)
//发送功率数据 //发送功率数据
if (power_last != power || main_num > 4) if (power_last != power || main_num > 4)
{ {
SetPowerRecord(&power_record, power); //SetPowerRecord(&power_record, power);
power_last = power; power_last = power;
main_num =0; main_num =0;
sprintf(power_buf, "{\"mac\":\"%s\",\"power\":\"%u.%u\",\"total_time\":%u}", sprintf(power_buf, "{\"mac\":\"%s\",\"power\":\"%u.%u\",\"total_time\":%u}",

View File

@@ -10,7 +10,17 @@
mico_timer_t power_timer; mico_timer_t power_timer;
PowerRecord power_record = { 44, { 50,55,60,65,70,75,80,85,90,95,90,85,80,75,70,65,60,65,70,75,80,85,90,95,90,85,80,75,70,65,60,65,70,75,80,85,90,95,90,85,80,75,70,65,60 } }; PowerRecord power_record = { 44, {
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99 } };
static uint32_t clock_count_last = 0; static uint32_t clock_count_last = 0;
static uint32_t clock_count = 0; static uint32_t clock_count = 0;
@@ -26,13 +36,13 @@ void SetPowerRecord(PowerRecord* pr, uint32_t pw)
char* GetPowerRecord(int idx) char* GetPowerRecord(int idx)
{ {
if (idx > power_record.idx) return NULL; if (idx > power_record.idx) return "";
int i = idx > 0 ? idx : (power_record.idx - PW_NUM - 1); int i = idx > 0 ? idx : (power_record.idx - PW_NUM - 1);
char* tmp = power_record_str; char* tmp = power_record_str;
for (; i <= power_record.idx; i++) for (; i <= power_record.idx; i++)
{ {
sprintf(tmp, "%d,", power_record.powers[i%PW_NUM]); sprintf(tmp, "%u,", (unsigned int)power_record.powers[i%PW_NUM]);
tmp += strlen(tmp); tmp += strlen(tmp);
} }
*(--tmp) = 0; *(--tmp) = 0;