Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native support for Brother/PES #138

Open
maehw opened this issue Jan 11, 2025 · 2 comments
Open

Add native support for Brother/PES #138

maehw opened this issue Jan 11, 2025 · 2 comments

Comments

@maehw
Copy link

maehw commented Jan 11, 2025

TL;DR: I've started to add support for the Brother/PES file format, but I am stuck - and I am looking for other people to help!


First of all, thanks for the nice project!

I've discovered TurtleStitch thanks to Margaret J. Low who posted about it in the fediverse: https://chaos.social/@[email protected]/113605225298852491

Nice to see it published under an open source license so that everyone can share & improve it.

I am an embedded software engineer and I am a noob with machine embroidery. However, I recently got myself an old Brother PE-150 machine for a reasonable price! The machine is very old and it doesn't have a USB port - instead it has those proprietary memory cards. There are cards which you can program with a card writer sold by Brother and their (free) PED-Basic software for Windows. Long story short: these machines only support the PES file format.

Interestingly, there's https://github.com/EmbroidePy/pyembroidery (CC @tatarize). I guess it could by used to convert the currently supported file formats (i.e. Melco/EXP and Tajima/DST). However, I'd not be too happy with the workflow and I'd prefer to export to Brother/PES directly from TurtleStitch (i.e. the JavaScript code running in the webbrowser).

There's plenty good ressources about the PES and PEC file formats in the web, e.g.:

I've forked this repository and created a branch to work on the PES format support. You can find it here: https://github.com/maehw/turtlestitch/tree/pes-support (haven't created a PR yet a
s work isn't finished; but I can so that you can easily see the changes I made so far).

I've been able to provide a proof of concept for PES files. Use this artifact at your own risk:

pes-poc.zip

This is what the file preview looks like in the Brother PED-Basic software (for the USB card writer):
pes-poc

I've been able to write the card with above PES file (see zipped attachment). A previous attempt looked like this:
there is no sewing data

The preview image is still blank - I guess it would be generated by the PED-Basic software itself from the actual PES sections.

In the PEC file, I've included a dummy chessboard alike pattern:
pes-pattern

I've also dared to stitch the actual dummy pattern (a few diagonal short stitches)... and it seemed to work!

What did I do? I've added a button to the GUI...
image

... and a method to stitchcode/turtleShepherd.js to do the PES file format encoding: https://github.com/maehw/turtlestitch/blob/pes-support/stitchcode/turtleShepherd.js#L846

I am looking for other developers who are willing support me in this task.

Where I am currently stuck:
I cannot access this.cache (resp. this.cache.length) in the method. What do I need to change? Consider me being more or less a beginner with JavaScript.

Nice to have but the next steps would also be interesting:

  1. Support me in the PEC stitchlist encoding (turn the commands that TurtleStitch uses into PEC encoded stitches/ jump stitches)
  2. Add support for color changes
  3. Add support to generate PEC thumbnails (48 x 38 pixels for every thread color)
  4. Add support so that PED-Basic will also generate proper thumbnail images (probably requires to add data in the PES v1 part of the file; I am currently using the bare minimum in the PES part as this should only be really necessary if someone wants to open the files in a design software)
@maehw
Copy link
Author

maehw commented Jan 12, 2025

I was able to fix the access problem to this. It seems that nested functions have another scope. So I could hand the this.cache into the function by an argument... or simply get rid of the helper function itself. As the other formats also directly encode in their methods, I've chosen the latter.

And I've also slightly modified the PoC stitch pattern (20 diagonal stitches of 1 mm each, then 4x 20 horizontal/vertical stitches of 1 mm each; total stitch count: 100):

pes-poc2

Turns out, that the PED-Basic software also does not need the PES part for creating a thumbnail but seems to interpret and draw the PEC stitch list (see screenshot above). I just didn't look close enough the last time.

pes-poc2.zip

The code itself is also pushed to the branch in my fork.

@maehw
Copy link
Author

maehw commented Jan 13, 2025

Hello everyone. I've created the (WIP) PR (see mention above).

First, I got some basic stitch encoding woring (no jump/trim stitches so far).

The problem I've seen now is that the y axis was inverted (i.e. the pattern was mirrored upside down). I've fixed in in the code - but PED-Basic then won't display the the generated PES file anymore:

The following screenshot should actually preview both files (turtlestitch_hello.pes and turtlestitch_inverted-y.pes):
turtlestitch-only-inverted-y

Please find attached both files:
turtlestitch_hello.zip

I've also tried a different program ("Wilcom TrueSizer" V2.0B). It seems to be less strict (not file format compliant?) and happily reads both files and displays the pattern.

right

upside-down

Any ideas on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant