Skip to content

Commit

Permalink
Merge pull request #60 from nicholaswilde/conditional-display
Browse files Browse the repository at this point in the history
Conditional display
  • Loading branch information
nicholaswilde committed Apr 5, 2022
2 parents fbcef26 + 8e3a209 commit cc4ec93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define VOLTAGE_MIN 3000 // min voltage of lipo battery (V)
#define EXP_A 0.00348 // y = B * exp(A*x)
#define EXP_B 0.000000686 // y = B * exp(A*x)
#define DISPLAY_THRESHOLD 65 // threshold current for the display to turn on (mA)

// Pins
#define BUTTON_A 15
Expand Down
5 changes: 3 additions & 2 deletions solar-battery-charger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ void loop() {

int current = ina260.readCurrent();

print("Mode: ");

// Determine the mode by sign of current
if (current<0){
if (abs(current)<DISPLAY_THRESHOLD) display.oled_command(SH110X_DISPLAYOFF);
print("Mode: ");
println("recharge");
doDischarge = false;
} else {
print("Mode: ");
println("discharge");
doDischarge = true;
}
Expand Down

0 comments on commit cc4ec93

Please sign in to comment.