Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
ethaderu
Date:
Tue Mar 05 02:34:44 2019 +0000
Revision:
3:78f223d34f36
Publish 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ethaderu 3:78f223d34f36 1 /* mbed Microcontroller Library
ethaderu 3:78f223d34f36 2 * Copyright (c) 2006-2013 ARM Limited
ethaderu 3:78f223d34f36 3 *
ethaderu 3:78f223d34f36 4 * Licensed under the Apache License, Version 2.0 (the "License");
ethaderu 3:78f223d34f36 5 * you may not use this file except in compliance with the License.
ethaderu 3:78f223d34f36 6 * You may obtain a copy of the License at
ethaderu 3:78f223d34f36 7 *
ethaderu 3:78f223d34f36 8 * http://www.apache.org/licenses/LICENSE-2.0
ethaderu 3:78f223d34f36 9 *
ethaderu 3:78f223d34f36 10 * Unless required by applicable law or agreed to in writing, software
ethaderu 3:78f223d34f36 11 * distributed under the License is distributed on an "AS IS" BASIS,
ethaderu 3:78f223d34f36 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ethaderu 3:78f223d34f36 13 * See the License for the specific language governing permissions and
ethaderu 3:78f223d34f36 14 * limitations under the License.
ethaderu 3:78f223d34f36 15 */
ethaderu 3:78f223d34f36 16
ethaderu 3:78f223d34f36 17 #include <time.h>
ethaderu 3:78f223d34f36 18
ethaderu 3:78f223d34f36 19 #ifdef __cplusplus
ethaderu 3:78f223d34f36 20 extern "C" {
ethaderu 3:78f223d34f36 21 #endif
ethaderu 3:78f223d34f36 22
ethaderu 3:78f223d34f36 23 /** Implementation of the C time.h functions
ethaderu 3:78f223d34f36 24 *
ethaderu 3:78f223d34f36 25 * Provides mechanisms to set and read the current time, based
ethaderu 3:78f223d34f36 26 * on the microcontroller Real-Time Clock (RTC), plus some
ethaderu 3:78f223d34f36 27 * standard C manipulation and formating functions.
ethaderu 3:78f223d34f36 28 *
ethaderu 3:78f223d34f36 29 * Example:
ethaderu 3:78f223d34f36 30 * @code
ethaderu 3:78f223d34f36 31 * #include "mbed.h"
ethaderu 3:78f223d34f36 32 *
ethaderu 3:78f223d34f36 33 * int main() {
ethaderu 3:78f223d34f36 34 * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
ethaderu 3:78f223d34f36 35 *
ethaderu 3:78f223d34f36 36 * while(1) {
ethaderu 3:78f223d34f36 37 * time_t seconds = time(NULL);
ethaderu 3:78f223d34f36 38 *
ethaderu 3:78f223d34f36 39 * printf("Time as seconds since January 1, 1970 = %d\n", seconds);
ethaderu 3:78f223d34f36 40 *
ethaderu 3:78f223d34f36 41 * printf("Time as a basic string = %s", ctime(&seconds));
ethaderu 3:78f223d34f36 42 *
ethaderu 3:78f223d34f36 43 * char buffer[32];
ethaderu 3:78f223d34f36 44 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
ethaderu 3:78f223d34f36 45 * printf("Time as a custom formatted string = %s", buffer);
ethaderu 3:78f223d34f36 46 *
ethaderu 3:78f223d34f36 47 * wait(1);
ethaderu 3:78f223d34f36 48 * }
ethaderu 3:78f223d34f36 49 * }
ethaderu 3:78f223d34f36 50 * @endcode
ethaderu 3:78f223d34f36 51 */
ethaderu 3:78f223d34f36 52
ethaderu 3:78f223d34f36 53 /** Set the current time
ethaderu 3:78f223d34f36 54 *
ethaderu 3:78f223d34f36 55 * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
ethaderu 3:78f223d34f36 56 * to the time represented by the number of seconds since January 1, 1970
ethaderu 3:78f223d34f36 57 * (the UNIX timestamp).
ethaderu 3:78f223d34f36 58 *
ethaderu 3:78f223d34f36 59 * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
ethaderu 3:78f223d34f36 60 *
ethaderu 3:78f223d34f36 61 * Example:
ethaderu 3:78f223d34f36 62 * @code
ethaderu 3:78f223d34f36 63 * #include "mbed.h"
ethaderu 3:78f223d34f36 64 *
ethaderu 3:78f223d34f36 65 * int main() {
ethaderu 3:78f223d34f36 66 * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
ethaderu 3:78f223d34f36 67 * }
ethaderu 3:78f223d34f36 68 * @endcode
ethaderu 3:78f223d34f36 69 */
ethaderu 3:78f223d34f36 70 void set_time(time_t t);
ethaderu 3:78f223d34f36 71
ethaderu 3:78f223d34f36 72 /** Attach an external RTC to be used for the C time functions
ethaderu 3:78f223d34f36 73 *
ethaderu 3:78f223d34f36 74 * Do not call this function from an interrupt while an RTC read/write operation may be occurring
ethaderu 3:78f223d34f36 75 *
ethaderu 3:78f223d34f36 76 * @param read_rtc pointer to function which returns current UNIX timestamp
ethaderu 3:78f223d34f36 77 * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
ethaderu 3:78f223d34f36 78 * @param init_rtc pointer to funtion which initializes RTC, can be NULL
ethaderu 3:78f223d34f36 79 * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
ethaderu 3:78f223d34f36 80 */
ethaderu 3:78f223d34f36 81 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
ethaderu 3:78f223d34f36 82
ethaderu 3:78f223d34f36 83 #ifdef __cplusplus
ethaderu 3:78f223d34f36 84 }
ethaderu 3:78f223d34f36 85 #endif