Member
Joined: 02/10/2010
I think I have figured out the issue of Rovio camera brightness control and have a fix. I achieved this by digging into the source code just released, and diassemble and compare to the BIN file. After the fix, you will find the brightness control will have more remarkable effection than before. IE, when you set the brightness to highest, the brightness is much brighter than before!!!
Seems that the camera contrast is still not enough. I will try to see if any other hack improvement can be found.
Instructions (only work for Firmware v5.03....)
Invoke the following URLs one by one, then re-adjust your Rovio brightness. (replace ... with the right address)
http://.../debug.cgi?action=write_mem&address=0x0009fb9c&value=0x03a0107f
http://.../debug.cgi?action=write_mem&address=0x0009fb9d&value=0x0ae3a010
http://.../debug.cgi?action=write_mem&address=0x0009fba4&value=0x03a010af
http://.../debug.cgi?action=write_mem&address=0x0009fba5&value=0x08e3a010
http://.../debug.cgi?action=write_mem&address=0x0009fbac&value=0x03a010cf
http://.../debug.cgi?action=write_mem&address=0x0009fbad&value=0x06e3a010
http://.../debug.cgi?action=write_mem&address=0x0009fbb4&value=0x03a01000
http://.../debug.cgi?action=write_mem&address=0x0009fbb5&value=0x04e3a010
http://.../debug.cgi?action=write_mem&address=0x0009fbbc&value=0x03a01025
http://.../debug.cgi?action=write_mem&address=0x0009fbbd&value=0x02e3a010
http://.../debug.cgi?action=write_mem&address=0x0009fbc4&value=0x03a0104a
http://.../debug.cgi?action=write_mem&address=0x0009fbc5&value=0x00e3a010
http://.../debug.cgi?action=write_mem&address=0x0009fbcc&value=0x03a0107f
http://.../debug.cgi?action=write_mem&address=0x0009fbcd&value=0x55e3a010
=================
Some update on the solution:
Figured out by Chris75, another more simple command can be used instead.
IE, to set the brightness, use URL like
http://..../debug.cgi?action=write_i2c&address=0x55&value=0xnn
where nn is a hex value from 0x00 ~ 0xff.
The trend of the value is
0xff (darkness) -> 0x80 , 0x00 (middle brightness) -> 0x7f (brightest)
To set the contrast, use URL like
http://.../debug.cgi?action=write_i2c&address=0x56&value=0xnn
where nn is a hex value from 0x00~0xff. 0x00 is with the least contrast, while 0xff is with the most contrast.
[Thanks Chris75 for figouring out the write_i2c debug fucntion.]
Two other useful options to get better poor-light performance:
a) Minimum frame rate during night mode. When the light is low, the night mode will automatically reduce the frame rate by multi-sampling. The more the frame rate is reduced, the more brightness it will get.
address: 0x3b.
Bits 7: 0 - disable night mode. 1- enable night mode (default for Rovio)
Bits 6~5
00 (default for Rovio): same as normal rate (means no use of night mode at all!)
01: 1/2 of normal mode frame rate
10: 1/4 of normal mode frame rate
11: 1/8 of normal mode frame rate
It needs to disable then reenable night mode to make it effective, so two commands are requird:
http://.../debug.cgi?action=write_i2c&address=0x3b&value=0x02
http://.../debug.cgi?action=write_i2c&address=0x3b&value=0xe2 (or, 82,a2,c2,e2)
b) The Auto Gain Control has a ceiling option, from 1x to 128x. Default is just 2x, in darkness it is not enough. When using higher AGC ceiling, the brightness will be improved while in extra darkness, however the noise of the image will increase as well. Compared to option a, the pros is that it does not reduce framerate.
Address: 0x14
bit 6-4: 000, 2x; 001, 4x;....;110:128x
SO use the command:
http://.../debug.cgi?action=write_i2c&address=0x14&value=0xn8
where n = 0,1,2,....,6
Please see http://www.robocommunity.com/download/17526/RovioBrighter/ for a stand-alone web page called RovioBrighter for setting the brightness/contrast quickly, no matter what client software you are using.
Once this is incorporated in the Rovio client software, you can dump the RovioBrighter as you will. ^ ^
Gandalf
The piece of code is in dsplib.c:
void dspSetBrightnessContrast_ov7670 (int nContrast, int nBrightness, int nAdjMode)
{
/* Contrast not set */
switch (nBrightness)
{
case 0:
i2cWriteI2C (0x55, 0xFF);
break;
case 1:
i2cWriteI2C (0x55, 0xE9);
break;
case 2:
i2cWriteI2C (0x55, 0xD4);
break;
case 3:
i2cWriteI2C (0x55, 0xBF);
break;
case 4:
i2cWriteI2C (0x55, 0xAA);
break;
case 5:
i2cWriteI2C (0x55, 0x95);
break;
case 6:
i2cWriteI2C (0x55, 0x80);
break;
default:
;
}
}
By looking into the datasheet of OV7670 (the camera CMOS chip), the range of the brightness should be around 00~FF. Someone told me that it translates to signed byte, ie, -128~127. So I conclude that the original code does not set the brightness to even beyond zero.
If my finding is right, I am so confused why this was not figured out by Woewee team.
RovioBrighter - brighter your Rovio!
http://www.robocommunity.com/download/17526/RovioBrighter/