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

New feature: Test fake battery #94

Merged
merged 9 commits into from
Nov 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add RGB LED test
  • Loading branch information
dalathegreat committed Nov 13, 2023
commit edf032947bde07049b6256455897d8689a43904a
4 changes: 4 additions & 0 deletions Software/Software.ino
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ uint16_t cell_min_voltage = 3700; // Stores the minimum cell voltage value in t
#define YELLOW 1
#define RED 2
#define BLUE 3
#define TEST_ALL_COLORS 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

To me it seems a bit strange that the led states are defined twice: once in Software.ino, and once in the battery file. Perhaps not blocking for this PR, but for the future it may be useful to define these states once in a separate header file, which can then be included by both Software.ino and the battery file.

Copy link
Owner Author

@dalathegreat dalathegreat Nov 14, 2023

Choose a reason for hiding this comment

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

Great suggestion, I refactored this and put it in a header in commit 2621e29 EDIT: and fixed a typo in d4290cc


Adafruit_NeoPixel pixels(1, WS2812_PIN, NEO_GRB + NEO_KHZ800);
static uint8_t brightness = 0;
@@ -451,6 +452,9 @@ void handle_LED_state() {
case RED:
pixels.setPixelColor(0, pixels.Color(150, 0, 0)); // Red LED full brightness
break;
case TEST_ALL_COLORS:
pixels.setPixelColor(0, pixels.Color(brightness, abs((100 - brightness)), abs((50 - brightness)))); // RGB
break;
default:
break;
}
2 changes: 1 addition & 1 deletion Software/USER_SETTINGS.h
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
//#define NISSAN_LEAF_BATTERY
//#define RENAULT_ZOE_BATTERY
//#define TESLA_MODEL_3_BATTERY
//#define TEST_FAKE_BATTERY
#define TEST_FAKE_BATTERY

/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */
//#define BYD_CAN //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus
2 changes: 1 addition & 1 deletion Software/src/battery/TEST-FAKE-BATTERY.cpp
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ void print_units(char* header, int value, char* units) {
void update_values_test_battery() { /* This function puts fake values onto the parameters sent towards the inverter */
bms_status = ACTIVE; //Always be in Active mode

LEDcolor = GREEN;
LEDcolor = TEST_ALL_COLORS; // Cycle the LED thru all available colors

SOC = 5000; // 50.00%

1 change: 1 addition & 0 deletions Software/src/battery/TEST-FAKE-BATTERY.h
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ extern uint8_t LEDcolor; //Enum, 0-2
#define YELLOW 1
#define RED 2
#define BLUE 3
#define TEST_ALL_COLORS 10

void update_values_test_battery();
void receive_can_test_battery(CAN_frame_t rx_frame);