Skip to content

Commit cb6fc99

Browse files
committed
Enable Watermark readings per cycle
1 parent 5065348 commit cb6fc99

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/Basic/Watermark10k/Watermark10k.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ void setup()
1010
while (!Serial && millis() < startNow)
1111
;
1212

13+
EdgeControl.begin();
1314
delay(2000);
1415

1516
Serial.println("Hello, 10k");
@@ -18,12 +19,12 @@ void setup()
1819
Power.on(PWR_VBAT);
1920

2021
Wire.begin();
21-
Expander.begin();
22+
delay(500);
2223

2324
Serial.print("Waiting for IO Expander Initialization...");
24-
while (!Expander) {
25+
while (!Expander.begin()) {
2526
Serial.print(".");
26-
delay(100);
27+
delay(250);
2728
}
2829
Serial.println(" done.");
2930

@@ -36,7 +37,6 @@ void setup()
3637
Watermark.commonMode(OUTPUT);
3738
Watermark.commonWrite(HIGH);
3839

39-
Watermark.enable();
4040
}
4141

4242
void loop()
@@ -56,8 +56,10 @@ int wmkAvgAnalogRead(pin_size_t pin)
5656
constexpr size_t count { 10 };
5757
unsigned int sum { 0 };
5858

59+
Watermark.enable();
5960
for (auto i = 0u; i < count; i ++)
6061
sum += Watermark.analogRead(pin);
62+
Watermark.disable();
6163

6264
return sum / count;
6365
}

0 commit comments

Comments
 (0)