Ver código fonte

Merge lightmeter from https://github.com/oleksiikutuzov/flipperzero-lightmeter

# Conflicts:
#	lightmeter/lightmeter.c
Willy-JL 11 meses atrás
pai
commit
dac8361971

+ 89 - 34
lightmeter/.clang-format

@@ -3,22 +3,55 @@ Language:        Cpp
 AccessModifierOffset: -4
 AlignAfterOpenBracket: AlwaysBreak
 AlignArrayOfStructures: None
-AlignConsecutiveMacros: None
-AlignConsecutiveAssignments: None
-AlignConsecutiveBitFields: None
-AlignConsecutiveDeclarations: None
+AlignConsecutiveAssignments:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveBitFields:
+  Enabled:         true
+  AcrossEmptyLines: true
+  AcrossComments:  true
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveDeclarations:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveMacros:
+  Enabled:         true
+  AcrossEmptyLines: false
+  AcrossComments:  true
+  AlignCompound:   true
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveShortCaseStatements:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCaseColons: false
 AlignEscapedNewlines: Left
 AlignOperands:   Align
-AlignTrailingComments: false
+AlignTrailingComments:
+  Kind:            Never
+  OverEmptyLines:  0
 AllowAllArgumentsOnNextLine: true
 AllowAllParametersOfDeclarationOnNextLine: false
-AllowShortEnumsOnASingleLine: true
+AllowBreakBeforeNoexceptSpecifier: Never
 AllowShortBlocksOnASingleLine: Never
 AllowShortCaseLabelsOnASingleLine: false
+AllowShortCompoundRequirementOnASingleLine: true
+AllowShortEnumsOnASingleLine: false
 AllowShortFunctionsOnASingleLine: None
-AllowShortLambdasOnASingleLine: All
 AllowShortIfStatementsOnASingleLine: WithoutElse
-AllowShortLoopsOnASingleLine: true
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
 AlwaysBreakAfterDefinitionReturnType: None
 AlwaysBreakAfterReturnType: None
 AlwaysBreakBeforeMultilineStrings: false
@@ -27,17 +60,18 @@ AttributeMacros:
   - __capability
 BinPackArguments: false
 BinPackParameters: false
+BitFieldColonSpacing: Both
 BraceWrapping:
   AfterCaseLabel:  false
   AfterClass:      false
   AfterControlStatement: Never
   AfterEnum:       false
+  AfterExternBlock: false
   AfterFunction:   false
   AfterNamespace:  false
   AfterObjCDeclaration: false
   AfterStruct:     false
   AfterUnion:      false
-  AfterExternBlock: false
   BeforeCatch:     false
   BeforeElse:      false
   BeforeLambdaBody: false
@@ -46,38 +80,35 @@ BraceWrapping:
   SplitEmptyFunction: true
   SplitEmptyRecord: true
   SplitEmptyNamespace: true
+BreakAdjacentStringLiterals: true
+BreakAfterAttributes: Leave
+BreakAfterJavaFieldAnnotations: false
+BreakArrays:     true
 BreakBeforeBinaryOperators: None
-BreakBeforeConceptDeclarations: true
+BreakBeforeConceptDeclarations: Always
 BreakBeforeBraces: Attach
-BreakBeforeInheritanceComma: false
-BreakInheritanceList: BeforeColon
+BreakBeforeInlineASMColon: OnlyMultiline
 BreakBeforeTernaryOperators: false
-BreakConstructorInitializersBeforeComma: false
 BreakConstructorInitializers: BeforeComma
-BreakAfterJavaFieldAnnotations: false
+BreakInheritanceList: BeforeColon
 BreakStringLiterals: false
 ColumnLimit:     99
 CommentPragmas:  '^ IWYU pragma:'
-QualifierAlignment: Leave
 CompactNamespaces: false
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
 Cpp11BracedListStyle: true
-DeriveLineEnding: true
 DerivePointerAlignment: false
 DisableFormat:   false
 EmptyLineAfterAccessModifier: Never
 EmptyLineBeforeAccessModifier: LogicalBlock
 ExperimentalAutoDetectBinPacking: false
-PackConstructorInitializers: BinPack
-BasedOnStyle:    ''
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-AllowAllConstructorInitializersOnNextLine: true
 FixNamespaceComments: false
 ForEachMacros:
   - foreach
   - Q_FOREACH
   - BOOST_FOREACH
+  - M_EACH
 IfMacros:
   - KJ_IF_MAYBE
 IncludeBlocks:   Preserve
@@ -97,19 +128,30 @@ IncludeCategories:
 IncludeIsMainRegex: '(Test)?$'
 IncludeIsMainSourceRegex: ''
 IndentAccessModifiers: false
-IndentCaseLabels: false
 IndentCaseBlocks: false
+IndentCaseLabels: false
+IndentExternBlock: AfterExternBlock
 IndentGotoLabels: true
 IndentPPDirectives: None
-IndentExternBlock: AfterExternBlock
-IndentRequires:  false
+IndentRequiresClause: false
 IndentWidth:     4
 IndentWrappedFunctionNames: true
+InsertBraces:    false
+InsertNewlineAtEOF: true
 InsertTrailingCommas: None
+IntegerLiteralSeparator:
+  Binary:          0
+  BinaryMinDigits: 0
+  Decimal:         0
+  DecimalMinDigits: 0
+  Hex:             0
+  HexMinDigits:    0
 JavaScriptQuotes: Leave
 JavaScriptWrapImports: true
 KeepEmptyLinesAtTheStartOfBlocks: false
+KeepEmptyLinesAtEOF: false
 LambdaBodyIndentation: Signature
+LineEnding:      DeriveLF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
@@ -119,34 +161,44 @@ ObjCBlockIndentWidth: 4
 ObjCBreakBeforeNestedBlockParam: true
 ObjCSpaceAfterProperty: true
 ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 10
 PenaltyBreakBeforeFirstCallParameter: 30
 PenaltyBreakComment: 10
 PenaltyBreakFirstLessLess: 0
 PenaltyBreakOpenParenthesis: 0
+PenaltyBreakScopeResolution: 500
 PenaltyBreakString: 10
 PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 100
-PenaltyReturnTypeOnItsOwnLine: 60
 PenaltyIndentedWhitespace: 0
+PenaltyReturnTypeOnItsOwnLine: 60
 PointerAlignment: Left
 PPIndentWidth:   -1
+QualifierAlignment: Leave
 ReferenceAlignment: Pointer
 ReflowComments:  false
 RemoveBracesLLVM: false
+RemoveParentheses: Leave
+RemoveSemicolon: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: OuterScope
 SeparateDefinitionBlocks: Leave
 ShortNamespaceLines: 1
+SkipMacroDefinitionBody: false
 SortIncludes:    Never
 SortJavaStaticImport: Before
-SortUsingDeclarations: false
+SortUsingDeclarations: Never
 SpaceAfterCStyleCast: false
 SpaceAfterLogicalNot: false
 SpaceAfterTemplateKeyword: true
+SpaceAroundPointerQualifiers: Default
 SpaceBeforeAssignmentOperators: true
 SpaceBeforeCaseColon: false
 SpaceBeforeCpp11BracedList: false
 SpaceBeforeCtorInitializerColon: true
 SpaceBeforeInheritanceColon: true
+SpaceBeforeJsonColon: false
 SpaceBeforeParens: Never
 SpaceBeforeParensOptions:
   AfterControlStatements: false
@@ -155,32 +207,35 @@ SpaceBeforeParensOptions:
   AfterFunctionDeclarationName: false
   AfterIfMacros:   false
   AfterOverloadedOperator: false
+  AfterPlacementOperator: true
+  AfterRequiresInClause: false
+  AfterRequiresInExpression: false
   BeforeNonEmptyParentheses: false
-SpaceAroundPointerQualifiers: Default
 SpaceBeforeRangeBasedForLoopColon: true
+SpaceBeforeSquareBrackets: false
 SpaceInEmptyBlock: false
-SpaceInEmptyParentheses: false
 SpacesBeforeTrailingComments: 1
 SpacesInAngles:  Never
-SpacesInConditionalStatement: false
 SpacesInContainerLiterals: false
-SpacesInCStyleCastParentheses: false
 SpacesInLineCommentPrefix:
   Minimum:         1
   Maximum:         -1
-SpacesInParentheses: false
+SpacesInParens:  Never
+SpacesInParensOptions:
+  InCStyleCasts:   false
+  InConditionalStatements: false
+  InEmptyParentheses: false
+  Other:           false
 SpacesInSquareBrackets: false
-SpaceBeforeSquareBrackets: false
-BitFieldColonSpacing: Both
-Standard:        c++03
+Standard:        c++20
 StatementAttributeLikeMacros:
   - Q_EMIT
 StatementMacros:
   - Q_UNUSED
   - QT_REQUIRE_VERSION
 TabWidth:        4
-UseCRLF:         false
 UseTab:          Never
+VerilogBreakBetweenInstancePorts: true
 WhitespaceSensitiveMacros:
   - STRINGIZE
   - PP_STRINGIZE

+ 4 - 1
lightmeter/.gitignore

@@ -1,4 +1,7 @@
 dist/*
 .vscode
 .clang-format
-.editorconfig
+.clangd
+.editorconfig
+.env
+.ufbt

+ 1 - 1
lightmeter/.gitsubtree

@@ -1,2 +1,2 @@
 https://github.com/xMasterX/all-the-plugins dev base_pack/lightmeter 4558d74c9da36abc851edd96a95d18f7d5511a75
-https://github.com/oleksiikutuzov/flipperzero-lightmeter main application 13b958b07eb21813680bca39923151364f035daf
+https://github.com/oleksiikutuzov/flipperzero-lightmeter main application 671723ddba0eb8f0089fcd2e9901e0a535bb8724

+ 1 - 1
lightmeter/application.fam

@@ -8,7 +8,7 @@ App(
     ],
     stack_size=4 * 1024,
     order=90,
-    fap_version=(1, 2),
+    fap_version=(1, 3),
     fap_icon="lightmeter.png",
     fap_category="GPIO/Sensors",
     fap_private_libs=[

+ 4 - 0
lightmeter/docs/changelog.md

@@ -1,3 +1,7 @@
+## v1.3
+
+* Update EV compute logic (thanks to @bogdumi)
+
 ## v1.2
 
 * Lux only screen now has statistics

+ 2 - 2
lightmeter/gui/views/main_view.c

@@ -8,7 +8,7 @@
 
 #define WORKER_TAG "Main View"
 
-static const int iso_numbers[] = {
+const int iso_numbers[] = {
     [ISO_6] = 6,
     [ISO_12] = 12,
     [ISO_25] = 25,
@@ -363,7 +363,7 @@ void draw_top_row(Canvas* canvas, MainViewModel* context) {
         canvas_draw_line(canvas, 0, 10, 128, 10);
 
         canvas_set_font(canvas, FontPrimary);
-        // metering mode A – ambient, F – flash
+        // metering mode A ÔÇô ambient, F ÔÇô flash
         // canvas_draw_str_aligned(canvas, 1, 1, AlignLeft, AlignTop, "A");
 
         snprintf(str, sizeof(str), "ISO: %d", iso_numbers[model->iso]);

+ 2 - 2
lightmeter/gui/views/main_view.h

@@ -9,11 +9,11 @@
    with reasonable resolution in 1-10k range
    on 20px of screen height  */
 #define LUX_HISTORGRAM_LOGBASE 1.4
-#define LUX_HISTORGRAM_BOTTOM 64 + 12
+#define LUX_HISTORGRAM_BOTTOM  64 + 12
 
 /* 40 pixels between 45th and 85th
    between left and right button labels */
-#define LUX_HISTORGRAM_LEFT 45
+#define LUX_HISTORGRAM_LEFT   45
 #define LUX_HISTORGRAM_LENGTH 40
 
 typedef struct MainView MainView;

+ 1 - 2
lightmeter/lightmeter.c

@@ -66,7 +66,6 @@ LightMeterApp* lightmeter_app_alloc(uint32_t first_scene) {
     // View dispatcher
     app->view_dispatcher = view_dispatcher_alloc();
     app->scene_manager = scene_manager_alloc(&lightmeter_scene_handlers, app);
-
     view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
     view_dispatcher_set_custom_event_callback(
         app->view_dispatcher, lightmeter_custom_event_callback);
@@ -248,7 +247,7 @@ void lightmeter_app_i2c_callback(LightMeterApp* context) {
     }
 
     if(main_view_get_dome(app->main_view)) lux *= DOME_COEFFICIENT;
-    EV = lux2ev(lux);
+    EV = lux2ev(lux, app->config->iso);
 
     main_view_set_lux(app->main_view, lux);
     main_view_set_EV(app->main_view, EV);

+ 14 - 11
lightmeter/lightmeter_config.h

@@ -1,15 +1,15 @@
 #pragma once
 
-#define LM_VERSION_APP "1.2"
-#define LM_DEVELOPED "Oleksii Kutuzov"
-#define LM_GITHUB "https://github.com/oleksiikutuzov/flipperzero-lightmeter"
-
-#define DOME_COEFFICIENT 2.3
-#define DEFAULT_ISO ISO_100
-#define DEFAULT_ND ND_0
-#define DEFAULT_APERTURE AP_2_8
-#define DEFAULT_SPEED SPEED_125
-#define DEFAULT_DOME WITHOUT_DOME
+#define LM_VERSION_APP "1.3"
+#define LM_DEVELOPED   "Oleksii Kutuzov"
+#define LM_GITHUB      "https://github.com/oleksiikutuzov/flipperzero-lightmeter"
+
+#define DOME_COEFFICIENT  2.3
+#define DEFAULT_ISO       ISO_100
+#define DEFAULT_ND        ND_0
+#define DEFAULT_APERTURE  AP_2_8
+#define DEFAULT_SPEED     SPEED_125
+#define DEFAULT_DOME      WITHOUT_DOME
 #define DEFAULT_BACKLIGHT BACKLIGHT_AUTO
 
 typedef enum {
@@ -121,4 +121,7 @@ typedef enum {
     SENSOR_MAX44009,
 } LightMeterSensorType;
 
-typedef enum { BACKLIGHT_AUTO, BACKLIGHT_ON } LightMeterBacklight;
+typedef enum {
+    BACKLIGHT_AUTO,
+    BACKLIGHT_ON
+} LightMeterBacklight;

+ 3 - 3
lightmeter/lightmeter_helper.c

@@ -1,11 +1,11 @@
 #include "lightmeter_helper.h"
-#include "lightmeter_config.h"
 
+extern const int iso_numbers[];
 extern const float aperture_numbers[];
 extern const float speed_numbers[];
 
-float lux2ev(float lux) {
-    return log2(lux / 2.5);
+float lux2ev(float lux, LightMeterISONumbers iso) {
+    return log2(lux / 2.5) + log2(iso_numbers[iso] / 100.0);
 }
 
 float getMinDistance(float x, float v1, float v2) {

+ 4 - 1
lightmeter/lightmeter_helper.h

@@ -1,8 +1,11 @@
 #pragma once
 
 #include <math.h>
+#include <stdint.h>
 
-float lux2ev(float lux);
+#include "lightmeter_config.h"
+
+float lux2ev(float lux, LightMeterISONumbers iso);
 
 float getMinDistance(float x, float v1, float v2);