Skip to content

Commit

Permalink
updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ripred committed Jun 18, 2023
1 parent 256506d commit 5580f64
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions examples/Smooth_Callbacks/Smooth_Calbacks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,29 @@ void display() {
Serial.print(scratch);
}

void on_change(double const /* new_value */) {
Serial.print("on_change(...): ");
display();
void on_change(double const new_value) {
static int last = average();
if (last != (int) new_value) {
last = (int) new_value;
Serial.print("on_change(...): ");
display();
}
}

void on_upper(double const /* new_value */) {
Serial.print("on_upper(...): ");
void on_upper(double const new_value) {
static int last = average();
if (last != (int) new_value) {
last = (int) new_value;
Serial.print("on_upper(...): ");
}
}

void on_lower(double const /* new_value */) {
Serial.print("on_lower(...): ");
void on_lower(double const new_value) {
static int last = average();
if (last != (int) new_value) {
last = (int) new_value;
Serial.print("on_lower(...): ");
}
}

void setup() {
Expand Down

0 comments on commit 5580f64

Please sign in to comment.