Ok guys, while I sort out an issue with the direction home and such I thought I would offer another function to the OSD.
I have seen some OSD that show the current throttle position so I added that in. I am not sure if anyone wants this function but it may be good for planes and wings to keep at a good cruise setting.
anyway, it is not great coding but it works. the ugly part is that I would like to create a right justify function but have not got there yet so I just did the best I could to right justify it. I am new to Arduino coding so dont bash me too hard. Perhalps if there is interest in this function, someone can write it better and add it to the next rev. I did not assisn a #define for it yet.
it "turns on" when the system is armed and it also automaticly calibrates to your throttle settings.
Thanks
Ross
Place this in the Screen.ino
Code: Select all
void displayCurrentThrottle(void)
{
// CurentThrottlePosition is set in Config.h to line 11 above flyTimePosition
// Calibrate high and low throttle settings --defaults set in GlobalVariables.h 1100-1900
if (MwRcData[THROTTLESTICK] > HighT) HighT = MwRcData[THROTTLESTICK] -5;
if (MwRcData[THROTTLESTICK] < LowT) LowT = MwRcData[THROTTLESTICK];
//insert symbol for throttle
screenBuffer[0]=0xC9;
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]);
//map current throttle to 0 -100 scale
if(!armed) {
screenBuffer[0]='-';
screenBuffer[1]='-';
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]+2);
}
else
{
int CurThrottle = map(MwRcData[THROTTLESTICK],LowT,HighT,0,100);
//begin right justify
int Digit = CurThrottle;
int CTDigit = CurThrottle % 10;
itoa(CurThrottle % 10,screenBuffer,10);
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]+3);
CurThrottle /= 10; // Shift by one digit
CTDigit = CurThrottle % 10;
if (Digit < 10){ screenBuffer[0] = 0; }
else { itoa(CurThrottle % 10,screenBuffer,10);}
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]+2);
CurThrottle /= 10; // Shift by one digit
CTDigit = CurThrottle % 10;
if (Digit < 100){ screenBuffer[0] = 0;}
else { itoa(1,screenBuffer,10);}
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]+1);
// add % to end
screenBuffer[0]='%';
MAX7456_WriteString(screenBuffer,CurentThrottlePosition[videoSignalType][screenType]+4);
}
}
Place this in the Config.h under the Middle of the screen section
Code: Select all
const int CurentThrottlePosition[2][2]= {
LINE11+22 ,LINE11+21 ,LINE11+23+60 ,LINE11+21+60 };
Place this in the GlobalVariable.h
Code: Select all
//For Current Throttle
int LowT = 1100;
int HighT = 1900;