Dedicated setup.cpp to clean up main.cpp
Also includes update of timestamp calculation in Zephyr.
This commit is contained in:
+1
-54
@@ -16,6 +16,7 @@
|
||||
#include "thingset.h" // handles access to internal data via communication interfaces
|
||||
#include "pcb.h" // hardware-specific settings
|
||||
#include "config.h" // user-specific configuration
|
||||
#include "setup.h"
|
||||
|
||||
#include "half_bridge.h" // PWM generation for DC/DC converter
|
||||
#include "hardware.h" // hardware-related functions like watchdog, etc.
|
||||
@@ -31,60 +32,6 @@
|
||||
#include "data_objects.h" // for access to internal data via ThingSet
|
||||
#include "bl_support.h" // Bootloader support from the application side
|
||||
|
||||
DcBus lv_bus;
|
||||
PowerPort lv_terminal(&lv_bus, true); // low voltage terminal (battery for typical MPPT)
|
||||
|
||||
#if CONFIG_HAS_DCDC_CONVERTER
|
||||
DcBus hv_bus;
|
||||
PowerPort hv_terminal(&hv_bus, true); // high voltage terminal (solar for typical MPPT)
|
||||
PowerPort dcdc_lv_port(&lv_bus); // internal low voltage side of DC/DC converter
|
||||
#if CONFIG_HV_TERMINAL_NANOGRID
|
||||
Dcdc dcdc(&hv_terminal, &dcdc_lv_port, MODE_NANOGRID);
|
||||
#elif CONFIG_HV_TERMINAL_BATTERY
|
||||
Dcdc dcdc(&hv_terminal, &dcdc_lv_port, MODE_MPPT_BOOST);
|
||||
#else
|
||||
Dcdc dcdc(&hv_terminal, &dcdc_lv_port, MODE_MPPT_BUCK);
|
||||
#endif // CONFIG_HV_TERMINAL
|
||||
#endif
|
||||
|
||||
#if CONFIG_HAS_PWM_SWITCH
|
||||
PwmSwitch pwm_switch(&lv_bus);
|
||||
#endif
|
||||
|
||||
#if CONFIG_HAS_LOAD_OUTPUT
|
||||
PowerPort load_terminal(&lv_bus); // load terminal (also connected to lv_bus)
|
||||
LoadOutput load(&load_terminal);
|
||||
#endif
|
||||
|
||||
#if CONFIG_HV_TERMINAL_SOLAR
|
||||
PowerPort &solar_terminal = hv_terminal;
|
||||
#elif CONFIG_LV_TERMINAL_SOLAR
|
||||
PowerPort &solar_terminal = lv_terminal;
|
||||
#elif CONFIG_PWM_TERMINAL_SOLAR
|
||||
PowerPort &solar_terminal = pwm_switch;
|
||||
#endif
|
||||
|
||||
#if CONFIG_HV_TERMINAL_NANOGRID
|
||||
PowerPort &grid_terminal = hv_terminal;
|
||||
#endif
|
||||
|
||||
#if CONFIG_LV_TERMINAL_BATTERY
|
||||
PowerPort &bat_terminal = lv_terminal;
|
||||
#elif CONFIG_HV_TERMINAL_BATTERY
|
||||
PowerPort &bat_terminal = hv_terminal;
|
||||
#endif
|
||||
|
||||
Charger charger(&bat_terminal);
|
||||
|
||||
BatConf bat_conf; // actual (used) battery configuration
|
||||
BatConf bat_conf_user; // temporary storage where the user can write to
|
||||
|
||||
DeviceStatus dev_stat;
|
||||
|
||||
extern ThingSet ts; // defined in data_objects.cpp
|
||||
|
||||
time_t timestamp; // current unix timestamp (independent of time(NULL), as it is user-configurable)
|
||||
|
||||
Serial serial(PIN_SWD_TX, PIN_SWD_RX, "serial", 115200);
|
||||
|
||||
/** Main function including initialization and continuous loop
|
||||
|
||||
Reference in New Issue
Block a user