096111e983
.claude/ 제외(.gitignore 추가). 기존 초기커밋(5a96a69) 위에 신규·수정·이동분 커밋.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
750 lines
17 KiB
C
750 lines
17 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
#include "Nano100Series.h"
|
|
#include "adc.h"
|
|
#include "gpio.h"
|
|
#include "pwm.h"
|
|
#include "timer.h"
|
|
#include "uart.h"
|
|
#include "sys.h"
|
|
#include "clk.h"
|
|
#include "EEPROM_Emulate.h"
|
|
|
|
|
|
#include "My_define.h"
|
|
|
|
|
|
|
|
extern uint8_t Melody_Mode;
|
|
|
|
extern volatile uint8_t Power_On;
|
|
extern volatile uint8_t Tx_Run_Mode;
|
|
extern volatile uint8_t Tx_Fan_Speed;
|
|
extern volatile uint8_t Tx_Reservation_Hour;
|
|
|
|
|
|
extern uint16_t Main_Err_Code;
|
|
extern uint8_t Vsp_Mode;
|
|
|
|
|
|
void delay_us(uint32_t us)
|
|
{
|
|
CLK_SysTickDelay(us);
|
|
}
|
|
|
|
|
|
void delay_ms(uint32_t ms)
|
|
{
|
|
while(ms--)
|
|
{
|
|
delay_us(1000);
|
|
}
|
|
}
|
|
|
|
|
|
void UART0_Init()//co2
|
|
{
|
|
/*---------------------------------------------------------------------------------------------------------*/
|
|
/* Init UART */
|
|
/*---------------------------------------------------------------------------------------------------------*/
|
|
SYS_ResetModule(UART0_RST);
|
|
UART_Open(UART0, 115200);
|
|
|
|
|
|
UART_EnableInt(UART0, UART_IER_RDA_IE_Msk);
|
|
NVIC_EnableIRQ(UART0_IRQn);
|
|
}
|
|
|
|
|
|
void UART1_Init()
|
|
{
|
|
/*---------------------------------------------------------------------------------------------------------*/
|
|
/* Init UART */
|
|
/*---------------------------------------------------------------------------------------------------------*/
|
|
SYS_ResetModule(UART1_RST);
|
|
UART_Open(UART1, 115200);
|
|
|
|
UART_EnableInt(UART1, UART_IER_RDA_IE_Msk);
|
|
NVIC_EnableIRQ(UART1_IRQn);
|
|
}
|
|
|
|
void SC0_Init() // to main
|
|
{
|
|
SCUART_Open(SC0, 1200);
|
|
// Enable smartcard receive interrupt
|
|
SCUART_ENABLE_INT(SC0, SC_IER_RDA_IE_Msk);
|
|
NVIC_EnableIRQ(SC0_IRQn);
|
|
}
|
|
|
|
|
|
void SC1_Init() // to dust
|
|
{
|
|
SCUART_Open(SC1, 9600);
|
|
// Enable smartcard receive interrupt
|
|
SCUART_ENABLE_INT(SC1, SC_IER_RDA_IE_Msk);
|
|
NVIC_EnableIRQ(SC1_IRQn);
|
|
}
|
|
|
|
|
|
|
|
|
|
void PowerDownFunction(void)
|
|
{
|
|
;
|
|
}
|
|
|
|
|
|
|
|
#define IR_EVENT_POWER 0x01
|
|
#define IR_EVENT_MODE 0x02
|
|
#define IR_EVENT_WIND_UP 0x04
|
|
#define IR_EVENT_WIND_DN 0x05
|
|
#define IR_EVENT_TIME_1 0x06
|
|
#define IR_EVENT_TIME_2 0x07
|
|
#define IR_EVENT_TIME_3 0x08
|
|
#define IR_EVENT_FILTER_RESET 0x09
|
|
|
|
#define IR_START 13500
|
|
#define IR_HIGH 2260
|
|
#define IR_LOW 1180
|
|
#define IR_STOP 600
|
|
#define IR_REPEAT 11200
|
|
|
|
uint16_t long_timer1 = 0;
|
|
uint16_t remocon_buff[4];
|
|
uint8_t remocon_pos = 0;
|
|
uint8_t remocon_bit_count = 0;
|
|
|
|
uint8_t IR_Event_Code = 0;
|
|
volatile uint8_t IR_Event_Flag = 0;
|
|
void IR_Receive(void)
|
|
{
|
|
uint16_t tmp = 0;
|
|
|
|
long_timer1 = TIMER2->DR/12;
|
|
TIMER2->CTL |= TIMER_CTL_SW_RST_Msk;
|
|
TIMER_Start(TIMER2);
|
|
|
|
if((long_timer1 > IR_START-300)&&(long_timer1 < IR_START+300))
|
|
{
|
|
remocon_buff[0] = 0;
|
|
remocon_buff[1] = 0;
|
|
remocon_bit_count = 0;
|
|
remocon_pos = 0;
|
|
}
|
|
else if((long_timer1 > IR_REPEAT-300)&&(long_timer1 < IR_REPEAT+300))
|
|
{
|
|
remocon_buff[0] = 0;
|
|
remocon_buff[1] = 0;
|
|
remocon_bit_count = 0;
|
|
remocon_pos = 0;
|
|
}
|
|
else if((long_timer1 > IR_HIGH-200)&&(long_timer1 < IR_HIGH+200))
|
|
{
|
|
remocon_buff[remocon_pos] |= 0x8000;
|
|
if(remocon_bit_count++ >= 15){remocon_bit_count = 0;remocon_pos=1;}
|
|
else {remocon_buff[remocon_pos] >>= 1;}
|
|
}
|
|
else if((long_timer1 > IR_LOW-200)&&(long_timer1 < IR_LOW+200))
|
|
{
|
|
remocon_buff[remocon_pos] &= ~0x8000;
|
|
if(remocon_bit_count++ >= 15){remocon_bit_count = 0;remocon_pos=1;}
|
|
else {remocon_buff[remocon_pos] >>= 1;}
|
|
}
|
|
|
|
if((remocon_pos == 1)&&(remocon_bit_count == 15))
|
|
{
|
|
if(remocon_buff[0] == 0xA55A)
|
|
{
|
|
tmp = remocon_buff[1];
|
|
/* switch(tmp)
|
|
{
|
|
case 0x6E11: // Power
|
|
IR_Event_Code = IR_EVENT_POWER;
|
|
break;
|
|
case 0x6D12: // mode
|
|
IR_Event_Code = IR_EVENT_MODE;
|
|
break;
|
|
case 0x6C13: // up
|
|
IR_Event_Code = IR_EVENT_WIND_UP;
|
|
break;
|
|
case 0x6817: // dn
|
|
IR_Event_Code = IR_EVENT_WIND_DN;
|
|
break;
|
|
case 0x6718: // 1hour
|
|
IR_Event_Code = IR_EVENT_TIME_1 ;
|
|
break;
|
|
case 0x6619: // 2hour
|
|
IR_Event_Code = IR_EVENT_TIME_2 ;
|
|
break;
|
|
case 0x215E: // 3hour
|
|
IR_Event_Code = IR_EVENT_TIME_3 ;
|
|
break;
|
|
case 0x354A: // filter reset
|
|
IR_Event_Code = IR_EVENT_FILTER_RESET;
|
|
break;
|
|
default:
|
|
IR_Event_Code = 0;
|
|
break;
|
|
}
|
|
if(IR_Event_Code)
|
|
{
|
|
IR_Event_Flag = 1;
|
|
}
|
|
*/
|
|
}
|
|
remocon_buff[0] = 0;
|
|
remocon_buff[1] = 0;
|
|
remocon_bit_count = 0;
|
|
remocon_pos = 0;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
volatile uint8_t Touch_Event = 0;
|
|
|
|
void GPABC_IRQHandler(void)
|
|
{
|
|
uint32_t reg;
|
|
|
|
if(GPIO_GET_INT_FLAG(PB, BIT12))
|
|
{
|
|
GPIO_CLR_INT_FLAG(PB, BIT12);
|
|
CLK->WK_INTSTS = 1; /* clear interrupt status */
|
|
if(PB12 == 0)Touch_Event = 1;
|
|
else Touch_Event = 2;
|
|
}
|
|
else if(GPIO_GET_INT_FLAG(PB, BIT14))
|
|
{
|
|
GPIO_CLR_INT_FLAG(PB, BIT14);
|
|
CLK->WK_INTSTS = 1; /* clear interrupt status */
|
|
IR_Receive();
|
|
}
|
|
else
|
|
{
|
|
reg = PA->ISRC; PA->ISRC = reg;
|
|
reg = PB->ISRC; PB->ISRC = reg;
|
|
reg = PC->ISRC; PC->ISRC = reg;
|
|
}
|
|
}
|
|
|
|
volatile uint8_t Run_Timer = 0;
|
|
volatile uint16_t mSec_Timer = 0;
|
|
volatile uint16_t Touch_Event_Timer = 0;
|
|
volatile uint16_t Blink_Timer = 0;
|
|
volatile uint8_t Rx_rs485_TimeOut = 0;
|
|
volatile uint8_t Rx_modbus_TimeOut = 0;
|
|
volatile uint8_t Rx_wifi_TimeOut = 0;
|
|
volatile uint16_t FastBlink_Timer = 0;
|
|
|
|
void TMR0_IRQHandler(void)
|
|
{
|
|
Touch_Event_Timer++;
|
|
|
|
if(Run_Timer)Run_Timer--;
|
|
if(mSec_Timer)mSec_Timer--;
|
|
if(Blink_Timer)Blink_Timer--;
|
|
if(FastBlink_Timer)FastBlink_Timer--;
|
|
if(Rx_rs485_TimeOut)Rx_rs485_TimeOut--;
|
|
if(Rx_modbus_TimeOut)Rx_modbus_TimeOut--;
|
|
if(Rx_wifi_TimeOut)Rx_wifi_TimeOut--;
|
|
|
|
// clear timer interrupt flag
|
|
TIMER_ClearIntFlag(TIMER0);
|
|
}
|
|
|
|
// TIMER_ClearWakeupFlag(TIMER0);
|
|
void Timer0_Init(void)
|
|
{
|
|
TIMER_Open(TIMER0, TIMER_PERIODIC_MODE, 1000); // 1ms -> HZ
|
|
|
|
// Enable timer interrupt
|
|
TIMER_EnableInt(TIMER0);
|
|
NVIC_EnableIRQ(TMR0_IRQn);
|
|
|
|
|
|
// Start Timer 0
|
|
TIMER_Start(TIMER0);
|
|
}
|
|
|
|
|
|
void TMR1_IRQHandler(void)
|
|
{
|
|
Melody_process();
|
|
|
|
|
|
// clear timer interrupt flag
|
|
TIMER_ClearIntFlag(TIMER1);
|
|
}
|
|
|
|
void Timer1_Init(void)
|
|
{
|
|
TIMER_Open(TIMER1, TIMER_PERIODIC_MODE, 100); // 10ms -> HZ
|
|
|
|
// Enable timer interrupt
|
|
TIMER_EnableInt(TIMER1);
|
|
NVIC_EnableIRQ(TMR1_IRQn);
|
|
|
|
|
|
// Start Timer 0
|
|
TIMER_Start(TIMER1);
|
|
}
|
|
void Timer2_Init(void) ///////////////////////////////////////////////////////////////////
|
|
{
|
|
TIMER_Open(TIMER2, TIMER_PERIODIC_MODE, 1); // 1000ms -> HZ
|
|
|
|
// Enable timer interrupt
|
|
TIMER_EnableInt(TIMER2);
|
|
// NVIC_EnableIRQ(TMR2_IRQn);
|
|
|
|
|
|
// Start Timer 0
|
|
TIMER_Start(TIMER2);
|
|
}/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
void PWM_Init(void)
|
|
{
|
|
// PWM0 frequency is 300Hz, duty 50%
|
|
// PWM_ConfigOutputChannel(PWM0, 3, 960, 50); // LCD Backlight
|
|
PWM_ConfigOutputChannel(PWM1, 0, 100, 0); // buzzer
|
|
|
|
// Enable output of all PWM channels
|
|
// PWM_EnableOutput(PWM0, 1<<3); // ch3
|
|
PWM_EnableOutput(PWM1, 0x01);
|
|
|
|
// Start
|
|
// PWM_Start(PWM0, 1<<3); // pwm0_ch3
|
|
PWM_Start(PWM1, 0x01);
|
|
|
|
}
|
|
|
|
|
|
|
|
volatile uint32_t ADC3_Value = 0;;
|
|
void ADC_IRQHandler(void)
|
|
{
|
|
uint32_t u32Flag;
|
|
|
|
// Get ADC conversion finish interrupt flag
|
|
u32Flag = ADC_GET_INT_FLAG(ADC, ADC_ADF_INT);
|
|
|
|
if(u32Flag & ADC_ADF_INT)
|
|
{
|
|
ADC3_Value = ADC_GET_CONVERSION_DATA(ADC, 3);
|
|
}
|
|
ADC_CLR_INT_FLAG(ADC, u32Flag);
|
|
|
|
}
|
|
|
|
void ADC_Init(void)
|
|
{
|
|
|
|
// Enable channel 1
|
|
ADC_Open(ADC, ADC_INPUT_MODE_SINGLE_END, ADC_OPERATION_MODE_SINGLE, ADC_CH_1_MASK);
|
|
|
|
// Set reference voltage to AVDD
|
|
ADC_SET_REF_VOLTAGE(ADC, ADC_REFSEL_POWER);
|
|
|
|
|
|
// Power on ADC
|
|
ADC_POWER_ON(ADC);
|
|
|
|
// Enable ADC ADC_IF interrupt
|
|
ADC_EnableInt(ADC, ADC_ADF_INT);
|
|
NVIC_EnableIRQ(ADC_IRQn);
|
|
|
|
|
|
ADC_START_CONV(ADC);
|
|
|
|
}
|
|
|
|
|
|
void GPIO_Init(void)
|
|
{
|
|
|
|
GPIO_SetMode(PA, BIT2|BIT3|BIT4, GPIO_PMD_OUTPUT); // A_2002
|
|
PA2 = 0;
|
|
PA3 = 0;
|
|
PA4 = 0;
|
|
GPIO_SetMode(PA, BIT13|BIT14|BIT15, GPIO_PMD_OUTPUT); // B_2002
|
|
PA13 = 0;
|
|
PA14 = 0;
|
|
PA15 = 0;
|
|
GPIO_SetMode(PC, BIT9|BIT10|BIT11, GPIO_PMD_OUTPUT); // C_2002
|
|
PC9 = 0;
|
|
PC10 = 0;
|
|
PC11 = 0;
|
|
GPIO_SetMode(PD, BIT7|BIT14|BIT15, GPIO_PMD_OUTPUT); // D_2002
|
|
PD7 = 0;
|
|
PD14 = 0;
|
|
PD15 = 0;
|
|
|
|
|
|
GPIO_SetMode(PB, BIT6, GPIO_PMD_OUTPUT); // 485 DIR
|
|
PB6 = 0;
|
|
|
|
|
|
GPIO_SetMode(PA, BIT10, GPIO_PMD_OPEN_DRAIN); // touch
|
|
GPIO_SetMode(PA, BIT11, GPIO_PMD_OPEN_DRAIN);
|
|
|
|
|
|
GPIO_SetMode(PB, BIT12, GPIO_PMD_INPUT); // touch int
|
|
GPIO_ENABLE_PULL_UP(PB, BIT12);
|
|
GPIO_EnableInt(PB, 12, GPIO_INT_BOTH_EDGE);
|
|
|
|
|
|
GPIO_SetMode(PB, BIT14, GPIO_PMD_INPUT); // ir int
|
|
GPIO_ENABLE_PULL_UP(PB, BIT14);
|
|
GPIO_EnableInt(PB, 14, GPIO_INT_FALLING);
|
|
|
|
NVIC_EnableIRQ(GPABC_IRQn);
|
|
|
|
/* Enable interrupt de-bounce function and select de-bounce sampling cycle time */
|
|
GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_HCLK, GPIO_DBCLKSEL_1);
|
|
GPIO_ENABLE_DEBOUNCE(PB, BIT12|BIT14);
|
|
|
|
}
|
|
|
|
void SYS_Init(void)
|
|
{
|
|
/* Unlock protected registers */
|
|
SYS_UnlockReg();
|
|
|
|
/* Enable clock source */
|
|
CLK_EnableXtalRC(CLK_PWRCTL_LIRC_EN_Msk|CLK_PWRCTL_HIRC_EN_Msk);
|
|
|
|
/* Waiting for clock source ready */
|
|
CLK_WaitClockReady(CLK_CLKSTATUS_LIRC_STB_Msk|CLK_CLKSTATUS_HIRC_STB_Msk);
|
|
|
|
/* If the defines do not exist in your project, please refer to the related clk.h in the Header folder appended to the tool package. */
|
|
/* Set HCLK clock */
|
|
CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC, CLK_HCLK_CLK_DIVIDER(1));
|
|
|
|
/* Enable IP clock */
|
|
CLK_EnableModuleClock(GPIO_MODULE);
|
|
CLK_EnableModuleClock(WDT_MODULE);
|
|
// CLK_EnableModuleClock(I2C0_MODULE);
|
|
// CLK_EnableModuleClock(I2C1_MODULE);
|
|
// CLK_EnableModuleClock(PWM0_CH23_MODULE);
|
|
CLK_EnableModuleClock(PWM1_CH01_MODULE);
|
|
CLK_EnableModuleClock(ISP_MODULE);
|
|
CLK_EnableModuleClock(SC0_MODULE);
|
|
// CLK_EnableModuleClock(SC1_MODULE);
|
|
CLK_EnableModuleClock(SRAM_MODULE);
|
|
CLK_EnableModuleClock(TICK_MODULE);
|
|
CLK_EnableModuleClock(TMR0_MODULE);
|
|
CLK_EnableModuleClock(TMR1_MODULE);
|
|
CLK_EnableModuleClock(TMR2_MODULE);
|
|
// CLK_EnableModuleClock(UART0_MODULE);
|
|
CLK_EnableModuleClock(UART1_MODULE);
|
|
CLK_EnableModuleClock(WDT_MODULE);
|
|
|
|
/* Set IP clock */
|
|
|
|
// CLK_SetModuleClock(PWM0_CH23_MODULE, CLK_CLKSEL1_PWM0_CH23_S_HIRC, MODULE_NoMsk);
|
|
CLK_SetModuleClock(PWM1_CH01_MODULE, CLK_CLKSEL2_PWM1_CH01_S_HIRC, MODULE_NoMsk);
|
|
CLK_SetModuleClock(SC0_MODULE, CLK_CLKSEL2_SC_S_HIRC, CLK_SC0_CLK_DIVIDER(6));
|
|
// CLK_SetModuleClock(SC1_MODULE, CLK_CLKSEL2_SC_S_HIRC, CLK_SC1_CLK_DIVIDER(1));
|
|
CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0_S_HIRC, MODULE_NoMsk);
|
|
CLK_SetModuleClock(TMR1_MODULE, CLK_CLKSEL1_TMR1_S_HIRC, MODULE_NoMsk);
|
|
CLK_SetModuleClock(TMR2_MODULE, CLK_CLKSEL2_TMR2_S_HIRC, MODULE_NoMsk);
|
|
// CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UART_S_HIRC, CLK_UART_CLK_DIVIDER(1));
|
|
CLK_SetModuleClock(UART1_MODULE, CLK_CLKSEL1_UART_S_HIRC, CLK_UART_CLK_DIVIDER(1));
|
|
CLK_SetModuleClock(WDT_MODULE, 0, 0);
|
|
|
|
/* Update System Core Clock */
|
|
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
|
|
SystemCoreClockUpdate();
|
|
|
|
|
|
|
|
//If the defines do not exist in your project, please refer to the corresponding sys.h in the Header folder appended to the tool package.
|
|
SYS->PA_H_MFP = SYS_PA_H_MFP_PA9_MFP_SC0_DAT | SYS_PA_H_MFP_PA8_MFP_SC0_CLK;
|
|
SYS->PB_H_MFP = SYS_PB_H_MFP_PB11_MFP_PWM1_CH0;
|
|
SYS->PB_L_MFP = SYS_PB_L_MFP_PB5_MFP_UART1_TX | SYS_PB_L_MFP_PB4_MFP_UART1_RX ;
|
|
SYS->PC_H_MFP = 0x00000000;
|
|
SYS->PC_L_MFP = 0x00000000;
|
|
SYS->PD_H_MFP = 0x00000000;
|
|
SYS->PD_L_MFP = 0x00000000;
|
|
SYS->PE_L_MFP = 0x00000000;
|
|
SYS->PF_L_MFP = SYS_PF_L_MFP_PF1_MFP_ICE_CLK | SYS_PF_L_MFP_PF0_MFP_ICE_DAT;
|
|
|
|
|
|
|
|
/* Lock protected registers */
|
|
SYS_LockReg();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
extern uint8_t Main_Modbus_ID;
|
|
|
|
void Processor_Init(void)
|
|
{
|
|
// 0 1 2 3 4 5 6 7 8 9 , ' ' , E , A
|
|
|
|
uint8_t eep_check[20];
|
|
uint8_t i;
|
|
|
|
Power_On = 0;
|
|
Tx_Run_Mode = 0;
|
|
Tx_Fan_Speed = 0;
|
|
Tx_Reservation_Hour = 0;
|
|
|
|
|
|
Led_OnOff(100,1);//all on
|
|
Disp_Segdata(0, 8, 8, 8, 8);
|
|
Disp_Segdata(1, 8, 8, 8, 8);
|
|
Disp_Segdata(2, 8, 8, 8, 8);
|
|
for(i=0; i<10; i++)Display_process();
|
|
|
|
touch_i2c_init() ;
|
|
|
|
|
|
Melody_Mode = MELODY_TOUCH;
|
|
delay_ms(2000);
|
|
|
|
|
|
Led_OnOff(100, 0); // all off
|
|
Disp_Segdata(0, 14, 14, 5, 2); // s2
|
|
Disp_Segdata(1, 1, 0, 0, 0); // 1000
|
|
Disp_Segdata(2, 16, 13, ROOMCON_VERSION>>4, ROOMCON_VERSION&0x0F); // R-01
|
|
for(i=0; i<10; i++)Display_process();
|
|
|
|
delay_ms(2000);
|
|
|
|
power_off_process();
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
for(i=0; i<10; i++)
|
|
{
|
|
Read_Data(i, &eep_check[i]);
|
|
}
|
|
|
|
if((eep_check[EEP_ADDR_START] == 0x55)&&(eep_check[EEP_ADDR_START+1] == 0xAA))
|
|
{
|
|
// Main_Modbus_ID = eep_check[EEP_ADDR_MODBUS_ID];
|
|
}
|
|
else
|
|
{
|
|
Main_Modbus_ID = 1;
|
|
|
|
Write_Data(EEP_ADDR_START, 0x55);
|
|
Write_Data(EEP_ADDR_START+1, 0xAA);
|
|
|
|
// Write_Data(EEP_ADDR_MODBUS_ID, Main_Modbus_ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern uint16_t Pm_1_0_value, Pm_2_5_value, Pm_10_value;
|
|
extern uint16_t CO2_Value;
|
|
uint8_t CO2_quality = 0;
|
|
uint8_t PM2_5_quality = 0;
|
|
uint8_t PM10_quality = 0;
|
|
uint8_t temp_fan_speed = 0;
|
|
uint8_t temp_pm_quality = 0;
|
|
|
|
#define CO2_HISTERISE 0
|
|
#define DUST_HISTERISE 0
|
|
|
|
void Air_Quality_process(void)
|
|
{
|
|
|
|
if(Power_On == 1)
|
|
{
|
|
if(CO2_Value <= 500-CO2_HISTERISE) CO2_quality = 0;
|
|
else if((CO2_Value > 500+CO2_HISTERISE)&&(CO2_Value <= 1000-CO2_HISTERISE)) CO2_quality = 0x01;
|
|
else if((CO2_Value > 1000+CO2_HISTERISE)&&(CO2_Value <= 1500-CO2_HISTERISE)) CO2_quality = 0x02;
|
|
else if(CO2_Value > 1500+CO2_HISTERISE)CO2_quality = 0x04;
|
|
|
|
//2020.5.26 PM2.5 기준변경
|
|
if(Pm_2_5_value <= 15-DUST_HISTERISE) PM2_5_quality = 0;
|
|
else if((Pm_2_5_value > 15+DUST_HISTERISE)&&(Pm_2_5_value <= 35-DUST_HISTERISE)) PM2_5_quality = 0x01;
|
|
else if((Pm_2_5_value > 35+DUST_HISTERISE)&&(Pm_2_5_value <= 75-DUST_HISTERISE)) PM2_5_quality = 0x02;
|
|
else if(Pm_2_5_value > 75+DUST_HISTERISE)PM2_5_quality = 0x04;
|
|
|
|
if(Pm_10_value <= 30-DUST_HISTERISE) PM10_quality = 0;
|
|
else if((Pm_10_value > 30+DUST_HISTERISE)&&(Pm_10_value <= 80-DUST_HISTERISE)) PM10_quality = 0x01;
|
|
else if((Pm_10_value > 80+DUST_HISTERISE)&&(Pm_10_value <= 150-DUST_HISTERISE)) PM10_quality = 0x02;
|
|
else if(Pm_10_value > 150+DUST_HISTERISE)PM10_quality = 0x04;
|
|
|
|
|
|
temp_pm_quality = PM2_5_quality | PM10_quality;
|
|
|
|
|
|
if(Tx_Run_Mode == MODE_AUTO)
|
|
{
|
|
if(CO2_quality == 0)
|
|
{
|
|
if(temp_pm_quality < 1)temp_fan_speed = 0;
|
|
else if(temp_pm_quality < 2)temp_fan_speed = 2;
|
|
else if(temp_pm_quality < 4)temp_fan_speed = 3;
|
|
else temp_fan_speed = 4;
|
|
}
|
|
else
|
|
{
|
|
if(CO2_quality == 0x01)
|
|
{
|
|
if(temp_pm_quality < 2)temp_fan_speed = 2;
|
|
else if(temp_pm_quality < 4)temp_fan_speed = 3;
|
|
else temp_fan_speed = 4;
|
|
}
|
|
else if(CO2_quality == 0x02)
|
|
{
|
|
if(temp_pm_quality < 4)temp_fan_speed = 3;
|
|
else temp_fan_speed = 4;
|
|
}
|
|
else if(CO2_quality == 0x04)
|
|
{
|
|
temp_fan_speed = 4;
|
|
}
|
|
}
|
|
|
|
Tx_Fan_Speed = temp_fan_speed;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
extern uint8_t Blinking_Count, Blink_Toggle;
|
|
|
|
extern volatile uint8_t Filter_Reset_Flag;
|
|
extern volatile uint8_t Tx_Mode_Event , Tx_Fan_Event , Tx_Reserve_Event ;
|
|
volatile uint16_t Fan_Setting_Timer = 0;
|
|
|
|
void IR_Remocon_process(void)
|
|
{
|
|
switch(IR_Event_Code)
|
|
{
|
|
case IR_EVENT_POWER:
|
|
if(Power_On == 0)power_on_process();
|
|
else power_off_process();
|
|
break;
|
|
case IR_EVENT_WIND_UP:
|
|
if(Power_On == 1)
|
|
{
|
|
if((Tx_Run_Mode == MODE_AUTO)||(Tx_Run_Mode == MODE_BYPASS))
|
|
{
|
|
Melody_Mode = MELODY_NG;
|
|
}
|
|
else
|
|
{
|
|
if(Tx_Fan_Speed<5)Tx_Fan_Speed++;
|
|
|
|
Tx_Fan_Event = TX_EVENT;
|
|
|
|
Melody_Mode = MELODY_TOUCH;
|
|
}
|
|
}
|
|
break;
|
|
case IR_EVENT_WIND_DN:
|
|
if(Power_On == 1)
|
|
{
|
|
if((Tx_Run_Mode == MODE_AUTO)||(Tx_Run_Mode == MODE_BYPASS))
|
|
{
|
|
Melody_Mode = MELODY_NG;
|
|
}
|
|
else
|
|
{
|
|
if(Tx_Fan_Speed > 1)Tx_Fan_Speed--;
|
|
|
|
Tx_Fan_Event = TX_EVENT;
|
|
|
|
Melody_Mode = MELODY_TOUCH;
|
|
}
|
|
}
|
|
break;
|
|
case IR_EVENT_TIME_1:
|
|
if(Power_On == 1)
|
|
{
|
|
if(Tx_Reservation_Hour == 1)Tx_Reservation_Hour = 0;
|
|
else Tx_Reservation_Hour = 1;
|
|
|
|
if(Blinking_Count == 0)
|
|
{
|
|
Blink_Timer = 0;
|
|
Blink_Toggle = 0;
|
|
}
|
|
Blinking_Count = 3;
|
|
Melody_Mode = MELODY_TOUCH;
|
|
|
|
Tx_Reserve_Event = TX_EVENT;
|
|
}
|
|
break;
|
|
case IR_EVENT_TIME_2:
|
|
if(Power_On == 1)
|
|
{
|
|
if(Tx_Reservation_Hour == 4)Tx_Reservation_Hour = 0;
|
|
else Tx_Reservation_Hour = 4;
|
|
|
|
if(Blinking_Count == 0)
|
|
{
|
|
Blink_Timer = 0;
|
|
Blink_Toggle = 0;
|
|
}
|
|
Blinking_Count = 3;
|
|
Melody_Mode = MELODY_TOUCH;
|
|
|
|
Tx_Reserve_Event = TX_EVENT;
|
|
}
|
|
|
|
break;
|
|
case IR_EVENT_TIME_3:
|
|
if(Power_On == 1)
|
|
{
|
|
if(Tx_Reservation_Hour == 8)Tx_Reservation_Hour = 0;
|
|
else Tx_Reservation_Hour = 8;
|
|
|
|
if(Blinking_Count == 0)
|
|
{
|
|
Blink_Timer = 0;
|
|
Blink_Toggle = 0;
|
|
}
|
|
Blinking_Count = 3;
|
|
Melody_Mode = MELODY_TOUCH;
|
|
|
|
Tx_Reserve_Event = TX_EVENT;
|
|
}
|
|
|
|
break;
|
|
case IR_EVENT_MODE:
|
|
if(Power_On == 1)
|
|
{
|
|
if(Tx_Run_Mode == MODE_VENT)Tx_Run_Mode = MODE_AUTO;
|
|
else if(Tx_Run_Mode == MODE_AUTO)Tx_Run_Mode = MODE_VENT;
|
|
|
|
|
|
Tx_Reservation_Hour = 0;
|
|
Tx_Fan_Speed = 3;
|
|
|
|
Tx_Mode_Event = TX_EVENT;
|
|
Tx_Fan_Event = TX_EVENT;
|
|
Tx_Reserve_Event = TX_EVENT;
|
|
|
|
Melody_Mode = MELODY_TOUCH;
|
|
}
|
|
break;
|
|
case IR_EVENT_FILTER_RESET:
|
|
Filter_Reset_Flag = 1;
|
|
Melody_Mode = MELODY_TOUCH;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if(IR_Event_Code)IR_Event_Code = 0;
|
|
}
|
|
|