]> git.gag.com Git - fw/quantimotor/commitdiff
turn on systemd support, delivery a service, startup file, and module loader
authorBdale Garbee <bdale@gag.com>
Sat, 5 Apr 2025 04:35:03 +0000 (22:35 -0600)
committerBdale Garbee <bdale@gag.com>
Sat, 5 Apr 2025 04:35:03 +0000 (22:35 -0600)
debian/quantimotor.install
debian/rules
enable_ads.py [new file with mode: 0755]
quantimotor.conf [new file with mode: 0644]
startup [new file with mode: 0644]

index 2a45b1b975a615275bbe810faede05f269e8ed0a..cc50a7469424021662ac1b4dc8ed6e5ade2928cb 100644 (file)
@@ -1,4 +1,7 @@
 bcm2837-rpi-zero-2-w.dtb usr/share/quantimotor
+enable_ads.py usr/share/quantimotor
+quantimotor.conf etc/modules-load.d
 raspi-extra-cmdline etc/default
 raspi-firmware-custom etc/default
+startup usr/share/quantimotor
 z99-quantimotor etc/kernel/postinst.d
index eb2b855b6ab77fca42044e28b3e8c500fece43d4..59a5b1f35bae1d3cf137b9863635d7151b0b5268 100755 (executable)
@@ -3,5 +3,5 @@
 export DH_VERBOSE = 1
 
 %:
-       dh $@
+       dh $@ --with=systemd
 
diff --git a/enable_ads.py b/enable_ads.py
new file mode 100755 (executable)
index 0000000..e5a9120
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+# Copyright (C) 2025 Bdale Garbee <bdale@gag.com>.  GPLv3+
+
+import gpiod
+import iio
+import signal
+import sys
+import time
+
+ctx = iio.LocalContext()
+ctrl = ctx.find_device('ads8688')
+
+# configuration for each channel on ADS8688
+OFFSET = "0"
+SCALE = "0.078127104"
+VOLTAGES = ['voltage0', 'voltage1', 'voltage2', 'voltage3', 'voltage4', 'voltage5', 'voltage6', 'voltage7']
+
+from gpiod.line import Direction, Value
+
+def set_line_values(chip_path, line_values):
+    value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
+
+    request = gpiod.request_lines(
+        chip_path,
+        consumer=sys.argv[0],
+        config={
+            tuple(line_values.keys()): gpiod.LineSettings(direction=Direction.OUTPUT)
+        },
+    )
+    request.set_values(line_values)
+
+if __name__ == "__main__":
+    try:
+        # initialize hardware
+        set_line_values(
+            "/dev/gpiochip0", 
+            {25: Value.ACTIVE,         # take ADS8688 out of reset
+              4: Value.ACTIVE,         # indicate 'ready' to LPC
+             16: Value.INACTIVE,       # pyro off
+             17: Value.INACTIVE,       # alarm b off
+             20: Value.INACTIVE,       # turn continuity LED off
+             21: Value.INACTIVE,       # turn armed LED off
+             27: Value.INACTIVE                # alarm a off
+            }
+        )
+
+        # configure ADC channels
+        for id in VOLTAGES:
+            chan = ctrl.find_channel(id)
+            # must set scale before offset, so offset 0 is valid!
+            chan.attrs['scale'].value = SCALE
+            chan.attrs['offset'].value = OFFSET
+
+        print('ADS set up .. do your thing!')
+
+
+    except OSError as ex:
+        print(ex, "\nD'oh!")
+
diff --git a/quantimotor.conf b/quantimotor.conf
new file mode 100644 (file)
index 0000000..8dccec1
--- /dev/null
@@ -0,0 +1 @@
+iio-trig-hrtimer
diff --git a/startup b/startup
new file mode 100644 (file)
index 0000000..df373db
--- /dev/null
+++ b/startup
@@ -0,0 +1,6 @@
+#!/bin/sh 
+
+# set up gpio lines, enabling ADC and setting channel parameters
+# /usr/share/quantimotor/enable_ads.py
+
+echo "quantimotor startup script ran" > /tmp/status