Author Topic: Flexible info screen  (Read 14248 times)

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Flexible info screen
« on: January 10, 2013, 12:34:19 AM »
i added a new file lately: flexinfo.c

background:
the late updates to all models photo info screen are very good and i like the changes.
unfortunately it gets complex and hackish the more models are updated.

before it gets a real mess, i decided to set up a flexible info screen that separates the code from model-specific settings and positions.
we now can also configure the positions via menu (for developers or power users) and add routines to load/save the setup into ini files.
stuff only interesting for real power users, like CF/SD card names, copyright strings etc etc will go into code, but not be printed or added to menu.
users can later load their power-user screen config and make ML fit their needs.


how does it work:
at the moment the function info_print_screen() called from display_shooting_info().
it uses the configuration in info_config[] that is model specific.
the configuration is an array of "elements" that will be printed on screen at given coordinates.

it looks like this:
Code: [Select]
    /* print ISO range */
    { .string = { { INFO_TYPE_STRING, { ISO_RANGE_POS_X, ISO_RANGE_POS_Y, 2 }}, INFO_STRING_ISO_MINMAX, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_MEDIUM } },

    /* entry 2 and 3, WB strings */
    { .string = { { INFO_TYPE_STRING, { WBS_POS_X, WBS_POS_Y, 2 }}, INFO_STRING_WBS_BA, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_LARGE } },
    { .string = { { INFO_TYPE_STRING, { WBS_POS_X + 40, WBS_POS_Y, 2 }}, INFO_STRING_WBS_GM, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_LARGE } },
   
    /* entry 4, battery_icon referenced as anchor */
    { .battery_icon = { { INFO_TYPE_BATTERY_ICON, { DISPLAY_BATTERY_POS_X, DISPLAY_BATTERY_POS_Y, 2 }}, DISPLAY_BATTERY_LEVEL_2, DISPLAY_BATTERY_LEVEL_1 } },
    { .battery_perf = { { INFO_TYPE_BATTERY_PERF, { -14, 0, 3, INFO_ANCHOR_LEFT | INFO_ANCHOR_TOP, 4 }}, /* 0=vert,1=horizontal */ 0, /* x size */ 12, /* y size */ 12 } },
    { .string = { { INFO_TYPE_STRING, { 0, 2, 2, INFO_ANCHOR_HCENTER | INFO_ANCHOR_BOTTOM, 4, INFO_ANCHOR_HCENTER | INFO_ANCHOR_TOP }}, INFO_STRING_BATTERY_PCT, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_LARGE } },
    { .string = { { INFO_TYPE_STRING, { 0, 0, 2, INFO_ANCHOR_RIGHT | INFO_ANCHOR_TOP, 4 }}, INFO_STRING_BATTERY_ID, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_LARGE } },

    /* entry 8, MLU string */
    { .string = { { INFO_TYPE_STRING, { MLU_STATUS_POS_X, MLU_STATUS_POS_Y, 2 }}, INFO_STRING_MLU, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_MEDIUM } },
   
    /* entry 9, kelvin */
    { .string = { { INFO_TYPE_STRING, { WB_KELVIN_POS_X, WB_KELVIN_POS_Y, 2 }}, INFO_STRING_KELVIN, COLOR_YELLOW, INFO_COL_FIELD, INFO_FONT_MEDIUM_SHADOW } },
   
    /* entry 10, pictures */
    { .fill = { { INFO_TYPE_FILL, { 540, 390, 1, 0, 0, 0, 150, 60 }}, INFO_COL_FIELD } },
    { .string = { { INFO_TYPE_STRING, { 550, 402, 2 }}, INFO_STRING_PICTURES_4, COLOR_FG_NONLV, INFO_COL_FIELD, INFO_FONT_CANON } },

lets look closer at the first entry:
Code: [Select]
/* print ISO range */
{
    /* we are defining a new string to be printed */
    .string =
    {
        {
            /* it must be of the type STRING and match the .string initializer above */
            INFO_TYPE_STRING,
            /* print it at X, Y and Z. Z is the layer - the higher the number, the later it gets drawn and overwrites other items (like fills or other strings) */
            { ISO_RANGE_POS_X, ISO_RANGE_POS_Y, 2 }
        },
        /* print the ISO_MINMAX string there. we have dozens of other strings, see the header */
        INFO_STRING_ISO_MINMAX,
        /* foreground color */
        COLOR_YELLOW,
        /* background color is "FIELD" or "BG" or any other COLOR_ define */
        INFO_COL_FIELD,
        /* medium font size */
        INFO_FONT_MEDIUM
    }
},

there is not just ".string", but some other interface items that can be drawn.
this is the current list of defined elements:

.string / INFO_TYPE_STRING
print some string like ISO, Kelvin, WB, picture count, time, date, etc.
if the element is not available, like we print the "MLU" string and MLU is disabled, the item will *not* get drawn.

.fill / INFO_TYPE_FILL
fill some area with specified color. useful for clearing some canon strings or symbols.
use the lowest Z values for such things and print the strings with higher Z values over it.

.battery_icon / INFO_TYPE_BATTERY_ICON
the battery icon Pelican made with some little changes to make it a bit more flexible.
in the initializer you can specify the red/yellow pct values.

.battery_perf / INFO_TYPE_BATTERY_PERF
also from Pelican the battery performance dots that tell you the battery health.
it is also a bit more flexible and can get configured to be printed horizontal/vertical and with custom dot sizes.

.icon / INFO_TYPE_ICON
not implemented yet, but why not put some code to paint icons from a file on screen.


(to be continued)

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Flexible info screen
« Reply #1 on: January 12, 2013, 04:58:33 PM »
One quick question, I'm porting this to the 1100D but there's no Kelvin icon that i'm aware of...any suggestions?
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5


Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #3 on: January 18, 2013, 12:30:05 AM »
The idea is good, I like it but I think it needs a little more work to be usable.

For example the avail_shot needs to show if it is above 999. You can program this condition to INFO_STRING_PICTURES but the INFO_TYPE_FILL have no condition so it will always clear the area. It would be a better solution if every item has a fill property which execute only when necessary (when the programmed condition is true).


Also it could be useful if every item has a show/hide property to easily turn on/off so you can put all the available options, and everybody can customize it (so you can display infos in the header/footer).


Also instead of using ifdefs in flexinfo.c I would put the camera specific info_config definition to a file in the platform folder (to 'misc' or a new file) so if two or more developer works on the info screen of the different cameras there is no conflict when they merge into the main repo.


EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Flexible info screen
« Reply #4 on: January 18, 2013, 12:34:49 AM »
Also it could be useful if every item has a show/hide property to easily turn on/off so you can put all the available options, and everybody can customize it (so you can display infos in the header/footer).


Also instead of using ifdefs in flexinfo.c I would put the camera specific info_config definition to a file in the platform folder (to 'misc' or a new file) so if two or more developer works on the info screen of the different cameras there is no conflict when they merge into the main repo.

agree.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Re: Flexible info screen
« Reply #5 on: January 18, 2013, 12:57:46 AM »
For example the avail_shot needs to show if it is above 999. You can program this condition to INFO_STRING_PICTURES but the INFO_TYPE_FILL have no condition so it will always clear the area. It would be a better solution if every item has a fill property which execute only when necessary (when the programmed condition is true).

already implemented. choose the string field as anchor item in the clear item.
then the clear item will only get drawn if the string item is printed (i.e. length > 0)

set hdr.pos.anchor to the index of your string item, but keep positioning absolute (hdr.pos.anchor_flags = 0)

Also it could be useful if every item has a show/hide property to easily turn on/off so you can put all the available options, and everybody can customize it (so you can display infos in the header/footer).

already planned. field hdr.pos.user_disable is the one you talk about.
just no code behind it yet.

Also instead of using ifdefs in flexinfo.c I would put the camera specific info_config definition to a file in the platform folder (to 'misc' or a new file) so if two or more developer works on the info screen of the different cameras there is no conflict when they merge into the main repo.

with mercural this is basically no problem. you can merge file changes without any fuzz.
i would keep it in one place for a special reason: its simpler to make all models look similar.
if it gets spread over multiple files, copy-paste and merge different models is not that easy.

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Flexible info screen
« Reply #6 on: January 19, 2013, 10:47:28 PM »
It worked for me on 600D until last changes, I've made a pull request for 600D, but maybe I've miss something that need to be added for showing items on the info screen?
Something to define maybe?
I can go in the editor submenu and they are shown right in position there. But If out of ML menu they are not shown in the photo info screen.

EDIT: also already put on consts.h WB_K_ICON_POS_X and WB_K_ICON_POS_Y for position of K icon.
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Flexible info screen
« Reply #7 on: January 20, 2013, 12:39:27 PM »
Ok, alex commit fixed it, now about items in the upped and lower corners, should we place them here and remove the Info screen settings item from Prefs menu?
Actually on 600d I have the menu but nothing is shown cause it was removed from ph_info_disp.c (#if 0)
I've changed it to this for showing it up:
Code: [Select]
-#if 0
+#ifdef DISPLAY_HEADER_FOOTER_INFO
+    int col_bg = bmp_getpixel(20,10);
+    int col_field = bmp_getpixel(20,10); //to check
+    int fnt;
    extern int header_left_info;
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #8 on: January 20, 2013, 03:53:21 PM »
already implemented. choose the string field as anchor item in the clear item.
then the clear item will only get drawn if the string item is printed (i.e. length > 0)
It doesn't work for me.

The aligning also doesn't work as I imagine. If the anchor is center or right it puts to left side of the string to the center or right instead of the center of the string or right side of the string.
For exmaple:
item 1: abcdefghijkl
item 2: 1234
item 2's anchor  is item 1,
Code: [Select]
anchor type: left
abcdefghijkl
1234


anchor type: center
abcdefghijkl
      1234


anchor type: right
abcdefghijkl
            1234
Instead of
 
Code: [Select]
anchor type: left
abcdefghijkl
1234


anchor type: center
abcdefghijkl
    1234


anchor type: right
abcdefghijkl
        1234
And now  the aligning is different for the different fonts.
EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down


g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Re: Flexible info screen
« Reply #10 on: January 20, 2013, 09:47:38 PM »
offsets at least should be fixed.

behavior:

anchor specified, but no anchor flags:
-> when the anchor item is not displayed, hide this item too (not tested)
-> positioning absolute from top left corner

anchor specified, flags specify some anchor position:
-> X and Y offsets are calculated separately - if just INFO_ANCHOR_LEFT is specified, X is relative to anchor item, Y is absolute (screen corrdinate)

in any case when anchor_flags_self is set:
-> X and Y coordinates, no matter if relative or absolute are for the specified anchor.


Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #12 on: January 25, 2013, 05:41:39 PM »
The INFO_COL_BG is the same black as the INFO_COL_FIELD (instead of gray on 7D).
The INFO_TYPE_FILL still doesn't work for me (it always clears the area even if the anchored string doesn't displayed).
I would like to display the avail_shot only when it is over 999, because the original Canon font is bigger (easier to read).

In the menu it could be better if you don't display all the options which you cannot reach (because it goes to the gray screen) just make an info like X: 100, Y: 200, Z: 2, etc. so it can fit on the screen. The option to change the string type would be great too.
EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down


Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #14 on: February 09, 2013, 09:43:31 PM »
Could you check the background color and the fill bug please?
EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Re: Flexible info screen
« Reply #15 on: February 09, 2013, 10:33:13 PM »
well, no idea whats wrong with the version you have - here it works without problems.
maybe you should revert all changes?

Code: [Select]
    { .fill = { { INFO_TYPE_FILL, { 10, 10, 1, 0, 1, 0, 30, 30, .name = "(clear)" }}, .color = INFO_COL_FIELD } },
    { .fill = { { INFO_TYPE_FILL, { 10, 40, 1, 0, 1, 0, 30, 30, .name = "(clear)" }}, .color = INFO_COL_BG } },
    { .fill = { { INFO_TYPE_FILL, { 10, 70, 1, 0, 1, 0, 30, 30, .name = "(clear)" }}, .color = COLOR_WHITE } },

it hides correctly when the anchor element is not shown.


Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #16 on: February 18, 2013, 09:20:04 PM »
well, no idea whats wrong with the version you have - here it works without problems.
Thanks, the bg color works here too now.
I still cannot use the INFO_TYPE_FILL for avail_shot because it's clearing the rectangle even if no text displayed.
EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Re: Flexible info screen
« Reply #17 on: February 18, 2013, 10:21:18 PM »
Thanks, the bg color works here too now.
I still cannot use the INFO_TYPE_FILL for avail_shot because it's clearing the rectangle even if no text displayed.

is this element referencing the text as anchor?
if you manually hide the text element (using editor) the filling disappears?

can you send me the config array?

Pelican

  • Senior
  • ****
  • Posts: 406
Re: Flexible info screen
« Reply #18 on: February 27, 2013, 10:58:48 AM »
is this element referencing the text as anchor?
Yes.
if you manually hide the text element (using editor) the filling disappears?
No.
can you send me the config array?
<fill name="Pics (clear)" x=540 y=390 z=1 w=150 h=60 anchor=11 color=-33554432 />
<string name="Pics" y=-1 z=2 w=78 h=40 anchor_flags=10 anchor=10 anchor_flags_self=10 string_type=36 fgcolor=1 bgcolor=-33554432 font_type=6 />

Also the 'Save config' is useless because it doesn't read back the saved xml at the start.
EOS 7D Mark II, EOS 7D, EOS 5, EOS 100 + lenses (10mm to 300mm), 600EX, 550EX, YN600EX x 3
EOScard, EOS DSLR firmwares, ARMu, NiControl, etc.: http://pel.hu/down

Marsu42

  • Hero Member
  • *****
  • Posts: 1557
  • 66d + flashes
Re: Flexible info screen
« Reply #19 on: February 27, 2013, 11:07:08 AM »
Is this only available for the INFO screen or also for Q settings where but you can actually change the settings and not just view them...

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Flexible info screen
« Reply #20 on: February 28, 2013, 03:08:02 PM »
Only info screen
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

cbob

  • New to the forum
  • *
  • Posts: 8
Re: Flexible info screen
« Reply #21 on: May 27, 2013, 01:17:09 AM »
I enabled flexinfo for the 550D: clock, free space, MLU, kelvin and bracketing.

Pull request: https://bitbucket.org/hudson/magic-lantern/pull-request/97/added-550d-flexinfo/diff



The clock is restored at the same font/position as before, but the other items have moved. I particularly like the new free space display.

A few comments/questions about flexinfo:

1) It's very flexible(!) and works great, but perhaps allows too much scope for making ML look entirely different on each model.

Just from the code, it's difficult to visualise how other camera models look without having familiarity/access to such bodies. e.g. the 7D seems to have a very complete flexinfo, including colours, but I have no idea how those features sit within the Canon 7D info screen. Making the 550D look consistent with that was impossible for me.

2) I presume the platform-specific X, Y coordinates defines can now be magic numbers in flexinfo.c rather than platform/consts.h? Lines from the platform-specific code islands at the top of flexinfo.c can never be shared between models anyway due to the need to hard code anchor references.

3) I added replications of some 7D info string types, with different padding and postfix (GB). Doing this could result in a lot of replicated code to suit different models. There's probably a better way to do this?

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 2973
Re: Flexible info screen
« Reply #22 on: May 27, 2013, 01:47:37 AM »
1) It's very flexible(!) and works great, but perhaps allows too much scope for making ML look entirely different on each model.
this was one of my goals since some features might not be necessary or just no space on screen for it.
also you might want to clear some areas on some model and on other models not.
it also allows to edit/provide XML files with all items or even profiles by selecting XMLs (not implemented)

2) I presume the platform-specific X, Y coordinates defines can now be magic numbers in flexinfo.c rather than platform/consts.h?
yep, absolutely

3) I added replications of some 7D info string types, with different padding and postfix (GB). Doing this could result in a lot of replicated code to suit different models. There's probably a better way to do this?
why did you have to add nopad versions? i would keep the old ones. you can use anchors to align left right or center.

the renaming of the free space items is okay, just the unit should not be there.
see the other models:
{ .text = { { INFO_TYPE_TEXT, { 144, 162, 2, .anchor_flags_self = (INFO_ANCHOR_RIGHT | INFO_ANCHOR_BOTTOM), .name = "GB" }}, "GB", COLOR_CYAN, INFO_COL_PEEK, INFO_FONT_MEDIUM } },

the unit "GB" is a string that is being anchored to the free space item.

thanks for supporting!

cbob

  • New to the forum
  • *
  • Posts: 8
Re: Flexible info screen
« Reply #23 on: May 27, 2013, 02:00:38 AM »
I see what you mean about the GB postfix. I've updated the code and pull request. GB is anchored to the right of the self-centered free space. The INFO_STRING with GB included is no longer present.

I still can't see how to properly center Kelvin (or free photos) when it's padded with %Xd though. The raw Kelvin value can be 4 or 5 chars long, but the %5d means the centering routine always centers for 5 chars and the text is only properly centered for > 10,000 K?

Greg

  • Hero Member
  • *****
  • Posts: 550
Re: Flexible info screen
« Reply #24 on: May 29, 2013, 07:56:29 PM »
500D :