comparison harelet.c @ 8:c60e4315cb7e

Automated Vimcurial commmit
author VilyaemKenyaz
date Tue, 12 Sep 2023 06:46:45 -0400
parents 1bb981516d87
children 4eb02dffc00f
comparison
equal deleted inserted replaced
7:1bb981516d87 8:c60e4315cb7e
5 * *******************************************/ 5 * *******************************************/
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10
10 #include "basedfilelib.h" 11 #include "basedfilelib.h"
11 12
12 #ifdef __linux__ 13 #ifdef __linux__
13 #include "linuxconio.h" 14 #include "linuxconio.h"
14 #endif 15 #endif
29 unsigned int down; 30 unsigned int down;
30 }point; 31 }point;
31 32
32 point points[MAXPOINT]; 33 point points[MAXPOINT];
33 34
34 unsigned int X = 0; 35 unsigned int X = 100;
35 unsigned int Y = 0; 36 unsigned int Y = 100;
36 unsigned int step = 5; 37 unsigned int step = 5;
37 unsigned int down = 0; 38 unsigned int down = 0;
38 unsigned int numpoints = 0; 39 unsigned int numpoints = 0;
39 char action; 40 char action;
40 41
41 /********************************************* 42 /*********************************************
42 * Description - Renders the screen 43 * Description - Renders the screen
43 * Author - William King 44 * Author - William King
44 * Date - Sep 08 2023 45 * Date - Sep 08 2023
45 * *******************************************/ 46 * *******************************************/
46 void Render(){ 47 void Render(){
47 clrscr(); 48 clrscr();
48 gotoxy(0,0); 49 gotoxy(0,30);
49 puts("HARELET A CAD PROGRAM BY VILYAEM KENYAZ, PEEP SOFTWARE 2023"); 50 puts("HARELET A CAD PROGRAM BY VILYAEM KENYAZ, PEEP SOFTWARE 2023");
50 printf("Number of Points: %d X: %d Y: %d STEPSIZE: %d DWN?: %d\n",numpoints,X,Y,step,down); 51 printf("Number of Points: %d X: %d Y: %d STEPSIZE: %d DWN?: %d\n",numpoints,X,Y,step,down);
51 52
52 //Render points 53 //Render points
53 for(int i = 0;i != MAXPOINT;i++){ 54 for(int i = 0;i != MAXPOINT;i++){
54 gotoxy(0,10); 55 gotoxy(0,50);
55 /*
56 //Move X
57 for(int j = 0;j != points[i].X;j++){
58
59 printf("");
60
61 }
62
63 //Move Y
64 for(int k = 0;k != points[i].Y;k++){
65
66 puts("");
67
68
69 }
70 */
71 56
72 gotoxy(points[i].X,points[i].Y); 57 gotoxy(points[i].X,points[i].Y);
73 58
74 if(points[i].down == 0){ 59 if(points[i].down == 0){
75 puts("X"); 60 puts("X");
80 65
81 66
82 } 67 }
83 68
84 //Render cursor 69 //Render cursor
85 /*
86 DocTop();
87 for(int i = 0;i != X;i++){
88 printf("");
89
90 }
91 for(int i = 0;i != Y;i++){
92 puts("");
93 }
94 */
95 70
96 gotoxy(X,Y); 71 gotoxy(X,Y);
97 72
98 puts("&"); 73 puts("&");
99 74
107 * Date - Sep 08 2023 82 * Date - Sep 08 2023
108 * *******************************************/ 83 * *******************************************/
109 void Compile(){ 84 void Compile(){
110 char * filename; 85 char * filename;
111 char * file; 86 char * file;
87 char buffer[sizeof(int)*8+1];
112 int choice; 88 int choice;
113 89
114 puts("Select your format\n1. RAW GCODE"); 90 puts("Select your format\n1. RAW GCODE");
115 scanf("%d",&choice); 91 scanf("%d",&choice);
116 92
125 //Meat of instructions 101 //Meat of instructions
126 for(int i = 0;i != numpoints;i++){ 102 for(int i = 0;i != numpoints;i++){
127 //Compose 103 //Compose
128 char * instruction; 104 char * instruction;
129 strcat(instruction,"G0 X"); 105 strcat(instruction,"G0 X");
130 strcat(instruction,itoa(points[i].X)); 106 itoa(points[i].X,buffer);
107 strcat(instruction,buffer);
131 strcat(instruction," Y"); 108 strcat(instruction," Y");
132 strcat(instruction,itoa(points[i].Y)); 109 itoa(points[i].Y,buffer);
110 strcat(instruction,buffer);
133 strcat(instruction," Z"); 111 strcat(instruction," Z");
134 strcat(instruction,itoa(DEEPNESS)); 112 itoa(DEEPNESS,buffer);
113 strcat(instruction,buffer);
135 //Write to string 114 //Write to string
136 strcat(file,instruction); 115 strcat(file,instruction);
137 } 116 }
138 //Finish 117 //Finish
139 strcat(file,"G0, X0, Y0, Z0"); 118 strcat(file,"G0, X0, Y0, Z0");
150 * Author - William King 129 * Author - William King
151 * Date - Sep 08 2023 130 * Date - Sep 08 2023
152 * *******************************************/ 131 * *******************************************/
153 void main(int argc, char* argv[]){ 132 void main(int argc, char* argv[]){
154 while(1){ 133 while(1){
155 Render(); 134 Render();
156 scanf("%c",&action); 135 scanf("%c",&action);
157 switch(action){ 136 switch(action){
158 case 'a': points[numpoints].X = X; 137 case 'a': points[numpoints].X = X;
159 points[numpoints].Y = Y; 138 points[numpoints].Y = Y;
160 points[numpoints].down = down; 139 points[numpoints].down = down;
161 numpoints++; 140 numpoints++;
162 break; 141 break;
163 case 'h': 142 case 'h':
164 143
165 if(X < 200 - step){ 144 X += step;
166 X += step; 145 break;
167 } 146 case 'j':
168 break; 147 Y += step;
169 case 'j': 148 break;
170 if(X > step){ 149 case 'k':
171 Y += step; 150 Y -= step;
172 } 151 break;
173 break; 152 case 'l':
174 case 'k': 153 X -= step;
175 if(Y < 0){ 154 break;
176 Y -= step; 155 case 's':
177 } 156 puts("Enter new step:");
178 break; 157 scanf("%d",&step);
179 case 'l': 158 break;
180 if(Y > 200){
181 X -= step;
182 }
183 break;
184 159
185 case 's': 160 case 'c': Compile();
186 puts("Enter new step:"); 161 break;
187 scanf("%d",&step); 162 default:
188 break; 163 break;
189 164 }
190 case 'c': Compile();
191 break;
192 default:
193 break;
194 }
195 } 165 }
196 166
197 exit(0); 167 exit(0);
198 } 168 }