Nagano kosen robocon
Embed:
(wiki syntax)
Show/hide line numbers
ActuatorHub.h
00001 #ifndef ACTUATORHUB_H_ 00002 #define ACTUATORHUB_H_ 00003 00004 #include "../../../CommonLibraries/RingBuffer/RingBuffer.h" 00005 00006 extern RINGBUFFER::RingBuffer HubRS485SendBuffer; 00007 extern RINGBUFFER::RingBuffer BluetoothSendBuffer; 00008 00009 namespace ACTUATORHUB { 00010 #define MOTOR_ADDR 'M' 00011 #define MOTOR2_ADDR 'N' 00012 #define MOTOR3_ADDR 'O' 00013 #define SOLENOID_ADDR 'S' 00014 #define BLUETOOTH_ADDR 'B' 00015 #define COLOR_ADDR 'C' 00016 #define TAPELED_ADDR 'L' 00017 00018 namespace MOTOR { 00019 #define FREE 0 00020 #define BACK 1 00021 #define FOR 2 00022 #define BRAKE 3 00023 00024 typedef struct { 00025 uint8_t dir; 00026 uint8_t pwm; 00027 }MotorStatus; 00028 00029 typedef union { 00030 struct { 00031 int data3 : 2; 00032 int data2 : 2; 00033 int data1 : 2; 00034 int data0 : 2; 00035 }; 00036 uint8_t all; 00037 }MotorDirectionData; 00038 00039 typedef struct { 00040 MotorDirectionData direction0to3; 00041 MotorDirectionData direction4to7; 00042 MotorDirectionData direction8to9; 00043 00044 uint8_t pwm0; 00045 uint8_t pwm1; 00046 uint8_t pwm2; 00047 uint8_t pwm3; 00048 uint8_t pwm4; 00049 uint8_t pwm5; 00050 uint8_t pwm6; 00051 uint8_t pwm7; 00052 uint8_t pwm8; 00053 uint8_t pwm9; 00054 uint8_t pwm10; 00055 uint8_t pwm11; 00056 uint8_t pwm12; 00057 }AllMotorData; 00058 00059 class Motor { 00060 public: 00061 static void Initialize(); 00062 static void Update(MotorStatus *status); 00063 static void SetDefault(); 00064 }; 00065 } 00066 00067 namespace SOLENOID { 00068 #define SOLENOID_ON 1 00069 #define SOLENOID_OFF 0 00070 00071 #define ALL_SOLENOID_ON 0xffff 00072 #define ALL_SOLENOID_OFF 0 00073 00074 typedef union { 00075 struct { 00076 int : 4; 00077 int solenoid11 : 1; 00078 int solenoid10 : 1; 00079 int solenoid9 : 1; 00080 int solenoid8 : 1; 00081 int solenoid7 : 1; 00082 int solenoid6 : 1; 00083 int solenoid5 : 1; 00084 int solenoid4 : 1; 00085 int solenoid3 : 1; 00086 int solenoid2 : 1; 00087 int solenoid1 : 1; 00088 int solenoid0 : 1; 00089 }; 00090 uint16_t all; 00091 }SolenoidStatus; 00092 00093 class Solenoid { 00094 public: 00095 static void Initialize(); 00096 static void Update(SolenoidStatus status); 00097 }; 00098 } 00099 00100 class ActuatorHub { 00101 public: 00102 static void Update(); 00103 }; 00104 } 00105 00106 #endif
Generated on Wed Jul 13 2022 00:47:24 by
1.7.2