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 C12832_lcd
main.cpp
- Committer:
- mazmonem
- Date:
- 2018-11-15
- Revision:
- 1:13aae0117bbf
- Parent:
- 0:275c29641333
- Child:
- 2:684c698024c4
File content as of revision 1:13aae0117bbf:
#include "mbed.h"
#include "C12832_lcd.h"
C12832_LCD lcd;
Timeout increment;
BusIn up(p16);
BusIn down(p17);
BusIn left(p18);
BusIn right(p19);
BusIn centre(p20);
int hours=0;
int minutes=0;
bool toggle=false;
// How to detect if up is hold not press?
if (up = 1){
if (left = 1) {
inc_hrs();
}
else if (right = 1){
inc_min();
}
}
if (down = 1)
{
if (left = 1) {
inc_hrs();
} else if (right=1) {
inc_min();
}
}
/**
Adjust minutes
*/
void adj_min()
{
if (minutes>59) {
minutes=0;
} else if (minutes<59) {
minutes=0;
)
}
/**
adj hrs
*/
void adj_hrs()
{
if (hours>23) {
hours=0;
}
else if (hours<23) {
hours=0;
)
}
/**
Increment minutes
*/
void inc_min()
{
minutes++;
adj_min();
}
void inc_hrs()
{
hours++;
adj_hrs();
}
/**
Main entry point
*/
int main()
{
while(true) {
increment.attach(&inc_min, 60.0);
}
lcd.cls();
lcd.locate(0,15);
// Check if minutes are less than 10 so a 0 can be prefixed onto the display
string mins = "00"; // String to display in lcd screen
if(minutes < 10) {
mins = "0" + minutes;
} else {
mins = minutes;
}
lcd.printf("%s", mins);
}
}