% signal=squid %D \module %D [ file=s-squid.mkxl, %D version2025.05.20, %D title=\CONTEXT\ Style File, %D subtitle=Squid Colors and Graphics, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \startmodule[squid] \pushoverloadmode \logo [PHILIPS] {Philips} \logo [PHOSCOM] {Phoscom} \logo [HUE] {hue} \logo [DECONZ] {deconz} \logo [CONBEE] {ConBee} \logo [EVOHOME] {EvoHome} \logo [WIFI] {WiFi} \logo [SQUID] {Squid} \logo [QRCODE] {QR\nbsp code} \logo [RASPBERRYPICO] {RPI Pico} \logo [ARDUINO] {Arduino} \popoverloadmode \definepalet [squid] [reset=black, busy=blue, done=yellow, finished=green, % problem=magenta, problem=orange, error=red] \startMPdefinitions vardef signal_led(expr n) = (0,100) rotated - ((n - 1) * (360/24)) enddef ; vardef signal_inner_led(expr n) = (0,75) rotated - ((n - 1) * (360/8)) enddef ; vardef signal_segment(expr n) = for i = (n - 1) * 3 + 1 upto n * 3 : signal_led(i) && endfor nocycle enddef ; vardef signal_segments(expr n) = for i = 1 upto (n - 1) * 3 + 3 : signal_led(i) && endfor nocycle enddef ; vardef signal_quadrant(expr n) = for i = (n - 1) * 6 + 1 upto n * 6 : signal_led(i) && endfor nocycle enddef ; vardef signal_quadrants(expr n) = for i = 1 upto n * 6 : signal_led(i) && endfor nocycle enddef ; vardef signal_leds = for i = 1 upto 24 : signal_led(i) && endfor nocycle enddef ; vardef signal_inner_leds = for i = 1 upto 8 : signal_inner_led(i) && endfor nocycle enddef ; vardef signal_range(expr n) = for i = 1 upto n : signal_led(i) && endfor nocycle enddef ; def signal_all_leds = drawdot signal_leds withpen pencircle scaled 20 withcolor .5white ; enddef ; def signal_all_inner_leds = drawdot signal_inner_leds withpen pencircle scaled 20 withcolor .5white ; enddef ; def signal_more_leds(expr n, c) = drawdot signal_range(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_one_segment(expr n, c) = drawdot signal_segment(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_more_segments(expr n, c) = drawdot signal_segments(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_one_quadrant(expr n, c) = drawdot signal_quadrant(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_more_quadrants(expr n, c) = drawdot signal_quadrants(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_one_led(expr n, c) = drawdot signal_led(n) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_one_thread(expr n, m, c) = drawdot signal_led((n-1)*3+m) withpen pencircle scaled 20 withcolor c ; enddef ; def signal_set_bounds = setbounds currentpicture to fullsquare scaled 200; enddef ; \stopMPdefinitions \startuniqueMPgraphic{signalled}{color} draw image ( drawdot signal_led(1) ) ysized (.6LineHeight) withcolor \MPvar{color} ; \stopuniqueMPgraphic \protected\def\SignalLed#1% {\hpack ymove -.3sd {\uniqueMPgraphic{signalled}{color=#1}}} \protected\def\SignalBusy {\SignalLed{squid:busy}} \protected\def\SignalDone {\SignalLed{squid:done}} \protected\def\SignalFinished{\SignalLed{squid:finished}} \protected\def\SignalProblem {\SignalLed{squid:problem}} \protected\def\SignalError {\SignalLed{squid:error}} \startbuffer[squid-001] \startcombination [nx=4,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(1, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 1 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(1, "squid:done"); signal_one_segment(2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 2 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(2, "squid:done"); signal_one_segment(3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 3 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(3, "squid:finished"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption okay \stopcaption \stopcombination \stopbuffer \startbuffer[squid-002] \startcombination [nx=1,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(1, "squid:error"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption error \stopcaption \stopcombination \stopbuffer \startbuffer[squid-003] \startcombination [nx=5,ny=2] \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(1, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 1 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(1, "squid:done"); signal_one_segment(2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 2 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(2, "squid:done"); signal_one_segment(3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 3 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(3, "squid:done"); signal_one_segment(4, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 4 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(4, "squid:done"); signal_one_segment(5, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 5 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(5, "squid:done"); signal_one_segment(6, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 6 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(6, "squid:done"); signal_one_segment(7, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 7 \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(7, "squid:done"); signal_one_segment(8, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 8 \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(7, "squid:done"); signal_one_segment(8, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 9 \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(8, "squid:problem"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption problem \stopcaption \stopcombination \stopbuffer \startbuffer[squid-004] \startcombination [nx=5,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(1, "squid:done"); signal_one_thread(1, 1, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption thread 1 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(2, "squid:done"); signal_one_thread(2, 2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption thread 2 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(3, "squid:done"); signal_one_thread(3, 1, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption thread 3 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(4, "squid:done"); signal_one_thread(4, 3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption thread 4 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_segment(5, "squid:done"); signal_one_thread(5, 3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption thread 5 \stopcaption \stopcombination \stopbuffer \startbuffer[squid-005] \startcombination [nx=5,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_more_segments(5, "squid:done"); signal_one_thread(1, 1, "squid:busy"); signal_one_thread(2, 2, "squid:busy"); signal_one_thread(3, 1, "squid:busy"); signal_one_thread(4, 3, "squid:busy"); signal_one_thread(5, 3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption 5 threads \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(8, "squid:done"); signal_one_thread(1, 1, "squid:busy"); signal_one_thread(2, 2, "squid:busy"); signal_one_thread(3, 1, "squid:busy"); signal_one_thread(4, 3, "squid:busy"); signal_one_thread(5, 3, "squid:busy"); signal_one_thread(6, 1, "squid:busy"); signal_one_thread(7, 2, "squid:busy"); signal_one_thread(8, 2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption 8 threads \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(8, red); signal_one_thread(1, 1, "squid:busy"); signal_one_thread(2, 2, "squid:busy"); signal_one_thread(3, 1, "squid:busy"); signal_one_thread(4, 3, "squid:busy"); signal_one_thread(5, 3, "squid:busy"); signal_one_thread(6, 1, "squid:busy"); signal_one_thread(7, 2, "squid:busy"); signal_one_thread(8, 2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption issues \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(8, "squid:finished"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption okay \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_segments(8, "squid:error"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption errors \stopcaption \stopcombination \stopbuffer \startbuffer[squid-006] \startcombination [nx=5,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_more_leds(6, "squid:done"); signal_one_led(7, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption page 7 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_leds(16, "squid:done"); signal_one_led(17, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption page 17 \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_leds(24, "squid:done"); signal_one_led(13, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption page 37 \stopcaption \startcontent \startMPcode draw image ( % signal_all_leds; signal_more_leds(24, "squid:finished"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption okay \stopcaption \stopcombination \stopbuffer \startbuffer[squid-007] \startcombination [nx=5,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; signal_one_quadrant(1, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 1 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_one_quadrant(1, "squid:done"); signal_one_quadrant(2, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 2 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_quadrants(2, "squid:done"); signal_one_quadrant(3, "squid:busy"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption run 3 \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_quadrants(3, "squid:finished"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption okay \stopcaption \startcontent \startMPcode draw image ( signal_all_leds; signal_more_quadrants(3, "squid:error"); ) ysized 20mm ; \stopMPcode \stopcontent \startcaption error \stopcaption \stopcombination \stopbuffer \startbuffer[squid-008] \startcombination [nx=1,ny=1] \startcontent \startMPcode draw image ( signal_all_leds; ) ysized 20mm ; \stopMPcode \stopcontent \startcaption leds \stopcaption \stopcombination \stopbuffer \startMPdefinitions def signal_text(expr s) = signal_all_leds; % signal_all_inner_leds; for i=1 upto 24 : if (substring(i-1,i) of s) == "+" : signal_one_led(i,"squid:busy"); elseif (substring(i-1,i) of s) == "!" : signal_one_led(i,"squid:problem"); fi ; endfor ; enddef ; string characters[]; characters[ASCII "A"] := "+++++!!+++-----+++!!++++" ; characters[ASCII "B"] := "------------------------" ; characters[ASCII "C"] := "+++------+++++++++++++++" ; characters[ASCII "D"] := "------------------------" ; characters[ASCII "E"] := "++---!!!---++++++!!!++++" ; characters[ASCII "F"] := "------------------------" ; characters[ASCII "G"] := "------------------------" ; characters[ASCII "H"] := "------------------------" ; characters[ASCII "I"] := "+++++++++++++-----------" ; characters[ASCII "J"] := "++++++++++++++++--------" ; characters[ASCII "K"] := "------------------------" ; characters[ASCII "L"] := "+--------+++++++++++++++" ; characters[ASCII "M"] := "!!++++++++-!!!-++++++++!" ; characters[ASCII "N"] := "++++++++++-----+++++++++" ; characters[ASCII "O"] := "++++++++++++++++++++++++" ; characters[ASCII "P"] := "------------------------" ; characters[ASCII "Q"] := "------------------------" ; characters[ASCII "R"] := "------------------------" ; characters[ASCII "S"] := "------------------------" ; characters[ASCII "T"] := "!!+++------!!!------+++!" ; characters[ASCII "U"] := "------------------------" ; characters[ASCII "V"] := "------------------------" ; characters[ASCII "W"] := "------------------------" ; characters[ASCII "X"] := "-+++-----+++--+++----+++" ; characters[ASCII "Y"] := "------------------------" ; characters[ASCII "Z"] := "------------------------" ; vardef signal_character(expr c) = image ( signal_text(characters[if string c : ASCII c else : c fi]) ) enddef ; \stopMPdefinitions \startbuffer[squid-009] \startMPcode numeric n ; n := 0; for i = (ASCII "A") upto (ASCII "Z") : pair a ; a := ((n mod 6) * 25mm, -(n div 6) * 25mm) ; n := n + 1 ; draw signal_character(i) ysized 20mm shifted a ; draw textext (char i) shifted a ; endfor ; \stopMPcode \stopbuffer \startbuffer[squid-010] \startMPcode draw signal_character("C") xsized 15mm shifted (0 * 17.5mm,0) ; draw signal_character("O") xsized 15mm shifted (1 * 17.5mm,0) ; draw signal_character("N") xsized 15mm shifted (2 * 17.5mm,0) ; draw signal_character("T") xsized 15mm shifted (3 * 17.5mm,0) ; draw signal_character("E") xsized 15mm shifted (4 * 17.5mm,0) ; draw signal_character("X") xsized 15mm shifted (5 * 17.5mm,0) ; draw signal_character("T") xsized 15mm shifted (6 * 17.5mm,0) ; \stopMPcode \stopbuffer \continueifinputfile{s-squid.mkxl} \starttext \startTEXpage\getbuffer[squid-001]\stopTEXpage \startTEXpage\getbuffer[squid-002]\stopTEXpage \startTEXpage\getbuffer[squid-003]\stopTEXpage \startTEXpage\getbuffer[squid-004]\stopTEXpage \startTEXpage\getbuffer[squid-005]\stopTEXpage \startTEXpage\getbuffer[squid-006]\stopTEXpage \startTEXpage\getbuffer[squid-007]\stopTEXpage \startTEXpage\getbuffer[squid-008]\stopTEXpage \startTEXpage\getbuffer[squid-009]\stopTEXpage \startTEXpage\getbuffer[squid-010]\stopTEXpage \stoptext \stopmodule