CCS811 support (#536)

* CCS811

* Move define, add test

* Remove sun artifact

* Lint

* Lint
This commit is contained in:
Otto Winter
2019-05-13 13:06:14 +02:00
committed by GitHub
parent 855e9367d4
commit 0281914507
9 changed files with 255 additions and 0 deletions
+7
View File
@@ -307,4 +307,11 @@ bool str_endswith(const std::string &full, const std::string &ending) {
return full.rfind(ending) == (full.size() - ending.size());
}
uint16_t encode_uint16(uint8_t msb, uint8_t lsb) { return (uint16_t(msb) << 8) | uint16_t(lsb); }
std::array<uint8_t, 2> decode_uint16(uint16_t value) {
uint8_t msb = (value >> 8) & 0xFF;
uint8_t lsb = (value >> 0) & 0xFF;
return {msb, lsb};
}
} // namespace esphome
+5
View File
@@ -127,6 +127,11 @@ uint8_t reverse_bits_8(uint8_t x);
uint16_t reverse_bits_16(uint16_t x);
uint32_t reverse_bits_32(uint32_t x);
/// Encode a 16-bit unsigned integer given a most and least-significant byte.
uint16_t encode_uint16(uint8_t msb, uint8_t lsb);
/// Decode a 16-bit unsigned integer into an array of two values: most significant byte, least significant byte.
std::array<uint8_t, 2> decode_uint16(uint16_t value);
/** Cross-platform method to disable interrupts.
*
* Useful when you need to do some timing-dependent communication.