summaryrefslogtreecommitdiff
path: root/Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c')
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c b/Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c
new file mode 100755
index 0000000..89a53dd
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/Resources/src/cmd_encoder_init.c
@@ -0,0 +1,39 @@
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include "../Include/encoder.h"
+#include "../Include/serial.h"
+
+void cmd_encoder_init(int h,int enc_mode,int pin_no_1,int pin_no_2)
+{
+
+ int wr;
+ char code_sent[10]="Ea";
+ char c[2];
+
+ sprintf(c,"%c",48+corresp[block->rpar[2]]);
+ strcat(code_sent,c);
+ if(block.rpar(2)==4)
+ {
+ char c1[2],c2[2],v[10];
+ sprintf(c1,"%c",48+0+corresp[block->rpar[3]]);
+ sprintf(v,"%s",(block->rpar[1]));
+ strcat(code_sent,c1);
+ strcat(code_sent,v);
+ }
+ else
+ {
+ char c2[2],v[10];
+ sprintf(c2,"%c",48+0+corresp[block->rpar[3]]);
+ sprintf(v,"%s",block->rpar[1]);
+ strcat(code_sent,c1);
+ strcat(code_sent,v);
+ }
+ wr=write_serial(1,code_sent,5);
+ strcpy(code_sent,"Ez");
+ sprintf(c,"%c",corresp[block->rpar[2]])
+ strcat(code_sent,c);
+ wr=write_serial(1,code_sent,3)
+} \ No newline at end of file