mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-02 04:39:59 -07:00
First Update
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
#include "lightmeter_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const lightmeter_on_enter_handlers[])(void*) = {
|
||||
#include "lightmeter_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const lightmeter_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "lightmeter_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const lightmeter_on_exit_handlers[])(void* context) = {
|
||||
#include "lightmeter_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers lightmeter_scene_handlers = {
|
||||
.on_enter_handlers = lightmeter_on_enter_handlers,
|
||||
.on_event_handlers = lightmeter_on_event_handlers,
|
||||
.on_exit_handlers = lightmeter_on_exit_handlers,
|
||||
.scene_num = LightMeterAppSceneNum,
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) LightMeterAppScene##id,
|
||||
typedef enum {
|
||||
#include "lightmeter_scene_config.h"
|
||||
LightMeterAppSceneNum,
|
||||
} LightMeterAppScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers lightmeter_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "lightmeter_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "lightmeter_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "lightmeter_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
@@ -1,4 +0,0 @@
|
||||
ADD_SCENE(lightmeter, main, Main)
|
||||
ADD_SCENE(lightmeter, config, Config)
|
||||
ADD_SCENE(lightmeter, help, Help)
|
||||
ADD_SCENE(lightmeter, about, About)
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "../../lightmeter.h"
|
||||
|
||||
void lightmeter_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
UNUSED(app);
|
||||
UNUSED(result);
|
||||
UNUSED(type);
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void lightmeter_scene_about_on_enter(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
furi_string_printf(temp_str, "\e#%s\n", "Information");
|
||||
|
||||
furi_string_cat_printf(temp_str, "Version: %s\n", LM_VERSION_APP);
|
||||
furi_string_cat_printf(temp_str, "Developed by: %s\n", LM_DEVELOPED);
|
||||
furi_string_cat_printf(temp_str, "Github: %s\n\n", LM_GITHUB);
|
||||
|
||||
furi_string_cat_printf(temp_str, "\e#%s\n", "Description");
|
||||
furi_string_cat_printf(
|
||||
temp_str,
|
||||
"Showing suggested camera\nsettings based on ambient\nlight or flash.\n\nInspired by a lightmeter\nproject by vpominchuk\n");
|
||||
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
0,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! \e!\n",
|
||||
false);
|
||||
widget_add_text_box_element(
|
||||
app->widget,
|
||||
0,
|
||||
2,
|
||||
128,
|
||||
14,
|
||||
AlignCenter,
|
||||
AlignBottom,
|
||||
"\e#\e! Lightmeter \e!\n",
|
||||
false);
|
||||
widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewAbout);
|
||||
}
|
||||
|
||||
bool lightmeter_scene_about_on_event(void* context, SceneManagerEvent event) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
bool consumed = false;
|
||||
UNUSED(app);
|
||||
UNUSED(event);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void lightmeter_scene_about_on_exit(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
// Clear views
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
#include "../../lightmeter.h"
|
||||
|
||||
#define TAG "Scene Config"
|
||||
|
||||
static const char* iso_numbers[] = {
|
||||
[ISO_6] = "6",
|
||||
[ISO_12] = "12",
|
||||
[ISO_25] = "25",
|
||||
[ISO_50] = "50",
|
||||
[ISO_100] = "100",
|
||||
[ISO_200] = "200",
|
||||
[ISO_400] = "400",
|
||||
[ISO_800] = "800",
|
||||
[ISO_1600] = "1600",
|
||||
[ISO_3200] = "3200",
|
||||
[ISO_6400] = "6400",
|
||||
[ISO_12800] = "12800",
|
||||
[ISO_25600] = "25600",
|
||||
[ISO_51200] = "51200",
|
||||
[ISO_102400] = "102400",
|
||||
};
|
||||
|
||||
static const char* nd_numbers[] = {
|
||||
[ND_0] = "0",
|
||||
[ND_2] = "2",
|
||||
[ND_4] = "4",
|
||||
[ND_8] = "8",
|
||||
[ND_16] = "16",
|
||||
[ND_32] = "32",
|
||||
[ND_64] = "64",
|
||||
[ND_128] = "128",
|
||||
[ND_256] = "256",
|
||||
[ND_512] = "512",
|
||||
[ND_1024] = "1024",
|
||||
[ND_2048] = "2048",
|
||||
[ND_4096] = "4096",
|
||||
};
|
||||
|
||||
static const char* diffusion_dome[] = {
|
||||
[WITHOUT_DOME] = "No",
|
||||
[WITH_DOME] = "Yes",
|
||||
};
|
||||
|
||||
static const char* backlight[] = {
|
||||
[BACKLIGHT_AUTO] = "Auto",
|
||||
[BACKLIGHT_ON] = "On",
|
||||
};
|
||||
|
||||
static const char* lux_only[] = {
|
||||
[LUX_ONLY_OFF] = "Off",
|
||||
[LUX_ONLY_ON] = "On",
|
||||
};
|
||||
|
||||
enum LightMeterSubmenuIndex {
|
||||
LightMeterSubmenuIndexISO,
|
||||
LightMeterSubmenuIndexND,
|
||||
LightMeterSubmenuIndexDome,
|
||||
LightMeterSubmenuIndexBacklight,
|
||||
LightMeterSubmenuIndexLuxMeter,
|
||||
LightMeterSubmenuIndexHelp,
|
||||
LightMeterSubmenuIndexAbout,
|
||||
};
|
||||
|
||||
static void iso_numbers_cb(VariableItem* item) {
|
||||
LightMeterApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, iso_numbers[index]);
|
||||
|
||||
LightMeterConfig* config = app->config;
|
||||
config->iso = index;
|
||||
lightmeter_app_set_config(app, config);
|
||||
}
|
||||
|
||||
static void nd_numbers_cb(VariableItem* item) {
|
||||
LightMeterApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, nd_numbers[index]);
|
||||
|
||||
LightMeterConfig* config = app->config;
|
||||
config->nd = index;
|
||||
lightmeter_app_set_config(app, config);
|
||||
}
|
||||
|
||||
static void dome_presence_cb(VariableItem* item) {
|
||||
LightMeterApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, diffusion_dome[index]);
|
||||
|
||||
LightMeterConfig* config = app->config;
|
||||
config->dome = index;
|
||||
lightmeter_app_set_config(app, config);
|
||||
}
|
||||
|
||||
static void backlight_cb(VariableItem* item) {
|
||||
LightMeterApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, backlight[index]);
|
||||
|
||||
LightMeterConfig* config = app->config;
|
||||
if(index != config->backlight) {
|
||||
if(index == BACKLIGHT_ON) {
|
||||
notification_message(
|
||||
app->notifications,
|
||||
&sequence_display_backlight_enforce_on); // force on backlight
|
||||
} else {
|
||||
notification_message(
|
||||
app->notifications,
|
||||
&sequence_display_backlight_enforce_auto); // force auto backlight
|
||||
}
|
||||
}
|
||||
config->backlight = index;
|
||||
lightmeter_app_set_config(app, config);
|
||||
}
|
||||
|
||||
static void lux_only_cb(VariableItem* item) {
|
||||
LightMeterApp* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, lux_only[index]);
|
||||
|
||||
LightMeterConfig* config = app->config;
|
||||
config->lux_only = index;
|
||||
lightmeter_app_set_config(app, config);
|
||||
}
|
||||
|
||||
static void ok_cb(void* context, uint32_t index) {
|
||||
LightMeterApp* app = context;
|
||||
UNUSED(app);
|
||||
switch(index) {
|
||||
case LightMeterSubmenuIndexHelp:
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventHelp);
|
||||
break;
|
||||
case LightMeterSubmenuIndexAbout:
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventAbout);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lightmeter_scene_config_on_enter(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
VariableItem* item;
|
||||
LightMeterConfig* config = app->config;
|
||||
|
||||
item =
|
||||
variable_item_list_add(var_item_list, "ISO", COUNT_OF(iso_numbers), iso_numbers_cb, app);
|
||||
variable_item_set_current_value_index(item, config->iso);
|
||||
variable_item_set_current_value_text(item, iso_numbers[config->iso]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "ND factor", COUNT_OF(nd_numbers), nd_numbers_cb, app);
|
||||
variable_item_set_current_value_index(item, config->nd);
|
||||
variable_item_set_current_value_text(item, nd_numbers[config->nd]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Diffusion dome", COUNT_OF(diffusion_dome), dome_presence_cb, app);
|
||||
variable_item_set_current_value_index(item, config->dome);
|
||||
variable_item_set_current_value_text(item, diffusion_dome[config->dome]);
|
||||
|
||||
item =
|
||||
variable_item_list_add(var_item_list, "Backlight", COUNT_OF(backlight), backlight_cb, app);
|
||||
variable_item_set_current_value_index(item, config->backlight);
|
||||
variable_item_set_current_value_text(item, backlight[config->backlight]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Lux meter only", COUNT_OF(lux_only), lux_only_cb, app);
|
||||
variable_item_set_current_value_index(item, config->lux_only);
|
||||
variable_item_set_current_value_text(item, lux_only[config->lux_only]);
|
||||
|
||||
item = variable_item_list_add(var_item_list, "Help and Pinout", 0, NULL, NULL);
|
||||
item = variable_item_list_add(var_item_list, "About", 0, NULL, NULL);
|
||||
|
||||
variable_item_list_set_selected_item(
|
||||
var_item_list,
|
||||
scene_manager_get_scene_state(app->scene_manager, LightMeterAppSceneConfig));
|
||||
|
||||
variable_item_list_set_enter_callback(var_item_list, ok_cb, app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewVarItemList);
|
||||
}
|
||||
|
||||
bool lightmeter_scene_config_on_event(void* context, SceneManagerEvent event) {
|
||||
LightMeterApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeTick) {
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case LightMeterAppCustomEventHelp:
|
||||
scene_manager_next_scene(app->scene_manager, LightMeterAppSceneHelp);
|
||||
consumed = true;
|
||||
break;
|
||||
case LightMeterAppCustomEventAbout:
|
||||
scene_manager_next_scene(app->scene_manager, LightMeterAppSceneAbout);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void lightmeter_scene_config_on_exit(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
variable_item_list_reset(app->var_item_list);
|
||||
main_view_set_iso(app->main_view, app->config->iso);
|
||||
main_view_set_nd(app->main_view, app->config->nd);
|
||||
main_view_set_dome(app->main_view, app->config->dome);
|
||||
main_view_set_lux_only(app->main_view, app->config->lux_only);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
#include "../../lightmeter.h"
|
||||
|
||||
void lightmeter_scene_help_on_enter(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
furi_string_printf(
|
||||
temp_str, "App works with BH1750\nambient light sensor\nconnected via I2C interface\n\n");
|
||||
furi_string_cat(temp_str, "\e#Pinout:\r\n");
|
||||
furi_string_cat(
|
||||
temp_str,
|
||||
" VCC: 3.3V\r\n"
|
||||
" GND: GND\r\n"
|
||||
" SDA: 15 [C1]\r\n"
|
||||
" SCL: 16 [C0]\r\n");
|
||||
|
||||
widget_add_text_scroll_element(app->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewHelp);
|
||||
}
|
||||
|
||||
bool lightmeter_scene_help_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
void lightmeter_scene_help_on_exit(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
widget_reset(app->widget);
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "../../lightmeter.h"
|
||||
|
||||
static void lightmeter_scene_main_on_left(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventConfig);
|
||||
}
|
||||
|
||||
void lightmeter_scene_main_on_enter(void* context) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
lightmeter_main_view_set_left_callback(app->main_view, lightmeter_scene_main_on_left, app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewMainView);
|
||||
}
|
||||
|
||||
bool lightmeter_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
LightMeterApp* app = context;
|
||||
|
||||
bool response = false;
|
||||
|
||||
switch(event.type) {
|
||||
case SceneManagerEventTypeCustom:
|
||||
if(event.event == LightMeterAppCustomEventConfig) {
|
||||
scene_manager_next_scene(app->scene_manager, LightMeterAppSceneConfig);
|
||||
response = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SceneManagerEventTypeTick:
|
||||
lightmeter_app_i2c_callback(app);
|
||||
response = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
void lightmeter_scene_main_on_exit(void* context) {
|
||||
UNUSED(context);
|
||||
}
|
||||
Reference in New Issue
Block a user