Get the text and centering position for a specific menu item returns the X position
| 909 | // returns the X position |
| 910 | // |
| 911 | static int obdMenuGetItem(SIMPLEMENU *sm, int iItem, char *szText) |
| 912 | { |
| 913 | int x, cx, len; |
| 914 | |
| 915 | if (iItem > sm->iMenuLen) |
| 916 | return -1; // invalid request |
| 917 | |
| 918 | if (sm->iFontSize == FONT_6x8) |
| 919 | cx = 6; |
| 920 | else if (sm->iFontSize == FONT_8x8) |
| 921 | cx = 8; |
| 922 | else |
| 923 | cx = 16; |
| 924 | strcpy(szText, sm->pMenuText[iItem]); |
| 925 | if (sm->pfnCallback && iItem > 0) // don't add callback for menu title |
| 926 | { |
| 927 | strcat(szText, " "); |
| 928 | strcat(szText, (*sm->pfnCallback)(iItem - 1)); |
| 929 | } |
| 930 | x = 0; |
| 931 | if (sm->bCenter || iItem == 0) // always center the menu title |
| 932 | { |
| 933 | len = strlen(szText); |
| 934 | x = (sm->iDispX - (len * cx)) / 2; |
| 935 | } |
| 936 | return x; |
| 937 | } /* obdMenuGetItem() */ |
| 938 | |
| 939 | // |
| 940 | // Erase the display and show the given menu |
no test coverage detected