Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 12:4b881052e3db, committed 2015-12-12
- Comitter:
- vhsstar
- Date:
- Sat Dec 12 03:20:40 2015 +0000
- Parent:
- 11:da190355ca49
- Commit message:
- All the things
Changed in this revision
| MenuStateMachine/MenuStateMachine.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MenuStateMachine/MenuStateMachine.h Fri Dec 11 18:19:27 2015 +0000
+++ b/MenuStateMachine/MenuStateMachine.h Sat Dec 12 03:20:40 2015 +0000
@@ -39,10 +39,14 @@
NFC device(p28, p27, p5, 0x48);
NFCTag taglesworth;
+int day = 11;
+int month = 12;
+int year = 15;
+
//Implimentation of functions
void startUp(void)
{
- taglesworth.setString("MILK 151210");
+ taglesworth.setString("MILK 151212");
screen.print("Start Up ");
wait(1);
Menu.nextState = &MainMenu;
@@ -100,6 +104,7 @@
screen.printTop("Read A Tag ");
+ device.writeNFCTag(&taglesworth);
if(device.readNFCTag(&taglesworth))
{
@@ -148,7 +153,39 @@
{
static int millisecondsLeft = 6000;
- int expired = 0;
+ int expired = 2;
+
+
+ if(taglesworth.Year() < year)
+ {
+ expired = 1;
+ }
+ else if(taglesworth.Year() > year)
+ {
+ expired = 0;
+ }
+ else
+ {
+ if(taglesworth.Month() < month)
+ {
+ expired = 1;
+ }
+ else if(taglesworth.Month() > month)
+ {
+ expired = 0;
+ }
+ else
+ {
+ if(taglesworth.Day() <= day)
+ {
+ expired = 1;
+ }
+ else if(taglesworth.Day() > day)
+ {
+ expired = 0;
+ }
+ }
+ }
thumby.update();
wait_ms(100);
@@ -162,7 +199,7 @@
char topString[16];
char bottomString[16];
- if(expired)
+ if(expired == 1)
{
if(millisecondsLeft % 2000 < 1000)
{
@@ -177,7 +214,7 @@
bottomString[6] = taglesworth.itemString[10];
bottomString[7] = taglesworth.itemString[11];
- //Fill them gaps up with spacres, yo
+ //Fill them gaps up with spaces, yo
for(int i = 8; i < 16; ++i)
{
topString[i] = ' ';
@@ -186,11 +223,19 @@
}
else
{
- //Expired screen 2
+ for(int i = 0; i < 16; ++i)
+ {
+ topString[i] = "Item Expired "[i];
+ bottomString[i] = "< Main Menu >"[i];
+ }
}
}
- else
+ else if (expired == 0)
{
+ int MonthsUntilExpired = taglesworth.Month() - month;
+ int DaysUntilExpired = taglesworth.Day() - day;
+ int YearsUntilExpired = taglesworth.Year() - year;
+
if(millisecondsLeft % 3000 < 1000)
{
for(int i = 0; i < 16; ++i)
@@ -204,8 +249,16 @@
for(int i = 0; i < 16; ++i)
{
topString[i] = ("Expires in: ")[i];
- bottomString[i] = ("No days ")[i];
+ bottomString[i] = (" __ y __ m __ d ")[i];
}
+ bottomString[1] = (YearsUntilExpired / 10) + '0';
+ bottomString[2] = (YearsUntilExpired % 10) + '0';
+
+ bottomString[6] = (MonthsUntilExpired / 10) + '0';
+ bottomString[7] = (MonthsUntilExpired % 10) + '0';
+
+ bottomString[11] = (DaysUntilExpired / 10) + '0';
+ bottomString[12] = (DaysUntilExpired % 10) + '0';
}
else
{

