comparison harelet.c @ 18:7bf25e90a1de

Finished writing OpenSBP Shopbot compiler
author VilyaemKenyaz
date Tue, 26 Sep 2023 23:19:42 -0400
parents 43dcb67b173d
children 8fe0b5711413
comparison
equal deleted inserted replaced
17:e13e2d661cc8 18:7bf25e90a1de
21 21
22 #define DEEPNESS 5 22 #define DEEPNESS 5
23 #define MAXPOINT 4096 23 #define MAXPOINT 4096
24 #define UNITS "G20\n" 24 #define UNITS "G20\n"
25 #define SPEED 20 25 #define SPEED 20
26
27 #define SBPUP "JZ &ZUP\n"
28 #define SBPDWN 0.0625
29
26 30
27 typedef struct{ 31 typedef struct{
28 unsigned int X; 32 unsigned int X;
29 unsigned int Y; 33 unsigned int Y;
30 unsigned int down; 34 unsigned int down;
37 unsigned int step = 5; 41 unsigned int step = 5;
38 unsigned int down = 0; 42 unsigned int down = 0;
39 unsigned int numpoints = 0; 43 unsigned int numpoints = 0;
40 char action; 44 char action;
41 45
46
47 /*********************************************
48 * Description - Convert integers to strings, makes
49 * source code more pretty.
50 * Author - William King
51 * Date - Sep 26 2023
52 * *******************************************/
53 char * IntToString(int num){
54 char * s;
55 sprintf(s,"%d",num);
56 return s;
57 }
58
42 /********************************************* 59 /*********************************************
43 * Description - Renders the screen 60 * Description - Renders the screen
44 * Author - William King 61 * Author - William King
45 * Date - Sep 08 2023 62 * Date - Sep 08 2023
46 * *******************************************/ 63 * *******************************************/
90 char file[8192]; 107 char file[8192];
91 char buffer[64]; 108 char buffer[64];
92 unsigned int choice; 109 unsigned int choice;
93 110
94 clrscr(); 111 clrscr();
95 puts("Select your format\n1. RAW GCODE"); 112 puts("Select your format\n1. RAW GCODE\n2. OPENSBP");
96 scanf("%d",&choice); 113 scanf("%d",&choice);
97 114
98 115
99 puts("Enter the filename"); 116 puts("Enter the filename");
100 scanf("%s",filename); 117 scanf("%s",filename);
119 strcat(instruction," Z 5\n"); 136 strcat(instruction," Z 5\n");
120 } 137 }
121 else{ 138 else{
122 strcat(instruction," Z 0\n"); 139 strcat(instruction," Z 0\n");
123 } 140 }
124 //strcat(instruction,buffer);
125 //Write to string 141 //Write to string
126 strcat(file,instruction); 142 strcat(file,instruction);
127 } 143 }
128 144
129 //Finish 145 //Finish
130 strcat(file,"G0 X0 Y0 Z0\n"); 146 strcat(file,"G0 X0 Y0 Z0\n");
131 WriteFile(filename,file); 147 WriteFile(filename,file);
132 } 148 }
149 else if(choice == 2){
150 // Setup the miller
151 strcat(file,"'OpenSBP file written by Harelet\n'Harelet, written by William King\n'No responsibilty is taken for any damages to any equipment\n\n'Starting\nSO, 1,1\nPause 2\nSA,\n&ZUP = 0.25\nMH\n\n'Bulk of instructions\n");
152
153 for(int i = 0;i != numpoints;i++){
154
155 char instruction[64];
156
157 strcat(instruction,"J2 ");
158 strcat(instruction,IntToString(points[i].X));
159 strcat(instruction," ");
160 strcat(instruction,IntToString(points[i].Y));
161 strcat(instruction,"\n");
162
163 if(points[i].down == 0){
164 strcat(instruction,"MZ -0,0625\n");
165 }
166 else{
167 strcat(instruction,"JZ,&ZUP\n");
168 }
169
170
171 strcat(file,instruction);
172 }
173
174 //Finished, add instructions to wait for the user
175 strcat(file,"\nJ2,0,0\nSO, 1,0\n'All done. Wait for user.\nPAUSE");
176
177 WriteFile(filename,file);
178
179 }
133 else{ 180 else{
134 181
135 puts("Invalid compiliation format"); 182 puts("Invalid compiliation format");
136 scanf(""); 183 scanf("");
137 184
138 185
139 } 186 }
140 187
141 puts("Finished Compiling GCODE"); 188 puts("Finished compiling instructions");
142 scanf(""); 189 scanf("");
143 190
144 } 191 }
145 192
146 193