changeset 18:7bf25e90a1de

Finished writing OpenSBP Shopbot compiler
author VilyaemKenyaz
date Tue, 26 Sep 2023 23:19:42 -0400
parents e13e2d661cc8
children 8fe0b5711413
files FIRST.SBP HARELET.MAN c.ksh harelet harelet.c
diffstat 5 files changed, 90 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FIRST.SBP	Tue Sep 26 23:19:42 2023 -0400
@@ -0,0 +1,23 @@
+'OpenSBP file written by Harelet
+'Harelet, written by William King
+'No responsibilty is taken for any damages to any equipment
+
+'Starting
+SO, 1,1
+Pause 2
+SA,
+&ZUP = 0.25
+MH
+
+'Bulk of instructions
+J2 55 25
+JZ,&ZUP
+J2 55 25
+JZ,&ZUP
+J2 25 25
+JZ,&ZUP
+
+J2,0,0
+SO, 1,0
+'All done. Wait for user.
+PAUSE
\ No newline at end of file
--- a/HARELET.MAN	Wed Sep 13 04:38:20 2023 -0400
+++ b/HARELET.MAN	Tue Sep 26 23:19:42 2023 -0400
@@ -10,22 +10,35 @@
 .SH
 DESC
 .PP
-CAD program for CNC machines
+CAD & CAM program for CNC machines
 
 Vim keys (HJKL) to move
 
 H Left
+
+
 J Down
+
+
 K Up
+
+
 L Right
 
+
+
 A to add a point at the current cursor's position
 
+
 D to make cursor set to down or up
 
-C to compile GCODE
+
+C to COMPILE instructions for a machine
 
-S to change step size
+
+S to change step size (how far you move)
+
 
 Q to exit
 
+
--- a/c.ksh	Wed Sep 13 04:38:20 2023 -0400
+++ b/c.ksh	Tue Sep 26 23:19:42 2023 -0400
@@ -1,6 +1,6 @@
 #!/bin/sh 
 clear 
 rm harelet 
-cc harelet.c -g -o harelet 
+tcc harelet.c -g -o harelet 
 doas cp harelet /usr/bin/ 
 gdb harelet
Binary file harelet has changed
--- a/harelet.c	Wed Sep 13 04:38:20 2023 -0400
+++ b/harelet.c	Tue Sep 26 23:19:42 2023 -0400
@@ -24,6 +24,10 @@
 #define UNITS	"G20\n"
 #define SPEED	20
 
+#define SBPUP "JZ &ZUP\n"
+#define SBPDWN 0.0625
+
+
 typedef struct{
 	unsigned int X;
 	unsigned int Y;
@@ -39,6 +43,19 @@
 unsigned int numpoints = 0;
 char action;
 
+
+/*********************************************
+* Description - Convert integers to strings, makes
+* source code more pretty.
+* Author - William King
+* Date - Sep 26 2023
+* *******************************************/
+char * IntToString(int num){
+	char * s;
+	sprintf(s,"%d",num);
+	return s;
+}
+
 /*********************************************
  * Description - Renders the screen
  * Author - William King
@@ -92,7 +109,7 @@
 	unsigned int choice;
 
 	clrscr();
-	puts("Select your format\n1. RAW GCODE");
+	puts("Select your format\n1. RAW GCODE\n2. OPENSBP");
 	scanf("%d",&choice);
 
 
@@ -121,7 +138,6 @@
 			else{
 				strcat(instruction," Z 0\n");
 			}
-			//strcat(instruction,buffer);
 			//Write to string
 			strcat(file,instruction);
 		}
@@ -130,6 +146,37 @@
 		strcat(file,"G0 X0 Y0 Z0\n");
 		WriteFile(filename,file);
 	}
+	else if(choice == 2){
+	// Setup the miller
+	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");
+
+	for(int i = 0;i != numpoints;i++){
+	
+			char instruction[64];
+
+			strcat(instruction,"J2 ");
+			strcat(instruction,IntToString(points[i].X));
+			strcat(instruction," ");
+			strcat(instruction,IntToString(points[i].Y));
+			strcat(instruction,"\n");
+
+			if(points[i].down == 0){
+				strcat(instruction,"MZ -0,0625\n");
+			}
+			else{
+				strcat(instruction,"JZ,&ZUP\n");
+			}
+				
+
+			strcat(file,instruction);
+	}
+
+	//Finished, add instructions to wait for the user
+	strcat(file,"\nJ2,0,0\nSO, 1,0\n'All done. Wait for user.\nPAUSE");
+
+	WriteFile(filename,file);
+
+	}
 	else{
 
 		puts("Invalid compiliation format");
@@ -138,7 +185,7 @@
 
 	}
 
-	puts("Finished Compiling GCODE");
+	puts("Finished compiling instructions");
 	scanf("");
 
 }