-
Notifications
You must be signed in to change notification settings - Fork 0
UI Popup Confirmation
- MODS:
c_ui.c
,c_ui.h
,ui.lms
After talking with Dr. Ludi we concluded that the next best step was to utilize the built in pop up functionality to possibly display more information of the users selection. On user selection the system notification will pop up cUiNotification
or possibly cUiQuestion
, displaying the selection's text in entirety and allowing for confirmation of selection and other possible actions.
There is a portion in c_ui within the function cUiBrowser
specified as controller CTRL
which I believe may have some insight on possible flow of the program once user selects an item. I believe I have found the portion in cUiBrowser
that handles the actual selection in the browser. A simple search for // Browser -> User Selects item: Handler portion
Within the firmware developer kit provided by lego, some generalized capabilities of the systems functions can be found ( op codes available ).
NOTIFICATION= 0x0B
Arguments
- (DATA8) Color –Specify either black or white, [0: White, 1: Black]
- (Data16) X0 –Specify X start point, [0 -177]
- (Data16) Y0 –Specify Y start point, [0 -127]
- (Data8) ICON1–First icon(Data8) ICON2–Second icon
- (Data8) ICON3–Third icon(Data8) STRING –First character in notification string
- (Data8) *STATE –State, 0 = INIT
Description
Enable displaying multiple notification options to the
QUESTION= 0x0C
Arguments
- (DATA8) Color –Specify either black or white, [0: White, 1: Black]
- (Data16) X0 –Specify X start point, [0 -177]
- (Data16) Y0 –Specify Y start point, [0 -127]
- (Data8) ICON1–First icon
- (Data8) ICON2 –Second icon
- (Data8) STRING –First character in question string
- (Data8) *STATE –State, 0 = No, 1 = OK
Return
- (Data8) OK –Answer, 0 = No, 1 = OK, -1 = SKIP
Description
Enable displaying question to the user and returning the users selection.
Based off the description of Question, it would seem that this function should be used for displaying and prompting for the user.
It would seem that I can implement popup capabilities by modifying the UI.lms file using the necessary bytecodes. Information for applicable icons can be found in bytecodes.h
and c_ui.c
.
Popups and handlers will be added to each menu screen found in the scheduler (playrecent, filescreen, apps, settings ). Searching for CALL(RUNBYTECODE
area in each subcall will help identify when user has selected the actual item.
It would be easier to implement popup functionality within the RUNBYTECODEFILE subcall as all instances call this function, however this would cause popups for every instance ( settings update etc ). An easy get around would be simply to copy the subcall and have one instance that creates popups, and one that acts normally ( to be used in the setting menu exclusively ).
I decided to keep the original subcall and create a duplicate modified to provide pop up capabilities. The modifications can be seen in the subcall RunBytecodefilePU
. I tried to be descriptive in comments and in the psuedo code.
MOVE8_8(DEBUG_SLOT,Slot) // Slot = DEBUG_SLOT
//
NotDebug: // }
//
// Insert question prompt // do
StillPressed: // {
UI_BUTTON(PRESSED,ENTER_BUTTON,Flag) // UI_BUTTON(PRESSED,ENTER_BUTTON,Flag)
// While user is holding ENTER go back to button test. //
JR_TRUE(Flag,StillPressed) // } while( Flag )
// Initial press ^, next question prompt with name of file //
// Selection handled within QUESTION prompt, only check return (YES)//
UI_DRAW(QUESTION,FG_COLOR,16,50,ICON_NONE, ICON_NONE, Filename, Stat, Yes )
// Need to still handle pressing back button // UI_DRAW( QUESTION, FG_COLOR, 16, 50, ICON_NONE, ICON_NONE, Filename, Stat, Yes )
// When Yes = 1, Valid_OK set high //
CP_EQ8(Yes,1,Valid_OK) //
// When Valid_OK is high, fall though else JR // if( Yes != 1 )
JR_FALSE(Valid_OK,end) // goto end
// // implicit else vvvvvv
//
FILE(LOAD_IMAGE,Slot,Name,Size,pFile) // FILE(LOAD_IMAGE,Slot,Name,Size,pFile)
PROGRAM_START(Slot,0,pFile,0) // PROGRAM_START(Slot,0,pFile,0)
//
MOVE8_8(0,Tmp) // Tmp = 0
// do
FileRunning: // {
A few test for functionality proved promising as every interaction behaved as expected.
Although provisions were made for text display, it would seem the text ability is omitted which is odd as it could easily be added to the program. Perhaps to avoid issues with display the omitted this ability. I decided to implement the text ability, and will continue to tweak the function until text can be displayed seamlessly. Current implementation is as follows:
switch ((*pQ).NoOfIcons)
{
case 1 :
{
dLcdDrawIcon((*UiInstance.pLcd).Lcd,Color,(*pQ).IconStartX,(*pQ).IconStartY,LARGE_ICON,Icon1);
// ADD TEXT TO DRAW, in the case of one icon, draw on the line below it.
dLcdDrawTextPU((*UiInstance.pLcd).Lcd,Color,(*pQ).IconStartX + (*pQ).IconSpaceX,(*pQ).IconStartY + (*pQ).IconHeight, AL_FONT,pText,1 );
}
break;
case 2 :
{
dLcdDrawIcon((*UiInstance.pLcd).Lcd,Color,(*pQ).IconStartX,(*pQ).IconStartY,LARGE_ICON,Icon1);
dLcdDrawIcon((*UiInstance.pLcd).Lcd,Color,(*pQ).IconStartX + (*pQ).IconSpaceX,(*pQ).IconStartY,LARGE_ICON,Icon2);
// ADD TEXT TO DRAW, however in the case of two icons, draw on the line below them.
dLcdDrawTextPU((*UiInstance.pLcd).Lcd,Color, (*pQ).IconStartX + 2*( (*pQ).IconSpaceX ),(*pQ).IconStartY + (*pQ).IconHeight, AL_FONT,pText, 1);
}
break;
default:
{
// When there are no icons, there is room for 2 rows of text ( about 8 characters )
dLcdDrawTextPU((*UiInstance.pLcd).Lcd,Color,(*pQ).ScreenStartX + 10,(*pQ).IconStartY, AL_FONT,pText, 2);
}
}
Currently, the number of lines printed in the popup depends on if icons are present. With icons, one line of text is printed below the icons. Without icons, enough room for 2 lines is present so two lines are selected for printing by utilizing the new driver dLcdDrawTextPU
.
// Exclusively for drawing text in the popups POP4, since POP4 can fit 8 characters using the
// AL_FONT ( 8 * 16 = 128 ), minimum is 40 ( 8 * 5 for tiny font ).
void dLcdDrawTextPU(UBYTE *pImage,DATA8 Color,DATA16 X0,DATA16 Y0,DATA8 Font,DATA8 *pText, DATA8 Lines)
{
DATA16 MAXCHAR_WIDTH = 128; // Max characters using AL_FONT width is 8.
DATA16 XI = X0; // X incrementer set to X naught.
DATA16 YI = Y0; // Y incrementer set to X naught.
DATA8 Instance = Lines; // Increment when first line is printed.
DATA8 LineSpacing = 2; // Line Spacing between lines.
if( Instance > 0 )
{
// While the value of pText is not NULL ('\0')
while( *pText )
{
// If X increment is within the pop up width, print line until Instance is 0
// Original if ( (XI < (MAXCHAR_WIDTH - FontInfo[Font].FontWidth) ) && Instance )
if ( (XI < (MAXCHAR_WIDTH + FontInfo[Font].FontWidth)) && Instance )
{
dLcdDrawChar(pImage,Color,XI,YI,Font,*pText);
XI += FontInfo[Font].FontWidth;
pText++;
}
// Once exceding the print line, Remove an instance, reset XI to X0
// Decrement YI by height of the line + 2
else{
Instance = Instance - 1; // Decrement since a line has printed.
XI = X0; // Reset to start of placement.
YI = YI + FontInfo[Font].FontHeight + LineSpacing; // Increment by Height of Font + 2
}
}
}
}
The new driver is passed the number of lines to be printed, and handles printing accordingly. Process is described via comments within the code.