|
| 1 | +import { customElement, html, LitElement, property, svg } from 'lit-element'; |
| 2 | +import { ElementPin } from '.'; |
| 3 | +import { GND, i2c, VCC } from './pin'; |
| 4 | + |
| 5 | +@customElement('wokwi-mpu6050') |
| 6 | +export class MPU6050Element extends LitElement { |
| 7 | + @property() led1 = false; |
| 8 | + |
| 9 | + readonly pinInfo: ElementPin[] = [ |
| 10 | + { name: 'INT', x: 7.28, y: 5.78, signals: [] }, |
| 11 | + { name: 'ADO', x: 16.9, y: 5.78, signals: [] }, |
| 12 | + { name: 'XCL', x: 26.4, y: 5.78, signals: [] }, |
| 13 | + { name: 'XDA', x: 36.0, y: 5.78, signals: [] }, |
| 14 | + { name: 'SDA', x: 45.6, y: 5.78, signals: [i2c('SDA')] }, |
| 15 | + { name: 'SCL', x: 55.2, y: 5.78, signals: [i2c('SCL')] }, |
| 16 | + { name: 'GND', x: 64.8, y: 5.78, signals: [GND()] }, |
| 17 | + { name: 'VCC', x: 74.4, y: 5.78, signals: [VCC()] }, |
| 18 | + ]; |
| 19 | + |
| 20 | + render() { |
| 21 | + const { led1 } = this; |
| 22 | + return html` |
| 23 | + <svg |
| 24 | + width="21.6mm" |
| 25 | + height="16.2mm" |
| 26 | + clip-rule="evenodd" |
| 27 | + fill-rule="evenodd" |
| 28 | + version="1.1" |
| 29 | + viewBox="0 0 81.6 61.2" |
| 30 | + xmlns="http://www.w3.org/2000/svg" |
| 31 | + > |
| 32 | + <defs> |
| 33 | + <pattern id="pin-pattern" height="2.1" width="14" patternUnits="userSpaceOnUse"> |
| 34 | + <path |
| 35 | + d=" m2.09 1.32c0.124 0 0.243-0.049 0.331-0.137 0.086-0.086 0.137-0.206 0.137-0.33v-0.387c0-0.124-0.050-0.242-0.137-0.33-0.087-0.087-0.207-0.137-0.331-0.137h-1.62v1.32z" |
| 36 | + fill="#f5f9f0" |
| 37 | + /> |
| 38 | + </pattern> |
| 39 | + </defs> |
| 40 | +
|
| 41 | + <!-- Board --> |
| 42 | + <path |
| 43 | + d="m81.6 0h-81.6v61.2h81.6zm-10 44.9c3.8 0 6.88 3.08 6.88 6.88 0 3.8-3.08 6.89-6.88 6.89-3.8 0-6.89-3.09-6.89-6.89 0-3.8 3.09-6.88 6.89-6.88zm-61.6 0c3.8 0 6.89 3.08 6.89 6.88 0 3.8-3.09 6.89-6.89 6.89-3.8 0-6.88-3.09-6.88-6.89 0-3.8 3.08-6.88 6.88-6.88zm-2.74-41.9c1.55 0 2.81 1.26 2.81 2.81s-1.26 2.8-2.81 2.8-2.8-1.26-2.8-2.8 1.26-2.81 2.8-2.81zm19.2 0c1.55 0 2.81 1.26 2.81 2.81s-1.26 2.8-2.81 2.8c-1.55 0-2.8-1.26-2.8-2.8s1.26-2.81 2.8-2.81zm-9.58 0c1.55 0 2.81 1.26 2.81 2.81s-1.26 2.8-2.81 2.8c-1.55 0-2.8-1.26-2.8-2.8s1.26-2.81 2.8-2.81zm19.2 0c1.55 0 2.81 1.26 2.81 2.81s-1.26 2.8-2.81 2.8c-1.55 0-2.8-1.26-2.8-2.8s1.26-2.81 2.8-2.81zm9.58 0c1.55 0 2.8 1.26 2.8 2.81s-1.26 2.8-2.8 2.8c-1.55 0-2.81-1.26-2.81-2.8s1.26-2.81 2.81-2.81zm19.2 0c1.55 0 2.8 1.26 2.8 2.81s-1.26 2.8-2.8 2.8-2.81-1.26-2.81-2.8 1.26-2.81 2.81-2.81zm-9.58 0c1.55 0 2.8 1.26 2.8 2.81s-1.26 2.8-2.8 2.8c-1.55 0-2.81-1.26-2.81-2.8s1.26-2.81 2.81-2.81zm19.2 0c1.55 0 2.8 1.26 2.8 2.81s-1.26 2.8-2.8 2.8c-1.55 0-2.81-1.26-2.81-2.8s1.26-2.81 2.81-2.81z" |
| 44 | + fill="#16619d" |
| 45 | + /> |
| 46 | +
|
| 47 | + <!-- Right Chip --> |
| 48 | + <g fill="#fefdf4"> |
| 49 | + <rect x="74.5" y="23.1" width="2.01" height="4.81" /> |
| 50 | + <rect x="67.8" y="33" width="2.01" height="4.81" /> |
| 51 | + <rect x="71.2" y="23.1" width="2.01" height="4.81" /> |
| 52 | + <rect x="67.8" y="23.1" width="2.01" height="4.81" /> |
| 53 | + <rect x="74.5" y="33" width="2.01" height="4.81" /> |
| 54 | + </g> |
| 55 | + <g fill="#31322e"> |
| 56 | + <rect x="74.5" y="25.5" width="2.01" height="2.4" /> |
| 57 | + <rect x="67.8" y="33" width="2.01" height="2.4" /> |
| 58 | + <rect x="71.2" y="25.5" width="2.01" height="2.4" /> |
| 59 | + <rect x="67.8" y="25.5" width="2.01" height="2.4" /> |
| 60 | + <rect x="74.5" y="33" width="2.01" height="2.4" /> |
| 61 | + </g> |
| 62 | +
|
| 63 | + <!-- Resistors --> |
| 64 | + <g fill="#e5e5e5"> |
| 65 | + <rect x="12" y="21.3" width="3.83" height="9.3" /> |
| 66 | + <rect x="17.7" y="21.3" width="3.83" height="9.3" /> |
| 67 | + <rect x="56.5" y="21.3" width="3.83" height="9.3" /> |
| 68 | + <rect x="51.2" y="21.3" width="3.83" height="9.3" /> |
| 69 | + <rect x="17.7" y="35.6" width="3.83" height="9.3" /> |
| 70 | + <rect x="23.3" y="21.3" width="3.83" height="9.3" /> |
| 71 | + <rect x="62.2" y="21.3" width="3.83" height="9.3" /> |
| 72 | + <rect x="51.2" y="35.8" width="3.83" height="9.3" /> |
| 73 | + <rect x="56.9" y="35.8" width="3.83" height="9.3" /> |
| 74 | + </g> |
| 75 | + <path d="m76 42.6v-3.13h-7.59v3.13z" fill="#fefdf4" /> |
| 76 | + <rect x="23.1" y="35.6" width="3.83" height="9.3" fill="#e5e5e5" /> |
| 77 | +
|
| 78 | + <g fill="#26232b"> |
| 79 | + <rect x="17.7" y="23.4" width="3.83" height="5.31" /> |
| 80 | + <rect x="56.5" y="23.4" width="3.83" height="5.31" /> |
| 81 | + <rect x="51.2" y="23.4" width="3.83" height="5.31" /> |
| 82 | + <rect x="17.7" y="37.7" width="3.83" height="5.31" /> |
| 83 | + </g> |
| 84 | + <g fill="#d8c18d"> |
| 85 | + <rect x="23.3" y="23.4" width="3.83" height="5.31" /> |
| 86 | + <rect x="62.2" y="23.4" width="3.83" height="5.31" /> |
| 87 | + <rect x="51.2" y="37.8" width="3.83" height="5.31" /> |
| 88 | + <rect x="56.9" y="37.8" width="3.83" height="5.31" /> |
| 89 | + <path d="m74.3 42.6v-3.13h-4.33v3.13z" /> |
| 90 | + </g> |
| 91 | + <g> |
| 92 | + <rect x="23.1" y="37.7" width="3.83" height="5.31" fill="#a06352" /> |
| 93 | + <rect x="31.8" y="47.1" width="15.6" height="6.03" fill="#f3c338" /> |
| 94 | + <rect x="67.3" y="27.9" width="9.76" height="5.28" fill="#010303" /> |
| 95 | + </g> |
| 96 | +
|
| 97 | + <!-- MPU6050 Chip --> |
| 98 | + <rect transform="translate(47,26)" width="5" height="14.5" fill="url(#pin-pattern)" /> |
| 99 | + <rect |
| 100 | + transform="translate(32.3,40) rotate(180)" |
| 101 | + width="5" |
| 102 | + height="14.5" |
| 103 | + fill="url(#pin-pattern)" |
| 104 | + /> |
| 105 | + <rect |
| 106 | + transform="translate(46.5,40.7) rotate(90)" |
| 107 | + width="5" |
| 108 | + height="14.5" |
| 109 | + fill="url(#pin-pattern)" |
| 110 | + /> |
| 111 | + <rect |
| 112 | + transform="translate(32.3,26) rotate(270)" |
| 113 | + width="5" |
| 114 | + height="14.5" |
| 115 | + fill="url(#pin-pattern)" |
| 116 | + /> |
| 117 | + <rect x="31.8" y="25.4" width="15.6" height="15.6" /> |
| 118 | +
|
| 119 | + <!-- LED --> |
| 120 | + <rect x="12" y="23.4" width="3.83" height="5.31" fill="#f5ecde" /> |
| 121 | + <filter id="ledFilter" x="-0.8" y="-0.8" height="5.2" width="5.8"> |
| 122 | + <feGaussianBlur stdDeviation="2" /> |
| 123 | + </filter> |
| 124 | + ${led1 && |
| 125 | + svg`<circle cx="13.9" cy="25.5" r="3.5" fill="#80ff80" filter="url(#ledFilter)" />`} |
| 126 | +
|
| 127 | + <!-- PCB Pins--> |
| 128 | + <g fill="none" stroke="#d0ae88" stroke-width=".648px"> |
| 129 | + <circle cx="64.8" cy="5.78" r="2.81" /> |
| 130 | + <circle cx="55.2" cy="5.78" r="2.81" /> |
| 131 | + <circle cx="45.6" cy="5.78" r="2.81" /> |
| 132 | + <circle cx="36" cy="5.78" r="2.81" /> |
| 133 | + <circle cx="26.4" cy="5.78" r="2.81" /> |
| 134 | + <circle cx="16.9" cy="5.78" r="2.81" /> |
| 135 | + <circle cx="7.28" cy="5.78" r="2.81" /> |
| 136 | + <circle cx="74.4" cy="5.78" r="2.81" /> |
| 137 | + </g> |
| 138 | +
|
| 139 | + <!-- Text --> |
| 140 | + <text |
| 141 | + transform="rotate(90)" |
| 142 | + fill="#ffffff" |
| 143 | + font-family="sans-serif" |
| 144 | + font-size="3.6px" |
| 145 | + x="10.056" |
| 146 | + > |
| 147 | + <tspan x="10.056" y="-6.193"> |
| 148 | + INT |
| 149 | + </tspan> |
| 150 | + <tspan x="10.056" y="-15.817"> |
| 151 | + ADO |
| 152 | + </tspan> |
| 153 | + <tspan x="10.056" y="-25.157"> |
| 154 | + XCL |
| 155 | + </tspan> |
| 156 | + <tspan x="10.056" y="-34.891"> |
| 157 | + XDA |
| 158 | + </tspan> |
| 159 | + <tspan x="10.056" y="-44.383"> |
| 160 | + SDA |
| 161 | + </tspan> |
| 162 | + <tspan x="9.911" y="-54.049"> |
| 163 | + SCL |
| 164 | + </tspan> |
| 165 | + <tspan x="10.057" y="-63.545"> |
| 166 | + GND |
| 167 | + </tspan> |
| 168 | + <tspan x="10.057" y="-73.260"> |
| 169 | + VCC |
| 170 | + </tspan> |
| 171 | + </text> |
| 172 | + </svg> |
| 173 | + `; |
| 174 | + } |
| 175 | +} |
0 commit comments