mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
v1.0.0
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -12,10 +12,12 @@ mico_timer_t power_timer;
|
||||
|
||||
PowerRecord power_record = { 1, { 0 } };
|
||||
|
||||
/*
|
||||
static uint32_t clock_count_last = 0;
|
||||
static uint32_t clock_count = 0;
|
||||
static uint32_t timer_count = 0;
|
||||
static uint32_t timer_irq_count = 0;
|
||||
static uint32_t clock_count = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static uint32_t timer_count = 0; //һ<>붨ʱ<EBB6A8><CAB1>
|
||||
static uint32_t timer_irq_count = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||||
*/
|
||||
uint32_t p_count = 0;
|
||||
|
||||
char power_record_str[1101] = { 0 };
|
||||
@@ -41,6 +43,7 @@ char* GetPowerRecord(int idx)
|
||||
return power_record_str;
|
||||
}
|
||||
|
||||
/*
|
||||
static void PowerTimerHandler(void* arg)
|
||||
{
|
||||
uint32_t timer = 0;
|
||||
@@ -72,19 +75,20 @@ static void PowerTimerHandler(void* arg)
|
||||
timer_count++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
float n_1s = 0;
|
||||
mico_time_t t_x = 0;
|
||||
mico_time_t past_ms = 0;
|
||||
mico_time_t rest_ms = 1000;
|
||||
mico_time_t rest_x_ms = 0;
|
||||
mico_time_t rest_y_ms = 0;
|
||||
float n_1s = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD>
|
||||
mico_time_t t_x = 0; //<2F><>ǰ<EFBFBD><C7B0>*1000
|
||||
mico_time_t past_ms = 0; //ϵͳ<CFB5><CDB3><EFBFBD>еĺ<D0B5><C4BA><EFBFBD><EFBFBD><EFBFBD>
|
||||
mico_time_t rest_x_ms = 0; //<2F><><EFBFBD>뵱ǰ<EBB5B1><C7B0><EFBFBD>߹<EFBFBD><DFB9>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD>
|
||||
mico_time_t rest_y_ms = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
static void PowerIrqHandler(void* arg)
|
||||
{
|
||||
clock_count = mico_nanosecond_clock_value();
|
||||
if (timer_irq_count == 0) clock_count_last = clock_count;
|
||||
timer_irq_count++;
|
||||
//clock_count = mico_nanosecond_clock_value();
|
||||
//if (timer_irq_count == 0) clock_count_last = clock_count;
|
||||
//timer_irq_count++;
|
||||
|
||||
p_count++;
|
||||
|
||||
mico_time_get_time(&past_ms);
|
||||
@@ -93,7 +97,7 @@ static void PowerIrqHandler(void* arg)
|
||||
t_x = past_ms - 1;
|
||||
}
|
||||
rest_x_ms = past_ms - t_x;
|
||||
if (rest_x_ms < 1000)
|
||||
if (rest_x_ms <= 1000)
|
||||
{
|
||||
n_1s += 1;
|
||||
rest_y_ms = t_x + 1000 - past_ms;
|
||||
@@ -101,7 +105,7 @@ static void PowerIrqHandler(void* arg)
|
||||
else if (rest_x_ms > 1000 && rest_x_ms < 2000)
|
||||
{
|
||||
n_1s += (float)rest_y_ms / (rest_x_ms - 1000 + rest_y_ms);
|
||||
rest_y_ms = 2000 - t_x;
|
||||
rest_y_ms = 2000 - rest_x_ms;
|
||||
t_x = past_ms / 1000 * 1000;
|
||||
|
||||
float power2 = 17.1 * n_1s;
|
||||
@@ -110,9 +114,12 @@ static void PowerIrqHandler(void* arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
//һ<>㲻<EFBFBD><E3B2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD>...<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~
|
||||
SetPowerRecord(&power_record, 123456);
|
||||
SetPowerRecord(&power_record, past_ms);
|
||||
SetPowerRecord(&power_record, t_x);
|
||||
SetPowerRecord(&power_record, rest_x_ms);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PowerInit(void)
|
||||
@@ -120,7 +127,7 @@ void PowerInit(void)
|
||||
os_log("user_power_init");
|
||||
|
||||
MicoGpioInitialize(POWER, INPUT_PULL_UP);
|
||||
mico_rtos_init_timer(&power_timer, 1000, PowerTimerHandler, NULL);
|
||||
//mico_rtos_init_timer(&power_timer, 1000, PowerTimerHandler, NULL);
|
||||
mico_rtos_start_timer(&power_timer);
|
||||
|
||||
MicoGpioEnableIRQ(POWER, IRQ_TRIGGER_FALLING_EDGE, PowerIrqHandler, NULL);
|
||||
|
||||
Reference in New Issue
Block a user