Alarm
Dependencies: mbed HTTPClient mbed-rtos 4DGL-uLCD-SE NTPClient EthernetInterface
Revision 1:2dcc0acbaa0b, committed 2020-12-17
- Comitter:
- conormoloney
- Date:
- Thu Dec 17 18:49:31 2020 +0000
- Parent:
- 0:070d52cbaed0
- Commit message:
- project alarm with LCD
Changed in this revision
4DGL-uLCD-SE.lib | Show annotated file Show diff for this revision Revisions of this file |
alarm.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 070d52cbaed0 -r 2dcc0acbaa0b 4DGL-uLCD-SE.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Thu Dec 17 18:49:31 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/sparkfun/code/4DGL-uLCD-SE/#e39a44de229a
diff -r 070d52cbaed0 -r 2dcc0acbaa0b alarm.h --- a/alarm.h Wed Dec 16 18:52:50 2020 +0000 +++ b/alarm.h Thu Dec 17 18:49:31 2020 +0000 @@ -2,13 +2,14 @@ #include "mbed.h" #include "EthernetInterface.h" #include "NTPClient.h" +#include "uLCD_4DGL.h" #define VOLUME 1 +//Serial Monitor Serial pc(USBTX, USBRX); // Parameters -char* domain_name = "us.pool.ntp.org"; int port_number = 123; // Networking @@ -17,10 +18,9 @@ //Pins PwmOut pwm_pin(p21); -DigitalIn button(p8); +DigitalIn button(p12); BusOut LEDS(LED1,LED2,LED3,LED4); - - +uLCD_4DGL uLCD(p9,p10,p11); // Plays a sound with the defined frequency, duration, and volume void playNote(float frequency, float duration, float volume) { @@ -36,25 +36,24 @@ eth.init(); eth.connect(); - pc.printf("IP address is \n%s\n\n",eth.getIPAddress()); wait(1); char* domainName="0.uk.pool.ntp.org"; - + //Initilaise LCD + uLCD.baudrate(115200); // Read time from server pc.printf("Reading time...\n\r"); ntpClient.setTime(domainName,123,0x00005000); - char buffer[80]; + //Buffers for holding time when the alarm begins and ends + char buffer1[80]; + char buffer2[80]; wait(2); eth.disconnect(); ctTime = time(NULL); - pc.printf("Alarm began on\n"); - strftime(buffer, 80, " %a %b %d\n %T %p %z\n %Z\n", \ + strftime(buffer1, 80, " %a %b %d\n %T %p %z\n %Z\n", \ localtime(&ctTime)); - pc.printf(" UTC/GMT:\n%s", buffer); - // Loop while((button==1)) { @@ -64,12 +63,16 @@ playNote(770,1.2,VOLUME); LEDS=0; } - - pc.printf("Alarm stopped on\n"); + uLCD.printf("Alarm Began On:\n"); + uLCD.printf(" UTC/GMT:\n%s", buffer1); + // pc.printf("Alarm stopped on\n"); ctTime = time(NULL); - strftime(buffer, 80, " %a %b %d\n %T %p %z\n %Z\n", \ + strftime(buffer2, 80, " %a %b %d\n %T %p %z\n %Z\n", \ localtime(&ctTime)); - pc.printf(" UTC/GMT:\n%s", buffer); + uLCD.printf("Alarm Stopped On:\n"); + uLCD.printf(" UTC/GMT:\n%s", buffer2); + wait(30); + uLCD.cls(); }