Wire vs. Wire1, still needs to be sorted out. ChatGPT has some tests to clarify which I will try after this commit. Magnetometer is on Wire and RTC is on Wire1, this apparently conflicts with the documentation. Getting values, though when I rotated both standing up and sideways, I did not see values ranging from 0-360.
This commit is contained in:
parent
ba6160d004
commit
fa212c80e6
2 changed files with 16 additions and 9 deletions
|
|
@ -205,7 +205,7 @@ Suggested workflow:
|
|||
|
||||
## Bottom Line
|
||||
|
||||
The examples are enough to establish that this sensor is suitable for a live heading and magnetic field display exercise. The only caution is that the example labeled "calibration" is session-local unless we explicitly persist the offsets. The first useful deliverable for this exercise should therefore be a per-unit magnetometer assay plus a serial real-time monitor, followed by persistent calibration storage and then an OLED compass view.
|
||||
The examples are enough to establish that this sensor is suitable for a live heading and magnetic field display exercise. The only caution is that the example labeled "calibration" is session-local unless we explicitly save in non-volatile memory the offsets. The first useful deliverable for this exercise should therefore be a per-unit magnetometer assay plus a serial real-time monitor, followed by persistent calibration storage and then an OLED compass view.
|
||||
|
||||
## Local Helper Scripts
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ void startWebServer() {
|
|||
Serial.println("wifi_ap=failed");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("wifi_ap=started");
|
||||
g_server.on("/", HTTP_GET, handleWebIndex);
|
||||
g_server.on("/files", HTTP_GET, handleWebFiles);
|
||||
g_server.on("/download", HTTP_GET, handleWebDownload);
|
||||
|
|
@ -415,17 +415,24 @@ bool probeI2cAddr(TwoWire& wire, uint8_t addr) {
|
|||
}
|
||||
|
||||
bool detectMagnetometer() {
|
||||
Serial.printf("Detecting magnetometer, kMagCandidateCount: %u\n", kMagCandidateCount);
|
||||
for (uint8_t i = 0; i < kMagCandidateCount; ++i) {
|
||||
const uint8_t addr = kMagCandidates[i];
|
||||
if (!probeI2cAddr(Wire1, addr)) {
|
||||
Serial.printf(" candidate[%u] = 0x%02X\n", i, kMagCandidates[i]);
|
||||
//
|
||||
if (!probeI2cAddr(Wire, addr)) {
|
||||
continue;
|
||||
}
|
||||
Serial.printf("Found device at 0x%02X, probing for magnetometer...\n", addr);
|
||||
|
||||
if (addr == 0x3C || addr == 0x3D) {
|
||||
Wire1.beginTransmission(addr);
|
||||
Wire1.write((uint8_t)0x00);
|
||||
if (Wire1.endTransmission(false) == 0 && Wire1.requestFrom((int)addr, 1) == 1) {
|
||||
const uint8_t marker = Wire1.read();
|
||||
//Wire1.beginTransmission(addr);
|
||||
//Wire1.write((uint8_t)0x00);
|
||||
//if (Wire1.endTransmission(false) == 0 && Wire1.requestFrom((int)addr, 1) == 1) {
|
||||
Wire.beginTransmission(addr);
|
||||
Wire.write((uint8_t)0x00);
|
||||
if (Wire.endTransmission(false) == 0 && Wire.requestFrom((int)addr, 1) == 1) {
|
||||
const uint8_t marker = Wire.read(); // was Wire1.read() in original code, but that seems wrong since Wire1 is a different bus
|
||||
if (marker != 0x80) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -452,7 +459,7 @@ bool initMagnetometer() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!g_qmc.begin(Wire1, g_magAddress, tbeam_supreme::i2cSda(), tbeam_supreme::i2cScl())) {
|
||||
if (!g_qmc.begin(Wire, g_magAddress, tbeam_supreme::i2cSda(), tbeam_supreme::i2cScl())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -683,7 +690,7 @@ void appSetup() {
|
|||
Serial.println("sd_mount=ok");
|
||||
g_sd.printCardInfo();
|
||||
}
|
||||
|
||||
// Next is the failure point
|
||||
g_magReady = initMagnetometer();
|
||||
if (!g_magReady) {
|
||||
Serial.println("magnetometer_init=failed");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue