資源簡介
arduino 小賤鐘源碼及教程.

代碼片段和文件信息
/*
DS3231.cpp:?DS3231?Real-Time?Clock?library
original?code?by
Eric?Ayars
4/1/11
updated?to?Arduino?1.0?
John?Hubert
Feb?7?2012
Released?into?the?public?domain.
*/
#include?
#define?CLOCK_ADDRESS?0x68
//?Constructor
DS3231::DS3231()?{
//?nothing?to?do?for?this?constructor.
}
/*****************************************?
Public?Functions
?*****************************************/
void?DS3231::getTime(byte&?year?byte&?month?byte&?date?byte&?DoW?byte&?hour?byte&?minute?byte&?second)?{
byte?tempBuffer;
bool?PM;
bool?h12;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x00));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?7);
second?=?bcdToDec(Wire.read());
minute?=?bcdToDec(Wire.read());
tempBuffer?=?bcdToDec(Wire.read());
h12?=?tempBuffer?&?0b01000000;
if?(h12)?{
PM?=?tempBuffer?&?0b00100000;
hour?=?bcdToDec(tempBuffer?&?0b00011111);
}?else?{
hour?=?bcdToDec(tempBuffer?&?0b00111111);
}
DoW?=?bcdToDec(Wire.read());
date?=?bcdToDec(Wire.read());
month?=?bcdToDec(Wire.read()?&?0b01111111);
year?=?bcdToDec(Wire.read());
}
byte?DS3231::getSecond()?{
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x00));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
return?bcdToDec(Wire.read());
}
byte?DS3231::getMinute()?{
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(0x01);
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
return?bcdToDec(Wire.read());
}
byte?DS3231::getHour(bool&?h12?bool&?PM)?{
byte?temp_buffer;
byte?hour;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(0x02);
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
temp_buffer?=?Wire.read();
h12?=?temp_buffer?&?0b01000000;
if?(h12)?{
PM?=?temp_buffer?&?0b00100000;
hour?=?bcdToDec(temp_buffer?&?0b00011111);
}?else?{
hour?=?bcdToDec(temp_buffer?&?0b00111111);
}
return?hour;
}
byte?DS3231::getDoW()?{
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x03));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
return?bcdToDec(Wire.read());
}
byte?DS3231::getDate()?{
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x04));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
return?bcdToDec(Wire.read());
}
byte?DS3231::getMonth(bool&?Century)?{
byte?temp_buffer;
byte?hour;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x05));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
temp_buffer?=?Wire.read();
Century?=?temp_buffer?&?0b10000000;
return?(bcdToDec(temp_buffer?&?0b01111111))?;
}
byte?DS3231::getYear()?{
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x06));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS?1);
return?bcdToDec(Wire.read());
}
void?DS3231::setSecond(byte?Second)?{
//?Sets?the?seconds?
//?This?function?also?resets?the?Oscillator?Stop?Flag?which?is?set
//?whenever?power?is?interrupted.
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.wr
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????16274??2012-02-08?22:56??Plotclock程序及安裝說明\libraries\DS3231_TEST\DS3231.cpp
?????文件???????5161??2012-02-08?22:51??Plotclock程序及安裝說明\libraries\DS3231_TEST\DS3231.h
?????文件???????4645??2014-11-13?22:49??Plotclock程序及安裝說明\libraries\DS3231_TEST\Examples\DS3231_TEST\DS3231_TEST.ino
?????文件????????548??2012-02-07?11:17??Plotclock程序及安裝說明\libraries\DS3231_TEST\keywords.txt
?????文件????????243??2012-02-08?23:05??Plotclock程序及安裝說明\libraries\DS3231_TEST\Readme.txt
?????文件???????2641??2010-03-06?11:09??Plotclock程序及安裝說明\libraries\Time\DateStrings.cpp
?????文件????????392??2009-12-29?17:24??Plotclock程序及安裝說明\libraries\Time\Examples\Processing\SyncArduinoClock\readme.txt
?????文件???????2015??2009-12-30?18:02??Plotclock程序及安裝說明\libraries\Time\Examples\Processing\SyncArduinoClock\SyncArduinoClock.pde
?????文件???????2115??2010-01-06?09:45??Plotclock程序及安裝說明\libraries\Time\Examples\TimeGPS\TimeGPS.pde
?????文件???????3458??2010-03-06?19:20??Plotclock程序及安裝說明\libraries\Time\Examples\TimeNTP\TimeNTP.pde
?????文件???????1043??2010-01-05?14:13??Plotclock程序及安裝說明\libraries\Time\Examples\TimeRTC\TimeRTC.pde
?????文件???????3180??2010-01-06?10:30??Plotclock程序及安裝說明\libraries\Time\Examples\TimeRTCLog\TimeRTCLog.pde
?????文件???????2228??2010-01-06?09:53??Plotclock程序及安裝說明\libraries\Time\Examples\TimeRTCSet\TimeRTCSet.pde
?????文件???????2392??2010-01-06?10:55??Plotclock程序及安裝說明\libraries\Time\Examples\TimeSerial\TimeSerial.pde
?????文件???????2129??2010-01-06?10:55??Plotclock程序及安裝說明\libraries\Time\Examples\TimeSerialDateStrings\TimeSerialDateStrings.pde
?????文件????????805??2010-01-05?12:02??Plotclock程序及安裝說明\libraries\Time\keywords.txt
?????文件???????6979??2010-01-11?21:36??Plotclock程序及安裝說明\libraries\Time\Readme.txt
?????文件???????7897??2010-11-01?20:32??Plotclock程序及安裝說明\libraries\Time\Time.cpp
?????文件???????5602??2011-07-22?17:30??Plotclock程序及安裝說明\libraries\Time\Time.h
?????文件???????9323??2017-03-21?23:15??Plotclock程序及安裝說明\Plotclock程序\1.plotclock調試擺臂程序\plotclockadj\plotclockadj.ino
?????文件??????11308??2017-03-21?23:15??Plotclock程序及安裝說明\Plotclock程序\2.plotclock主程序?-?有時鐘模塊版\plotclock\plotclock.ino
?????文件??????10636??2016-07-10?18:24??Plotclock程序及安裝說明\Plotclock程序\3.plotclock主程序?-?無時鐘模塊版\plotclock\plotclock.ino
?????文件????????244??2014-11-08?00:48??Plotclock程序及安裝說明\Plotclock程序\3.plotclock主程序?-?無時鐘模塊版\什么是時鐘模塊?.txt
?????文件????5409227??2017-07-30?11:31??Plotclock程序及安裝說明\小賤鐘安裝說明201707.docx
?????文件????????832??2014-12-20?21:31??Plotclock程序及安裝說明\說明.txt
?????目錄??????????0??2016-07-15?17:07??Plotclock程序及安裝說明\libraries\Time\Examples\Processing\SyncArduinoClock
?????目錄??????????0??2016-07-15?17:07??Plotclock程序及安裝說明\libraries\DS3231_TEST\Examples\DS3231_TEST
?????目錄??????????0??2016-07-15?17:07??Plotclock程序及安裝說明\libraries\Time\Examples\Processing
?????目錄??????????0??2016-07-15?17:07??Plotclock程序及安裝說明\libraries\Time\Examples\TimeGPS
?????目錄??????????0??2016-07-15?17:07??Plotclock程序及安裝說明\libraries\Time\Examples\TimeNTP
............此處省略21個文件信息
評論
共有 條評論