We used an acceleration curve to overcome the sensitivity of the low range of the joystick. The code looks exactly like this:
tempRight = pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
tempLeft = pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
if(p1_y >= 127){
tempRight = (tempRight - 127)(tempRight - 127)/127 + 127;
tempLeft = (tempLeft - 127)(tempLeft - 127)/127 + 127;
}
if(p1_y < 127){
tempRight = (tempRight - 127)(tempRight - 127)/-127 + 127;
tempLeft = (tempLeft - 127)(tempLeft - 127)/-127 + 127;
}
pwm13 = pwm14 = tempRight;
pwm15 = pwm16 = tempLeft;
When building, the compiler gives error 1202: Call of non-function, on the 4 lines inside the if statements.
I’m completely stumped, any help would be greatly appreciated.
Cuog
January 30, 2006, 7:44pm
2
I’m not entirely sure what the error is in your code i will take a look at it again but if u want here is the method i used for doind the same thing u are doing:
try adding brackets for order of operations:
tempRight = (((tempRight - 127) * (tempRight - 127))/127) + 127;
#include “ifi_aliases.h”
#include “ifi_default.h”
#include “ifi_utilities.h”
#include “user_routines.h”
#include “cuog_cam.h”
#include “cuog_util.h”
#include “math.h”
void Exp_Joy_Mapping()
{
char raw = 0;
switch(MAP_NUMBER)
{
//maps joystick and PWM #8
case 8:
raw = (MAP_JOYSTICK08 - 128) / 11.3;
if(MAP_JOYSTICK08 < 127)
{
MAP_PWM08 = (raw * raw) - 128;
}
else
{
MAP_PWM08 = (raw * raw) + 128;
}
//maps joystick and PWM #7
case 7:
raw = (MAP_JOYSTICK07 - 128) / 11.3;
if(MAP_JOYSTICK07 < 127)
{
MAP_PWM07 = (raw * raw) - 128;
}
else
{
MAP_PWM07 = (raw * raw) + 128;
}
//maps joystick and PWM #6
case 6:
raw = (MAP_JOYSTICK06 - 128) / 11.3;
if(MAP_JOYSTICK06 < 127)
{
MAP_PWM06 = (raw * raw) - 128;
}
else
{
MAP_PWM06 = (raw * raw) + 128;
}
//maps joystick and PWM #5
case 5:
raw = (MAP_JOYSTICK05 - 128) / 11.3;
if(MAP_JOYSTICK05 < 127)
{
MAP_PWM05 = (raw * raw) - 128;
}
else
{
MAP_PWM05 = (raw * raw) + 128;
}
//maps joystick and PWM #4
case 4:
raw = (MAP_JOYSTICK04 - 128) / 11.3;
if(MAP_JOYSTICK04 < 127)
{
MAP_PWM04 = (raw * raw) - 128;
}
else
{
MAP_PWM04 = (raw * raw) + 128;
}
//maps joystick and PWM #3
case 3:
raw = (MAP_JOYSTICK03 - 128) / 11.3;
if(MAP_JOYSTICK03 < 127)
{
MAP_PWM03 = (raw * raw) - 128;
}
else
{
MAP_PWM03 = (raw * raw) + 128;
}
//maps joystick and PWM #2
case 2:
raw = (MAP_JOYSTICK02 - 128) / 11.3;
if(MAP_JOYSTICK02 < 127)
{
MAP_PWM02 = (raw * raw) - 128;
}
else
{
MAP_PWM02 = (raw * raw) + 128;
}
//maps joystick and PWM #1
case 1:
raw = (MAP_JOYSTICK01 - 128) / 11.3;
if(MAP_JOYSTICK01 < 127)
{
MAP_PWM01 = (raw * raw) - 128;
}
else
{
MAP_PWM01 = (raw * raw) + 128;
}
break;
}
}
You need an asterisk (*) to multiply.
'Doh! Man, 3 years programming C and I still make these stupid mistakes. Yesterday I forgot to end a quotation on a string and the compiler decided to give a syntax error on a comment 20 lines down :ahh:
Thanks alot for the help guys, it’s always nice to have the outside party take a look at your code because one of two things can happen:
They write it better.
They find your stupid mistake.