readme and some copilot fixes
This commit is contained in:
parent
cffc0931b7
commit
c7b5dedcae
64
readme
64
readme
|
@ -1,43 +1,27 @@
|
||||||
|
### install
|
||||||
|
```bash
|
||||||
|
git clone git@github.com:5shekel/madpeset.git && cd madpeset
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
|
python -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install pillow brother_ql
|
||||||
|
```
|
||||||
|
to get the camera working, you need to install the drivers for the camera. I used the [official guide](https://www.raspberrypi.org/documentation/configuration/camera.md) to install the drivers.
|
||||||
|
|
||||||
|
if you use a webcam try
|
||||||
|
```bash
|
||||||
|
sudo apt install fswebcam
|
||||||
|
```
|
||||||
|
|
||||||
|
### run
|
||||||
|
```bash
|
||||||
|
python txt.py
|
||||||
|
```
|
||||||
|
i usually add a tmux session to `~/.bashrc` to run the script on startup
|
||||||
|
|
||||||
|
|
||||||
|
test printer
|
||||||
```py
|
```py
|
||||||
brother_ql -b pyusb -m QL-550 -p usb://0x04f9:0x2016 print -l 62 pefectFake.jpg --dither
|
brother_ql -b pyusb -m QL-550 -p usb://0x04f9:0x2016 print -l 62 pefectFake.jpg --dither
|
||||||
```
|
```
|
||||||
```
|
|
||||||
byobu new-window -n 'printer' 'cd ~/printBash && bash switch.sh'
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
#to reload the systemd manager configuration.
|
|
||||||
#Run
|
|
||||||
sudo systemctl enable switch.service
|
|
||||||
#to enable the service to start at boot.
|
|
||||||
#Run
|
|
||||||
sudo systemctl start switch.service
|
|
||||||
#to start the service immediately.
|
|
||||||
```
|
|
||||||
|
|
||||||
To command the camera in the terminal I suggest to use the fswebcam package. To install:
|
|
||||||
|
|
||||||
`sudo apt install fswebcam`
|
|
||||||
|
|
||||||
To take an image with a certain resolution and hide the standard banner:
|
|
||||||
|
|
||||||
`fswebcam -r 1280x720 --no-banner /images/image1.jpg`
|
|
||||||
|
|
||||||
To find the supported webcam resolutions:
|
|
||||||
|
|
||||||
`v4l2-ctl --list-formats-ext`
|
|
||||||
|
|
||||||
You could also use ffmpeg to take images and video. To install:
|
|
||||||
|
|
||||||
`sudo apt install ffmpeg`
|
|
||||||
|
|
||||||
To take an image:
|
|
||||||
|
|
||||||
`ffmpeg -f v4l2 -video_size 1280x720 -i /dev/video0 -frames 1 out.jpg`
|
|
||||||
|
|
||||||
A more advanced alternative is mjpeg-streamer, which enables you to stream the camera in a browser. You can find a detailed tutorial how to set that up here.
|
|
32
txt.py
32
txt.py
|
@ -11,11 +11,17 @@ username = os.getlogin()
|
||||||
parser = argparse.ArgumentParser(description="Image Generation and Printing")
|
parser = argparse.ArgumentParser(description="Image Generation and Printing")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def camera():
|
def camera():
|
||||||
print("cam")
|
print("cam")
|
||||||
webcam_command = "fswebcam webcam.jpg ; /home/{username}/.local/bin/brother_ql -b pyusb -m QL-550 -p usb://0x04f9:0x2016 print -l 62 --dither webcam.jpg"
|
webcam_command = (
|
||||||
|
"fswebcam webcam.jpg ; "
|
||||||
|
"/home/{username}/.local/bin/brother_ql -b pyusb -m QL-550 "
|
||||||
|
"-p usb://0x04f9:0x2016 print -l 62 --dither webcam.jpg"
|
||||||
|
)
|
||||||
subprocess.run(webcam_command, shell=True)
|
subprocess.run(webcam_command, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def map_to_keyboard_hebrew(input_text):
|
def map_to_keyboard_hebrew(input_text):
|
||||||
keyboard_to_hebrew = {
|
keyboard_to_hebrew = {
|
||||||
't': 'א',
|
't': 'א',
|
||||||
|
@ -55,6 +61,7 @@ def map_to_keyboard_hebrew(input_text):
|
||||||
output_text = ''.join([keyboard_to_hebrew.get(char, char) for char in input_text.lower()])
|
output_text = ''.join([keyboard_to_hebrew.get(char, char) for char in input_text.lower()])
|
||||||
return output_text
|
return output_text
|
||||||
|
|
||||||
|
|
||||||
def rtl_text_wrap(text, width):
|
def rtl_text_wrap(text, width):
|
||||||
words = text.split()
|
words = text.split()
|
||||||
lines = []
|
lines = []
|
||||||
|
@ -77,12 +84,9 @@ def rtl_text_wrap(text, width):
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
user_input = input("Type something (or press + for camera): ")
|
user_input = input("Type something (or press + for camera): ")
|
||||||
if user_input =="+":
|
if user_input == "+":
|
||||||
camera()
|
camera()
|
||||||
elif user_input != "":
|
elif user_input != "":
|
||||||
img_width = 696
|
img_width = 696
|
||||||
|
@ -98,9 +102,9 @@ while True:
|
||||||
|
|
||||||
num_lines = wrapped_text.count('\n') + 1
|
num_lines = wrapped_text.count('\n') + 1
|
||||||
font_size = img_width // 6
|
font_size = img_width // 6
|
||||||
ttfont="5x5-Tami.ttf"
|
ttfont = "5x5-Tami.ttf"
|
||||||
ttfont="VarelaRound-Regular.ttf"
|
ttfont = "VarelaRound-Regular.ttf"
|
||||||
ttfont="fonts/xbmc-hebrew-fonts/Roboto-Bold-xbmc-il.ttf"
|
ttfont = "fonts/xbmc-hebrew-fonts/Roboto-Bold-xbmc-il.ttf"
|
||||||
font = ImageFont.truetype(ttfont, font_size)
|
font = ImageFont.truetype(ttfont, font_size)
|
||||||
line_height = font_size + 10
|
line_height = font_size + 10
|
||||||
img_height = num_lines * line_height + 200
|
img_height = num_lines * line_height + 200
|
||||||
|
@ -113,9 +117,11 @@ while True:
|
||||||
d.text((x, y), wrapped_text, font=font, fill=(0, 0, 0))
|
d.text((x, y), wrapped_text, font=font, fill=(0, 0, 0))
|
||||||
image.save("output.png")
|
image.save("output.png")
|
||||||
|
|
||||||
|
# Step 2: Print
|
||||||
printer_ql550="0x2016"
|
printer_ql550 = "0x2016"
|
||||||
printer_id1="000M6Z401370"
|
printer_id1 = "000M6Z401370"
|
||||||
command = f"/home/{username}/.local/bin/brother_ql -b pyusb --model QL-550 -p usb://0x04f9:{printer_ql550}/{printer_id1} print -l 62 output.png"
|
command = (
|
||||||
|
f"/home/{username}/.local/bin/brother_ql -b pyusb --model QL-550 "
|
||||||
|
f"-p usb://0x04f9:{printer_ql550}/{printer_id1} print -l 62 output.png"
|
||||||
|
)
|
||||||
subprocess.run(command, shell=True)
|
subprocess.run(command, shell=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user