Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: a1ex on December 22, 2013, 12:19:13 PM

Title: Easy Coding tasks
Post by: a1ex on December 22, 2013, 12:19:13 PM
Inspired from darktable (http://sourceforge.net/apps/trac/darktable/wiki/EasyCoding). 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 (http://www.magiclantern.fm/forum/index.php?topic=9700.msg96953#msg96953))

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!
Title: Re: Easy Coding tasks
Post by: pravdomil on December 22, 2013, 10:33:38 PM
thanks for this a1ex, I plan spend some weekend on coding it, very usefull
Title: Re: Easy Coding tasks
Post by: g3gg0 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 (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Warning-32.png), error (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Error-32.png) or information (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Information-32.png))
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  (https://bitbucket.org/hudson/magic-lantern/src/d12a423e5f6786524f136cdb5e37660350a68be4/src/notify_box.c?at=NotifyBoxIcon)that cleans up the stuff a bit
Title: Re: Easy Coding tasks
Post by: 1% on February 02, 2014, 08:52:46 PM
QuoteCropmarks in photo mode

https://bitbucket.org/hudson/magic-lantern/issue/1763/disabling-cropmarks-in-photo-mode-does-not

Did my fix not work for this?
Title: Re: Easy Coding tasks
Post by: a1ex on February 02, 2014, 09:02:55 PM
I don't know, where's your pull request?
Title: Re: Easy Coding tasks
Post by: 1% on February 02, 2014, 09:23:17 PM
QuoteI 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.
Title: Re: Easy Coding tasks
Post by: g3gg0 on February 02, 2014, 09:30:35 PM
Quote from: 1% on February 02, 2014, 09:23:17 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 ;)
Title: Re: Easy Coding tasks
Post by: pompeiisneaks on February 04, 2014, 08:38:20 PM
Quote from: 1% on February 02, 2014, 08:52:46 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
Title: Re: Easy Coding tasks
Post by: 1% on February 04, 2014, 08:49:55 PM
As long as it makes it back to main I'm happy.
Title: Re: Easy Coding tasks
Post by: viniciusatique on February 08, 2014, 11:32:05 PM
Quote from: g3gg0 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 (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Warning-32.png), error (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Error-32.png) or information (https://cdn1.iconfinder.com/data/icons/gnome-desktop-icons-png/PNG/32/Gnome-Dialog-Information-32.png))
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?
Title: Re: Easy Coding tasks
Post by: 1% on February 09, 2014, 12:16:05 AM
It stops at like 1799 frames. Maybe can do a frame count.
Title: Re: Easy Coding tasks
Post by: g3gg0 on February 09, 2014, 12:22:04 AM
Quote from: viniciusatique on February 08, 2014, 11:32:05 PM
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.
Title: Re: Easy Coding tasks
Post by: viniciusatique on February 09, 2014, 12:25:09 AM
Quote from: 1% on February 09, 2014, 12:16:05 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?
Title: Re: Easy Coding tasks
Post by: viniciusatique on February 09, 2014, 12:30:02 AM
Quote from: g3gg0 on February 09, 2014, 12:22:04 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.
Title: Re: Easy Coding tasks
Post by: g3gg0 on February 09, 2014, 01:22:50 AM
Quote from: viniciusatique on February 09, 2014, 12:30:02 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.
Title: Easy Coding tasks
Post by: viniciusatique 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?
Title: Re: Easy Coding tasks
Post by: g3gg0 on February 09, 2014, 01:39:19 AM
if the video stopped and the user did not press rec, restart video.
Title: Re: Easy Coding tasks
Post by: viniciusatique on February 09, 2014, 01:53:58 AM
Ooooh! Right! Thanks g3gg0
Title: Re: Easy Coding tasks
Post by: viniciusatique 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?
Title: Re: Easy Coding tasks
Post by: viniciusatique 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.

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
Title: Re: Easy Coding tasks
Post by: viniciusatique 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.

#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
Title: Re: Easy Coding tasks
Post by: a1ex 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.
Title: Re: Easy Coding tasks
Post by: viniciusatique 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
Title: Re: Easy Coding tasks
Post by: 1% 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.
Title: Re: Easy Coding tasks
Post by: g3gg0 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.
Title: Re: Easy Coding tasks
Post by: tjaja 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
Title: Re: Easy Coding tasks
Post by: g3gg0 on February 16, 2014, 10:32:43 AM
Quote from: tjaja 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

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 ;)
Title: Re: Easy Coding tasks
Post by: eyeland 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 :)
Title: Re: Easy Coding tasks
Post by: Audionut 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.
Title: Re: Easy Coding tasks
Post by: Johny007 on May 14, 2014, 12:59:45 AM
Quote from: g3gg0 on February 02, 2014, 08:40:53 PM
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
Title: Re: Easy Coding tasks
Post by: g3gg0 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.
Title: Re: Easy Coding tasks
Post by: Johny007 on May 14, 2014, 07:53:15 PM
Any hint how to fix flicker? Temporary stop rendering of other ML GUI?
Title: Re: Easy Coding tasks
Post by: applewide 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
Title: Re: Easy Coding tasks
Post by: Straight_Shooter on May 19, 2021, 02:46:20 PM
Would there be a way to breathe some new life into this thread? That is, to set up some new easy coding tasks for people to work on? I think that having these is a great idea, and it can help to bring in some new people into ML development. Can't hurt to try :)
Title: Re: Easy Coding tasks
Post by: kitor on May 19, 2021, 06:55:02 PM
With the development stagnation I can't think of any.

All the recent stuff for Digic 7 and 8 is mostly R&D. It would be helpful if someone would be able to test our recent developments on Digic 6 (we assume it should be fairly straightforward), but this is definitely not an easy task.

On the other hand last year I wrote:

Quote from: kitor on October 03, 2020, 10:43:55 AM
Just porting it further is 'above my paygrade'.

and without any previous embedded C skills (and just very basic skills outside PHP/Bash/Python scripting and a lot of interest in vintage computers and consoles hacking from youtube) in just two months with great help (and later collaboration) mainly with @names_are_hard on Discord, this (https://www.magiclantern.fm/forum/index.php?topic=22770.msg234805#msg234805), this (https://www.magiclantern.fm/forum/index.php?topic=26024.0), this (https://www.magiclantern.fm/forum/index.php?topic=22770.msg235007#msg235007) and recently this (https://www.magiclantern.fm/forum/index.php?topic=23296.msg235438#msg235438) had happened.

So it is not that hard, but requires courage and a lot of spare time to understand the basics :)
Title: Re: Easy Coding tasks
Post by: ML700D on May 20, 2021, 08:06:52 AM
@kitor how to start?  :D
maybe I can learn and contribute, if there is an assist.
Title: Re: Easy Coding tasks
Post by: kitor on May 20, 2021, 09:39:59 AM
Start with build environment. There are threads in this section - slightly outdated, but on the other hand environment problem solving is slightly easier than actual later work.

After that try to build something from either unified branch on HG or dev on @names_are_hard GitHub clone. If it works, you have a working development env.
And if you go git, you can check on your 700D if our recent changes didn't break anything for Digic 5 ;)

Later I would suggest playing with minimal/hello-world (dev branch on git, digic6-dumper on hg). This is just a code execution on camera, without any real magic lantern code running. Source code built there is pretty simple - there's whole "startup sequence" there (where ML hijacks Canon stuff) and then just a simple task is started that is able to draw on screen and blink a led.
And you don't need to search for any stubs as 700D is already supported camera :)

There's a startup sequence flow chart in some thread on the forum, I forgot which.

As long as you don't poke into memory addresses that you are unsure of, you are relatively safe to play with almost any C code there (in fact, minimal build was a base for doom port on 200D).

In the meantime you can join our Discord - we will be more than happy to answer any technical questions.
Title: Re: Easy Coding tasks
Post by: Walter Schulz on May 20, 2021, 10:09:11 AM
Quote from: kitor on May 20, 2021, 09:39:59 AM
There's a startup sequence flow chart in some thread on the forum, I forgot which.

This one?
https://a1ex.magiclantern.fm/bleeding-edge/ml-startup.png
Title: Re: Easy Coding tasks
Post by: kitor on May 20, 2021, 10:16:43 AM
Yes, but it was posted by Alex in a whole topic explaining this early boot process.

Edit: https://www.magiclantern.fm/forum/index.php?topic=23641
Title: Re: Easy Coding tasks
Post by: ML700D on May 20, 2021, 06:24:58 PM
oh.. thanks.. I'll try to figure it out.  :D