Updates per style guide

This commit is contained in:
Josh Stewart 2016-10-26 00:42:20 +11:00
parent 3bdeec43f5
commit 6e50a6fc57
2 changed files with 5 additions and 9 deletions

View File

@ -72,7 +72,7 @@ void initialiseIdle()
idle_pin_mask = digitalPinToBitMask(pinIdle1);
idle2_pin_port = portOutputRegister(digitalPinToPort(pinIdle2));
idle2_pin_mask = digitalPinToBitMask(pinIdle2);
idle_pwm_max_count = 1000000L / (configPage3.idleFreq << 5); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz
idle_pwm_max_count = 1000000L / (16 * configPage3.idleFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz
idlePID.SetOutputLimits(0, idle_pwm_max_count);
idlePID.SetTunings(configPage3.idleKP, configPage3.idleKI, configPage3.idleKD);
idlePID.SetMode(AUTOMATIC); //Turn PID on

View File

@ -362,16 +362,12 @@ int get3DTableValue(struct table3D *fromTable, int Y, int X)
//Initial check incase the values were hit straight on
long p;
if (xMaxValue == xMinValue)
p = ((long)(X - xMinValue) << 8); //This only occurs if the requested X value was equal to one of the X axis bins
else
p = ((long)(X - xMinValue) << 8) / (xMaxValue - xMinValue); //This is the standard case
if (xMaxValue == xMinValue) { p = ((long)(X - xMinValue) << 8); } //This only occurs if the requested X value was equal to one of the X axis bins
else { p = ((long)(X - xMinValue) << 8) / (xMaxValue - xMinValue); } //This is the standard case
long q;
if (yMaxValue == yMinValue)
q = ((long)(Y - yMinValue) << 8);
else
q = 256 - (((long)(Y - yMaxValue) << 8) / (yMinValue - yMaxValue));
if (yMaxValue == yMinValue) { q = ((long)(Y - yMinValue) << 8); }
else { q = 256 - (((long)(Y - yMaxValue) << 8) / (yMinValue - yMaxValue)); }
int m = ((256-p) * (256-q)) >> 8;
int n = (p * (256-q)) >> 8;