[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Spin button problem



Bart Vandewoestyne wrote:
> 
> I'm having the following spin button problem:
> 
> I have attached two spinbuttons to a horizontal buttonbox.  I want to be
> able to change the value of one spinbutton without changing the value of
> the other.  Now, for some strange reason that i didn't find yet, when i
> change the value of the first spinbutton, the value of the SECOND
> spinbutton gets the same value!  I don't know WHY this is, and would be
> glad to get some hints on this one...

Hmmm... i think i have found my problem... i shouldn't be using these
mot_set_clock_high_time() and mot_set_clock_low_time() functions that
are connected as callbacks with the "changed" signal.  The problem is:
right now i have this turn() function that makes a stepper motor turn
through the parallel port:

/* --- Sending a clock signal to the L297N is giving a clock HIGH
signal,
 * --- followed by a clock LOW signal on pin 3 (Data1)
 */
void mot_turn(int *user_data)
{
 mot_turn_ok=TRUE;
 while ( mot_turn_ok ) {
   *user_data = *user_data | 0x02;
   outb(*user_data, BASEPORT);	
   usleep(mot_clock_time_high*1000);
   *user_data = *user_data & (~0x02);
   outb(*user_data, BASEPORT);	
   usleep(mot_clock_time_low*1000);
   while(gtk_events_pending()) gtk_main_iteration(); }
}


I guess that this should change into something like:


void mot_turn(int *user_data)
{
 mot_turn_ok=TRUE;
 while ( mot_turn_ok ) {
   *user_data = *user_data | 0x02;
   outb(*user_data, BASEPORT);	
  
usleep(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton1)*1000);
   *user_data = *user_data & (~0x02);
   outb(*user_data, BASEPORT);	
  
usleep(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton2)*1000);
   while(gtk_events_pending()) gtk_main_iteration(); }
}


But the problem is that i created the spinbuttons in another function
that is declared in another file in order to do some modular programming
and get a good overview on my program... so the spinbuttons i created in
that other function in that other file are local to that function and i
can't use them in this turn() function.  How should i solve this so that
the global variabeles mot_clock_time_high and mot_clock_time_low are set
to the correct value when the program starts the turn() function?

Tnx for the help!

-- 
Bart Vandewoestyne		http://hello.to/MC303		
Hugo Verrieststraat 48		Bart.Vandewoestyne@skynet.be
8550 ZWEVEGEM			ICQ# 21275340
BELGIUM - EUROPE		nick: MC303
Phone: +32(0)56/75.48.11
-------------------------------------------------------------
"If we knew what it was we were doing, it would not
 be called research, would it?"
				-- Albert Einstein --



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]