Skip to content

Commit caee24f

Browse files
committed
Added support for Frame rev8 PCBs with camera on LDO rail
Fixed extended VTS registers for manual shutter mode Improved camera test scripts for better quality
1 parent 81cac5f commit caee24f

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

source/application/lua_libraries/camera.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,18 @@ static int lua_camera_set_shutter(lua_State *L)
711711
return luaL_error(L, "shutter must be between 4 and 16383");
712712
}
713713

714+
// If shutter is longer than frame length (VTS register)
715+
if (shutter > 0x32A)
716+
{
717+
check_error(i2c_write(CAMERA, 0x380E, 0xFF, shutter >> 8).fail);
718+
check_error(i2c_write(CAMERA, 0x380F, 0xFF, shutter).fail);
719+
}
720+
else
721+
{
722+
check_error(i2c_write(CAMERA, 0x380E, 0xFF, 0x03).fail);
723+
check_error(i2c_write(CAMERA, 0x380F, 0xFF, 0x22).fail);
724+
}
725+
714726
check_error(i2c_write(CAMERA, 0x3500, 0x03, shutter >> 12).fail);
715727
check_error(i2c_write(CAMERA, 0x3501, 0xFF, shutter >> 4).fail);
716728
check_error(i2c_write(CAMERA, 0x3502, 0xF0, shutter << 4).fail);

source/application/main.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,21 @@ static void set_power_rails(bool enable)
5858
// Turn on LDO0 (1.2V rail)
5959
check_error(i2c_write(PMIC, 0x39, 0x07, 0x06).fail);
6060

61-
// Turn on SBB2 (2.7V rail) with 333mA limit
61+
// Turn on LDO1 (2.8V rail)
62+
check_error(i2c_write(PMIC, 0x3B, 0x07, 0x06).fail);
63+
64+
// Turn on SBB2 (2.95V rail) with 333mA limit
6265
check_error(i2c_write(PMIC, 0x2E, 0x37, 0x36).fail);
6366

6467
return;
6568
}
6669

67-
// Turn off SBB2 (2.7V rail) with active discharge resistor on
70+
// Turn off SBB2 (2.95V rail) with active discharge resistor on
6871
check_error(i2c_write(PMIC, 0x2E, 0x0F, 0x0C).fail);
6972

73+
// Turn off LDO1 (2.8V rail)
74+
check_error(i2c_write(PMIC, 0x3B, 0x0F, 0x0C).fail);
75+
7076
// Turn off LDO0 (1.2V rail)
7177
check_error(i2c_write(PMIC, 0x39, 0x0F, 0x0C).fail);
7278

@@ -216,12 +222,15 @@ static void hardware_setup(bool *factory_reset)
216222
// Set SBB0 to 1.0V
217223
check_error(i2c_write(PMIC, 0x29, 0x7F, 0x04).fail);
218224

219-
// Set SBB2 to 2.7V
220-
check_error(i2c_write(PMIC, 0x2D, 0x7F, 0x26).fail);
225+
// Set SBB2 to 2.95V
226+
check_error(i2c_write(PMIC, 0x2D, 0x7F, 0x2B).fail);
221227

222228
// Set LDO0 to 1.2V
223229
check_error(i2c_write(PMIC, 0x38, 0x7F, 0x10).fail);
224230

231+
// Set LDO1 to 2.8V
232+
check_error(i2c_write(PMIC, 0x3A, 0x7F, 0x50).fail);
233+
225234
// Turn/keep off FPGA before FPGA configuration
226235
set_power_rails(false);
227236

tests/test_camera_and_audio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@ async def main():
683683
local state = 'CAPTURE'
684684
local state_time = 0
685685
686+
frame.display.power_save(true)
687+
frame.camera.power_save(false)
688+
686689
frame.microphone.stop()
687690
frame.microphone.start { }
688691
@@ -716,7 +719,7 @@ async def main():
716719
end
717720
718721
if frame.time.utc() - last_autoexp_time > 0.1 then
719-
frame.camera.auto { }
722+
frame.camera.auto { analog_gain_limit=40, shutter_limit=2500 }
720723
last_autoexp_time = frame.time.utc()
721724
end
722725

tests/test_camera_fps.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ def receive_data(data):
651651

652652
image_buffer += data[1:]
653653
print(
654-
f"Received {str(len(image_buffer)-1)} bytes. FPS = {fps}. Press enter to finish ",
655-
end="\r",
654+
f"\rReceived {str(len(image_buffer)-1)} bytes. FPS = {fps}. Press enter to finish ",
655+
end="",
656656
)
657657

658658

@@ -666,6 +666,9 @@ async def main():
666666
frame.display.power_save(true)
667667
frame.camera.power_save(false)
668668
669+
-- frame.camera.set_gain(40)
670+
-- frame.camera.set_shutter(2500)
671+
669672
while true do
670673
if state == 'CAPTURE' then
671674
frame.camera.capture { quality_factor = 50 }
@@ -698,10 +701,10 @@ async def main():
698701
end
699702
700703
if frame.time.utc() - last_autoexp_time > 0.1 then
701-
local stats = frame.camera.auto { analog_gain_limit=30, shutter_limit=3200 }
702-
-- if stats ~= nil then
703-
-- print('gain = '..stats['analog_gain']..', shutter = '..stats['shutter'])
704-
-- end
704+
local stats = frame.camera.auto { analog_gain_limit=40, shutter_limit=2500 }
705+
if stats ~= nil then
706+
print('gain = '..stats['analog_gain']..', shutter = '..stats['shutter']..' ')
707+
end
705708
last_autoexp_time = frame.time.utc()
706709
end
707710
end
@@ -710,7 +713,8 @@ async def main():
710713
# Connect to bluetooth and upload file
711714
b = Bluetooth()
712715
await b.connect(
713-
print_response_handler=lambda s: print(s), data_response_handler=receive_data
716+
# print_response_handler=lambda s: print("\r" + s, end=""),
717+
data_response_handler=receive_data,
714718
)
715719

716720
print("Uploading script")

0 commit comments

Comments
 (0)