i want to translate this simple Sub from Arduino sketch
to b4r, why does it not work ????
thanks for any help
B4X:
void myRtcGet()
{ byte rSec, rMin, rHour, rDOW, rDay, rMonth, rYear;
Wire.beginTransmission(DS3231_I2C_ADDRESS); // Open I2C line in write mode
Wire.write(0x00); // Set the register pointer to (0x00)
Wire.endTransmission(); // End Write Transmission
Wire.requestFrom(DS3231_I2C_ADDRESS, 7); // Open the I2C line in send mode
rSec = bcdToDec(Wire.read() & 0x7f); // Read seven bytes of data
rMin = bcdToDec(Wire.read());
rHour = bcdToDec(Wire.read() & 0x3f);
rDOW = bcdToDec(Wire.read());
rDay = bcdToDec(Wire.read());
rMonth = bcdToDec(Wire.read());
rYear = bcdToDec(Wire.read());
setTime(rHour,rMin,rSec,rDay,rMonth,rYear);
}
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Private w1 As WireMaster
Private w1Adress As Int = 0x68
End Sub
Sub GetClockData
Log("Init Ds3231")
w1.Initialize
w1.WriteTo(w1Adress,Array As Byte(0, 0))
Dim data() As Byte = w1.RequestFrom(w1Adress,7)
If data.Length = 7 Then
Log("Data:",(data))
Else
Log("Missing data...")
Log("Data:",(data))
End If
End Sub