Skip to content

Commit

Permalink
Add missing static keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Jan 28, 2025
1 parent 138b4cc commit a706cf9
Show file tree
Hide file tree
Showing 13 changed files with 302 additions and 299 deletions.
526 changes: 263 additions & 263 deletions src/yasolr_dashboard.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/yasolr_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#define YASOLR_DISPLAY_LINE_SIZE 21

Mycila::EasyDisplay* display = nullptr;
Mycila::Task* displayTask = nullptr;

uint8_t startingInformation = 1;
uint32_t lastDisplayUpdate = 0;
static Mycila::Task* displayTask = nullptr;
static uint8_t startingInformation = 1;
static uint32_t lastDisplayUpdate = 0;

void yasolr_init_display() {
if (config.getBool(KEY_ENABLE_DISPLAY)) {
Expand Down
3 changes: 2 additions & 1 deletion src/yasolr_ds18.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
Mycila::DS18* ds18O1 = nullptr;
Mycila::DS18* ds18O2 = nullptr;
Mycila::DS18* ds18Sys = nullptr;
Mycila::Task* ds18Task = nullptr;

static Mycila::Task* ds18Task = nullptr;

void yasolr_init_ds18() {
logger.info(TAG, "Initialize DS18 probes...");
Expand Down
3 changes: 2 additions & 1 deletion src/yasolr_jsy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include <yasolr.h>

Mycila::JSY* jsy = nullptr;
Mycila::Task* jsyTask = nullptr;
Mycila::TaskManager* jsyTaskManager = nullptr;

static Mycila::Task* jsyTask = nullptr;

void yasolr_init_jsy() {
if (config.getBool(KEY_ENABLE_JSY)) {
assert(!jsy);
Expand Down
2 changes: 1 addition & 1 deletion src/yasolr_lights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Mycila::TrafficLight lights;

Mycila::Task lightsTask("Lights", [](void* params) {
static Mycila::Task lightsTask("Lights", [](void* params) {
if (!safeBootTask.isPaused()) {
lights.setAllOn();
return;
Expand Down
5 changes: 3 additions & 2 deletions src/yasolr_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include <yasolr.h>

Mycila::Logger logger;
Mycila::Task* loggingTask = nullptr;
WebSerial* webSerial = nullptr;

static Mycila::Task* loggingTask = nullptr;
static WebSerial* webSerial = nullptr;

void yasolr_init_logging() {
logger.info(TAG, "Initialize logging...");
Expand Down
14 changes: 7 additions & 7 deletions src/yasolr_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Mycila::Task* mqttPublishConfigTask = nullptr;
Mycila::Task* mqttPublishStaticTask = nullptr;
Mycila::Task* mqttPublishTask = nullptr;

Mycila::Task* haDiscoveryTask = nullptr;
static Mycila::Task* haDiscoveryTask = nullptr;

void connect() {
static void connect() {
mqtt->end();

bool secured = config.getBool(KEY_MQTT_SECURED);
Expand Down Expand Up @@ -53,7 +53,7 @@ void connect() {
mqtt->begin(mqttConfig);
}

void subscribe() {
static void subscribe() {
logger.info(TAG, "Subscribing to MQTT topics...");

const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC);
Expand Down Expand Up @@ -185,7 +185,7 @@ void subscribe() {
}
}

void publishConfig() {
static void publishConfig() {
logger.info(TAG, "Publishing config to MQTT...");
const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC);

Expand All @@ -197,7 +197,7 @@ void publishConfig() {
}
}

void publishStaticData() {
static void publishStaticData() {
logger.info(TAG, "Publishing static data to MQTT...");
const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC);

Expand Down Expand Up @@ -228,7 +228,7 @@ void publishStaticData() {
yield();
}

void publishData() {
static void publishData() {
const std::string& baseTopic = config.getString(KEY_MQTT_TOPIC);

Mycila::System::Memory memory;
Expand Down Expand Up @@ -309,7 +309,7 @@ void publishData() {
}
}

void haDiscovery() {
static void haDiscovery() {
logger.info(TAG, "Publishing Home Assistant Discovery configuration");

Mycila::HA::Discovery haDiscovery;
Expand Down
4 changes: 2 additions & 2 deletions src/yasolr_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*/
#include <yasolr.h>

Mycila::Task networkManagerTask("ESPConnect", [](void* params) { espConnect.loop(); });
static Mycila::Task networkManagerTask("ESPConnect", [](void* params) { espConnect.loop(); });

Mycila::Task networkStartTask("Network Start", Mycila::TaskType::ONCE, [](void* params) {
static Mycila::Task networkStartTask("Network Start", Mycila::TaskType::ONCE, [](void* params) {
logger.info(TAG, "Enable Network Services...");

// Web server
Expand Down
3 changes: 2 additions & 1 deletion src/yasolr_pzem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Mycila::PZEM* pzemO1 = nullptr;
Mycila::PZEM* pzemO2 = nullptr;
Mycila::Task* pzemO1PairingTask = nullptr;
Mycila::Task* pzemO2PairingTask = nullptr;
Mycila::Task* pzemTask = nullptr;
Mycila::TaskManager* pzemTaskManager = nullptr;

static Mycila::Task* pzemTask = nullptr;

void yasolr_init_pzem() {
logger.info(TAG, "Initialize PZEM...");
uint8_t count = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/yasolr_relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

Mycila::RouterRelay* relay1 = nullptr;
Mycila::RouterRelay* relay2 = nullptr;
Mycila::Task* relayTask = nullptr;

static Mycila::Task* relayTask = nullptr;

void yasolr_init_relays() {
logger.info(TAG, "Initialize relays...");
Expand Down
24 changes: 12 additions & 12 deletions src/yasolr_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Mycila::RouterOutput* output1 = nullptr;
Mycila::RouterOutput* output2 = nullptr;

// ZCD
Mycila::ZeroCrossDimmer* zcDimmer1 = nullptr;
Mycila::ZeroCrossDimmer* zcDimmer2 = nullptr;
Mycila::PulseAnalyzer* pulseAnalyzer = nullptr;
Mycila::Task* zcdTask = nullptr;
static Mycila::ZeroCrossDimmer* zcDimmer1 = nullptr;
static Mycila::ZeroCrossDimmer* zcDimmer2 = nullptr;
static Mycila::Task* zcdTask = nullptr;

// tasks

Mycila::Task calibrationTask("Calibration", [](void* params) { router.continueCalibration(); });
static Mycila::Task calibrationTask("Calibration", [](void* params) { router.continueCalibration(); });

Mycila::Task routerTask("Router", [](void* params) {
static Mycila::Task routerTask("Router", [](void* params) {
std::optional<float> voltage = grid.getVoltage();

if (!voltage.has_value() || grid.getPower().isAbsent())
Expand All @@ -43,14 +43,14 @@ Mycila::Task routerTask("Router", [](void* params) {

// functions

bool isZeroCrossBased(const char* type) {
static bool isZeroCrossBased(const char* type) {
return strcmp(type, YASOLR_DIMMER_LSA_PWM_ZCD) == 0 ||
strcmp(type, YASOLR_DIMMER_ROBODYN) == 0 ||
strcmp(type, YASOLR_DIMMER_RANDOM_SSR) == 0 ||
strcmp(type, YASOLR_DIMMER_TRIAC) == 0;
}

Mycila::Dimmer* createDimmer1() {
static Mycila::Dimmer* createDimmer1() {
if (config.getBool(KEY_ENABLE_OUTPUT1_DIMMER)) {
const char* type = config.get(KEY_OUTPUT1_DIMMER_TYPE);
Mycila::Dimmer* dimmer = nullptr;
Expand Down Expand Up @@ -81,7 +81,7 @@ Mycila::Dimmer* createDimmer1() {
return nullptr;
}

Mycila::Dimmer* createDimmer2() {
static Mycila::Dimmer* createDimmer2() {
if (config.getBool(KEY_ENABLE_OUTPUT2_DIMMER)) {
const char* type = config.get(KEY_OUTPUT2_DIMMER_TYPE);
Mycila::Dimmer* dimmer = nullptr;
Expand Down Expand Up @@ -112,7 +112,7 @@ Mycila::Dimmer* createDimmer2() {
return nullptr;
}

Mycila::Relay* createBypassRelay1() {
static Mycila::Relay* createBypassRelay1() {
if (config.getBool(KEY_ENABLE_OUTPUT1_RELAY)) {
Mycila::Relay* relay = new Mycila::Relay();
relay->begin(config.getLong(KEY_PIN_OUTPUT1_RELAY), config.isEqual(KEY_OUTPUT1_RELAY_TYPE, YASOLR_RELAY_TYPE_NC) ? Mycila::RelayType::NC : Mycila::RelayType::NO);
Expand All @@ -136,7 +136,7 @@ Mycila::Relay* createBypassRelay1() {
return nullptr;
}

Mycila::Relay* createBypassRelay2() {
static Mycila::Relay* createBypassRelay2() {
if (config.getBool(KEY_ENABLE_OUTPUT2_RELAY)) {
Mycila::Relay* relay = new Mycila::Relay();
relay->begin(config.getLong(KEY_PIN_OUTPUT2_RELAY), config.isEqual(KEY_OUTPUT2_RELAY_TYPE, YASOLR_RELAY_TYPE_NC) ? Mycila::RelayType::NC : Mycila::RelayType::NO);
Expand All @@ -160,7 +160,7 @@ Mycila::Relay* createBypassRelay2() {
return nullptr;
}

void initOutput1(uint16_t semiPeriod) {
static void initOutput1(uint16_t semiPeriod) {
Mycila::Dimmer* dimmer = createDimmer1();
Mycila::Relay* bypassRelay = createBypassRelay1();

Expand Down Expand Up @@ -196,7 +196,7 @@ void initOutput1(uint16_t semiPeriod) {
}
}

void initOutput2(uint16_t semiPeriod) {
static void initOutput2(uint16_t semiPeriod) {
Mycila::Dimmer* dimmer = createDimmer2();
Mycila::Relay* bypassRelay = createBypassRelay2();

Expand Down
2 changes: 1 addition & 1 deletion src/yasolr_trial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <yasolr.h>

#ifdef APP_MODEL_TRIAL
Mycila::Task* trialTask = nullptr;
static Mycila::Task* trialTask = nullptr;
#endif

void yasolr_init_trial() {
Expand Down
6 changes: 2 additions & 4 deletions src/yasolr_web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ extern const uint8_t config_html_gz_start[] asm("_binary__pio_data_config_html_g
extern const uint8_t config_html_gz_end[] asm("_binary__pio_data_config_html_gz_end");

AsyncWebServer webServer(80);

AsyncAuthenticationMiddleware authMiddleware;
AsyncLoggingMiddleware loggingMiddleware;

ESPDash dashboard(webServer, "/dashboard", false);
Mycila::ESPConnect espConnect(webServer);

static AsyncAuthenticationMiddleware authMiddleware;
static AsyncLoggingMiddleware loggingMiddleware;
YaSolR::Website website;

Mycila::Task dashboardInitTask("Init Dashboard", Mycila::TaskType::ONCE, [](void* params) {
Expand Down

0 comments on commit a706cf9

Please sign in to comment.