コード例 #1
0
        private static void WriteLEDDriver(I2CConfiguration i2c, uint value)
        {
            uint byte0 = (0xF0 & value) >> 4;
            uint byte1 = (0x0F & value) << 4;

            i2c.WriteByte(byte0, byte1);
        }
コード例 #2
0
        private static void WriteCameraRegister(I2CConfiguration i2c, uint reg, uint value)
        {
            uint byte0 = value & 0xFF;
            uint byte1 = (value >> 8) & 0xFF;

            i2c.WriteByte(reg, byte1);
            i2c.WriteByte(0xF0, byte0);
        }
コード例 #3
0
        private static void WriteCameraRegister(I2CConfiguration i2c, uint register, uint value)
        {
            // ATMega -> Python480 passthrough protocol
            var regLow  = register & 0xFF;
            var regHigh = (register >> 8) & 0xFF;
            var valLow  = value & 0xFF;
            var valHigh = (value >> 8) & 0xFF;

            i2c.WriteByte(0x05, regHigh);
            i2c.WriteByte(regLow, valHigh);
            i2c.WriteByte(valLow, 0x00);
        }
コード例 #4
0
        protected override IObservable <MiniscopeDataFrame> Process(IObservable <ONIManagedFrame <ushort> > source, ulong frameOffset)
        {
            // The LED brightnes and binary on/off state are linked in their firmware and so require
            // some hackuiness to get the behavior I want.
            running = true;

            // Turn on EWL
            using (var i2c = new I2CConfiguration(DeviceAddress, ID, MAX14574Address))
            {
                i2c.WriteByte(0x03, 0x03);
            }

            // Turn on LED
            using (var i2c = new I2CConfiguration(DeviceAddress, ID, ATMegaAddress))
            {
                i2c.WriteByte(1, (uint)(LEDBrightness == 0 ? 0xFF : 0x00));
            }

            return(source
                   .SkipWhile(f => (f.Sample[5] & 0x8000) == 0)
                   .Buffer(Rows)
                   .Select(block => { return new MiniscopeDataFrame(block, frameOffset, Rows, Columns); })
                   .Finally(() =>
            {
                // Turn off EWL
                using (var i2c = new I2CConfiguration(DeviceAddress, ID, MAX14574Address))
                {
                    i2c.WriteByte(0x03, 0x00);
                }

                // Turn off LED
                using (var i2c = new I2CConfiguration(DeviceAddress, ID, ATMegaAddress))
                {
                    i2c.WriteByte(1, 0xFF);
                }

                running = false;
            }));
        }
コード例 #5
0
 private static int ReadCameraRegister(I2CConfiguration i2c, uint reg)
 {
     return((int)(i2c.ReadByte(reg) << 8 | i2c.ReadByte(0xF0)));
 }