phaseform 3 Posted September 29, 2015 Share Posted September 29, 2015 Just been able to get an RTC output on an I2C LCD working on a TM4C123. Using this RTC Library which I understand uses the chips built in RTC/hibernate function and this I2C LCD Library, which seems to only like I2C(3) // Core library for code-sense - IDE-based #if defined(WIRING) // Wiring specific # include "Wiring.h" #elif defined(ENERGIA) // LaunchPad specific # include "Energia.h" #else // error # error Platform not defined #endif // end IDE // Include application, user and local libraries // The time library provides all the tools. // No need for reinventing them! #include "time.h" #define CEST 2*60*60 #include "DateTimeLibrary.h" const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets //LCD #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x27 for a 16 character, 2 line display // Prototypes char * datestamp = __DATE__; char * timestamp = __TIME__; // Define variables and constants time_t myEpochRTC; tm myTimeRTC; DateTime myRTC; // Add setup code void setup() { Wire.begin(3); Wire.setModule(3); lcd.init(); // initialize the lcd Serial.begin(9600); delay(300); myRTC.begin(); myRTC.setTimeZone(tz_GMT); Serial.print("*** datestamp = "); Serial.println(datestamp); Serial.print("*** timestamp = "); Serial.println(timestamp); // Fri, 31 Jul 2015 20:41:48 GMT myEpochRTC = 946743570; // Set time to RTC, only once myRTC.setTime(myEpochRTC); Serial.print("Set RTC = "); Serial.println(myEpochRTC, DEC); myEpochRTC = 0; } // Add loop code void loop() { lcd.backlight(); lcd.setCursor(0,0); lcd.print("Session time:"); // Local time zone myEpochRTC = myRTC.getLocalTime(); lcd.setCursor(0,1); //lcd.print(stringDateTime(myEpochRTC)); // Even more flexible output! // see http://www.cplusplus.com/reference/ctime/strftime/ convertEpoch2Structure(myEpochRTC, myTimeRTC); lcd.print(stringFormatDateTime("%I:%M:%S %p.", myTimeRTC)); delay(100); } spirilis 1 Quote Link to post Share on other sites
Rei Vilo 695 Posted September 29, 2015 Share Posted September 29, 2015 Wire.begin(3); means you start I Quote Link to post Share on other sites
phaseform 3 Posted October 9, 2015 Author Share Posted October 9, 2015 Wire.begin(3); means you start I Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.