Skip to content

Commit

Permalink
Merge pull request #13 from mwood77/fix/reduce-mem-load
Browse files Browse the repository at this point in the history
Fix/reduce mem load
  • Loading branch information
mwood77 authored Jan 25, 2022
2 parents 40b2733 + 2bc4a1b commit 97f7045
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions koffie/koffie.ino
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
float const PRESSURE_SENSOR_INPUT_PIN{A3};
double const RELAY_CONTROL_OUTPUT_PIN{11}; // PWM compatible output @ 498 Hz (CHECK BEFORE CHANGING)
const int PRESSURE_TRANSDUCER_MAX_PSI = 60.0; // Change this value to the maximum value your pressure sensor can read in PSI. Ex: 30 PSI sensor = 30.0
const double ATMOSPHERIC_OFFSET{0.0};
const double ATMOSPHERIC_OFFSET{0.0}; // Example offset of -0.17 (measured against physical gauge)

/*
* These values control the overall "tuning" of the PID.
Expand Down Expand Up @@ -453,18 +453,19 @@

MEASUREMENT_INPUT = convertedReading;

if (MEASUREMENT_INPUT > SETPOINT) {
relay.setDutyCyclePercent(0);
relay.setRelayPosition(relayPositionOpen); // change relayPositionOpen to relayPositionClosed if your relay is normally open
} else {
relay.setDutyCyclePercent(CONTROL_OUTPUT / 255.0); // Relay library only accepts values between 0 and 1
}

// COMPUTE PID LEVELS
pidControl.Compute();

// APPLY PID COMPUTE TO RELAY
relay.loop();

if (MEASUREMENT_INPUT > SETPOINT) {
relay.setDutyCyclePercent(0);
} else {
relay.setDutyCyclePercent(CONTROL_OUTPUT / 255.0); // Relay library only accepts values between 0 and 1
}

// Serial.print(F("SETPOINT: "));
// Serial.print(SETPOINT); // only displays in BAR in serial monitor
// Serial.print(F(" | MEASUREMENT_INPUT: "));
Expand Down Expand Up @@ -589,22 +590,24 @@
display.fillRect(66, 20, 62, 64, BLACK);
display.setTextColor(WHITE, BLACK);

if (CURRENT_MODE == 25) {

display.setCursor(70, 28);
display.print(F("TARG "));

if (MEASUREMENT_UNIT == 'F') {
display.print(convertedSetPoint);
} else {
display.print(SETPOINT);
}

display.setCursor(70, 48);
display.print(F("ACTL "));
display.print(pressure, 2);

} else {

// *********************************************************************************************************
// If you want to display a digital readout of the current (unfiltered) pressure in MANU mode,
// uncomment the lines beneath and the closing bracket at line 629.
// *********************************************************************************************************
//
// if (CURRENT_MODE == 25) {
// display.setCursor(70, 28);
// display.print(F("TARG "));
// if (MEASUREMENT_UNIT == 'F') {
// display.print(convertedSetPoint);
// } else {
// display.print(SETPOINT);
// }
// display.setCursor(70, 48);
// display.print(F("ACTL "));
// display.print(pressure, 2);
// } else {

display.setTextSize(2);
display.setCursor(74, 35);
Expand All @@ -623,11 +626,10 @@
} else {
display.print(F("BAR"));
}

}
// }

display.display();

}

/**
Expand Down

0 comments on commit 97f7045

Please sign in to comment.