Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/GPSSensor/GPSSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static const uint32_t GPSBaud = 9600;
const int offset = 1;

#include <SPI.h>
#include <Time.h>
#include <TimeLib.h>
#include <MySensors.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/IrrigationController/IrrigationController.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Contributed by Jim (BulldogLowell@gmail.com) with much contribution from Pete (p
//#define MY_NODE_ID 1 // Set this to fix your Radio ID or use Auto

#include <Wire.h>
#include <Time.h>
#include <TimeLib.h>
#include <SPI.h>
#include <MySensors.h>
#include <LiquidCrystal.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/RainGauge/RainGauge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <SPI.h>
#include <MySensors.h>
#include <math.h>
#include <Time.h>
#include <TimeLib.h>

#define SKETCH_NAME "Rain Gauge"
#define SKETCH_VERSION "1.4.1a"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include <SPI.h>
#include <MySensors.h>
#include <Time.h>
#include <TimeLib.h>
#include <DS3232RTC.h> // A DS3231/DS3232 library
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/TimeAwareSensor/TimeAwareSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <SPI.h>
#include <MySensors.h>
#include <Time.h>
#include <TimeLib.h>

bool timeReceived = false;
unsigned long lastUpdate=0, lastRequest=0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include <Time.h>
#include <TimeLib.h>
#include <SPI.h>
#include <MySensors.h>
#include <stdarg.h>
Expand Down
37 changes: 27 additions & 10 deletions libraries/Time/DateStrings.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
/* DateStrings.cpp
* Definitions for date strings for use with the Time library
*
* Updated for Arduino 1.5.7 18 July 2014
*
* No memory is consumed in the sketch if your code does not call any of the string methods
* You can change the text of the strings, make sure the short strings are each exactly 3 characters
* the long strings can be any length up to the constant dt_MAX_STRING_LEN defined in Time.h
* the long strings can be any length up to the constant dt_MAX_STRING_LEN defined in TimeLib.h
*
*/

#include <avr/pgmspace.h>
#include "Time.h"

#if defined(__AVR__)
#include <avr/pgmspace.h>
#else
// for compatiblity with Arduino Due and Teensy 3.0 and maybe others?
#define PROGMEM
#define PGM_P const char *
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned char **)(addr))
#define strcpy_P(dest, src) strcpy((dest), (src))
#endif
#include <string.h> // for strcpy_P or strcpy
#include "TimeLib.h"

// the short strings for each day or month must be exactly dt_SHORT_STR_LEN
#define dt_SHORT_STR_LEN 3 // the length of short strings

static char buffer[dt_MAX_STRING_LEN+1]; // must be big enough for longest string and the terminating null

const char monthStr0[] PROGMEM = "";
const char monthStr1[] PROGMEM = "January";
const char monthStr2[] PROGMEM = "February";
const char monthStr3[] PROGMEM = "March";
Expand All @@ -28,10 +41,10 @@ const char monthStr10[] PROGMEM = "October";
const char monthStr11[] PROGMEM = "November";
const char monthStr12[] PROGMEM = "December";

PGM_P const monthNames_P[] PROGMEM =
const PROGMEM char * const PROGMEM monthNames_P[] =
{
"",monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6,
monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12
monthStr0,monthStr1,monthStr2,monthStr3,monthStr4,monthStr5,monthStr6,
monthStr7,monthStr8,monthStr9,monthStr10,monthStr11,monthStr12
};

const char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec";
Expand All @@ -45,15 +58,19 @@ const char dayStr5[] PROGMEM = "Thursday";
const char dayStr6[] PROGMEM = "Friday";
const char dayStr7[] PROGMEM = "Saturday";

PGM_P const dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";
const PROGMEM char * const PROGMEM dayNames_P[] =
{
dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7
};

const char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThuFriSat";

/* functions to return date strings */

char* monthStr(uint8_t month)
{
strcpy_P(buffer, (PGM_P)pgm_read_word(&(monthNames_P[month])));
return buffer;
return buffer;
}

char* monthShortStr(uint8_t month)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@


import processing.serial.*;
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;

public static final short portIndex = 1; // select the com port, 0 is the first port
public static final char TIME_HEADER = 'T'; //header byte for arduino serial time message
public static final short portIndex = 0; // select the com port, 0 is the first port
public static final String TIME_HEADER = "T"; //header for arduino serial time message
public static final char TIME_REQUEST = 7; // ASCII bell character
public static final char LF = 10; // ASCII linefeed
public static final char CR = 13; // ASCII linefeed
Expand All @@ -25,10 +28,15 @@ void setup() {
println(Serial.list());
println(" Connecting to -> " + Serial.list()[portIndex]);
myPort = new Serial(this,Serial.list()[portIndex], 9600);
println(getTimeNow());
}

void draw()
{
textSize(20);
textAlign(CENTER);
fill(0);
text("Click to send\nTime Sync", 0, 75, 200, 175);
if ( myPort.available() > 0) { // If data is available,
char val = char(myPort.read()); // read it and store it in val
if(val == TIME_REQUEST){
Expand All @@ -52,19 +60,19 @@ void mousePressed() {
}


void sendTimeMessage(char header, long time) {
void sendTimeMessage(String header, long time) {
String timeStr = String.valueOf(time);
myPort.write(header); // send header and time to arduino
myPort.write(timeStr);
myPort.write(timeStr);
myPort.write('\n');
}

long getTimeNow(){
// java time is in ms, we want secs
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(new Date());
int tzo = cal.get(Calendar.ZONE_OFFSET);
int dst = cal.get(Calendar.DST_OFFSET);
long now = (cal.getTimeInMillis() / 1000) ;
now = now + (tzo/1000) + (dst/1000);
return now;
Date d = new Date();
Calendar cal = new GregorianCalendar();
long current = d.getTime()/1000;
long timezone = cal.get(cal.ZONE_OFFSET)/1000;
long daylight = cal.get(cal.DST_OFFSET)/1000;
return current + timezone + daylight;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The portIndex must be set the Serial port connected to Arduino.
Download TimeSerial.pde onto Arduino and you should see the time
message displayed when you run SyncArduinoClock in Processing.
The Arduino time is set from the time on your computer through the
Processing sketch.
Processing sketch.
82 changes: 0 additions & 82 deletions libraries/Time/Examples/TimeGPS/TimeGPS.pde

This file was deleted.

120 changes: 0 additions & 120 deletions libraries/Time/Examples/TimeNTP/TimeNTP.pde

This file was deleted.

Loading