![]() |
Using multiple classes in java to control one pwm
1 Attachment(s)
So I'm trying to figure out how to do multiple classes. This is the strucuture of the classes, where everything in events is a system on the robot.
http://www.chiefdelphi.com/forums/at...5&d=1396919131 The problem is, I put all the pwm stuff in map, so when the second one runs it complains about that pwm already being assigned. How do I get around this? Here is the error I get, incase I misinterpreted it: Spoiler for blah:
|
Re: Using multiple classes in java to control one pwm
Can you paste your map.java?
If at any point a conflict in PWM ports is detected your project will return an error and a stacktrace like the one you pasted. You will probably need to reassign the port in code, as well as move the physical cable itself on your Digital Sidecar. |
If you declare a talon object in map.java, you can just make new variables in the two other classes that point to the existing object.
Ex: Talon motor = map.getMotor(); Or just map.motor if you make it public, but encapsulation. |
Re: Using multiple classes in java to control one pwm
Quote:
Code:
Talon motor = new Motor(PWM_PORT_ON_DSC); |
Re: Using multiple classes in java to control one pwm
Sorry, the one I was using as map was outputmap. I called it map in all the events though. (Map is inputmap, will go ahead and rename it.)
Spoiler for outputmap:
Also, how do I make it public so I don't have to write: Code:
import edu.wpi.first.wpilibj.templates.outputmap; |
Re: Using multiple classes in java to control one pwm
Quote:
Code:
public class outputmap |
Re: Using multiple classes in java to control one pwm
Thanks, it worked perfectly. Doesn't seem to like multiple instances.
That is really weird, that you can access a static variable when you can't access a non-static one, I can see something like public/private/semiprivate where semiprivate is the same as current public and public is the same as current public static. I do come from python and javascript though, so not having types to variables must be weird here. |
Quote:
So, outputmap x = new outputmap(); Static variables and methods, however, do not require this. Please correct me if anything I said is horribly wrong :) |
Re: Using multiple classes in java to control one pwm
Quote:
|
| All times are GMT -5. The time now is 22:37. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi