Here is my code. I have been experimenting with the Toggle class and the plain getRawButton methods however I noticed that when I have a lot of buttons to handle like this some problems start to arise. Sometimes buttons won't work while I am moving the robot or I can only do one button at a time. I understand this is likely a problem with using all the if statements. (I tried if/elif) but I still get a lot of problems like that. My question is: Is there a better way to structure all this? Is this the point where I have to start using the MagicBot framework? We just want to be able to switch between "slow" and "fast" and "reverse" and also be able to control the motors that handle the cube launcher. I will be looking for some other repos on github to see how other teams have done it.

It might do to give your code some more descriptive variable names, as a start.

Are you sure you want toggle actions? We generally tend to have hold-to-activate or single-press actions because it's easier for the drivers to determine whether something should be active (are they holding the button vs. did they press it sometime in the past?)

Thirdly which I think may be the cause of some of your problems, is that you are checking

Code:

if toggleX

which, while valid syntax, probably won't do what you want. This will always return True for an initialized object as those are "truthy." You instead want to check toggleX.on, which I see you doing in some places.

And you definitely want to use if statements and DO NOT conjoin them together in if/elif chains. You only want to use those for disjoint actions (things that will never occur at the same time.)

This is why things (everything but self.d) seem to not be changing. When you call self.toggle2, it checks to see if you have repressed the button. This will return true once and only once for each button press.

So lets say you press and release button 2. The first time it detects this, self.toggle2 will be true, and then b and c will both get set to 1. The next loop. self.toggle2 won't be true, so the code will go into the else statement. Can you see the problem? a,b, and c are all (pretty much) always getting reset to -1, 0, and 0 respectively.

Remember, a toggle only has 2 values, true and false. So you can only really use a single toggle to toggle between two values. You're trying to switch between three, so you might have to rethink your logic.

__________________There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.

but then you should ask, if you're always setting the speed to 0, what is the purpose of these statements?

__________________There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.