added new max1227 helper functions

This commit is contained in:
2022-02-17 20:42:53 +01:00
parent ae4d1e6db3
commit 49decb8e9a
2 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "max1227.h"
#include <cstring>
uint8_t max1227::buildConvByte(ScanModes scanMode, uint8_t channel, bool readTemp) {
return (1 << 7) | (channel << 3) | (scanMode << 1) | readTemp;
}
@ -26,3 +28,11 @@ void max1227::prepareExternallyClockedRead0ToN(uint8_t *spiBuf, uint8_t n, size_
spiBuf[(n + 1) * 2] = 0x00;
sz = (n + 1) * 2 + 1;
}
void max1227::prepareExternallyClockedTemperatureRead(uint8_t *spiBuf, size_t &sz) {
spiBuf[0] = buildConvByte(ScanModes::N_ONCE, 0, true);
std::memset(spiBuf + 1, 0, 24);
sz = 25;
}
float max1227::getTemperature(int16_t temp) { return static_cast<float>(temp) * 0.125; }