mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
fix:手机插口标号与实际标号不同的问题
fix:优化功率比例系数
This commit is contained in:
10
TC1/main.h
10
TC1/main.h
@@ -4,7 +4,7 @@
|
||||
#include "mico.h"
|
||||
#include "MiCOKit_EXT.h"
|
||||
|
||||
#define VERSION "v0.7"
|
||||
#define VERSION "v0.8"
|
||||
|
||||
#define TYPE 1
|
||||
#define TYPE_NAME "zTC1"
|
||||
@@ -26,10 +26,10 @@
|
||||
#define Relay_OFF 0
|
||||
|
||||
#define Relay_0 MICO_GPIO_6
|
||||
#define Relay_1 MICO_GPIO_7
|
||||
#define Relay_2 MICO_GPIO_8
|
||||
#define Relay_3 MICO_GPIO_9
|
||||
#define Relay_4 MICO_GPIO_10
|
||||
#define Relay_1 MICO_GPIO_8
|
||||
#define Relay_2 MICO_GPIO_10
|
||||
#define Relay_3 MICO_GPIO_7
|
||||
#define Relay_4 MICO_GPIO_9
|
||||
#define Relay_5 MICO_GPIO_18
|
||||
#define Relay_NUM PLUG_NUM
|
||||
|
||||
|
||||
@@ -9,34 +9,60 @@
|
||||
|
||||
mico_timer_t power_timer;
|
||||
|
||||
static uint32_t timer_count_last = 0;
|
||||
static uint32_t clock_count_last = 0;
|
||||
static uint32_t clock_count = 0;
|
||||
static uint32_t timer_count = 0;
|
||||
static uint32_t timer = 0;
|
||||
static uint32_t timer_irq_count = 0;
|
||||
|
||||
static void power_timer_handler( void* arg )
|
||||
{
|
||||
|
||||
// uint8_t pin_input = MicoGpioInputGet( POWER );
|
||||
if ( timer_count_last != timer_count )
|
||||
{
|
||||
// os_log("power_irq_handler:%u-%u=%u",timer_count,timer_count_last,timer);
|
||||
timer_count_last = timer_count;
|
||||
uint32_t timer = 0;
|
||||
|
||||
timer=timer/1000;
|
||||
power=9500000/timer;
|
||||
os_log("power_irq_handler:%u,%07u",power,timer);
|
||||
if ( timer_irq_count > 1 )
|
||||
{
|
||||
timer = (clock_count - clock_count_last);
|
||||
|
||||
os_log("power_irq_handler:%09u %u %u",timer,timer_irq_count,timer_count);
|
||||
if ( timer_count > 3 )
|
||||
{
|
||||
timer /= 1000;
|
||||
timer += 4294967; //0xffffffff/1000;
|
||||
} else if ( clock_count < clock_count_last )
|
||||
{
|
||||
timer += 0xffffffff;
|
||||
timer /= 1000;
|
||||
}else timer/=1000;
|
||||
power = 17100000 * (timer_irq_count - 1) / timer;
|
||||
timer_count = 0;
|
||||
timer_irq_count = 0;
|
||||
} else
|
||||
{
|
||||
timer_count++;
|
||||
}
|
||||
// if(timer_count==0) os_log("power_timer_handler Hight:%d",timer_count_last);
|
||||
|
||||
// if ( clock_count_last != timer_count )
|
||||
// {
|
||||
//// os_log("power_irq_handler:%u-%u=%u",timer_count,clock_count_last,timer);
|
||||
// timer = (timer_count - clock_count_last);
|
||||
// if ( timer_count < clock_count_last ) timer += 0xffffffff;
|
||||
//
|
||||
// timer = timer / 1000;
|
||||
// power = 15200000 / timer;
|
||||
// os_log("power_irq_handler:%u,%07u",power,timer);
|
||||
// clock_count_last = timer_count;
|
||||
// }
|
||||
// if(timer_count==0) os_log("power_timer_handler Hight:%d",clock_count_last);
|
||||
// timer_count++;
|
||||
// timer_count_last=timer_count;
|
||||
// clock_count_last=timer_count;
|
||||
}
|
||||
|
||||
static void power_irq_handler( void* arg )
|
||||
{
|
||||
// timer_count_last=timer_count;
|
||||
timer_count = mico_nanosecond_clock_value();
|
||||
timer=timer_count-timer_count_last;
|
||||
if(timer_count<timer_count_last) timer+=0xffffffff;
|
||||
clock_count = mico_nanosecond_clock_value( );
|
||||
if ( timer_irq_count == 0 ) clock_count_last = clock_count;
|
||||
timer_irq_count++;
|
||||
}
|
||||
|
||||
void user_power_init( void )
|
||||
@@ -44,7 +70,7 @@ void user_power_init( void )
|
||||
os_log("user_power_init");
|
||||
|
||||
MicoGpioInitialize( POWER, INPUT_PULL_UP );
|
||||
mico_rtos_init_timer( &power_timer, 20, power_timer_handler, NULL );
|
||||
mico_rtos_init_timer( &power_timer, 1000, power_timer_handler, NULL );
|
||||
mico_rtos_start_timer( &power_timer );
|
||||
|
||||
MicoGpioEnableIRQ( POWER, IRQ_TRIGGER_FALLING_EDGE, power_irq_handler, NULL );
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user