We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Keeping arduino+processing project in sync
Page Index Toggle Pages: 1
Keeping arduino+processing project in sync (Read 1897 times)
Keeping arduino+processing project in sync
Jun 9th, 2010, 9:47am
 
Hi,

I've worked on arduino for sometime, and processing for sometime, separately. Now I'm trying to put these two together. I have a header file from arduino, where I defined a list of constants with #define. I want processing to have these definitions as well but there is no #define in processing so I can't just import this header file and rename it .pde. Any suggestions? Thanks in advance. My current way is just to declear them as variables in processing.
Re: Keeping arduino+processing project in sync
Reply #1 - Jun 9th, 2010, 1:04pm
 
Read the Arduino file as a text file and parse it. Either use the dynamic values or you can write back a .pde file to use in your projects.
Re: Keeping arduino+processing project in sync
Reply #2 - Jun 10th, 2010, 7:37am
 
Thanks PhiLho. Do you mean creating a .pde file with all variable definitions in it and include it in my project? I am using this way but since the constants in C++ became variables like:
#define mode_active 1 becomes int mode_active=1;
I can't use the mode_active variable in switch case like before:
I would do:
switch (machine_mode)
{
case mode_active:
break...

I can't do this if I'm using a variable mode_active.

So my new question is: can I define constants in Java or Processing? Thanks again?

Update: did some digging on the internet and found someone's article in 1996. On can do: static final int mode_active=1;
The reason is Java has no precompiler to take care of #define.
Re: Keeping arduino+processing project in sync
Reply #3 - Jun 10th, 2010, 10:50am
 
I defined an interface:
Code:
public interface CONST {
   public static final int tran_not_ready= 100;
   public static final int not_ready= 0;
   public static final int tran_not_ready_ready= 1;
   public static final int ready= 2;
   public static final int tran_ready_blocker= 3;
   public static final int blocker= 4;
   public static final int tran_blocker_gap= 5;
   public static final int gap= 6;
   public static final int tran_gap_blocker= 7;
   public static final int time_out= 8;
   public static final int disabled= 99;
   public static final int timeout_us= 500000;
   public static final int mode_vel= 0;
   public static final int mode_ang= 1;
   public static final int mode_sync= 2;
   public static final int mode_acc= 3;
   public static final float blocker_dist=(float) 0.01;
   public static final int spoke_number=10;
}

I'm successful in pure java programs in netbean but since processing is different, I can't implement my constant interface on the processing class or How do I do that? Thanks
Re: Keeping arduino+processing project in sync
Reply #4 - Jun 11th, 2010, 1:09am
 
Put your interface in a .java file instead of a .pde one.
Note: you can use import static to make them regular global variables.
Note sure if static import works with Processing 1.1, should work with 018x.
Page Index Toggle Pages: 1