pyfrc icon indicating copy to clipboard operation
pyfrc copied to clipboard

Add simple test type that allows you to specify when buttons are pressed

Open virtuald opened this issue 10 years ago • 4 comments
trafficstars

This is the most common type of simplistic test one might want, I imagine. The primary usefulness I think would be exercising all your stuff, so you can be sure that they don't have syntax errors. Adding an additional function that gets called to check it is nice, but should be optional. Something like.. hm. I don't really know what this looks like. Maybe:

# port, button number?
release = (1, 1)
fire = (1,2)

# time, button to press (defaults to pressing for 0.2s)
tests = [
  (1.0, release),
  (2.0, fire),
  .. 
]

run_button_test(tests)

@sarosenb you should do this.

virtuald avatar Dec 17 '14 08:12 virtuald

I can see the usefulness of this. What is the 1.0 and 2.0 in the test list used for?

sarosenb avatar Dec 17 '14 14:12 sarosenb

That would be the time to activate the button.

virtuald avatar Dec 17 '14 16:12 virtuald

I think what you can do is, if you want to assert something at the end of a test you could have something like this:

port, button number?

release = (1, 1) fire = (1,2)

time, button to press (defaults to pressing for 0.2s),

(optional)lamda to be run at end #of test

tests = [ (1.0, release, lamda:assert(hal_data['pwm'][0]['val'] = 1), (2.0, fire), .. ]

On Wed, Dec 17, 2014 at 11:19 AM, Dustin Spicuzza [email protected] wrote:

That would be the time to activate the button.

— Reply to this email directly or view it on GitHub https://github.com/robotpy/pyfrc/issues/8#issuecomment-67347267.

sarosenb avatar Dec 17 '14 17:12 sarosenb

yeah, the lambda thing was what I was thinking too.

virtuald avatar Dec 17 '14 17:12 virtuald