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.
Fork of CW_copy by
calender_operation.h
- Committer:
- joseph_adamu
- Date:
- 2018-01-10
- Revision:
- 1:dc648c5624b9
File content as of revision 1:dc648c5624b9:
#include "mbed.h"
#include "print_LCD.h"
DigitalIn sw1(PE_12);
DigitalIn sw2(PE_14);
// function performs the cursor movement fro the date and time
//basically when the cusor is 0 upon upload the program the cursor stays in
//the first column, fist row and
//when cursor is 1 the moves to the second column in the first row
void date_and_time_update()
{
if (cursor == 0)
{
lcd.locate(0,0);
lcd.printf("%i", d);
}
if (cursor == 1)
{
lcd.locate(1,0);
lcd.printf("%i", dd);
}
if (cursor == 2)
{
lcd.locate(3,0);
lcd.printf("%i", m);
}
if (cursor == 3)
{
lcd.locate(4,0);
lcd.printf("%i", mm);
}
if (cursor == 4)
{
lcd.locate(6,0);
lcd.printf("%i", y);
}
if (cursor == 5)
{
lcd.locate(7,0);
lcd.printf("%i", yy);
}
if (cursor == 6)
{
lcd.locate(8,0);
lcd.printf("%i", yyy);
}
if (cursor == 7)
{
lcd.locate(9,0);
lcd.printf("%i", yyyy);
}
if (cursor == 8)
{
lcd.locate(0,1);
lcd.printf("%i", h);
}
if (cursor == 9)
{
lcd.locate(1,1);
lcd.printf("%i", hh);
}
if (cursor == 10)
{
lcd.locate(3,1);
lcd.printf("%i", mi);
}
if (cursor == 11)
{
lcd.locate(4,1);
lcd.printf("%i", mmi);
}
if (cursor == 12)
{
lcd.locate(6,1);
lcd.printf("%i", s);
}
if (cursor == 13)
{
lcd.locate(7,1);
lcd.printf("%i", ss);
}
}
// button performance function
// when the switch is preseed ==1 it waits 0.5 ms then it moves to the columns/ rows
void button_select_date()
{
if (sw2 == 1)
{
wait (1);
cursor++;
}
else if(cursor != 14)
{
switch (cursor)
{
case 0:
if (sw1 == 1)
{
wait (1);
d++;
if (d == 4)
{
d = 0;
}
}
case 1:
if (sw1 == 1)
{
wait (1);
dd++;
if (dd == 10)
{
dd = 0;
}
}
case 2:
if (sw1 == 1)
{
wait (1);
m++;
if (m == 2)
{
m = 0;
}
}
case 3:
if (sw1 == 1)
{
wait (1);
mm++;
if (mm == 10)
{
mm = 0;
}
}
case 4:
if (sw1 == 1)
{
wait (1);
y++;
if (y == 3)
{
y = 0;
}
}
case 5:
if (sw1 == 1)
{
wait (1);
yy++;
if (yy == 10)
{
yy = 0;
}
}
case 6:
if (sw1 == 1)
{
wait (1);
yyy++;
if (yyy == 10)
{
yyy = 0;
}
}
case 7:
if (sw1 == 1)
{
wait (1);
yyyy++;
if (yyyy == 10)
{
yyyy = 0;
}
}
case 8:
if (sw1 == 1)
{
wait (1);
h++;
if (h== 3)
{
h = 0;
}
}
case 9:
if (sw1 == 1)
{
wait (1);
hh++;
if (hh == 10)
{
hh = 0;
}
}
case 10:
if (sw1 == 1)
{
wait (1);
mi++;
if (mi == 6)
{
mi = 0;
}
}
case 11:
if (sw1 == 1)
{
wait (1);
mmi++;
if (mmi == 10)
{
mmi = 0;
}
}
case 12:
if (sw1 == 1)
{
wait (1);
s++;
if (s == 6)
{
s = 0;
}
}
case 13:
if (sw1 == 1)
{
wait (1);
ss++;
if (ss == 10)
{
ss = 0;
}
}
}
}
date_and_time_update();
}
