trunk fmt

This commit is contained in:
Thomas Göttgens 2024-06-16 16:29:45 +02:00
parent e546220a80
commit ceb884cf18
5 changed files with 214 additions and 214 deletions

View File

@ -351,19 +351,19 @@ class AnalogBatteryLevel : public HasBatteryLevel
virtual bool isVbusIn() override
{
#ifdef EXT_PWR_DETECT
#ifdef HELTEC_CAPSULE_SENSOR_V3
#ifdef HELTEC_CAPSULE_SENSOR_V3
// if external powered that pin will be pulled down
if (digitalRead(EXT_PWR_DETECT) == LOW) {
return true;
}
// if it's not LOW - check the battery
#else
#else
// if external powered that pin will be pulled up
if (digitalRead(EXT_PWR_DETECT) == HIGH) {
return true;
}
// if it's not HIGH - check the battery
#endif
#endif
#endif
return getBattVoltage() > chargingVolt;
}
@ -461,11 +461,11 @@ Power::Power() : OSThread("Power")
bool Power::analogInit()
{
#ifdef EXT_PWR_DETECT
#ifdef HELTEC_CAPSULE_SENSOR_V3
#ifdef HELTEC_CAPSULE_SENSOR_V3
pinMode(EXT_PWR_DETECT, INPUT_PULLUP);
#else
#else
pinMode(EXT_PWR_DETECT, INPUT);
#endif
#endif
#endif
#ifdef EXT_CHRG_DETECT
pinMode(EXT_CHRG_DETECT, ext_chrg_detect_mode);

View File

@ -1,8 +1,8 @@
#pragma once
#include "../variants/rak2560/RAK9154Sensor.h"
#include "PowerStatus.h"
#include "concurrency/OSThread.h"
#include "configuration.h"
#include "../variants/rak2560/RAK9154Sensor.h"
#ifdef ARCH_ESP32
#include <esp_adc_cal.h>
@ -56,7 +56,7 @@ extern RAK9154Sensor rak9154Sensor;
class Power : private concurrency::OSThread
{
public:
public:
Observable<const meshtastic::PowerStatus *> newStatus;
Power();
@ -68,7 +68,7 @@ public:
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
const uint16_t OCV[11] = {OCV_ARRAY};
protected:
protected:
meshtastic::PowerStatus *statusHandler;
/// Setup a xpowers chip axp192/axp2101, return true if found
@ -76,7 +76,7 @@ protected:
/// Setup a simple ADC input based battery sensor
bool analogInit();
private:
private:
// open circuit voltage lookup table
uint8_t low_voltage_counter;
#ifdef DEBUG_HEAP

View File

@ -4,8 +4,8 @@
#include "../modules/Telemetry/Sensor/TelemetrySensor.h"
#include "configuration.h"
#include <RAK-OneWireSerial.h>
#include "concurrency/Periodic.h"
#include <RAK-OneWireSerial.h>
using namespace concurrency;
@ -27,8 +27,7 @@ static uint8_t provision = 0;
static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT_E eid, uint8_t *msg, uint16_t len)
{
switch (eid)
{
switch (eid) {
case SNHUBAPI_EVT_RECV_REQ:
case SNHUBAPI_EVT_RECV_RSP:
break;
@ -62,12 +61,10 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
// LOG_INFO("%02x,", msg[i]);
// }
// LOG_INFO("\r\n");
switch (msg[0])
{
switch (msg[0]) {
case RAK_IPSO_CAPACITY:
dc_prec = msg[1];
if (dc_prec > 100)
{
if (dc_prec > 100) {
dc_prec = 100;
}
break;
@ -92,12 +89,10 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
// }
// LOG_INFO("\r\n");
switch (msg[0])
{
switch (msg[0]) {
case RAK_IPSO_CAPACITY:
dc_prec = msg[1];
if (dc_prec > 100)
{
if (dc_prec > 100) {
dc_prec = 100;
}
break;
@ -129,21 +124,18 @@ static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT
static int32_t onewireHandle()
{
if (provision != 0)
{
if (provision != 0) {
RakSNHub_Protocl_API.get.data(provision);
provision = 0;
}
while (mySerial.available())
{
while (mySerial.available()) {
char a = mySerial.read();
buff[bufflen++] = a;
delay(2); // continue data, timeout=2ms
}
if (bufflen != 0)
{
if (bufflen != 0) {
RakSNHub_Protocl_API.process((uint8_t *)buff, bufflen);
bufflen = 0;
}

View File

@ -1,22 +1,23 @@
import sys
import struct
import sys
Import("env")
# Parse input and create UF2 file
def create_uf2(source, target, env):
# source_hex = target[0].get_abspath()
source_hex = target[0].get_string(False)
source_hex = '.\\'+source_hex
source_hex = ".\\" + source_hex
print("#########################################################")
print("Create UF2 from "+source_hex)
print("Create UF2 from " + source_hex)
print("#########################################################")
# print("Source: " + source_hex)
target = source_hex.replace(".hex", "")
target = target + ".uf2"
# print("Target: " + target)
with open(source_hex, mode='rb') as f:
with open(source_hex, mode="rb") as f:
inpbuf = f.read()
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
@ -48,9 +49,17 @@ class Block:
flags = 0x0
if familyid:
flags |= 0x2000
hd = struct.pack("<IIIIIIII",
UF2_MAGIC_START0, UF2_MAGIC_START1,
flags, self.addr, 256, blockno, numblocks, familyid)
hd = struct.pack(
"<IIIIIIII",
UF2_MAGIC_START0,
UF2_MAGIC_START1,
flags,
self.addr,
256,
blockno,
numblocks,
familyid,
)
hd += self.bytes[0:256]
while len(hd) < 512 - 4:
hd += b"\x00"
@ -70,20 +79,20 @@ def convert_from_hex_to_uf2(buf):
upper = 0
currblock = None
blocks = []
for line in buf.split('\n'):
for line in buf.split("\n"):
if line[0] != ":":
continue
i = 1
rec = []
while i < len(line) - 1:
rec.append(int(line[i:i+2], 16))
rec.append(int(line[i : i + 2], 16))
i += 2
tp = rec[3]
if tp == 4:
upper = ((rec[4] << 8) | rec[5]) << 16
elif tp == 2:
upper = ((rec[4] << 8) | rec[5]) << 4
assert (upper & 0xffff) == 0
assert (upper & 0xFFFF) == 0
elif tp == 1:
break
elif tp == 0:
@ -92,10 +101,10 @@ def convert_from_hex_to_uf2(buf):
appstartaddr = addr
i = 4
while i < len(rec) - 1:
if not currblock or currblock.addr & ~0xff != addr & ~0xff:
currblock = Block(addr & ~0xff)
if not currblock or currblock.addr & ~0xFF != addr & ~0xFF:
currblock = Block(addr & ~0xFF)
blocks.append(currblock)
currblock.bytes[addr & 0xff] = rec[i]
currblock.bytes[addr & 0xFF] = rec[i]
addr += 1
i += 1
numblocks = len(blocks)

View File

@ -34,8 +34,7 @@
#include "WVariant.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif // __cplusplus
// Number of pins defined in PinDescription array
@ -56,7 +55,7 @@ extern "C"
#define LED_STATE_ON 1 // State when LED is litted
/*
/*
* Buttons
*/
@ -78,14 +77,14 @@ extern "C"
#define PIN_A6 (0xff)
#define PIN_A7 (0xff)
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
#define ADC_RESOLUTION 14
// Other pins
@ -93,7 +92,7 @@ extern "C"
#define PIN_NFC1 (9)
#define PIN_NFC2 (10)
static const uint8_t AREF = PIN_AREF;
static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
@ -118,12 +117,12 @@ extern "C"
#define PIN_SPI1_MOSI (30) // (0 + 30)
#define PIN_SPI1_SCK (3) // (0 + 3)
static const uint8_t SS = 42;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
static const uint8_t SS = 42;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
/*
/*
* eink display pins
*/
@ -159,7 +158,7 @@ extern "C"
#define EXTERNAL_FLASH_DEVICES IS25LP080D
#define EXTERNAL_FLASH_USE_QSPI
/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports
/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports
RAK5005-O <-> nRF52840
IO1 <-> P0.17 (Arduino GPIO number 17)
IO2 <-> P1.02 (Arduino GPIO number 34)
@ -174,29 +173,29 @@ extern "C"
SPI_CS <-> P0.26 (Arduino GPIO number 26)
*/
// RAK4630 LoRa module
// RAK4630 LoRa module
/* Setup of the SX1262 LoRa module ( https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/ )
/* Setup of the SX1262 LoRa module ( https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/ )
P1.10 NSS SPI NSS (Arduino GPIO number 42)
P1.11 SCK SPI CLK (Arduino GPIO number 43)
P1.12 MOSI SPI MOSI (Arduino GPIO number 44)
P1.13 MISO SPI MISO (Arduino GPIO number 45)
P1.14 BUSY BUSY signal (Arduino GPIO number 46)
P1.15 DIO1 DIO1 event interrupt (Arduino GPIO number 47)
P1.06 NRESET NRESET manual reset of the SX1262 (Arduino GPIO number 38)
P1.10 NSS SPI NSS (Arduino GPIO number 42)
P1.11 SCK SPI CLK (Arduino GPIO number 43)
P1.12 MOSI SPI MOSI (Arduino GPIO number 44)
P1.13 MISO SPI MISO (Arduino GPIO number 45)
P1.14 BUSY BUSY signal (Arduino GPIO number 46)
P1.15 DIO1 DIO1 event interrupt (Arduino GPIO number 47)
P1.06 NRESET NRESET manual reset of the SX1262 (Arduino GPIO number 38)
Important for successful SX1262 initialization:
Important for successful SX1262 initialization:
* Setup DIO2 to control the antenna switch
* Setup DIO3 to control the TCXO power supply
* Setup the SX1262 to use it's DCDC regulator and not the LDO
* RAK4630 schematics show GPIO P1.07 connected to the antenna switch, but it should not be initialized, as DIO2 will do the
control of the antenna switch
* Setup DIO2 to control the antenna switch
* Setup DIO3 to control the TCXO power supply
* Setup the SX1262 to use it's DCDC regulator and not the LDO
* RAK4630 schematics show GPIO P1.07 connected to the antenna switch, but it should not be initialized, as DIO2 will do the
control of the antenna switch
SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
*/
*/
#define DETECTION_SENSOR_EN 4