Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update USER_SETTINGS.cpp #717

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions Software/USER_SETTINGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,63 @@
#include "USER_SECRETS.h"
#include "src/devboard/hal/hal.h"

/* This file contains all the battery settings and limits */
/* They can be defined here, or later on in the WebUI */
/* Most important is to select which CAN interface each component is connected to */
/*
CAN_NATIVE = Native CAN port on the LilyGo & Stark hardware
CANFD_NATIVE = Native CANFD port on the Stark CMR hardware
CAN_ADDON_MCP2515 = Add-on CAN MCP2515 connected to GPIO pins
CANFD_ADDON_MCP2518 = Add-on CAN-FD MCP2518 connected to GPIO pins
*/
/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment change makes it HARDER to use the software, when the examples are removed.

It also removes the most important comment, that specifies the CAN mappings.

I suggest reverting all of it. There is no improvement here.

* Configuration file for battery settings, WiFi, CAN, MQTT, and other device behaviors.
* Adjust settings as needed, or manage them later in the WebUI.
*/

/* ------------------------- CAN Configuration ------------------------- */
/* CAN interface selection for each connected component. */
volatile CAN_Configuration can_config = {
.battery = CAN_NATIVE, // Which CAN is your battery connected to?
.inverter = CAN_NATIVE, // Which CAN is your inverter connected to? (No need to configure incase you use RS485)
.battery_double = CAN_ADDON_MCP2515, // (OPTIONAL) Which CAN is your second battery connected to?
.charger = CAN_NATIVE // (OPTIONAL) Which CAN is your charger connected to?
.battery = CAN_NATIVE, // Battery CAN interface
.inverter = CAN_NATIVE, // Inverter CAN interface (use RS485 if not configured)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not use RS485 automatically, bad wording. Original wording makes it more clear.

.battery_double = CAN_ADDON_MCP2515, // Optional: Second battery CAN interface
.charger = CAN_NATIVE // Optional: Charger CAN interface
};

std::string ssid = WIFI_SSID; // Set in USER_SECRETS.h
std::string password = WIFI_PASSWORD; // Set in USER_SECRETS.h
const char* ssidAP = "Battery Emulator"; // Maximum of 63 characters, also used for device name on web interface
const char* passwordAP = AP_PASSWORD; // Set in USER_SECRETS.h
const uint8_t wifi_channel = 0; // Set to 0 for automatic channel selection
/* ------------------------- WiFi Settings ------------------------- */
std::string ssid = WIFI_SSID; // WiFi SSID, defined in USER_SECRETS.h
std::string password = WIFI_PASSWORD; // WiFi password, defined in USER_SECRETS.h
const char* ssidAP = "Battery Emulator"; // Max 63 chars, also used as device name in WebUI
const char* passwordAP = AP_PASSWORD; // Access Point password, defined in USER_SECRETS.h
const uint8_t wifi_channel = 0; // 0 for automatic channel selection

/* ------------------------- Web Server Settings ------------------------- */
#ifdef WEBSERVER
const char* http_username = HTTP_USERNAME; // Set in USER_SECRETS.h
const char* http_password = HTTP_PASSWORD; // Set in USER_SECRETS.h
// Set your Static IP address. Only used incase WIFICONFIG is set in USER_SETTINGS.h
const char* http_username = HTTP_USERNAME; // Web server username, defined in USER_SECRETS.h
const char* http_password = HTTP_PASSWORD; // Web server password, defined in USER_SECRETS.h

// Static IP configuration (used only if WIFICONFIG is enabled in USER_SETTINGS.h)
IPAddress local_IP(192, 168, 10, 150);
IPAddress gateway(192, 168, 10, 1);
IPAddress subnet(255, 255, 255, 0);
#endif // WEBSERVER

// MQTT
/* ------------------------- MQTT Settings ------------------------- */
#ifdef MQTT
const char* mqtt_user = MQTT_USER; // Set in USER_SECRETS.h
const char* mqtt_password = MQTT_PASSWORD; // Set in USER_SECRETS.h
const char* mqtt_user = MQTT_USER; // MQTT username, defined in USER_SECRETS.h
const char* mqtt_password = MQTT_PASSWORD; // MQTT password, defined in USER_SECRETS.h

#ifdef MQTT_MANUAL_TOPIC_OBJECT_NAME
const char* mqtt_topic_name =
"BE"; // Custom MQTT topic name. Previously, the name was automatically set to "battery-emulator_esp32-XXXXXX"
const char* mqtt_object_id_prefix =
"be_"; // Custom prefix for MQTT object ID. Previously, the prefix was automatically set to "esp32-XXXXXX_"
const char* mqtt_device_name =
"Battery Emulator"; // Custom device name in Home Assistant. Previously, the name was automatically set to "BatteryEmulator_esp32-XXXXXX"
const char* mqtt_topic_name = "BE"; // Custom MQTT topic name
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments are VITAL for people updating from older versions. They should not be removed, since it makes using MQTT way harder.

const char* mqtt_object_id_prefix = "be_"; // Custom prefix for MQTT object IDs
const char* mqtt_device_name = "Battery Emulator"; // Custom device name in Home Assistant
#endif // MQTT_MANUAL_TOPIC_OBJECT_NAME
#endif // USE_MQTT
#endif // MQTT

/* ------------------------- Equipment Stop Button Settings ------------------------- */
#ifdef EQUIPMENT_STOP_BUTTON
// Equipment stop button behavior. Use NC button for safety reasons.
//LATCHING_SWITCH - Normally closed (NC), latching switch. When pressed it activates e-stop
//MOMENTARY_SWITCH - Short press to activate e-stop, long 15s press to deactivate. E-stop is persistent between reboots
// Define equipment stop button behavior for safety:
// LATCHING_SWITCH: Normally closed (NC) latching switch, activates e-stop when pressed.
// MOMENTARY_SWITCH: Short press activates e-stop; long (15s) press deactivates it. Persistent between reboots.
volatile STOP_BUTTON_BEHAVIOR equipment_stop_behavior = LATCHING_SWITCH;
#endif

/* Charger settings (Optional, when using generator charging) */
volatile float CHARGER_SET_HV = 384; // Reasonably appropriate 4.0v per cell charging of a 96s pack
volatile float CHARGER_MAX_HV = 420; // Max permissible output (VDC) of charger
volatile float CHARGER_MIN_HV = 200; // Min permissible output (VDC) of charger
volatile float CHARGER_MAX_POWER = 3300; // Max power capable of charger, as a ceiling for validating config
volatile float CHARGER_MAX_A = 11.5; // Max current output (amps) of charger
volatile float CHARGER_END_A = 1.0; // Current at which charging is considered complete
/* ------------------------- Charger Settings ------------------------- */
/* Charger settings for optional generator charging. */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are editing this comment, would be good to further clarify that Charger section is completely unused if no optional charger hardware has been configured. Not sure how to word it better...

volatile float CHARGER_SET_HV = 384.0f; // Default charging voltage (VDC) for a 96s pack
volatile float CHARGER_MAX_HV = 420.0f; // Max permissible charger output voltage (VDC)
volatile float CHARGER_MIN_HV = 200.0f; // Min permissible charger output voltage (VDC)
volatile float CHARGER_MAX_POWER = 3300; // Max charger power (W)
volatile float CHARGER_MAX_A = 11.5f; // Max charger current output (A)
volatile float CHARGER_END_A = 1.0f; // Current threshold for charge completion (A)
Loading