update with workable projector control on/off/next

This commit is contained in:
Yunhorn 2025-02-25 21:04:16 +08:00
parent 0513112180
commit 69d452721f
4 changed files with 10 additions and 134 deletions

View File

@ -1,12 +1,3 @@
/**
* @file EV1527.c
* @author cyWu (1917507415@qq.com)
* @brief EV1527解码框架使80us的定时器
* @version 0.1
* @date 2024-03-28
* @copyright Copyright (c) 2024
*
*/
#include "ev1527.h"
volatile uint32_t TIM1_cnt=0;
// 定时周期
@ -547,7 +538,7 @@ void STS_RF_Send_AddressBit_and_CmdBit(uint8_t *rf_payload, uint8_t rf_length)
}
}
STS_RF_write_send_ending();
printf("ending bits ...\r\n");
// printf("ending bits ...\r\n");
}

View File

@ -33,37 +33,7 @@
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
TIM_HandleTypeDef htim1;
#if 1
/* Captured Values */
uint32_t uwIC2Value1 = 0;
uint32_t uwIC2Value2 = 0;
uint32_t uwDiffCapture = 0;
/* Capture index */
uint16_t uhCaptureIndex = 0;
/* Frequency Value */
uint32_t uwFrequency = 0;
#endif
/* USER CODE BEGIN PV */
#if 1
/* Captured Value */
uint32_t uwIC2Value = 0;
/* Duty Cycle Value */
uint32_t uwDutyCycle = 0;
/* Frequency Value */
// uint32_t uwFrequency = 0;
#endif
#if 1
volatile uint32_t capture_Buf[3]={0}; // counter
volatile uint8_t capture_Cnt=0; // state
volatile uint32_t high_time, low_time; // high level duration, low level duration
#endif
//uint8_t rf_payload[3]={0xF8,0xCD,0x07}, rf_length=3;
uint8_t rf_payload[3]={0x1F,0xB3,0xE0}, rf_length=3; // RC_PROJECTOR
uint8_t sos_rf_payload[3]={0x82,0x73,0xA0}, sos_rf_length=3; // sos_button
enum rf_cmd_enum
@ -172,7 +142,7 @@ int main(void)
printf("start \r\n");
// EV1527_Init();
EV1527Reset();
#if 0
/*## Start the Input Capture in interrupt mode ##########################*/
if (HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2) != HAL_OK)
@ -183,17 +153,6 @@ int main(void)
}
#endif
#if 0
while (0)
{
HAL_Delay_Us(1000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET);
HAL_Delay_Us(1000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
}
#endif
/* ---------------------------------------------------------------------------
TIM1 configuration: PWM Input mode
@ -230,29 +189,6 @@ int main(void)
while(1)
{
#if 0
switch(capture_Cnt) {
case 0:
capture_Cnt ++;
//printf("cc: %ld \r\n", capture_Cnt);
//TIM_SET_CAPTUREPOLARITY(&htim1, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_RISING);
__HAL_TIM_SET_CAPTUREPOLARITY(&htim1,TIM_CHANNEL_2,TIM_INPUTCHANNELPOLARITY_RISING);
HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_2); // or _HAL_TIM_ENABLE(&htim1);
break;
case 3:
high_time = capture_Buf[1] - capture_Buf[0]; // high time
low_time = capture_Buf[2] - capture_Buf[1]; // low time
if (low_time/high_time > 2) printf("_");
if (high_time/low_time > 2) printf("+");
// HAL_UART_Transmit(&huart2, (uint8_t*)high_time, 1, 0xffff); // print high time
//HAL_Delay(1000); //delay 1 s
//HAL_Delay_Us(1000000);
capture_Cnt = 0; // clear flag
break;
}
#endif
}
@ -263,59 +199,6 @@ while(1)
}
#if 0
RF_Read_TIM_init();
uint8_t vt=0;
uint8_t codex=0;
uint32_t k=0;
#endif
#if 0
EV1527_Init();
while(1)
{
RF_Signal_Decode();
HAL_Delay(1/20);
}
#endif
#if 0
// for(i=0; i<16; i++)
{
printf("\r\n Set Key down \r\n");
HAL_GPIO_WritePin(RC_SET_GPIO_Port, RC_SET_Pin, GPIO_PIN_RESET);
HAL_Delay(3000);
while(1)
{
k=0;
printf("\r\n Scan code \r\n");
codex =0;
codexx =0;
do {
// sts_rc_key(i);
//codex = sts_rc_decodedx();
codex = codexx;
vt=HAL_GPIO_ReadPin(RC_VT_GPIO_Port, RC_VT_Pin);
if (vt||code_vt)
{
printf("+++\r\n");
}
// HAL_Delay(10);
k++;
}while ((vt==0));
printf("\r\n Cycle=%ld decoded x= %02x vt=%02x\r\n", k, codexx, code_vt);
HAL_Delay(1000);
}
}
#endif
#if 0
uint8_t i;
while (1)
@ -379,7 +262,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
switch(GPIO_Pin)
{
case BUT1_Pin:
#if 0
#if 1
printf("Button 1 pressed, sending cmd #1 \r\n");
//STS_RF_Send_AddressBit_and_CmdBit(rf_payload, rf_length);
// STS_RF_Send_Multi_Times(rf_payload, 3, 8);
@ -387,12 +270,14 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
STS_RF_Send_Button_Multi_Times(rf_payload, single_button, 3, 8);
#endif
// for SOS BUTTON
#if 0
printf("SOS Button pressed, sending cmd #1 \r\n");
//STS_RF_Send_AddressBit_and_CmdBit(rf_payload, rf_length);
// STS_RF_Send_Multi_Times(rf_payload, 3, 8);
single_button = sos_rf_cmd[BUTTON_ON];
STS_RF_Send_Button_Multi_Times(sos_rf_payload, single_button, 3, 8);
#endif
break;
case BUT2_Pin:
@ -412,7 +297,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
case DATA_433_PIN:
//printf("^");
HAL_TIM_IC_CaptureCallback(&htim1);
// HAL_TIM_IC_CaptureCallback(&htim1);
//RF_Signal_Decode();
break;

View File

@ -369,10 +369,10 @@ void EXTI9_5_IRQHandler(void)
__HAL_GPIO_EXTI_CLEAR_IT(RC_D5_Pin);
#endif
//HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
HAL_GPIO_EXTI_IRQHandler(DATA_433_PIN);
__HAL_GPIO_EXTI_CLEAR_IT(DATA_433_PIN);
//HAL_GPIO_EXTI_IRQHandler(DATA_433_PIN);
//__HAL_GPIO_EXTI_CLEAR_IT(DATA_433_PIN);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */