Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 2022_NHK_B_UK 2022_NHK_B_sub2
Diff: SEKIkikou.cpp
- Revision:
- 0:04c98c2cfe16
- Child:
- 1:fab774f63278
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SEKIkikou.cpp Sun Oct 09 10:13:01 2022 +0000
@@ -0,0 +1,72 @@
+
+#include "SEKIkikou.h"
+
+SEKIkikou::SEKIkikou(ikarashiMDC *ik1, ikarashiMDC *ik2, ikarashiMDC *ik3, uint8_t *b1, uint8_t *b2, uint8_t *b3, uint8_t *b4, int *env1, int *env2, int *env3){
+ ik[0] = ik1; //射出
+ ik[1] = ik2; //将校
+ ik[2] = ik3; //装填
+ button[0] = b1; //射出
+ button[1] = b2; //上
+ button[2] = b3; //下
+ button[3] = b4; //装填
+ encoder[0] = env1; //射出
+ encoder[1] = env2; //将校
+ encoder[2] = env3; //装填
+ for(int i=0; i<3; i++) mspeed[i] = 0;
+}
+
+void SEKIkikou::runAll(float speedI, float speedLoad, float speedLift)
+{
+ runInjection(speedI);
+ runLoad(speedLoad);
+ runLift(speedLift);
+}
+
+void SEKIkikou::runInjection(float speed)
+{
+ ik[0]->setSpeed(mspeed[0]);
+ if(timer.read() >= 1){
+ *encoder[0] = 0;
+ timer.reset();
+ }else{
+ mspeed[0] = 0;
+ }
+ if(*button[0] <= 0){
+ mspeed[0] = 0;
+ return;
+ }
+ if(*encoder[0] < 360){
+ mspeed[0] = speed;
+ }else if(*encoder[0] >= 360){
+ timer.start();
+ mspeed[0] = 0;
+ }
+}
+
+void SEKIkikou::runLoad(float speed)
+{
+ ik[2]->setSpeed(mspeed[2]);
+ if(*button[3] <= 0){
+ mspeed[2] = 0;
+ return;
+ }else if(*button[3] >= 1){
+ mspeed[2] = speed;
+ }else{
+ mspeed[2] = 0;
+ }
+}
+
+void SEKIkikou::runLift(float speed)
+{
+ ik[1]->setSpeed(mspeed[1]);
+ if(*button[1] <= 0 && *button[2] <= 0){
+ mspeed[1] = 0;
+ return;
+ }else if(*button[1] >= 1){
+ mspeed[1] = speed;
+ }else if(*button[2] >= 1){
+ mspeed[1] = -speed;
+ }else{
+ mspeed[1] = 0;
+ }
+}
\ No newline at end of file