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: TextLCD mbed-rtos mbed
main.cpp
- Committer:
- jfields
- Date:
- 2014-10-03
- Revision:
- 1:38e744366b97
- Parent:
- 0:c204b3ecd227
- Child:
- 2:91cb258f9745
File content as of revision 1:38e744366b97:
#include "mbed.h"
#include "rtos.h"
#include "TextLCD.h"
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x2);
Serial pc (USBTX, USBRX);
DigitalOut myled(LED1);
// global vars
int mm [] = {0, 0};
int ss [] = {0, 0};
int MM [] = {0, 0};
// functions
void update_display(void const *args);
void update_mm(void const *args);
void update_ss(void const *args);
void update_MM(void const *args);
int main() {
Thread thread_display(update_display);
Thread thread_mm(update_mm);
Thread thread_ss(update_ss);
Thread thread_MM(update_MM);
while (true) {
}
}
void update_display(void const *args) {
while (1) {
lcd.printf("%d%d:%d%d:%d%d\n\n", MM[1], MM[0],ss[1],ss[0],mm[1],mm[0]);
Thread::wait(10);
}
}
void update_mm(void const *args) {
while (1) {
Thread::wait(10);
mm[0]++;
if (mm[0] >= 10) {
mm[0] = 0;
mm[1]++;
}
if (mm[1] >= 10) {
mm[0] = 0;
mm[1] = 0;
}
}
}
void update_ss(void const *args) {
while (1) {
Thread::wait(1000);
ss[0]++;
if (ss[0] >= 10) {
ss[0] = 0;
ss[1]++;
}
if (ss[1] >= 6) {
ss[0] = 0;
ss[1] = 0;
}
}
}
void update_MM(void const *args) {
while (1) {
Thread::wait(60000);
MM[0]++;
if (MM[0] >= 10) {
MM[0] = 0;
MM[1]++;
}
if (MM[1] >= 6) {
MM[0] = 0;
MM[1] = 0;
}
}
}