-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SV-Zanshin
authored and
SV-Zanshin
committed
Jun 28, 2018
1 parent
9ee297f
commit c6806c5
Showing
5 changed files
with
576 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
########################################################################################## | ||
# This section defines which file types are associated with which linguist-documentation # | ||
# language types. Without this, linguist detects this as mere c++ code and not as an # | ||
# Arduino library # | ||
########################################################################################## | ||
######################################################################## | ||
# This section defines which file types are associated with which # | ||
# linguist-documentation language types. Initially this was set so that# | ||
# the "Arduino" language was chosen, but that is no longer considered # | ||
# a language so everything has been reverted to "c++" # | ||
# # | ||
# Date Author Comments # | ||
# ========== ============================= =========================== # | ||
# 2018-06-24 https://github.com/SV-Zanshin Changed file # | ||
# # | ||
######################################################################## | ||
examples/ linguist-documentation=false | ||
*.ino linguist-language=c++ | ||
*.c linguist-language=c++ | ||
*.cpp linguist-language=c++ | ||
*.h linguist-language=c++ | ||
*.c linguist-language=c++ | ||
*.ino linguist-language=c++ | ||
*.pde linguist-language=c++ | ||
*.c linguist-language=c++ | ||
*.h linguist-language=c++ | ||
*.cpp linguist-language=c++ | ||
|
||
# Auto detect text files and perform LF normalization | ||
######################################################################## | ||
# Auto detect text files and perform LF normalization # | ||
######################################################################## | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
######################################################################## | ||
# Custom setting for Visual Studio/Atmel Studio files # | ||
######################################################################## | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain | ||
######################################################################## | ||
# Standard to msysgit # | ||
######################################################################## | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,80 @@ | ||
# Windows image file caches | ||
######################################################################## | ||
# This file defines which file types are to be ignroed and skipped by # | ||
# git so that they are not transferred and committed. # | ||
# # | ||
# Date Author Comments # | ||
# ========== ============================= =========================== # | ||
# 2018-06-24 https://github.com/SV-Zanshin Changed file # | ||
# # | ||
######################################################################## | ||
|
||
######################################################################## | ||
# Windows image file caches # | ||
######################################################################## | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
######################################################################## | ||
# Windows folder config file # | ||
######################################################################## | ||
Desktop.ini | ||
|
||
# Work in progress folder | ||
WorkInProgress/ | ||
# Recycle Bin used on file shares | ||
######################################################################## | ||
# Recycle Bin used on file shares # | ||
######################################################################## | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
######################################################################## | ||
# Windows Installer files # | ||
######################################################################## | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
######################################################################## | ||
# Windows shortcuts # | ||
######################################################################## | ||
*.lnk | ||
|
||
# ========================= | ||
# Operating System Files | ||
# ========================= | ||
|
||
# OSX | ||
# ========================= | ||
|
||
######################################################################## | ||
# Operating System Files - OSX # | ||
######################################################################## | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
######################################################################## | ||
# Thumbnails # | ||
######################################################################## | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
######################################################################## | ||
# Files that might appear in the root of a volume # | ||
######################################################################## | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
|
||
# Directories potentially created on remote AFP share | ||
######################################################################## | ||
# Directories potentially created on remote AFP share # | ||
######################################################################## | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
# Files and directories from the Atmel Studio Arduino IDE | ||
|
||
######################################################################## | ||
# Files and directories from the Atmel Studio Arduino IDE # | ||
######################################################################## | ||
.vs | ||
__vm | ||
Debug | ||
Release | ||
*.atsln | ||
*.componentinfo.xml | ||
*.cppproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/******************************************************************************************************************* | ||
** Example program for using the MCP7940 library and a MCP7940N with power fail and battery backup options ** | ||
** ** | ||
** The MCP7940 library uses the standard SPI Wire library for communications with the RTC chip and has also used ** | ||
** the class definitions of the standard RTClib library from Adafruit/Jeelabs. ** | ||
** ** | ||
** The data sheet for the MCP7940M is located at http://ww1.microchip.com/downloads/en/DeviceDoc/20002292B.pdf. ** | ||
** The description for the GPS from adafruit can be found at https://learn.adafruit.com/adafruit-ultimate-gps/. ** | ||
** ** | ||
** The program demonstrates the battery backup related functions in the library ** | ||
** ** | ||
** This program is free software: you can redistribute it and/or modify it under the terms of the GNU General ** | ||
** Public License as published by the Free Software Foundation, either version 3 of the License, or (at your ** | ||
** option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY ** | ||
** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** | ||
** GNU General Public License for more details. You should have received a copy of the GNU General Public License ** | ||
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** | ||
** ** | ||
** Vers. Date Developer Comments ** | ||
** ====== ========== =================== ======================================================================== ** | ||
** 1.0.0 2017-07-30 [email protected] Initial coding ** | ||
** ** | ||
*******************************************************************************************************************/ | ||
#include <MCP7940.h> // Include the MCP7940 RTC library // | ||
/******************************************************************************************************************* | ||
** Declare all program constants ** | ||
*******************************************************************************************************************/ | ||
const uint32_t SERIAL_SPEED = 115200; // Set the baud rate for Serial I/O // | ||
const uint8_t SPRINTF_BUFFER_SIZE = 64; // Buffer size for sprintf() // | ||
const uint8_t LED_PIN = 13; // Built in LED // | ||
const uint8_t MFP_PIN = 2; // Pin used for the MCP7940 MFP // | ||
/******************************************************************************************************************* | ||
** Declare global variables and instantiate classes ** | ||
*******************************************************************************************************************/ | ||
MCP7940_Class MCP7940; // Create an instance of the MCP7940// | ||
char inputBuffer[SPRINTF_BUFFER_SIZE]; // Buffer for sprintf()/sscanf() // | ||
DateTime now; // Global definition of a date/time // | ||
/******************************************************************************************************************* | ||
** Method Setup(). This is an Arduino IDE method which is called upon boot or restart. It is only called one time ** | ||
** and then control goes to the main loop, which loop indefinately. ** | ||
*******************************************************************************************************************/ | ||
void setup() { // Arduino standard setup method // | ||
pinMode(MFP_PIN,INPUT); // MCP7940 Alarm MFP digital pin // | ||
pinMode(LED_PIN,OUTPUT); // Green built in LED on Arduino // | ||
digitalWrite(LED_PIN,LOW); // Turn off the LED light // | ||
Serial.begin(SERIAL_SPEED); // Start serial port at Baud rate // | ||
#ifdef __AVR_ATmega32U4__ // If this is a 32U4 processor, then// | ||
delay(3000); // wait 3 seconds for the serial // | ||
#endif // interface to initialize // | ||
sprintf(inputBuffer,"Starting BatteryBackup program\n- c++ compiler version %s\n- Compiled on %s at %s\n", | ||
__VERSION__,__DATE__,__TIME__); // // | ||
Serial.print(inputBuffer); // Display program and compile date // | ||
sprintf(inputBuffer,"- Arduino IDE V%d\, CPU Frequency %dmHz\n", // // | ||
ARDUINO, F_CPU/1000000); // // | ||
Serial.print(inputBuffer); // Display IDE and speed information// | ||
Serial.print(F("- Initializing MCP7940 Real-Time-Clock\n")); // // | ||
while (!MCP7940.begin()) { // Initialize RTC communications // | ||
Serial.println(F("- Unable to find MCP7940M. Waiting 3 seconds.")); // Show error text // | ||
delay(3000); // wait three seconds // | ||
} // of loop until device is located // // | ||
MCP7940.adjust(); // Set the RTC time to compile time // | ||
sprintf(inputBuffer,"- Time set to %04d-%02d-%02d %02d:%02d:%02d\n", // Use sprintf() to pretty print // | ||
now.year(),now.month(),now.day(),now.hour(),now.minute(), // output with leading zeroes // | ||
now.second()); // // | ||
Serial.print(inputBuffer); // Output the sprintf buffer // | ||
MCP7940.setBattery(true); // enable Battery Backup // | ||
Serial.print("- Battery Backup mode is "); // // | ||
Serial.println(MCP7940.getBattery()); // // | ||
} // of method setup() // // | ||
/******************************************************************************************************************* | ||
** This is the main program for the Arduino IDE, it is an infinite loop and keeps on repeating. ** | ||
*******************************************************************************************************************/ | ||
void loop() { // // | ||
static uint8_t lastSeconds = 0; // Store last time seconds displayed// | ||
now = MCP7940.now(); // get the current date/time // | ||
if (now.second()!=lastSeconds) { // If the seconds have changed // | ||
sprintf(inputBuffer,"%04d-%02d-%02d %02d:%02d:%02d", // Use sprintf() to pretty print // | ||
now.year(),now.month(),now.day(),now.hour(),now.minute(), // output with leading zeroes // | ||
now.second()); // // | ||
Serial.print(inputBuffer); // Output the sprintf buffer // | ||
if (MCP7940.getPowerFail()) { // If a power failure is detected // | ||
Serial.print(" *Power Fail*"); // // | ||
} // of if-then power has failed // // | ||
Serial.println(); // // | ||
lastSeconds = now.second(); // Set the seconds // | ||
} // of if-then seconds have changed // // | ||
} // of method loop() //----------------------------------// |
Oops, something went wrong.