Skip to content

Commit 9502602

Browse files
committed
feat: add gas sensor
1 parent 3146e3f commit 9502602

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

src/gas-sensor-element.stories.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { html } from 'lit-html';
2+
import './gas-sensor-element';
3+
4+
export default {
5+
title: 'Gas Sensor',
6+
component: 'wokwi-gas-sensor',
7+
};
8+
9+
const Template = () => html`<wokwi-gas-sensor></wokwi-gas-sensor>`;
10+
11+
export const Default = Template.bind({});

src/gas-sensor-element.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { customElement, html, LitElement } from 'lit-element';
2+
import { ElementPin } from '.';
3+
import { GND, VCC } from './pin';
4+
5+
@customElement('wokwi-gas-sensor')
6+
export class GasSensorElement extends LitElement {
7+
readonly pinInfo: ElementPin[] = [
8+
{ name: 'AOUT', y: 16.5, x: 137, number: 1, signals: [] },
9+
{ name: 'DOUT', y: 26.4, x: 137, number: 2, signals: [] },
10+
{ name: 'GND', y: 36.5, x: 137, number: 3, signals: [GND()] },
11+
{ name: 'VCC', y: 46.2, x: 137, number: 4, signals: [VCC()] },
12+
];
13+
14+
render() {
15+
return html`
16+
<svg
17+
width="36.232mm"
18+
height="16.617mm"
19+
fill-rule="evenodd"
20+
version="1.1"
21+
viewBox="0 0 137 59.5"
22+
xmlns="http://www.w3.org/2000/svg"
23+
>
24+
<defs>
25+
<pattern id="a" width="4.1" height="4.1" patternUnits="userSpaceOnUse">
26+
<path
27+
d="m0 0v4.09h0.4v-0.85l0.42 0.381v0.469h0.4v-0.0996l0.109 0.0996h0.711v-0.799l0.42 0.379v0.42h0.398v-0.0488l0.0547 0.0488h0.766v-0.75l0.42 0.381v0.369h0.4v-4.09h-0.4v0.311l-0.334-0.311h-0.598l0.111 0.0996v0.9l-0.42-0.379v-0.621h-0.398v0.25l-0.277-0.25h-0.6l0.0566 0.0508v0.9l-0.42-0.381v-0.57h-0.4v0.201l-0.223-0.201zm0.4 0.359 0.42 0.381v0.9l-0.42-0.381zm1.64 0.0508 0.42 0.391v0.889l-0.42-0.379zm1.64 0.0605 0.42 0.379v0.891l-0.42-0.381zm-2.46 0.639 0.42 0.381v0.9l-0.42-0.381zm1.64 0.0508 0.42 0.381v0.898l-0.42-0.379zm-2.46 0.641 0.42 0.379v0.9l-0.42-0.379zm1.64 0.0488 0.42 0.381v0.9l-0.42-0.381zm1.64 0.0508 0.42 0.379v0.9l-0.42-0.379zm-2.46 0.65 0.42 0.379v0.9l-0.42-0.379zm1.64 0.0488 0.42 0.381v0.9l-0.42-0.381z"
28+
fill="#949392"
29+
/>
30+
</pattern>
31+
<g id="pin">
32+
<path
33+
fill="#c6bf95"
34+
d="m29 4.6c0.382 0 0.748-0.152 1.02-0.422s0.422-0.636 0.422-1.02v-1e-3c0-0.382-0.152-0.748-0.422-1.02s-0.636-0.422-1.02-0.422h-26.1c-0.234 0-0.423 0.189-0.423 0.423v2.04c0 0.234 0.189 0.423 0.423 0.423h26.1z"
35+
/>
36+
<rect x="0" y="0" width="6.9" height="6.9" />
37+
</g>
38+
</defs>
39+
40+
<!-- Board -->
41+
<path
42+
d="m113 0h-113v59.5h113zm-1.6 53.2c0 2.62-2.12 4.74-4.74 4.74s-4.74-2.12-4.74-4.74c0-2.62 2.12-4.74 4.74-4.74s4.74 2.12 4.74 4.74zm-110 0c0 2.62 2.12 4.74 4.74 4.74 2.62 0 4.74-2.12 4.74-4.74 0-2.62-2.12-4.74-4.74-4.74-2.62 0-4.74 2.12-4.74 4.74zm105-51.6c2.62 0 4.74 2.12 4.74 4.74 0 2.62-2.12 4.74-4.74 4.74s-4.74-2.12-4.74-4.74c0-2.62 2.12-4.74 4.74-4.74zm-101 0c-2.62 0-4.74 2.12-4.74 4.74 0 2.62 2.12 4.74 4.74 4.74 2.62 0 4.74-2.12 4.74-4.74 0-2.62-2.12-4.74-4.74-4.74z"
43+
fill="#0664af"
44+
/>
45+
46+
<!-- Pins -->
47+
<use xlink:href="#pin" x="107" y="12" />
48+
<use xlink:href="#pin" x="107" y="21.3" />
49+
<use xlink:href="#pin" x="107" y="31.1" />
50+
<use xlink:href="#pin" x="107" y="40.9" />
51+
52+
<!-- Sensor -->
53+
<circle cx="47.7" cy="29.8" r="31.2" fill="none" stroke="#fff" stroke-width=".4px" />
54+
<circle cx="47.7" cy="29.8" r="28.8" fill="#dedede" />
55+
<circle cx="47.7" cy="29.8" r="25.8" fill="#d0ccc4" />
56+
<circle cx="47.7" cy="29.8" r="21.4" fill="#bab3ad" />
57+
<circle cx="47.7" cy="29.8" r="21.4" fill="url(#a)" />
58+
59+
<text fill="#ffffff" font-family="sans-serif" font-size="3.72px">
60+
<tspan x="94.656" y="16.729">
61+
AOUT
62+
</tspan>
63+
<tspan x="94.656" y="26.098">
64+
DOUT
65+
</tspan>
66+
<tspan x="94.656" y="35.911">
67+
GND
68+
</tspan>
69+
<tspan x="94.656" y="45.696">
70+
VCC
71+
</tspan>
72+
</text>
73+
</svg>
74+
`;
75+
}
76+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ export { NTCTemperatureSensorElement } from './ntc-temperature-sensor-element';
3333
export { HeartBeatSensorElement } from './heart-beat-sensor-element';
3434
export { TiltSwitchElement } from './tilt-switch-element';
3535
export { FlameSensorElement } from './flame-sensor-element';
36+
export { GasSensorElement } from './gas-sensor-element';

src/react-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { NTCTemperatureSensorElement } from './ntc-temperature-sensor-element';
3232
import { HeartBeatSensorElement } from './heart-beat-sensor-element';
3333
import { TiltSwitchElement } from './tilt-switch-element';
3434
import { FlameSensorElement } from './flame-sensor-element';
35+
import { GasSensorElement } from './gas-sensor-element';
3536

3637
type WokwiElement<T> = Partial<T> & React.ClassAttributes<T>;
3738

@@ -69,6 +70,7 @@ declare global {
6970
'wokwi-heart-beat-sensor': WokwiElement<HeartBeatSensorElement>;
7071
'wokwi-tilt-switch': WokwiElement<TiltSwitchElement>;
7172
'wokwi-flame-sensor': WokwiElement<FlameSensorElement>;
73+
'wokwi-gas-sensor': WokwiElement<GasSensorElement>;
7274
}
7375
}
7476
}

0 commit comments

Comments
 (0)