Ejemplo n.º 1
0
void InputLine::moveCursorBackward(){
	//move cursor backwards if there is still space in this field
	// else jump to previous input field
	if(cursorPoint > active->start){
		cursorPoint--;
		cursorMove = false;
		displayInput();
	} else {
		if(jumpField(false, true, true)){
			displayInput();
		}
	}
}
Ejemplo n.º 2
0
void InputLine::moveCursorForward(){
	//move cursor forwards if there is still space in this field
	// else jump to next input field
	if(cursorPoint < active->finish){
		cursorPoint++;
		cursorMove = false;
		displayInput();
	} else {
		if(jumpField(true, true, true)){
			displayInput();
		}
	}
}
Ejemplo n.º 3
0
void InputLine::removeCurrentElementMoveBackward(){
	// remove current element from active input field
	// else jump to previous input field and remove last element
	if(cursorPoint > active->start){
		inputLine[cursorPoint] = ' ';
		cursorPoint--;
		displayInput();
		cursorMove = false;
	} else if(cursorPoint == active->start) {
		inputLine[cursorPoint] = ' ';
		jumpField(false, false, true);
		displayInput();
	}
}
Ejemplo n.º 4
0
void InputLine::removeCurrentElementMoveForward(){
	// remove current element from active input field
	// else jump to next input field and remove first element
	if(cursorPoint < active->finish){
		inputLine[cursorPoint] = ' ';
		displayInput();
		cursorPoint++;
		cursorMove = false;
		cursorMoveTimer = CURSORMOVETIME;				
	} else if(cursorPoint == active->finish){
		inputLine[cursorPoint] = ' ';
		jumpField(true, false, true);
		displayInput();
	}
}
Ejemplo n.º 5
0
void sort(int *num)
{
	register int i, j;
    for ( i = 0; i < SIZE; i++ )
        for ( j = 0; j < SIZE-1-i; j++)
        {
            if ( *(num+j) > *(num+(j+1)) )
            {
                // swap
                //
                *( num+(j+1) ) = *( num+(j+1) ) + *( num + j );
                *( num + j )   = *( num+(j+1) ) - *( num + j );
                *( num+(j+1) ) = *( num+(j+1) ) - *( num + j );

                //same as:
                /*
                                num[j+1] = num[j+1] + num[j];
                                num[j]   = num[j+1] - num[j];
                                num[j+1] = num[j+1] - num[j];
                                */
            }//end if
        }//end for j

    displayInput(num); // display array after it is sorted
}//end sort()
Ejemplo n.º 6
0
//MAIN FUNCTION **************************************************************
void main(void)
{
    char keypad;
    char tensDigit; 
    char onesDigit; 
    char numAsDecimal; 
    
    initMethods(); 
    putchar('\r');  // Dummy write to serial port
    printf("\nStart\r\n");

    Counts = 0;
    while (Counts < 1); // Wait a long time (1s) for keypad & LCD to initialize

    lcd_clear();
    lcd_print("Calibration:\nHello world!\n012_345_678:\nabc def ghij");
    
    
    while (1)
    {
        keypadInput = read_keypad(); //read the keypad
        if (keypadInput != -1) { //if keypad pressed
            tensDigit = keypadInput; while(read_keypad() != -1); pause(); //store press as tens digit
            
            do {
                onesDigit = read_keypad(); //set the result of read_keypad to ones digit
            } while (onesDigit == -1) //stop once ones digit equals an input value
            while(read_keypad() != -1); pause(); //wait until key is released, then pause for one second
             
            numAsDecimal = twoDigitNum(tensDigit, onesDigit); 
            displayInput(numAsDecimal); 
        }
    }
Ejemplo n.º 7
0
void InputLine::enableInput(bool enable){
	inputActive = enable;
	// if input is closed print the final result
	// in order to make sure cursor is not left visible
	if(!enable){
		displayInput();
	}
}
Ejemplo n.º 8
0
void  Interface::display()
{
  std::stringstream num;

  if (SDL_BlitSurface(back_sprt, NULL, screen, NULL) < 0)
    throw errGraphic ("Blit Surface");
  displayInput();
  scrollControl();
  menuControl();
  displayKitchenMenu(0);
  if (kitchensData.size() != 0)
    displayKitchenList(0);
  displayKitchenMenu(1);
  if (kitchensData.size() != 0)
    displayKitchenList(1);
  SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
}
Ejemplo n.º 9
0
bool InputLine::addLabel(int start, char* text){
    int length = strlen(text);
    bool spaceAvaliable = checkSpace(start-1, length);
    start--;
		
    // if space is avaliable set label text
	// mark corresponding spaces unavaliable
	if(spaceAvaliable){
		for(int i = 0; i < length; i++){
			avaliable[start + i] = false;
			inputLine[start + i] = text[i];
		}
		displayInput();
		return true;
	} else {
		return false;
	}
}
Ejemplo n.º 10
0
void InputLine::readNumbers(char key){
	switch (key){
		case 'A': enableInput(false); break;
		case 'B': moveCursorForward(); break;
		case 'C': moveCursorBackward(); break;		  
		case 'D': switchInputMode(); break;
		case '*': removeCurrentElementMoveBackward(); break;
		case '#': removeCurrentElementMoveForward(); break;
		default:
			if(key){
				if(cursorPoint <= active->finish){
					inputLine[cursorPoint] = key;
					if(cursorPoint == active->finish){
						jumpField(true, false, false);
					} else {
						cursorPoint++;
					}
					displayInput();	  
				} 	
			}
		break;
		}
}
Ejemplo n.º 11
0
void trakkermodel::loadInput(){
    //qDebug() << "TODO: load input samples from txt file dialog";


    QString fName = QFileDialog::getOpenFileName(NULL,("Open File"), QDir::currentPath(),("Trakker Data (*.tra)"));
    if (QFile::exists(fName)){
        QFile f(fName);
        if (f.open(QIODevice::ReadOnly)){
            QDataStream in (&f);
            quint16 numberOfChannels  ;
            quint16 sizeOfEachChannel ;

            in >> numberOfChannels ;
            if (numberOfChannels != 4){
                QMessageBox mesBox;
                mesBox.setDefaultButton(QMessageBox::Ok);
                mesBox.setText("Wrong number of channels, or file corrupted.");
            }else{
                in >> sizeOfEachChannel ;
                if (sizeOfEachChannel != bufferSize){
                QMessageBox mesBox;
                mesBox.setDefaultButton(QMessageBox::Ok);
                mesBox.setText("Wrong length of channelsor file corrupted.");
                }
                else{
                    m_triggeredData.clear();
                    in >> m_triggeredData ;
                }
            }
            f.close();

            clearCorrView();
            b_signalPresent = true ;
            displayInput();
        }
    clearCorrView();
    }
Ejemplo n.º 12
0
/****************************************************************************
REMARKS:
Main function to do the interactive tests.
****************************************************************************/
ibool doVideoCaptureTest(
    GC_devCtx *gc,
    GA_glCtx *gl,
    int xRes,
    int yRes,
    int bitsPerPixel,
    N_uint32 flags,
    int refreshRate,
    GA_CRTCInfo *crtc,
    N_uint32 planeMask,
    ibool force1bppShadow)
{
    int                     i,choice;
    ibool                   success = true,all = true;
    GA_videoFuncs           video;
    GA_videoCaptureFuncs    capture;
    GA_VideoCaptureInf      captureInfo;
    GA_captureInputTypes    inputs[ ] = { gaCaptureCompositeInput,
                                          gaCaptureSVideoInput,
                                          gaCaptureRGBInput,
                                          gaCaptureRS170Input };
#define NUM_INPUTS (sizeof(inputs) / sizeof(inputs[0]))

    /* Obtain the mode information before setting the mode */
    dc = gc->dc;
    virtualX = virtualY = bytesPerLine = -1;
    modeInfo.dwSize = sizeof(modeInfo);
    if (xRes == -1) {
        if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
            return false;
        }
    else {
        if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
            return false;
        }

    /* Check mode for video acceleration capabilities */
    if (!(modeInfo.Attributes & gaHaveAccelVideo)) {
        GC_printf(gc,"Video acceleration not available!\n\n");
        return false;
        }

    /* Check mode for video capture format list */
    captureInfo.dwSize = sizeof(captureInfo);
    if (!(modeInfo.VideoWindows)) {
        GC_printf(gc,"Video capture format list not available!\n\n");
        return false;
        }
    else
        memcpy(&captureInfo,*modeInfo.VideoCapture,captureInfo.dwSize);

    for (;;) {
        /* Display video format menu while in graphics console mode */
        GC_clrscr(gc);
        GC_printf(gc,"Video Capture Test\n\n");

        /* Display menu of available video overlay formats */
        GC_printf(gc,"Select Video Capture input to test:\n\n");
        for (i = 0; i < NUM_INPUTS; i++) {
            if ((captureInfo.InputType & inputs[i]) != inputs[i])
                continue;
            GC_printf(gc,"  [%i] - %s\n",i,displayInput(inputs[i]));
            }
        GC_printf(gc,"  [Q] - Quit\n\n");
        GC_printf(gc,"Choice: ");
        for (;;) {
            choice = EVT_getch();
            if (tolower(choice) == 'q' || choice == 0x1B)
                return true;
            choice = (choice) - '0';
            if (choice >= 0 && choice < NUM_INPUTS) {
                if ((captureInfo.InputType & inputs[choice]) == inputs[choice])
                    break;
                }
            }

        /* Obtain the mode information and set the display mode */
        GC_leave(gc);
        dc = gc->dc;
        virtualX = virtualY = bytesPerLine = -1;
        modeInfo.dwSize = sizeof(modeInfo);
        if (xRes == -1) {
            if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
                return false;
            if (init.SetVideoMode(flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,refreshRate,crtc) != 0)
                return false;
            }
        else {
            if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
                return false;
            if (init.SetCustomVideoMode(xRes,yRes,bitsPerPixel,flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,crtc) != 0)
                return false;
            }
        cntMode = flags;
        if (!InitSoftwareRasterizer(cntDevice,1,false))
            PM_fatalError("Unable to initialise software rasteriser!");

        /* Get the hardware video overlay functions */
        video.dwSize = sizeof(video);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOFUNCS,&video)) {
            displayError("Video functions not available!");
            success = false;
            goto DoneTests;
            }
        capture.dwSize = sizeof(capture);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOCAPTUREFUNCS,&capture)) {
            displayError("Video capture functions not available!");
            success = false;
            goto DoneTests;
            }

        /* Run the tests for the selected capture input */
        i = choice;
        all = (stricmp(accelTestName,"all") == 0);
        if (all || stricmp(accelTestName,"capture") == 0)
            if (staticTest(&video,&capture,inputs[i],gaCaptureStandardNTSC,&captureInfo) == 0x1B)
                goto DoneTests;

DoneTests:
        /* Return to text mode, restore the state of the console and reloop */
        ExitSoftwareRasterizer();
        GC_restore(gc);
        if (!success)
            break;
        }

    (void)gl;
    (void)planeMask;
    (void)force1bppShadow;
    return success;
}
Ejemplo n.º 13
0
main()
{
	int winning[SIZE] = { 1, 3, 5, 7, 9, 11 }; // winning numbers + bonus

    register int i;
	char option;
	int pickedNumbers[SIZE];
    int freq[MAX+1] = {0}; // max is the highest number user can enter, so only MAX elements are needed in this array - MAX+1 so number is same as position - initially set to 0
    int num_match;
    int numbersEntered = 0; // false
    int b_match = 0; // bonus does not match

	//main program loop
	//
	do
    {
        system("cls");//clears the screen
        printf("Enter 1 - 5, or 0 to select an option from below:\n\n");

        printf("________________________________________________________________________________\n");
        printf("(1) Enter the 6 Numbers ( range: 1 - 42 )\n\n");
        printf("(2) Display the Entered Numbers\n\n");
        printf("(3) Display Numbers in Increasing Order\n\n");
        printf("(4) Did I Win?\n\n");
        printf("(5) Display Frequency of Numbers Entered\n\n");
        printf("(0) Exit Program\n");
        printf("________________________________________________________________________________\n\n");
        
        printf("Enter option:  ");
        scanf("%1s", &option);
        flushall();  // clear buffer
        
        system("cls");//clears the screen

        switch (option)
        {
        	case '1':
        	{
        		//get input
        		getInput(pickedNumbers, freq);
                numbersEntered++;
        		break;
        	}//end case 1
        	case '2':
        	{
                if ( numbersEntered == 0 )
                {
                    printf("**You did not Enter Your Numbers\n\n");
                }//end if

        		else // display numbers
        		{
                    displayInput(pickedNumbers);
        		}//end else
                break;
        	}//end case 2
        	case '3':
        	{
                if ( numbersEntered == 0 )
                {
                    printf("**You did not Enter Your Numbers\n\n");
                }
        		else // sort the numbers
        		{
                    sort(pickedNumbers);
        		}
                break;
        	}//end case 3
        	case '4':
        	{
                if ( numbersEntered == 0 )
                {
                    printf("**You did not Enter Your Numbers\n\n");
                }
        		else // see match
        		{
                    num_match = compare(pickedNumbers, winning);
                    
                    // check bonus
                    //
                    for ( i = 0; i < SIZE; i++ )
                    {
                        if ( *(pickedNumbers + i) == BONUS )
                        {
                            b_match++;
                            break; // dont check rest of numbers 
                        }//end if
                    }//end for

                    switch ( num_match )
                    {
                        case 3:
                        {
                            if ( b_match > 0 )
                                printf("You Won a Cinema Ticket\n");
                            else
                                printf("You Lost :(\n");
                            break;
                        }
                        case 4:
                        {
                            if ( b_match > 0 )
                                printf("You Won a Weekend Away\n");
                            else
                                printf("You Won a Night Out\n");
                            break;
                        }
                        case 5:
                        {
                            if ( b_match > 0 )
                                printf("You Won a New Car\n");
                            else
                                printf("You Won a Holiday\n");
                            break;
                        }
                        case 6:
                        {
                            printf("You Won the JACKPOT!!!\n");
                            break;
                        }
                        default:
                        {
                            printf("You Lost :(\n");
                        }
                    }//end switch
                    
        		}//end else
                break;
        	}//end case 4
        	case '5':
        	{
                if ( numbersEntered == 0 )
                {
                    printf("**You did not Enter Your Numbers\n");
                }//end if
        		else //get frequency
        		{
                    frequency( freq );
                }//end else
                break;
        	}//end case 5
        	case '0':
        	{
        		exitp();
        		break;
        	}//end case 0
        	default:
        	{
                system("cls");//clears the screen
                printf("**Error: Input value not valid\n\n");
            }
        }//end switch

        printf("\n\n**Press Enter to Continue");
        getchar();
    }//end do
    while ( option != '0' );
} //end main
Ejemplo n.º 14
0
void InputLine::readLetters(char key){
	if(cursorMove){
		if(cursorMoveTimer < 1){
		    if(cursorPoint < active->finish){
				cursorMove = false;
				cursorMoveTimer = CURSORMOVETIME;
				cursorPoint++;
				displayInput();
				lastChar = '/';
			} else {
				if(jumpField(true, false, true)){
					displayInput();
					lastChar = '/';
				}
			}
		} else {
			cursorMoveTimer--;      
		}
	}
	
	switch (key){
		case 'A': enableInput(false); break;
		case 'B': moveCursorForward(); break;
		case 'C': moveCursorBackward(); break;		  
		case 'D': switchInputMode(); break;
		case '*': removeCurrentElementMoveBackward(); break;
		case '#': removeCurrentElementMoveForward(); break;
		default:
			//no key assigned to 0 while reading letters
			if(key && key != '0'){
				if(cursorPoint <= active->finish){
					if(lastChar == key){
						int pos = key - '0';
						if(charCount > 2){
							charCount = 0;
						}
						cursorMoveTimer = CURSORMOVETIME;
						inputLine[cursorPoint] = alphaNumeric[pos-1][charCount];
						charCount++;
						cursorMoveTimer = CURSORMOVETIME;
						displayInput();
					} else {
						int pos = key - '0';
						charCount = 0;
						if(cursorMove == true){
							if(cursorPoint < active->finish){
								cursorPoint++;
							}else{
								jumpField(true, false, true);
							}
						} 
						//check if the input mode is still alphabetic
						//it might have been changed by jumping to next input field
						if(currentReadMode == 1){
							inputLine[cursorPoint] = alphaNumeric[pos-1][charCount];
							cursorMove = true;
							cursorMoveTimer = CURSORMOVETIME;
							lastChar = key;
						}
						displayInput();	  
					}
				}
					
			} 
		break;
		}
}