Hello everybody,
I have a problem when I try to convert a string to a numeric value.
Example:
I get a DateTime value in the following message "DT20170920111250S??" with the emedded date of "20170920" (09/20/2017) and the embedded time of "111250" (11:12:50).
I want to call the following Sub (to set the RTC), but I have to pass the parameters in numeric form (as bytes) and not the ASCII value:
setDS3231time(50, 12, 11, 0, 20, 9, 17)
How can I do this correctly? Any help is highly appreciated.
H.
I have a problem when I try to convert a string to a numeric value.
Example:
I get a DateTime value in the following message "DT20170920111250S??" with the emedded date of "20170920" (09/20/2017) and the embedded time of "111250" (11:12:50).
I want to call the following Sub (to set the RTC), but I have to pass the parameters in numeric form (as bytes) and not the ASCII value:
setDS3231time(50, 12, 11, 0, 20, 9, 17)
B4X:
Sub setDS3231time(second As Byte, minute As Byte, hour As Byte, dayofweek As Byte,dayOfMonth As Byte, months As Byte, years As Byte)
'First byte=0 --> Set Next input To start at the seconds register
'Next bytes (in BCD): second,minutes, hours, dayOfWeek,dayOfMonth,month,year
wirevar.WriteTo(RTC_ADDRESS,Array As Byte(0,decToBcd(second),decToBcd(minute),decToBcd(hour),decToBcd(dayofweek),decToBcd(dayOfMonth),decToBcd(months),decToBcd(years)))
End Sub
How can I do this correctly? Any help is highly appreciated.
H.