stop explicitly using Serial.print for debug messages

1.2-legacy
geeksville 2020-02-04 08:17:44 -08:00
rodzic 4a40b9499b
commit b04fb061c4
13 zmienionych plików z 103 dodań i 101 usunięć

Wyświetl plik

@ -1,5 +1,6 @@
#include "BluetoothUtil.h" #include "BluetoothUtil.h"
#include "BluetoothSoftwareUpdate.h" #include "BluetoothSoftwareUpdate.h"
#include "configuration.h"
#include <esp_gatt_defs.h> #include <esp_gatt_defs.h>
#include <BLE2902.h> #include <BLE2902.h>
#include <Arduino.h> #include <Arduino.h>
@ -17,7 +18,7 @@ uint32_t rebootAtMsec = 0; // If not zero we will reboot at this time (used to r
class UpdateCallbacks : public BLECharacteristicCallbacks class UpdateCallbacks : public BLECharacteristicCallbacks
{ {
void onRead(BLECharacteristic *pCharacteristic) { void onRead(BLECharacteristic *pCharacteristic) {
Serial.println("Got on read"); DEBUG_MSG("Got on read\n");
} }
void onWrite(BLECharacteristic *pCharacteristic) void onWrite(BLECharacteristic *pCharacteristic)
@ -30,7 +31,7 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
uint32_t len = getValue32(pCharacteristic, 0); uint32_t len = getValue32(pCharacteristic, 0);
crc.reset(); crc.reset();
bool canBegin = Update.begin(len); bool canBegin = Update.begin(len);
Serial.printf("Setting update size %u, result %d\n", len, canBegin); DEBUG_MSG("Setting update size %u, result %d\n", len, canBegin);
if(!canBegin) if(!canBegin)
// Indicate failure by forcing the size to 0 // Indicate failure by forcing the size to 0
pCharacteristic->setValue(0UL); pCharacteristic->setValue(0UL);
@ -40,31 +41,31 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
std::string value = pCharacteristic->getValue(); std::string value = pCharacteristic->getValue();
uint32_t len = value.length(); uint32_t len = value.length();
uint8_t *data = pCharacteristic->getData(); uint8_t *data = pCharacteristic->getData();
// Serial.printf("Writing %u\n", len); // DEBUG_MSG("Writing %u\n", len);
crc.update(data, len); crc.update(data, len);
Update.write(data, len); Update.write(data, len);
} }
else if (pCharacteristic == &swUpdateCRC32Characteristic) else if (pCharacteristic == &swUpdateCRC32Characteristic)
{ {
uint32_t expectedCRC = getValue32(pCharacteristic, 0); uint32_t expectedCRC = getValue32(pCharacteristic, 0);
Serial.printf("expected CRC %u\n", expectedCRC); DEBUG_MSG("expected CRC %u\n", expectedCRC);
uint8_t result = 0xff; uint8_t result = 0xff;
// Check the CRC before asking the update to happen. // Check the CRC before asking the update to happen.
if(crc.finalize() != expectedCRC) { if(crc.finalize() != expectedCRC) {
Serial.println("Invalid CRC!"); DEBUG_MSG("Invalid CRC!\n");
result = 0xe0; // FIXME, use real error codes result = 0xe0; // FIXME, use real error codes
} }
else { else {
if (Update.end()) if (Update.end())
{ {
Serial.println("OTA done, rebooting in 5 seconds!"); DEBUG_MSG("OTA done, rebooting in 5 seconds!\n");
rebootAtMsec = millis() + 5000; rebootAtMsec = millis() + 5000;
} }
else else
{ {
Serial.println("Error Occurred. Error #: " + String(Update.getError())); DEBUG_MSG("Error Occurred. Error #: %d\n", Update.getError());
} }
result = Update.getError(); result = Update.getError();
} }
@ -72,7 +73,7 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
swUpdateResultCharacteristic.notify(); swUpdateResultCharacteristic.notify();
} }
else { else {
Serial.println("unexpected write"); DEBUG_MSG("unexpected write\n");
} }
} }
}; };

Wyświetl plik

@ -4,6 +4,7 @@
#include <BLE2902.h> #include <BLE2902.h>
#include <Arduino.h> #include <Arduino.h>
#include <Update.h> #include <Update.h>
#include "configuration.h"
static BLECharacteristic SWVersionCharacteristic(BLEUUID((uint16_t) ESP_GATT_UUID_SW_VERSION_STR), BLECharacteristic::PROPERTY_READ); static BLECharacteristic SWVersionCharacteristic(BLEUUID((uint16_t) ESP_GATT_UUID_SW_VERSION_STR), BLECharacteristic::PROPERTY_READ);
static BLECharacteristic ManufacturerCharacteristic(BLEUUID((uint16_t) ESP_GATT_UUID_MANU_NAME), BLECharacteristic::PROPERTY_READ); static BLECharacteristic ManufacturerCharacteristic(BLEUUID((uint16_t) ESP_GATT_UUID_MANU_NAME), BLECharacteristic::PROPERTY_READ);
@ -102,11 +103,11 @@ void dumpCharacteristic(BLECharacteristic *c) {
std::string value = c->getValue(); std::string value = c->getValue();
if (value.length() > 0) { if (value.length() > 0) {
Serial.print("New value: "); DEBUG_MSG("New value: ");
for (int i = 0; i < value.length(); i++) for (int i = 0; i < value.length(); i++)
Serial.print(value[i]); DEBUG_MSG("%c", value[i]);
Serial.println(); DEBUG_MSG("\n");
} }
} }

Wyświetl plik

@ -20,7 +20,7 @@ framework = arduino
board_build.partitions = partition-table.csv board_build.partitions = partition-table.csv
; note: we add src to our include search path so that lmic_project_config can override ; note: we add src to our include search path so that lmic_project_config can override
build_flags = -Wall -Wextra -Wno-missing-field-initializers -ggdb -O3 -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG build_flags = -Wall -Wextra -Wno-missing-field-initializers -Isrc -O3 -Wl,-Map,.pio/build/esp32/output.map -DAXP_DEBUG_PORT=Serial -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG ; -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
upload_speed = 921600 upload_speed = 921600
@ -36,7 +36,7 @@ monitor_speed = 115200
# debug_port = /dev/ttyUSB0 # debug_port = /dev/ttyUSB0
debug_tool = olimex-arm-usb-ocd-h debug_tool = olimex-arm-usb-ocd-h
; upload_protocol = olimex-arm-usb-ocd-h upload_protocol = olimex-arm-usb-ocd-h
;debug_init_cmds = ;debug_init_cmds =
; adapter_khz 10000 ; adapter_khz 10000

1
src/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1 @@
main.ino.cpp

Wyświetl plik

@ -9,6 +9,7 @@
#include "MeshService.h" #include "MeshService.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "configuration.h"
// This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in proccess at once // This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in proccess at once
static uint8_t trBytes[_max(_max(_max(_max(ToRadio_size, RadioConfig_size), User_size), MyNodeInfo_size), FromRadio_size)]; static uint8_t trBytes[_max(_max(_max(_max(ToRadio_size, RadioConfig_size), User_size), MyNodeInfo_size), FromRadio_size)];
@ -29,7 +30,7 @@ public:
void onRead(BLECharacteristic *c) void onRead(BLECharacteristic *c)
{ {
Serial.println("Got proto read"); DEBUG_MSG("Got proto read\n");
size_t numbytes = pb_encode_to_bytes(trBytes, sizeof(trBytes), fields, my_struct); size_t numbytes = pb_encode_to_bytes(trBytes, sizeof(trBytes), fields, my_struct);
c->setValue(trBytes, numbytes); c->setValue(trBytes, numbytes);
} }
@ -37,7 +38,7 @@ public:
void onWrite(BLECharacteristic *c) void onWrite(BLECharacteristic *c)
{ {
// dumpCharacteristic(pCharacteristic); // dumpCharacteristic(pCharacteristic);
Serial.println("Got on proto write"); DEBUG_MSG("Got on proto write\n");
std::string src = c->getValue(); std::string src = c->getValue();
if (pb_decode_from_bytes((const uint8_t *)src.c_str(), src.length(), fields, my_struct)) if (pb_decode_from_bytes((const uint8_t *)src.c_str(), src.length(), fields, my_struct))
{ {
@ -57,7 +58,7 @@ public:
void onRead(BLECharacteristic *c) void onRead(BLECharacteristic *c)
{ {
Serial.println("Got nodeinfo read"); DEBUG_MSG("Got nodeinfo read\n");
const NodeInfo *info = nodeDB.readNextInfo(); const NodeInfo *info = nodeDB.readNextInfo();
if (info) if (info)
@ -74,7 +75,7 @@ public:
void onWrite(BLECharacteristic *c) void onWrite(BLECharacteristic *c)
{ {
// dumpCharacteristic(pCharacteristic); // dumpCharacteristic(pCharacteristic);
Serial.println("Got on nodeinfo write"); DEBUG_MSG("Got on nodeinfo write\n");
nodeDB.resetReadPointer(); nodeDB.resetReadPointer();
} }
}; };
@ -137,7 +138,7 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
{ {
void onRead(BLECharacteristic *c) void onRead(BLECharacteristic *c)
{ {
Serial.println("Got on read"); DEBUG_MSG("Got on read\n");
if (c == &meshFromRadioCharacteristic) if (c == &meshFromRadioCharacteristic)
{ {
@ -147,12 +148,12 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
// or make empty if the queue is empty // or make empty if the queue is empty
if (!mp) if (!mp)
{ {
Serial.println("toPhone queue is empty"); DEBUG_MSG("toPhone queue is empty\n");
c->setValue((uint8_t *)"", 0); c->setValue((uint8_t *)"", 0);
} }
else else
{ {
Serial.println("delivering toPhone packet to phone"); DEBUG_MSG("delivering toPhone packet to phone\n");
static FromRadio fradio; static FromRadio fradio;
@ -176,7 +177,7 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
void onWrite(BLECharacteristic *c) void onWrite(BLECharacteristic *c)
{ {
// dumpCharacteristic(pCharacteristic); // dumpCharacteristic(pCharacteristic);
Serial.println("Got on write"); DEBUG_MSG("Got on write\n");
if (c == &meshToRadioCharacteristic) if (c == &meshToRadioCharacteristic)
{ {
@ -270,7 +271,7 @@ BLEService *createMeshBluetoothService(BLEServer *server)
service->start(); service->start();
server->getAdvertising()->addServiceUUID(service->getUUID()); server->getAdvertising()->addServiceUUID(service->getUUID());
Serial.println("*** Mesh service:"); DEBUG_MSG("*** Mesh service:\n");
service->dump(); service->dump();
return service; return service;

Wyświetl plik

@ -38,21 +38,20 @@ bool MeshRadio::init()
if (!manager.init()) if (!manager.init())
{ {
Serial.println("LoRa radio init failed"); DEBUG_MSG("LoRa radio init failed\n");
Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info"); DEBUG_MSG("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info\n");
return false; return false;
} }
Serial.println("LoRa radio init OK!"); DEBUG_MSG("LoRa radio init OK!\n");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(radioConfig.center_freq)) if (!rf95.setFrequency(radioConfig.center_freq))
{ {
Serial.println("setFrequency failed"); DEBUG_MSG("setFrequency failed\n");
while (1) assert(0); // fixme panic
;
} }
Serial.printf("Set Freq to: %f\n", radioConfig.center_freq); DEBUG_MSG("Set Freq to: %f\n", radioConfig.center_freq);
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
@ -67,13 +66,13 @@ bool MeshRadio::init()
ErrorCode MeshRadio::send(MeshPacket *p) ErrorCode MeshRadio::send(MeshPacket *p)
{ {
Serial.println("enquing packet for sending on mesh"); DEBUG_MSG("enquing packet for sending on mesh\n");
return txQueue.enqueue(p, 0); // nowait return txQueue.enqueue(p, 0); // nowait
} }
ErrorCode MeshRadio::sendTo(NodeNum dest, const uint8_t *buf, size_t len) ErrorCode MeshRadio::sendTo(NodeNum dest, const uint8_t *buf, size_t len)
{ {
Serial.printf("mesh sendTo %d bytes to %d\n", len, dest); DEBUG_MSG("mesh sendTo %d bytes to %d\n", len, dest);
// FIXME - for now we do all packets as broadcast // FIXME - for now we do all packets as broadcast
dest = NODENUM_BROADCAST; dest = NODENUM_BROADCAST;
@ -115,7 +114,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
if (manager.recvfromAckTimeout(radiobuf, &rxlen, 0, &srcaddr, &destaddr, &id, &flags)) if (manager.recvfromAckTimeout(radiobuf, &rxlen, 0, &srcaddr, &destaddr, &id, &flags))
{ {
// We received a packet // We received a packet
Serial.printf("Received packet from mesh src=%d,dest=%d,id=%d,len=%d\n", srcaddr, destaddr, id, rxlen); DEBUG_MSG("Received packet from mesh src=%d,dest=%d,id=%d,len=%d\n", srcaddr, destaddr, id, rxlen);
MeshPacket *mp = pool.allocZeroed(); MeshPacket *mp = pool.allocZeroed();
assert(mp); // FIXME assert(mp); // FIXME
@ -140,7 +139,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
MeshPacket *txp = txQueue.dequeuePtr(0); // nowait MeshPacket *txp = txQueue.dequeuePtr(0); // nowait
if (txp) if (txp)
{ {
Serial.println("sending queued packet on mesh"); DEBUG_MSG("sending queued packet on mesh\n");
assert(txp->has_payload); assert(txp->has_payload);
size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload); size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload);

Wyświetl plik

@ -6,6 +6,7 @@
#include "mesh.pb.h" #include "mesh.pb.h"
#include "PointerQueue.h" #include "PointerQueue.h"
#include "MeshTypes.h" #include "MeshTypes.h"
#include "configuration.h"
@ -37,7 +38,7 @@ public:
void loop(); void loop();
/// The radioConfig object just changed, call this to force the hw to change to the new settings /// The radioConfig object just changed, call this to force the hw to change to the new settings
void reloadConfig() { Serial.println("FIXME add reloadConfig"); } void reloadConfig() { DEBUG_MSG("FIXME add reloadConfig\n"); }
private: private:
RH_RF95 rf95; // the raw radio interface RH_RF95 rf95; // the raw radio interface

Wyświetl plik

@ -38,7 +38,7 @@ MeshService::MeshService()
void MeshService::init() void MeshService::init()
{ {
if (!radio.init()) if (!radio.init())
Serial.println("radio init failed"); DEBUG_MSG("radio init failed\n");
} }
/// Do idle processing (mostly processing messages which have been queued from the radio) /// Do idle processing (mostly processing messages which have been queued from the radio)
@ -73,7 +73,7 @@ void MeshService::handleToRadio(std::string s)
break; break;
default: default:
Serial.println("Error: unexpected ToRadio variant"); DEBUG_MSG("Error: unexpected ToRadio variant\n");
break; break;
} }
} }

Wyświetl plik

@ -54,7 +54,7 @@ public:
void reloadConfig() { radio.reloadConfig(); } void reloadConfig() { radio.reloadConfig(); }
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh /// The owner User record just got updated, update our node DB and broadcast the info into the mesh
void reloadOwner() { Serial.println("FIXME implement reloadOwner"); } void reloadOwner() { DEBUG_MSG("FIXME implement reloadOwner\n"); }
private: private:

Wyświetl plik

@ -4,6 +4,7 @@
#include <pb_encode.h> #include <pb_encode.h>
#include <pb_decode.h> #include <pb_decode.h>
#include "configuration.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "NodeDB.h" #include "NodeDB.h"
@ -50,7 +51,7 @@ void NodeDB::updateFrom(const MeshPacket &mp)
if (mp.has_payload) if (mp.has_payload)
{ {
const SubPacket &p = mp.payload; const SubPacket &p = mp.payload;
Serial.printf("Update DB node %x for %d\n", mp.from, p.which_variant); DEBUG_MSG("Update DB node %x for %d\n", mp.from, p.which_variant);
if (p.which_variant != SubPacket_want_node_tag) // we don't create nodeinfo records for someone that is just trying to claim a nodenum if (p.which_variant != SubPacket_want_node_tag) // we don't create nodeinfo records for someone that is just trying to claim a nodenum
{ {
int oldNumNodes = numNodes; int oldNumNodes = numNodes;

Wyświetl plik

@ -52,7 +52,7 @@ esp_sleep_source_t wakeCause; // the reason we booted this time
void doDeepSleep(uint64_t msecToWake) void doDeepSleep(uint64_t msecToWake)
{ {
Serial.printf("Entering deep sleep for %llu seconds\n", msecToWake / 1000); DEBUG_MSG("Entering deep sleep for %llu seconds\n", msecToWake / 1000);
// not using wifi yet, but once we are this is needed to shutoff the radio hw // not using wifi yet, but once we are this is needed to shutoff the radio hw
// esp_wifi_stop(); // esp_wifi_stop();
@ -173,38 +173,32 @@ void scanI2Cdevice(void)
err = Wire.endTransmission(); err = Wire.endTransmission();
if (err == 0) if (err == 0)
{ {
Serial.print("I2C device found at address 0x"); DEBUG_MSG("I2C device found at address 0x%x\n", addr);
if (addr < 16)
Serial.print("0");
Serial.print(addr, HEX);
Serial.println(" !");
nDevices++; nDevices++;
if (addr == SSD1306_ADDRESS) if (addr == SSD1306_ADDRESS)
{ {
ssd1306_found = true; ssd1306_found = true;
Serial.println("ssd1306 display found"); DEBUG_MSG("ssd1306 display found\n");
} }
#ifdef T_BEAM_V10 #ifdef T_BEAM_V10
if (addr == AXP192_SLAVE_ADDRESS) if (addr == AXP192_SLAVE_ADDRESS)
{ {
axp192_found = true; axp192_found = true;
Serial.println("axp192 PMU found"); DEBUG_MSG("axp192 PMU found\n");
} }
#endif #endif
} }
else if (err == 4) else if (err == 4)
{ {
Serial.print("Unknow error at address 0x"); DEBUG_MSG("Unknow error at address 0x%x\n", addr);
if (addr < 16)
Serial.print("0");
Serial.println(addr, HEX);
} }
} }
if (nDevices == 0) if (nDevices == 0)
Serial.println("No I2C devices found\n"); DEBUG_MSG("No I2C devices found\n");
else else
Serial.println("done\n"); DEBUG_MSG("done\n");
} }
/** /**
@ -225,55 +219,56 @@ void axp192Init()
{ {
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS))
{ {
Serial.println("AXP192 Begin PASS"); DEBUG_MSG("AXP192 Begin PASS\n");
// axp.setChgLEDMode(LED_BLINK_4HZ);
DEBUG_MSG("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("----------------------------------------\n");
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA radio
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS main power
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
axp.setDCDC1Voltage(3300); // for the OLED power
DEBUG_MSG("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
axp.debugCharging();
pinMode(PMU_IRQ, INPUT_PULLUP);
attachInterrupt(PMU_IRQ, [] {
pmu_irq = true;
},
FALLING);
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, 1);
axp.clearIRQ();
if (axp.isChargeing())
{
baChStatus = "Charging";
}
} }
else else
{ {
Serial.println("AXP192 Begin FAIL"); DEBUG_MSG("AXP192 Begin FAIL\n");
}
// axp.setChgLEDMode(LED_BLINK_4HZ);
Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
Serial.println("----------------------------------------");
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA radio
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS main power
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
axp.setDCDC1Voltage(3300); // for the OLED power
Serial.printf("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
Serial.printf("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
Serial.printf("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
axp.debugCharging();
pinMode(PMU_IRQ, INPUT_PULLUP);
attachInterrupt(PMU_IRQ, [] {
pmu_irq = true;
},
FALLING);
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, 1);
axp.clearIRQ();
if (axp.isChargeing())
{
baChStatus = "Charging";
} }
} }
else else
{ {
Serial.println("AXP192 not found"); DEBUG_MSG("AXP192 not found\n");
} }
#endif #endif
} }
@ -291,7 +286,7 @@ void initDeepSleep()
wakeButtons = ((uint64_t)1) << buttons.gpios[0]; wakeButtons = ((uint64_t)1) << buttons.gpios[0];
*/ */
Serial.printf("booted, wake cause %d (boot count %d)\n", wakeCause, bootCount); DEBUG_MSG("booted, wake cause %d (boot count %d)\n", wakeCause, bootCount);
} }
const char *getDeviceName() const char *getDeviceName()
@ -399,7 +394,7 @@ void loop()
{ {
if (!wasPressed) if (!wasPressed)
{ // just started a new press { // just started a new press
Serial.println("pressing"); DEBUG_MSG("pressing\n");
wasPressed = true; wasPressed = true;
minPressMs = millis() + 3000; minPressMs = millis() + 3000;
} }

Wyświetl plik

@ -1,4 +1,5 @@
#include <Arduino.h> #include <Arduino.h>
#include "configuration.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include <pb_encode.h> #include <pb_encode.h>
#include <pb_decode.h> #include <pb_decode.h>
@ -12,7 +13,7 @@ size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc
pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize); pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize);
if (!pb_encode(&stream, fields, &src_struct)) if (!pb_encode(&stream, fields, &src_struct))
{ {
Serial.printf("Error: can't encode protobuf %s\n", PB_GET_ERROR(&stream)); DEBUG_MSG("Error: can't encode protobuf %s\n", PB_GET_ERROR(&stream));
assert(0); // FIXME - panic assert(0); // FIXME - panic
} }
else else
@ -28,7 +29,7 @@ bool pb_decode_from_bytes(const uint8_t *srcbuf, size_t srcbufsize, const pb_msg
pb_istream_t stream = pb_istream_from_buffer(srcbuf, srcbufsize); pb_istream_t stream = pb_istream_from_buffer(srcbuf, srcbufsize);
if (!pb_decode(&stream, fields, &dest_struct)) if (!pb_decode(&stream, fields, &dest_struct))
{ {
Serial.printf("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream)); DEBUG_MSG("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream));
return false; return false;
} }
else else

Wyświetl plik

@ -92,7 +92,7 @@ void screen_print(const char * text, uint8_t x, uint8_t y) {
} }
void screen_print(const char * text) { void screen_print(const char * text) {
Serial.printf("Screen: %s\n", text); DEBUG_MSG("Screen: %s\n", text);
if(!display) return; if(!display) return;
display->print(text); display->print(text);
@ -136,8 +136,9 @@ void screen_loop() {
if (axp.isVbusRemoveIRQ()) { if (axp.isVbusRemoveIRQ()) {
baChStatus = "No Charging"; baChStatus = "No Charging";
} }
Serial.println(baChStatus); //Prints charging status to screen DEBUG_MSG("%s\n", baChStatus); //Prints charging status to screen
digitalWrite(2, !digitalRead(2)); // This is not a GPIO actually connected on the tbeam board
// digitalWrite(2, !digitalRead(2));
axp.clearIRQ(); axp.clearIRQ();
} }
#endif #endif