Skip to content

Commit

Permalink
bugfix in reading M204 and M205
Browse files Browse the repository at this point in the history
  • Loading branch information
arhi committed Jan 2, 2018
1 parent a1b3b3d commit d9a542d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
1 change: 0 additions & 1 deletion calcmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ double calcmove(char * buffer, print_settings_t * print_settings){
//SMOOTHIEWARE - JUNCTION DEVIATION & ACCELERATION

costheta = (xa * oldxa + ya * oldya + za + oldza) / (sqrt(xa * xa + ya * ya + za * za) * sqrt(oldxa * oldxa + oldya * oldya + oldza * oldza));

if (costheta < 0.95) {
speed = f;
if (costheta > -0.95F) {
Expand Down
18 changes: 10 additions & 8 deletions gcodestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ int main(int argc, char** argv) {
double next_pct = 100;
double pct_step = 0.1;
double heatup_time = 0.0;
char *apikey;
char *apiurl;
CURL *curl;
char *apikey = NULL;
char *apiurl = NULL;
CURL *curl = NULL;
CURLcode res;
curl_mime *form = NULL;
curl_mimepart *field = NULL;
struct curl_slist *headerlist = NULL;
void *chunk;
void *chunk = NULL;
int alert = 0;

static struct option long_options[] = {
Expand Down Expand Up @@ -165,6 +165,8 @@ int main(int argc, char** argv) {
next_pct = 0.9;
heatup_time = 0.0;
seconds = heatup_time;
apikey = NULL;
apiurl = NULL;

int option_index = 0;
int getopt_result;
Expand Down Expand Up @@ -525,14 +527,14 @@ int main(int argc, char** argv) {
#ifdef _WIN32
if (alert) {
char ttime[128];
snprintf(ttime, 128, "Total Time:");
snprintf(ttime, 128, "Total Time: ");

if ((long int) floor(seconds) > 60 * 60 * 24 * 7)
snprintf(ttime, 128, "%s %ld weeks, ", ttime, (long int) floor(seconds) / 60 / 60 / 24 / 7);
snprintf(ttime, 128, "%s%ld weeks, ", ttime, (long int) floor(seconds) / 60 / 60 / 24 / 7);
if ((long int) floor(seconds) > 60 * 60 * 24)
snprintf(ttime, 128, "%s %ld days, ", ttime, ((long int) floor(seconds) / 60 / 60 / 24) % 7);
snprintf(ttime, 128, "%s%ld days, ", ttime, ((long int) floor(seconds) / 60 / 60 / 24) % 7);
if ((long int) floor(seconds) > 60 * 60)
snprintf(ttime, 128, "%s %02ld:", ttime, ((long int) floor(seconds) / 3600) % 24);
snprintf(ttime, 128, "%s%02ld:", ttime, ((long int) floor(seconds) / 3600) % 24);

snprintf(ttime, 128, "%s%02ld:", ttime, ((long int) floor(seconds) / 60) % 60);
snprintf(ttime, 128, "%s%02ld ", ttime, (long int) floor(seconds) % 60);
Expand Down
12 changes: 6 additions & 6 deletions gcodestat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include <stdbool.h>

#define LINE_BUFFER_LENGTH 4096
#define DEFAULT_ACCELERATION 100
#define DEFAULT_JUNCTION_DEVIATION 0.02
#define DEFAULT_JERK 4.00
#define DEFAULT_MAX_SPEED 100000
#define DEFAULT_RETRACT_TIME 0.0
#define DEFAULT_PRIME_TIME 0.0
#define DEFAULT_ACCELERATION 1000
#define DEFAULT_JUNCTION_DEVIATION 0.02
#define DEFAULT_JERK 4.00
#define DEFAULT_MAX_SPEED 100000
#define DEFAULT_RETRACT_TIME 0.0
#define DEFAULT_PRIME_TIME 0.0

#define GCODE_IRRELEVANT 0
#define GCODE_MOVE 1
Expand Down
Binary file added libcurl.dll
Binary file not shown.
43 changes: 33 additions & 10 deletions readgcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,51 @@ double read_dwell(char *buffer){
* M203
*/
int read_maxfeed(char *buff, print_settings_t *print_settings){
read_gvalue(buff, 'X', &(print_settings->x_maxspeed));
read_gvalue(buff, 'Y', &(print_settings->y_maxspeed));
read_gvalue(buff, 'Z', &(print_settings->z_maxspeed));
double X,Y,Z;
read_gvalue(buff, 'X', &X);
read_gvalue(buff, 'Y', &Y);
read_gvalue(buff, 'Z', &Z);
if (X > 0) print_settings->x_maxspeed = X;
if (Y > 0) print_settings->y_maxspeed = Y;
if (Z > 0) print_settings->z_maxspeed = Z;
return(0);
}

/*
* M204
*/
int read_accel(char* buffer, print_settings_t *print_settings){
double Saccel, Xaccel;
double Saccel, Paccel;
Saccel = 0;
Xaccel = 0;
read_gvalue(buffer, 'S', &Saccel);
read_gvalue(buffer, 'X', &Xaccel);
if (_MIN_(Saccel, Xaccel) > 0) print_settings->accel = _MIN_(Saccel, Xaccel);
Paccel = 0;
read_gvalue(buffer, 'S', &Saccel); //Smoothieware
read_gvalue(buffer, 'P', &Paccel); //Marlin
if (_MAX_(Saccel, Paccel) > 0) print_settings->accel = _MAX_(Saccel, Paccel); //can only S or P so whichever >0
return(0);
}

/*
* M205
*/
int read_jdev(char* buffer, print_settings_t *print_settings){
return read_gvalue(buffer, 'X', &(print_settings->jdev));
double Xj, Yj;
Xj = 0;
Yj = 0;
read_gvalue(buffer, 'X', &Xj); //Smoothieware, Marlin
read_gvalue(buffer, 'Y', &Yj); //Marlin
if (Xj > 0) print_settings->jdev = Xj;
if (Yj > 0 && Yj < Xj) print_settings->jdev = Yj;
return(0);
}

/*
* M220
*/
int read_speedover(char* buffer, print_settings_t *print_settings){
return read_gvalue(buffer, 'S', &(print_settings->speedoverride));
double S;
read_gvalue(buffer, 'S', &S);
if (S > 0) print_settings->speedoverride = S;
return (0);
}

//TODO:
Expand Down
4 changes: 4 additions & 0 deletions readgcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#define _MIN_(a,b) (((a)<(b))?(a):(b))
#endif

#ifndef _MAX_
#define _MAX_(a,b) (((a)>(b))?(a):(b))
#endif

bool comment(char *);
int gcode(char *);
double read_dwell(char *);
Expand Down

0 comments on commit d9a542d

Please sign in to comment.