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;
Quote:
|
Originally Posted by code
#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;
}
}
|