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: BME280 BMP280 TextLCD mbed
Fork of CW_watchdog_08012018a by
main.cpp
- Committer:
- ckalintra
- Date:
- 2018-01-09
- Revision:
- 3:f5fe5071416a
- Parent:
- 2:c696dfd53eeb
- Child:
- 4:5dbb5145d0a9
File content as of revision 3:f5fe5071416a:
#include "mbed.h"
#include "TextLCD.h"
#include "BME280.h"
#include "putty.h"
#define watchdog_time 15
//DigitalOut myled(LED1);
int dislcd = 0, wdcounter = 0, watchdog = 0;
float T = 15;
Ticker display;
Ticker second_pass;
InterruptIn button(USER_BUTTON);
DigitalOut led(PB_11), led2(PB_10);
//NVIC_SetPriority(display, 0);
//NVIC_SetPriority(second_pass, 1);
//NVIC_SetPriority(button, 1);
void second_tick()
{
ss++;
if(watchdog == 1)
{
wdcounter++;
}
time_rule();
day_check();
lcd.cls();
if (dislcd == 1)
{
lcd.locate(10,0);
lcd.printf("l:%1.2f", lvl);
lcd.locate(0,0);
lcd.printf("p:%5.1f", pressuref);
lcd.locate(10,1);
lcd.printf("t:%2.1f", tempf);
display_time();
}
else if (dislcd == 0)
{
display_dates();
display_time();
}
if (wdcounter >= watchdog_time)
{
NVIC_SystemReset();
}
}
void lcddisp()
{
if (gather_data == 1)
{
led2 = 1;
display_time();
getdata();
store();
led2 = 0;
}
if (gather_data ==0)
{
led = 1;
wait(0.2);
led = 0;
}
}
void check_display()
{
if(dislcd == 0)
{dislcd = 1;}
else
{dislcd = 0;}
}
int main()
{
lcd.cls();
//display_date_time();
// while (pointer != 14)
// {
// select_date();
// }
bmp.initialize();
pc.printf("\n\rputty ready\n\r");
display.attach(&lcddisp, T);
second_pass.attach(&second_tick, 1.0);
button.rise(&check_display);
while(1)
{
check_display();
putty_write();
check_display();
if (interrupt == 1)
{
T = t;
display.attach(&lcddisp, T);
interrupt = 0;
}
}
}
