small changes and many new sensors

This commit is contained in:
2023-10-30 14:30:02 +01:00
parent 07917fe5ba
commit aad07c1b0a
21 changed files with 1642 additions and 297 deletions

View File

@@ -100,6 +100,7 @@
#include "driver/gpio.h"
#include "esp8266/gpio_struct.h"
struct MyGPIO {
static inline bool get(const uint8_t num) {
@@ -166,6 +167,11 @@
ESP_ERROR_CHECK(gpio_config(&io_conf));
}
static void setBuiltInLED(bool on) {
setOutput(GPIO_NUM_2);
if (on) {clear(GPIO_NUM_2);} else {set(GPIO_NUM_2);}
}
static void toggleBuiltInLED() {
static bool level = false;
setOutput(GPIO_NUM_2);
@@ -179,6 +185,7 @@
#elif IS_ESP32
#include "driver/gpio.h"
#include "soc/gpio_reg.h"
// NOTE from the manual
// GPIO 6-11 are usually used for SPI flash.

View File

@@ -157,7 +157,7 @@ public:
Log::addInfo(NAME, "found %d", i);
}
waitLong();
if (i%16 == 0) {delay(10);}
//if (i%16 == 0) {DELAY_MS(10);}
}
}
@@ -219,6 +219,44 @@ public:
public:
/** similar to readReg() but without actually selecting a register */
bool readRaw(const uint8_t addr, const uint8_t len, uint8_t* dst) {
bool ok;
ok = startWrite(addr);
if (!ok) {Log::addInfo(NAME, "failed start read(1)"); return false;}
stop();
ok = startRead(addr);
if (!ok) {Log::addInfo(NAME, "failed start read(2)"); return false;}
readBytes(dst, len);
stop();
return true;
}
/** similar to writeReg() but without actually selecting a register */
bool writeRaw(const uint8_t addr, const uint8_t len, const uint8_t* src) {
bool ok;
// address the slave in write mode and select the first register to read
ok = startWrite(addr);
if (!ok) {Log::addInfo(NAME, "failed start write"); return false;}
ok = writeBytesAndCheck(src, len);
if (!ok) {Log::addInfo(NAME, "failed to write register contents"); return false;}
stop();
return true;
}