Skip to content

Commit

Permalink
Merge pull request #15 from EdgePi-Cloud/dev-fix-dac-inputs
Browse files Browse the repository at this point in the history
Dev update RPC server description
  • Loading branch information
jimmy121192 authored Jan 22, 2024
2 parents 46c8d20 + a43324e commit d4e3661
Show file tree
Hide file tree
Showing 7 changed files with 3,814 additions and 382 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/create-release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will create a new tag based on latest commit to branch

name: Create Release Tag

on:
push:
branches:
- main

jobs:
build-and-publish:
name: Create Release Tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
- name: Get Current Version
run: echo "current_version=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
- name: Create Release Tag
env:
commit_name: bot-edgepi
commit_email: [email protected]
username: bot-edgepi
run: |
git config user.name ${{ env.commit_name }}
git config user.email ${{ env.commit_email }}
git tag -a release/v${{ env.current_version }} -m "tag release version ${{ env.current_version }}"
git push origin release/v${{ env.current_version }}
24 changes: 17 additions & 7 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ on:
push:
branches:
- main
tags:
- release/*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public
node-version: "16.x"
registry-url: "https://registry.npmjs.org"

- name: Publish Package to npm
run: |
npm ci
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release Package
uses: ncipollo/[email protected]
3 changes: 1 addition & 2 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14 # Adjust this to your desired Node.js version
node-version: 16 # Adjust this to your desired Node.js version

- name: Set Git user information
run: |
Expand Down Expand Up @@ -59,7 +59,6 @@ jobs:
version=$(cat package.json | jq -r '.version')
git add .
git commit -m "Bump version to $version"
git push --follow-tags
git push --force origin "$branch_name":dev
- name: Delete versioned branch
Expand Down
20 changes: 11 additions & 9 deletions edgepi-dac.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
transport: { value: "Local" },
tcpAddress: { value: "" },
tcpPort: { value: "" },
voltage: {},
voltage: { value: 0 },
channel: { value: 1 },
gain: { value: false },
},
Expand All @@ -18,12 +18,10 @@
return this.name || "dac";
},
oneditprepare: function () {
const configTransportSelect = document.getElementById(
"node-input-transport"
);
const transportType = document.getElementById("node-input-transport");
const gainOff = document.getElementById("node-input-gainOff");
const gainOn = document.getElementById("node-input-gainOn");
const tcpField = document.querySelector(".form-row.tcp");
const tcpTransportInputs = document.querySelector(".form-row.tcp");
const voltageGainOff = document.querySelector(".form-row.voltageGainOff");
const voltageGainOn = document.querySelector(".form-row.voltageGainOn");

Expand All @@ -34,8 +32,8 @@
}

function updateEditor() {
tcpField.style.display =
configTransportSelect.value === "Network" ? "flex" : "none";
tcpTransportInputs.style.display =
transportType.value === "Network" ? "flex" : "none";
const selectedGain = !gainOff.checked;
voltageGainOff.style.display = !selectedGain ? "flex" : "none";
voltageGainOn.style.display = selectedGain ? "flex" : "none";
Expand All @@ -46,7 +44,7 @@
this.gain ? "node-input-voltageGainOn" : "node-input-voltageGainOff"
).value = this.voltage;

configTransportSelect.addEventListener("change", updateEditor);
transportType.addEventListener("change", updateEditor);
gainOff.addEventListener("change", updateEditor);
gainOn.addEventListener("change", updateEditor);
},
Expand Down Expand Up @@ -190,7 +188,11 @@
<h3>Properties</h3>
<dl class="message-properties">
<dt>RPC Server</dt>
<dd>The connection to your EdgePi's RPC Server.</dd>
<dd>
The connection to your EdgePi's RPC Server. Use <strong>Local</strong> if
node-red is running on EdgePi. Otherwise use the
<strong>Network</strong> option and enter EdgePi's IP address / Hostname.
</dd>
<dt>Channel</dt>
<dd>The EdgePi channel to write voltage to.</dd>
<dt>Output Voltage<span class="property-type">number</span></dt>
Expand Down
17 changes: 11 additions & 6 deletions edgepi-dac.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ module.exports = function (RED) {
function DacNode(config) {
RED.nodes.createNode(this, config);
const node = this;
let voltage = config.voltage;
let gain = config.gain;
let channel = config.channel;
let { voltage, gain, channel } = config;

initializeNode(config).then((dac) => {
node.on("input", async function (msg, send, done) {
node.status({ fill: "green", shape: "dot", text: "input received" });
try {
gain = msg.gain || gain;
voltage = msg.payload || voltage;
channel = msg.channel || channel;
if (msg.payload) {
voltage = msg.payload;
}
if (typeof msg.gain === "boolean") {
gain = msg.gain;
}
if (msg.channel) {
channel = msg.channel;
}

if ((gain && voltage > 10) || (!gain && voltage > 5) || voltage < 0) {
throw new Error(
`Voltage being written is outside the valid range ${
Expand Down
Loading

0 comments on commit d4e3661

Please sign in to comment.