Skip to content

Commit

Permalink
Merge pull request #461 from selfcustody/cube_camera_init_fix
Browse files Browse the repository at this point in the history
Fix camera initialization for Maix Cube
  • Loading branch information
odudex authored Sep 26, 2024
2 parents fba1281 + 49c107d commit 9803f8e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ edit_uri: edit/main/docs
docs_dir: docs
site_dir: public
extra:
latest_krux: krux-v24.09.0
latest_krux: krux-v24.09.1
latest_installer: v0.0.20-alpha-2
latest_installer_rpm: krux-installer-0.0.20_alpha-2-1.x86_64.rpm
latest_installer_deb: krux-installer_0.0.20-alpha-2_amd64.deb
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

[tool.poetry]
name = "krux"
version = "24.09.0"
version = "24.09.1"
description = "Open-source signing device firmware for Bitcoin"
authors = ["Jeff S <jeffreesun@protonmail.com>"]

Expand Down
13 changes: 5 additions & 8 deletions src/krux/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ def __init__(self):
def initialize_sensor(self, grayscale=False):
"""Initializes the camera"""
self.antiglare_enabled = False
if self.cam_id in (OV7740_ID, GC2145_ID):
sensor.reset(freq=18200000)
if board.config["type"] == "cube":
# Rotate camera 180 degrees on Cube
sensor.set_hmirror(1)
sensor.set_vflip(1)
else:
sensor.reset()
sensor.reset(freq=18200000)
self.cam_id = sensor.get_id()
if board.config["type"] == "cube":
# Rotate camera 180 degrees on Cube
sensor.set_hmirror(1)
sensor.set_vflip(1)
self.mode = COLOR_MODE
if grayscale and self.cam_id != GC2145_ID:
# GC2145 does not support grayscale
Expand Down
2 changes: 1 addition & 1 deletion src/krux/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
VERSION = "24.09.0"
VERSION = "24.09.1"
SIGNER_PUBKEY = "03339e883157e45891e61ca9df4cd3bb895ef32d475b8e793559ea10a36766689b"
14 changes: 13 additions & 1 deletion tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def test_init(mocker, m5stickv):
assert isinstance(c, Camera)


def test_initialize_sensors(mocker, m5stickv):
def test_initialize_sensors(mocker, multiple_devices):
import board
import krux
from krux.camera import Camera, OV7740_ID, OV2640_ID, GC0328_ID, GC2145_ID

Expand All @@ -30,6 +31,17 @@ def test_initialize_sensors(mocker, m5stickv):
if config_method:
getattr(c, config_method).assert_called()

if board.config["type"] == "cube" or c.cam_id == OV2640_ID:
krux.camera.sensor.set_vflip.assert_called_with(1)
else:
krux.camera.sensor.set_vflip.assert_not_called()
krux.camera.sensor.set_vflip.reset_mock()

if board.config["type"] == "cube":
krux.camera.sensor.set_hmirror.assert_called_with(1)
else:
krux.camera.sensor.set_hmirror.assert_not_called()

krux.camera.sensor.reset.assert_called()
krux.camera.sensor.set_pixformat.assert_called()
assert (
Expand Down

0 comments on commit 9803f8e

Please sign in to comment.