Skip to content

Commit

Permalink
Update test_all_apis (test_pwm_multi_duty)
Browse files Browse the repository at this point in the history
- in test_pwm_multi_duty,
Increased the N to 5000 because
if N is too small, sometimes the test could fail.
  • Loading branch information
pjueon committed Jan 12, 2022
1 parent 8565759 commit cb59c5e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions samples/test_all_apis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,16 @@ class APITests

GPIO::PWM p(pin_data.out_a, 500);
p.start(pct);
constexpr int N = 1000;
constexpr int N = 5000;
for (int i = 0; i < N; i++)
count += GPIO::input(pin_data.in_a);

p.stop();

auto min_ct = 10 * (pct - 5);
auto max_ct = 10 * (pct + 5);
const auto weight = N / 100.0;
const auto delta = 5;
const auto min_ct = weight * (pct - delta);
const auto max_ct = weight * (pct + delta);

assert(min_ct <= count && count <= max_ct);
GPIO::cleanup();
Expand Down

0 comments on commit cb59c5e

Please sign in to comment.