RTC Emulator
I have been using the Propeller_RTC_Emulator object in one of my projects.
It seems to me that the current minutes Should be stored in the variable MM in the Propeller_RTC_Emulator_DEMO object.
However, when I print the value to the screen using the vga_text Dec function, it prints "0".
Can anyone explain how to get the minutes value from this object?
It seems to me that the current minutes Should be stored in the variable MM in the Propeller_RTC_Emulator_DEMO object.
However, when I print the value to the screen using the vga_text Dec function, it prints "0".
Can anyone explain how to get the minutes value from this object?
Comments
''Propeller Water Detection Demo '' CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ''Constants rx = 31 tx = 30 baud = 115200 EOT = 4 ACK = 6 US = 31 UniqueID = 130 ''EEPROM Loader UIDAddress = $7FE0 EEPROMDevice = $A0 EEPROMPin = 28 OBJ Clock : "PropellerRTC_Emulator" '' Real Time Clock Emulator ser : "FullDuplexSerialPlus" '' Serial COM Object vga : "VGA_Text" '' VGA Object mem : "Basic_I2C_Driver" '' EEPROM Object VAR ''RTC Variables long TimeString byte SS,MM,HH,AP,DD,MO,YY,LY byte DateStamp[11], TimeStamp[11] long UID ' for the UniqueID byte lastSync ' holds the last minute we synced with the computer's RTC PUB FULLTEST ser.start(rx,tx,0,baud) '' Start Serial COM vga.start(16) '' Start VGA out Clock.Start(@TimeString) '' Initiate Prop Clock waitcnt(clkfreq/10+cnt) '' wait for VGA to stabilize UID := get_UID '' Get this Chip's Unique ID from EEPROM vga.str(string("Unique ID: ")) vga.dec(UID) waitForPing getTime repeat Clock.ParseDateStamp(@DateStamp) Clock.ParseTimeStamp(@TimeStamp) vga.out(1) '' Send the HOME code to the VGA Screen vga.str(@DateStamp) '' Display Date to the VGA terminal vga.str(string(" ")) vga.str(@TimeStamp) '' Display Time to the VGA terminal vga.out(" ") vga.dec(TimeString) vga.out(" ") vga.dec(lastSync) check_sync_time PUB main | i, flag ser.start(rx, tx, 0, baud) VGA.Start(16) waitcnt(clkfreq+cnt) UID := get_UID vga.dec(UID) repeat VGA.dec(waitForPing) getTime send_mail(@MyEmail,@FrEmail,string("Test"),string("Testing Again. <br> Hello, <b>html</b>")) PRI waitForPing | temp repeat temp := ser.RxCheck ' check the Input Buffer if temp <> -1 if temp == 5 ' is it a PING? ser.rx ' remove the EOT (End of Transmission) byte ser.tx( ACK ) ' transmit [ACK][UniqueID][EOT] ser.dec( UID ) ser.tx( EOT ) return true return temp PRI check_sync_time if lastSync+5 < MM getTime elseif lastSync <> 0 AND MM == 0 getTime PRI getTime | temp, pos ''Time request is: Time[EOT] ser.str(string("Time",US)) custom_str_in(@InputData,EOT) ser.tx( ACK ) ser.tx( EOT ) '' Start Parsing the Clock Data: '' Format is [Year][US][Month][US][Day][US][Hour][US][Minute][US][Second][US][AM/PM][EOT] pos := @InputData 'Get a pointer to the TimeString Clock.Suspend 'Suspend clock while being set '' Pull Year Data pos := pullfield(pos,US) Clock.SetYear(ser.StrToDec(@Field+2)) ' Pull Last two Digits from Year info 'Pull Month Data pos := pullfield(pos,US) Clock.SetMonth(ser.StrToDec(@Field)) 'Set the Month 'Pull Date Data pos := pullfield(pos,US) Clock.SetDate(ser.StrToDec(@Field)) 'Pull Hour Data pos := pullfield(pos,US) Clock.SetHour(ser.StrToDec(@Field)) 'Pull Minute Data pos := pullfield(pos,US) Clock.SetMin(ser.StrToDec(@Field)) 'Pull Second Data pos := pullfield(pos,US) Clock.SetSec(ser.StrToDec(@Field)) 'Pull AM/PM Data pullfield(pos,0) Clock.SetAMPM(ser.StrToDec(@Field)) Clock.Restart '' Start Clock after being set 'save the minute we synced in lastSync lastSync := MM return True PRI pullfield(ptr,chr)| temp temp := @Field repeat while byte[ptr] <> chr byte[temp++] := byte[ptr++] byte[temp]:=0 return ++ptr PRI send_mail(eto,efrom,subj,body) '' Supports HTML in message. Format is: ' Email[US][SMTP Server][US][SMTP Username][US][SMTP Password][US][To Address][US][From Address][US][Subject][US][Body][US][EOT] ser.str(string("Email",US)) ser.str(@SMTPServ) ser.tx(US) ser.str(@SMTPUser) ser.tx(US) ser.str(@SMTPPass) ser.tx(US) ser.str(eto) ser.tx(US) ser.str(efrom) ser.tx(US) ser.str(subj) ser.tx(US) ser.str(body) ser.tx(EOT) PRI custom_str_in(ptr,chr) | i,optr ''WARNING: This Function *CAN* overwrite Run-Time Memory optr := ptr ' Save original pointer repeat i := ser.rx ' RX one byte if(i == chr) ' If matches character, it's the end byte[ptr] := 0 quit byte[ptr++] := i ' otherwise, add it to the string. return optr PRI get_UID vga.str(string("starting EEPROM",13)) mem.initialize(EEPROMPin) return mem.ReadLong(EEPROMPin, EEPROMDevice, UIDAddress) DAT MyEmail byte "---------@gmail.com",0 FrEmail byte "---------@gmail.com",0 SMTPServ byte "smtp.gmail.com",0 SMTPUser byte "---------@gmail.com",0 SMTPPass byte "---------",0 InputData byte "This string will be over-written by the data sent by H2PropGUI. It is Extra Long to prevent data loss.",0 Field byte "This is for storing info.",0 {{ ┌──────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this │ │software and associated documentation files (the "Software"), to deal in the Software │ │without restriction, including without limitation the rights to use, copy, modify, │ │merge, publish, distribute, sublicense, and/or sell copies of the Software, and to │ │permit persons to whom the Software is furnished to do so, subject to the following │ │conditions: │ │ │ │ │ │The above copyright notice and this permission notice shall be included in all copies │ │or substantial portions of the Software. │ │ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, │ │INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A │ │PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT │ │HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION │ │OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │ │SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────┘ }}
Because of the Variable MM always being 0, check_sync_time never runs get_time.
It's on this page:
http://www.rayslogic.com/propeller/Programming/Programming.htm
under:
RTC (Real-Time Clock) Services
"just using the Prop"
I may use your RTC Object later, as it seems a bit more robust than the RTC_Emulator object, but I have solved the problem.
I added a function that returns the value of the MM variable inside the RTC Object, and that seems to work fine.
Thanks for the help!