mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
这样写好看点
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "mico.h"
|
||||
#include "micokit_ext.h"
|
||||
|
||||
#define VERSION "v1.0.7"
|
||||
#define VERSION "v1.0.9"
|
||||
|
||||
#define TYPE 1
|
||||
#define TYPE_NAME "zTC1"
|
||||
|
||||
@@ -28,7 +28,7 @@ char* GetPowerRecord(int idx)
|
||||
char* tmp = power_record_str;
|
||||
for (; i <= power_record.idx; i++)
|
||||
{
|
||||
sprintf(tmp, "%u,", (unsigned int)power_record.powers[i%PW_NUM]);
|
||||
sprintf(tmp, "%lu,", power_record.powers[i%PW_NUM]);
|
||||
tmp += strlen(tmp);
|
||||
}
|
||||
*(--tmp) = 0;
|
||||
@@ -36,7 +36,7 @@ char* GetPowerRecord(int idx)
|
||||
}
|
||||
|
||||
uint64_t NS = 1000000000;
|
||||
float n_1s = 0; //在当前一秒秒功率中断次数
|
||||
float n_1s = 0; //在当前这一秒功率中断次数
|
||||
uint64_t past_ns = 0; //系统运行的纳秒数
|
||||
uint64_t irq_old = 0; //上次中断的时间(纳秒)
|
||||
|
||||
@@ -52,9 +52,9 @@ static void PowerIrqHandler(void* arg)
|
||||
{
|
||||
n_1s += 1;
|
||||
irq_old = past_ns;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int n = (spend_ns - past_ns % NS) / NS;
|
||||
n_1s += (float)(NS - irq_old % NS) / spend_ns;
|
||||
float power2 = 17.1 * n_1s;
|
||||
@@ -69,7 +69,6 @@ static void PowerIrqHandler(void* arg)
|
||||
irq_old = past_ns;
|
||||
n_1s = (float)(past_ns % NS) / spend_ns;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerInit(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user