1
|
1 /*********************************************
|
|
2 * Description - Harelet is a CAD and compiler program for CNC milling machines
|
|
3 * Author - William King
|
|
4 * Date - Sep 08 2023
|
|
5 * *******************************************/
|
|
6
|
|
7 #include <stdio.h>
|
|
8 #include <stdlib.h>
|
|
9 #include "basedfilelib.h"
|
|
10
|
|
11 #define DEEPNESS 5
|
|
12 #define MAXPOINT 4096
|
2
|
13 #define UNITS "G20"
|
|
14 #define SPEED 20
|
1
|
15
|
|
16 typedef struct{
|
|
17 unsigned int X,Y,down;
|
|
18 }point;
|
|
19
|
|
20 points[MAXPOINT];
|
|
21
|
|
22 unsigned int X,Y,step,down,numpoints;
|
|
23 char action;
|
|
24
|
|
25 /*********************************************
|
|
26 * Description - Renders the screen
|
|
27 * Author - William King
|
|
28 * Date - Sep 08 2023
|
|
29 * *******************************************/
|
|
30 void Render(){
|
|
31
|
|
32 for(int i = 0;i != MAXPOINT;i++){
|
|
33 DocTop();
|
|
34 //Move X
|
|
35 for(int j = 0;j != points[i].X;j++){
|
|
36
|
|
37 printf("");
|
|
38
|
|
39 }
|
|
40
|
|
41 //Move Y
|
|
42 for(int k = 0;k != points[i].Y;k++){
|
|
43
|
|
44 puts("");
|
|
45
|
|
46
|
|
47 }
|
|
48
|
|
49 puts("X");
|
|
50
|
|
51
|
|
52 }
|
|
53
|
|
54
|
|
55 }
|
|
56
|
|
57 /*********************************************
|
|
58 * Description - This function compiles instructions for CNC machines.
|
|
59 * Author - William King
|
|
60 * Date - Sep 08 2023
|
|
61 * *******************************************/
|
|
62 void Compile(){
|
|
63 char * filename;
|
2
|
64 char * file;
|
1
|
65 int choice;
|
|
66
|
|
67 puts("Select your format\n1. RAW GCODE\n2. Superhare INO");
|
|
68 scanf("%d",&choice);
|
|
69
|
|
70
|
|
71 puts("Enter the filename");
|
|
72 scanf("%s",filename);
|
|
73
|
|
74 if(choice == 1){
|
2
|
75 //Set the miller
|
|
76 strcat(file,UNITS);
|
|
77
|
|
78 //Meat of instructions
|
|
79 for(int i = 0;i != numpoints;i++){
|
|
80 //Compose
|
|
81 char * instruction;
|
|
82 strcat(instruction,"G0 X");
|
|
83 strcat(instruction,sprintf("%d",points[i].X));
|
|
84 strcat(instruction," Y");
|
|
85 strcat(inustrction,sprintf
|
|
86 //Write to string
|
|
87 strcat(file,instruction);
|
|
88 }
|
|
89 //Finish
|
|
90 strcat(file,"G0, X0, Y0, Z0");
|
|
91 WriteFile(filename,file);
|
1
|
92 }
|
|
93 else{
|
2
|
94 //Set the miller
|
|
95
|
1
|
96
|
2
|
97 //Meat of instructions
|
|
98
|
|
99
|
|
100 //Finish
|
1
|
101
|
|
102 }
|
|
103
|
|
104 puts("Finished Compiling");
|
|
105
|
|
106 }
|
|
107
|
|
108
|
|
109 /*********************************************
|
|
110 * Description - Main function
|
|
111 * Author - William King
|
|
112 * Date - Sep 08 2023
|
|
113 * *******************************************/
|
|
114 void main(int argc, char* argv[]){
|
|
115 scanf("%c",&action);
|
|
116 switch(action){
|
2
|
117 case 'a': points[numpoints].X = X;
|
|
118 points[numpoints].Y = Y;
|
|
119 points[numpoints].down = down;
|
|
120 numpoints++;
|
|
121 break;
|
|
122 case 'h':
|
|
123 X+=step;
|
|
124 break;
|
|
125 case 'j':
|
|
126 Y+=step;
|
1
|
127 break;
|
2
|
128 case 'k':
|
|
129 Y-=step;
|
|
130 break;
|
|
131 case 'l':
|
|
132 X-=step;
|
1
|
133 break;
|
2
|
134
|
|
135 case 's':
|
|
136 puts("Enter new step:");
|
|
137 scanf("%d",&step);
|
|
138 break;
|
|
139 default:
|
1
|
140 break;
|
|
141 }
|
|
142 exit(0);
|
|
143 }
|