annotate harelet.c @ 8:c60e4315cb7e

Automated Vimcurial commmit
author VilyaemKenyaz
date Tue, 12 Sep 2023 06:46:45 -0400
parents 1bb981516d87
children 4eb02dffc00f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
1 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
2 * Description - Harelet is a CAD and compiler program for CNC milling machines
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
3 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
4 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
5 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
6
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
7 #include <stdio.h>
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
8 #include <stdlib.h>
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
9 #include <string.h>
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
10
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
11 #include "basedfilelib.h"
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
12
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
13 #ifdef __linux__
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
14 #include "linuxconio.h"
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
15 #endif
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
16
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
17 #ifdef _WIN32
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
18 #include <Windows.h>>
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
19 #include <conio.h>
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
20 #endif
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
21
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
22 #define DEEPNESS 5
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
23 #define MAXPOINT 4096
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
24 #define UNITS "G20"
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
25 #define SPEED 20
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
26
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
27 typedef struct{
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
28 unsigned int X;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
29 unsigned int Y;
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
30 unsigned int down;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
31 }point;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
32
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
33 point points[MAXPOINT];
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
34
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
35 unsigned int X = 100;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
36 unsigned int Y = 100;
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
37 unsigned int step = 5;
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
38 unsigned int down = 0;
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
39 unsigned int numpoints = 0;
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
40 char action;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
41
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
42 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
43 * Description - Renders the screen
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
44 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
45 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
46 * *******************************************/
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
47 void Render(){
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
48 clrscr();
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
49 gotoxy(0,30);
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
50 puts("HARELET A CAD PROGRAM BY VILYAEM KENYAZ, PEEP SOFTWARE 2023");
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
51 printf("Number of Points: %d X: %d Y: %d STEPSIZE: %d DWN?: %d\n",numpoints,X,Y,step,down);
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
52
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
53 //Render points
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
54 for(int i = 0;i != MAXPOINT;i++){
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
55 gotoxy(0,50);
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
56
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
57 gotoxy(points[i].X,points[i].Y);
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
58
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
59 if(points[i].down == 0){
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
60 puts("X");
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
61 }
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
62 else{
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
63 puts("*");
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
64 }
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
65
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
66
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
67 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
68
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
69 //Render cursor
7
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
70
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
71 gotoxy(X,Y);
1bb981516d87 Automated Vimcurial commmit
VilyaemKenyaz
parents: 6
diff changeset
72
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
73 puts("&");
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
74
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
75
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
76
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
77 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
78
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
79 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
80 * Description - This function compiles instructions for CNC machines.
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
81 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
82 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
83 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
84 void Compile(){
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
85 char * filename;
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
86 char * file;
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
87 char buffer[sizeof(int)*8+1];
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
88 int choice;
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
89
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
90 puts("Select your format\n1. RAW GCODE");
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
91 scanf("%d",&choice);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
92
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
93
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
94 puts("Enter the filename");
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
95 scanf("%s",filename);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
96
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
97 if(choice == 1){
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
98 //Set the miller
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
99 strcat(file,UNITS);
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
100 strcat(file,"G0 X0 Y0 Z0");
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
101 //Meat of instructions
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
102 for(int i = 0;i != numpoints;i++){
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
103 //Compose
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
104 char * instruction;
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
105 strcat(instruction,"G0 X");
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
106 itoa(points[i].X,buffer);
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
107 strcat(instruction,buffer);
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
108 strcat(instruction," Y");
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
109 itoa(points[i].Y,buffer);
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
110 strcat(instruction,buffer);
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
111 strcat(instruction," Z");
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
112 itoa(DEEPNESS,buffer);
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
113 strcat(instruction,buffer);
4
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
114 //Write to string
0ed615367b10 Automated Vimcurial commmit
VilyaemKenyaz
parents: 3
diff changeset
115 strcat(file,instruction);
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
116 }
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
117 //Finish
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
118 strcat(file,"G0, X0, Y0, Z0");
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
119 WriteFile(filename,file);
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
120 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
121
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
122 puts("Finished Compiling");
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
123
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
124 }
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
125
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
126
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
127 /*********************************************
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
128 * Description - Main function
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
129 * Author - William King
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
130 * Date - Sep 08 2023
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
131 * *******************************************/
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
132 void main(int argc, char* argv[]){
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
133 while(1){
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
134 Render();
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
135 scanf("%c",&action);
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
136 switch(action){
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
137 case 'a': points[numpoints].X = X;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
138 points[numpoints].Y = Y;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
139 points[numpoints].down = down;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
140 numpoints++;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
141 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
142 case 'h':
6
ec82c868b8b0 Automated Vimcurial commmit
VilyaemKenyaz
parents: 5
diff changeset
143
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
144 X += step;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
145 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
146 case 'j':
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
147 Y += step;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
148 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
149 case 'k':
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
150 Y -= step;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
151 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
152 case 'l':
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
153 X -= step;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
154 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
155 case 's':
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
156 puts("Enter new step:");
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
157 scanf("%d",&step);
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
158 break;
2
1b0ebe86b44c Automated Vimcurial commmit
VilyaemKenyaz
parents: 1
diff changeset
159
8
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
160 case 'c': Compile();
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
161 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
162 default:
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
163 break;
c60e4315cb7e Automated Vimcurial commmit
VilyaemKenyaz
parents: 7
diff changeset
164 }
5
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
165 }
3879c1178448 Automated Vimcurial commmit
VilyaemKenyaz
parents: 4
diff changeset
166
1
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
167 exit(0);
47e1b1039d7b Automated Vimcurial commmit
VilyaemKenyaz
parents: 0
diff changeset
168 }