= Updating Legacy Apps to New Look = Consider if the app to be changed only has minor changes from one of the standard apps. In this case it may be easier to use the code from the new style standard app and merge the changes into it. Otherwise, follow the below steps. 1. If it has not been done yet create 825gen2 build configurations for the project: Debug-ARM825, Release-ARM825, (See [wiki:UpdatingLegacyApps Updating Legacy Apps]) and Debug-ARM825-SIM (See [wiki:Simulating825gen2 Simulating 825gen2 Apps]). 2. Copy the files apphelpers.cpp, apphelpers.h, and appinfo.h from one of the new standard projects such as ID storage into the project to update. Changes to these files might be needed. For example, if different fonts or font sizes are desired these are specified in apphelpers.cpp. 3. Copy code for main screen below from a standard app such as ID storage. It is likely changes will need to be made to this code to suit the particular application. {{{ #if ARM64 #define NUM_WT_INDEXES 3 // Gross, tare, net #define WT_INDEX_GROSS 0 #define WT_INDEX_TARE 1 #define WT_INDEX_NET 2 CFormRect rectWtLbl[NUM_WT_INDEXES]; // Location for gross, tare, net labels CFormRect rectWt[NUM_WT_INDEXES]; CFormRect rectWtUnits[NUM_WT_INDEXES]; CFormRect rectWtStatus; CFormRect rectCapacity[2]; // If OIML needs two lines CFormRect rectErrorMsg; CFormRect rectLargeMsg; // Size of all weight rects, used for "WEIGHT ERROR", or "OVER CAPACITY" CFormRect rectManTare; CFormRect rectBelowButtons; CFormRect rectWeightBackground; void SetupDisplayLocations(void) { int n; CFormRect rect; CFormAdvanceY advanceY; // Weight status below capacity with is fontIndexSmallPrompt,multiplier 1.0 plus fixed DrawBorder height FONT_HEIGHT + 16 rect.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0, BORDER_BOX_HEIGHT); rect.SetHeightBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0); rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.26, 0.25); // Show above of gross weight value rectWtStatus = rect; rectWtStatus.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.0, 0.30); rectWtStatus.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.7, BORDER_BOX_HEIGHT); for(n = 0; n < 2; n++) { if(n == 0) { rectCapacity[n].SetY(BORDER_BOX_HEIGHT); } else { rectCapacity[n].SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), BORDER_BOX_HEIGHT); } rectCapacity[n].SetX(0); rectCapacity[n].SetLeftAndWidthBasedOnDspArea(&dspMain, 0.01, 0.41); rectCapacity[n].SetHeightBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0); } advanceY.SetBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0, 0); rect += advanceY; rectManTare = rect; rectManTare.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.31, 0.20); rectManTare.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.7, BORDER_BOX_HEIGHT); // Setup weight label, value, and units locations // horizontal coordinates based on display area width // vertical coordinates based on font heights // // Header // Capacity 1 // Capacity 2 // // |- 0% 25% -|- 26% - 51% -|- 55% 70% -| // // wt status // Gross 120000 lb // // Tare 40000 lb // // Net 80000 lb // // Error message // ----- Buttons ------- rect.SetHeightBasedOnFont(fontBigLabel, 1.0); // move Y position down to 1/4 of font height. int heightNZ = fontBigLabel.GetFont(0).GetHeight(); heightNZ = heightNZ / 2; int heightZ = fontBigLabel.GetFont(1).GetHeight(); heightZ = heightZ / 2; advanceY.SetBasedOnFont(fontBigLabel, 1.0); rect.GetRect(0).SetY(rect.GetRect(0).GetY() + heightNZ); rect.GetRect(1).SetY(rect.GetRect(1).GetY() + heightZ); for(n = 0; n < NUM_WT_INDEXES; n++) { rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.01, 0.24); rectWtLbl[n] = rect; rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.26, 0.25); rectWt[n] = rect; rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.55, 0.15); rectWtUnits[n] = rect; rect += advanceY; } // Large message such as "WEIGHT ERROR" upper left is set same as weight label "Gross", lower right is same as net weight units label. rectLargeMsg.SetLocationAndSizeFrom(rectWtLbl[WT_INDEX_GROSS], rectWtUnits[WT_INDEX_NET]); rectWeightBackground.SetLocationAndSizeFrom(rectWtLbl[WT_INDEX_GROSS], rectWtLbl[WT_INDEX_GROSS]); rectWeightBackground.SetX(0); rectWeightBackground.SetWidth(dspMain.GetWidth() - 1); rect.SetTopBasedOnFont(formFontSetSmall.GetFont(fontIndexPrompt), 12.0); rect.SetHeightBasedOnFont(formFontSetSmall.GetFont(fontIndexPrompt), 1.0); rect.SetX(0); rect.SetWidth((dspMain.GetWidth() / 2) - 1); rectErrorMsg = rect; } #endif }}} 4. Find the InitLCD function call and change as follows: {{{ void IndStartup(void) { #if ARM64 InitLCD(DSP_INIT_NEW_STYLE_APP); dspMain.SetZoomWidth(0, dspMain.GetZoomWidth(1)); if(dsp_height > 800) { dspMain.SetZoomHeight(0, (int)(dspMain.GetZoomHeight(1) * 0.84)); } InitFonts(); SetupDisplayLocations(); #else InitLCD(); #endif // ... Additional code } }}} 5. Modify functions that do display operations such as shown: {{{ void ShowGTN(void) { #if ARM64 SetCurColor(COLOR_INFO); SetBkColor(nColorWhite); fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_GROSS], LANG(STR_GROSS_LABEL)); if (curScale >= 0 && GetWtMode(curScale) == wtmode_net) { fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_TARE], LANG(STR_TARE_LABEL)); fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_NET], LANG(STR_NET_LABEL)); } #else SetCurColor(nColorGreen); SetBkColor(nColorBlack); DisplayText(GROSS_LBL_X, GROSS_WT_Y, LANG(STR_GROSS_LABEL), 0, BIG_FONT); if (curScale >= 0 && GetWtMode(curScale) == wtmode_net) { DisplayText(TARE_LBL_X, TARE_WT_Y, LANG(STR_TARE_LABEL), 0, BIG_FONT); DisplayText(NET_LBL_X, NET_WT_Y, LANG(STR_NET_LABEL), 0, BIG_FONT); } SetBkColor(nColorBlack); #endif } }}} 6. Search for all menu and inputs forms such as search for "FORM_INIT" make appropriate changes to use new style FORM_ADD_INPUT2 instead of FORM_ADD_INPUT and FORM_ADD_BUTTON2 instead of FORM_ADD_BUTTON such as: {{{ void PresetScreen(void) { #if ARM64 CFormRect rect, rectInp; FORM_INIT(Setup, EventPresetScreenShow, NULL, NULL, NULL, nFormFlgShowHelp); SetupInputFormToUseFontSet(formSetup, rect, rectInp, "Total Violation: "); FORM_ADD_INPUT2(Setup, Thresh, rect, rectInp, "On Threshold: ", 6, 0, 999999, NULL, &g_setup.onThresh, FORM_FLOAT, NULL, "Enter the on threshold"); AdvanceInputRects(rect, rectInp); FORM_ADD_INPUT2(Setup, ViolTot, rect, rectInp, "Total Violation: ", 6, 0, 999999, NULL, &g_setup.violWt[0], FORM_FLOAT, NULL, "Enter violation weight for total"); AdvanceInputRects(rect, rectInp); FORM_ADD_INPUT2(Setup, Viol1, rect, rectInp, "P1 Violation: ", 6, 0, 999999, NULL, &g_setup.violWt[1], FORM_FLOAT, NULL, "Violation weight for P1"); #else FORM_INIT(Setup, EventPresetScreenShow, NULL, NULL, NULL, nFormFlgShowHelp); FORM_ADD_INPUT(Setup, Thresh, 0, FONT_HEIGHT * 2, "On Threshold: ", 6, 0, 999999, NULL, &g_setup.onThresh, FORM_FLOAT, NULL, "Enter the on threshold"); FORM_ADD_INPUT(Setup, ViolTot, 0, FONT_HEIGHT * 4, "Total violation: ", 6, 0, 999999, NULL, &g_setup.violWt[0], FORM_FLOAT, NULL, "Enter violation weight for total"); FORM_ADD_INPUT(Setup, Viol1, 0, FONT_HEIGHT * 6, "P1 Violation: ", 6, 0, 999999, NULL, &g_setup.violWt[1], FORM_FLOAT, NULL, "Violation weight for P1"); #endif FORM_SHOW(Setup); int n = FORM_RUN(Setup); if (n != FORM_RESULT_ESC) { SaveSetup(); } FORM_HIDE(Setup); } }}} {{{ void FileOperation(void) { #if ARM64 CFormRect rect; FORM_INIT(Update, EventDownloadedFileShow, NULL, NULL, NULL, 0); SetupMenuFormToUseFontSet(formUpdate, rect, 0.8 ); FORM_ADD_BUTTON2(Update, Export, rect, "Export", 'X', EventExport, FORM_BUTTON_SHADOW); rect += btnAdvanceY; FORM_ADD_BUTTON2(Update, Import, rect, "Import", 'I', EventImport, FORM_BUTTON_SHADOW); #else FORM_INIT(Update, EventDownloadedFileShow, NULL, NULL, NULL, 0); FORM_ADD_BUTTON(Update, Export, MENU_COL1_X, MENU_ROW1_Y, " Export ", 'X', EventExport, FORM_BUTTON_INVERT); FORM_ADD_BUTTON(Update, Import, MENU_COL1_X, MENU_ROW2_Y, " Import ", 'I', EventImport, FORM_BUTTON_INVERT); #endif FORM_SHOW(Update); FORM_RUN(Update); FORM_HIDE(Update); } }}}