@@ -4,6 +4,40 @@ Interact with simulated I2C devices
44
55NOTE: This project is an active development. Expect big API changes as we use it.
66
7+ ## Using
8+
9+ CircuitsSim requires Elixir Circuits 2.0 libraries. Currently, this requires the
10+ following in your ` mix.exs ` :
11+
12+ ``` elixir
13+ defp deps () do
14+ [
15+ {:circuits_i2c , " ~> 2.0" },
16+ {:circuits_spi , " ~> 2.0.0-pre.0" },
17+ {:circuits_gpio , " ~> 2.0.0-pre.0" }
18+ ]
19+ end
20+ ```
21+
22+ You may need to add ` override: true ` since not many libraries have been updated
23+ to allow Circuits 2.0 versions. The update is generally compatible, so this is
24+ safe.
25+
26+ CircuitsSim works by providing an alternative backend for interacting with
27+ hardware. This is setup via ` config/config.exs ` . In your project, you may only
28+ want the simulated backends for ` MIX_ENV=test ` configurations, so you'll want to
29+ add the following appropriately. For trying it out, it's fine to start with
30+ adding this to ` config.exs ` :
31+
32+ ``` elixir
33+ config :circuits_i2c , default_backend: CircuitsSim .I2C .Backend
34+ config :circuits_spi , default_backend: CircuitsSim .SPI .Backend
35+ config :circuits_gpio , default_backend: CircuitsSim .GPIO .Backend
36+ ```
37+
38+ Note that you don't need to replace all backends. If you're only using I2C,
39+ there's no need to bring in SPI and GPIO support.
40+
741## Demo
842
943CircuitsSim takes a configuration for how to set up the simulated I2C buses and
0 commit comments