diff --git a/idle.ino b/idle.ino index cefb7b69..3b8e4310 100644 --- a/idle.ino +++ b/idle.ino @@ -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 diff --git a/table.ino b/table.ino index 0a561767..f277032a 100644 --- a/table.ino +++ b/table.ino @@ -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;