Пример #1
0
int doDeposit()
{
	int ammounttodeposit;
	eraseDisplay();
	displayString(0, "Press center button to exit");
	while (getButtonPress(buttonEnter) != 1)
	{
		ammounttodeposit +=getBill();
		eraseDisplay();
		displayString(0, "Press center button to exit");
		displayString(1,"%d", ammounttodeposit);
	}
	return ammounttodeposit;
	eraseDisplay();

}
Пример #2
0
void manualCallibColor() {

	unsigned short lightVal = 0;
	unsigned short greyVal = 0;
	unsigned short darkVal = 0;
	displayBigTextLine(0, "Color callib.");
	displayTextLine(3, "Place sensor on light surface.");
	displayTextLine(4, "Press Enter to accept.");
	while(true) {
		// Display the reflected value live to help manual positioning.
		lightVal = getColorReflected(Color1);
		displayBigTextLine(6, "Reflected: %d", lightVal);

		// Press enter to take 10 light sampels then tage the average and break out of the loop.
		if(getButtonPress(buttonEnter) == 1) {
			lightVal = avgReflectedLight(10);
			break;
		}
	}

	delay(1000);

	eraseDisplay();

	displayBigTextLine(0, "Color callib.");
	displayTextLine(3, "Place sensor on grey surface.");
	displayTextLine(4, "Press Enter to accept.");

	while(true) {
		// Display the reflected value live to help manual positioning.
		greyVal = getColorReflected(Color1);
		displayBigTextLine(6, "Reflected: %d", greyVal);

		// Press enter to take 10 light sampels then tage the average and break out of the loop.
		if(getButtonPress(buttonEnter) == 1) {
			greyVal = avgReflectedLight(10);
			break;
		}
	}

	delay(1000);

	displayBigTextLine(0, "Color callib.");
	displayTextLine(3, "Place sensor on dark surface.");
	displayTextLine(4, "Press Enter to accept.");
	while(true) {
		// Display the reflected value live to help manual positioning.
		darkVal = getColorReflected(Color1);
		displayBigTextLine(6, "Reflected: %d", darkVal);

		// Press enter to take 10 light sampels then tage the average and break out of the loop.
		if(getButtonPress(buttonEnter) == 1) {
			darkVal = avgReflectedLight(10);
			break;
		}
	}
		delay(5000);

	threshold = (lightVal + greyVal) / 2;
	stopLine = darkVal;
}
Пример #3
0
task main()
{
		struct Account accountList[NUMACCOUNTS];
		initAccounts(accountList, NUMACCOUNTS);

		string account;
		string cardnum;
		string pin;
		int accountindex;
		bool pinCorrect;

		while (getBatteryCurrent() > 0.02)
		{
			/*
			displayString(0,"Swipe card to Begin");
			do
			{
				cardnum = getCardSwipe();
				accountindex = doesExist(cardnum, accountList);
				displayString(0,"ERROR Card Not Found!!");
			}while (accountindex == -1);
			eraseDisplay();
			do
			{
				pinCorrect = checkPin(accountList);
				displayString(0,"ERROR Incorrect PIN");
			}while (pinCorrect == false);
			wait1Msec(100);
			eraseDisplay();
			wait1Msec(500);*/

			//Selection Menu
			while (getButtonPress(buttonEnter) != 1)
			{
					eraseDisplay();
					displayString(1,"Press center button to close transaction");
					displayString(2,"<----                   ---->");
					displayString(3,"Deposit             Withdraw");
					displayString(4,"     Balance: %f", accountList[accountindex].balance);

					waitForButtonPress();

			    if (getButtonPress(buttonLeft) == 1)
			    {
			    		int amount = doDeposit();
			        accountList[accountindex].balance += amount;
							eraseDisplay();
			        displayString(0,"%d", amount);
			    }
			    else if (getButtonPress(buttonRight) ==1)
			    {
			            int amount = doWithdraw(accountList[accountindex]);
			            if (amount != -1)
			            {
			            	accountList[accountindex].balance -= amount;
			            }
			    }
		  }

	    wait1Msec(5000);


		}
}
Пример #4
0
//Joel Ruhland
//Fully Tested
int getAmount()
{
        char amount[3] = {'0','0','0'};
        int i = 0;

        while (!getButtonPress(buttonEnter))
        {
                char pointer[3] = {' ',' ',' '};
                pointer[i] = '^';
                displayString(0, "Enter Amount: %c%c%c",amount[0],amount[1],amount[2]);
                displayString(1, "              %c%c%c",pointer[0],pointer[1],pointer[2]);

                while (getButtonPress(buttonAny) == 0)
              	{}
                //React to button Presses
               	while (getButtonPress(buttonAny) == 1)
                {
                        if (getButtonPress(buttonLeft) == 1)
                        {
                                i--;
                        }
                        else if (getButtonPress(buttonRight) ==1)
                        {
                                i++;
                        }
                        else if (getButtonPress(buttonUp) ==1)
                        {
                                amount[i]++;
                        }
                        else if (getButtonPress(buttonDown) ==1)
                        {
                                amount[i]--;
                        }
                        else
                        {
                                break;
                        }

                        if (i<0)
                                i++;
                        else if (i>2)
                                i--;

                        if (amount[i] >= ':')
                        		amount[i]--;
                        else if (amount[i] <= '/')
                        		amount[i]++;

                        wait1Msec(250);
                        eraseDisplay();


                }


        }
        int a0 = amount[0] - '0';
        int a1 = amount[1] - '0';
        int a2 = amount[2] - '0';
        eraseDisplay();
        return (a0*100+a1*10+a2);
}
Пример #5
0
bool checkPin(Account * accountList)
{
        char pin[4] = {'0','0','0','0'};
        int i = 0;

        while (!getButtonPress(buttonEnter))
        {
                char pointer[4] = {' ',' ',' ',' '};
                pointer[i] = '^';
                displayString(1, "Enter PIN: %c%c%c%c",pin[0],pin[1],pin[2],pin[3]);
                displayString(2, "           %c%c%c%c",pointer[0],pointer[1],pointer[2],pointer[3]);

                while (getButtonPress(buttonAny) == 0)
              	{}

                //React to button Presses
               	while (getButtonPress(buttonAny) == 1)
                {
                        if (getButtonPress(buttonLeft) == 1)
                        {
                                i--;
                        }
                        else if (getButtonPress(buttonRight) ==1 )
                        {
                                i++;
                        }
                        else if (getButtonPress(buttonUp) ==1)
                        {
                                pin[i]++;
                        }
                        else if (getButtonPress(buttonDown) ==1)
                        {
                                pin[i]--;
                        }
                        else
                        {
                                break;
                        }

                        if (i<0)
                                i++;
                        else if (i>3)
                                i--;

                        if (pin[i] >= ':')
                        		pin[i]--;
                        else if (pin[i] <= '/')
                        		pin[i]++;

                        wait1Msec(250);
                        eraseDisplay();


                }


        }
        eraseDisplay();
        string pinvalue = "";
        for (int i = 0; i<4; i++)
        {
        	pinvalue+=pin[i];
        }

        return comparePin(pinvalue, accountList);
}