-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
300 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
apps/electron-app/src/render/components/react-flow/nodes/Relay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { RelayData, RelayValueType } from '@microflow/components'; | ||
import { BaseNode, NodeContainer, useNodeSettings } from './Node'; | ||
import { Handle } from './Handle'; | ||
import { Position } from '@xyflow/react'; | ||
import { useNodeValue } from '../../../stores/node-data'; | ||
import { Icons } from '@ui/index'; | ||
import { useEffect } from 'react'; | ||
import { usePins } from '../../../stores/board'; | ||
import { MODES } from '../../../../common/types'; | ||
import { mapPinToPaneOption } from '../../../../utils/pin'; | ||
|
||
export function Relay(props: Props) { | ||
return ( | ||
<NodeContainer {...props}> | ||
<Value /> | ||
<Settings /> | ||
<Handle type="target" position={Position.Left} id="open" offset={-1} /> | ||
<Handle type="target" position={Position.Left} id="close" /> | ||
<Handle type="target" position={Position.Left} id="toggle" offset={1} /> | ||
</NodeContainer> | ||
); | ||
} | ||
|
||
function Value() { | ||
const value = useNodeValue<RelayValueType>(false); | ||
|
||
if (!value) return <Icons.ZapOff className="text-muted-foreground" size={48} />; | ||
return <Icons.Zap className="text-yellow-400" size={48} />; | ||
} | ||
|
||
function Settings() { | ||
const { pane, settings } = useNodeSettings<RelayData>(); | ||
const pins = usePins(); | ||
|
||
useEffect(() => { | ||
if (!pane) return; | ||
|
||
const pinBinding = pane.addBinding(settings, 'pin', { | ||
view: 'list', | ||
disabled: !pins.length, | ||
label: 'pin', | ||
index: 0, | ||
options: pins | ||
.filter(pin => pin.supportedModes.includes(MODES.OUTPUT)) | ||
.map(mapPinToPaneOption), | ||
}); | ||
|
||
const typeBinding = pane.addBinding(settings, 'type', { | ||
view: 'list', | ||
disabled: !pins.length, | ||
label: 'mode', | ||
index: 1, | ||
options: [ | ||
{ value: 'NO', text: 'Normally open' }, | ||
{ value: 'NC', text: 'Normally closed' }, | ||
], | ||
}); | ||
|
||
return () => { | ||
pinBinding.dispose(); | ||
typeBinding.dispose(); | ||
}; | ||
}, [settings, pane, pins]); | ||
|
||
return null; | ||
} | ||
|
||
type Props = BaseNode<RelayData>; | ||
Relay.defaultProps = { | ||
data: { | ||
group: 'hardware', | ||
label: 'Relay', | ||
pin: 10, | ||
tags: ['analog', 'digital', 'output'], | ||
type: 'NO', | ||
} satisfies Props['data'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
apps/nextjs-app/app/docs/microflow-studio/nodes/external/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: External nodes | ||
--- | ||
|
||
External nodes allow you to interact with external services. These nodes are the bridge between your microflow and the outside world. |
9 changes: 9 additions & 0 deletions
9
apps/nextjs-app/app/docs/microflow-studio/nodes/flow/calculate/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Calculate | ||
--- | ||
|
||
{% tags %} | ||
{% tag title="Control" /%} | ||
{% /tags %} | ||
|
||
The `Calculate` node allows you to perform mathematical operations on the input data. You can use this node for example to add, subtract, multiply, or divide numbers. |
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
apps/nextjs-app/app/docs/microflow-studio/nodes/flow/constant/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Constant | ||
--- | ||
|
||
{% tags %} | ||
{% tag title="Generator" /%} | ||
{% /tags %} | ||
|
||
A constant value which can be used as input for other nodes. This node is useful when you want to use a fixed value in your microflow. | ||
|
||
This could be useful in combination with the [`Calculate`](/docs/microflow-studio/nodes/flow/calculate) node to perform mathematical operations on the constant value. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
apps/nextjs-app/app/docs/microflow-studio/nodes/flow/note/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Note | ||
--- | ||
|
||
{% tags %} | ||
{% tag title="Information" /%} | ||
{% /tags %} | ||
|
||
For complex flows or to provide additional information, you can add a note to the flow. This note is not visible in the flow execution, but it can be used to document the flow. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Flow nodes | ||
--- | ||
|
||
Flow nodes allow you to direct the flow of data. Manipulate, transform, (re-)direct or filter data as it flows through your microflow. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
apps/nextjs-app/app/docs/microflow-studio/nodes/hardware/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: Hardware nodes | ||
--- | ||
|
||
Hardware nodes allows you to connect your microcontroller to various hardware components like sensors, actuators, and displays. These nodes are the building blocks of your hardware project. |
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
apps/nextjs-app/app/docs/microflow-studio/nodes/hardware/relay/page.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: Relay | ||
--- | ||
|
||
{% tags %} | ||
{% tag title="Analog" /%} | ||
{% tag title="Digital" /%} | ||
{% tag title="Output" /%} | ||
{% /tags %} | ||
|
||
|
||
Control high voltage devices with a relay. A relay is an electrically operated switch that allows you to control a high-power circuit with a low-power signal -- like that from a microcontroller. | ||
|
||
{% callout type="warning" title="DANGER: LETHAL VOLTAGE" %} | ||
Working with high voltage can be `DEADLY`. Even a momentary lapse in caution can result in severe injury or `DEATH`. | ||
|
||
Never attempt to handle high voltage circuits without proper knowledge and always work under the supervision of a qualified expert. Your life is on the line. | ||
{% /callout %} | ||
|
||
## Resources | ||
|
||
- [Johnny-Five](https://johnny-five.io/api/relay/) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.