sforkowany z mirror/meshtastic-firmware
stop explicitly using Serial.print for debug messages
rodzic
4a40b9499b
commit
b04fb061c4
|
@ -1,5 +1,6 @@
|
|||
#include "BluetoothUtil.h"
|
||||
#include "BluetoothSoftwareUpdate.h"
|
||||
#include "configuration.h"
|
||||
#include <esp_gatt_defs.h>
|
||||
#include <BLE2902.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
|
||||
{
|
||||
void onRead(BLECharacteristic *pCharacteristic) {
|
||||
Serial.println("Got on read");
|
||||
DEBUG_MSG("Got on read\n");
|
||||
}
|
||||
|
||||
void onWrite(BLECharacteristic *pCharacteristic)
|
||||
|
@ -30,7 +31,7 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
|
|||
uint32_t len = getValue32(pCharacteristic, 0);
|
||||
crc.reset();
|
||||
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)
|
||||
// Indicate failure by forcing the size to 0
|
||||
pCharacteristic->setValue(0UL);
|
||||
|
@ -40,31 +41,31 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
|
|||
std::string value = pCharacteristic->getValue();
|
||||
uint32_t len = value.length();
|
||||
uint8_t *data = pCharacteristic->getData();
|
||||
// Serial.printf("Writing %u\n", len);
|
||||
// DEBUG_MSG("Writing %u\n", len);
|
||||
crc.update(data, len);
|
||||
Update.write(data, len);
|
||||
}
|
||||
else if (pCharacteristic == &swUpdateCRC32Characteristic)
|
||||
{
|
||||
uint32_t expectedCRC = getValue32(pCharacteristic, 0);
|
||||
Serial.printf("expected CRC %u\n", expectedCRC);
|
||||
DEBUG_MSG("expected CRC %u\n", expectedCRC);
|
||||
|
||||
uint8_t result = 0xff;
|
||||
|
||||
// Check the CRC before asking the update to happen.
|
||||
if(crc.finalize() != expectedCRC) {
|
||||
Serial.println("Invalid CRC!");
|
||||
DEBUG_MSG("Invalid CRC!\n");
|
||||
result = 0xe0; // FIXME, use real error codes
|
||||
}
|
||||
else {
|
||||
if (Update.end())
|
||||
{
|
||||
Serial.println("OTA done, rebooting in 5 seconds!");
|
||||
DEBUG_MSG("OTA done, rebooting in 5 seconds!\n");
|
||||
rebootAtMsec = millis() + 5000;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Error Occurred. Error #: " + String(Update.getError()));
|
||||
DEBUG_MSG("Error Occurred. Error #: %d\n", Update.getError());
|
||||
}
|
||||
result = Update.getError();
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ class UpdateCallbacks : public BLECharacteristicCallbacks
|
|||
swUpdateResultCharacteristic.notify();
|
||||
}
|
||||
else {
|
||||
Serial.println("unexpected write");
|
||||
DEBUG_MSG("unexpected write\n");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <BLE2902.h>
|
||||
#include <Arduino.h>
|
||||
#include <Update.h>
|
||||
#include "configuration.h"
|
||||
|
||||
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);
|
||||
|
@ -102,11 +103,11 @@ void dumpCharacteristic(BLECharacteristic *c) {
|
|||
std::string value = c->getValue();
|
||||
|
||||
if (value.length() > 0) {
|
||||
Serial.print("New value: ");
|
||||
DEBUG_MSG("New value: ");
|
||||
for (int i = 0; i < value.length(); i++)
|
||||
Serial.print(value[i]);
|
||||
DEBUG_MSG("%c", value[i]);
|
||||
|
||||
Serial.println();
|
||||
DEBUG_MSG("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ framework = arduino
|
|||
board_build.partitions = partition-table.csv
|
||||
|
||||
; 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
|
||||
|
||||
upload_speed = 921600
|
||||
|
@ -36,7 +36,7 @@ monitor_speed = 115200
|
|||
# debug_port = /dev/ttyUSB0
|
||||
|
||||
debug_tool = olimex-arm-usb-ocd-h
|
||||
; upload_protocol = olimex-arm-usb-ocd-h
|
||||
upload_protocol = olimex-arm-usb-ocd-h
|
||||
|
||||
;debug_init_cmds =
|
||||
; adapter_khz 10000
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
main.ino.cpp
|
|
@ -9,6 +9,7 @@
|
|||
#include "MeshService.h"
|
||||
#include "mesh-pb-constants.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
|
||||
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)
|
||||
{
|
||||
Serial.println("Got proto read");
|
||||
DEBUG_MSG("Got proto read\n");
|
||||
size_t numbytes = pb_encode_to_bytes(trBytes, sizeof(trBytes), fields, my_struct);
|
||||
c->setValue(trBytes, numbytes);
|
||||
}
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
void onWrite(BLECharacteristic *c)
|
||||
{
|
||||
// dumpCharacteristic(pCharacteristic);
|
||||
Serial.println("Got on proto write");
|
||||
DEBUG_MSG("Got on proto write\n");
|
||||
std::string src = c->getValue();
|
||||
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)
|
||||
{
|
||||
Serial.println("Got nodeinfo read");
|
||||
DEBUG_MSG("Got nodeinfo read\n");
|
||||
const NodeInfo *info = nodeDB.readNextInfo();
|
||||
|
||||
if (info)
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
void onWrite(BLECharacteristic *c)
|
||||
{
|
||||
// dumpCharacteristic(pCharacteristic);
|
||||
Serial.println("Got on nodeinfo write");
|
||||
DEBUG_MSG("Got on nodeinfo write\n");
|
||||
nodeDB.resetReadPointer();
|
||||
}
|
||||
};
|
||||
|
@ -137,7 +138,7 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
|
|||
{
|
||||
void onRead(BLECharacteristic *c)
|
||||
{
|
||||
Serial.println("Got on read");
|
||||
DEBUG_MSG("Got on read\n");
|
||||
|
||||
if (c == &meshFromRadioCharacteristic)
|
||||
{
|
||||
|
@ -147,12 +148,12 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
|
|||
// or make empty if the queue is empty
|
||||
if (!mp)
|
||||
{
|
||||
Serial.println("toPhone queue is empty");
|
||||
DEBUG_MSG("toPhone queue is empty\n");
|
||||
c->setValue((uint8_t *)"", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("delivering toPhone packet to phone");
|
||||
DEBUG_MSG("delivering toPhone packet to phone\n");
|
||||
|
||||
static FromRadio fradio;
|
||||
|
||||
|
@ -176,7 +177,7 @@ class BluetoothMeshCallbacks : public BLECharacteristicCallbacks
|
|||
void onWrite(BLECharacteristic *c)
|
||||
{
|
||||
// dumpCharacteristic(pCharacteristic);
|
||||
Serial.println("Got on write");
|
||||
DEBUG_MSG("Got on write\n");
|
||||
|
||||
if (c == &meshToRadioCharacteristic)
|
||||
{
|
||||
|
@ -270,7 +271,7 @@ BLEService *createMeshBluetoothService(BLEServer *server)
|
|||
service->start();
|
||||
server->getAdvertising()->addServiceUUID(service->getUUID());
|
||||
|
||||
Serial.println("*** Mesh service:");
|
||||
DEBUG_MSG("*** Mesh service:\n");
|
||||
service->dump();
|
||||
|
||||
return service;
|
||||
|
|
|
@ -38,21 +38,20 @@ bool MeshRadio::init()
|
|||
|
||||
if (!manager.init())
|
||||
{
|
||||
Serial.println("LoRa radio init failed");
|
||||
Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
|
||||
DEBUG_MSG("LoRa radio init failed\n");
|
||||
DEBUG_MSG("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info\n");
|
||||
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
|
||||
if (!rf95.setFrequency(radioConfig.center_freq))
|
||||
{
|
||||
Serial.println("setFrequency failed");
|
||||
while (1)
|
||||
;
|
||||
DEBUG_MSG("setFrequency failed\n");
|
||||
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
|
||||
|
||||
|
@ -67,13 +66,13 @@ bool MeshRadio::init()
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
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))
|
||||
{
|
||||
// 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();
|
||||
assert(mp); // FIXME
|
||||
|
@ -140,7 +139,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
|
|||
MeshPacket *txp = txQueue.dequeuePtr(0); // nowait
|
||||
if (txp)
|
||||
{
|
||||
Serial.println("sending queued packet on mesh");
|
||||
DEBUG_MSG("sending queued packet on mesh\n");
|
||||
assert(txp->has_payload);
|
||||
|
||||
size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "mesh.pb.h"
|
||||
#include "PointerQueue.h"
|
||||
#include "MeshTypes.h"
|
||||
#include "configuration.h"
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
void loop();
|
||||
|
||||
/// 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:
|
||||
RH_RF95 rf95; // the raw radio interface
|
||||
|
|
|
@ -38,7 +38,7 @@ MeshService::MeshService()
|
|||
void MeshService::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)
|
||||
|
@ -73,7 +73,7 @@ void MeshService::handleToRadio(std::string s)
|
|||
break;
|
||||
|
||||
default:
|
||||
Serial.println("Error: unexpected ToRadio variant");
|
||||
DEBUG_MSG("Error: unexpected ToRadio variant\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
void reloadConfig() { radio.reloadConfig(); }
|
||||
|
||||
/// 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:
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <pb_encode.h>
|
||||
#include <pb_decode.h>
|
||||
#include "configuration.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
#include "NodeDB.h"
|
||||
|
||||
|
@ -50,7 +51,7 @@ void NodeDB::updateFrom(const MeshPacket &mp)
|
|||
if (mp.has_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
|
||||
{
|
||||
int oldNumNodes = numNodes;
|
||||
|
|
111
src/main.ino
111
src/main.ino
|
@ -52,7 +52,7 @@ esp_sleep_source_t wakeCause; // the reason we booted this time
|
|||
|
||||
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
|
||||
// esp_wifi_stop();
|
||||
|
@ -173,38 +173,32 @@ void scanI2Cdevice(void)
|
|||
err = Wire.endTransmission();
|
||||
if (err == 0)
|
||||
{
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.print(addr, HEX);
|
||||
Serial.println(" !");
|
||||
DEBUG_MSG("I2C device found at address 0x%x\n", addr);
|
||||
|
||||
nDevices++;
|
||||
|
||||
if (addr == SSD1306_ADDRESS)
|
||||
{
|
||||
ssd1306_found = true;
|
||||
Serial.println("ssd1306 display found");
|
||||
DEBUG_MSG("ssd1306 display found\n");
|
||||
}
|
||||
#ifdef T_BEAM_V10
|
||||
if (addr == AXP192_SLAVE_ADDRESS)
|
||||
{
|
||||
axp192_found = true;
|
||||
Serial.println("axp192 PMU found");
|
||||
DEBUG_MSG("axp192 PMU found\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (err == 4)
|
||||
{
|
||||
Serial.print("Unknow error at address 0x");
|
||||
if (addr < 16)
|
||||
Serial.print("0");
|
||||
Serial.println(addr, HEX);
|
||||
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
DEBUG_MSG("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
DEBUG_MSG("done\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,55 +219,56 @@ void axp192Init()
|
|||
{
|
||||
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
|
||||
{
|
||||
Serial.println("AXP192 Begin FAIL");
|
||||
}
|
||||
// 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";
|
||||
DEBUG_MSG("AXP192 Begin FAIL\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("AXP192 not found");
|
||||
DEBUG_MSG("AXP192 not found\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -291,7 +286,7 @@ void initDeepSleep()
|
|||
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()
|
||||
|
@ -399,7 +394,7 @@ void loop()
|
|||
{
|
||||
if (!wasPressed)
|
||||
{ // just started a new press
|
||||
Serial.println("pressing");
|
||||
DEBUG_MSG("pressing\n");
|
||||
wasPressed = true;
|
||||
minPressMs = millis() + 3000;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <Arduino.h>
|
||||
#include "configuration.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
#include <pb_encode.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);
|
||||
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
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -92,7 +92,7 @@ void screen_print(const char * text, uint8_t x, uint8_t y) {
|
|||
}
|
||||
|
||||
void screen_print(const char * text) {
|
||||
Serial.printf("Screen: %s\n", text);
|
||||
DEBUG_MSG("Screen: %s\n", text);
|
||||
if(!display) return;
|
||||
|
||||
display->print(text);
|
||||
|
@ -136,8 +136,9 @@ void screen_loop() {
|
|||
if (axp.isVbusRemoveIRQ()) {
|
||||
baChStatus = "No Charging";
|
||||
}
|
||||
Serial.println(baChStatus); //Prints charging status to screen
|
||||
digitalWrite(2, !digitalRead(2));
|
||||
DEBUG_MSG("%s\n", baChStatus); //Prints charging status to screen
|
||||
// This is not a GPIO actually connected on the tbeam board
|
||||
// digitalWrite(2, !digitalRead(2));
|
||||
axp.clearIRQ();
|
||||
}
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue