Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main/button_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ typedef enum {
BTN_SETTINGS_DISPLAY_EXIT,
BTN_SETTINGS_DISPLAY_BRIGHTNESS,
BTN_SETTINGS_DISPLAY_ORIENTATION,
BTN_SETTINGS_DISPLAY_CAMERA_ROTATE,
BTN_SETTINGS_DISPLAY_THEME,
BTN_SETTINGS_XPUB_EXPORT,
BTN_SETTINGS_QR_PINSERVER,
Expand Down
7 changes: 6 additions & 1 deletion main/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "jade_tasks.h"
#include "power.h"
#include "sensitive.h"
#include "storage.h"
#include "ui.h"
#include "utils/event.h"
#include "utils/malloc_ext.h"
Expand Down Expand Up @@ -376,8 +377,12 @@ static void jade_camera_task(void* data)

typedef void (*copy_camera_image_fn_t)(
uint8_t[DISPLAY_IMAGE_HEIGHT][DISPLAY_IMAGE_WIDTH], const uint8_t[CAMERA_IMAGE_HEIGHT][CAMERA_IMAGE_WIDTH]);
// The user may have persisted an extra 180-degree rotation to correct for camera
// modules which can be physically mounted either way up (eg. on some DIY units).
// This composes with any flipped display orientation, hence the inequality.
const bool camera_rotated = storage_get_gui_flags() & GUI_FLAGS_CAMERA_ROTATED;
copy_camera_image_fn_t copy_camera_image
= gui_get_flipped_orientation() ? COPY_CAMERA_IMAGE_FLIPPED : COPY_CAMERA_IMAGE_STRAIGHT;
= (gui_get_flipped_orientation() != camera_rotated) ? COPY_CAMERA_IMAGE_FLIPPED : COPY_CAMERA_IMAGE_STRAIGHT;

camera_task_config_t* const camera_config = (camera_task_config_t*)data;
JADE_ASSERT(camera_config->fn_process);
Expand Down
18 changes: 18 additions & 0 deletions main/process/dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,16 @@ static void handle_flip_orientation(void)
}
}

#if defined(CONFIG_HAS_CAMERA) && !defined(CONFIG_BOARD_TYPE_JADE_ANY)
static void handle_camera_rotate(void)
{
// Toggle the extra 180-degree camera image rotation - takes effect
// next time the camera is used
const uint8_t gui_flags = storage_get_gui_flags();
storage_set_gui_flags(gui_flags ^ GUI_FLAGS_CAMERA_ROTATED);
}
#endif

#ifdef CONFIG_HAS_CAMERA
static void handle_pinserver_scan(void)
{
Expand Down Expand Up @@ -2302,6 +2312,14 @@ static void handle_settings(const bool startup_menu)
handle_flip_orientation();
break;

#if defined(CONFIG_HAS_CAMERA) && !defined(CONFIG_BOARD_TYPE_JADE_ANY)
case BTN_SETTINGS_DISPLAY_CAMERA_ROTATE:
handle_camera_rotate();
// remake parent screen to update the menu item label
act = make_display_settings_activity();
break;
#endif

case BTN_SETTINGS_DISPLAY_THEME:
handle_display_theme();
// remake parent screen to update colours
Expand Down
1 change: 1 addition & 0 deletions main/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define BLE_ENABLED 0x1

#define GUI_FLAGS_THEMES_MASK 0x7
#define GUI_FLAGS_CAMERA_ROTATED 0x20
#define GUI_FLAGS_FLIP_ORIENTATION 0x40
#define GUI_FLAGS_USE_WHEEL_CLICK 0x80

Expand Down
14 changes: 14 additions & 0 deletions main/ui/dashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../button_events.h"
#include "../display.h"
#include "../jade_assert.h"
#include "../storage.h"
#include "../ui.h"
#include "process.h"
#include "utils/malloc_ext.h"
Expand Down Expand Up @@ -392,13 +393,23 @@ gui_activity_t* make_display_settings_activity(void)
btn_data_t hdrbtns[] = { { .txt = "=", .font = JADE_SYMBOLS_16x16_FONT, .ev_id = BTN_SETTINGS_DISPLAY_EXIT },
{ .txt = NULL, .font = GUI_DEFAULT_FONT, .ev_id = GUI_BUTTON_EVENT_NONE } };

#if defined(CONFIG_HAS_CAMERA) && !defined(CONFIG_BOARD_TYPE_JADE_ANY)
// The label doubles as the state indicator - shows 'Camera Rotated' while
// the extra 180-degree camera rotation is active
const char* const camera_btn_label
= (storage_get_gui_flags() & GUI_FLAGS_CAMERA_ROTATED) ? "Camera Rotated" : "Rotate Camera";
#endif

// NOTE: Only boards listed here have brightness controls
// NOTE: Jade v1.1's do not support Flip Orientation because of issues with screen offsets
#if defined(CONFIG_BOARD_TYPE_JADE_V2_ANY) || defined(CONFIG_BOARD_TYPE_WS_TOUCH_LCD2) \
|| defined(CONFIG_BOARD_TYPE_TTGO_TDISPLAY) || defined(CONFIG_BOARD_TYPE_M5_STICKC_PLUS_2)
btn_data_t menubtns[]
= { { .txt = "Display Brightness", .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_BRIGHTNESS },
{ .txt = "Flip Orientation", .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_ORIENTATION },
#if defined(CONFIG_HAS_CAMERA) && !defined(CONFIG_BOARD_TYPE_JADE_ANY)
{ .txt = camera_btn_label, .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_CAMERA_ROTATE },
#endif
{ .txt = "Theme", .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_THEME } };
#elif defined(CONFIG_BOARD_TYPE_JADE_V1_1)
btn_data_t menubtns[]
Expand All @@ -409,6 +420,9 @@ gui_activity_t* make_display_settings_activity(void)
#else // DIY units
btn_data_t menubtns[]
= { { .txt = "Flip Orientation", .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_ORIENTATION },
#if defined(CONFIG_HAS_CAMERA)
{ .txt = camera_btn_label, .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_CAMERA_ROTATE },
#endif
{ .txt = "Theme", .font = GUI_DEFAULT_FONT, .ev_id = BTN_SETTINGS_DISPLAY_THEME } };
#endif

Expand Down