diff harelet.c @ 12:35e6a7b53e3c

Automated Vimcurial commmit
author VilyaemKenyaz
date Tue, 12 Sep 2023 08:18:53 -0400
parents 1d4df12de9e3
children 8fe2392f2fcc
line wrap: on
line diff
--- a/harelet.c	Tue Sep 12 08:05:11 2023 -0400
+++ b/harelet.c	Tue Sep 12 08:18:53 2023 -0400
@@ -88,11 +88,12 @@
  * Date - Sep 08 2023
  * *******************************************/
 void Compile(){
-	
-	char * filename;
-	char * file;
-	char buffer[sizeof(int)*8+1];
-	int choice;
+
+	char filename[32];
+	char file[8192];
+	char buffer[32];
+	unsigned int choice;
+
 	clrscr();
 	puts("Select your format\n1. RAW GCODE");
 	scanf("%d",&choice);
@@ -100,7 +101,7 @@
 
 	puts("Enter the filename");
 	scanf("%s",filename);
-
+	printf("Compiling %s,,,\n",filename);
 	if(choice == 1){
 		//Set the miller
 		strcat(file,UNITS);
@@ -108,7 +109,7 @@
 		//Meat of instructions
 		for(int i = 0;i != numpoints;i++){
 			//Compose
-			char * instruction;
+			char instruction[32];
 			strcat(instruction,"G0 X");
 			strcat(instruction,buffer);
 			//Convert X to string
@@ -117,9 +118,12 @@
 			//Convert Y to string
 			sprintf(buffer,"%d",&points[i].Y);
 			strcat(instruction,buffer);
-			//Convert Z to string
-			sprintf(buffer,"%d",5);
-			strcat(instruction," Z");
+			if(points[i].down = 1){
+				strcat(instruction," Z 5");
+			}
+			else{
+				strcat(instruction," Z 0");
+			}
 			strcat(instruction,buffer);
 			//Write to string
 			strcat(file,instruction);
@@ -128,10 +132,16 @@
 		strcat(file,"G0, X0, Y0, Z0");
 		WriteFile(filename,file);
 	}
+	else{
+
+		puts("Invalid compile format");
+
+
+	}
 
 	puts("Finished Compiling GCODE");
 
-	
+
 }
 
 
@@ -144,49 +154,48 @@
 	clrscr();
 	while(1){
 		Render();
-		//New CONIO controls
 		switch(getchar()){
-		case 'h': 
-			X -= step;
-			break;
-		case 'j': 
-			Y += step;
-			break;
-		case 'k': 
-			Y -= step;
-			break;
-		case 'l': 
-			X += step;
-			break;
+			case 'h': 
+				X -= step;
+				break;
+			case 'j': 
+				Y += step;
+				break;
+			case 'k': 
+				Y -= step;
+				break;
+			case 'l': 
+				X += step;
+				break;
 
-		case 's': 
-			puts("New stepsize");
-			scanf("%d",&step);
+			case 's': 
+				puts("New stepsize");
+				scanf("%d",&step);
 
-			break;
+				break;
 
-		case 'a': 
-		   	points[numpoints].X = X;
-		   	points[numpoints].Y = Y;
-		   	points[numpoints].down = down;
-		   	numpoints++;
-			break;
-		case 'd':
-			if(down == 1){
-			down = 0;
-			}
-			else{
-			down = 1;
-			}
-			break;
+			case 'a': 
+				points[numpoints].X = X;
+				points[numpoints].Y = Y;
+				points[numpoints].down = down;
+				numpoints++;
+				break;
+			case 'd':
+				if(down == 1){
+					down = 0;
+				}
+				else{
+					down = 1;
+				}
+				break;
 
-		case 'c': 
-			Compile();
-			break;
+			case 'c': 
+				Compile();
+				break;
 
-		default:
-			putchar('\a');
-			break;
+			default:
+				putchar('\a');
+				break;
 		}
 	}