Skip to content

Commit 4371949

Browse files
committed
Adjust ADC scaling based on kernel version
The older Linux 3.8.13 kernel produced raw ADC value of 0 to 1800. Newer Linux 4.1+ kernels produce ADC value of 0 to 4095.
1 parent 50e8883 commit 4371949

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

source/py_adc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ static PyObject *py_read(PyObject *self, PyObject *args)
8686
}
8787

8888
//scale modifier
89+
#ifdef BBBVERSION41
8990
value = value / 4095.0;
91+
#else
92+
value = value / 1800.0;
93+
#endif
9094

9195
py_value = Py_BuildValue("f", value);
9296

0 commit comments

Comments
 (0)