-
Notifications
You must be signed in to change notification settings - Fork 9
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
Device dependent margins/config #54
Merged
maresb
merged 27 commits into
labelle-org:develop
from
FaBjE:feature/deviceDependentMargins
Jul 4, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d73626d
Add "DYMO LabelMANAGER PC II" device ID
FaBjE 06f61ea
Add 24mm tape type
FaBjE 3aecdc7
device specific init WIP
FaBjE 1872e40
Add DeviceConfig class for each printer
FaBjE 1b279b3
Please mypy...
FaBjE 2353512
Fix usb device recognition
FaBjE dcc6234
Calculate margins instead of using lookup table
FaBjE 040f2c2
Force sending an "exact printhead width" bitmap to the printer
FaBjE f907b8b
Fix config not updated when device set
FaBjE d64c977
Tested on LabelManager PnP
FaBjE a7def5e
replace all camels with snakes
FaBjE d8dcb3d
Cleanup supported device list syntax
FaBjE 4fc8b68
Convert device config to dataclass
FaBjE 1d36049
Convert labeler device-config to property
FaBjE d8b3b6d
Move get_tape_print_size_and_margins_px to labeler class tape_print_p…
FaBjE 13fa9b9
Revert GUI supported_tape_sizes type
FaBjE 424ec34
Remove fixed default tapesize (take highest supported as default)
FaBjE d342a04
Shorten matches_device_id function
FaBjE 1786928
Fix code convention in if statement
FaBjE 16d82e8
Shorten if statement
FaBjE e239867
Shorten if statement
FaBjE b390217
Let get_device_config_by_id raise exception if not supported
FaBjE 0bdf8fd
Remove var / shorten line
FaBjE a4ed930
fix comment
FaBjE fdf3538
Clear up comment block
FaBjE 0fa7ad5
Fix wrong var name
FaBjE 7246473
Remove constant DPI values and calculations
FaBjE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from dataclasses import dataclass | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
@dataclass | ||
class DeviceConfig: | ||
"""Configuration object for the capabilities of a label printer.""" | ||
|
||
name: str | ||
"""Name of this device""" | ||
|
||
device_ids: list[int] | ||
"""List of USB Device ID's this device can identify as""" | ||
|
||
print_head_px: int | ||
"""Size of the print head in pixels (use calibration routine to determine)""" | ||
|
||
print_head_mm: float | ||
"""Size of the active area of the print head in millimters | ||
(use calibration routine to determine)""" | ||
|
||
supported_tape_sizes_mm: list[int] | ||
"""List of supported tape sizes in mm""" | ||
|
||
tape_alignment_inaccuracy_mm: float = 1.0 | ||
"""The inaccuracy of the tape position relative to the printhead | ||
Inaccuracy of the tape position is mostly caused by | ||
the tape moving slightly from side to side in the cartridge. | ||
Improper cartrigde placemement is also an factor, | ||
but negligible due to a physical spring in the lid. | ||
""" | ||
|
||
LABELER_DISTANCE_BETWEEN_PRINT_HEAD_AND_CUTTER_MM: float = 8.1 | ||
"""This is the distance between the printhead and the cutter (knife). | ||
""" | ||
|
||
def matches_device_id(self, device_id: int) -> bool: | ||
"""Check if the a device ID matches this config.""" | ||
return device_id in self.device_ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed? In case the list is constant, it would be better as a convention to prefer tuple over list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The amount of supported tape sizes varies from printer to printer. I got an error that I tried to change the "tuple" size. A quick google search gave this as a solution. If there is a better solution please elaborate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, tuples are "immutable" so you should always generate a new one instead of modifying an old one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (It didn´t complain this time)
Edit:
Sorry, had to revert this: