Exemple #1
0
 public static void Adjust(byte newHour, byte newMin, byte newSec, byte newDay, byte newMonth, int newYear)
 {
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x00, newSec, TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x01, Tools.Bin2Bcd(newMin)[0], TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x02, newHour, TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x03, 1, TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x04, newDay, TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x05, newMonth, TransactionTimeout);
     I2CBus.GetInstance().WriteRegister(SlaveConfig, 0x06, (byte)(newYear - 2000), TransactionTimeout);
 }
Exemple #2
0
        public static byte[] CurrentTime()
        {
            var time = new byte[7];

            I2CBus.GetInstance().ReadRegister(SlaveConfig, 0x00, time, TransactionTimeout);

            var realseconds = Tools.Bcd2Bin(new [] { time[0] });
            var minutes     = Tools.Bcd2Bin(new [] { time[1] });
            var hours       = Tools.Bcd2Bin(new [] { time[2] });

            Rebug.Print("Current time: " + hours + ":" + minutes + ":" + realseconds + ", Freemem: " + Debug.GC(true) + ", Action Count: " + ThreadPool.ActionCount + ", Log count: " + FlightComputer.Logger.PendingItems);
            return(new[]
            {
                (byte)hours,
                (byte)minutes,
                (byte)realseconds
            });
        }