From 7f376f46d680b9bb3ab4665344c6f2cb3f4cdc03 Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 7 Dec 2023 14:31:15 +0100 Subject: Build WIP --- 8seg_digit_circuit.svg | 1065 ++++++++++++++++++++++++++++++++++++ 8seg_strand_power_distribution.svg | 500 +++++++++++++++++ center_fw/src/main.c | 2 +- led_tape.svg | 48 +- len_map.py | 96 ++++ 5 files changed, 1687 insertions(+), 24 deletions(-) create mode 100644 8seg_digit_circuit.svg create mode 100644 8seg_strand_power_distribution.svg create mode 100644 len_map.py diff --git a/8seg_digit_circuit.svg b/8seg_digit_circuit.svg new file mode 100644 index 0000000..f67610d --- /dev/null +++ b/8seg_digit_circuit.svg @@ -0,0 +1,1065 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LED Tape segments + l = 100.0 - 2*3.0 = 94 cm + l = 130 - 2*3.0 = 124 cm + l = 82 - 2.0 = 80 cm + + + + Horizontal (H) + Vertical (V) + Diagonal (D) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Rev R07" + "Rev R07" + + + + + + + + " Up " + + + + "[URL]" + "[URL]" + 0 x + 0 x + 6 x + Cut patterns + 1 x + 3 x + 0 x + 3 x + 1 x + 1 x + + diff --git a/8seg_strand_power_distribution.svg b/8seg_strand_power_distribution.svg new file mode 100644 index 0000000..abbbb7e --- /dev/null +++ b/8seg_strand_power_distribution.svg @@ -0,0 +1,500 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + + + 0.2 m + 0.4 + 1.0 + 0.3 m = 1.7 m + 0.4 + 1.0 + 0.4 + 1.0 + 0.1 + 0.2 + 0.2 m = 3.3 m + + + + + + + + + + + Splitter "A" side is cable red side + Left (short) stub: Terminal block right side is cable red side + Right (long) stub: Terminal block left side is cable red side + + diff --git a/center_fw/src/main.c b/center_fw/src/main.c index c066297..8c91607 100644 --- a/center_fw/src/main.c +++ b/center_fw/src/main.c @@ -209,7 +209,7 @@ void ADC1_IRQHandler(void) { /* Read sample and apply threshold */ int sample = ADC1->DR; /* resets the EOC interrupt flag */ - int bit = sample > THRESHOLD_ADC_COUNTS; + int bit = sample < THRESHOLD_ADC_COUNTS; int bit_margin = ((int)sample) - THRESHOLD_ADC_COUNTS; if (bit_margin < 0) { bit_margin = -bit_margin; diff --git a/led_tape.svg b/led_tape.svg index 6999959..3d7796f 100644 --- a/led_tape.svg +++ b/led_tape.svg @@ -2,21 +2,21 @@ + inkscape:version="1.3 (0e150ed6c4, 2023-07-21)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> @@ -25,7 +25,6 @@ image/svg+xml - @@ -40,15 +39,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1030" + inkscape:window-width="3208" + inkscape:window-height="1981" id="namedview4" showgrid="false" - inkscape:zoom="0.99999999" - inkscape:cx="119.84761" - inkscape:cy="40.617263" - inkscape:window-x="0" - inkscape:window-y="50" + inkscape:zoom="0.12102105" + inkscape:cx="-1222.9277" + inkscape:cy="-1739.3668" + inkscape:window-x="26" + inkscape:window-y="23" inkscape:window-maximized="0" inkscape:current-layer="svg2" inkscape:measure-start="288.323,-37.2999" @@ -59,27 +58,30 @@ fit-margin-right="0" fit-margin-bottom="0" inkscape:document-units="mm" - inkscape:snap-global="false" /> + inkscape:snap-global="false" + inkscape:showpageshadow="2" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" /> + transform="matrix(1.5310128,0,0,1.6910455,-1737.4329,315.54284)" + style="fill:none;stroke:#bfbfbf;stroke-width:20.6453;stroke-miterlimit:4;stroke-dasharray:none"> + style="fill:none;fill-rule:evenodd;stroke:#bfbfbf;stroke-width:20.6453;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + style="fill:none;fill-rule:evenodd;stroke:#bfbfbf;stroke-width:20.6453;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + style="fill:none;fill-rule:evenodd;stroke:#bfbfbf;stroke-width:20.6453;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> remainder {l_rem_k}') + candidates.append((i, j, k)) +candidates = np.array(candidates, dtype=int) +print() + +# Find all ways to combine the cuts found above to cut [num_rolls] into segments, where the amount of segments of length +# [a], [b], and [c] that we get in total best matches the proportions we need ([n] times [a], [m] times [b], [l] times +# [c], so 2:2:4 times for 94:124:80 cm) +num_rolls = 3 +indices_seen = set() +out = [] +for indices in itertools.product(candidates, repeat=num_rolls): + indices = np.array(indices) + index_tup = tuple(sorted(map(tuple, indices))) + if index_tup in indices_seen: + continue + indices_seen.add(index_tup) + rem = l_tot - (indices * arr).sum(axis=1) + rem_total = rem.sum() + count_total = indices.sum(axis=0).astype(float) + count_total /= arr_count + spread = count_total.max() - count_total.min() + + if spread > 2 or (rem < 2).any(): + continue + print(indices.tolist(), f'{rem_total=} {spread=}') + out.append((spread, rem_total, indices.tolist(), rem.tolist(), indices.sum(axis=0).tolist())) +print() + +# Print out the n best matches found. Sort first by how close we match our target 2:2:4 ratio, then by how much waste +# we leave. +print('Best matches:') +for spread, rem_total, indices, rem, index_sum in sorted(out, key=lambda x: (x[0], x[1]))[:25]: + print(indices, f'{spread=} {rem_total=} {rem=} {index_sum=}') + +# Here's the output for future reference. There are a number of combinations that produce 68 cm of waste split across +# three 5m rolls of tape. We selected # 1 since it leaves leftovers of useful lengths. +# +# Best matches: +# [[0, 0, 6], [0, 4, 0], [4, 0, 1]] spread=0.25 rem_total=68 rem=[20, 4, 44] index_sum=[4, 4, 7] +# [[0, 0, 6], [1, 3, 0], [3, 1, 1]] spread=0.25 rem_total=68 rem=[20, 34, 14] index_sum=[4, 4, 7] +# [[0, 2, 3], [0, 2, 3], [4, 0, 1]] spread=0.25 rem_total=68 rem=[12, 12, 44] index_sum=[4, 4, 7] +# [[0, 2, 3], [1, 1, 3], [3, 1, 1]] spread=0.25 rem_total=68 rem=[12, 42, 14] index_sum=[4, 4, 7] +# [[0, 2, 3], [2, 1, 2], [2, 1, 2]] spread=0.25 rem_total=68 rem=[12, 28, 28] index_sum=[4, 4, 7] +# [[0, 3, 1], [1, 0, 5], [3, 1, 1]] spread=0.25 rem_total=68 rem=[48, 6, 14] index_sum=[4, 4, 7] +# [[0, 4, 0], [1, 0, 5], [3, 0, 2]] spread=0.25 rem_total=68 rem=[4, 6, 58] index_sum=[4, 4, 7] +# [[1, 0, 5], [1, 3, 0], [2, 1, 2]] spread=0.25 rem_total=68 rem=[6, 34, 28] index_sum=[4, 4, 7] +# [[0, 0, 6], [0, 3, 1], [3, 1, 1]] spread=0.5 rem_total=82 rem=[20, 48, 14] index_sum=[3, 4, 8] +# [[0, 0, 6], [0, 4, 0], [3, 0, 2]] spread=0.5 rem_total=82 rem=[20, 4, 58] index_sum=[3, 4, 8] +# [[0, 0, 6], [1, 3, 0], [2, 1, 2]] spread=0.5 rem_total=82 rem=[20, 34, 28] index_sum=[3, 4, 8] +# [[0, 1, 4], [0, 2, 3], [3, 1, 1]] spread=0.5 rem_total=82 rem=[56, 12, 14] index_sum=[3, 4, 8] +# [[0, 2, 3], [0, 2, 3], [3, 0, 2]] spread=0.5 rem_total=82 rem=[12, 12, 58] index_sum=[3, 4, 8] +# [[0, 2, 3], [1, 0, 5], [2, 2, 0]] spread=0.5 rem_total=82 rem=[12, 6, 64] index_sum=[3, 4, 8] +# [[0, 2, 3], [1, 1, 3], [2, 1, 2]] spread=0.5 rem_total=82 rem=[12, 42, 28] index_sum=[3, 4, 8] +# [[0, 3, 1], [1, 0, 5], [2, 1, 2]] spread=0.5 rem_total=82 rem=[48, 6, 28] index_sum=[3, 4, 8] +# [[0, 4, 0], [1, 0, 5], [2, 0, 3]] spread=0.5 rem_total=82 rem=[4, 6, 72] index_sum=[3, 4, 8] +# [[1, 0, 5], [1, 1, 3], [1, 3, 0]] spread=0.5 rem_total=82 rem=[6, 42, 34] index_sum=[3, 4, 8] +# [[0, 0, 6], [0, 3, 1], [4, 0, 1]] spread=0.5 rem_total=112 rem=[20, 48, 44] index_sum=[4, 3, 8] +# [[0, 0, 6], [1, 2, 1], [3, 1, 1]] spread=0.5 rem_total=112 rem=[20, 78, 14] index_sum=[4, 3, 8] +# [[0, 0, 6], [1, 3, 0], [3, 0, 2]] spread=0.5 rem_total=112 rem=[20, 34, 58] index_sum=[4, 3, 8] +# [[0, 0, 6], [2, 1, 2], [2, 2, 0]] spread=0.5 rem_total=112 rem=[20, 28, 64] index_sum=[4, 3, 8] +# [[0, 1, 4], [0, 2, 3], [4, 0, 1]] spread=0.5 rem_total=112 rem=[56, 12, 44] index_sum=[4, 3, 8] +# [[0, 1, 4], [1, 1, 3], [3, 1, 1]] spread=0.5 rem_total=112 rem=[56, 42, 14] index_sum=[4, 3, 8] +# [[0, 1, 4], [2, 1, 2], [2, 1, 2]] spread=0.5 rem_total=112 rem=[56, 28, 28] index_sum=[4, 3, 8] + -- cgit