mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Initial commit
This commit is contained in:
commit
6c7efdd0f6
59 changed files with 8604 additions and 0 deletions
27
src/helpers/ArduinoHelpers.h
Normal file
27
src/helpers/ArduinoHelpers.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <Mesh.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
class VolatileRTCClock : public mesh::RTCClock {
|
||||
long millis_offset;
|
||||
public:
|
||||
VolatileRTCClock() { millis_offset = 1715770351; } // 15 May 2024, 8:50pm
|
||||
uint32_t getCurrentTime() override { return (millis()/1000 + millis_offset); }
|
||||
void setCurrentTime(uint32_t time) override { millis_offset = time - millis()/1000; }
|
||||
};
|
||||
|
||||
class ArduinoMillis : public mesh::MillisecondClock {
|
||||
public:
|
||||
unsigned long getMillis() override { return millis(); }
|
||||
};
|
||||
|
||||
class StdRNG : public mesh::RNG {
|
||||
public:
|
||||
void begin(long seed) { randomSeed(seed); }
|
||||
void random(uint8_t* dest, size_t sz) override {
|
||||
for (int i = 0; i < sz; i++) {
|
||||
dest[i] = (::random(0, 256) & 0xFF);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue