code sanitization (decentralized several vars, 2)

This commit is contained in:
cyberman54 2021-03-31 21:43:51 +02:00
parent e439d932b9
commit 9335161676
18 changed files with 42 additions and 23 deletions

View File

@ -5,6 +5,8 @@
#include "reset.h"
#include <Preferences.h>
extern configData_t cfg;
void saveConfig(bool erase = false);
bool loadConfig(void);
void eraseConfig(void);

View File

@ -13,6 +13,7 @@
#include "sdcard.h"
#include "reset.h"
#include "led.h"
#include "power.h"
extern Ticker cyclicTimer;

View File

@ -4,6 +4,7 @@
#include <libpax_api.h>
#include "cyclic.h"
#include "qrcode.h"
#include "power.h"
#if (COUNT_ENS)
#include "corona.h"
@ -77,7 +78,10 @@
#define QR_VERSION 3 // 29 x 29px
const uint8_t QR_SCALEFACTOR = (MY_DISPLAY_HEIGHT - 4) / 29; // 4px borderlines
extern uint8_t DisplayIsOn, displaybuf[];
extern hw_timer_t *displayIRQ;
extern uint8_t volatile channel; // wifi channel rotation counter
void dp_setup(int contrast = 0);
void dp_refresh(bool nextPage = false);

View File

@ -50,16 +50,7 @@
#define _seconds() millis() / 1000.0
enum timesource_t { _gps, _rtc, _lora, _set, _unsynced };
enum snifftype_t { MAC_SNIFF_WIFI, MAC_SNIFF_BLE, MAC_SNIFF_BLE_ENS };
enum runmode_t {
RUNMODE_POWERCYCLE,
RUNMODE_NORMAL,
RUNMODE_WAKEUP,
RUNMODE_UPDATE,
RUNMODE_SLEEP,
RUNMODE_MAINTENANCE
};
// Struct holding devices's runtime configuration
// using packed to avoid compiler padding, because struct will be memcpy'd to
@ -125,16 +116,6 @@ typedef struct {
extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons;
extern configData_t cfg; // current device configuration
extern char clientId[20]; // unique clientID
extern uint8_t batt_level; // display value
extern uint16_t volatile libpax_macs_ble, libpax_macs_wifi; // libpax values
extern uint8_t volatile channel; // wifi channel rotation counter
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
extern timesource_t timeSource;
extern hw_timer_t *displayIRQ, *matrixDisplayIRQ, *ppsIRQ;
extern SemaphoreHandle_t I2Caccess;
extern TaskHandle_t irqHandlerTask, ClockTask;
extern Timezone myTZ;
#endif

View File

@ -21,6 +21,8 @@
#define MY_DISPLAY_SCL SCL
#endif
extern SemaphoreHandle_t I2Caccess;
void i2c_init(void);
void i2c_deinit(void);
void i2c_scan(void);

View File

@ -26,6 +26,8 @@ void mask_user_IRQ();
void unmask_user_IRQ();
void doIRQ(int irq);
extern TaskHandle_t irqHandlerTask;
#ifdef HAS_DISPLAY
void IRAM_ATTR DisplayIRQ();
#endif

View File

@ -6,8 +6,8 @@
#include "ledmatrixdisplay.h"
extern uint8_t MatrixDisplayIsOn;
extern LEDMatrix matrix;
extern hw_timer_t *matrixDisplayIRQ;
void init_matrix_display(bool reverse = false);
void refreshTheMatrixDisplay(bool nextPage = false);

View File

@ -7,4 +7,6 @@
void init_libpax();
extern uint16_t volatile libpax_macs_ble, libpax_macs_wifi; // libpax values
#endif

View File

@ -21,5 +21,6 @@
#include "corona.h"
#include "boot.h"
#include "libpax_helpers.h"
#include "power.h"
#endif

View File

@ -3,6 +3,7 @@
#include "sensor.h"
#include "sds011read.h"
#include "gpsread.h"
// MyDevices CayenneLPP 1.0 channels for Synamic sensor payload format
// all payload goes out on LoRa FPort 1
@ -100,5 +101,6 @@ private:
};
extern PayloadConvert payload;
extern uint8_t batt_level;
#endif // _PAYLOAD_H_

View File

@ -11,6 +11,7 @@
#include "cyclic.h"
#include "timekeeper.h"
#include "timesync.h"
#include "power.h"
// maximum number of elements in rcommand interpreter queue
#define RCMD_QUEUE_SIZE 5

View File

@ -16,6 +16,15 @@ void enter_deepsleep(const uint64_t wakeup_sec = 60,
const gpio_num_t wakeup_gpio = GPIO_NUM_MAX);
unsigned long long uptime(void);
enum runmode_t {
RUNMODE_POWERCYCLE,
RUNMODE_NORMAL,
RUNMODE_WAKEUP,
RUNMODE_UPDATE,
RUNMODE_SLEEP,
RUNMODE_MAINTENANCE
};
extern RTC_NOINIT_ATTR runmode_t RTC_runmode;
extern RTC_NOINIT_ATTR uint32_t RTC_restarts;

View File

@ -2,6 +2,7 @@
#define _SENDDATA_H
#include <libpax_api.h>
#include "libpax_helpers.h"
#include "spislave.h"
#include "mqttclient.h"
#include "cyclic.h"

View File

@ -1,6 +1,8 @@
#ifndef _SENSOR_H
#define _SENSOR_H
#include "configmanager.h"
#define HAS_SENSORS (HAS_SENSOR_1 || HAS_SENSOR_2 || HAS_SENSOR_3)
uint8_t sensor_mask(uint8_t sensor_no);

View File

@ -10,8 +10,15 @@
#include "if482.h"
#include "dcf77.h"
enum timesource_t { _gps, _rtc, _lora, _set, _unsynced };
extern const char timeSetSymbols[];
extern Ticker timesyncer;
extern timesource_t timeSource;
extern TaskHandle_t ClockTask;
extern Timezone myTZ;
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
extern hw_timer_t *ppsIRQ;
void IRAM_ATTR CLOCKIRQ(void);
void clock_init(void);

View File

@ -17,6 +17,8 @@ static const char TAG[] = __FILE__;
Preferences nvram;
configData_t cfg; // struct holds current device configuration
static const uint8_t cfgMagicBytes[] = {0x21, 0x76, 0x87, 0x32, 0xf4};
static const size_t cfgLen = sizeof(cfg), cfgLen2 = sizeof(cfgMagicBytes);
static uint8_t buffer[cfgLen + cfgLen2];

View File

@ -89,8 +89,6 @@ triggers pps 1 sec impulse
// local Tag for logging
static const char TAG[] = __FILE__;
configData_t cfg; // struct holds current device configuration
uint8_t batt_level = 0; // display value
char clientId[20] = {0}; // unique ClientID
void setup() {

View File

@ -5,6 +5,8 @@
// Local logging tag
static const char TAG[] = __FILE__;
uint8_t batt_level = 0; // display value
#ifdef BAT_MEASURE_ADC
esp_adc_cal_characteristics_t *adc_characs =
(esp_adc_cal_characteristics_t *)calloc(