Author Topic: My modifications to CHDK  (Read 5827 times)

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #15 on: 27 / June / 2008, 05:54:41 »
12. Show and erase RAW in review mode

So the idea is, when in review mode:
- to display in OSD if there is a RAW file corresponding to the current viewed JPG
- to allow in alt-mode RAW deletion (disp button), but also navigation between pictures (left/right) and jpg deletion (bottom) like outside alt-mode

Code: [Select]
platform/ixus70_sd1000/sub/102a/stubs_min.S:15
+DEF(review_file,0xF640)
include/platform.h:58
+extern char review_file;

core/raw.h:28
+extern static char prefixes[][4];
+extern static char exts[][4];
core/raw.c:16
-static char raw_prefixes[][4] = { "IMG", "CRW", "SND" };
-static char raw_exts[][4] = { "JPG", "CRW", "CR2", "THM", "WAV" };
+char raw_prefixes[][4] = { "IMG", "CRW", "SND" };
+char raw_exts[][4] = { "JPG", "CRW", "CR2", "THM", "WAV" };
gui_osd.h:61
+extern char* gui_raw_file;
+extern int gui_raw_exists;
gui_osd.c:24
+char gui_raw_file[64] = "";
+int gui_raw_exists = 0;
core/gui_osd.c:15
+#include "raw.h"
core/gui_osd.c:691
+void gui_osd_draw_raw_file()
+{
+ int pos, fd;
+
+ strncpy(gui_raw_file, &review_file, 64);
+ if (gui_raw_file[63] != 0) return;
+ pos = strlen(gui_raw_file);
+ strncpy(gui_raw_file+pos-12, raw_prefixes[conf.raw_prefix], 3);
+ strncpy(gui_raw_file+pos-3, raw_exts[conf.raw_ext], 3);
+ if (!conf.raw_in_dir) strncpy(gui_raw_file+7, "100", 3);
+ fd = open(gui_raw_file, O_RDONLY, 0777);
+ if (fd >= 0)
+ {
+ gui_raw_exists = 1;
+ close(fd);
+ draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "RAW pic", conf.osd_color_warn);
+ } else
+ {
+ draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "", conf.osd_color_warn);
+ gui_raw_exists = 0;
+ }
+}
core/gui.c:2032,gui_draw_osd
+ if ((m&MODE_MASK) == MODE_PLAY && conf.show_raw_state && !mode_video)
+ gui_osd_draw_raw_file();
+
  if ((m&MODE_MASK) == MODE_REC && (recreview_hold==0 || conf.show_osd_in_review) ) {

core/gui.c:1671
+static void gui_delete_raw_selected(unsigned int btn)
+{
+ if (btn == MBOX_BTN_YES)
+ {
+ if  (gui_raw_exists) remove(gui_raw_file);
+ }
+}
core/gui.c:1751,gui_kbd_process
 case GUI_MODE_ALT:
+ if ((mode_get()&MODE_MASK) == MODE_PLAY)
+ {
+ if (kbd_is_key_clicked(KEY_LEFT))
+ { kbd_key_press(KEY_LEFT); pressed_key = KEY_LEFT; } else
+ if (kbd_is_key_clicked(KEY_RIGHT))
+ { kbd_key_press(KEY_RIGHT); pressed_key = KEY_RIGHT; } else
+ if (kbd_is_key_clicked(KEY_DOWN))
+ { kbd_key_press(KEY_DOWN); pressed_key = KEY_DOWN; } else
+ if (kbd_is_key_clicked(KEY_UP))
+ { kbd_key_press(KEY_UP); pressed_key = KEY_UP; } else
+ if (kbd_is_key_clicked(KEY_SET))
+ { kbd_key_press(KEY_SET); pressed_key = KEY_SET; } else
+ if (kbd_is_key_clicked(KEY_DISPLAY))
+ {
+ gui_mbox_init(LANG_MSG_DELETE_RAW, (int)"", MBOX_FUNC_RESTORE|MBOX_BTN_YES_NO, &gui_delete_raw_selected);
+ }
+ } else {
  if (kbd_is_key_clicked(SHORTCUT_TOGGLE_RAW)) {
core/gui.c:1862,kbd_key_processed
  }
+ }
  break;
 case GUI_MODE_MENU:
core/gui_lang.h:488
+#define LANG_MSG_DELETE_RAW       384
core/gui_lang.h:492
-#define GUI_LANG_ITEMS                  383
+#define GUI_LANG_ITEMS                  384
core/gui_lang.c:502
+"384 \"Delete RAW?\"\n"

So only the current viewed file name address is maybe platform dependant... Are there RAM dumps available for all platforms?
« Last Edit: 27 / June / 2008, 15:54:17 by cyril42e »

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: My modifications to CHDK
« Reply #16 on: 27 / June / 2008, 12:01:49 »
Hah thats funny,that would have been my next project :)
In review_file,do you see the whole name? And also if it is an avi? Because then i could code slideshows... We only need to find out if a shown movie is playing or paused.anyhow,nice progress,thanks!

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #17 on: 27 / June / 2008, 16:29:57 »

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: My modifications to CHDK
« Reply #18 on: 27 / June / 2008, 16:47:16 »
well, playback is on every canon camera, but for example on my a620 it 5ucks very much in comparison to the one on the s3is.
by the way, check out #21 in for devs: vacant jobs, must-have features, status & overview / for users: a poll
you can see that your feature can possibly lead to a whole new range of features, at least these are some of the features i thought of when i compiled the list.

Offline Jucifer

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 251
  • [A710IS]
Re: My modifications to CHDK
« Reply #19 on: 29 / June / 2008, 23:09:52 »
Suggestion: instead of having a script submenu:

...
----- Current script -----
script-name
------- Parameters -------
param1                  [4]
param2                  [2]
...


why not having:

...
------- script-name -------
param1                  [4]
param2                  [2]
...


I'd like that. :]

Tried to add tweak 11 (with sets), didn't quite succeed yet (cam doesn't start properly). :I
Maybe I'll try again some other day.

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #20 on: 29 / June / 2008, 23:32:45 »
Tried to add tweak 11 (with sets), didn't quite succeed yet (cam doesn't start properly). :I
Maybe I'll try again some other day.

Arf, I'll do it again directly on the latest SVN, see if I forgot something in my "manual" diff, and provide a true diff.

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #21 on: 30 / June / 2008, 04:21:35 »
Ok, it was just a stupid programmation error. I was using strrchr(fn, '/')+1, so when '/' was not found, strrchr was returning NULL, and I was playing with address 1. When the camera starts the function was called with empty string => buffer overflow sometimes when the resulting string is too long, as I wasn't taking any precaution. So now it's fixed, and I took precautions. Should be ok. I attached the svn-diff (I'm learning...) against juciphox-427 (I also included the script-title menu modification).

Sorry for this...

Offline Jucifer

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 251
  • [A710IS]
Re: My modifications to CHDK
« Reply #22 on: 30 / June / 2008, 10:30:46 »
How about doing save_params_values() (if necessary) when changing sets? (Does the necessity really have to be checked?)

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #23 on: 30 / June / 2008, 14:55:30 »
How about doing save_params_values() (if necessary) when changing sets? (Does the necessity really have to be checked?)

Well, I was trying to limit writing to card, so I didn't want save each time a param is changed. But I missed the "when changing set", you're right. If we raise a flag when the params have changed and only write to the card when the params have changed, it won't write a lot more to the card, and will probably be more intuitive. Good point Jucipher, it's better like that :).

New diff attached. I also save params when a new script is loaded, so there shouldn't be any surprise anymore about whether it saves or not, it always saves :) (except if the camera is shutdown when a param was just modified and the script menu still open, but that's because CHDK doesn't save the values to its config file in this case).

CHDK Forum

Re: My modifications to CHDK
« Reply #23 on: 30 / June / 2008, 14:55:30 »

Offline Jucifer

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 251
  • [A710IS]
Re: My modifications to CHDK
« Reply #24 on: 30 / June / 2008, 15:30:14 »
(Still at least) one little thing:
maybe the set should also be saved after loading default param values.

Now, if you
- switch to a set
- change a param to non-default value
- load default param values
- switch to another set
- and back to the first set,
the param doesn't have the default value

Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #25 on: 30 / June / 2008, 16:47:56 »
Yes, I missed that. That's because when default params are loaded, there is no difference with... what was loaded, so it thinks that params have not changed. Fixed.

Offline Velo

  • Rookie
  • *
  • Posts: 30
Re: My modifications to CHDK
« Reply #26 on: 03 / July / 2008, 22:26:35 »
Oh, concerning the mess in scripts, I had another idea: being able to call scripts from inside scripts. Something like:
script <scriptname> [param1] [param2] ...
Some work to do to save the context (maybe allowing only one degree of inclusion), but it would be more readable and reliable than including them manually, having to change variable names, and propagate changes etc...

Do you know about my Lua patch? There you can define functions in different files and call then after you require'd the file. For require'd files there is also no file size limit of 8 kb. Only for the main file.


Offline cyril42e

  • Full Member
  • ***
  • Posts: 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: My modifications to CHDK
« Reply #27 on: 03 / July / 2008, 22:59:16 »
Do you know about my Lua patch? There you can define functions in different files and call then after you require'd the file. For require'd files there is also no file size limit of 8 kb. Only for the main file.
Yes I heard about it, but haven't tried yet... But this feature is an excellent point in favor of Lua, I will try it soon!

Offline PhyrePhoX

  • Global Moderator
  • Guru Member
  • *****
  • Posts: 2254
  • make RAW not WAR
    • PhyreWorX
Re: My modifications to CHDK
« Reply #28 on: 17 / August / 2008, 01:01:33 »
heya cyril42e, wrote a lil something about your 12th feature here.

just wanted to ask you if you can examine your save params and save sets (ubasic and lua?) functions in order to find some bugs. we have a few user reports that came in claiming that using your feature fubared the cfg file (thus people had to delete it because chdk was behaving mad after a restart, which is understandable if the cfg is fuxxored) - which is why i integrated a switch to enable/disable this feature (as a workaround). maybe you can have a look into this otherwise great feature. seems to happen in big scripts which use a lot of params for example.

thanks in advance, PhoX

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal