Browse Source

add some diagrams, and the infrastructure to make them...

These will be integrated into the code shortly..
irr_shared
John-Mark Gurney 3 years ago
parent
commit
38510f74da
4 changed files with 99 additions and 0 deletions
  1. +16
    -0
      Makefile
  2. +3
    -0
      arch.getxt
  3. +74
    -0
      box.sh
  4. +6
    -0
      conns.getxt

+ 16
- 0
Makefile View File

@@ -210,3 +210,19 @@ init-$($(module)_NAME):
update-$($(module)_NAME): update-$($(module)_NAME):
git subtree pull -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH) git subtree pull -P $($(module)_NAME) --squash $($(module)_REPO) $($(module)_BRANCH)
.endfor .endfor

# Making diagrams, imported from fbsdembdev
# =========================================
# https://github.com/ironcamel/Graph-Easy

.SUFFIXES: .getxt .diag .html

.getxt.diag: box.sh
graph-easy < $< | sh $(.CURDIR)/box.sh > $@

.diag.html:
(cat $<; echo; echo '<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://casual-effects.com/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>') > $@

DIAG?=diag
test-diag:
ls $(.CURDIR)/box.sh $(.CURDIR)/$(DIAG).getxt $(.CURDIR)/Makefile | entr sh -c 'cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) $(DIAG).diag && cat $(MAKEOBJDIR)/$(DIAG).diag'

+ 3
- 0
arch.getxt View File

@@ -0,0 +1,3 @@
[ lora.py ] -- { label: multicast } [ loraserv.py ]
[ loraserv.py ] -- { label: "USB VCP" } [ lora.gw.elf\nmain.c ]
[ lora.gw.elf\nmain.c ] -- { label: LoRa } [ lora.irr.elf\nirr_main.c ]

+ 74
- 0
box.sh View File

@@ -0,0 +1,74 @@
#!/bin/sh
fname=$(mktemp foobar.XXXXX)
cat > "$fname"
awk '
maxline == 1 {
if (maxlength < length)
maxlength = length
}

function printtop () {
blank = sprintf("%*s", maxlength + 4, "")
gsub(" ", "*", blank)
printf("%s\n", blank)
}

function printline(a)
{
printf("* %s%*s *\n", a, maxlength - length(a), "")
}

# return the string a, with the character at pos, replaced with chr
function replace(a, pos, chr)
{
return substr(a, 1, pos - 1) chr substr(a, pos + 1)
}

output == 1 && FNR == 1 {
printtop()
printf("* %*s *\n", maxlength, "")

prevline = $0
next
}

output == 1 {
# fix up horizontal issues
gsub("\\|-", "+-", prevline)
gsub("\\| -", "+--", prevline)
gsub("-\\|", "-+", prevline)
gsub("- \\|", "--+", prevline)

# Fix up vertical issues

# first fix edges from below
r = split($0, a, "|")
pos = 0
for (i = 2; i <= r; i++) {
pos += length(a[i - 1]) + 1
if (substr(prevline, pos, 1) == "-")
prevline = replace(prevline, pos, "+")
}

# fix edges from above
r = split(prevline, a, "|")
pos = 0
for (i = 2; i <= r; i++) {
pos += length(a[i - 1]) + 1
if (substr($0, pos, 1) == "-")
$0 = replace($0, pos, "+")
}

printline(prevline)

prevline = $0
}

END {
printline(prevline)
printf("* %*s *\n", maxlength, "")
printtop()
}
' maxline=1 "$fname" maxline=0 output=1 "$fname"

rm "$fname"

+ 6
- 0
conns.getxt View File

@@ -0,0 +1,6 @@
[ 24V AC ] -- { label: "~/~" } [ AC-DC PS 5V ]
[ AC-DC PS 5V ] -- { label: GND } [ Relay ]
[ AC-DC PS 5V ] -- { label: "+5V -> JD-VCC" } [ Relay ]
[ AC-DC PS 5V ] -- { label: GND } [ Node151 ]
[ AC-DC PS 5V ] -- { label: "+5V -> VUSB" } [ Node151 ]
[ Node151 ] -- { label: GPIO } [ Relay ]

Loading…
Cancel
Save