#include "joy_adjust.h"
#include <stdio.h>

/**********************************************
* FUNCTION NAME: joy_adjust
* PURPOSE: adjust motor value depending on twisty scale
* CALLED FROM: userroutines.c, default routines 
* ARGUMENTS:
*     Argument       Type             Min-Max   Description
*     --------       -------------    --         -----------
*     joystick       int              -255:255    joystick suggested speed	
*     wheel          int              -255:255    joystick wheel for scaling
* RETURNS: a new speedyness int.
* 
*************************************************/      

int joy_adjust(int joystick, unsigned char wheel)
{
long speed;

   // printf("1 x:%d, w:%d     ",joystick,wheel);
    speed = (long)joystick * (JOYADJON + wheel);
    speed = speed/(JOYADJON + 255);
   // printf("2 s:%d,\r",speed);
    return (int)speed;
}

