@@ -6,51 +6,29 @@ defmodule AHT20.Calc do
6
6
@ doc """
7
7
Calculates the relative humidity in percent.
8
8
9
- iex> AHT20.Calc.relative_humidity (158119)
9
+ iex> AHT20.Calc.humidity_rh_from_raw (158119)
10
10
15.079402923583984
11
11
"""
12
- @ spec relative_humidity ( integer ) :: float
13
- def relative_humidity ( raw_humidity ) , do: raw_humidity / 1_048_576.0 * 100.0
12
+ @ spec humidity_rh_from_raw ( integer ) :: float
13
+ def humidity_rh_from_raw ( raw_humidity ) , do: raw_humidity / 1_048_576.0 * 100.0
14
14
15
15
@ doc """
16
16
Calculates the temperature in Celsius.
17
17
18
- iex> AHT20.Calc.celsius_from_raw_temperature (410343)
18
+ iex> AHT20.Calc.temperature_c_from_raw (410343)
19
19
28.26671600341797
20
20
"""
21
- @ spec celsius_from_raw_temperature ( integer ) :: float
22
- def celsius_from_raw_temperature ( raw_temperature ) , do: raw_temperature / 1_048_576.0 * 200.0 - 50.0
21
+ @ spec temperature_c_from_raw ( integer ) :: float
22
+ def temperature_c_from_raw ( raw_temperature ) , do: raw_temperature / 1_048_576.0 * 200.0 - 50.0
23
23
24
24
@ doc """
25
25
Calculates the temperature in Fahrenheit.
26
26
27
- iex> AHT20.Calc.fahrenheit_from_raw_temperature (410343)
27
+ iex> AHT20.Calc.temperature_f_from_raw (410343)
28
28
82.88008880615234
29
29
"""
30
- @ spec fahrenheit_from_raw_temperature ( integer ) :: float
31
- def fahrenheit_from_raw_temperature ( raw_temperature ) do
32
- celsius_from_raw_temperature ( raw_temperature ) * 9.0 / 5.0 + 32.0
33
- end
34
-
35
- @ doc """
36
- Obtains the humidity value from the sensor output.
37
-
38
- iex> AHT20.Calc.raw_humidity_from_sensor_output(<<28, 38, 154, 118, 66, 231, 118>>)
39
- 158119
40
- """
41
- @ spec raw_humidity_from_sensor_output ( << _ :: 56 >> ) :: integer ( )
42
- def raw_humidity_from_sensor_output ( << _state , humidity :: 20 , _temperature :: 20 , _crc >> ) do
43
- humidity
44
- end
45
-
46
- @ doc """
47
- Obtains the temperature value from the sensor output.
48
-
49
- iex> AHT20.Calc.raw_temperature_from_sensor_output(<<28, 38, 154, 118, 66, 231, 118>>)
50
- 410343
51
- """
52
- @ spec raw_temperature_from_sensor_output ( << _ :: 56 >> ) :: integer ( )
53
- def raw_temperature_from_sensor_output ( << _state , _humidity :: 20 , temperature :: 20 , _crc >> ) do
54
- temperature
30
+ @ spec temperature_f_from_raw ( integer ) :: float
31
+ def temperature_f_from_raw ( raw_temperature ) do
32
+ temperature_c_from_raw ( raw_temperature ) * 9.0 / 5.0 + 32.0
55
33
end
56
34
end
0 commit comments