Skip to content

Instantly share code, notes, and snippets.

@johnty
Created April 6, 2017 18:00
Show Gist options
  • Select an option

  • Save johnty/4f5d0919628a8ca418580be076f8e7d9 to your computer and use it in GitHub Desktop.

Select an option

Save johnty/4f5d0919628a8ca418580be076f8e7d9 to your computer and use it in GitHub Desktop.
Wolfram Connected Device Driver for PiShield A2D (MCP3008), using wiringpi GPIO command
(* until we figure out how to pass strings to ext commands, this bit is hard coded *)
readsensor[_, x_] :=
(<<"!gpio -x mcp3004:100:0 aread 100")
readsensor[_, 0] :=
(<<"!gpio -x mcp3004:100:0 aread 100")
readsensor[_, 1] :=
(<<"!gpio -x mcp3004:100:0 aread 101")
readsensor[_, 2] :=
(<<"!gpio -x mcp3004:100:0 aread 102")
readsensor[_, 3] :=
(<<"!gpio -x mcp3004:100:0 aread 103")
readsensor[_, 4] :=
(<<"!gpio -x mcp3004:100:0 aread 104")
readsensor[_, 5] :=
(<<"!gpio -x mcp3004:100:0 aread 105")
readsensor[_, 6] :=
(<<"!gpio -x mcp3004:100:0 aread 106")
readsensor[_, 7] :=
(<<"!gpio -x mcp3004:100:0 aread 107")
DeviceFramework`DeviceClassRegister["PiShield","ReadFunction"->readsensor];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment