├── .gitignore ├── LICENSE ├── README.md ├── commands.txt ├── convert.py ├── mono.bmp ├── nejePrint.sh └── printer.py /.gitignore: -------------------------------------------------------------------------------- 1 | converted.bmp 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Alessio Graziano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2017-06-11 **__Project discontinued due to machine aviability__ Feel free to fork and edit** 2 | 3 | 4 | 5 | Since I didn't figure out how to make Neje Software work on wine. 6 | 7 | commands.txt is kind of a retro-engineering log. 8 | It seems to just save a bitmap somewhere and then prints it. 9 | 10 | # nejePrint 11 | Linux script for Neje Laser engraver 12 | 13 | Usage: 14 | nejePrint.sh SERIALDEVICE IMAGE [BURNINGTIME] 15 | 16 | Image must be 520x520 BMP 1 bit color depth (See mono.bmp) 17 | 18 | 19 | 20 | # python3 Neje Printer 21 | Python 3 based Neje Printer script. 22 | 23 | If the printer is running just pause before running the script. 24 | 25 | Does: 26 | * Image Conversion (Not square images will be stretched) 27 | * Image Load 28 | * Burning Time Setup (With working printer if software already loaded) 29 | * Preview and print (If you really cannot press the button) 30 | * Go home, Reset, Pause 31 | 32 | Does not: 33 | * Converted image Preview 34 | * Printed trace view 35 | * Manual Control 36 | 37 | 38 | 39 | Requires: 40 | * Python3 41 | * Pyserial 42 | * Python EasyGUI 43 | 44 | 45 | More detailed instructions: 46 | http://axengineering.wordpress.com/2016/06/14/neje-laser-engraver-on-linux/ 47 | -------------------------------------------------------------------------------- /commands.txt: -------------------------------------------------------------------------------- 1 | UP Means DOWN 2 | 3 | F1 Start 4 | F2 Pause 5 | F3 To Origin 6 | F4 CarvingPreview 7 | F5 Move 8 | 01 Up 9 | 02 Down 10 | 03 Left 11 | 04 Right 12 | 13 | F6 ??? (Send to Setup) ep 14 | F7 Reverse 15 | 02 Y 16 | F9 Restart y 17 | 18 | 01-F0 Burning Time 19 | 20 | 21 | Image Send: 22 | 23 | FEx8 24 | (Pausa 3 secondi) 25 | 32830 byte di immagine 512x512 1 bit bitmap 26 | -------------------------------------------------------------------------------- /convert.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import tkinter as tk 3 | from tkinter import filedialog 4 | 5 | import serial 6 | import time 7 | 8 | ser = serial.Serial('/dev/ttyUSB0', 57600) 9 | ser.write(b"\xF6") 10 | rep=ser.read(2); 11 | 12 | print('Replied') 13 | 14 | if rep == b'ep' : 15 | root = tk.Tk() 16 | root.withdraw() 17 | file_path = filedialog.askopenfilename() 18 | 19 | im = Image.open(file_path) 20 | 21 | im = im.resize((512,512), Image.NEAREST) 22 | im = im.convert('1').transpose(Image.FLIP_TOP_BOTTOM) 23 | 24 | 25 | im.save('converted.bmp') 26 | 27 | ser.write(b"\xFE\xFE\xFE\xFE\xFE\xFE\xFE\xFE") 28 | time.sleep(3) 29 | ser.write(open("converted.bmp","rb").read()) 30 | time.sleep(3) 31 | 32 | ser.write(b"\xF3") 33 | time.sleep(5) 34 | 35 | burnTime=int(input("Enter burning time (1-200) : ")) 36 | #ser.write(b"\x10") 37 | ser.write(bytes([burnTime])) 38 | time.sleep(1) 39 | 40 | ser.write(b"\xF4") 41 | print("All Done, press the button to print") 42 | else : 43 | print('Printer not connected') 44 | -------------------------------------------------------------------------------- /mono.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AxelTB/nejePrint/c5e43840beb8894485e09d22fd2c177debbd470c/mono.bmp -------------------------------------------------------------------------------- /nejePrint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$#" -lt 2 ]; then 4 | echo "Usage:" 5 | echo " nejePrint.sh SERIALDEVICE IMAGE [BURNINGTIME]" 6 | exit 7 | fi 8 | 9 | if [ "$#" -eq 3 ]; then 10 | btime=`echo "obase=16; $3" | bc` 11 | else 12 | btime=20 13 | fi 14 | 15 | #echo $btime 16 | #echo -e "\x$btime" 17 | 18 | 19 | actualsize=$(wc -c <"$2") 20 | 21 | if [ $actualsize -ne 32830 ]; then 22 | echo "Image must be 520x520 BMP 1 bit color depth" 23 | exit 24 | fi 25 | 26 | 27 | echo setting port... 28 | stty 57600 < $1 29 | sleep 1 30 | stty < $1 31 | echo done 32 | 33 | echo Handshake... 34 | echo -e '\xF6' > $1 35 | sleep 1 36 | echo done 37 | 38 | echo Sending 39 | echo -e '\xFE\xFE\xFE\xFE\xFE\xFE\xFE\xFE' >$1 40 | sleep 3 41 | cat $2 > $1 42 | echo done 43 | sleep 1 44 | 45 | echo home 46 | echo -e '\xF3' > $1 47 | sleep 5 48 | 49 | echo Burning Time 0x$btime 50 | echo -e '\x$btime' > $1 51 | sleep 1 52 | 53 | echo preview 54 | echo -e '\xF4' > $1 55 | 56 | 57 | echo All Done 58 | -------------------------------------------------------------------------------- /printer.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | import serial 4 | import time 5 | from easygui import * 6 | 7 | ser = serial.Serial('/dev/ttyUSB0', 57600) 8 | ser.write(b"\xF6") 9 | rep=ser.read(2); 10 | 11 | reply='bho' 12 | if rep == b'ep' : 13 | choices = ["Convert Image","Load Converted Image","Preview","Print","Set Burning Time","Send Laser Home", "Reset Printer","Pause","Quit"] 14 | 15 | while (reply != 'Quit'): 16 | reply = choicebox("What would you like to do?", choices=choices) 17 | 18 | if reply == choices[0] : 19 | 20 | file_path = fileopenbox() 21 | im = Image.open(file_path) 22 | 23 | im = im.resize((512,512), Image.NEAREST) 24 | im = im.convert('1').transpose(Image.FLIP_TOP_BOTTOM) 25 | 26 | 27 | im.save('converted.bmp') 28 | msgbox("Check converted.bmp for a (Vertically flipped) preview") 29 | elif reply == choices[1]: 30 | print('Sending converted.bmp to machine, please wait') 31 | ser.write(b"\xFE\xFE\xFE\xFE\xFE\xFE\xFE\xFE") 32 | time.sleep(3) 33 | print('.') 34 | ser.write(open("converted.bmp","rb").read()) 35 | print('.') 36 | time.sleep(3) 37 | print('Done!') 38 | 39 | ser.write(b"\xF3") 40 | elif reply == choices[2]: 41 | ser.write(b"\xF4") 42 | elif reply == choices[3]: 43 | ser.write(b"\xF1") 44 | elif reply == choices[4]: 45 | #burnTime=int(input("Enter burning time (1-240) : ")) 46 | burnTime=integerbox(msg='Enter Burning time', title='Set Burning Time', default=20, lowerbound=1, upperbound=240) 47 | #ser.write(b"\x10") 48 | if burnTime != None : 49 | ser.write(bytes([burnTime])) 50 | elif reply == choices[5]: 51 | ser.write(b"\xF3") 52 | elif reply == choices[6]: 53 | ser.write(b"\xF9") 54 | elif reply == choices[7]: 55 | ser.write(b"\xF2") 56 | 57 | else : 58 | print('Printer not connected') 59 | --------------------------------------------------------------------------------