mirror of
				https://github.com/DashyFox/StackSport.git
				synced 2025-10-31 19:02:47 +00:00 
			
		
		
		
	IR_CMD_Wrapper
This commit is contained in:
		| @ -9,6 +9,7 @@ | |||||||
| #define INC_IR_CMD_HANDLER_H_ | #define INC_IR_CMD_HANDLER_H_ | ||||||
|  |  | ||||||
| #include "stm32f1xx_hal.h" | #include "stm32f1xx_hal.h" | ||||||
|  | #include <string.h> | ||||||
|  |  | ||||||
| void IR_CMD_Handler(); | void IR_CMD_Handler(); | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										80
									
								
								Core/Src/IR_CMD_HandlerLogic.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								Core/Src/IR_CMD_HandlerLogic.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,80 @@ | |||||||
|  | /* | ||||||
|  |  * IR_CMD_HandlerLogic.c | ||||||
|  |  * | ||||||
|  |  *  Created on: Aug 26, 2024 | ||||||
|  |  *      Author: DashyFox | ||||||
|  |  */ | ||||||
|  | #include "IR_CMD_Handler.h" | ||||||
|  | #include "IR.h" | ||||||
|  | #include "ShiftReg.h" | ||||||
|  |  | ||||||
|  | #include "Print.h" | ||||||
|  |  | ||||||
|  | enum IR_MENU { | ||||||
|  | 	IR_MENU_Home, | ||||||
|  |  | ||||||
|  | 	IR_MENU_SHOT, | ||||||
|  | 	IR_MENU_PROGR, | ||||||
|  | 	IR_MENU_MACRO, | ||||||
|  | 	IR_MENU_, | ||||||
|  |  | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | // << | ||||||
|  | extern void (*InputHandler)(void); 			// ProcessFunc | ||||||
|  | extern uint16_t inputParam;					// current input parameter | ||||||
|  |  | ||||||
|  | // >> | ||||||
|  | extern IRData data; | ||||||
|  |  | ||||||
|  | // () | ||||||
|  | extern void NullFunc(); 					// null func for paramEnter(NullFunc); | ||||||
|  | extern void paramEnter(void(*onEnter_)());	// setParamFunc for enter | ||||||
|  |  | ||||||
|  | uint8_t testData; | ||||||
|  | void selectShot(){ | ||||||
|  | 	testData = inputParam; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | unsigned char b1 = 1; | ||||||
|  | unsigned char b2 = 1; | ||||||
|  | unsigned char b3 = 1; | ||||||
|  | void IR_Home_Process() { | ||||||
|  | 	InputHandler = IR_Home_Process; | ||||||
|  | 	SetShiftReg_inline(0xff, 0, 0); | ||||||
|  | 	switch (data.command) { | ||||||
|  | 	case IR_FONT_RIGHT: | ||||||
|  |  | ||||||
|  | 		paramEnter(selectShot); | ||||||
|  | 		break; | ||||||
|  |  | ||||||
|  | //	case IR_FONT_RIGHT: | ||||||
|  | //		//		        	if(!(b1>64 || b2> 64|| b3>64)) b1 = 64; | ||||||
|  | //		//		        	else | ||||||
|  | //		//		        	{ | ||||||
|  | //		//		        		b1 = b1>>1; | ||||||
|  | //		//		        		b2 = b2<<1; | ||||||
|  | //		//		        		b3 = b3<<1; | ||||||
|  | //		//		        	} | ||||||
|  | //		SetShiftReg_inline(b1, b2, b3); | ||||||
|  | //		break; | ||||||
|  | 	case IR_FRONT_MID: | ||||||
|  | 		SetShiftReg_inline(0, 0, 0); | ||||||
|  | 		b1 = b2 = b3 = 0; | ||||||
|  | 		break; | ||||||
|  | 	case IR_FRONT_LEFT: | ||||||
|  | 		//					if(!b3) | ||||||
|  | 		//						b3 = 128; | ||||||
|  | 		//					b3 = b3>>1; | ||||||
|  | 		//					if(!b3) | ||||||
|  | 		//						b2 = 64; | ||||||
|  |  | ||||||
|  | 		SetShiftReg_inline(++b1, ++b2, ++b3); | ||||||
|  | 		break; | ||||||
|  |  | ||||||
|  | 	default: | ||||||
|  | 		break; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -8,8 +8,9 @@ | |||||||
| #include "IR_CMD_Handler.h" | #include "IR_CMD_Handler.h" | ||||||
| #include "IR.h" | #include "IR.h" | ||||||
| #include "SimpleTimer.h" | #include "SimpleTimer.h" | ||||||
| #include "Print.h" |  | ||||||
| #include "ShiftReg.h" | #include "ShiftReg.h" | ||||||
|  | #include "Print.h" | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| #define IR_Timeout 137 | #define IR_Timeout 137 | ||||||
| #define ResetInputProgerss_Timeout 2500 | #define ResetInputProgerss_Timeout 2500 | ||||||
| @ -22,10 +23,6 @@ extern unsigned char IRStatus; | |||||||
| IRData data; | IRData data; | ||||||
| IRData old_data; | IRData old_data; | ||||||
| 
 | 
 | ||||||
| unsigned char b1 = 1; |  | ||||||
| unsigned char b2 = 1; |  | ||||||
| unsigned char b3 = 1; |  | ||||||
| 
 |  | ||||||
| uint32_t IR_Timeout_timer = 0; | uint32_t IR_Timeout_timer = 0; | ||||||
| uint8_t dataHandled_flag = 0; | uint8_t dataHandled_flag = 0; | ||||||
| 
 | 
 | ||||||
| @ -35,21 +32,21 @@ uint8_t digitInputInProgerss = 0; | |||||||
| 
 | 
 | ||||||
| uint8_t inputDigit = 0; // left = 0 to right
 | uint8_t inputDigit = 0; // left = 0 to right
 | ||||||
| 
 | 
 | ||||||
| uint16_t inputNumberParam = NULL_NumberParam; | uint16_t inputParam = NULL_NumberParam; | ||||||
| 
 |  | ||||||
| enum IR_MENU { |  | ||||||
| 	IR_MENU_Home, |  | ||||||
| 
 |  | ||||||
| 	IR_MENU_SHOT, IR_MENU_PROGR, IR_MENU_MACRO, IR_MENU_, |  | ||||||
| 
 |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| void IR_Home_Process(); | void IR_Home_Process(); | ||||||
| void IR_Shot_Selection(); |  | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | void IR_ParamEnter(); | ||||||
| void IR_CMD_Clear(); | void IR_CMD_Clear(); | ||||||
| 
 |  | ||||||
| void (*InputHandler)(void) = IR_Home_Process; | void (*InputHandler)(void) = IR_Home_Process; | ||||||
|  | void NullFunc(){}; | ||||||
|  | void (*onParamEnter)() = NullFunc; | ||||||
|  | void paramEnter(void(*onEnter_)()){ | ||||||
|  | 	InputHandler = IR_ParamEnter; | ||||||
|  | 	onParamEnter = onEnter_; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void IR_CMD_Handler() { | void IR_CMD_Handler() { | ||||||
| 
 | 
 | ||||||
| @ -90,57 +87,19 @@ void IR_CMD_Clear() { | |||||||
| 	inputDigit = 0; | 	inputDigit = 0; | ||||||
| 	inputInProgerss = 0; | 	inputInProgerss = 0; | ||||||
| 	digitInputInProgerss = 0; | 	digitInputInProgerss = 0; | ||||||
| 	inputNumberParam = NULL_NumberParam; | 	inputParam = NULL_NumberParam; | ||||||
| 	SetShiftReg_inline(0, 0xff, 0); | 	SetShiftReg_inline(0, 0xff, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void IR_Home_Process() { | void IR_ParamEnter() { | ||||||
| 	InputHandler = IR_Home_Process; |  | ||||||
| 	SetShiftReg_inline(0xff, 0, 0); |  | ||||||
| 	switch (data.command) { |  | ||||||
| 	case IR_FONT_RIGHT: |  | ||||||
| 		InputHandler = IR_Shot_Selection; |  | ||||||
| 		break; |  | ||||||
| 
 |  | ||||||
| //	case IR_FONT_RIGHT:
 |  | ||||||
| //		//		        	if(!(b1>64 || b2> 64|| b3>64)) b1 = 64;
 |  | ||||||
| //		//		        	else
 |  | ||||||
| //		//		        	{
 |  | ||||||
| //		//		        		b1 = b1>>1;
 |  | ||||||
| //		//		        		b2 = b2<<1;
 |  | ||||||
| //		//		        		b3 = b3<<1;
 |  | ||||||
| //		//		        	}
 |  | ||||||
| //		SetShiftReg_inline(b1, b2, b3);
 |  | ||||||
| //		break;
 |  | ||||||
| 	case IR_FRONT_MID: |  | ||||||
| 		SetShiftReg_inline(0, 0, 0); |  | ||||||
| 		b1 = b2 = b3 = 0; |  | ||||||
| 		break; |  | ||||||
| 	case IR_FRONT_LEFT: |  | ||||||
| 		//					if(!b3)
 |  | ||||||
| 		//						b3 = 128;
 |  | ||||||
| 		//					b3 = b3>>1;
 |  | ||||||
| 		//					if(!b3)
 |  | ||||||
| 		//						b2 = 64;
 |  | ||||||
| 
 |  | ||||||
| 		SetShiftReg_inline(++b1, ++b2, ++b3); |  | ||||||
| 		break; |  | ||||||
| 
 |  | ||||||
| 	default: |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void IR_Shot_Selection() { // Сделать общим
 |  | ||||||
| 	SetShiftReg_inline(0x03, 0, 0); | 	SetShiftReg_inline(0x03, 0, 0); | ||||||
| 	if (0 <= data.command && data.command <= 9) { | 	if (0 <= data.command && data.command <= 9) { | ||||||
| 		if (digitInputInProgerss) { | 		if (digitInputInProgerss) { | ||||||
| 			inputNumberParam = inputNumberParam * 10; // dec shift << 1
 | 			inputParam = inputParam * 10; // dec shift << 1
 | ||||||
| 			inputNumberParam += data.command + 1; | 			inputParam += data.command + 1; | ||||||
| 			SetShiftReg_inline(0xF0, 0, 0); | 			SetShiftReg_inline(0xF0, 0, 0); | ||||||
| 		} else { | 		} else { | ||||||
| 			inputNumberParam = data.command + 1; | 			inputParam = data.command + 1; | ||||||
| 		} | 		} | ||||||
| 		digitInputInProgerss = 1; | 		digitInputInProgerss = 1; | ||||||
| 	} else { | 	} else { | ||||||
| @ -148,10 +107,11 @@ void IR_Shot_Selection() { // Сделать общим | |||||||
| 		switch (data.command) { | 		switch (data.command) { | ||||||
| 
 | 
 | ||||||
| 		case IR_ENTER: | 		case IR_ENTER: | ||||||
| 			if(inputNumberParam != NULL_NumberParam){ | 			if(inputParam != NULL_NumberParam){ | ||||||
| 				SetShiftReg_inline(0, 0, inputNumberParam); | 				SetShiftReg_inline(0, 0, inputParam); | ||||||
|  | 				onParamEnter(); | ||||||
| 			} | 			} | ||||||
| 			inputNumberParam = NULL_NumberParam; | 			inputParam = NULL_NumberParam; | ||||||
| 			digitInputInProgerss = 0; | 			digitInputInProgerss = 0; | ||||||
| 			break; | 			break; | ||||||
| 
 | 
 | ||||||
| @ -161,3 +121,6 @@ void IR_Shot_Selection() { // Сделать общим | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| @ -68,7 +68,7 @@ uint8_t velosety[600]; | |||||||
| uint8_t rxcomlite = 0; | uint8_t rxcomlite = 0; | ||||||
| uint8_t initcomlete = 0; | uint8_t initcomlete = 0; | ||||||
|  |  | ||||||
| uint8_t uart_rx_buffer[64]; | uint8_t uart_rx_buffer[UART_BUFFER_SIZE]; | ||||||
|  |  | ||||||
| unsigned char Shiftreg[3]; | unsigned char Shiftreg[3]; | ||||||
|  |  | ||||||
|  | |||||||
| @ -184,7 +184,7 @@ extern I2C_HandleTypeDef hi2c1; | |||||||
| extern TIM_HandleTypeDef htim3; | extern TIM_HandleTypeDef htim3; | ||||||
| extern UART_HandleTypeDef huart3; | extern UART_HandleTypeDef huart3; | ||||||
| /* USER CODE BEGIN EV */ | /* USER CODE BEGIN EV */ | ||||||
|  | extern uint8_t uart_rx_buffer[UART_BUFFER_SIZE]; | ||||||
| /* USER CODE END EV */ | /* USER CODE END EV */ | ||||||
|  |  | ||||||
| /******************************************************************************/ | /******************************************************************************/ | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user