aa

Dependencies:   mbed

Committer:
M_souta
Date:
Fri Oct 18 22:33:25 2019 +0000
Revision:
29:44d5454ce8fa
Parent:
28:479631c2de29
Child:
30:8f092276b2ba
tt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:669ef71cba68 1 #include "mbed.h"
t_yamamoto 0:669ef71cba68 2 #include "Process.h"
Ryosei 27:dd9f27fce7d1 3 #include "Pulse.h"
Ryosei 27:dd9f27fce7d1 4 #include <stdlib.h>
7ka884 4:ba9df71868df 5 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 6 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
M_souta 21:e3b58d675c1c 7 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 8 #include "../../Communication/Controller/Controller.h"
t_yamamoto 0:669ef71cba68 9 #include "../../Input/Switch/Switch.h"
Ryosei 27:dd9f27fce7d1 10
t_yamamoto 0:669ef71cba68 11 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 12 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 13 #include "../Using.h"
t_yamamoto 0:669ef71cba68 14
t_yamamoto 0:669ef71cba68 15 using namespace SWITCH;
7ka884 4:ba9df71868df 16 using namespace PID_SPACE;
Ryosei 27:dd9f27fce7d1 17
M_souta 21:e3b58d675c1c 18 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 19
M_souta 22:7d93f79a3686 20
t_yamamoto 0:669ef71cba68 21 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 22 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 23 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 24
t_yamamoto 0:669ef71cba68 25 static bool lock;
t_yamamoto 0:669ef71cba68 26 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 27 static int current;
t_yamamoto 0:669ef71cba68 28
t_yamamoto 0:669ef71cba68 29 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 30
t_yamamoto 0:669ef71cba68 31 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 32 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 33 #endif
t_yamamoto 0:669ef71cba68 34
t_yamamoto 0:669ef71cba68 35 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 36
t_yamamoto 0:669ef71cba68 37 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 38
kishibekairohan 2:c015739085d3 39
M_souta 22:7d93f79a3686 40 Serial pc(USBTX, USBRX);
kishibekairohan 7:e88c5d47a3be 41
kishibekairohan 16:3f2c2d89372b 42 //**************Buzzer****************
kishibekairohan 11:028a150943b5 43 //DigitalOut buzzer(BUZZER_PIN);
kishibekairohan 9:f93fc79a49ea 44 void BuzzerTimer_func();
kishibekairohan 9:f93fc79a49ea 45 Ticker BuzzerTimer;
kishibekairohan 16:3f2c2d89372b 46 bool EMGflag = false;
kishibekairohan 16:3f2c2d89372b 47 PwmOut buzzer(BUZZER_PIN);
kishibekairohan 16:3f2c2d89372b 48 //**************Buzzer****************
kishibekairohan 11:028a150943b5 49
kishibekairohan 11:028a150943b5 50 //************TapeLed*****************
kishibekairohan 11:028a150943b5 51 void TapeLedEms_func();
kishibekairohan 11:028a150943b5 52 TapeLedData tapeLED;
kishibekairohan 11:028a150943b5 53 TapeLedData sendLedData;
kishibekairohan 11:028a150943b5 54 TapeLED_Mode ledMode = Normal;
kishibekairohan 11:028a150943b5 55 Ticker tapeLedTimer;
kishibekairohan 11:028a150943b5 56 //************TapaLed*****************
kishibekairohan 16:3f2c2d89372b 57
Ryosei 27:dd9f27fce7d1 58 const int omni[15][15] = {
Ryosei 27:dd9f27fce7d1 59 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 60 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 61 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 62 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
Ryosei 27:dd9f27fce7d1 63 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
Ryosei 27:dd9f27fce7d1 64 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
Ryosei 27:dd9f27fce7d1 65 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
Ryosei 27:dd9f27fce7d1 66 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
Ryosei 27:dd9f27fce7d1 67 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
Ryosei 27:dd9f27fce7d1 68 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
Ryosei 27:dd9f27fce7d1 69 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
Ryosei 27:dd9f27fce7d1 70 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
Ryosei 27:dd9f27fce7d1 71 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
Ryosei 27:dd9f27fce7d1 72 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
Ryosei 27:dd9f27fce7d1 73 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
M_souta 21:e3b58d675c1c 74 };
M_souta 21:e3b58d675c1c 75
M_souta 21:e3b58d675c1c 76 const int curve[15] = { -204, -150, -104, -66, -38, -17, -4, 0, 4, 17, 38, 66, 104, 150, 204 };
M_souta 21:e3b58d675c1c 77
M_souta 29:44d5454ce8fa 78
M_souta 21:e3b58d675c1c 79 uint8_t SetStatus(int);
M_souta 21:e3b58d675c1c 80 uint8_t SetPWM(int);
M_souta 18:c694bae76e51 81
t_yamamoto 0:669ef71cba68 82 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 83
t_yamamoto 0:669ef71cba68 84 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 85 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 86 static void Process0(void);
t_yamamoto 0:669ef71cba68 87 #endif
t_yamamoto 0:669ef71cba68 88 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 89 static void Process1(void);
t_yamamoto 0:669ef71cba68 90 #endif
t_yamamoto 0:669ef71cba68 91 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 92 static void Process2(void);
t_yamamoto 0:669ef71cba68 93 #endif
t_yamamoto 0:669ef71cba68 94 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 95 static void Process3(void);
t_yamamoto 0:669ef71cba68 96 #endif
t_yamamoto 0:669ef71cba68 97 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 98 static void Process4(void);
t_yamamoto 0:669ef71cba68 99 #endif
t_yamamoto 0:669ef71cba68 100 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 101 static void Process5(void);
t_yamamoto 0:669ef71cba68 102 #endif
t_yamamoto 0:669ef71cba68 103 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 104 static void Process6(void);
t_yamamoto 0:669ef71cba68 105 #endif
t_yamamoto 0:669ef71cba68 106 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 107 static void Process7(void);
t_yamamoto 0:669ef71cba68 108 #endif
t_yamamoto 0:669ef71cba68 109 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 110 static void Process8(void);
t_yamamoto 0:669ef71cba68 111 #endif
t_yamamoto 0:669ef71cba68 112 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 113 static void Process9(void);
t_yamamoto 0:669ef71cba68 114 #endif
t_yamamoto 0:669ef71cba68 115 #endif
t_yamamoto 0:669ef71cba68 116
t_yamamoto 0:669ef71cba68 117 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 118 {
Ryosei 27:dd9f27fce7d1 119 #pragma region USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 120 /*Replace here with the initialization code of your variables.*/
Ryosei 27:dd9f27fce7d1 121
Ryosei 27:dd9f27fce7d1 122 #pragma endregion USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 123
Ryosei 27:dd9f27fce7d1 124 lock = true;
Ryosei 27:dd9f27fce7d1 125 processChangeComp = true;
Ryosei 27:dd9f27fce7d1 126 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 127
Ryosei 27:dd9f27fce7d1 128 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 129 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 130 Process[0] = Process0;
Ryosei 27:dd9f27fce7d1 131 #endif
Ryosei 27:dd9f27fce7d1 132 #if USE_PROCESS_NUM>1
Ryosei 27:dd9f27fce7d1 133 Process[1] = Process1;
Ryosei 27:dd9f27fce7d1 134 #endif
Ryosei 27:dd9f27fce7d1 135 #if USE_PROCESS_NUM>2
Ryosei 27:dd9f27fce7d1 136 Process[2] = Process2;
Ryosei 27:dd9f27fce7d1 137 #endif
Ryosei 27:dd9f27fce7d1 138 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 139 Process[3] = Process3;
Ryosei 27:dd9f27fce7d1 140 #endif
Ryosei 27:dd9f27fce7d1 141 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 142 Process[4] = Process4;
Ryosei 27:dd9f27fce7d1 143 #endif
Ryosei 27:dd9f27fce7d1 144 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 145 Process[5] = Process5;
Ryosei 27:dd9f27fce7d1 146 #endif
Ryosei 27:dd9f27fce7d1 147 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 148 Process[6] = Process6;
Ryosei 27:dd9f27fce7d1 149 #endif
Ryosei 27:dd9f27fce7d1 150 #if USE_PROCESS_NUM>7
Ryosei 27:dd9f27fce7d1 151 Process[7] = Process7;
Ryosei 27:dd9f27fce7d1 152 #endif
Ryosei 27:dd9f27fce7d1 153 #if USE_PROCESS_NUM>8
Ryosei 27:dd9f27fce7d1 154 Process[8] = Process8;
Ryosei 27:dd9f27fce7d1 155 #endif
Ryosei 27:dd9f27fce7d1 156 #if USE_PROCESS_NUM>9
Ryosei 27:dd9f27fce7d1 157 Process[9] = Process9;
Ryosei 27:dd9f27fce7d1 158 #endif
Ryosei 27:dd9f27fce7d1 159 #endif
t_yamamoto 0:669ef71cba68 160 }
t_yamamoto 0:669ef71cba68 161
t_yamamoto 0:669ef71cba68 162 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 163 {
Ryosei 27:dd9f27fce7d1 164 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 165 if(controller->Button.HOME) lock = false;
Ryosei 27:dd9f27fce7d1 166
Ryosei 27:dd9f27fce7d1 167 if(controller->Button.START && processChangeComp) {
Ryosei 27:dd9f27fce7d1 168 current++;
Ryosei 27:dd9f27fce7d1 169 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
Ryosei 27:dd9f27fce7d1 170 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 171 } else if(controller->Button.SELECT && processChangeComp) {
Ryosei 27:dd9f27fce7d1 172 current--;
Ryosei 27:dd9f27fce7d1 173 if (current < 0) current = 0;
Ryosei 27:dd9f27fce7d1 174 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 175 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
Ryosei 27:dd9f27fce7d1 176 #endif
Ryosei 27:dd9f27fce7d1 177
Ryosei 27:dd9f27fce7d1 178 #ifdef USE_MOTOR
Ryosei 27:dd9f27fce7d1 179 ACTUATORHUB::MOTOR::Motor::Update(motor);
Ryosei 27:dd9f27fce7d1 180 #endif
Ryosei 27:dd9f27fce7d1 181
Ryosei 27:dd9f27fce7d1 182 #ifdef USE_SOLENOID
Ryosei 27:dd9f27fce7d1 183 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
Ryosei 27:dd9f27fce7d1 184 #endif
Ryosei 27:dd9f27fce7d1 185
Ryosei 27:dd9f27fce7d1 186 #ifdef USE_RS485
Ryosei 27:dd9f27fce7d1 187 ACTUATORHUB::ActuatorHub::Update();
Ryosei 27:dd9f27fce7d1 188 //LINEHUB::LineHub::Update();
Ryosei 27:dd9f27fce7d1 189 #endif
Ryosei 27:dd9f27fce7d1 190
Ryosei 27:dd9f27fce7d1 191 }
Ryosei 27:dd9f27fce7d1 192
Ryosei 27:dd9f27fce7d1 193
Ryosei 27:dd9f27fce7d1 194 void SystemProcess()
Ryosei 27:dd9f27fce7d1 195 {
Ryosei 27:dd9f27fce7d1 196 SystemProcessInitialize();
Ryosei 27:dd9f27fce7d1 197 while(1) {
M_souta 29:44d5454ce8fa 198
Ryosei 27:dd9f27fce7d1 199 buzzer.period(1.0/800);
Ryosei 27:dd9f27fce7d1 200
Ryosei 27:dd9f27fce7d1 201 #ifdef USE_MU
Ryosei 27:dd9f27fce7d1 202 controller = CONTROLLER::Controller::GetData();
Ryosei 27:dd9f27fce7d1 203 #endif
Ryosei 27:dd9f27fce7d1 204
Ryosei 27:dd9f27fce7d1 205 #ifdef USE_ERRORCHECK
M_souta 29:44d5454ce8fa 206 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost) {
Ryosei 27:dd9f27fce7d1 207 CONTROLLER::Controller::DataReset();
Ryosei 27:dd9f27fce7d1 208 AllActuatorReset();
Ryosei 27:dd9f27fce7d1 209 lock = true;
Ryosei 27:dd9f27fce7d1 210 } else
Ryosei 27:dd9f27fce7d1 211 #endif
Ryosei 27:dd9f27fce7d1 212 {
Ryosei 27:dd9f27fce7d1 213
Ryosei 27:dd9f27fce7d1 214 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 215 if(!lock) {
Ryosei 27:dd9f27fce7d1 216 Process[current]();
Ryosei 27:dd9f27fce7d1 217 } else
Ryosei 27:dd9f27fce7d1 218 #endif
Ryosei 27:dd9f27fce7d1 219 {
Ryosei 27:dd9f27fce7d1 220 //ロック時の処理
Ryosei 27:dd9f27fce7d1 221 }
Ryosei 27:dd9f27fce7d1 222 }
Ryosei 27:dd9f27fce7d1 223
Ryosei 27:dd9f27fce7d1 224
Ryosei 27:dd9f27fce7d1 225 //Emergency!
Ryosei 27:dd9f27fce7d1 226 /*
Ryosei 27:dd9f27fce7d1 227 if(!EMG_0 && !EMG_1 && !EMGflag){
Ryosei 27:dd9f27fce7d1 228 buzzer = 0;
Ryosei 27:dd9f27fce7d1 229 BuzzerTimer.attach(BuzzerTimer_func, 1);
Ryosei 27:dd9f27fce7d1 230 EMGflag = true;
Ryosei 27:dd9f27fce7d1 231 LED_DEBUG0 = 1;
Ryosei 27:dd9f27fce7d1 232 }
Ryosei 27:dd9f27fce7d1 233 if(EMG_0 && EMG_1 && EMGflag){
Ryosei 27:dd9f27fce7d1 234 buzzer = 1;
Ryosei 27:dd9f27fce7d1 235 BuzzerTimer.detach();
Ryosei 27:dd9f27fce7d1 236 EMGflag = false;
Ryosei 27:dd9f27fce7d1 237 }
Ryosei 27:dd9f27fce7d1 238 */
Ryosei 27:dd9f27fce7d1 239 SystemProcessUpdate();
Ryosei 27:dd9f27fce7d1 240 }
t_yamamoto 0:669ef71cba68 241 }
t_yamamoto 0:669ef71cba68 242
kishibekairohan 2:c015739085d3 243
kishibekairohan 2:c015739085d3 244
kishibekairohan 2:c015739085d3 245
t_yamamoto 0:669ef71cba68 246 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 247 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 248 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 249 static void Process0()
Ryosei 27:dd9f27fce7d1 250 {
Ryosei 27:dd9f27fce7d1 251 AllActuatorReset();
t_yamamoto 0:669ef71cba68 252 }
t_yamamoto 0:669ef71cba68 253 #endif
t_yamamoto 0:669ef71cba68 254
t_yamamoto 0:669ef71cba68 255 #if USE_PROCESS_NUM>1
kishibekairohan 16:3f2c2d89372b 256 static void Process1()
t_yamamoto 0:669ef71cba68 257 {
Ryosei 27:dd9f27fce7d1 258
t_yamamoto 0:669ef71cba68 259 }
t_yamamoto 0:669ef71cba68 260 #endif
t_yamamoto 0:669ef71cba68 261
t_yamamoto 0:669ef71cba68 262 #if USE_PROCESS_NUM>2
kishibekairohan 16:3f2c2d89372b 263 static void Process2()
Ryosei 27:dd9f27fce7d1 264 {
M_souta 26:4c0ce2f05688 265
kishibekairohan 13:b6e02d6261d7 266 }
kishibekairohan 13:b6e02d6261d7 267 #endif
kishibekairohan 13:b6e02d6261d7 268
kishibekairohan 13:b6e02d6261d7 269 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 270 static void Process3()
kishibekairohan 13:b6e02d6261d7 271 {
M_souta 29:44d5454ce8fa 272
kishibekairohan 13:b6e02d6261d7 273 }
kishibekairohan 13:b6e02d6261d7 274 #endif
kishibekairohan 13:b6e02d6261d7 275
kishibekairohan 13:b6e02d6261d7 276 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 277 static void Process4()
M_souta 22:7d93f79a3686 278 {
M_souta 29:44d5454ce8fa 279
kishibekairohan 13:b6e02d6261d7 280 }
kishibekairohan 13:b6e02d6261d7 281 #endif
kishibekairohan 13:b6e02d6261d7 282
kishibekairohan 13:b6e02d6261d7 283 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 284 static void Process5()
Ryosei 27:dd9f27fce7d1 285 {
Ryosei 27:dd9f27fce7d1 286
kishibekairohan 13:b6e02d6261d7 287 }
kishibekairohan 13:b6e02d6261d7 288 #endif
kishibekairohan 13:b6e02d6261d7 289
kishibekairohan 13:b6e02d6261d7 290 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 291 static void Process6()
kishibekairohan 13:b6e02d6261d7 292 {
Ryosei 27:dd9f27fce7d1 293
kishibekairohan 13:b6e02d6261d7 294 }
kishibekairohan 13:b6e02d6261d7 295 #endif
kishibekairohan 13:b6e02d6261d7 296
kishibekairohan 13:b6e02d6261d7 297 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 298 static void Process7()
kishibekairohan 13:b6e02d6261d7 299 {
M_souta 29:44d5454ce8fa 300
kishibekairohan 12:c09b3e08a316 301 }
kishibekairohan 12:c09b3e08a316 302 #endif
kishibekairohan 12:c09b3e08a316 303
Ryosei 27:dd9f27fce7d1 304 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 305 static void Process8()
kishibekairohan 12:c09b3e08a316 306 {
M_souta 29:44d5454ce8fa 307
kishibekairohan 12:c09b3e08a316 308 }
kishibekairohan 12:c09b3e08a316 309 #endif
kishibekairohan 12:c09b3e08a316 310
kishibekairohan 13:b6e02d6261d7 311 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 312 static void Process9()
kishibekairohan 12:c09b3e08a316 313 {
Ryosei 27:dd9f27fce7d1 314
t_yamamoto 0:669ef71cba68 315 }
t_yamamoto 0:669ef71cba68 316 #endif
t_yamamoto 0:669ef71cba68 317 #endif
t_yamamoto 0:669ef71cba68 318 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 319
t_yamamoto 0:669ef71cba68 320 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 321 {
M_souta 29:44d5454ce8fa 322 #ifdef USE_SOLENOID
M_souta 29:44d5454ce8fa 323 solenoid.all = ALL_SOLENOID_OFF;
M_souta 29:44d5454ce8fa 324 #endif
M_souta 29:44d5454ce8fa 325
M_souta 29:44d5454ce8fa 326 #ifdef USE_MOTOR
M_souta 29:44d5454ce8fa 327 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
M_souta 29:44d5454ce8fa 328 motor[i].dir = FREE;
M_souta 29:44d5454ce8fa 329 motor[i].pwm = 0;
M_souta 29:44d5454ce8fa 330 }
M_souta 29:44d5454ce8fa 331 #endif
t_yamamoto 0:669ef71cba68 332 }
t_yamamoto 0:669ef71cba68 333
Ryosei 27:dd9f27fce7d1 334 void BuzzerTimer_func()
Ryosei 27:dd9f27fce7d1 335 {
kishibekairohan 16:3f2c2d89372b 336 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 337 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 338 }
kishibekairohan 11:028a150943b5 339
Ryosei 27:dd9f27fce7d1 340 void TapeLedEms_func()
Ryosei 27:dd9f27fce7d1 341 {
kishibekairohan 16:3f2c2d89372b 342 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 343 }
kishibekairohan 16:3f2c2d89372b 344
kishibekairohan 16:3f2c2d89372b 345 #pragma region USER-DEFINED-FUNCTIONS
M_souta 29:44d5454ce8fa 346
M_souta 29:44d5454ce8fa 347 uint8_t SetStatus(int pwmVal)
Ryosei 27:dd9f27fce7d1 348 {
M_souta 29:44d5454ce8fa 349 if (pwmVal < 0) return BACK;
M_souta 29:44d5454ce8fa 350 else if (pwmVal > 0) return FOR;
M_souta 29:44d5454ce8fa 351 else if (pwmVal == 0) return BRAKE;
M_souta 29:44d5454ce8fa 352 else return BRAKE;
M_souta 22:7d93f79a3686 353 }
kishibekairohan 16:3f2c2d89372b 354
M_souta 29:44d5454ce8fa 355 uint8_t SetPWM(int pwmVal)
Ryosei 27:dd9f27fce7d1 356 {
M_souta 29:44d5454ce8fa 357 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
M_souta 29:44d5454ce8fa 358 else return abs(pwmVal);
M_souta 22:7d93f79a3686 359 }
kishibekairohan 16:3f2c2d89372b 360
t_yamamoto 0:669ef71cba68 361 #pragma endregion