The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Author: Ed

  • Kenmore 158 UI: Automatic Button Builder

    Given the glacially slow Arduino touch-screen TFT display as a first pass UI for the Kenmore 158 sewing machine, I need some UI elements.

    I need buttons. Lots of buttons.

    Each button will have several different states that must be visually distinct:

    • Disabled – not available for pressing
    • Released – can be pressed and is inactive
    • Pressed – has been pressed and is now active

    There may be other states, but those should be enough to get started.

    I’d rather not draw that detail by hand for each button, so some tinkering with the Bash script driving the Imagemagick routines produced these results:

    Buttons
    Buttons

    Aren’t those just the ugliest buttons you’ve ever seen?

    The garish colors identify different functions, the crude shading does a (rather poor) job of identifying the states, and the text & glyphs should be unambiguous in context. Obviously, there’s room for improvement.

    The point is that I can begin building the UI code that will slap those bitmaps on the Arduino’s touch-panel LCD while responding to touches, then come back and prettify the buttons as needed. With a bit of attention to detail, I should be able to re-skin the entire UI without building the data into the Arduino sketch, but I’ll start crude.

    The mkAll.sh script that defines the button characteristics and calls the generator script:

    ./mkBFam.sh NdDn springgreen4 ⤓
    ./mkBFam.sh NdUp springgreen4 ⤒
    ./mkBFam.sh NdAny springgreen4 ⟳ 80 80 40
    ./mkBFam.sh PdOne sienna One 120 80
    ./mkBFam.sh PdFol sienna Follow 120 80
    ./mkBFam.sh PdRun sienna Run 120 80
    ./mkBFam.sh SpMax maroon1  🏃 80 80 40
    ./mkBFam.sh SpMed maroon2  🐇 80 80 40
    ./mkBFam.sh SpLow maroon3  🐌
    montage *bmp -tile 3x -geometry +2+2 Buttons.png
    display Buttons.png
    

    As before, if you don’t see rabbit and snail glyphs, then your fonts don’t cover those Unicode blocks.

    The quick-and-dirty mkBFam.sh script that produces three related buttons for each set of parameters:

    # create family of simple beveled buttons
    # Ed Nisley - KE4ZNU
    # January 2015
    
    [ -z $1 ] && FN=Test || FN=$1
    [ -z $2 ] && CLR=red || CLR=$2
    [ -z $3 ] && TXT=x   || TXT=$3
    [ -z $4 ] && SX=80   || SX=$4
    [ -z $5 ] && SY=80   || SY=$5
    [ -z $6 ] && PT=25   || PT=$6
    [ -z $7 ] && BDR=10  || BDR=$7
    
    echo fn=$FN clr=$CLR txt=$TXT sx=$SX sy=$SY pt=$PT bdr=$BDR
    
    echo Working ...
    
    echo Shape
    convert -size ${SX}x${SY} xc:none \
    -fill $CLR -draw "roundrectangle $BDR,$BDR $((SX-BDR)),$((SY-BDR)) $((BDR-2)),$((BDR-2))" \
    ${FN}_s.png
    
    echo Highlights
    convert ${FN}_s.png \
      \( +clone -alpha extract -blur 0x12 -shade 110x2 \
      -normalize -sigmoidal-contrast 16,60% -evaluate multiply .5\
      -roll +4+8 +clone -compose Screen -composite \) \
      -compose In  -composite \
      ${FN}_h.png
    
    convert ${FN}_s.png \
      \( +clone -alpha extract -blur 0x12 -shade 110x0 \
      -normalize -sigmoidal-contrast 16,60% -evaluate multiply .5\
      -roll +4+8 +clone -flip -flop -compose Screen -composite \) \
      -compose In  -composite \
      ${FN}_l.png
    
    echo Borders
    convert ${FN}_h.png \
      \( +clone -alpha extract  -blur 0x2 -shade 0x90 -normalize \
      -blur 0x2  +level 60,100%  -alpha On \) \
      -compose Multiply -composite \
       ${FN}_bh.png
    
    convert ${FN}_l.png \
      \( +clone -alpha extract  -blur 0x2 -shade 0x90 -normalize \
      -blur 0x2  +level 60,100%  -alpha On \) \
      -compose Multiply -composite \
       ${FN}_bl.png
    
    echo Buttons
    convert ${FN}_s.png \
      -font /usr/share/fonts/custom/Symbola.ttf  -pointsize ${PT}  -fill black  -stroke black \
      -gravity Center  -annotate 0 "${TXT}"  -trim -repage 0x0+7+7 \
      \( +clone -background navy -shadow 80x4+4+4 \) +swap \
      -background snow4  -flatten \
      ${FN}0.png
    
    convert ${FN}_bl.png \
      -font /usr/share/fonts/custom/Symbola.ttf  -pointsize ${PT}  -fill black  -stroke black \
      -gravity Center  -annotate 0 "${TXT}"  -trim -repage 0x0+7+7 \
      \( +clone -background navy -shadow 80x4+4+4 -flip -flop \) +swap \
      -background snow4  -flatten \
      ${FN}1.png
    
    convert ${FN}_bh.png \
      -font /usr/share/fonts/custom/Symbola.ttf  -pointsize $PT  -fill black  -stroke black \
      -gravity Center  -annotate 0 "${TXT}"  -trim -repage 0x0+7+7 \
      \( +clone -background navy -shadow 80x4+4+4 \) +swap \
      -background snow4  -flatten \
      ${FN}2.png
    
    echo BMPs
    for ((i=0 ; i <= 2 ; i++))
    do
     convert ${FN}${i}.png -type truecolor ${FN}${i}.bmp
    # display -resize 300% ${FN}${i}.bmp
    done
    
    echo Done!
    

    Now, to get those bitmaps from the SD card into the proper place on the LCD panel…

  • Monthly Image: Spherometer Measurements

    Our Larval Engineer volunteered to convert the lens from a defunct magnifying desk lamp into a hand-held magnifier; there’s more to that story than is relevant here. I bulldozed her into making a solid model of the lens before starting on the hand-holdable design, thus providing a Thing to contemplate while working out the holder details.

    That justified excavating a spherometer from the heap to determine the radius of curvature for the lens:

    Student Sphereometer on lens
    Student Sphereometer on lens

    You must know either the average radius / diameter of the pins or the average pin-to-pin distance. We used a quick-and-dirty measurement for the radius, but after things settled down, I used a slightly more rigorous approach. Spotting the pins on carbon paper (!) produced these numbers:

    Sphereometer Pin Radii
    Sphereometer Pin Radii

    The vertical scale has hard-metric divisions: 1 mm on the post and 0.01 on the dial. You’d therefore expect the pins to be a hard metric distance apart, but the 25.28 mm average radius suggests a crappy hard-inch layout. It was, of course, a long-ago surplus find without provenance.

    The 43.91 mm average pin-to-pin distance works out to a 50.7 mm bolt circle diameter = 25.35 mm radius, which is kinda-sorta close to the 25.28 mm average radius. I suppose averaging the averages would slightly improve things, but …

    The vertical distance for the lens in question was 0.90 mm, at least for our purposes. That’s the sagitta, which sounds cool enough to justify this whole exercise right there. It’s 100 mm in diameter and the ground edge is 2.8 mm thick, although the latter is subject to some debate.

    Using the BCD, the chord equation applies:

    • Height m = 0.90 mm
    • Base c = 50.7 mm
    • Lens radius r = (m2 + c2/4) / 2m = 357.46 mm

    Using the pin-to-pin distance, the spherometer equation applies:

    • Pin-to-pin a = 43.91 mm
    • Sagitta h = 0.90 mm
    • Lens radius R = (h/2) + (a2 / 6h) = 357.50 mm

    Close enough, methinks.

    Solving the chord equation for the total height of each convex side above the edge:

    • Base c = 100 mm
    • Lens radius r = 357.5 mm
    • Height m = r – sqrt(r2 -c2/4) = 3.5 mm

    So the whole lens should be 2 · 3.5 + 2.8 = 9.8 mm thick. It’s actually 10.15 mm, which says they were probably trying for 10.0 mm and I’m measuring the edge thickness wrong.

    She submitted to all this nonsense with good grace and cooked up an OpenSCAD model that prints the “lens” in two halves:

    Printed Lens - halves on platform
    Printed Lens – halves on platform

    Alas, those thin flanges have too little area on the platform to resist the contraction of the plastic above, so they didn’t fit together very well at all:

    Printed Lens - base distortion
    Printed Lens – base distortion

    We figured a large brim would solve that problem, but then it was time for her to return to the hot, fast core of college life…

  • Kenmore 158: Useful Unicode Glyphs

    It turns out, for some reasons that aren’t relevant here, that I’ll be using the Adafruit Arduino LCD panel for the sewing machine control panel, at least to get started. In mulling that over, the notion of putting text on the buttons suggests using getting simple pictures with Unicode characters.

    Herewith, some that may prove useful:

    • Needle stop up: ↥ = U+21A5
    • Needle stop up: ⤒=U+2912
    • Needle stop down: ⤓ = U+2913
    • Needle stop any: ↕ = U+2195
    • Needle stop any: ⟳ = U+27F3
    • Needle stop any: ⇅ = U+21C5
    • Rapid speed: ⛷ = U+26F7 (skier)
    • Rapid speed: 🐇  = U+1F407 (rabbit)
    • Slow speed: 🐢 = U+1F422 (turtle)
    • Dead slow: 🐌 = U+1F40C (snail)
    • Maximum speed: 🏃 = U+1F3C3 (runner)
    • Bobbin: ⛀ = U+26C0 (white draughts man)
    • Bobbin: ⛂ = U+26C2 (black draughts man)
    • Bobbin winding: 🍥 = U+1F365 (fish cake with swirl)

    Of course, displaying those characters require a font with deep Unicode support, which may explain why your browser renders them as gibberish / open blocks / whatever. The speed glyphs look great on the Unicode table, but none of the fonts around here support them; I’m using the Droid font family to no avail.

    Blocks of interest:

    The links in the fileformat.info table of Unicode blocks lead to font coverage reports, but I don’t know how fonts get into those reports. The report for the Miscellaneous Symbols block suggested the Symbola font would work and a test with LibreOffice show it does:

    Symbola font test
    Symbola font test

    An all-in-one-page Unicode symbol display can lock up your browser hard while rendering a new page.

    Unicode is weird

  • 3D Printed Handcuffs

    A friend who read about my chain mail armor asked about handcuffs, so I ran off one of gianteye’s Printable Handcuffs V1.0:

    3D Printed Handcuff
    3D Printed Handcuff

    Alas, that shows the difficulty of using an STL file designed for a different printer, as the interlocking parts didn’t even come close to fitting and required major abrasive adjustment with a Dremel. One of the few successful prints reported on Thingiverse seems involve a commercial printer, so it’s not just the M2’s problem.

    I’m not sufficiently motivated to conjure an OpenSCAD model right now…

  • 3D Printed Chain Mail Armor – Zombie Hunter Edition

    Reducing the link bars to 4×4 threads produced a diminutive patch:

    Square Armor - small links - platform
    Square Armor – small links – platform

    Most of the dark smudges come from optical effects in the natural PLA filament, but the second-from-upper-left armor button contains a dollop of black PLA left in the nozzle from the end of that spool; running meters and meters of filament through the extruder isn’t enough to clean the interior. I now have some filament intended to clean the extruder, but it arrived after the black ran out.

    Comparing the patch with the original buttons shows the size difference:

    Square Armor - large vs small links
    Square Armor – large vs small links

    A trial fit suggested a 5×5 patch would fit better, so …

    Square Armor - small links - mounted
    Square Armor – small links – mounted

    The whip stitching accentuates the jacket’s style.  We I think a glittery piping cord square around the armor links would spiff it up enormously and hide the open links, but that’s in the nature of fine tuning.

    I’ll eventually see what happens with 3×3 thread = 1.2×0.6 mm links, which may be too small for reliable bridging and too delicate for anything other the finest evening wear.

  • The Bigger the Blob, the Better the Job

    Found outside the local Kohl’s department store:

    Welded hand rail joint
    Welded hand rail joint

    In all fairness, I don’t know how you’d weld a decent joint in a situation like that, without far more prep work than seems appropriate. There’s not much metal in those tubes for proper grinding and fishmouthing.

    The handrail may not be long for this world: the bottom few inches of many posts have corroded to the vanishing point due all the salt applied to the pavement…

  • Bad Batteries Are Bad: Cold Weather Edition

    So we took an out-and-back walk across the Walkway Over the Hudson, after which I spotted this amusing sight:

    Parking Meter - empty battery box
    Parking Meter – empty battery box

    The horrible color balance comes from using a preset tuned for the M2’s new LED lights, rather than letting the camera figure things out on its own, then fighting it down after cropping.

    Anyhow, we did a bit over two miles of walking with outdoor temperature just over freezing. The camera lives in the left cargo pocket of my pants and the spare NB-5L battery in the camera case faces outward. Neither battery would power the camera at ambient temperature; evidently, being that cold reduced their output voltage below the level that the camera would accept.

    With a cold battery, the camera grunted, displayed a message about replacing the battery, and promptly shut itself off. Warming one of the batteries boosted its terminal voltage enough to take the picture, which accounts for not getting the proper color balance: I was fully occupied just getting the camera working.

    Back home and warmed up, the camera said both batteries were fully charged. They came from the BNF27 lot that produced low terminal voltages, so I’ll reserve them for warmer weather and use the BNI13 lot during the next few months.