Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 73e6d61

Browse files
committed
update
1 parent c11568b commit 73e6d61

4 files changed

Lines changed: 33 additions & 18 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"Nespresso's",
77
"Vertuo",
88
"Vertuoline",
9-
"barcodes"
9+
"barcodes",
10+
"nargs"
1011
]
1112
}

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ This project aims to decode and generate printable barcodes for the Nespresso's
55
1. Download the latest version of python [here](https://www.python.org/downloads/). Or at least have version 3.7 or greater.
66
2. Install Pillow through `pip install Pillow`
77

8-
### Helpful links
8+
# Usage
9+
This project has two scripts, the generator and printer.
10+
11+
## The generator
12+
The generator takes a simplified form of a pod's code called the ID to generate a code that can be passed to the printer. The ID has 4 segments of 1s and 0s, for example "1100 1101 0100 001101"
13+
14+
TODO: Example and table
15+
16+
## The printer
17+
The printer takes a code and turns it into a printable image. The code should be 140 characters consisting of only 1s and 0s.
18+
19+
```console
20+
> python printer.py 01110010110110010010001101010111001011010101000100110110011100011101100100010011010101110001110101010001001101010111000111010101001000110110
21+
22+
> python printer.py -o outputPath.png 01110010110110010010001101010111001011010101000100110110011100011101100100010011010101110001110101010001001101010111000111010101001000110110
23+
```
24+
25+
26+
# Helpful links
927
* https://www.reddit.com/r/nespresso/comments/d9xnv9/breaking_the_nespresso_vertuo_barcodes/
1028
* https://www.reddit.com/r/nespresso/comments/okc1vx/breaking_the_nespresso_vertuo_barcodes_part_2/

generator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
"""Used to generate a custom barcode.
1+
"""Used to generate a custom code.
22
3-
This Script is used to generate a custom code that can be passed to
3+
This script is used to generate a custom code that can be passed to
44
the printer script.
55
6-
Each code can be summarized in 4 segments, 3 four character segments and 1 six
6+
Each ID can be summarized in 4 segments, 3 four character segments and 1 six
77
character segment. For example "1100 1101 0100 001101"
88
"""
99

1010
import argparse
1111
from functools import partial
1212

1313
"""
14-
The four segments are repeated for times with different separators in
14+
The four segments are repeated four times with different separators in
1515
between. Though the separators are the same across pods.
1616
17-
for example, Melozio has the following code
17+
For example, Melozio has the following code
1818
1919
01 1100 10 1101 10 0100 10 010110 01
2020
01 1100 10 1101 01 0100 01 010110 10
@@ -24,15 +24,15 @@
2424
"""
2525

2626

27-
def _getCode() -> tuple[str, str, str, str]:
27+
def _getID() -> tuple[str, str, str, str]:
2828
"""Get the code from the user
2929
"""
3030

3131
parser = argparse.ArgumentParser(description="Generate a code to pass to the printer.") # noqa
3232
parser.add_argument(
33-
"code",
33+
"ID",
3434
nargs="+",
35-
help="The code to generate with. Formated like this, '1100 1101 0100 001101'"
35+
help="The ID to generate a code with. Formated like this, '1100 1101 0100 001101'" # noqa
3636
)
3737

3838
segments = parser.parse_args().code
@@ -69,7 +69,7 @@ def _getCode() -> tuple[str, str, str, str]:
6969

7070

7171
def main():
72-
seg1, seg2, seg3, seg4 = _getCode()
72+
seg1, seg2, seg3, seg4 = _getID()
7373

7474
formatter = "01{seg1}{sep1}{seg2}{sep2}{seg3}{sep3}{seg4}{sep4}"
7575
formatter = partial(

printer.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
from PIL import Image, ImageDraw
77

8-
TEST_CODE = "01110010110110010010001101010111001011010101000100110110011100011101100100010011010101110001110101010001001101010111000111010101001000110110" # noqa
9-
108
IMAGE_SIZE = 2400
119
POD_OUTER_DIA = 2.26
1210
POD_INNER_DIA = 2.02
@@ -47,12 +45,12 @@ def _getArgs() -> _PrinterArgs:
4745

4846
# verify the input code
4947
if len(args.code) != 140:
50-
print("The input code is not 140 character!")
48+
print("The code is not 140 character!")
5149
parser.exit()
5250
pass
5351

5452
if any(c not in "10" for c in args.code):
55-
print("The input code has invalid characters! It can only have 1s and 0s.")
53+
print("The code has invalid characters! It can only have 1s and 0s.")
5654
parser.exit()
5755
pass
5856

@@ -123,9 +121,7 @@ def main():
123121
)
124122
pass
125123

126-
with open(outputPath, mode="wb") as outFile:
127-
im.save(outFile, dpi=(DPI, DPI))
128-
pass
124+
im.save(outputPath)
129125
pass
130126
pass
131127

0 commit comments

Comments
 (0)