Skip to content

Commit 3986407

Browse files
mnishiguchifhunleth
authored andcommitted
fix(veml7700): broken render function
1 parent fe17294 commit 3986407

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/circuits_sim/device/veml7700.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ defmodule CircuitsSim.Device.VEML7700 do
124124

125125
@impl I2CDevice
126126
def render(state) do
127-
light_lux = Float.round(state.light_lux * 1.0, 3)
128-
"Light: #{light_lux} lux"
127+
"Ambient light sensor raw output: #{state.als_output}"
129128
end
130129

131130
@impl I2CDevice

test/circuits_sim/device/veml7700_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ defmodule CircuitsSim.Device.VEML7700Test do
1515
[i2c_bus: i2c_bus]
1616
end
1717

18+
test "setting VEML7700 state", %{i2c_bus: i2c_bus} do
19+
VEML7700Sim.set_state(i2c_bus, @i2c_address, als_output: 123)
20+
assert I2CServer.render(i2c_bus, @i2c_address) == "Ambient light sensor raw output: 123"
21+
end
22+
1823
test "reads and writes registers", %{i2c_bus: i2c_bus} do
1924
VEML7700Sim.set_state(i2c_bus, @i2c_address, als_config: 0, als_output: 440)
2025

test/circuits_sim_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
defmodule CircuitsSimTest do
22
use ExUnit.Case
33
doctest CircuitsSim
4+
5+
test "info/0 does not crash" do
6+
CircuitsSim.info()
7+
end
48
end

0 commit comments

Comments
 (0)