From 29c442f32c1716fd680f70ba66ef1cb91b6ee4c2 Mon Sep 17 00:00:00 2001 From: Greg Cormier Date: Sun, 26 Feb 2023 10:53:10 -0500 Subject: [PATCH 1/3] panel fab --- .github/workflows/fabrication-panel.yml | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/fabrication-panel.yml diff --git a/.github/workflows/fabrication-panel.yml b/.github/workflows/fabrication-panel.yml new file mode 100644 index 0000000..9f1ba8e --- /dev/null +++ b/.github/workflows/fabrication-panel.yml @@ -0,0 +1,68 @@ +name: "Fabrication - Panel" +on: + push: + paths: + - '**.kicad_sch' + - '**.kicad_pcb' + - '**kibot.yaml' + pull_request: + paths: + - '**.kicad_sch' + - '**.kicad_pcb' + - '**kibot.yaml' + tags: + - pcb-v* + workflow_dispatch: + workflow_call: + +env: + BaseFileName: megadesk + Timezone: America/Toronto + PanelFolder: pcb/panel_output + runs-on: ubuntu-latest + +jobs: + make_panel: + name: Create panel + runs-on: ubuntu-latest + + steps: + # Check out the files + - uses: actions/checkout@v3 + + # Generate the panel first + - name: KiBot + uses: INTI-CMNB/KiBot@v2_k6 + with: + config: pcb/kibot-panel.yaml + dir: ${{ env.PanelFolder }} + schema: pcb/${{ env.BaseFileName }}.kicad_sch + board: pcb/${{ env.BaseFileName }}.kicad_pcb + + # Get the current date and time, in the timezone specified above, for use later. + - name: Get current date and time + id: date + run: echo "date=$(TZ='${{ env.Timezone }}' date +'%Y-%m-%d %T')" >> $GITHUB_OUTPUT + + # Get the current date + - name: Get current date + id: date_only + run: echo "date_only=$(TZ='${{ env.Timezone }}' date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + + # Generate fab output based on panel + - name: KiBot + uses: INTI-CMNB/KiBot@v2_k6 + with: + config: pcb/kibot.yaml + dir: ${{ env.PanelFolder }} + schema: pcb/megadesk_panel.kicad_sch + board: pcb/megadesk_panel.kicad_pcb + + # Archive all the artifacts from output and attach to the action's results. + - name: Archive production artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BaseFileName }}-panel-fab-${{ steps.date_only.outputs.date_only }} + path: ${{ env.PanelFolder }}/** + + \ No newline at end of file From c991ee08b7e0caf5b3419b6ed3c457c580bb7210 Mon Sep 17 00:00:00 2001 From: AnAnalogGuy <70239317+AnAnalogGuy@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:55:57 +0100 Subject: [PATCH 2/3] Add files via upload --- esphome/megadesk.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 esphome/megadesk.h diff --git a/esphome/megadesk.h b/esphome/megadesk.h new file mode 100644 index 0000000..28e88e0 --- /dev/null +++ b/esphome/megadesk.h @@ -0,0 +1,84 @@ +#include "esphome.h" + +class Megadesk : public Component, public Sensor, public UARTDevice { + public: + Megadesk(UARTComponent *parent) : UARTDevice(parent) {} + + Sensor *raw_height = new Sensor(); + Sensor *min_height = new Sensor(); + Sensor *max_height = new Sensor(); + + void setup() override {} + + int digits=0; + + int readdigits() + { + int r; + while ((r = read()) > 0) { + if ((r < 0x30) || (r > 0x39)) { + // non-digit we're done, return what we have + return digits; + } + // it's a digit, add with base10 shift + digits = 10*digits + (r-0x30); + // keep reading... + } + return -1; + } + + void recvData() + { + const int numChars = 2; + const int numFields = 4; // read/store all 4 fields for simplicity, use only the last 3. + // static variables allows segmented/char-at-a-time decodes + static uint16_t receivedBytes[numFields]; + static uint8_t ndx = 0; + int r; // read char/digit + + // read 2 chars + while ((ndx < numChars) && ((r = read()) != -1)) + { + if ((ndx == 0) && (r != '>')) + { + // first char is not Tx, keep reading... + continue; + } + receivedBytes[ndx] = r; + ++ndx; + } + // read ascii digits + while ((ndx >= numChars) && ((r = readdigits()) != -1)) { + receivedBytes[ndx] = r; + digits = 0; // clear + if (++ndx == numFields) { + // thats all 4 fields. parse/process them now and break-out. + parseData(receivedBytes[1], + receivedBytes[2], + receivedBytes[3]); + ndx = 0; + return; + } + } + } + + void parseData(byte command, uint16_t position, uint8_t push_addr) + { + if (command == '=') + { + raw_height->publish_state(position); + } else if (command == 'R'){ + if (push_addr == 11){ + min_height->publish_state(position); + } else if (push_addr == 12){ + max_height->publish_state(position); + } + } + } + + void loop() override { + while (available()) { + recvData(); + } + } +}; \ No newline at end of file From f8e65d103a3e513f89ce4f88ac627ded634a9e7b Mon Sep 17 00:00:00 2001 From: AnAnalogGuy <70239317+AnAnalogGuy@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:57:17 +0100 Subject: [PATCH 3/3] Add files via upload --- esphome/megadesk.yaml | 172 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 esphome/megadesk.yaml diff --git a/esphome/megadesk.yaml b/esphome/megadesk.yaml new file mode 100644 index 0000000..cc2f38d --- /dev/null +++ b/esphome/megadesk.yaml @@ -0,0 +1,172 @@ +esphome: + name: megadesk + comment: ESPHome Device controlling Megadesk controller + platform: ESP8266 + # details on how to find/select your board can be found at https://esphome.io/components/esp8266.html + board: d1_mini + includes: + - megadesk.h + on_boot: + priority: -100 + then: + - delay: 1s + - uart.write: "raw_height, megadesk->min_height, megadesk->max_height }; + sensors: + - id: megadesk_raw + internal: true + on_value: + then: + - component.update: megadesk_height_inches + - component.update: megadesk_height_cm + - component.update: megadesk_height_raw + - name: "Megadesk Minimum Height" + - name: "Megadesk Maximum Height" + +number: + - platform: template + name: "Megadesk Height (inches)" + id: megadesk_height_inches + min_value: 23 + max_value: 47 + step: 0.53 + mode: slider + update_interval: never + unit_of_measurement: 'inches' + #NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin + lambda: |- + return ((((id(megadesk_raw).state - 299) * (47 - 23)) / (6914 - 299)) + 23); + set_action: + - number.set: + id: megadesk_height_raw + value: !lambda "return int((((x - 23) * (6914 - 299)) / (47 - 23)) + 299);" + - platform: template + name: "Megadesk Height (cm)" + id: megadesk_height_cm + min_value: 58.42 + max_value: 118.745 + step: 0.53 + mode: slider + update_interval: never + unit_of_measurement: 'cm' + #NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin + lambda: |- + return ((((id(megadesk_raw).state - 299) * (119.38 - 58.42)) / (6914 - 299)) + 58.42); + set_action: + - number.set: + id: megadesk_height_raw + value: !lambda "return int((((x - 58.42) * (6640 - 299)) / (119.38 - 58.42)) + 299);" + - platform: template + name: "Megadesk Height (raw)" + id: megadesk_height_raw +# internal: true + min_value: 299 + max_value: 6640 + step: 1 + mode: slider + update_interval: never + lambda: |- + return id(megadesk_raw).state; + set_action: + - uart.write: !lambda |- + char buf[20]; + sprintf(buf, "<=%i,.", int(x)); + std::string s = buf; + return std::vector( s.begin(), s.end() ); + +button: + - platform: template + name: "Desk Position 2" + on_press: + then: + - uart.write: "