I’ve spotted a couple of minor issues with the setScanLimit() and setIntensity() methods. The test ‘limit>=0 || limit<8’ on line 88 is always true, so spiTransfer is called even with bad limit values. Line 88 should be corrected as shown below:
if(limit>=0 && limit<8)
Similarly, on line 95 there is a test ‘intensity>=0 || intensity<16’ which is always true no matter what. Line 95 should be corrected as shown below:
if(intensity>=0 && intensity<16)