/*! Adds a stitch to the pattern (\a p) at the absolute position (\a x,\a y). Positive y is up. Units are in millimeters. */ void embPattern_addStitchAbs(EmbPattern* p, double x, double y, int flags, int isAutoColorIndex) { EmbStitch s; if(!p) { embLog_error("emb-pattern.c embPattern_addStitchAbs(), p argument is null\n"); return; } if(flags & END) { if(embStitchList_empty(p->stitchList)) return; /* Prevent unnecessary multiple END stitches */ if(p->lastStitch->stitch.flags & END) { embLog_error("emb-pattern.c embPattern_addStitchAbs(), found multiple END stitches\n"); return; } embPattern_fixColorCount(p); /* HideStitchesOverLength(127); TODO: fix or remove this */ } if(flags & STOP) { if(embStitchList_empty(p->stitchList)) return; if(isAutoColorIndex) p->currentColorIndex++; } /* NOTE: If the stitchList is empty, we will create it before adding stitches to it. The first coordinate will be the HOME position. */ if(embStitchList_empty(p->stitchList)) { /* NOTE: Always HOME the machine before starting any stitching */ EmbPoint home = embSettings_home(&(p->settings)); EmbStitch h; h.xx = home.xx; h.yy = home.yy; h.flags = JUMP; h.color = p->currentColorIndex; p->stitchList = p->lastStitch = embStitchList_create(h); } s.xx = x; s.yy = y; s.flags = flags; s.color = p->currentColorIndex; #ifdef ARDUINO inoEvent_addStitchAbs(p, s.xx, s.yy, s.flags, s.color); #else /* ARDUINO */ p->lastStitch = embStitchList_add(p->lastStitch, s); #endif /* ARDUINO */ p->lastX = s.xx; p->lastY = s.yy; }
/* Adds a stitch at the absolute position (x,y). Positive y is up. Units are in millimeters. */ void embPattern_addStitchAbs(EmbPattern* p, double x, double y, int flags, int isAutoColorIndex) { EmbStitch s; if(!p) { embLog_error("emb-pattern.c embPattern_addStitchAbs(), p argument is null\n"); return; } if(flags & END) { embPattern_fixColorCount(p); /* HideStitchesOverLength(127); TODO: fix or remove this */ } if((flags & STOP) && embStitchList_empty(p->stitchList)) return; if((flags & STOP) && isAutoColorIndex) { p->currentColorIndex++; } s.xx = x; s.yy = y; s.flags = flags; s.color = p->currentColorIndex; if(!(p->stitchList)) { p->stitchList = (EmbStitchList*)malloc(sizeof(EmbStitchList)); if(!p->stitchList) { embLog_error("emb-pattern.c embPattern_addStitchAbs(), cannot allocate memory for p->stitchList\n"); return; } p->stitchList->stitch = s; p->stitchList->next = 0; p->lastStitch = p->stitchList; } else { embStitchList_add(p->lastStitch, s); p->lastStitch = p->lastStitch->next; } p->lastX = s.xx; p->lastY = s.yy; }
/* Adds a stitch at the absolute position (x,y). Positive y is up. Units are in millimeters. */ void embPattern_addStitchAbs(EmbPattern* p, double x, double y, int flags, int isAutoColorIndex) { /* TODO: pointer safety */ EmbStitch s; if(flags & END) { embPattern_fixColorCount(p); /* HideStitchesOverLength(127); TODO: fix or remove this */ } if((flags & STOP) && embStitchList_empty(p->stitchList)) return; if((flags & STOP) && isAutoColorIndex) { p->currentColorIndex++; } s.xx = x; s.yy = y; s.flags = flags; s.color = p->currentColorIndex; if(!(p->stitchList)) { p->stitchList = (EmbStitchList*)malloc(sizeof(EmbStitchList)); /* TODO: malloc fail error */ p->stitchList->stitch = s; p->stitchList->next = 0; p->lastStitch = p->stitchList; } else { embStitchList_add(p->lastStitch, s); p->lastStitch = p->lastStitch->next; } p->lastX = s.xx; p->lastY = s.yy; }