mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-06 06:52:26 +00:00
trunk fmt
This commit is contained in:
parent
e546220a80
commit
ceb884cf18
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
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("#########################################################")
|
||||
@ -16,7 +17,7 @@ def create_uf2(source, target, env):
|
||||
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,7 +79,7 @@ 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
|
||||
@ -83,7 +92,7 @@ def convert_from_hex_to_uf2(buf):
|
||||
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)
|
||||
|
@ -34,8 +34,7 @@
|
||||
#include "WVariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// Number of pins defined in PinDescription array
|
||||
|
Loading…
Reference in New Issue
Block a user