I am trying to concatenate the year month and day from the RTC values of now.year(), now.month(), and now.day().
I want combine the now.year(), now.month(),now.day() to end up with "20180717"
/*
* Arduino Clock with Coloer SPI oled
* Tempature reading that changes color based on tempature
* Battery level that changes color based on capasity
*
* ToDo: Add Menu, Add alarm saved to eprom
*
* BY: C4PT41ND34DP00L
*
* sclk = 13
* data = 11
* cd = 8
* cs = 10
* reset = 9
* Bat = A1 (if 5v arduino must connect + of bat to A1 before any boost converter)
* TMP36 = A0
* DS3113
* GND = GND
* VCC = 5V
* SDA = A4
* SCL = A5
*/
#include <SPI.h>
#include "Ucglib.h"
#include <Wire.h>
#include "RTClib.h"
#include <Battery.h>
//#include <SFE_BMP180.h>
// Setup RTC
RTC_DS1307 RTC;
char monthString[37] = {"JanFebMarAprMayJunJulAugSepOctNovDec"};
int monthIndex[122] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33};
/***********************************************************************************************/
//Setup bat mon (Min Voltage, Max Voltage, Sinsor pin)
Battery battery(3000, 4200, A1);
/***********************************************************************************************/
Ucglib_SSD1331_18x96x64_UNIVISION_SWSPI ucg(/*sclk=*/ 13, /*data=*/ 11, /*cd=*/ 8, /*cs=*/ 10, /*reset=*/ 9);
//TMP36 Pin Variables
boolean useTMP36 = true; // set this to false if you don not use TMP36
//boolean useTMP36 = false;
#define aref_voltage 1.1 // we tie to teh internal ref (1.1 V)
int tempPin = 0; //the analog pin that the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tempReading; // the analog reading from the sensor
/***********************************************************************************************/
void setup(void)
{
analogReference(INTERNAL);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
delay(1000);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
battery.begin(3700, 1.0); //Set first number to batteries mV
// init done
ucg.clearScreen();
}
void loop(void)
{
DateTime now = RTC.now();
ucg.setFontMode(UCG_FONT_MODE_SOLID);
ucg.setColor(0, 204, 0, 204);
ucg.setColor(1, 0, 0, 0);
ucg.setFont(ucg_font_04b_03b_hf);
ucg.setPrintPos(25, 60);
for (int i = 0; i <= 2; i++) {
ucg.print(monthString[monthIndex[now.month() - 1] + i]);
}
ucg.print('/');
ucg.print(now.day(), DEC);
ucg.print('/');
ucg.print(now.year(), DEC);
/***********************************************************************************************/
// display time in digital format
ucg.setFontMode(UCG_FONT_MODE_SOLID);
ucg.setColor(0, 255, 255, 255);
ucg.setColor(1, 0, 0, 0);
ucg.setFont(ucg_font_helvB24_hf);
ucg.setPrintPos(3, 45);
const uint8_t h = now.hour();
const uint8_t hr_12 = h % 12;
// Functions to move the cursor to second line fisrt position
if (hr_12 < 10) { // Zero padding if value less than 10 ie."09" instead of "9"
ucg.print(" ");
ucg.print((h > 12) ? h - 12 : ((h == 0) ? 12 : h), DEC); // Conversion to AM/PM
}
else {
ucg.print((h > 12) ? h - 12 : ((h == 0) ? 12 : h), DEC); // Conversion to AM/PM
}
printDigits(now.minute());
if (h < 12) { // Adding the AM/PM sufffix
ucg.setFontMode(UCG_FONT_MODE_SOLID);
ucg.setFont(ucg_font_04b_03b_hf);
ucg.setColor(0, 255, 255, 255);
ucg.setColor(1, 0, 0, 0);
ucg.setPrintPos(86, 35);
ucg.print("AM");
}
else {
ucg.setFontMode(UCG_FONT_MODE_SOLID);
ucg.setFont(ucg_font_04b_03b_hf);
ucg.setColor(0, 255, 255, 255);
ucg.setColor(1, 0, 0, 0);
ucg.setPrintPos(86, 25);
ucg.print("PM");
ucg.setFontMode(UCG_FONT_MODE_SOLID);
ucg.setFont(ucg_font_04b_03b_hf);
ucg.setColor(0, 255, 255, 255);
ucg.setColor(1, 0, 0, 0);
ucg.setPrintPos(0, 60);
ucg.print(now.year() + now.month() + now.day()); //Adds them together
ucg.print(now.year() && now.month() && now.day()); //gives me a |
}
}