@@ -196,19 +196,6 @@ class Camera
}
}
await Task . Delay ( 5 ) ;
{
var ret = await UDPClientPool . WriteAddr ( this . ep , this . taskID , CameraAddr . CAMERA_POWER , 0x00000101 ) ;
if ( ! ret . IsSuccessful )
{
logger . Error ( $"Failed to write STORE_ADDR: {ret.Error}" ) ;
return new ( ret . Error ) ;
}
if ( ! ret . Value )
{
logger . Error ( "STORE_ADDR write returned false" ) ;
return new ( new Exception ( "STORE_ADDR write returned false" ) ) ;
}
}
return true ;
}
@@ -253,32 +240,44 @@ class Camera
/// <summary>
/// 批量配置I2C寄存器
/// </summary>
/// <param name="registerTable">寄存器配置表,每个元素包含3个字节: [地址高位, 地址低位, 数据 ]</param>
/// <param name="registerTable">寄存器配置表,每个元素格式为:[16位寄存器地址, 数据1, 数据2, ... ]</param>
/// <param name="customDelayMs">自定义延时时间( 毫秒) , 如果为null则使用默认延时逻辑</param>
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureRegisters ( byte [ ] [ ] registerTable , int? customDelayMs = null )
public async ValueTask < Result < bool > > ConfigureRegisters ( UInt16 [ ] [ ] registerTable , int? customDelayMs = null )
{
var i2c = new Peripherals . I2cClient . I2c ( this . address , this . port , this . taskID , this . timeout ) ;
foreach ( var cmd in registerTable )
{
if ( cmd . Length ! = 3 )
if ( cmd . Length < 2 )
{
logger . Error ( $"Invalid register command length: {cmd.Length}, expected 3 bytes " ) ;
return new ( new ArgumentException ( $"Invalid register command length: {cmd.Length}, expected 3 byte s" ) ) ;
logger . Error ( $"Invalid register command length: {cmd.Length}, expected at least 2 elements (address + data) " ) ;
return new ( new ArgumentException ( $"Invalid register command length: {cmd.Length}, expected at least 2 element s" ) ) ;
}
var ret = await i2c . WriteData ( CAM_I2C_ADDR , cmd , CAM_PROTO ) ;
// 将16位地址和数据转换为字节数组
var i2cData = new byte [ cmd . Length + 1 ] ; // +1 because address becomes 2 bytes
var address = cmd [ 0 ] ;
i2cData [ 0 ] = ( byte ) ( address > > 8 ) ; // 地址高位
i2cData [ 1 ] = ( byte ) ( address & 0xFF ) ; // 地址低位
// 复制数据部分
for ( int i = 1 ; i < cmd . Length ; i + + )
{
i2cData [ i + 1 ] = ( byte ) cmd [ i ] ;
}
var ret = await i2c . WriteData ( CAM_I2C_ADDR , i2cData , CAM_PROTO ) ;
if ( ! ret . IsSuccessful )
{
logger . Error ( $"I2C write 0x{CAM_I2C_ADDR.ToString(" X ")} failed: {BitConverter.ToString(cmd )} error: {ret.Error}" ) ;
logger . Error ( $"I2C write 0x{CAM_I2C_ADDR.ToString(" X ")} failed: Address=0x{address:X4}, Data={string.Join(" , ", cmd.Skip(1).Select(x => $" 0 x { x : X2 } ") )} error: {ret.Error}" ) ;
return new ( ret . Error ) ;
}
if ( ! ret . Value )
{
logger . Error ( $"I2C write 0x{CAM_I2C_ADDR.ToString(" X ")} returned false: {BitConverter.ToString(cmd )}" ) ;
logger . Error ( $"I2C write 0x{CAM_I2C_ADDR.ToString(" X ")} returned false: Address=0x{address:X4}, Data={string.Join(" , ", cmd.Skip(1).Select(x => $" 0 x { x : X2 } ") )}" ) ;
return false ;
}
@@ -290,7 +289,7 @@ class Camera
else
{
// 使用默认延时逻辑
if ( cmd [ 0 ] = = 0x30 & & cmd [ 1 ] = = 0x08 & & cmd [ 2 ] = = 0x82 )
if ( address = = 0x3008 & & cmd . Length > = 2 & & cmd [ 1 ] = = 0x82 )
{
// 复位命令, 等待5MS
await Task . Delay ( 5 ) ;
@@ -376,39 +375,39 @@ class Camera
}
// 2. 配置I2C寄存器
var resolutionRegisters = new byte [ ] [ ]
var resolutionRegisters = new UInt16 [ ] [ ]
{
// H_OFFSET/V_OFFSET
new byte [ ] { 0x38 , 0x10 , unchecked ( ( byte ) ( ( hOffset > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x11 , unchecked ( ( byte ) ( hOffset & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x12 , unchecked ( ( byte ) ( ( vOffset > > 8 ) & 0xFF ) ) } ,
[0x3810, unchecked((byte)((hOffset >> 8) & 0xFF))] ,
[0x3811, unchecked((byte)(hOffset & 0xFF))] ,
[0x3812, unchecked((byte)((vOffset >> 8) & 0xFF))] ,
// H_START/V_START
new byte [ ] { 0x38 , 0x00 , unchecked ( ( byte ) ( ( hStart > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x01 , unchecked ( ( byte ) ( hStart & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x02 , unchecked ( ( byte ) ( ( vStart > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x03 , unchecked ( ( byte ) ( vStart & 0xFF ) ) } ,
[0x3800, unchecked((byte)((hStart >> 8) & 0xFF))] ,
[0x3801, unchecked((byte)(hStart & 0xFF))] ,
[0x3802, unchecked((byte)((vStart >> 8) & 0xFF))] ,
[0x3803, unchecked((byte)(vStart & 0xFF))] ,
// H_END/V_END
new byte [ ] { 0x38 , 0x04 , unchecked ( ( byte ) ( ( hEnd > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x05 , unchecked ( ( byte ) ( hEnd & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x06 , unchecked ( ( byte ) ( ( vEnd > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x07 , unchecked ( ( byte ) ( vEnd & 0xFF ) ) } ,
[0x3804, unchecked((byte)((hEnd >> 8) & 0xFF))] ,
[0x3805, unchecked((byte)(hEnd & 0xFF))] ,
[0x3806, unchecked((byte)((vEnd >> 8) & 0xFF))] ,
[0x3807, unchecked((byte)(vEnd & 0xFF))] ,
// 输出像素个数
new byte [ ] { 0x38 , 0x08 , unchecked ( ( byte ) ( ( dvpHo > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x09 , unchecked ( ( byte ) ( dvpHo & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x0A , unchecked ( ( byte ) ( ( dvpVo > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x0B , unchecked ( ( byte ) ( dvpVo & 0xFF ) ) } ,
[0x3808, unchecked((byte)((dvpHo >> 8) & 0xFF))] ,
[0x3809, unchecked((byte)(dvpHo & 0xFF))] ,
[0x380A, unchecked((byte)((dvpVo >> 8) & 0xFF))] ,
[0x380B, unchecked((byte)(dvpVo & 0xFF))] ,
// 总像素
new byte [ ] { 0x38 , 0x0C , unchecked ( ( byte ) ( ( hts > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x0D , unchecked ( ( byte ) ( hts & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x0E , unchecked ( ( byte ) ( ( vts > > 8 ) & 0xFF ) ) } ,
new byte [ ] { 0x38 , 0x0F , unchecked ( ( byte ) ( vts & 0xFF ) ) } ,
[0x380C, unchecked((byte)((hts >> 8) & 0xFF))] ,
[0x380D, unchecked((byte)(hts & 0xFF))] ,
[0x380E, unchecked((byte)((vts >> 8) & 0xFF))] ,
[0x380F, unchecked((byte)(vts & 0xFF))] ,
// Timing Voffset
new byte [ ] { 0x38 , 0x13 , unchecked ( ( byte ) ( vOffset & 0xFF ) ) }
[0x3813, unchecked((byte)(vOffset & 0xFF))]
} ;
var configResult = await ConfigureRegisters ( resolutionRegisters , customDelayMs : 1 ) ;
@@ -533,9 +532,9 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > Reset ( )
{
var resetRegisters = new byte [ ] [ ]
var resetRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x30 , 0x08 , 0x82 } // 复位命令
[0x30, 0x08, 0x82] // 复位命令
} ;
return await ConfigureRegisters ( resetRegisters , customDelayMs : 5 ) ; // 复位后等待5ms
@@ -547,9 +546,9 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > Sleep ( )
{
var sleepRegisters = new byte [ ] [ ]
var sleepRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x30 , 0x08 , 0x42 } // 休眠命令
[0x3008, 0x42] // 休眠命令
} ;
return await ConfigureRegisters ( sleepRegisters ) ;
@@ -561,13 +560,13 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureBasicRegisters ( )
{
var basicRegisters = new byte [ ] [ ]
var basicRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x31 , 0x03 , 0x02 } ,
new byte [ ] { 0x30 , 0x17 , 0xff } ,
new byte [ ] { 0x30 , 0x18 , 0xff } ,
new byte [ ] { 0x30 , 0x37 , 0x13 } ,
new byte [ ] { 0x31 , 0x08 , 0x01 }
[0x3103, 0x02] ,
[0x3017, 0xff] ,
[0x3018, 0xff] ,
[0x3037, 0x13] ,
[0x3108, 0x01]
} ;
return await ConfigureRegisters ( basicRegisters ) ;
@@ -579,13 +578,13 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureSensorControl ( )
{
var sensorRegisters = new byte [ ] [ ]
var sensorRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x36 , 0x30 , 0x36 } ,
new byte [ ] { 0x36 , 0x31 , 0x0e } ,
new byte [ ] { 0x36 , 0x32 , 0xe2 } ,
new byte [ ] { 0x36 , 0x33 , 0x12 } ,
new byte [ ] { 0x36 , 0x21 , 0xe0 }
[0x3630, 0x36] ,
[0x3631, 0x0e] ,
[0x3632, 0xe2] ,
[0x3633, 0x12] ,
[0x3621, 0xe0]
} ;
return await ConfigureRegisters ( sensorRegisters ) ;
@@ -597,14 +596,14 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureAnalogControl ( )
{
var analogRegisters = new byte [ ] [ ]
var analogRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x37 , 0x04 , 0xa0 } ,
new byte [ ] { 0x37 , 0x03 , 0x5a } ,
new byte [ ] { 0x37 , 0x15 , 0x78 } ,
new byte [ ] { 0x37 , 0x17 , 0x01 } ,
new byte [ ] { 0x37 , 0x0b , 0x60 } ,
new byte [ ] { 0x37 , 0x05 , 0x1a }
[0x3704, 0xa0] ,
[0x3703, 0x5a] ,
[0x3715, 0x78] ,
[0x3717, 0x01] ,
[0x370b, 0x60] ,
[0x3705, 0x1a]
} ;
return await ConfigureRegisters ( analogRegisters ) ;
@@ -616,13 +615,13 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureClockControl ( )
{
var clockRegisters = new byte [ ] [ ]
var clockRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x39 , 0x05 , 0x02 } ,
new byte [ ] { 0x39 , 0x06 , 0x10 } ,
new byte [ ] { 0x39 , 0x01 , 0x0a } ,
new byte [ ] { 0x30 , 0x35 , 0x11 } , // 30fps
new byte [ ] { 0x30 , 0x36 , PLL_MUX } // PLL倍频
[0x3905, 0x02] ,
[0x3906, 0x10] ,
[0x3901, 0x0a] ,
[0x3035, 0x11] , // 30fps
[0x3036, PLL_MUX] // PLL倍频
} ;
return await ConfigureRegisters ( clockRegisters ) ;
@@ -634,15 +633,15 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigurePSRAMControl ( )
{
var psramRegisters = new byte [ ] [ ]
var psramRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x37 , 0x31 , 0x12 } ,
new byte [ ] { 0x36 , 0x00 , 0x08 } ,
new byte [ ] { 0x36 , 0x01 , 0x33 } ,
new byte [ ] { 0x30 , 0x2d , 0x60 } ,
new byte [ ] { 0x36 , 0x20 , 0x52 } ,
new byte [ ] { 0x37 , 0x1b , 0x20 } ,
new byte [ ] { 0x47 , 0x1c , 0x50 }
[0x3731, 0x12] ,
[0x3600, 0x08] ,
[0x3601, 0x33] ,
[0x302d, 0x60] ,
[0x3620, 0x52] ,
[0x371b, 0x20] ,
[0x471c, 0x50]
} ;
return await ConfigureRegisters ( psramRegisters ) ;
@@ -654,15 +653,15 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureDVPTiming ( )
{
var dvpRegisters = new byte [ ] [ ]
var dvpRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x3a , 0x13 , 0x43 } ,
new byte [ ] { 0x3a , 0x18 , 0x00 } ,
new byte [ ] { 0x3a , 0x19 , 0xf8 } ,
new byte [ ] { 0x36 , 0x35 , 0x13 } ,
new byte [ ] { 0x36 , 0x36 , 0x03 } ,
new byte [ ] { 0x36 , 0x34 , 0x40 } ,
new byte [ ] { 0x36 , 0x22 , 0x01 }
[0x3a13, 0x43] ,
[0x3a18, 0x00] ,
[0x3a19, 0xf8] ,
[0x3635, 0x13] ,
[0x3636, 0x03] ,
[0x3634, 0x40] ,
[0x3622, 0x01]
} ;
return await ConfigureRegisters ( dvpRegisters ) ;
@@ -674,18 +673,18 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureBaseControl ( )
{
var baseRegisters = new byte [ ] [ ]
var baseRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x3c , 0x01 , 0x34 } ,
new byte [ ] { 0x3c , 0x04 , 0x28 } ,
new byte [ ] { 0x3c , 0x05 , 0x98 } ,
new byte [ ] { 0x3c , 0x06 , 0x00 } ,
new byte [ ] { 0x3c , 0x07 , 0x08 } ,
new byte [ ] { 0x3c , 0x08 , 0x00 } ,
new byte [ ] { 0x3c , 0x09 , 0x1c } ,
new byte [ ] { 0x3c , 0x0a , 0x9c } ,
new byte [ ] { 0x3c , 0x0b , 0x40 } ,
new byte [ ] { 0x37 , 0x08 , 0x64 }
[0x3c01, 0x34] ,
[0x3c04, 0x28] ,
[0x3c05, 0x98] ,
[0x3c06, 0x00] ,
[0x3c07, 0x08] ,
[0x3c08, 0x00] ,
[0x3c09, 0x1c] ,
[0x3c0a, 0x9c] ,
[0x3c0b, 0x40] ,
[0x3708, 0x64]
} ;
return await ConfigureRegisters ( baseRegisters ) ;
@@ -697,15 +696,15 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureImageFormat ( )
{
var formatRegisters = new byte [ ] [ ]
var formatRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x40 , 0x01 , 0x02 } ,
new byte [ ] { 0x40 , 0x05 , 0x1a } ,
new byte [ ] { 0x30 , 0x00 , 0x00 } ,
new byte [ ] { 0x30 , 0x04 , 0xff } ,
new byte [ ] { 0x43 , 0x00 , 0x6F } , // RGB565:first byte:{g[2:0],b[4:0]],second byte:{r[4:0],g[5:3]}
new byte [ ] { 0x50 , 0x1f , 0x01 } , // Format: ISP RGB
new byte [ ] { 0x44 , 0x0e , 0x00 }
[0x4001, 0x02] ,
[0x4005, 0x1a] ,
[0x3000, 0x00] ,
[0x3004, 0xff] ,
[0x4300, 0x6F] , // RGB565:first byte:{g[2:0],b[4:0]],second byte:{r[4:0],g[5:3]}
[0x501f, 0x01] , // Format: ISP RGB
[0x440e, 0x00]
} ;
return await ConfigureRegisters ( formatRegisters ) ;
@@ -717,10 +716,10 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureISPControl ( )
{
var ispRegisters = new byte [ ] [ ]
var ispRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x50 , 0x00 , 0xA7 } , // ISP控制
new byte [ ] { 0x50 , 0x01 , 0xA3 } // ISP控制
[0x5000, 0xA7] , // ISP控制
[0x5001, 0xA3] // ISP控制
} ;
return await ConfigureRegisters ( ispRegisters ) ;
@@ -732,19 +731,19 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureAEC ( )
{
var aecRegisters = new byte [ ] [ ]
var aecRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x3a , 0x0f , 0x30 } , // AEC控制;stable range in high
new byte [ ] { 0x3a , 0x10 , 0x28 } , // AEC控制;stable range in low
new byte [ ] { 0x3a , 0x1b , 0x30 } , // AEC控制;stable range out high
new byte [ ] { 0x3a , 0x1e , 0x26 } , // AEC控制;stable range out low
new byte [ ] { 0x3a , 0x11 , 0x60 } , // AEC控制; fast zone high
new byte [ ] { 0x3a , 0x1f , 0x14 } , // AEC控制; fast zone low
new byte [ ] { 0x3a , 0x02 , 0x17 } , // 60Hz max exposure
new byte [ ] { 0x3a , 0x03 , 0x10 } , // 60Hz max exposure
new byte [ ] { 0x3a , 0x14 , 0x17 } , // 50Hz max exposure
new byte [ ] { 0x3a , 0x15 , 0x10 } , // 50Hz max exposure
new byte [ ] { 0x3b , 0x07 , 0x0a } // 帧曝光模式
[0x3a0f, 0x30] , // AEC控制;stable range in high
[0x3a10, 0x28] , // AEC控制;stable range in low
[0x3a1b, 0x30] , // AEC控制;stable range out high
[0x3a1e, 0x26] , // AEC控制;stable range out low
[0x3a11, 0x60] , // AEC控制; fast zone high
[0x3a1f, 0x14] , // AEC控制; fast zone low
[0x3a02, 0x17] , // 60Hz max exposure
[0x3a03, 0x10] , // 60Hz max exposure
[0x3a14, 0x17] , // 50Hz max exposure
[0x3a15, 0x10] , // 50Hz max exposure
[0x3b07, 0x0a] // 帧曝光模式
} ;
return await ConfigureRegisters ( aecRegisters ) ;
@@ -756,29 +755,29 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureLENC ( )
{
var lencRegisters = new byte [ ] [ ]
var lencRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x58 , 0x00 , 0x23 } , new byte [ ] { 0x58 , 0x 01, 0x14 } , new byte [ ] { 0x58 , 0x 02, 0x0f } ,
new byte [ ] { 0x58 , 0x03 , 0x0f } , new byte [ ] { 0x58 , 0x 04, 0x12 } , new byte [ ] { 0x58 , 0x 05, 0x26 } ,
new byte [ ] { 0x58 , 0x06 , 0x0c } , new byte [ ] { 0x58 , 0x 07, 0x08 } , new byte [ ] { 0x58 , 0x 08, 0x05 } ,
new byte [ ] { 0x58 , 0x09 , 0x05 } , new byte [ ] { 0x58 , 0x 0a, 0x08 } , new byte [ ] { 0x58 , 0x 0b, 0x0d } ,
new byte [ ] { 0x58 , 0x0c , 0x08 } , new byte [ ] { 0x58 , 0x 0d, 0x03 } , new byte [ ] { 0x58 , 0x 0e, 0x00 } ,
new byte [ ] { 0x58 , 0x0f , 0x00 } , new byte [ ] { 0x58 , 0x 10, 0x03 } , new byte [ ] { 0x58 , 0x 11, 0x09 } ,
new byte [ ] { 0x58 , 0x12 , 0x07 } , new byte [ ] { 0x58 , 0x 13, 0x03 } , new byte [ ] { 0x58 , 0x 14, 0x00 } ,
new byte [ ] { 0x58 , 0x15 , 0x01 } , new byte [ ] { 0x58 , 0x 16, 0x03 } , new byte [ ] { 0x58 , 0x 17, 0x08 } ,
new byte [ ] { 0x58 , 0x18 , 0x0d } , new byte [ ] { 0x58 , 0x 19, 0x08 } , new byte [ ] { 0x58 , 0x 1a, 0x05 } ,
new byte [ ] { 0x58 , 0x1b , 0x06 } , new byte [ ] { 0x58 , 0x 1c, 0x08 } , new byte [ ] { 0x58 , 0x 1d, 0x0e } ,
new byte [ ] { 0x58 , 0x1e , 0x29 } , new byte [ ] { 0x58 , 0x 1f, 0x17 } , new byte [ ] { 0x58 , 0x 20, 0x11 } ,
new byte [ ] { 0x58 , 0x21 , 0x11 } , new byte [ ] { 0x58 , 0x 22, 0x15 } , new byte [ ] { 0x58 , 0x 23, 0x28 } ,
new byte [ ] { 0x58 , 0x24 , 0x46 } , new byte [ ] { 0x58 , 0x 25, 0x26 } , new byte [ ] { 0x58 , 0x 26, 0x08 } ,
new byte [ ] { 0x58 , 0x27 , 0x26 } , new byte [ ] { 0x58 , 0x 28, 0x64 } , new byte [ ] { 0x58 , 0x 29, 0x26 } ,
new byte [ ] { 0x58 , 0x2a , 0x24 } , new byte [ ] { 0x58 , 0x 2b, 0x22 } , new byte [ ] { 0x58 , 0x 2c, 0x24 } ,
new byte [ ] { 0x58 , 0x2d , 0x24 } , new byte [ ] { 0x58 , 0x 2e, 0x06 } , new byte [ ] { 0x58 , 0x 2f, 0x22 } ,
new byte [ ] { 0x58 , 0x30 , 0x40 } , new byte [ ] { 0x58 , 0x 31, 0x42 } , new byte [ ] { 0x58 , 0x 32, 0x24 } ,
new byte [ ] { 0x58 , 0x33 , 0x26 } , new byte [ ] { 0x58 , 0x 34, 0x24 } , new byte [ ] { 0x58 , 0x 35, 0x22 } ,
new byte [ ] { 0x58 , 0x36 , 0x22 } , new byte [ ] { 0x58 , 0x 37, 0x26 } , new byte [ ] { 0x58 , 0x 38, 0x44 } ,
new byte [ ] { 0x58 , 0x39 , 0x24 } , new byte [ ] { 0x58 , 0x 3a, 0x26 } , new byte [ ] { 0x58 , 0x 3b, 0x28 } ,
new byte [ ] { 0x58 , 0x3c , 0x42 } , new byte [ ] { 0x58 , 0x 3d, 0xce }
[0x5800, 0x23] , [ 0x58 01, 0x14 ] , [ 0x58 02, 0x0f ] ,
[0x5803, 0x0f] , [ 0x58 04, 0x12 ] , [ 0x58 05, 0x26 ] ,
[0x5806, 0x0c] , [ 0x58 07, 0x08 ] , [ 0x58 08, 0x05 ] ,
[0x5809, 0x05] , [ 0x58 0a, 0x08 ] , [ 0x58 0b, 0x0d ] ,
[0x580c, 0x08] , [ 0x58 0d, 0x03 ] , [ 0x58 0e, 0x00 ] ,
[0x580f, 0x00] , [ 0x58 10, 0x03 ] , [ 0x58 11, 0x09 ] ,
[0x5812, 0x07] , [ 0x58 13, 0x03 ] , [ 0x58 14, 0x00 ] ,
[0x5815, 0x01] , [ 0x58 16, 0x03 ] , [ 0x58 17, 0x08 ] ,
[0x5818, 0x0d] , [ 0x58 19, 0x08 ] , [ 0x58 1a, 0x05 ] ,
[0x581b, 0x06] , [ 0x58 1c, 0x08 ] , [ 0x58 1d, 0x0e ] ,
[0x581e, 0x29] , [ 0x58 1f, 0x17 ] , [ 0x58 20, 0x11 ] ,
[0x5821, 0x11] , [ 0x58 22, 0x15 ] , [ 0x58 23, 0x28 ] ,
[0x5824, 0x46] , [ 0x58 25, 0x26 ] , [ 0x58 26, 0x08 ] ,
[0x5827, 0x26] , [ 0x58 28, 0x64 ] , [ 0x58 29, 0x26 ] ,
[0x582a, 0x24] , [ 0x58 2b, 0x22 ] , [ 0x58 2c, 0x24 ] ,
[0x582d, 0x24] , [ 0x58 2e, 0x06 ] , [ 0x58 2f, 0x22 ] ,
[0x5830, 0x40] , [ 0x58 31, 0x42 ] , [ 0x58 32, 0x24 ] ,
[0x5833, 0x26] , [ 0x58 34, 0x24 ] , [ 0x58 35, 0x22 ] ,
[0x5836, 0x22] , [ 0x58 37, 0x26 ] , [ 0x58 38, 0x44 ] ,
[0x5839, 0x24] , [ 0x58 3a, 0x26 ] , [ 0x58 3b, 0x28 ] ,
[0x583c, 0x42] , [ 0x58 3d, 0xce ]
} ;
return await ConfigureRegisters ( lencRegisters ) ;
@@ -790,19 +789,19 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureAWB ( )
{
var awbRegisters = new byte [ ] [ ]
var awbRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x51 , 0x80 , 0xff } , new byte [ ] { 0x51 , 0x 81, 0xf2 } , new byte [ ] { 0x51 , 0x 82, 0x00 } ,
new byte [ ] { 0x51 , 0x83 , 0x14 } , new byte [ ] { 0x51 , 0x 84, 0x25 } , new byte [ ] { 0x51 , 0x 85, 0x24 } ,
new byte [ ] { 0x51 , 0x86 , 0x09 } , new byte [ ] { 0x51 , 0x 87, 0x09 } , new byte [ ] { 0x51 , 0x 88, 0x09 } ,
new byte [ ] { 0x51 , 0x89 , 0x75 } , new byte [ ] { 0x51 , 0x 8a, 0x54 } , new byte [ ] { 0x51 , 0x 8b, 0xe0 } ,
new byte [ ] { 0x51 , 0x8c , 0xb2 } , new byte [ ] { 0x51 , 0x 8d, 0x42 } , new byte [ ] { 0x51 , 0x 8e, 0x3d } ,
new byte [ ] { 0x51 , 0x8f , 0x56 } , new byte [ ] { 0x51 , 0x 90, 0x46 } , new byte [ ] { 0x51 , 0x 91, 0xf8 } ,
new byte [ ] { 0x51 , 0x92 , 0x04 } , new byte [ ] { 0x51 , 0x 93, 0x70 } , new byte [ ] { 0x51 , 0x 94, 0xf0 } ,
new byte [ ] { 0x51 , 0x95 , 0xf0 } , new byte [ ] { 0x51 , 0x 96, 0x03 } , new byte [ ] { 0x51 , 0x 97, 0x01 } ,
new byte [ ] { 0x51 , 0x98 , 0x04 } , new byte [ ] { 0x51 , 0x 99, 0x12 } , new byte [ ] { 0x51 , 0x 9a, 0x04 } ,
new byte [ ] { 0x51 , 0x9b , 0x00 } , new byte [ ] { 0x51 , 0x 9c, 0x06 } , new byte [ ] { 0x51 , 0x 9d, 0x82 } ,
new byte [ ] { 0x51 , 0x9e , 0x38 }
[0x5180, 0xff] , [ 0x51 81, 0xf2 ] , [ 0x51 82, 0x00 ] ,
[0x5183, 0x14] , [ 0x51 84, 0x25 ] , [ 0x51 85, 0x24 ] ,
[0x5186, 0x09] , [ 0x51 87, 0x09 ] , [ 0x51 88, 0x09 ] ,
[0x5189, 0x75] , [ 0x51 8a, 0x54 ] , [ 0x51 8b, 0xe0 ] ,
[0x518c, 0xb2] , [ 0x51 8d, 0x42 ] , [ 0x51 8e, 0x3d ] ,
[0x518f, 0x56] , [ 0x51 90, 0x46 ] , [ 0x51 91, 0xf8 ] ,
[0x5192, 0x04] , [ 0x51 93, 0x70 ] , [ 0x51 94, 0xf0 ] ,
[0x5195, 0xf0] , [ 0x51 96, 0x03 ] , [ 0x51 97, 0x01 ] ,
[0x5198, 0x04] , [ 0x51 99, 0x12 ] , [ 0x51 9a, 0x04 ] ,
[0x519b, 0x00] , [ 0x51 9c, 0x06 ] , [ 0x51 9d, 0x82 ] ,
[0x519e, 0x38]
} ;
return await ConfigureRegisters ( awbRegisters , customDelayMs : 2 ) ;
@@ -814,14 +813,14 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureGamma ( )
{
var gammaRegisters = new byte [ ] [ ]
var gammaRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x54 , 0x80 , 0x01 } , new byte [ ] { 0x54 , 0x 81, 0x08 } , new byte [ ] { 0x54 , 0x 82, 0x14 } ,
new byte [ ] { 0x54 , 0x83 , 0x28 } , new byte [ ] { 0x54 , 0x 84, 0x51 } , new byte [ ] { 0x54 , 0x 85, 0x65 } ,
new byte [ ] { 0x54 , 0x86 , 0x71 } , new byte [ ] { 0x54 , 0x 87, 0x7d } , new byte [ ] { 0x54 , 0x 88, 0x87 } ,
new byte [ ] { 0x54 , 0x89 , 0x91 } , new byte [ ] { 0x54 , 0x 8a, 0x9a } , new byte [ ] { 0x54 , 0x 8b, 0xaa } ,
new byte [ ] { 0x54 , 0x8c , 0xb8 } , new byte [ ] { 0x54 , 0x 8d, 0xcd } , new byte [ ] { 0x54 , 0x 8e, 0xdd } ,
new byte [ ] { 0x54 , 0x8f , 0xea } , new byte [ ] { 0x54 , 0x 90, 0x1d }
[0x5480, 0x01] , [ 0x54 81, 0x08 ] , [ 0x54 82, 0x14 ] ,
[0x5483, 0x28] , [ 0x54 84, 0x51 ] , [ 0x54 85, 0x65 ] ,
[0x5486, 0x71] , [ 0x54 87, 0x7d ] , [ 0x54 88, 0x87 ] ,
[0x5489, 0x91] , [ 0x54 8a, 0x9a ] , [ 0x54 8b, 0xaa ] ,
[0x548c, 0xb8] , [ 0x54 8d, 0xcd ] , [ 0x54 8e, 0xdd ] ,
[0x548f, 0xea] , [ 0x54 90, 0x1d ]
} ;
return await ConfigureRegisters ( gammaRegisters ) ;
@@ -834,12 +833,12 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureCMX ( )
{
var cmxRegisters = new byte [ ] [ ]
var cmxRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x53 , 0x81 , 0x1e } , new byte [ ] { 0x53 , 0x 82, 0x5b } , new byte [ ] { 0x53 , 0x 83, 0x08 } ,
new byte [ ] { 0x53 , 0x84 , 0x0a } , new byte [ ] { 0x53 , 0x 85, 0x7e } , new byte [ ] { 0x53 , 0x 86, 0x88 } ,
new byte [ ] { 0x53 , 0x87 , 0x7c } , new byte [ ] { 0x53 , 0x 88, 0x6c } , new byte [ ] { 0x53 , 0x 89, 0x10 } ,
new byte [ ] { 0x53 , 0x8a , 0x01 } , new byte [ ] { 0x53 , 0x 8b, 0x98 }
[0x5381, 0x1e] , [ 0x53 82, 0x5b ] , [ 0x53 83, 0x08 ] ,
[0x5384, 0x0a] , [ 0x53 85, 0x7e ] , [ 0x53 86, 0x88 ] ,
[0x5387, 0x7c] , [ 0x53 88, 0x6c ] , [ 0x53 89, 0x10 ] ,
[0x538a, 0x01] , [ 0x53 8b, 0x98 ]
} ;
return await ConfigureRegisters ( cmxRegisters ) ;
@@ -851,11 +850,11 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureSDE ( )
{
var sdeRegisters = new byte [ ] [ ]
var sdeRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x55 , 0x80 , 0x06 } , new byte [ ] { 0x55 , 0x 83, 0x40 } , new byte [ ] { 0x55 , 0x 84, 0x10 } ,
new byte [ ] { 0x55 , 0x89 , 0x10 } , new byte [ ] { 0x55 , 0x 8a, 0x00 } , new byte [ ] { 0x55 , 0x 8b, 0xf8 } ,
new byte [ ] { 0x50 , 0x1d , 0x40 }
[0x5580, 0x06] , [ 0x55 83, 0x40 ] , [ 0x55 84, 0x10 ] ,
[0x5589, 0x10] , [ 0x55 8a, 0x00 ] , [ 0x55 8b, 0xf8 ] ,
[0x501d, 0x40]
} ;
return await ConfigureRegisters ( sdeRegisters ) ;
@@ -867,13 +866,13 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureCIP ( )
{
var cipRegisters = new byte [ ] [ ]
var cipRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x53 , 0x00 , 0x08 } , new byte [ ] { 0x53 , 0x 01, 0x30 } , new byte [ ] { 0x53 , 0x 02, 0x10 } ,
new byte [ ] { 0x53 , 0x03 , 0x00 } , new byte [ ] { 0x53 , 0x 04, 0x08 } , new byte [ ] { 0x53 , 0x 05, 0x30 } ,
new byte [ ] { 0x53 , 0x06 , 0x08 } , new byte [ ] { 0x53 , 0x 07, 0x16 } , new byte [ ] { 0x53 , 0x 09, 0x08 } ,
new byte [ ] { 0x53 , 0x0a , 0x30 } , new byte [ ] { 0x53 , 0x 0b, 0x04 } , new byte [ ] { 0x53 , 0x 0c, 0x06 } ,
new byte [ ] { 0x50 , 0x25 , 0x00 }
[0x5300, 0x08] , [ 0x53 01, 0x30 ] , [ 0x53 02, 0x10 ] ,
[0x5303, 0x00] , [ 0x53 04, 0x08 ] , [ 0x53 05, 0x30 ] ,
[0x5306, 0x08] , [ 0x53 07, 0x16 ] , [ 0x53 09, 0x08 ] ,
[0x530a, 0x30] , [ 0x53 0b, 0x04 ] , [ 0x53 0c, 0x06 ] ,
[0x5025, 0x00]
} ;
return await ConfigureRegisters ( cipRegisters ) ;
@@ -885,16 +884,16 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureTimingControl ( )
{
var timingRegisters = new byte [ ] [ ]
var timingRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x38 , 0x20 , 0x46 } , // vflip
new byte [ ] { 0x38 , 0x21 , 0x01 } , // mirror
new byte [ ] { 0x38 , 0x14 , 0x31 } , // timing X inc
new byte [ ] { 0x38 , 0x15 , 0x31 } , // timing Y inc
new byte [ ] { 0x36 , 0x18 , 0x00 } ,
new byte [ ] { 0x36 , 0x12 , 0x29 } ,
new byte [ ] { 0x37 , 0x09 , 0x52 } ,
new byte [ ] { 0x37 , 0x0c , 0x03 }
[0x3820, 0x46] , // vflip
[0x3821, 0x01] , // mirror
[0x3814, 0x31] , // timing X inc
[0x3815, 0x31] , // timing Y inc
[0x3618, 0x00] ,
[0x3612, 0x29] ,
[0x3709, 0x52] ,
[0x370c, 0x03]
} ;
return await ConfigureRegisters ( timingRegisters ) ;
@@ -906,22 +905,22 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > ConfigureTestAndFlash ( )
{
var testRegisters = new byte [ ] [ ]
var testRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x40 , 0x04 , 0x02 } , // BLC(背光) 2 lines
new byte [ ] { 0x47 , 0x13 , 0x03 } , // JPEG mode 3
new byte [ ] { 0x44 , 0x07 , 0x04 } , // 量化标度
new byte [ ] { 0x46 , 0x0c , 0x20 } ,
new byte [ ] { 0x48 , 0x37 , 0x22 } , // DVP CLK divider
new byte [ ] { 0x38 , 0x24 , 0x02 } , // DVP CLK divider
[0x4004, 0x02] , // BLC(背光) 2 lines
[0x4713, 0x03] , // JPEG mode 3
[0x4407, 0x04] , // 量化标度
[0x460c, 0x20] ,
[0x4837, 0x22] , // DVP CLK divider
[0x3824, 0x02] , // DVP CLK divider
// 彩条测试禁用
new byte [ ] { 0x50 , 0x3d , 0x00 } ,
new byte [ ] { 0x47 , 0x41 , 0x00 } ,
[0x503d, 0x00] ,
[0x4741, 0x00] ,
// 闪光灯配置
new byte [ ] { 0x30 , 0x16 , 0x02 } ,
new byte [ ] { 0x30 , 0x1c , 0x02 } ,
new byte [ ] { 0x30 , 0x19 , 0x02 } , // 开启闪光灯
new byte [ ] { 0x30 , 0x19 , 0x00 } // 关闭闪光灯
[0x3016, 0x02] ,
[0x301c, 0x02] ,
[0x3019, 0x02] , // 开启闪光灯
[0x3019, 0x00] // 关闭闪光灯
} ;
return await ConfigureRegisters ( testRegisters ) ;
@@ -933,11 +932,396 @@ class Camera
/// <returns>配置结果</returns>
public async ValueTask < Result < bool > > StartStreaming ( )
{
var startRegisters = new byte [ ] [ ]
var startRegisters = new UInt16 [ ] [ ]
{
new byte [ ] { 0x30 , 0x08 , 0x02 } // 开始流
[0x3008, 0x02] // 开始流
} ;
return await ConfigureRegisters ( startRegisters ) ;
}
#region 自 动 对 焦 功 能
/// <summary>
/// OV5640 自动对焦固件数据
/// </summary>
private static readonly UInt16 [ ] OV5640_AF_FIRMWARE =
[
0x02, 0x0d, 0xf3, 0x02, 0x0a, 0x5f, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0x31, 0x30, 0x01,
0x03, 0x02, 0x03, 0x09, 0x30, 0x02, 0x03, 0x02, 0x03, 0x09, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0xbb,
0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x45, 0x75, 0x1e, 0x20,
0xd2, 0x34, 0x12, 0x0c, 0x0c, 0x78, 0x9c, 0x12, 0x0b, 0xd2, 0x78, 0xa8, 0xa6, 0x14, 0x08, 0xa6,
0x15, 0x78, 0xb3, 0xa6, 0x09, 0x18, 0x76, 0x01, 0x78, 0x4c, 0xa6, 0x0a, 0x08, 0xa6, 0x0b, 0x78,
0x6c, 0xa6, 0x14, 0x08, 0xa6, 0x15, 0x78, 0xb3, 0xe6, 0x78, 0x8c, 0xf6, 0x75, 0x1f, 0x01, 0x78,
0xbb, 0xe6, 0x78, 0xb8, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, 0xbd, 0xe6, 0x78, 0xba,
0xf6, 0x22, 0x79, 0xb8, 0xe7, 0xd3, 0x78, 0xbb, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08,
0xc3, 0x79, 0xbb, 0xe7, 0x78, 0xb8, 0x96, 0xff, 0x78, 0xa6, 0x76, 0x00, 0x08, 0xa6, 0x07, 0x79,
0xb9, 0xe7, 0xd3, 0x78, 0xbc, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0xbc,
0xe7, 0x78, 0xb9, 0x96, 0xff, 0x12, 0x0c, 0x13, 0x79, 0xba, 0xe7, 0xd3, 0x78, 0xbd, 0x96, 0x40,
0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0xbd, 0xe7, 0x78, 0xba, 0x96, 0xff, 0x12, 0x0c,
0x13, 0x78, 0xb2, 0xe6, 0x25, 0xe0, 0x24, 0x4c, 0xf8, 0xa6, 0x0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 0xd3, 0x78, 0xb3, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0xb3, 0xe7,
0x78, 0xb4, 0x96, 0xff, 0x78, 0xb7, 0xa6, 0x07, 0xe5, 0x1f, 0x64, 0x02, 0x60, 0x03, 0x02, 0x02,
0xef, 0x90, 0x30, 0x24, 0x74, 0x0f, 0xf0, 0x90, 0x0e, 0x8a, 0xe4, 0x93, 0xff, 0x18, 0xe6, 0xc3,
0x9f, 0x40, 0x03, 0x02, 0x03, 0x09, 0x90, 0x30, 0x24, 0x74, 0x0e, 0xf0, 0x78, 0xa2, 0x12, 0x0b,
0xd9, 0x12, 0x0b, 0xa2, 0x90, 0x0e, 0x87, 0x12, 0x0b, 0xb7, 0x78, 0x9e, 0x12, 0x0b, 0xe8, 0x7b,
0x04, 0x12, 0x0b, 0x90, 0xc3, 0x12, 0x07, 0x0e, 0x50, 0x6f, 0x90, 0x0e, 0x8b, 0xe4, 0x93, 0xff,
0x78, 0xb7, 0xe6, 0x9f, 0x40, 0x07, 0x90, 0x30, 0x24, 0x74, 0x0a, 0x80, 0x16, 0x90, 0x0e, 0x89,
0xe4, 0x93, 0xff, 0xd3, 0x78, 0xa7, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x09, 0x90, 0x30,
0x24, 0x74, 0x0b, 0xf0, 0x75, 0x1f, 0x05, 0x78, 0xae, 0x12, 0x0b, 0xd9, 0x12, 0x0b, 0xa2, 0x90,
0x0e, 0x88, 0x12, 0x0b, 0xb7, 0x78, 0xa8, 0x12, 0x0b, 0xe8, 0x7b, 0x40, 0x12, 0x0b, 0x90, 0xd3,
0x12, 0x07, 0x0e, 0x40, 0x24, 0x90, 0x30, 0x24, 0x74, 0x0c, 0xf0, 0x75, 0x1f, 0x05, 0x22, 0x90,
0x30, 0x24, 0x74, 0x01, 0xf0, 0xe5, 0x1f, 0xb4, 0x05, 0x0f, 0xd2, 0x01, 0xc2, 0x02, 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5, 0x3c, 0x90, 0x30, 0x28, 0xf0, 0x75,
0x1e, 0x10, 0xd2, 0x34, 0x22, 0xe5, 0x49, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xba, 0xf6, 0x90, 0x0e,
0x85, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, 0xba,
0xe6, 0x25, 0xe0, 0x24, 0x4c, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0e, 0xc3, 0xd3,
0x78, 0xb5, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xba, 0xe6, 0x78, 0xb7, 0xf6, 0x78, 0xb4,
0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x85, 0xe4, 0x93, 0x12, 0x0e, 0xc3, 0xc3, 0x78, 0xc0,
0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xba, 0xe6, 0x78, 0xb8, 0xf6, 0x78, 0xbf, 0xa6, 0x06,
0x08, 0xa6, 0x07, 0x78, 0xb4, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc0, 0x96, 0xff, 0xee, 0x18,
0x96, 0x78, 0xc1, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8e, 0xe4, 0x18, 0x12, 0x0e, 0xa1, 0x40,
0x02, 0xd2, 0x36, 0x78, 0xba, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, 0x4a,
0xe6, 0xc3, 0x78, 0xbe, 0x12, 0x0e, 0x97, 0x40, 0x05, 0x12, 0x0e, 0x92, 0x40, 0x39, 0x12, 0x0e,
0xba, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbb, 0xa6, 0x07, 0x78, 0xb7, 0xe6,
0x24, 0x03, 0x78, 0xbd, 0xf6, 0x78, 0xb7, 0xe6, 0x24, 0xfd, 0x78, 0xbe, 0xf6, 0x12, 0x0e, 0xba,
0x40, 0x06, 0x78, 0xbe, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbd, 0xe6, 0xff, 0x78, 0xbc, 0xa6, 0x07,
0x75, 0x1f, 0x02, 0x78, 0xb6, 0x76, 0x01, 0x02, 0x05, 0x59, 0xe5, 0x1f, 0x64, 0x02, 0x60, 0x03,
0x02, 0x05, 0x39, 0x78, 0xbc, 0xe6, 0xff, 0xc3, 0x78, 0xbe, 0x12, 0x0e, 0x98, 0x40, 0x08, 0x12,
0x0e, 0x92, 0x50, 0x03, 0x02, 0x05, 0x37, 0x12, 0x0e, 0xba, 0x40, 0x04, 0x7f, 0xff, 0x80, 0x02,
0x7f, 0x01, 0x78, 0xbb, 0xa6, 0x07, 0x78, 0xb7, 0xe6, 0x04, 0x78, 0xbd, 0xf6, 0x78, 0xb7, 0xe6,
0x14, 0x78, 0xbe, 0xf6, 0x18, 0x12, 0x0e, 0xbc, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x00,
0x78, 0xbd, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, 0x80,
0x02, 0x7f, 0x00, 0x78, 0xbe, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, 0x04,
0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbd, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, 0x94,
0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbe, 0xa6, 0x07, 0x12, 0x0e, 0xba,
0x40, 0x06, 0x78, 0xbe, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbd, 0xe6, 0xff, 0x78, 0xbc, 0xa6, 0x07,
0x75, 0x1f, 0x03, 0x78, 0xb6,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0x82, 0xf5, 0x82,
0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12,
0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83,
0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04,
0x78, 0x50, 0x12, 0x0c, 0x7f, 0x90, 0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3,
0x12, 0x0c, 0x38, 0x90, 0x38, 0x10, 0x12, 0x0c, 0x2c, 0x90, 0x38, 0x06, 0x78, 0x52, 0x12, 0x0c,
0x7f, 0x90, 0x38, 0x02, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0c, 0x38, 0x90,
0x38, 0x12, 0x12, 0x0c, 0x2c, 0xa3, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x50, 0x79, 0x50, 0x12, 0x0c,
0x95, 0x90, 0x38, 0x14, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x50, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02,
0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x51, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15,
0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x95, 0x90, 0x38, 0x15, 0xe0, 0xb4,
0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8,
0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x79, 0x50, 0x12, 0x0c, 0x67, 0x09, 0x12, 0x0c, 0x67,
0xaf, 0x45, 0x12, 0x0c, 0x1d, 0x7d, 0x50, 0x12, 0x05, 0x9c, 0x78, 0x58, 0xa6, 0x06, 0x08, 0xa6,
0x07, 0xaf, 0x43, 0x12, 0x0c, 0x1d, 0x7d, 0x50, 0x12, 0x05, 0x9c, 0x78, 0x54, 0xa6, 0x06, 0x08,
0xa6, 0x07, 0xaf, 0x46, 0x78, 0x52, 0x12, 0x0c, 0x1f, 0x7d, 0x3c, 0x12, 0x05, 0x9c, 0x78, 0x5a,
0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x44, 0x7e, 0x00, 0x78, 0x52, 0x12, 0x0c, 0x21, 0x7d, 0x3c,
0x12, 0x05, 0x9c, 0x78, 0x56, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xc3, 0x78, 0x59, 0xe6, 0x94, 0x08,
0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, 0x08, 0x76, 0x08, 0xc3, 0x78, 0x5b, 0xe6, 0x94,
0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, 0x08, 0x76, 0x08, 0x78, 0x58, 0x12, 0x0c,
0x54, 0xff, 0xd3, 0x78, 0x55, 0xe6, 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x58, 0xe6, 0x13,
0xfe, 0x08, 0xe6, 0x78, 0x55, 0x12, 0x0c, 0x8a, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5c,
0x12, 0x0c, 0x4c, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a,
0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x8a, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00,
0xe4, 0xfc, 0xfd, 0x78, 0x60, 0x12, 0x07, 0x4f, 0x78, 0x58, 0x12, 0x0c, 0x54, 0x78, 0x55, 0x26,
0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x64, 0x12, 0x0c, 0x4c, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18,
0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x68, 0x12, 0x07, 0x4f, 0x12, 0x0c, 0x5c, 0x78, 0x64, 0x12,
0x07, 0x42, 0xd3, 0x12, 0x07, 0x0e, 0x40, 0x08, 0x12, 0x0c, 0x5c, 0x78, 0x64, 0x12, 0x07, 0x4f,
0x78, 0x52, 0x12, 0x0c, 0x5e, 0x78, 0x68, 0x12, 0x07, 0x42, 0xd3, 0x12, 0x07, 0x0e, 0x40, 0x0a,
0x78, 0x52, 0x12, 0x0c, 0x5e, 0x78, 0x68, 0x12, 0x07, 0x4f, 0xe4, 0xfd, 0x78, 0x5f, 0x12, 0x0c,
0x77, 0x24, 0x01, 0x12, 0x0c, 0x40, 0x78, 0x63, 0x12, 0x0c, 0x77, 0x24, 0x02, 0x12, 0x0c, 0x40,
0x78, 0x67, 0x12, 0x0c, 0x77, 0x24, 0x03, 0x12, 0x0c, 0x40, 0x78, 0x6b, 0x12, 0x0c, 0x77, 0x24,
0x04, 0x12, 0x0c, 0x40, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41,
0x90, 0x30, 0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0,
0xf5, 0x40, 0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x33, 0xe5, 0x41, 0x12, 0x07, 0x67, 0x09, 0xb4, 0x03,
0x09, 0xb8, 0x04, 0x09, 0xbe, 0x05, 0x09, 0xc1, 0x06, 0x09, 0xc4, 0x07, 0x09, 0xcd, 0x08, 0x09,
0xde, 0x12, 0x09, 0xe0, 0x80, 0x09, 0xe5, 0x81, 0x0a, 0x43, 0x8f, 0x0a, 0x32, 0x90, 0x0a, 0x43,
0x91, 0x0a, 0x43, 0x92, 0x0a, 0x43, 0x93, 0x0a, 0x43, 0x94, 0x0a, 0x43, 0x98, 0x0a, 0x40, 0x9f,
0x00, 0x00, 0x0a, 0x5e, 0x12, 0x0e, 0xce, 0x22, 0x12, 0x0e, 0xce, 0xd2, 0x03, 0x22, 0xd2, 0x03,
0x22, 0xc2, 0x03, 0x22, 0xa2, 0x36, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x43, 0xc2, 0x01, 0xc2,
0x02, 0xc2, 0x03, 0x12, 0x0d, 0x14, 0x75, 0x1e, 0x70, 0xd2, 0x34, 0x02, 0x0a, 0x43, 0x80, 0x4d,
0x12, 0x0f, 0x17, 0x80, 0x5e, 0x85, 0x3d, 0x43, 0x85, 0x3e, 0x44, 0xe5, 0x45, 0xc3, 0x13, 0xff,
0xe5, 0x43, 0xc3, 0x9f, 0x50, 0x02, 0x8f, 0x43, 0xe5, 0x46, 0xc3, 0x13, 0xff, 0xe5, 0x44, 0xc3,
0x9f, 0x50, 0x02, 0x8f, 0x44, 0xe5, 0x45, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x43, 0x90, 0x0e, 0x7f,
0x12, 0x0e, 0xea, 0x40, 0x04, 0xee, 0x9f, 0xf5, 0x43, 0xe5, 0x46, 0xc3, 0x13, 0xff, 0xfd, 0xe5,
0x44, 0x90, 0x0e, 0x80, 0x12, 0x0e, 0xea, 0x40, 0x04, 0xee, 0x9f, 0xf5, 0x44, 0x12, 0x07, 0x8d,
0x80, 0x11, 0x85, 0x40, 0x46, 0x85, 0x3f, 0x45, 0x85, 0x3e, 0x44, 0x85, 0x3d, 0x43, 0x80, 0x03,
0x02, 0x07, 0x8d, 0x90, 0x30, 0x24, 0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f,
0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, 0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0,
0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30,
0xe3, 0x4c, 0x30, 0x35, 0x3e, 0x90, 0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90,
0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, 0xe0, 0xf5, 0x15, 0x30, 0x01, 0x06, 0x30, 0x32, 0x03, 0xd3,
0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x32, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
0x0a, 0x30, 0x32, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, 0x80, 0x01,
0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, 0xe5, 0x32,
0x30, 0xe1, 0x14, 0x30, 0x33, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, 0x30, 0x00,
0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, 0xa1, 0xe0,
0xf5, 0x09, 0x30, 0x30, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, 0x90, 0x3f,
0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x7d,
0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7b, 0x74, 0x01, 0x93, 0x9f, 0xff,
0xe4, 0x93,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, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff,
0x18, 0xe6, 0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0x75,
0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, 0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36,
0x15, 0x75, 0x37, 0x0d, 0x12, 0x0d, 0x85, 0x12, 0x00, 0x09, 0x12, 0x0f, 0x17, 0x12, 0x00, 0x06,
0xd2, 0x00, 0xd2, 0x33, 0xd2, 0xaf, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75,
0x37, 0x03, 0x12, 0x0d, 0x85, 0x30, 0x08, 0x09, 0xc2, 0x33, 0x12, 0x09, 0x5d, 0xc2, 0x08, 0xd2,
0x33, 0x30, 0x0b, 0x09, 0xc2, 0x35, 0x12, 0x00, 0x0e, 0xc2, 0x0b, 0xd2, 0x35, 0x30, 0x09, 0x09,
0xc2, 0x35, 0x12, 0x03, 0x0a, 0xc2, 0x09, 0xd2, 0x35, 0x30, 0x0e, 0x03, 0x12, 0x07, 0x8d, 0x30,
0x34, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, 0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0,
0xc2, 0x34, 0x80, 0xc1, 0xe4, 0xf5, 0x49, 0x90, 0x0e, 0x77, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5,
0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a,
0x12, 0x0f, 0x11, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x07,
0x32, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, 0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35,
0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30,
0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, 0x0d, 0xc5, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e,
0x72, 0x12, 0x0f, 0x05, 0x12, 0x0d, 0xc5, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12,
0x0f, 0x05, 0x02, 0x0d, 0xc5, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, 0xed, 0xc3, 0x95, 0x37, 0x50,
0x33, 0x12, 0x0f, 0x52, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, 0xf5, 0x39, 0x45, 0x38, 0x60,
0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, 0x52, 0x74, 0x03, 0x93, 0x52,
0x04, 0x12, 0x0f, 0x52, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xec,
0xf0, 0x0d, 0x80, 0xc7, 0x22, 0xa2, 0xaf, 0x92, 0x31, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, 0x90,
0x0e, 0x5d, 0x60, 0x0b, 0x12, 0x0f, 0x47, 0xe0, 0xf5, 0x2c, 0xe0, 0xf5, 0x2d, 0x80, 0x0f, 0x12,
0x0f, 0x47, 0xe5, 0x30, 0xf0, 0x90, 0x0e, 0x5f, 0x12, 0x0f, 0x47, 0xe5, 0x31, 0xf0, 0xa2, 0x31,
0x92, 0xaf, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcb, 0x02, 0x0c, 0x9f, 0x00,
0x11, 0x05, 0x25, 0x16, 0x33, 0x02, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x20, 0x20, 0x14, 0x00,
0x10, 0x00, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40,
0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30,
0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07,
0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00,
0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36,
0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x00, 0x03, 0x98, 0x00, 0xcc, 0x50,
0x3c, 0x28, 0x1e, 0x0c, 0x0c, 0x00, 0x00, 0x10, 0x0c, 0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00,
0xa5, 0x5a, 0x78, 0xbc, 0xe6, 0xd3, 0x08, 0xff, 0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98,
0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x12, 0x05, 0x8a, 0x78, 0xbf, 0xe6,
0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, 0x9c, 0x22, 0x78, 0xbb, 0xd3, 0xe6, 0x64, 0x80,
0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xd2, 0x01,
0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x34, 0xd2, 0x32, 0xd2, 0x35, 0xd2, 0x01, 0xc2,
0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x34, 0xd2, 0x32, 0x22, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe4,
0x93, 0xfe, 0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x8f, 0x3b, 0x8e, 0x3a,
0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x07, 0x32, 0x8f, 0x31, 0x8e, 0x30, 0x8d, 0x2f, 0x8c, 0x2e,
0x22, 0x93, 0xf9, 0xf8, 0x02, 0x07, 0x1f, 0x90, 0x0e, 0x81, 0x12, 0x07, 0x32, 0x8f, 0x46, 0x8e,
0x45, 0x8d, 0x44, 0x8c, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0e,
0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, 0xf0,
0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x8e,
0x83, 0x22, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x07, 0x5b
] ;
/// <summary>
/// 写入自动对焦固件到摄像头
/// </summary>
/// <returns>写入结果</returns>
private async ValueTask < Result < bool > > WriteFocusFirmware ( )
{
logger . Info ( "开始写入OV5640自动对焦固件" ) ;
var setStartAddrResult = await ConfigureRegisters ( [ [ 0x3000 , 0x80 ] ] ) ;
if ( ! setStartAddrResult . IsSuccessful ) return setStartAddrResult ;
UInt16 firmwareAddr = 0x8000 ;
var firmwareCommands = new List < UInt16 [ ] > ( ) ;
for ( int i = 0 ; i < OV5640_AF_FIRMWARE . Length ; i + + )
{
UInt16 addr = ( UInt16 ) ( firmwareAddr + i ) ;
firmwareCommands . Add ( [ addr , OV5640_AF_FIRMWARE [ i ] ] ) ;
}
var result = await ConfigureRegisters ( firmwareCommands . ToArray ( ) ) ;
if ( ! result . IsSuccessful )
{
logger . Error ( $"固件写入失败: {result.Error}" ) ;
return result ;
}
logger . Info ( $"OV5640自动对焦固件写入完成, 总共写入 {OV5640_AF_FIRMWARE.Length} 字节" ) ;
return true ;
}
/// <summary>
/// 初始化自动对焦功能
/// </summary>
/// <returns>初始化结果</returns>
public async ValueTask < Result < bool > > InitAutoFocus ( )
{
logger . Info ( "开始初始化OV5640自动对焦功能" ) ;
// 步骤1: 启动MCU
var mcuResult = await ConfigureRegisters ( [ [ 0x3000 , 0x20 ] ] ) ;
if ( ! mcuResult . IsSuccessful ) return mcuResult ;
// 步骤2: 写入自动对焦固件
var firmwareResult = await WriteFocusFirmware ( ) ;
if ( ! firmwareResult . IsSuccessful ) return firmwareResult ;
// 步骤3: 配置对焦相关寄存器
var focusRegisters = new UInt16 [ ] [ ]
{
[0x3022, 0x00] , // 清除指令寄存器
[0x3023, 0x00] , // 清除状态寄存器
[0x3024, 0x00] , // 清除参数寄存器
[0x3025, 0x00] ,
[0x3026, 0x00] ,
[0x3027, 0x00] ,
[0x3028, 0x00] ,
[0x3029, 0xFF] , // 状态寄存器
[0x3000, 0x00] , // 启动MCU
[0x3004, 0xFF] // 使能中断
} ;
var result = await ConfigureRegisters ( focusRegisters ) ;
if ( ! result . IsSuccessful ) return result ;
logger . Info ( "OV5640自动对焦功能初始化完成" ) ;
return true ;
}
/// <summary>
/// 执行一次自动对焦
/// </summary>
/// <returns>对焦结果</returns>
public async ValueTask < Result < bool > > PerformAutoFocus ( )
{
logger . Info ( "开始执行一次自动对焦" ) ;
// 步骤1: 将 0x3022 寄存器写为 0x03, 开始单点对焦过程
var focusCmdResult = await ConfigureRegisters ( [ [ 0x3022 , 0x03 ] ] ) ;
if ( ! focusCmdResult . IsSuccessful )
{
logger . Error ( $"写入对焦命令失败: {focusCmdResult.Error}" ) ;
return focusCmdResult ;
}
logger . Info ( "已发送单点对焦命令 (0x3022 = 0x03)" ) ;
// 步骤2: 读取寄存器 0x3029 的状态,如果返回值为 0x10, 代表对焦已完成
int iteration = 5000 ;
byte focusStatus = 0x00 ;
do
{
var readResult = await ReadRegister ( 0x3029 ) ;
if ( ! readResult . IsSuccessful )
{
logger . Error ( $"读取对焦状态寄存器(0x3029)失败: {readResult.Error}" ) ;
return new ( readResult . Error ) ;
}
focusStatus = readResult . Value ;
if ( focusStatus = = 0x10 )
{
logger . Info ( "对焦已完成 (0x3029 = 0x10)" ) ;
break ;
}
if ( iteration - - = = 0 )
{
logger . Error ( $"自动对焦超时,状态: 0x{focusStatus:X2}" ) ;
return new ( new Exception ( $"自动对焦超时,状态: 0x{focusStatus:X2}" ) ) ;
}
await Task . Delay ( 10 ) ;
}
while ( focusStatus ! = 0x10 ) ;
// 步骤3: 写寄存器 0x3022 为 0x06, 暂停对焦过程, 使镜头将保持在此对焦位置
var pauseResult = await ConfigureRegisters ( [ [ 0x3022 , 0x06 ] ] ) ;
if ( ! pauseResult . IsSuccessful )
{
logger . Error ( $"暂停对焦过程失败: {pauseResult.Error}" ) ;
return pauseResult ;
}
logger . Info ( $"自动对焦完成并暂停,镜头保持在对焦位置,剩余迭代次数: {iteration}" ) ;
return true ;
}
#endregion
}