Skip to content

Commit badd8ee

Browse files
committed
feat(ir-receiver): add IR Receiver
for wokwi/wokwi-features#90
1 parent 0a0c67d commit badd8ee

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export { SlideSwitchElement } from './slide-switch-element';
2525
export { HCSR04Element } from './hc-sr04-element';
2626
export { LCD2004Element } from './lcd2004-element';
2727
export { AnalogJoystickElement } from './analog-joystick-element';
28+
export { IRReceiverElement } from './ir-receiver-element';

src/ir-receiver-element.stories.ts

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

src/ir-receiver-element.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { customElement, html, LitElement } from 'lit-element';
2+
import { ElementPin, GND, VCC } from './pin';
3+
4+
@customElement('wokwi-ir-receiver')
5+
export class IRReceiverElement extends LitElement {
6+
readonly pinInfo: ElementPin[] = [
7+
{ name: 'GND', y: 87.75, x: 20.977, number: 1, signals: [GND()] },
8+
{ name: 'VCC', y: 87.75, x: 30.578, number: 2, signals: [VCC()] },
9+
{ name: 'DAT', y: 87.75, x: 40.18, number: 3, signals: [] },
10+
];
11+
12+
render() {
13+
return html`
14+
<svg
15+
version="1.1"
16+
viewBox="0 0 61.1 88.7"
17+
width="16.178mm"
18+
height="23.482mm"
19+
font-family="sans-serif"
20+
xmlns="http://www.w3.org/2000/svg"
21+
>
22+
<g fill="#171514">
23+
<path
24+
d="m61.1 4.85c0-2.68-2.17-4.85-4.85-4.85h-51.4c-2.68 0-4.85 2.17-4.85 4.85v61c0 2.68 2.17 4.85 4.85 4.85h51.4c2.68 0 4.85-2.17 4.85-4.85zm-7.43 53.3c2.29 0 4.14 1.86 4.14 4.14 0 2.28-1.85 4.14-4.14 4.14s-4.14-1.86-4.14-4.14c0-2.29 1.85-4.14 4.14-4.14zm-46.3 0c2.29 0 4.14 1.86 4.14 4.14 0 2.28-1.85 4.14-4.14 4.14-2.29 0-4.14-1.86-4.14-4.14 0-2.29 1.85-4.14 4.14-4.14z"
25+
stroke-width=".987"
26+
/>
27+
<rect x="16.5" y="58.2" width="28.2" height="8.28" stroke="#fff" stroke-width=".888px" />
28+
<rect x="14.2" y="23" width="11.3" height="4.66" stroke="#fff" stroke-width=".888px" />
29+
</g>
30+
<rect x="15.2" y="23.7" width="9.44" height="3.23" fill="#a19e9e" stroke-width=".987" />
31+
<g fill="#171514" stroke="#fff" stroke-width=".888px">
32+
<rect x="14.2" y="33" width="11.3" height="4.66" />
33+
<rect x="31.6" y="23" width="11.3" height="4.66" />
34+
<rect x="31.6" y="33" width="11.3" height="4.66" />
35+
</g>
36+
<g fill="#433b38" stroke-width=".987">
37+
<rect x="17.7" y="59.1" width="6.47" height="6.47" />
38+
<rect x="27.3" y="59.1" width="6.47" height="6.47" />
39+
<rect x="37" y="59.1" width="6.47" height="6.47" />
40+
</g>
41+
<g fill="#9f9f9f" stroke-width=".987">
42+
<path
43+
d="m22.4 62.5c0-0.377-0.149-0.739-0.416-1.01-0.268-0.267-0.629-0.417-1.01-0.417-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.418 0.419h2.01c0.231 0 0.418-0.188 0.418-0.419v-25.8z"
44+
/>
45+
<path
46+
d="m32 62.5c0-0.377-0.149-0.739-0.416-1.01-0.268-0.267-0.629-0.417-1.01-0.417-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.418 0.419h2.01c0.231 0 0.418-0.188 0.418-0.419v-25.8z"
47+
/>
48+
<path
49+
d="m41.6 62.5c0-0.377-0.15-0.739-0.417-1.01s-0.629-0.417-1.01-0.417c-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.419 0.419h2.01c0.231 0 0.419-0.188 0.419-0.419v-25.8z"
50+
/>
51+
</g>
52+
<g transform="rotate(90)" fill="#ffffff" font-size="5px">
53+
<text x="45.369" y="-37.601">DAT</text>
54+
<text x="45.609" y="-28.801">VCC</text>
55+
<text x="45.359" y="-20.2">GND</text>
56+
<text font-size="5.71px">
57+
<tspan
58+
x="16.234 18.076 22.422 24.263 28.608 32.018 35.112 36.639 40.05 43.144 46.553"
59+
y="-52.266"
60+
>
61+
IR Reciever
62+
</tspan>
63+
</text>
64+
</g>
65+
<g fill="none" stroke="#fff">
66+
<path
67+
d="m56.3 6.32c-0.654 0.514-1.48 0.82-2.37 0.82-0.895 0-1.72-0.306-2.37-0.82"
68+
stroke-width=".316px"
69+
/>
70+
<path
71+
d="m57.4 7.97c-0.949 0.745-2.14 1.19-3.44 1.19-1.3 0-2.49-0.445-3.44-1.19"
72+
stroke-width=".395px"
73+
/>
74+
<path
75+
d="m58.9 9.32c-1.38 1.08-3.11 1.73-5 1.73s-3.62-0.646-5-1.73"
76+
stroke-width=".395px"
77+
/>
78+
</g>
79+
<path
80+
d="m20.4 10.2h-6.13c-0.382 0-0.691 0.309-0.691 0.691v6.2c0 0.382 0.309 0.691 0.691 0.691h13c0.931 0.0563 1.88 0.0563 2.81 0h12.7c0.381 0 0.691-0.309 0.691-0.691v-6.2c0-0.382-0.31-0.691-0.691-0.691h-5.88c-1.39-3.12-4.55-5.31-8.23-5.31-3.68 0-6.84 2.19-8.23 5.31zm0.463 0.691c1.18-3.1 4.21-5.31 7.77-5.31 3.55 0 6.59 2.21 7.76 5.31h6.35v6.2h-12.7c-0.914 0.0563-1.85 0.0563-2.77 0h-13v-6.2z"
81+
fill="#fff"
82+
stroke-width=".987"
83+
/>
84+
<path
85+
d="m28.6 6.32c4.01 0 7.27 3.26 7.27 7.27 0 4.01-14.5 4.01-14.5 0 0-4.01 3.26-7.27 7.27-7.27z"
86+
fill="#2d2624"
87+
stroke-width=".987"
88+
/>
89+
<clipPath id="b">
90+
<path
91+
d="m37.2 14.5c4.06 0 7.36 3.3 7.36 7.36 0 4.06-14.7 4.06-14.7 0 0-4.06 3.3-7.36 7.36-7.36z"
92+
/>
93+
</clipPath>
94+
<g transform="matrix(.987 0 0 .987 -8.13 -8.03)" clip-path="url(#b)">
95+
<path
96+
d="m37.2 12.3c-0.069 0.303 0.377 0.714 0.536 0.965 0.504 0.799 0.744 1.43 1.07 2.3 1.01 2.7 0.775 5.41 0.775 8.2 0 0.121 0.155-0.196 0.262-0.254 0.233-0.126 0.484-0.232 0.724-0.345 0.727-0.341 1.47-0.602 2.24-0.833 2.84-0.852 4.9-0.521 6.1-3.77 0.26-0.704 0.404-1.57 0.22-2.31-0.225-0.9-2.44-3.28-3.27-3.7-1.35-0.675-3.05-0.667-4.43-1.01-1.3-0.326-3.08-0.498-4.11 0.524"
97+
fill="#483f3c"
98+
/>
99+
</g>
100+
<rect x="19.1" y="11" width="19.1" height="5.51" fill="#2d2624" stroke-width=".987" />
101+
<clipPath id="a"><rect x="27.6" y="19.3" width="19.3" height="5.58" /></clipPath>
102+
<g transform="matrix(.987 0 0 .987 -8.13 -8.03)" clip-path="url(#a)">
103+
<path
104+
d="m38.1 18.8c0.144 0.284 0.197 0.749 0.286 1.07 0.466 1.68 0.509 3.53 0.399 5.27-0.041 0.653-0.374 1.31-0.374 1.96 0 0.041 0.076-0.032 0.116-0.043 0.154-0.042 0.14-0.034 0.29-0.06 0.375-0.063 0.754-0.104 1.13-0.153 0.884-0.115 1.77-0.241 2.66-0.34 2.32-0.26 5.58 0.4 6.53-2.44 0.185-0.557 0.236-1.13 0.289-1.72 0.054-0.587 0.14-1.38-0.037-1.95-0.922-3-4.9-1.81-7.22-1.81-0.773 0-1.54 0.084-2.3 0.236-0.055 0.011-0.659 0.108-0.659 0.114"
105+
fill="#483f3c"
106+
/>
107+
</g>
108+
<g fill="#a19e9e" stroke-width=".987">
109+
<circle cx="16.5" cy="14" r="1.44" />
110+
<circle cx="40.5" cy="14" r="1.44" />
111+
<rect x="15.2" y="33.7" width="9.44" height="3.23" />
112+
<rect x="32.5" y="23.7" width="9.44" height="3.23" />
113+
<rect x="32.5" y="33.7" width="9.44" height="3.23" />
114+
</g>
115+
<g stroke-width=".987">
116+
<rect x="17.9" y="23.7" width="3.93" height="3.23" fill="#8e7147" />
117+
<rect x="34.8" y="24.1" width="4.88" height="2.44" fill="#171514" />
118+
<rect x="34.8" y="34.1" width="4.88" height="2.44" fill="#171514" />
119+
<text fill="#ffffff" font-size="2.2px" stroke-width=".987">
120+
<tspan x="35.267719 36.591557 37.915394" y="26.1">103</tspan>
121+
<tspan x="35.267719 36.591557 37.915394" y="36.12">102</tspan>
122+
</text>
123+
<rect x="17.9" y="33.7" width="3.93" height="3.23" fill="#ccf9f9" />
124+
</g>
125+
</svg>
126+
`;
127+
}
128+
}

src/react-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { SlideSwitchElement } from './slide-switch-element';
2424
import { HCSR04Element } from './hc-sr04-element';
2525
import { LCD2004Element } from './lcd2004-element';
2626
import { AnalogJoystickElement } from './analog-joystick-element';
27+
import { IRReceiverElement } from './ir-receiver-element';
2728

2829
type WokwiElement<T> = Partial<T> & React.ClassAttributes<T>;
2930

@@ -53,6 +54,7 @@ declare global {
5354
'wokwi-hc-sr04': WokwiElement<HCSR04Element>;
5455
'wokwi-lcd2004': WokwiElement<LCD2004Element>;
5556
'wokwi-analog-joystick': WokwiElement<AnalogJoystickElement>;
57+
'wokwi-ir-receiver': WokwiElement<IRReceiverElement>;
5658
}
5759
}
5860
}

0 commit comments

Comments
 (0)