diff --git a/src/hx711-element.stories.ts b/src/hx711-element.stories.ts new file mode 100644 index 0000000..74e0bc8 --- /dev/null +++ b/src/hx711-element.stories.ts @@ -0,0 +1,17 @@ +import { html } from 'lit'; +import './hx711-element'; + +export default { + title: 'Hx711', + component: 'wokwi-hx711', + argTypes: { + value: { control: { type: 'number', min: -2147483648, max: 2147483647, step: 1 } }, + }, + args: { + value: 0, + }, +}; + +const Template = () => html``; + +export const Default = Template.bind({}); diff --git a/src/hx711-element.ts b/src/hx711-element.ts new file mode 100644 index 0000000..bd1f071 --- /dev/null +++ b/src/hx711-element.ts @@ -0,0 +1,491 @@ +import { html, LitElement, svg } from 'lit'; +import { customElement, property } from 'lit/decorators.js'; +import { ElementPin, GND, VCC } from './pin'; + +@customElement('wokwi-hx711') +export class Hx711Element extends LitElement { + @property() value = 0; + + readonly pinInfo: ElementPin[] = [ + { name: 'VDD', y: 53, x: 109, number: 1, signals: [VCC()] }, + { name: 'DOUT', y: 35, x: 109, number: 2, signals: [] }, + { name: 'SCK', y: 44, x: 109, number: 3, signals: [] }, + { name: 'GND', y: 26, x: 109, number: 4, signals: [GND()] }, + ]; + + render() { + return html` + + + + HX711 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A- + + + E+ + + + + + GND + + + DT + + + SCK + + + VCC + + + A+ + + + B- + + + B+ + + + E- + + + + + + + + + + + + + + + + + + + + + + + HX711 + + + + + + + + + `; + } +} diff --git a/src/index.ts b/src/index.ts index 5e95a65..0e7f29d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,3 +48,4 @@ export { LedBarGraphElement } from './led-bar-graph-element'; export { MicrosdCardElement } from './microsd-card-element'; export { DipSwitch8Element } from './dip-switch-8-element'; export { StepperMotorElement } from './stepper-motor-element'; +export { Hx711Element } from './hx711-element'; diff --git a/src/react-types.ts b/src/react-types.ts index 4d9314a..bba30ba 100644 --- a/src/react-types.ts +++ b/src/react-types.ts @@ -47,6 +47,7 @@ import { LedBarGraphElement } from './led-bar-graph-element'; import { MicrosdCardElement } from './microsd-card-element'; import { DipSwitch8Element } from './dip-switch-8-element'; import { StepperMotorElement } from './stepper-motor-element'; +import { Hx711Element } from './hx711-element'; type WokwiElement = Partial & React.ClassAttributes; @@ -99,6 +100,7 @@ declare global { 'wokwi-microsd-card': WokwiElement; 'wokwi-dip-switch-8': WokwiElement; 'wokwi-stepper-motor': WokwiElement; + 'wokwi-hx711': WokwiElement; } } }