Skip to content

Commit bb5c231

Browse files
committed
feat(neopixel-matrix): add pinInfo
1 parent b88c23f commit bb5c231

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/neopixel-matrix-element.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { css, customElement, html, LitElement, property, svg } from 'lit-element';
2+
import { ElementPin, GND, VCC } from './pin';
23

34
const pixelWidth = 5.66;
45
const pixelHeight = 5;
@@ -54,6 +55,27 @@ export class NeopixelMatrixElement extends LitElement {
5455
*/
5556
@property() animation = false;
5657

58+
get pinInfo(): ElementPin[] {
59+
const { cols, rows, rowSpacing, colSpacing } = this;
60+
const mmToPix = 3.78;
61+
const pinSpacing = 2.54;
62+
const p = pinSpacing * mmToPix;
63+
const cx = ((cols * (colSpacing + pixelWidth)) / 2) * mmToPix;
64+
const y = rows * (rowSpacing + pixelHeight) * mmToPix;
65+
66+
return [
67+
{
68+
name: 'GND',
69+
x: cx - 1.5 * p,
70+
y,
71+
signals: [GND()],
72+
},
73+
{ name: 'VCC', x: cx - 0.5 * p, y, signals: [VCC()] },
74+
{ name: 'DIN', x: cx + 0.5 * p, y, signals: [] },
75+
{ name: 'DOUT', x: cx + 1.5 * p, y, signals: [] },
76+
];
77+
}
78+
5779
private pixelElements: Array<[SVGElement, SVGElement, SVGElement, SVGElement]> | null = null;
5880

5981
private animationFrame: number | null = null;

0 commit comments

Comments
 (0)