Skip to content

Commit f115efa

Browse files
committed
feat(ds1307): add DS1307 element
1 parent e6c69fb commit f115efa

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

src/ds1307-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 './ds1307-element';
3+
4+
export default {
5+
title: 'DS1307',
6+
component: 'wokwi-ds1307',
7+
};
8+
9+
export const DS1307 = () => html`<wokwi-ds1307></wokwi-ds1307>`;

src/ds1307-element.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { customElement, html, LitElement } from 'lit-element';
2+
import { ElementPin, GND, i2c, VCC } from './pin';
3+
4+
@customElement('wokwi-ds1307')
5+
export class Ds1307Element extends LitElement {
6+
readonly pinInfo: ElementPin[] = [
7+
{ name: 'GND', y: 15, x: 9.5, number: 1, signals: [GND()] },
8+
{ name: '5V', y: 25, x: 9.5, number: 2, signals: [VCC(5)] },
9+
{ name: 'SDA', y: 34.5, x: 9.5, number: 3, signals: [i2c('SDA')] },
10+
{ name: 'SCL', y: 44, x: 9.5, number: 4, signals: [i2c('SCL')] },
11+
{ name: 'SQW', y: 54, x: 9.5, number: 5, signals: [] },
12+
];
13+
14+
render() {
15+
return html`
16+
<svg
17+
width="25.8mm"
18+
height="22.212mm"
19+
version="1.1"
20+
viewBox="0 0 25.8 22.212"
21+
xmlns="http://www.w3.org/2000/svg"
22+
>
23+
<path
24+
d="m2.961 0c-1.6405 0-2.961 1.3207-2.961 2.9611v16.29c0 1.6405 1.3206 2.961 2.961 2.961h19.878c1.6405 0 2.961-1.3206 2.961-2.961v-2.1407c-2.4623-2.4996-2.4864-1.3794-2.4996-5.5588-0.01319-4.1794 0.11192-2.4623 2.4996-5.5961v-2.9945c0-1.6405-1.3206-2.9611-2.961-2.9611zm20.214 1.5792h1.04e-4c3e-3 -1.1e-5 0.0061-1.1e-5 0.0091 0 0.67598-1.6e-5 1.224 0.54798 1.224 1.224 1.5e-5 0.67598-0.54798 1.224-1.224 1.224-0.67598 1.5e-5 -1.224-0.54798-1.224-1.224-3.4e-5 -0.67241 0.54238-1.2189 1.2148-1.224zm-20.564 1.9405c0.29985-2.4e-5 0.54294 0.24306 0.54291 0.54291 2.4e-5 0.29985-0.24306 0.54294-0.54291 0.54291-0.29985 2.4e-5 -0.54294-0.24306-0.54291-0.54291-2.4e-5 -0.29985 0.24306-0.54294 0.54291-0.54291zm-0.02958 2.5853c0.0011-3e-6 0.0021-3e-6 0.0032 0 0.29985-2.4e-5 0.54294 0.24306 0.54291 0.54291-3.2e-5 0.29981-0.2431 0.54283-0.54291 0.54281-0.29977-3.2e-5 -0.54278-0.24304-0.54281-0.54281-2.9e-5 -0.29858 0.24107-0.54114 0.53965-0.54291zm0.02632 2.5062h1.04e-4c0.0011-3e-6 0.0021-3e-6 0.0032 0 0.29985-2.4e-5 0.54294 0.24306 0.54291 0.54291-3.2e-5 0.29981-0.2431 0.54284-0.54291 0.54281-0.29981 2.4e-5 -0.54288-0.243-0.54291-0.54281-2.9e-5 -0.29858 0.24107-0.54114 0.53965-0.54291zm0.02652 2.5853c0.0011-3e-6 0.0021-3e-6 0.0032 0 0.29977 3.2e-5 0.54278 0.24304 0.54281 0.54281 2.4e-5 0.29981-0.243 0.54288-0.54281 0.54291-0.29985 2.4e-5 -0.54294-0.24306-0.54291-0.54291 2.7e-5 -0.29858 0.24117-0.5411 0.53975-0.54281zm-0.02652 2.5325h1.04e-4c0.0011-3e-6 0.0021-3e-6 0.0032 0 0.29985-2.4e-5 0.54294 0.24306 0.54291 0.54291-3.2e-5 0.29981-0.2431 0.54284-0.54291 0.54281-0.29981 2.4e-5 -0.54288-0.243-0.54291-0.54281-2.9e-5 -0.29858 0.24107-0.54114 0.53965-0.54291zm-0.02663 4.4895c3e-3 -1.1e-5 0.0061-1.1e-5 0.0091 0 0.6759 4.2e-5 1.2238 0.54795 1.2238 1.2238 1.5e-5 0.67594-0.54791 1.2239-1.2238 1.224-0.67598 1.5e-5 -1.224-0.54798-1.224-1.224 2.2e-5 -0.67241 0.54248-1.2189 1.2149-1.2238z"
25+
fill="#015abe"
26+
/>
27+
<g fill="#ffe680">
28+
<path
29+
d="m2.6116 3.0997a0.97608 0.96289 0 0 0-0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606-0.9629 0.97608 0.96289 0 0 0-0.97606-0.9629zm-0.01316 0.40897a0.52761 0.5408 0 0 1 0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761-0.54077 0.52761 0.5408 0 0 1 0.52761-0.54077z"
30+
/>
31+
<path
32+
d="m2.5853 5.685a0.97608 0.96289 0 0 0-0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606-0.9629 0.97608 0.96289 0 0 0-0.97606-0.9629zm-0.01316 0.40897a0.52761 0.5408 0 0 1 0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761-0.54077 0.52761 0.5408 0 0 1 0.52761-0.54077z"
33+
/>
34+
<path
35+
d="m2.6116 8.1911a0.97608 0.96289 0 0 0-0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606-0.9629 0.97608 0.96289 0 0 0-0.97606-0.9629zm-0.01316 0.40897a0.52761 0.5408 0 0 1 0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761-0.54077 0.52761 0.5408 0 0 1 0.52761-0.54077z"
36+
/>
37+
<path
38+
d="m2.638 10.776a0.97608 0.96289 0 0 0-0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606-0.9629 0.97608 0.96289 0 0 0-0.97606-0.9629zm-0.01316 0.40897a0.52761 0.5408 0 0 1 0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761-0.54077 0.52761 0.5408 0 0 1 0.52761-0.54077z"
39+
/>
40+
<path
41+
d="m2.6116 13.309a0.97608 0.96289 0 0 0-0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606 0.9629 0.97608 0.96289 0 0 0 0.97606-0.9629 0.97608 0.96289 0 0 0-0.97606-0.9629zm-0.01316 0.40897a0.52761 0.5408 0 0 1 0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761 0.54077 0.52761 0.5408 0 0 1-0.52761-0.54077 0.52761 0.5408 0 0 1 0.52761-0.54077z"
42+
/>
43+
</g>
44+
<text transform="rotate(90)" font-size="1.3px" fill="#e6e6e6">
45+
<tspan x="0.78" y="-3.81">GND</tspan>
46+
<tspan x="5.75" y="-0.43">5V</tspan>
47+
<tspan x="7.89" y="-3.81">SDA</tspan>
48+
<tspan x="10.45" y="-0.49">SCL</tspan>
49+
<tspan x="13" y="-3.97">SQW</tspan>
50+
</text>
51+
<g fill="#999">
52+
<rect x="6.5174" y="9.8" width=".62" height="1.971" rx=".2" ry=".2" />
53+
<rect x="6.5174" y="4.29" width=".62" height="1.97" rx=".2" ry=".2" />
54+
<rect x="7.8138" y="4.26" width=".62" height="1.97" rx=".2" ry=".2" />
55+
<rect x="7.8138" y="9.77" width=".621" height="1.97" rx=".2" ry=".2" />
56+
<rect x="9.0674" y="4.26" width=".62" height="1.97" rx=".2" ry=".2" />
57+
<rect x="10.321" y="4.26" width=".62" height="1.97" rx=".2" ry=".2" />
58+
<rect x="9.0674" y="9.77" width=".621" height="1.97" rx=".2" ry=".2" />
59+
<rect x="10.321" y="9.77" width=".621" height="1.97" rx=".2" ry=".2" />
60+
<rect x="8.8304" y="13" width="1.38" height="1.43" rx=".2" ry=".2" />
61+
<rect x="5.0064" y="18.56" width="1.38" height="1.43" rx=".2" ry=".2" />
62+
<rect x="5.0064" y="13.02" width="1.38" height="1.43" rx=".2" ry=".2" />
63+
<rect x="8.8118" y="18.57" width="1.38" height="1.43" rx=".2" ry=".2" />
64+
</g>
65+
<rect x="6.2656" y="6.1049" width="5.1111" height="3.8244" fill="#1a1a1a" />
66+
<rect x="5.9653" y="12.746" width="3.173" height="7.7357" fill="#1a1a1a" />
67+
<text fill="#e6e6e6">
68+
<tspan x="10.5" y="19.8" font-size="2.1px">RTC</tspan>
69+
<tspan x="10.1" y="21.5" font-size="1.38px">DS1307</tspan>
70+
</text>
71+
<path
72+
d="m23.105 6.4546-0.093544 11.038h-7.6239l-1.4032-2.666-0.14032-7.2965 1.1514-1.1171z"
73+
fill="#e7d652"
74+
/>
75+
<path
76+
transform="scale(.26458)"
77+
d="m65.771 8.0801c-0.74122-0.056466-0.96289 0.40508-0.96289 0.99805v10.564h-7.7773l-11.018 11.018v26.67l11.191 11.193 7.0625-0.029297v11.404c0.030992 0.86246 0.40014 1.3613 1.3613 1.3613h9.8711c0.79548 0 1.1738-0.34656 1.1738-1.0801v-10.686h7.377s-0.091892-1.0897 0.49805-1.2539c4.3436-1.2091 5.1203-2.5601 5.7949-4.0449 2.0727-4.5618-6.7065-7.6884-6.1094-21.266 0.5971-13.577 7.9939-12.227 6.2988-18.801-0.48161-1.8679-2.1495-3.113-5.6328-3.3926-0.48254-0.038702-0.44922-0.99414-0.44922-0.99414h-7.5781v-10.717c0.00373-0.74652-0.24336-0.94531-1.0918-0.94531h-10.01zm-1.5918 16.668a7.937 7.937 0 0 1 0.14844 0 7.937 7.937 0 0 1 7.9375 7.9355 7.937 7.937 0 0 1-7.9375 7.9375 7.937 7.937 0 0 1-7.9355-7.9375 7.937 7.937 0 0 1 7.7871-7.9355zm0 24.707a7.937 7.937 0 0 1 0.14844 0 7.937 7.937 0 0 1 7.9375 7.9355 7.937 7.937 0 0 1-7.9375 7.9375 7.937 7.937 0 0 1-7.9355-7.9375 7.937 7.937 0 0 1 7.7871-7.9355z"
78+
fill="#e6e6e6"
79+
/>
80+
<path
81+
d="m2.5877 17.819a1.6229 1.6229 0 0 0-1.6198 1.6229 1.6229 1.6229 0 0 0 1.6228 1.6228 1.6229 1.6229 0 0 0 1.6229-1.6228 1.6229 1.6229 0 0 0-1.6229-1.6229 1.6229 1.6229 0 0 0-0.0031 0zm0.0031 0.43845a1.1471 1.1471 0 0 1 1.1471 1.1471 1.1471 1.1471 0 0 1-1.1471 1.1471 1.1471 1.1471 0 0 1-1.1471-1.1471 1.1471 1.1471 0 0 1 1.1471-1.1471z"
82+
fill="#e7e3c4"
83+
/>
84+
<path
85+
d="m23.181 1.1802a1.6229 1.6229 0 0 0-1.6198 1.6229 1.6229 1.6229 0 0 0 1.6228 1.6228 1.6229 1.6229 0 0 0 1.6229-1.6228 1.6229 1.6229 0 0 0-1.6229-1.6229 1.6229 1.6229 0 0 0-0.0031 0zm0.0031 0.43845a1.1471 1.1471 0 0 1 1.1471 1.1471 1.1471 1.1471 0 0 1-1.1471 1.1471 1.1471 1.1471 0 0 1-1.1471-1.1471 1.1471 1.1471 0 0 1 1.1471-1.1471z"
86+
fill="#e7e3c4"
87+
/>
88+
<path
89+
d="m15.049 3.0132c-0.14489 0.02316-0.26986-0.0058-0.27922-0.06459-0.0094-0.05874 0.1005-0.1251 0.24541-0.1481 0.14481-0.023 0.26976 0.0058 0.27913 0.06451 0.0094 0.05874-0.1004 0.12518-0.24531 0.14818m-0.1376 0.60509c-0.05307 0.027-0.1501-0.05691-0.21671-0.18746-0.06668-0.13072-0.07782-0.2587-0.02468-0.2857 0.0529-0.02693 0.14978 0.05697 0.21654 0.18761 0.06668 0.13054 0.0779 0.25845 0.02485 0.28555m-0.57077-0.24323c-0.10363 0.10379-0.22167 0.1538-0.26376 0.11171-0.04214-0.04199 0.0078-0.16022 0.1114-0.26399 0.10354-0.10394 0.22158-0.15395 0.26384-0.11189 0.04206 0.04201-0.0078 0.1603-0.11148 0.26416m-0.39663-0.72272c0.02685-0.05307 0.15476-0.04201 0.2853 0.02443 0.13079 0.06645 0.21504 0.16341 0.18802 0.21638-0.027 0.05289-0.15476 0.04209-0.28545-0.02435-0.13072-0.06643-0.21487-0.16341-0.18786-0.21646m0.75238-0.38413c0.05882 0.0091 0.0879 0.13424 0.06492 0.27913-0.0227 0.14491-0.08873 0.25478-0.14762 0.24556-0.05866-0.0093-0.08784-0.13425-0.06509-0.27905 0.02285-0.14491 0.08896-0.25485 0.1478-0.24564m1.8552 0.39655c-0.01218-0.07703-0.05401-0.09906-0.15492-0.13127-0.07663-0.02462-0.58986-0.18811-0.58986-0.18811s-0.35776-0.1352-0.62286 0.05595c-0.03575 0.02579-0.07278 0.05512-0.10988 0.08638 0.03118-0.03718 0.06051-0.07413 0.08625-0.10987 0.19057-0.26551 0.05482-0.62311 0.05482-0.62311s-0.16438-0.51284-0.18915-0.5896c-0.03245-0.10067-0.05449-0.14251-0.1316-0.15445-0.07724-0.01225-0.1109 0.0207-0.17278 0.1066-0.04713 0.06524-0.36128 0.5029-0.36128 0.5029s-0.23885 0.29846-0.13922 0.6098c0.01352 0.04176 0.02998 0.08607 0.04834 0.13112-0.02582-0.0412-0.05193-0.08053-0.07798-0.11598-0.19371-0.26314-0.5755-0.24479-0.5755-0.24479s-0.53864-0.0021-0.61911-0.0022c-0.10594-3.55e-4 -0.15243 0.0079-0.18784 0.07734-0.03543 0.06949-0.01451 0.11194 0.04809 0.19723 0.04751 0.06501 0.3668 0.4989 0.3668 0.4989s0.20998 0.3196 0.53673 0.32088c0.04391 2.18e-4 0.09096-0.0018 0.13928-0.0053a1.9307 1.9307 0 0 0-0.13406 0.03824c-0.31025 0.1029-0.4105 0.47187-0.4105 0.47187s-0.16847 0.51163-0.19363 0.58824c-0.03285 0.1005-0.03951 0.14722 0.01563 0.20228 0.0552 0.0553 0.10202 0.04847 0.20252 0.01532 0.07653-0.02508 0.58791-0.19459 0.58791-0.19459s0.36858-0.10106 0.47076-0.41146c0.01388-0.04166 0.02645-0.08704 0.03816-0.13383-0.0035 0.04824-0.0053 0.09521-0.0049 0.13912 0.0018 0.32683 0.32169 0.53625 0.32169 0.53625s0.43436 0.31815 0.49943 0.36576c0.08559 0.06228 0.12791 0.08319 0.19748 0.0477 0.0694-0.03543 0.07751-0.08192 0.07701-0.18786-1.97e-4 -0.08048-0.0035-0.61911-0.0035-0.61911s0.01794-0.38188-0.24564-0.5751c-0.03543-0.02596-0.07463-0.05201-0.11579-0.07765 0.04495 0.0181 0.08902 0.03454 0.13102 0.04768 0.31134 0.09929 0.60947-0.14018 0.60947-0.14018s0.43694-0.31486 0.50226-0.36199c0.08575-0.06203 0.11852-0.09609 0.10634-0.17311"
90+
fill="#fff"
91+
/>
92+
<text fill="#fff" font-size="2.5px" font-weight="bold">
93+
<tspan x="12.6" y="12.7">+</tspan>
94+
</text>
95+
</svg>
96+
`;
97+
}
98+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ export { ServoElement } from './servo-element';
1919
export { DHT22Element as Dht22Element } from './dht22-element';
2020
export { ArduinoMegaElement } from './arduino-mega-element';
2121
export { ArduinoNanoElement } from './arduino-nano-element';
22+
export { Ds1307Element } from './ds1307-element';

src/pin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ export const usart = (signal: 'RX' | 'TX', bus = 0): PinSignalInfo => ({
7676
signal,
7777
bus,
7878
});
79+
80+
export const GND = (): PinSignalInfo => ({ type: 'power', signal: 'GND' });
81+
export const VCC = (voltage?: number): PinSignalInfo => ({ type: 'power', signal: 'VCC', voltage });

src/react-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ServoElement } from './servo-element';
1818
import { DHT22Element } from './dht22-element';
1919
import { ArduinoMegaElement } from './arduino-mega-element';
2020
import { ArduinoNanoElement } from './arduino-nano-element';
21+
import { Ds1307Element } from './ds1307-element';
2122

2223
declare global {
2324
namespace JSX {
@@ -39,6 +40,7 @@ declare global {
3940
'wokwi-dht22': Partial<DHT22Element>;
4041
'wokwi-arduino-mega': Partial<ArduinoMegaElement>;
4142
'wokwi-arduino-nano': Partial<ArduinoNanoElement>;
43+
'wokwi-ds1307': Partial<Ds1307Element>;
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)