Skip to content

Commit 92c2c9c

Browse files
baptleducbenpicco
andcommitted
refactor: switch ADS1115 PGA return values from float (V) to int (mV)
Co-authored-by: benpicco <[email protected]>
1 parent 34b4ba1 commit 92c2c9c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/include/ads1115.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,20 @@ int ads1115_set_ain_ch_input(ads1115_t *dev, ads1115_mux_t mux);
198198
*/
199199
int ads1115_read_conversion(ads1115_t *dev, uint16_t *value);
200200

201-
202-
static inline float _ads1115_get_pga_voltage(ads1115_pga_t pga)
201+
static inline int _ads1115_get_pga_voltage(ads1115_pga_t pga)
203202
{
204203
switch (pga) {
205-
case ADS1115_PGA_6_144V: return 6.144f;
206-
case ADS1115_PGA_4_096V: return 4.096f;
207-
case ADS1115_PGA_2_048V: return 2.048f;
208-
case ADS1115_PGA_1_024V: return 1.024f;
209-
case ADS1115_PGA_0_512V: return 0.512f;
204+
case ADS1115_PGA_6_144V: return 6144;
205+
case ADS1115_PGA_4_096V: return 4096;
206+
case ADS1115_PGA_2_048V: return 2048;
207+
case ADS1115_PGA_1_024V: return 1024;
208+
case ADS1115_PGA_0_512V: return 512;
210209
case ADS1115_PGA_0_256V:
211210
case ADS1115_PGA_0_256V_B:
212211
case ADS1115_PGA_0_256V_C:
213-
return 0.256f;
212+
return 256;
214213
default:
215-
return 0.0f;
214+
return 0;
216215
}
217216
}
218217

0 commit comments

Comments
 (0)