mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-13 05:28:14 +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 "mico.h"
|
||||||
#include "MiCOKit_EXT.h"
|
#include "MiCOKit_EXT.h"
|
||||||
|
|
||||||
#define VERSION "v0.7"
|
#define VERSION "v0.8"
|
||||||
|
|
||||||
#define TYPE 1
|
#define TYPE 1
|
||||||
#define TYPE_NAME "zTC1"
|
#define TYPE_NAME "zTC1"
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
#define Relay_OFF 0
|
#define Relay_OFF 0
|
||||||
|
|
||||||
#define Relay_0 MICO_GPIO_6
|
#define Relay_0 MICO_GPIO_6
|
||||||
#define Relay_1 MICO_GPIO_7
|
#define Relay_1 MICO_GPIO_8
|
||||||
#define Relay_2 MICO_GPIO_8
|
#define Relay_2 MICO_GPIO_10
|
||||||
#define Relay_3 MICO_GPIO_9
|
#define Relay_3 MICO_GPIO_7
|
||||||
#define Relay_4 MICO_GPIO_10
|
#define Relay_4 MICO_GPIO_9
|
||||||
#define Relay_5 MICO_GPIO_18
|
#define Relay_5 MICO_GPIO_18
|
||||||
#define Relay_NUM PLUG_NUM
|
#define Relay_NUM PLUG_NUM
|
||||||
|
|
||||||
|
|||||||
@@ -9,34 +9,60 @@
|
|||||||
|
|
||||||
mico_timer_t power_timer;
|
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_count = 0;
|
||||||
static uint32_t timer = 0;
|
static uint32_t timer_irq_count = 0;
|
||||||
|
|
||||||
static void power_timer_handler( void* arg )
|
static void power_timer_handler( void* arg )
|
||||||
{
|
{
|
||||||
|
|
||||||
// uint8_t pin_input = MicoGpioInputGet( POWER );
|
// uint8_t pin_input = MicoGpioInputGet( POWER );
|
||||||
if ( timer_count_last != timer_count )
|
uint32_t timer = 0;
|
||||||
{
|
|
||||||
// os_log("power_irq_handler:%u-%u=%u",timer_count,timer_count_last,timer);
|
|
||||||
timer_count_last = timer_count;
|
|
||||||
|
|
||||||
timer=timer/1000;
|
if ( timer_irq_count > 1 )
|
||||||
power=9500000/timer;
|
{
|
||||||
os_log("power_irq_handler:%u,%07u",power,timer);
|
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++;
|
||||||
// timer_count_last=timer_count;
|
// clock_count_last=timer_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void power_irq_handler( void* arg )
|
static void power_irq_handler( void* arg )
|
||||||
{
|
{
|
||||||
// timer_count_last=timer_count;
|
clock_count = mico_nanosecond_clock_value( );
|
||||||
timer_count = mico_nanosecond_clock_value();
|
if ( timer_irq_count == 0 ) clock_count_last = clock_count;
|
||||||
timer=timer_count-timer_count_last;
|
timer_irq_count++;
|
||||||
if(timer_count<timer_count_last) timer+=0xffffffff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_power_init( void )
|
void user_power_init( void )
|
||||||
@@ -44,7 +70,7 @@ void user_power_init( void )
|
|||||||
os_log("user_power_init");
|
os_log("user_power_init");
|
||||||
|
|
||||||
MicoGpioInitialize( POWER, INPUT_PULL_UP );
|
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 );
|
mico_rtos_start_timer( &power_timer );
|
||||||
|
|
||||||
MicoGpioEnableIRQ( POWER, IRQ_TRIGGER_FALLING_EDGE, power_irq_handler, NULL );
|
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