// fork from tw:ina_ani:arduino-nano
!blabel = \(pos,style,s,w)
  if(s != "")
    lw(0.3)
      scale(w/13,1/10)
        ss("transparent")
          fs((style(pos))(1))
            rotate(1/4)
              apoly(4,0.3)
    scale(0.08)
      scale(0.5)
        fs((style(pos))(0))
          text(s)
!label = \(pos,style,s)
  blabel(pos,style,s,1.5)
!mlabel = \(pos,style,s)
  blabel(pos,style,s,3)
!llabel = \(pos,style,s)
  blabel(pos,style,s,5)

!blabel5 = \(dir, s,s1,s2,s3,s4,s5,s6,s7)
    shift(dir*-0.15,0)
      lw(3)
        ss("#ffd")
          scale(0.04)
            circle()
    shift(0, 0)
        label(0,s,s1)
        shift(dir*0.12, 0)
          mlabel(1,s,s2)
        shift(dir*0.27, 0)
          mlabel(2,s,s3)
        shift(dir*0.47, 0)
          llabel(3,s,s4)
        shift(dir*0.67, 0)
          mlabel(4,s,s5)
        shift(dir*0.85, 0)
          mlabel(5,s,s6)
        shift(dir*1.05, 0)
          llabel(6,s,s7)
!label5 = \(s, s1,s2,s3,s4,s5,s6,s7)
  blabel5(-1, s,s1,s2,s3,s4,s5,s6,s7)
!label5r = \(s,s1,s2,s3,s4,s5,s6,s7)
  blabel5(1, s,s1,s2,s3,s4,s5,s6,s7)

!choice = \(n)
  evalExtArg(n)
!aStyle = \(n)
  choice(n)
    "black"
    "#fdf"
!nullStyle = \(n)
  choice(n)
    "black"
    "white"
!pinStyle = \(n)
  choice(n)
    "white"
    "gray"
!regStyle = \(n)
  choice(n)
    "black"
    "orange"
!purStyle = \(n)
  choice(n)
    "black"
    "#0F0"
!intStyle = \(n)
  choice(n)
    "red"
    "#fdd"
!spiStyle = \(n)
  choice(n)
    "white"
    "#33f"
!i2cStyle = \(n)
  choice(n)
    "black"
    "#dd3"
!gndStyle = \(n)
  choice(n)
    "white"
    "black"
!vccStyle = \(n)
  choice(n)
    "white"
    "red"
!rStyle = \(n)
  choice(n)
    "white"
    "#66f"
!theme1 = \(n)
  choice(n)
    pinStyle
    regStyle
    purStyle
    intStyle
    purStyle
    aStyle
    rStyle
!themeGnd = \(n)
  choice(n)
    pinStyle
    gndStyle
    nullStyle
    nullStyle
    nullStyle
    aStyle
    rStyle
!themeVcc = \(n)
  choice(n)
    pinStyle
    vccStyle
    nullStyle
    nullStyle
    nullStyle
    aStyle
    rStyle
!themeSpi = \(n)
  choice(n)
    pinStyle
    regStyle
    purStyle
    intStyle
    spiStyle
    aStyle
    rStyle
!themeI2c = \(n)
  choice(n)
    pinStyle
    regStyle
    purStyle
    intStyle
    i2cStyle
    aStyle
    rStyle

scale(0.5)
 font("RoundM+")
  // GRID
  lw(0.1)
    fig()
      xy0(0,-2)
      xy(0,3)
      xy0(-3,0)
      xy(3,0)

  scale(0.7,1.7)
    fs("#39a")
      rect() // edge
  fs("black")
    shift(0,-0.8)
     scale(0.07)
       fs("white")
        text("Arduino Nano")
  shift(0, 0.8)
    scale(0.3,0.3)
      fs("#ddd")
        rect()
      fs("black")
        scale(0.2)
         text("USB")
  scale(0.3,0.3)
    fs("black")
      rotate(1/4)
        rect()
      fs("white")
        scale(0.15)
         text("ATMega328")

  shift(-0.45,-0.7)
    label5(theme1 , "31", "PD1", "TXD", "PCINT17","","1","")
    shift(0, 0.1)
     label5(theme1 , "30", "PD0", "RXD", "PCINT16","","0","")
    shift(0, 0.2)
     label5(theme1 , "29", "PC6", "RST", "PCINT14","","","")
    shift(0, 0.3)
      label5(themeGnd , "","GND","","","","","")
    shift(0, 0.4)
     label5(theme1 , "32", "PD2", "INT0", "PCINT18","","2", "Pluse")
    shift(0, 0.5)
     label5(theme1 , "1", "PD3", "INT1", "PCINT19","OC2B","3","NC0")
    shift(0, 0.6)
     label5(theme1 , "2", "PD4",   "T0", "PCINT20","XCK","4", "ROW0")
    shift(0, 0.7)
     label5(theme1 , "9", "PD5",   "T1", "PCINT21","OC0B","5", "ROW1")
    shift(0, 0.8)
     label5(theme1 ,"10", "PD5", "AIN0", "PCINT22","OC0A","6", "ROW2")
    shift(0, 0.9)
     label5(theme1 ,"11", "PD7", "AIN1", "PCINT23","","7", "ROW3")
    shift(0, 1.0)
     label5(theme1 ,"12", "PB0", "CLKO", "PCINT0","ICP1","8", "COL0")
    shift(0, 1.1)
     label5(theme1 ,"13", "PB1", "OC1A", "PCINT1","","9", "AUDIO")
    shift(0, 1.2)
     label5(themeSpi ,"14", "PB2", "OC1B", "PCINT2","SS","10", "COL1")
    shift(0, 1.3)
     label5(themeSpi ,"15", "PB3", "OC2", "PCINT3","MOSI","11", "COL2")
    shift(0, 1.4)
     label5(themeSpi ,"16", "PB4", "","PCINT4","MISO","12", "COL3")

  shift(0.45,-0.7)
    label5r(themeVcc ,"","VIN","","","","","")
    shift(0, 0.1)
      label5r(themeGnd ,"","GND","","","","","")
    shift(0, 0.2)
     label5r(theme1 ,"29", "PC6", "RST", "PCINT14","","","")
    shift(0, 0.3)
     label5r(themeVcc ,"","5V","","","","","")
    shift(0, 0.4)
     label5r(theme1 ,"22", "", "ADC7", "","","A7","")
    shift(0, 0.5)
     label5r(theme1 ,"19", "", "ADC6", "","","A6","")
    shift(0, 0.6)
     label5r(themeI2c ,"28", "PC5","ADC5", "PCINT13","SCL","19/A5", "CLOCK")
    shift(0, 0.7)
     label5r(themeI2c ,"27", "PC4","ADC4", "PCINT12","SDA","18/A4", "DATA")
    shift(0, 0.8)
     label5r(theme1 ,"26", "PC3","ADC3", "PCINT11","","17/A3", "NC2")
    shift(0, 0.9)
     label5r(theme1 ,"25", "PC2","ADC2", "PCINT10","","16/A2", "NC1")
    shift(0, 1.0)
     label5r(theme1 ,"24", "PC1","ADC1", "PCINT9","","15/A1", "COL6")
    shift(0, 1.1)
     label5r(theme1 ,"23", "PC0","ADC0", "PCINT8","","14/A0", "COL5")
    shift(0, 1.2)
     label5r(themeVcc ,"21", "AREF", "", "","","","")
    shift(0, 1.3)
     label5r(themeVcc ,"","3V3","","","","","")
    shift(0, 1.4)
     label5r(themeSpi ,"17", "PB5","", "PCINT5","SCK","13", "COL4")
tw:ina_ani
mce2
1578219489