Skip to content

Commit 858f1c1

Browse files
committed
feat: add pinInfo property #34
1 parent de969e0 commit 858f1c1

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

src/arduino-uno-element.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ElementPin } from './pin';
12
import { customElement, html, LitElement, property, svg } from 'lit-element';
23
import { pinsFemalePattern } from './patterns/pins-female';
34

@@ -8,6 +9,40 @@ export class ArduinoUnoElement extends LitElement {
89
@property() ledTX = false;
910
@property() ledPower = false;
1011

12+
readonly pinInfo: ElementPin[] = [
13+
{ name: 'A5.2', x: 87, y: 9, functions: ['analog', 'i2c'], signals: ['SCL'] },
14+
{ name: 'A4.2', x: 97, y: 9, functions: ['analog', 'i2c'], signals: ['SDA'] },
15+
{ name: 'AREF', x: 106, y: 9, functions: [], signals: [] },
16+
{ name: 'GND.1', x: 115.5, y: 9, functions: ['power'], signals: ['GND'] },
17+
{ name: '13', x: 125, y: 9, functions: ['gpio', 'spi'], signals: ['SCK'] },
18+
{ name: '12', x: 134.5, y: 9, functions: ['gpio', 'spi'], signals: ['MISO'] },
19+
{ name: '11', x: 144, y: 9, functions: ['gpio', 'pwm', 'spi'], signals: ['MOSI'] },
20+
{ name: '10', x: 153.5, y: 9, functions: ['gpio', 'pwm', 'spi'], signals: ['SS'] },
21+
{ name: '9', x: 163, y: 9, functions: ['gpio', 'pwm'], signals: [] },
22+
{ name: '8', x: 173, y: 9, functions: ['gpio'], signals: [] },
23+
{ name: '7', x: 189, y: 9, functions: ['gpio'], signals: [] },
24+
{ name: '6', x: 198.5, y: 9, functions: ['gpio', 'pwm'], signals: [] },
25+
{ name: '5', x: 208, y: 9, functions: ['gpio', 'pwm'], signals: [] },
26+
{ name: '4', x: 217.5, y: 9, functions: ['gpio'], signals: [] },
27+
{ name: '3', x: 227, y: 9, functions: ['gpio', 'pwm'], signals: [] },
28+
{ name: '2', x: 236.5, y: 9, functions: ['gpio'], signals: [] },
29+
{ name: '1', x: 246, y: 9, functions: ['gpio', 'usart'], signals: ['TX'] },
30+
{ name: '0', x: 255.5, y: 9, functions: ['gpio', 'usart'], signals: ['RX'] },
31+
{ name: 'IOREF', x: 131, y: 191.5, functions: [], signals: [] },
32+
{ name: 'RESET', x: 140.5, y: 191.5, functions: [], signals: [] },
33+
{ name: '3.3V', x: 150, y: 191.5, functions: ['power'], signals: [] },
34+
{ name: '5V', x: 160, y: 191.5, functions: ['power'], signals: [] },
35+
{ name: 'GND.2', x: 169.5, y: 191.5, functions: ['power'], signals: ['GND'] },
36+
{ name: 'GND.3', x: 179, y: 191.5, functions: ['power'], signals: ['GND'] },
37+
{ name: 'VIN', x: 188.5, y: 191.5, functions: ['power'], signals: [] },
38+
{ name: 'A0', x: 208, y: 191.5, functions: ['gpio', 'analog'], signals: [] },
39+
{ name: 'A1', x: 217.5, y: 191.5, functions: ['gpio', 'analog'], signals: [] },
40+
{ name: 'A2', x: 227, y: 191.5, functions: ['gpio', 'analog'], signals: [] },
41+
{ name: 'A3', x: 236.5, y: 191.5, functions: ['gpio', 'analog'], signals: [] },
42+
{ name: 'A4', x: 246, y: 191.5, functions: ['gpio', 'analog', 'i2c'], signals: ['SDA'] },
43+
{ name: 'A5', x: 255.5, y: 191.5, functions: ['gpio', 'analog', 'i2c'], signals: ['SCL'] },
44+
];
45+
1146
render() {
1247
const { ledPower, led13, ledRX, ledTX } = this;
1348
return html`

src/led-element.ts

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

34
const lightColors: { [key: string]: string } = {
45
red: '#ff8080',
@@ -17,6 +18,11 @@ export class LEDElement extends LitElement {
1718
@property() lightColor: string | null = null;
1819
@property() label = '';
1920

21+
readonly pinInfo: ElementPin[] = [
22+
{ name: 'A', x: 24, y: 42, functions: [], signals: [], description: 'Anode' },
23+
{ name: 'C', x: 16, y: 42, functions: [], signals: [], description: 'Cathode' },
24+
];
25+
2026
static get styles() {
2127
return css`
2228
:host {

src/pin.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export type PinFunction = 'power' | 'i2c' | 'spi' | 'gpio' | 'pwm' | 'analog' | 'dac' | 'usart';
2+
3+
export interface ElementPin {
4+
/**
5+
* A name that uniquely identifies the pin, e.g. `GND` or `VCC`.
6+
* Pins that are connected internally must have the same name prefix, followed by a single dot,
7+
* and a unique suffix (e.g. `GND.1` and `GND.2`).
8+
*/
9+
name: string;
10+
11+
/** The x-coordinate of the pin, relative to the element's origin */
12+
x: number;
13+
14+
/** The y-coordinate of the pin, relative to the element's origin */
15+
y: number;
16+
17+
/** The functions of this pin. Leave empty for generic pins without a designated function. **/
18+
functions: PinFunction[];
19+
20+
/**
21+
* List of signals carried by this pin. This is useful for pins such as I²C or SPI pins, where there are designated
22+
* signal names (e.g. for I²C we have `SCL` and `SDA`). Set to an empty array if the pin isn't tied to specific
23+
* protocol signals.
24+
*/
25+
signals: string[];
26+
27+
/**
28+
* Optional pin description
29+
*/
30+
description?: string;
31+
}

0 commit comments

Comments
 (0)