Author Topic: Easy Coding tasks  (Read 36787 times)

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10319
  • 5D Mark Free
Easy Coding tasks
« on: December 22, 2013, 12:19:13 PM »
Inspired from darktable. These things require minimal C skills and can be solved in roughly 5-10 lines of code => good for beginner developers looking for something easy to jump in.

Look for "easy coding task" around the forum or the issue tracker
That's how we used to mark them lately.

Minor typos
https://bitbucket.org/hudson/magic-lantern/issue/1742/typo-in-menu solved by pompeiisneaks

(keep looking for these things; we are not native English speakers)


Benchmark fonts (solved in 3aba2ce)

Cropmarks in photo mode solved by 1% and merged by pompeiisneaks

Cold pixel fix in raw2dng (solved by escho)

Bad pixel fix from a .badpixel file (solved by bouncyball)

File join support in raw2dng (autodetect and merge .RAW, .R00, .R01...) (solved by bouncyball)



Missing indicators in the LiveView info bars

Solving one indicator from this list should fit as a EasyCoding task. Solving all of them will take more than 10 lines of code.

https://bitbucket.org/hudson/magic-lantern/issue/1741/50d-maybe-others-no-longer-displays
https://bitbucket.org/hudson/magic-lantern/issue/1687/exposure-compensation-missing-from-lv (solved by ayshih)
https://bitbucket.org/hudson/magic-lantern/issue/1715/no-aperture-stop-indication-sincenightly (solved by ayshih)
http://www.magiclantern.fm/forum/index.php?topic=9282
and the API you should use is described here: http://www.magiclantern.fm/forum/index.php?topic=8539.msg79753#msg79753

Happy coding!

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Easy Coding tasks
« Reply #1 on: December 22, 2013, 10:33:38 PM »
thanks for this a1ex, I plan spend some weekend on coding it, very usefull

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #2 on: February 02, 2014, 08:40:53 PM »
Clean up movie restart feature
Current state:
The "Movie Restart" feature is for automatic restarting H264 recording if it was stopped due to reaching 4GiB or 30 min limits.
At the moment this is done by checking some error message dialog id and recording state.
This is a bit hard to port for every model and on firmware change.

Goal:
Rewrite the code so that it is more or less a simple state machine that receives the users keypresses as input (Rec, Set)
and checks if recording started (RECORDING_H264) within a second after the keypress was received. Same for stopping.
If the recording indicator indicates that recording suddenly stopped, it should re-emit a movie_start() and check if it records longer than 10 seconds.
If recording stops in less than 10 seconds again, reset the state and wait for the next user input (Rec, Set)
This check is to make sure that recording didnt stop automatically due to e.g. sensor overheating or disk space.

Hint: It would be a good start to draw a state diagram
(i *never* thought i would ever really say that i like drawing charts ;) )

Rework NotifyBox
Current state:
The NotifyBox feature is an useful on-screen display to notify the user of some happenings.
Unfortunately its implementation is quite crude, just printing the text on screen, providing not much usability.

Goal:
Pimp this functionality by
1) drawing some borders and making it look more like a information dialog, not like a bug.
2) adding e.g. NotifyBoxEx which allows to pass some icon type
(warning , error or information )
3) add an option to make the boxes disappear when the user presses a button

Make sure the icons being used are GPLed! (e.g. GNOME, KDE or any other linux window manager/toolkit provide plenty)

there is some reference implementation that cleans up the stuff a bit
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Easy Coding tasks
« Reply #3 on: February 02, 2014, 08:52:46 PM »

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10319
  • 5D Mark Free
Re: Easy Coding tasks
« Reply #4 on: February 02, 2014, 09:02:55 PM »
I don't know, where's your pull request?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Easy Coding tasks
« Reply #5 on: February 02, 2014, 09:23:17 PM »
Quote
I don't know, where's your pull request?

No HG transplant?

Quote
Unfortunately its implementation is quite crude, just printing the text on screen, providing not much usability.

From using it, also seems inefficient.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #6 on: February 02, 2014, 09:30:35 PM »
No HG transplant?

From using it, also seems inefficient.

it is much easier to get a pull request, than to dig in other repositories, expecially when you dont know where to look.

yes, its inefficient. but it was never meant to get used that much ;)
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

pompeiisneaks

  • Freshman
  • **
  • Posts: 66
Re: Easy Coding tasks
« Reply #7 on: February 04, 2014, 08:38:20 PM »
Did my fix not work for this?

Sorry I found that you didn't put this in as a pull request, so I just put your fix into my tree and submitted the pull request,  I gave credit to you for the find though.  a1ex if you want to wait and reject mine to give 1% credit by all means do so :)

~Phil

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Easy Coding tasks
« Reply #8 on: February 04, 2014, 08:49:55 PM »
As long as it makes it back to main I'm happy.

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #9 on: February 08, 2014, 11:32:05 PM »
Clean up movie restart feature
Current state:
The "Movie Restart" feature is for automatic restarting H264 recording if it was stopped due to reaching 4GiB or 30 min limits.
At the moment this is done by checking some error message dialog id and recording state.
This is a bit hard to port for every model and on firmware change.

Goal:
Rewrite the code so that it is more or less a simple state machine that receives the users keypresses as input (Rec, Set)
and checks if recording started (RECORDING_H264) within a second after the keypress was received. Same for stopping.
If the recording indicator indicates that recording suddenly stopped, it should re-emit a movie_start() and check if it records longer than 10 seconds.
If recording stops in less than 10 seconds again, reset the state and wait for the next user input (Rec, Set)
This check is to make sure that recording didnt stop automatically due to e.g. sensor overheating or disk space.

Hint: It would be a good start to draw a state diagram
(i *never* thought i would ever really say that i like drawing charts ;) )

Rework NotifyBox
Current state:
The NotifyBox feature is an useful on-screen display to notify the user of some happenings.
Unfortunately its implementation is quite crude, just printing the text on screen, providing not much usability.

Goal:
Pimp this functionality by
1) drawing some borders and making it look more like a information dialog, not like a bug.
2) adding e.g. NotifyBoxEx which allows to pass some icon type
(warning , error or information )
3) add an option to make the boxes disappear when the user presses a button

Make sure the icons being used are GPLed! (e.g. GNOME, KDE or any other linux window manager/toolkit provide plenty)

If so, how does the camera know if the button was pushed by user or by the movie restart feature? Because if it can't tell the diference, I think it will never stop recording. Am I right or did I miss something? Perhaps using the time (29'.59") as a marker that it was stopped because it reached the limit time? Any inputs?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Easy Coding tasks
« Reply #10 on: February 09, 2014, 12:16:05 AM »
It stops at like 1799 frames. Maybe can do a frame count.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #11 on: February 09, 2014, 12:22:04 AM »
If so, how does the camera know if the button was pushed by user or by the movie restart feature?

as described, the user keys have to be monitored.
if user pressed REC and the video stops, well then its likely that this was intended ;)
if nothing was pressed, stopping was not intended by the user.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #12 on: February 09, 2014, 12:25:09 AM »
It stops at like 1799 frames. Maybe can do a frame count.

But then it would be different for every h264 format, no? like 24fps and 50 fps and 29 fps. Any idea on how I can use the time?
I was thinking something in the line of:
if(!RECORDING_H264 && recording_prev && BGMT_REC && time elapsed 1799 seconds?) But I don;t know how to code this!

And what is the difference between BGMT_REC and BGMT_FLASH_MOVIE?

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #13 on: February 09, 2014, 12:30:02 AM »
as described, the user keys have to be monitored.
if user pressed REC and the video stops, well then its likely that this was intended ;)
if nothing was pressed, stopping was not intended by the user.

Yes, I understand that, but what then is the command the canon firmware gives the camera to stop recording? If it isn't an error (because we don't want to use errors anymore, right?), I was under the impression it was a BGMT_REC or something similar to movie_was_stopped_by_set.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #14 on: February 09, 2014, 01:22:50 AM »
Yes, I understand that, but what then is the command the canon firmware gives the camera to stop recording?
canon does not fake a keypress.
it is handled in the state objects internally.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Easy Coding tasks
« Reply #15 on: February 09, 2014, 01:27:30 AM »
So I'm missing only one information and I can't find it, though I've looked for it: what is the line I should use in the code to tell that the camera stopped the recording because of the time limit?

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #16 on: February 09, 2014, 01:39:19 AM »
if the video stopped and the user did not press rec, restart video.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #17 on: February 09, 2014, 01:53:58 AM »
Ooooh! Right! Thanks g3gg0

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #18 on: February 09, 2014, 02:26:56 AM »
Just one last thing: when video stopped on 5D2 it was "stopped by set", right? Now on 5D3 is it the same thing? And if it is, can I use it even when 5D3 doesn't have a gui.c?

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #19 on: February 09, 2014, 04:19:14 PM »
So, I tried this code and it didn't work. Any ideas why? As far as I can understand it should work because it wasn't a press of BGMT_REC that stopped the recording.

Code: [Select]
if(!RECORDING_H264 && recording_prev && !BGMT_REC)
        #endif
        {
            if (movie_restart)
            {
                msleep(500);
                movie_start();
            }
        }
        recording_prev = RECORDING_H264;

        if(!RECORDING_H264)
        {
            movie_was_stopped_by_set = 0;
        }
    #endif

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #20 on: February 09, 2014, 10:58:29 PM »
Done! Working on my 5D3. Movie restarting after every 29 minutes. May work for all cameras. Doesn't depend on error messages. See what you think.

Code: [Select]
#ifdef FEATURE_MOVIE_RESTART
        static int recording_prev = 0;
        static int first_time = 0;
        static int start_rec_time = 0;
        static int r = 0;
       
        #if defined(CONFIG_5D2) || defined(CONFIG_50D) || defined(CONFIG_7D)
        if(!RECORDING_H264 && recording_prev && !movie_was_stopped_by_set) // see also gui.c
        #else
        if(RECORDING_H264)
        #endif
        {
            if (movie_restart)
            { 
               if(!first_time)
                  {
                 start_rec_time = get_seconds_clock();
                 NotifyBox(2000,"Movie Restart Active", start_rec_time, r > 1 ? "s" : "");
                 first_time = 1;   
                    }
                r =  get_seconds_clock() - start_rec_time;
                     if(r > 1740)
                    {
                movie_end();
                start_rec_time = 0;
                first_time = 0;
                NotifyBox(2000,"Restarting", start_rec_time, r > 1 ? "s" : "");
                movie_start();
                    }
            }
        }
       
        recording_prev = RECORDING_H264;

        if(!RECORDING_H264)
        {
            movie_was_stopped_by_set = 0;
        }
    #endif

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10319
  • 5D Mark Free
Re: Easy Coding tasks
« Reply #21 on: February 09, 2014, 11:03:20 PM »
It probably works for you, but the assumption about 1740 is pretty hard. What happens if you use FPS override? What if it stops because of high bitrate / slow card?

Try to follow g3gg0's advice, it's much more robust.

viniciusatique

  • New to the forum
  • *
  • Posts: 24
Re: Easy Coding tasks
« Reply #22 on: February 09, 2014, 11:30:43 PM »
It stops and doesn't restart. It restarts only if the command movie_end() was issued. Tested putting 2000 and letting the camera stopping automatically. Didn't restart.
Anyway, it was the way I could do it. Would love to do exactly what g3gg0 suggested but there are too many variables I don't know. Like: what is the codification of the button rec? Which button starts recording and what is its name. What are the commands available for me to use. I couldn't find documentation that explains how everything works. :-(
Anyway, for now this works. Don't know if it will alonside fps override though. Will keep trying to think about g3gg9's solution

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Easy Coding tasks
« Reply #23 on: February 09, 2014, 11:34:59 PM »
The popup way works... just probably the stub is wrong in 5DIII, it was working on 6D when I was testing it and also when movies stopped from BR being too high.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #24 on: February 09, 2014, 11:46:42 PM »
nah sorry, thats not what i meant it to be.
i recommended starting with a state diagram to clarify the problem.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

tjaja

  • Freshman
  • **
  • Posts: 83
Re: Easy Coding tasks
« Reply #25 on: February 10, 2014, 04:26:34 PM »
Ok minimal C skills, check. So if I tutorial and dummy book myself the basics I can help with the (superuberduper) easy stuff?
No need for linux knowledge? That would be great
5DFree, 550D, canon 50mm 1.4

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #26 on: February 16, 2014, 10:32:43 AM »
Ok minimal C skills, check. So if I tutorial and dummy book myself the basics I can help with the (superuberduper) easy stuff?
No need for linux knowledge? That would be great

uhm the exact scale of knowledge is hard to explain...
but it helps when you are able to programm a C program that prints "hello world" without having to look up anything in the net ;)
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

eyeland

  • Member
  • ***
  • Posts: 154
  • 5D Mark Spree
Re: Easy Coding tasks
« Reply #27 on: March 01, 2014, 11:06:48 PM »
I am just about as eager to help as I am clueless about writing code, but I am very fast learner and I studied logic syntax quite extensively as a part of my philosophy master so I just need a nudge in the right direction.
Anyone care to link me a few resources for getting started?
(I know that a quick google search is easy, but I tend to OD on information, and sometimes it takes a certain level of knowledge to distinguish good/relevant material from the less good :)
Daybreak broke me loose and brought me back...

Audionut

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3400
  • Blunt and to the point
Re: Easy Coding tasks
« Reply #28 on: March 02, 2014, 12:14:15 AM »
Start here:  http://www.magiclantern.fm/forum/index.php?topic=9517.0

And you should start looking at the source.

Johny007

  • Just arrived
  • *
  • Posts: 2
Re: Easy Coding tasks
« Reply #29 on: May 14, 2014, 12:59:45 AM »
Rework NotifyBox
Current state:
The NotifyBox feature is an useful on-screen display to notify the user of some happenings.
Unfortunately its implementation is quite crude, just printing the text on screen, providing not much usability.


Should I consider this done with this commit? https://bitbucket.org/hudson/magic-lantern/src/d12a423e5f6786524f136cdb5e37660350a68be4/src/notify_box.c?at=NotifyBoxIcon

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3040
Re: Easy Coding tasks
« Reply #30 on: May 14, 2014, 01:06:36 PM »
i would rather see it as reference. it has still some issues with flicker due to repainting.
will update the post, pointing there.
thanks for pointing out.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

Johny007

  • Just arrived
  • *
  • Posts: 2
Re: Easy Coding tasks
« Reply #31 on: May 14, 2014, 07:53:15 PM »
Any hint how to fix flicker? Temporary stop rendering of other ML GUI?

applewide

  • New to the forum
  • *
  • Posts: 19
Re: Easy Coding tasks
« Reply #32 on: May 14, 2014, 07:56:12 PM »
i want to help, i got bs and ms in computer science, i think i can do this