MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / deltaRead

Method deltaRead

libraries/MCP_ADC/MCP_ADC.cpp:101–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100
101int16_t MCP_ADC::deltaRead(uint8_t channel)
102{
103 if (channel >= _channels) return 0;
104
105 int16_t val0 = differentialRead(channel & 0xFE);
106 // int16_t val1 = differentialRead(channel | 0x01);
107 // no need to read if val0 has a positive value
108 int16_t val1 = (val0 > 0) ? 0 : differentialRead(channel | 0x01);
109
110 if (channel & 0x01) return val1 - val0;
111 return val0 - val1;
112}
113
114
115void MCP_ADC::setSPIspeed(uint32_t speed)

Callers 1

unittestFunction · 0.80

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.64