I downloaded the new 016 IDE software and copied my libraries.
I have a sketch using Wire.H and NewSoftSerial (for a DS1307 RTC and serial LCD). The code using NewSoftSerial is display garbage on the LCD when compiled and uploaded with version 016 but works perfectly with version 015.
#define LCD //compile NewSoftSerial LCD code
#define DEBUG //compile serial monitor clock display
#define SETCLOCK //compile clock setup code
#include "Wire.h"
#ifdef LCD
#include <NewSoftSerial.h>
#endif
#define DS1307_I2C_ADDRESS 0x68 //seven bit address
#define MAXLINE 10
#define is12HR 0x40
#define isPM 0x20
#define homeCur 1 //Cursor home cntl-A
#define bigChar 2 //Begin big characters cntl-B
#define regChar 3 //End big characters cntl-C
#define noCurs 4 //Make cursor invisible cntl-D
#define ulCurs 5 //Show underline cursor cntl-E
#define blkCurs 6 //Show blinking block cursor
#define rngBell 7 //Bell output cntl-G
#define backSp 8 //Backspace cntl-H
#define hTab 9 //Horizontal tab (4 col) cntl-I
#define curLF 10 //Smart linefeed cntl-J
#define vTab 11 //cursor up one line cntl-K
#define clrLCD 12 //Clear entire LCD screen cntl-L
#define carRet 13 //Carriage return cntl-M
#define offBkLight 15 //Backlight off cntl-O
#define onBkLight 14 //Backlight on cntl-N
#define posCmd 16 //Position cursor cntl-P
#define clrCol 17 //Clear column cntl-Q ?
#define alignRight 18 //Accept right-alignment data cntl-R
#define Esc 27 //Escape sequences
static char *dayname[] =
{ "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
};
#ifdef LCD
NewSoftSerial mySerial(255, 3); //tx only
#endif
void setup()
{
Wire.begin();
Serial.begin(9600);
#ifdef LCD
mySerial.begin(9600);
mySerial.print(clrLCD, BYTE);
mySerial.print(onBkLight , BYTE);
delay(1000);
#endif
#ifdef SETCLOCK
char ans[1];
int serbytes=0;
Serial.println("Enter 'y' to set clock");
serbytes = getSerStrWait(ans, 1, 5000);
if (strcmp(ans, "y") == 0) {
setClock();
}
#endif
}
void loop()
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year, ampm;
getClock(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year, &m);
#ifdef DEBUG
leadzero(hour);
Serial.print(hour, DEC);
Serial.print(":");
leadzero(minute);
Serial.print(minute, DEC);
Serial.print(":");
leadzero(second);
Serial.print(second, DEC);
if (ampm != ' ') { //not space
Serial.print(" ");
Serial.print(ampm);
Serial.print("M");
}
Serial.print(" ");
leadzero(month);
Serial.print(month, DEC);
Serial.print("/");
leadzero(dayOfMonth);
Serial.print(dayOfMonth, DEC);
Serial.print("/");
leadzero(year);
Serial.print(year, DEC);
Serial.print(" ");
Serial.println(dayname[dayOfWeek-1]);
#endif
#ifdef LCD
mySerial.print(posCmd, BYTE);
mySerial.print(24+64, BYTE);
lcdleadzero(hour);
mySerial.print(hour, DEC);
mySerial.print(":");
lcdleadzero(minute);
mySerial.print(minute, DEC);
mySerial.print(":");
lcdleadzero(second);
mySerial.print(second, DEC);
if (ampm != ' ') { //not space
mySerial.print(" ");
mySerial.print(ampm);
mySerial.print("M");
}
mySerial.print(posCmd, BYTE);
mySerial.print(44+64, BYTE);
lcdleadzero(month);
mySerial.print(month, DEC);
mySerial.print("/");
lcdleadzero(dayOfMonth);
mySerial.print(dayOfMonth, DEC);
mySerial.print("/");
lcdleadzero(year);
mySerial.print(year, DEC);
mySerial.print(" ");
mySerial.println(dayname[dayOfWeek-1]);
#endif
delay(1000);
}
void leadzero(byte val) {
if (val < 10) {
Serial.print("0");
}
}
#ifdef LCD
void lcdleadzero(byte val) {
if (val < 10) {
mySerial.print("0");
}
}
#endif
#ifdef SETCLOCK
void setClock() {
//prompt for time settings
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
byte mode = 0x00;
byte ampm = 0x00;
char ans[1];
char dig2[3];
int serbytes=0;
Serial.println("Enter 2 dig year");
serbytes = getSerStr(dig2, 2);
year = atoi(dig2);
Serial.println("Enter 2 dig month");
serbytes = getSerStr(dig2, 2);
month = atoi(dig2);
Serial.println("Enter 2 dig day of month (1-31)");
serbytes = getSerStr(dig2, 2);
dayOfMonth = atoi(dig2);
Serial.println("Enter day of week where 1=SUN 2=MON 3=TUE 4=WED 5=THU 6=FRI 7=SAT");
serbytes = getSerStr(dig2, 1);
dayOfWeek = atoi(dig2);
Serial.println("Enter clock mode - 12 or 24");
serbytes = getSerStr(dig2, 2);
if (strcmp(dig2, "12") == 0) {
mode = is12HR;
Serial.println("Enter 'a' or 'p' for AM or PM");
serbytes = getSerStr(ans, 1);
if (strcmp(ans, "p") == 0) {
ampm = isPM;
}
}
Serial.print("Enter 2 dig hour ");
if (mode == is12HR) {
Serial.println("(1-12)");
}else{
Serial.println("(0-23)");
}
serbytes = getSerStr(dig2, 2);
hour = atoi(dig2);
Serial.println("Enter 2 dig minute");
serbytes = getSerStr(dig2, 2);
minute = atoi(dig2);
second = 0;
if (mode == is12HR) {
hour = hour | is12HR;
if (ampm == isPM) {
hour = hour | isPM;
}
}
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(hour); //already formatted with bits 6 and 5
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
#endif
// Gets the date and time from the ds1307
void getClock(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year,
byte *ampm)
{
byte work;
byte mode; //12 or 24 hour
byte ap_ind; //am or pm indicator
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f); //mask CH bit (bit 7)
*minute = bcdToDec(Wire.receive());
// *hour = bcdToDec(Wire.receive());
work = Wire.receive(); // get hour byte
mode = work & is12HR; // if bit 6 high, running 12 hour mode
if (mode == is12HR) {
ap_ind = work & isPM; // if bit 5 high, it's P M
*hour = bcdToDec(work & 0x1f); // mask bits 5 thru 7 for 12 hour clock
if (ap_ind == isPM) {
*ampm = 'P';
}else{
*ampm = 'A';
}
}else{
*hour = bcdToDec(work & 0x3f); // mask bits 6 and 7 for 24 hour clock
*ampm = ' ';
}
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
#ifdef SETCLOCK
int getSerStr(char line[], int lim) {
int bytesread=0;
int val=0;
while(bytesread<lim) {
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10) || (val == 13) || (val == '*')) {
break; // stop reading
}
line[bytesread] = val; // add the digit
bytesread++; // ready to read next character
}
}
line[bytesread] = '\0'; //terminate string
return(bytesread);
}
int getSerStrWait(char line[], int lim, int waitms) {
int bytesread=0;
int val=0;
unsigned long start = millis();
while(bytesread<lim) {
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10) || (val == 13) || (val == '*')) {
break; // stop reading
}
line[bytesread] = val; // add the digit
bytesread++; // ready to read next character
}
if (millis() - start > waitms) {
Serial.flush();
line[0] = '\0';
return(0);
}
}
line[bytesread] = '\0'; //terminate string
return(bytesread);
}
#endif
//BCD to decimal conversion: decVal =(bcdVal.NIB1 * 10) + bcdVal.NIB0
//decimal to BCD conversion: bcdVal = (decVal / 10 <<4) + bcdVal // 10
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16*10) + (val%16) );
}
// Stops the DS1307, but it has the side effect of setting seconds to 0
// Probably only want to use this for testing
/*void stopDs1307()
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(0x80);
Wire.endTransmission();
}*/