mirror of
https://github.com/digistump/DigistumpArduino.git
synced 2025-09-17 17:32:25 -07:00
switch to setup for Arduino Boards Manager
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
rtc_clock.set_time(10, 29, 49);
|
||||
|
||||
rtc_clock.set_alarmtime(10, 30, 0);
|
||||
|
||||
rtc_clock.attachalarm(announcement);
|
||||
// rtc_clock.disable_alarm();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("At the third stroke, it will be ");
|
||||
Serial.print(rtc_clock.get_hours());
|
||||
Serial.print(":");
|
||||
Serial.print(rtc_clock.get_minutes());
|
||||
Serial.print(":");
|
||||
Serial.println(rtc_clock.get_seconds());
|
||||
}
|
||||
|
||||
void announcement() {
|
||||
Serial.println();
|
||||
Serial.println("Get up and buy an Arduino Due.");
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
boolean toggle = false;
|
||||
int old_unixtime;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
|
||||
//Summertimebegin Germany in 2013
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(31,3,2013);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if ( rtc_clock.unixtime() != old_unixtime) {
|
||||
old_unixtime = rtc_clock.unixtime();
|
||||
output();
|
||||
}
|
||||
|
||||
if ( rtc_clock.get_seconds() == 10 ) {
|
||||
Serial.print("Timeleap ");
|
||||
toggle = !toggle;
|
||||
}
|
||||
if ( rtc_clock.get_seconds() == 10 && toggle == false ) {
|
||||
//Summertimebegin Germany in 2013
|
||||
Serial.println("back to summer");
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(31,3,2013);
|
||||
} else if (rtc_clock.get_seconds() == 10 && toggle == true ) {
|
||||
//Wintertimebegin Germany in 2013
|
||||
Serial.println("forward to the end of summer");
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(27,10,2013);
|
||||
}
|
||||
}
|
||||
|
||||
void output() {
|
||||
Serial.print("Unixtime: ");
|
||||
Serial.println(rtc_clock.unixtime(Germany));
|
||||
|
||||
Serial.println("And in plain for everyone");
|
||||
Serial.print("Time: ");
|
||||
digitprint(rtc_clock.get_hours() + rtc_clock.summertime(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_minutes(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_seconds(), 2);
|
||||
Serial.println("");
|
||||
Serial.print("Date: ");
|
||||
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
|
||||
Serial.print(" ");
|
||||
digitprint(rtc_clock.get_days(), 2);
|
||||
Serial.print(".");
|
||||
digitprint(rtc_clock.get_months(), 2);
|
||||
Serial.print(".");
|
||||
Serial.println(rtc_clock.get_years());
|
||||
|
||||
Serial.print("Is Summertime?: ");
|
||||
if ( rtc_clock.summertime() == 1 ) {
|
||||
Serial.println("Yes!");
|
||||
} else {
|
||||
Serial.println("No!");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
rtc_clock.set_time(10, 29, 9);
|
||||
rtc_clock.set_date(22, 10, 2012);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("At the third stroke, it will be ");
|
||||
Serial.print(rtc_clock.get_hours());
|
||||
Serial.print(":");
|
||||
Serial.print(rtc_clock.get_minutes());
|
||||
Serial.print(":");
|
||||
Serial.println(rtc_clock.get_seconds());
|
||||
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
|
||||
Serial.print(": ");
|
||||
Serial.print(rtc_clock.get_days());
|
||||
Serial.print(".");
|
||||
Serial.print(rtc_clock.get_months());
|
||||
Serial.print(".");
|
||||
Serial.println(rtc_clock.get_years());
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
int hh,mm,ss,dow,dd,mon,yyyy;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
rtc_clock.set_time(__TIME__);
|
||||
rtc_clock.set_date(__DATE__);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("Time: ");
|
||||
rtc_clock.get_time(&hh,&mm,&ss);
|
||||
rtc_clock.get_date(&dow,&dd,&mon,&yyyy);
|
||||
digitprint(hh, 2);
|
||||
Serial.print(":");
|
||||
digitprint(mm, 2);
|
||||
Serial.print(":");
|
||||
digitprint(ss, 2);
|
||||
Serial.println("");
|
||||
Serial.print("Date: ");
|
||||
Serial.print(daynames[dow-1]);
|
||||
Serial.print(" ");
|
||||
digitprint(dd, 2);
|
||||
Serial.print(".");
|
||||
digitprint(mon, 2);
|
||||
Serial.print(".");
|
||||
Serial.println(yyyy);
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
rtc_clock.set_time(__TIME__);
|
||||
rtc_clock.set_date(__DATE__);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("Unixtime: ");
|
||||
Serial.println(rtc_clock.unixtime());
|
||||
Serial.println("And in plain for everyone");
|
||||
Serial.print("Time: ");
|
||||
digitprint(rtc_clock.get_hours(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_minutes(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_seconds(), 2);
|
||||
Serial.println("");
|
||||
Serial.print("Date: ");
|
||||
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
|
||||
Serial.print(" ");
|
||||
digitprint(rtc_clock.get_days(), 2);
|
||||
Serial.print(".");
|
||||
digitprint(rtc_clock.get_months(), 2);
|
||||
Serial.print(".");
|
||||
Serial.println(rtc_clock.get_years());
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
rtc_clock.set_time(__TIME__);
|
||||
rtc_clock.set_date(__DATE__);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("Unixtime: ");
|
||||
//All known Timezones are supported set in this style "UTC+1" or "UTC-930" without colon
|
||||
Serial.println(rtc_clock.unixtime(UTC-5));
|
||||
Serial.println("And in plain for everyone");
|
||||
Serial.print("Time: ");
|
||||
digitprint(rtc_clock.get_hours(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_minutes(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_seconds(), 2);
|
||||
Serial.println("");
|
||||
Serial.print("Date: ");
|
||||
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
|
||||
Serial.print(" ");
|
||||
digitprint(rtc_clock.get_days(), 2);
|
||||
Serial.print(".");
|
||||
digitprint(rtc_clock.get_months(), 2);
|
||||
Serial.print(".");
|
||||
Serial.println(rtc_clock.get_years());
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
|
||||
|
||||
boolean toggle = false;
|
||||
int old_unixtime;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(15,6,2013);
|
||||
rtc_clock.timing();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if ( rtc_clock.unixtime() != old_unixtime) {
|
||||
old_unixtime = rtc_clock.unixtime();
|
||||
output();
|
||||
}
|
||||
|
||||
if ( rtc_clock.get_seconds() == 10 ) {
|
||||
Serial.print("Timeleap ");
|
||||
toggle = !toggle;
|
||||
}
|
||||
if ( rtc_clock.get_seconds() == 10 && toggle == false ) {
|
||||
//Summertimebegin Germany in 2013
|
||||
Serial.println("back to summer");
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(31,3,2013);
|
||||
} else if (rtc_clock.get_seconds() == 10 && toggle == true ) {
|
||||
//Wintertimebegin Germany in 2013
|
||||
Serial.println("forward to the end of summer");
|
||||
rtc_clock.set_time(1,59,50);
|
||||
rtc_clock.set_date(27,10,2013);
|
||||
}
|
||||
}
|
||||
|
||||
void output() {
|
||||
Serial.print("Unixtime: ");
|
||||
Serial.println(rtc_clock.unixtime(Germany));
|
||||
|
||||
Serial.println("And in plain for everyone");
|
||||
Serial.print("Time: ");
|
||||
digitprint(rtc_clock.get_hours() + rtc_clock.summertime(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_minutes(), 2);
|
||||
Serial.print(":");
|
||||
digitprint(rtc_clock.get_seconds(), 2);
|
||||
Serial.println("");
|
||||
Serial.print("Date: ");
|
||||
Serial.print(daynames[rtc_clock.get_day_of_week()-1]);
|
||||
Serial.print(" ");
|
||||
digitprint(rtc_clock.get_days(), 2);
|
||||
Serial.print(".");
|
||||
digitprint(rtc_clock.get_months(), 2);
|
||||
Serial.print(".");
|
||||
Serial.println(rtc_clock.get_years());
|
||||
|
||||
Serial.print("Is Summertime?: ");
|
||||
if ( rtc_clock.summertime() == 1 ) {
|
||||
Serial.println("Yes!");
|
||||
} else {
|
||||
Serial.println("No!");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
#include <rtc_clock.h>
|
||||
|
||||
#define START_VALUE "Jan 01 2007"
|
||||
|
||||
// Select the Slowclock source
|
||||
//RTC_clock rtc_clock(RC);
|
||||
RTC_clock rtc_clock(XTAL);
|
||||
|
||||
int counter = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
rtc_clock.init();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (rtc_clock.date_already_set() == 0) {
|
||||
Serial.print("no ");
|
||||
} else {
|
||||
Serial.print("yes ");
|
||||
}
|
||||
digitprint(counter, 3, 1);
|
||||
Serial.println();
|
||||
delay(125);
|
||||
if (counter == 50) {
|
||||
rtc_clock.set_date(__DATE__);
|
||||
}
|
||||
if (counter == 100) {
|
||||
counter = 0;
|
||||
// technical all the same
|
||||
//rtc_clock.set_date( 1, 1, 2007);
|
||||
//rtc_clock.set_date("Jan 01 2007");
|
||||
rtc_clock.set_date(START_VALUE);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
||||
void digitprint(int value, int lenght, int placeholder){
|
||||
for (int i = 0; i < (lenght - numdigits(value)); i++){
|
||||
if (placeholder == 0)
|
||||
Serial.print("0");
|
||||
else
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.print(value);
|
||||
}
|
||||
|
||||
int numdigits(int i){
|
||||
int digits;
|
||||
if (i < 10)
|
||||
digits = 1;
|
||||
else
|
||||
digits = (int)(log10((double)i)) + 1;
|
||||
return digits;
|
||||
}
|
Reference in New Issue
Block a user