mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 10:21:40 +00:00
Revert "remember which devices were scanned on which bus and set them accordingly." - this is not working at all.
This commit is contained in:
parent
037d6c253b
commit
6a696af8f6
@ -44,25 +44,25 @@ void printATECCInfo()
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length, TwoWire myWire) {
|
||||
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
|
||||
uint16_t value = 0x00;
|
||||
myWire.beginTransmission(address);
|
||||
myWire.write(reg);
|
||||
myWire.endTransmission();
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(reg);
|
||||
Wire.endTransmission();
|
||||
delay(20);
|
||||
myWire.requestFrom(address, length);
|
||||
DEBUG_MSG("Wire.available() = %d\n", myWire.available());
|
||||
if (myWire.available() == 2) {
|
||||
Wire.requestFrom(address, length);
|
||||
DEBUG_MSG("Wire.available() = %d\n", Wire.available());
|
||||
if (Wire.available() == 2) {
|
||||
// Read MSB, then LSB
|
||||
value = (uint16_t)myWire.read() << 8;
|
||||
value |= myWire.read();
|
||||
} else if (myWire.available()) {
|
||||
value = myWire.read();
|
||||
value = (uint16_t)Wire.read() << 8;
|
||||
value |= Wire.read();
|
||||
} else if (Wire.available()) {
|
||||
value = Wire.read();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
uint8_t oled_probe(byte addr, TwoWire myWire)
|
||||
uint8_t oled_probe(byte addr)
|
||||
{
|
||||
uint8_t r = 0;
|
||||
uint8_t r_prev = 0;
|
||||
@ -70,12 +70,12 @@ uint8_t oled_probe(byte addr, TwoWire myWire)
|
||||
uint8_t o_probe = 0;
|
||||
do {
|
||||
r_prev = r;
|
||||
myWire.beginTransmission(addr);
|
||||
myWire.write(0x00);
|
||||
myWire.endTransmission();
|
||||
myWire.requestFrom((int)addr, 1);
|
||||
if (myWire.available()) {
|
||||
r = myWire.read();
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom((int)addr, 1);
|
||||
if (Wire.available()) {
|
||||
r = Wire.read();
|
||||
}
|
||||
r &= 0x0f;
|
||||
|
||||
@ -90,24 +90,24 @@ uint8_t oled_probe(byte addr, TwoWire myWire)
|
||||
return o_probe;
|
||||
}
|
||||
|
||||
void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
void scanI2Cdevice(bool partial)
|
||||
{
|
||||
byte err, addr;
|
||||
uint16_t registerValue = 0x00;
|
||||
int nDevices = 0;
|
||||
for (addr = 1; addr < 127; addr++) {
|
||||
myWire.beginTransmission(addr);
|
||||
err = myWire.endTransmission();
|
||||
if (partial && addr != SSD1306_ADDRESS && addr != ST7567_ADDRESS && addr != XPOWERS_AXP192_AXP2101_ADDRESS)
|
||||
continue;
|
||||
Wire.beginTransmission(addr);
|
||||
err = Wire.endTransmission();
|
||||
if (err == 0) {
|
||||
DEBUG_MSG("I2C device found at address 0x%x\n", addr);
|
||||
|
||||
i2cScanMap[addr] = {addr, busnum};
|
||||
|
||||
nDevices++;
|
||||
|
||||
if (addr == SSD1306_ADDRESS) {
|
||||
screen_found = addr;
|
||||
screen_model = oled_probe(addr, myWire);
|
||||
screen_model = oled_probe(addr);
|
||||
if (screen_model == 1) {
|
||||
DEBUG_MSG("ssd1306 display found\n");
|
||||
} else if (screen_model == 2) {
|
||||
@ -118,7 +118,8 @@ void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
}
|
||||
#ifndef ARCH_PORTDUINO
|
||||
if (addr == ATECC608B_ADDR) {
|
||||
if (atecc.begin(ATECC608B_ADDR) == true) {
|
||||
keystore_found = addr;
|
||||
if (atecc.begin(keystore_found) == true) {
|
||||
DEBUG_MSG("ATECC608B initialized\n");
|
||||
} else {
|
||||
DEBUG_MSG("ATECC608B initialization failed\n");
|
||||
@ -128,21 +129,24 @@ void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
#endif
|
||||
#ifdef RV3028_RTC
|
||||
if (addr == RV3028_RTC){
|
||||
rtc_found = addr;
|
||||
DEBUG_MSG("RV3028 RTC found\n");
|
||||
Melopero_RV3028 rtc;
|
||||
rtc.initI2C(myWire);
|
||||
rtc.initI2C();
|
||||
rtc.writeToRegister(0x35,0x07); // no Clkout
|
||||
rtc.writeToRegister(0x37,0xB4);
|
||||
}
|
||||
#endif
|
||||
#ifdef PCF8563_RTC
|
||||
if (addr == PCF8563_RTC){
|
||||
rtc_found = addr;
|
||||
DEBUG_MSG("PCF8563 RTC found\n");
|
||||
}
|
||||
#endif
|
||||
if (addr == CARDKB_ADDR) {
|
||||
cardkb_found = addr;
|
||||
// Do we have the RAK14006 instead?
|
||||
registerValue = getRegisterValue(addr, 0x04, 1, myWire);
|
||||
registerValue = getRegisterValue(addr, 0x04, 1);
|
||||
if (registerValue == 0x02) { // KEYPAD_VERSION
|
||||
DEBUG_MSG("RAK14004 found\n");
|
||||
kb_model = 0x02;
|
||||
@ -157,11 +161,12 @@ void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
}
|
||||
#ifdef HAS_PMU
|
||||
if (addr == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||
pmu_found = true;
|
||||
DEBUG_MSG("axp192/axp2101 PMU found\n");
|
||||
}
|
||||
#endif
|
||||
if (addr == BME_ADDR || addr == BME_ADDR_ALTERNATE) {
|
||||
registerValue = getRegisterValue(addr, 0xD0, 1, myWire); // GET_ID
|
||||
registerValue = getRegisterValue(addr, 0xD0, 1); // GET_ID
|
||||
if (registerValue == 0x61) {
|
||||
DEBUG_MSG("BME-680 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = addr;
|
||||
@ -174,7 +179,7 @@ void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
}
|
||||
}
|
||||
if (addr == INA_ADDR || addr == INA_ADDR_ALTERNATE) {
|
||||
registerValue = getRegisterValue(addr, 0xFE, 2, myWire);
|
||||
registerValue = getRegisterValue(addr, 0xFE, 2);
|
||||
DEBUG_MSG("Register MFG_UID: 0x%x\n", registerValue);
|
||||
if (registerValue == 0x5449) {
|
||||
DEBUG_MSG("INA260 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||
@ -221,5 +226,5 @@ void scanI2Cdevice(TwoWire myWire, uint8_t busnum)
|
||||
DEBUG_MSG("%i I2C devices found\n",nDevices);
|
||||
}
|
||||
#else
|
||||
void scanI2Cdevice() {}
|
||||
void scanI2Cdevice(bool partial) {}
|
||||
#endif
|
||||
|
@ -20,16 +20,10 @@ void readFromRTC()
|
||||
{
|
||||
struct timeval tv; /* btw settimeofday() is helpfull here too*/
|
||||
#ifdef RV3028_RTC
|
||||
if(i2cScanMap[RV3028_RTC].addr == RV3028_RTC) {
|
||||
if(rtc_found == RV3028_RTC) {
|
||||
uint32_t now = millis();
|
||||
Melopero_RV3028 rtc;
|
||||
if (i2cScanMap[RV3028_RTC].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
rtc.initI2C(Wire1);
|
||||
#endif
|
||||
} else {
|
||||
rtc.initI2C();
|
||||
}
|
||||
rtc.initI2C();
|
||||
tm t;
|
||||
t.tm_year = rtc.getYear() - 1900;
|
||||
t.tm_mon = rtc.getMonth() - 1;
|
||||
@ -47,16 +41,14 @@ void readFromRTC()
|
||||
}
|
||||
}
|
||||
#elif defined(PCF8563_RTC)
|
||||
if(i2cScanMap[PCF8563_RTC].addr == PCF8563_RTC) {
|
||||
if(rtc_found == PCF8563_RTC) {
|
||||
uint32_t now = millis();
|
||||
PCF8563_Class rtc;
|
||||
if (i2cScanMap[PCF8563_RTC].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
rtc.begin(Wire1);
|
||||
#ifdef RTC_USE_WIRE1
|
||||
rtc.begin(Wire1);
|
||||
#else
|
||||
rtc.begin();
|
||||
#endif
|
||||
} else {
|
||||
rtc.begin();
|
||||
}
|
||||
auto tc = rtc.getDateTime();
|
||||
tm t;
|
||||
t.tm_year = tc.year - 1900;
|
||||
@ -112,29 +104,21 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv)
|
||||
|
||||
// If this platform has a setable RTC, set it
|
||||
#ifdef RV3028_RTC
|
||||
if(i2cScanMap[RV3028_RTC].addr == RV3028_RTC) {
|
||||
if(rtc_found == RV3028_RTC) {
|
||||
Melopero_RV3028 rtc;
|
||||
if (i2cScanMap[RV3028_RTC].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
rtc.initI2C(Wire1);
|
||||
#endif
|
||||
} else {
|
||||
rtc.initI2C();
|
||||
}
|
||||
rtc.initI2C();
|
||||
tm *t = localtime(&tv->tv_sec);
|
||||
rtc.setTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
||||
DEBUG_MSG("RV3028_RTC setTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
||||
}
|
||||
#elif defined(PCF8563_RTC)
|
||||
if(i2cScanMap[PCF8563_RTC].addr == PCF8563_RTC) {
|
||||
if(rtc_found == PCF8563_RTC) {
|
||||
PCF8563_Class rtc;
|
||||
if (i2cScanMap[PCF8563_RTC].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
rtc.begin(Wire1);
|
||||
#ifdef RTC_USE_WIRE1
|
||||
rtc.begin(Wire1);
|
||||
#else
|
||||
rtc.begin();
|
||||
#endif
|
||||
} else {
|
||||
rtc.begin();
|
||||
}
|
||||
tm *t = localtime(&tv->tv_sec);
|
||||
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
||||
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
GxEPD2_BW<TECHO_DISPLAY_MODEL, TECHO_DISPLAY_MODEL::HEIGHT> *adafruitDisplay;
|
||||
|
||||
EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g, HW_I2C i2cBus)
|
||||
EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl)
|
||||
{
|
||||
#if defined(TTGO_T_ECHO)
|
||||
setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT);
|
||||
|
@ -22,7 +22,7 @@ class EInkDisplay : public OLEDDisplay
|
||||
/* constructor
|
||||
FIXME - the parameters are not used, just a temporary hack to keep working like the old displays
|
||||
*/
|
||||
EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g, HW_I2C i2cBus);
|
||||
EInkDisplay(uint8_t address, int sda, int scl);
|
||||
|
||||
// Write the buffer to the display memory (for eink we only do this occasionally)
|
||||
virtual void display(void) override;
|
||||
|
@ -872,7 +872,7 @@ void _screen_header()
|
||||
// }
|
||||
// }
|
||||
// #else
|
||||
Screen::Screen(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g, HW_I2C i2cBus) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl, g, i2cBus), ui(&dispdev)
|
||||
Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev)
|
||||
{
|
||||
address_found = address;
|
||||
cmdQueue.setReader(this);
|
||||
|
@ -115,7 +115,7 @@ class Screen : public concurrency::OSThread
|
||||
CallbackObserver<Screen, const UIFrameEvent *>(this, &Screen::handleUIFrameEvent);
|
||||
|
||||
public:
|
||||
explicit Screen(uint8_t address, int sda = -1, int scl = -1,OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64, HW_I2C i2cBus = I2C_ONE);
|
||||
explicit Screen(uint8_t address, int sda = -1, int scl = -1);
|
||||
|
||||
Screen(const Screen &) = delete;
|
||||
Screen &operator=(const Screen &) = delete;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
static TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
|
||||
|
||||
TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g, HW_I2C i2cBus)
|
||||
TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl)
|
||||
{
|
||||
#ifdef SCREEN_ROTATE
|
||||
setGeometry(GEOMETRY_RAWMODE, TFT_HEIGHT, TFT_WIDTH);
|
||||
|
@ -18,7 +18,7 @@ class TFTDisplay : public OLEDDisplay
|
||||
/* constructor
|
||||
FIXME - the parameters are not used, just a temporary hack to keep working like the old displays
|
||||
*/
|
||||
TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY g, HW_I2C i2cBus);
|
||||
TFTDisplay(uint8_t address, int sda, int scl);
|
||||
|
||||
// Write the buffer to the display memory
|
||||
virtual void display(void) override;
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "cardKbI2cImpl.h"
|
||||
#include "InputBroker.h"
|
||||
|
||||
#if HAS_WIRE
|
||||
|
||||
CardKbI2cImpl *cardKbI2cImpl;
|
||||
|
||||
CardKbI2cImpl::CardKbI2cImpl() :
|
||||
@ -12,7 +10,7 @@ CardKbI2cImpl::CardKbI2cImpl() :
|
||||
|
||||
void CardKbI2cImpl::init()
|
||||
{
|
||||
if (i2cScanMap[CARDKB_ADDR].addr != CARDKB_ADDR)
|
||||
if (cardkb_found != CARDKB_ADDR)
|
||||
{
|
||||
// Input device is not detected.
|
||||
return;
|
||||
@ -20,5 +18,3 @@ void CardKbI2cImpl::init()
|
||||
|
||||
inputBroker->registerSource(this);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,60 +1,52 @@
|
||||
#include "kbI2cBase.h"
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#if HAS_WIRE
|
||||
extern uint8_t cardkb_found;
|
||||
extern uint8_t kb_model;
|
||||
|
||||
KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
||||
{
|
||||
this->_originName = name;
|
||||
}
|
||||
|
||||
uint8_t read_from_14004(uint8_t reg, uint8_t *data, uint8_t length, TwoWire myWire)
|
||||
uint8_t read_from_14004(uint8_t reg, uint8_t *data, uint8_t length)
|
||||
{
|
||||
uint8_t readflag = 0;
|
||||
myWire.beginTransmission(CARDKB_ADDR);
|
||||
myWire.write(reg);
|
||||
myWire.endTransmission(); // stop transmitting
|
||||
Wire.beginTransmission(CARDKB_ADDR);
|
||||
Wire.write(reg);
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
delay(20);
|
||||
myWire.requestFrom(CARDKB_ADDR, (int)length);
|
||||
Wire.requestFrom(CARDKB_ADDR, (int)length);
|
||||
int i = 0;
|
||||
while ( myWire.available() ) // slave may send less than requested
|
||||
while ( Wire.available() ) // slave may send less than requested
|
||||
{
|
||||
data[i++] = myWire.read(); // receive a byte as a proper uint8_t
|
||||
data[i++] = Wire.read(); // receive a byte as a proper uint8_t
|
||||
readflag = 1;
|
||||
}
|
||||
return readflag;
|
||||
}
|
||||
|
||||
void write_to_14004(uint8_t reg, uint8_t data, TwoWire myWire)
|
||||
void write_to_14004(uint8_t reg, uint8_t data)
|
||||
{
|
||||
myWire.beginTransmission(CARDKB_ADDR);
|
||||
myWire.write(reg);
|
||||
myWire.write(data);
|
||||
myWire.endTransmission(); // stop transmitting
|
||||
Wire.beginTransmission(CARDKB_ADDR);
|
||||
Wire.write(reg);
|
||||
Wire.write(data);
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
}
|
||||
|
||||
int32_t KbI2cBase::runOnce()
|
||||
{
|
||||
if (i2cScanMap[CARDKB_ADDR].addr != CARDKB_ADDR) {
|
||||
if (cardkb_found != CARDKB_ADDR){
|
||||
// Input device is not detected.
|
||||
return INT32_MAX;
|
||||
}
|
||||
|
||||
TwoWire myWire = Wire;
|
||||
|
||||
if (i2cScanMap[CARDKB_ADDR].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
myWire = Wire1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (kb_model == 0x02) {
|
||||
// RAK14004
|
||||
uint8_t rDataBuf[8] = {0};
|
||||
uint8_t PrintDataBuf = 0;
|
||||
if (read_from_14004(0x01, rDataBuf, 0x04, myWire) == 1) {
|
||||
if (read_from_14004(0x01, rDataBuf, 0x04) == 1) {
|
||||
for (uint8_t aCount = 0; aCount < 0x04; aCount++) {
|
||||
for (uint8_t bCount = 0; bCount < 0x04; bCount++ ) {
|
||||
if (((rDataBuf[aCount] >> bCount) & 0x01) == 0x01) {
|
||||
@ -73,10 +65,10 @@ int32_t KbI2cBase::runOnce()
|
||||
}
|
||||
} else {
|
||||
// m5 cardkb
|
||||
myWire.requestFrom(CARDKB_ADDR, 1);
|
||||
Wire.requestFrom(CARDKB_ADDR, 1);
|
||||
|
||||
while (myWire.available()) {
|
||||
char c = myWire.read();
|
||||
while (Wire.available()) {
|
||||
char c = Wire.read();
|
||||
InputEvent e;
|
||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||
e.source = this->_originName;
|
||||
@ -121,5 +113,3 @@ int32_t KbI2cBase::runOnce()
|
||||
}
|
||||
return 500;
|
||||
}
|
||||
|
||||
#endif
|
39
src/main.cpp
39
src/main.cpp
@ -79,9 +79,16 @@ meshtastic::NodeStatus *nodeStatus = new meshtastic::NodeStatus();
|
||||
uint8_t screen_found;
|
||||
uint8_t screen_model;
|
||||
|
||||
// The I2C address of the cardkb or RAK14004 (if found)
|
||||
uint8_t cardkb_found;
|
||||
// 0x02 for RAK14004 and 0x00 for cardkb
|
||||
uint8_t kb_model;
|
||||
|
||||
// The I2C address of the RTC Module (if found)
|
||||
uint8_t rtc_found;
|
||||
|
||||
// Keystore Chips
|
||||
uint8_t keystore_found;
|
||||
#ifndef ARCH_PORTDUINO
|
||||
ATECCX08A atecc;
|
||||
#endif
|
||||
@ -95,8 +102,6 @@ bool pmu_found;
|
||||
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
|
||||
uint8_t nodeTelemetrySensorsMap[_TelemetrySensorType_MAX + 1] = { 0 }; // one is enough, missing elements will be initialized to 0 anyway.
|
||||
|
||||
scanmap i2cScanMap[128] = { 0 };
|
||||
|
||||
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
||||
|
||||
const char *getDeviceName()
|
||||
@ -174,8 +179,7 @@ void setup()
|
||||
|
||||
initDeepSleep();
|
||||
|
||||
// The T-Echo needs to switch the peripheral power rail on before we can do anything else
|
||||
// this controls much more than just the display, so we do it first
|
||||
// Testing this fix für erratic T-Echo boot behaviour
|
||||
#if defined(TTGO_T_ECHO) && defined(PIN_EINK_PWR_ON)
|
||||
pinMode(PIN_EINK_PWR_ON, OUTPUT);
|
||||
digitalWrite(PIN_EINK_PWR_ON, HIGH);
|
||||
@ -212,6 +216,7 @@ void setup()
|
||||
|
||||
fsInit();
|
||||
|
||||
// router = new DSRRouter();
|
||||
router = new ReliableRouter();
|
||||
|
||||
#ifdef I2C_SDA1
|
||||
@ -247,14 +252,19 @@ void setup()
|
||||
powerStatus->observe(&power->newStatus);
|
||||
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration
|
||||
|
||||
#if HAS_WIRE
|
||||
// We need to scan here to decide if we have a screen for nodeDB.init()
|
||||
scanI2Cdevice(Wire,0);
|
||||
|
||||
#ifdef LILYGO_TBEAM_S3_CORE
|
||||
// In T-Beam-S3-core, the I2C device cannot be scanned before power initialization, otherwise the device will be stuck
|
||||
// PCF8563 RTC in tbeam-s3 uses Wire1 to share I2C bus
|
||||
Wire1.beginTransmission(PCF8563_RTC);
|
||||
if (Wire1.endTransmission() == 0){
|
||||
rtc_found = PCF8563_RTC;
|
||||
DEBUG_MSG("PCF8563 RTC found\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef I2C_SDA1
|
||||
scanI2Cdevice(Wire1,1);
|
||||
#endif
|
||||
// We need to scan here to decide if we have a screen for nodeDB.init()
|
||||
scanI2Cdevice();
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
setupSDCard();
|
||||
@ -294,6 +304,13 @@ void setup()
|
||||
|
||||
playStartMelody();
|
||||
|
||||
|
||||
/*
|
||||
* Repeat the scanning for I2C devices after power initialization or look for 'latecomers'.
|
||||
* Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core
|
||||
*/
|
||||
// scanI2Cdevice();
|
||||
|
||||
// fixed screen override?
|
||||
if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO)
|
||||
screen_model = config.display.oled;
|
||||
@ -329,7 +346,7 @@ void setup()
|
||||
|
||||
// Do this after service.init (because that clears error_code)
|
||||
#ifdef HAS_PMU
|
||||
if (i2cScanMap[XPOWERS_AXP192_AXP2101_ADDRESS].addr == 0)
|
||||
if (!pmu_found)
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_NO_AXP192); // Record a hardware fault for missing hardware
|
||||
#endif
|
||||
|
||||
|
10
src/main.h
10
src/main.h
@ -12,7 +12,10 @@
|
||||
|
||||
extern uint8_t screen_found;
|
||||
extern uint8_t screen_model;
|
||||
extern uint8_t cardkb_found;
|
||||
extern uint8_t kb_model;
|
||||
extern uint8_t rtc_found;
|
||||
extern uint8_t keystore_found;
|
||||
|
||||
extern bool eink_found;
|
||||
extern bool pmu_found;
|
||||
@ -23,13 +26,6 @@ extern bool isUSBPowered;
|
||||
extern ATECCX08A atecc;
|
||||
#endif
|
||||
|
||||
typedef struct _scanmap {
|
||||
uint8_t addr;
|
||||
uint8_t bus;
|
||||
} scanmap;
|
||||
|
||||
extern scanmap i2cScanMap[128];
|
||||
|
||||
extern uint8_t nodeTelemetrySensorsMap[_TelemetrySensorType_MAX + 1];
|
||||
|
||||
extern int TCPPort; // set by Portduino
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "NodeDB.h"
|
||||
#include "MeshService.h"
|
||||
#include "PowerFSM.h" // neede for button bypass
|
||||
#include "main.h"
|
||||
#include "mesh/generated/cannedmessages.pb.h"
|
||||
|
||||
#ifdef OLED_RU
|
||||
@ -36,6 +35,8 @@
|
||||
// Remove Canned message screen if no action is taken for some milliseconds
|
||||
#define INACTIVATE_AFTER_MS 20000
|
||||
|
||||
extern uint8_t cardkb_found;
|
||||
|
||||
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
|
||||
|
||||
CannedMessageModuleConfig cannedMessageModuleConfig;
|
||||
@ -52,7 +53,7 @@ CannedMessageModule::CannedMessageModule()
|
||||
{
|
||||
if (moduleConfig.canned_message.enabled) {
|
||||
this->loadProtoForModule();
|
||||
if ((this->splitConfiguredMessages() <= 0) && (i2cScanMap[CARDKB_ADDR].addr != CARDKB_ADDR)) {
|
||||
if ((this->splitConfiguredMessages() <= 0) && (cardkb_found != CARDKB_ADDR)) {
|
||||
DEBUG_MSG("CannedMessageModule: No messages are configured. Module is disabled\n");
|
||||
this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED;
|
||||
} else {
|
||||
|
@ -15,14 +15,8 @@ int32_t BME280Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = bme280.begin(nodeTelemetrySensorsMap[sensorType], &Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = bme280.begin(nodeTelemetrySensorsMap[sensorType], &Wire);
|
||||
}
|
||||
|
||||
status = bme280.begin(nodeTelemetrySensorsMap[sensorType]);
|
||||
|
||||
bme280.setSampling( Adafruit_BME280::MODE_FORCED,
|
||||
Adafruit_BME280::SAMPLING_X1, // Temp. oversampling
|
||||
Adafruit_BME280::SAMPLING_X1, // Pressure oversampling
|
||||
|
@ -14,13 +14,6 @@ int32_t BME680Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
bme680 = Adafruit_BME680(&Wire1);
|
||||
#endif
|
||||
} else {
|
||||
bme680 = Adafruit_BME680(&Wire);
|
||||
}
|
||||
status = bme680.begin(nodeTelemetrySensorsMap[sensorType]);
|
||||
|
||||
return initI2CSensor();
|
||||
|
@ -15,14 +15,6 @@ int32_t BMP280Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
bmp280 = Adafruit_BMP280(&Wire1);
|
||||
#endif
|
||||
} else {
|
||||
bmp280 = Adafruit_BMP280(&Wire);
|
||||
}
|
||||
|
||||
status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]);
|
||||
|
||||
bmp280.setSampling( Adafruit_BMP280::MODE_FORCED,
|
||||
|
@ -15,13 +15,7 @@ int32_t INA219Sensor::runOnce() {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
ina219 = Adafruit_INA219(nodeTelemetrySensorsMap[sensorType]);
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = ina219.begin(&Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = ina219.begin(&Wire);
|
||||
}
|
||||
status = ina219.begin();
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,7 @@ int32_t INA260Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = ina260.begin(nodeTelemetrySensorsMap[sensorType], &Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = ina260.begin(nodeTelemetrySensorsMap[sensorType], &Wire);
|
||||
}
|
||||
status = ina260.begin(nodeTelemetrySensorsMap[sensorType]);
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,7 @@ int32_t LPS22HBSensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = lps22hb.begin_I2C(nodeTelemetrySensorsMap[sensorType], &Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = lps22hb.begin_I2C(nodeTelemetrySensorsMap[sensorType], &Wire);
|
||||
}
|
||||
status = lps22hb.begin_I2C(nodeTelemetrySensorsMap[sensorType]);
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,7 @@ int32_t MCP9808Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = mcp9808.begin(nodeTelemetrySensorsMap[sensorType], &Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = mcp9808.begin(nodeTelemetrySensorsMap[sensorType], &Wire);
|
||||
}
|
||||
status = mcp9808.begin(nodeTelemetrySensorsMap[sensorType]);
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
|
@ -14,18 +14,7 @@ int32_t SHTC3Sensor::runOnce() {
|
||||
if (!hasSensor()) {
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if (i2cScanMap[nodeTelemetrySensorsMap[sensorType]].addr == 0) {
|
||||
DEBUG_MSG("SHTC3 not found on i2c bus\n");
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
}
|
||||
if(i2cScanMap[nodeTelemetrySensorsMap[sensorType]].bus == 1) {
|
||||
#ifdef I2C_SDA1
|
||||
status = shtc3.begin(&Wire1);
|
||||
#endif
|
||||
} else {
|
||||
status = shtc3.begin(&Wire);
|
||||
}
|
||||
|
||||
status = shtc3.begin();
|
||||
return initI2CSensor();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ class TelemetrySensor
|
||||
DEBUG_MSG("Could not connect to detected %s sensor.\n Removing from nodeTelemetrySensorsMap.\n", sensorName);
|
||||
nodeTelemetrySensorsMap[sensorType] = 0;
|
||||
} else {
|
||||
DEBUG_MSG("Opened %s sensor on detected i2c bus\n", sensorName);
|
||||
DEBUG_MSG("Opened %s sensor on default i2c bus\n", sensorName);
|
||||
setup();
|
||||
}
|
||||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
|
||||
|
@ -2,13 +2,6 @@
|
||||
|
||||
#define ARCH_RP2040
|
||||
|
||||
#ifndef HAS_SCREEN
|
||||
#define HAS_SCREEN 1
|
||||
#endif
|
||||
#ifndef HAS_WIRE
|
||||
#define HAS_WIRE 1
|
||||
#endif
|
||||
|
||||
#if defined(PRIVATE_HW)
|
||||
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user