Lua script - enhanced tv mode for all cams

  • 27 Replies
  • 9074 Views
*

Offline msl

  • *****
  • 1172
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
  • Publish
    Lua script - enhanced tv mode for all cams
    « on: 26 / October / 2008, 12:52:02 »
    Advertisements
    This is a little script for a enhanced  tv mode. It should be work for all cams (with or without tv mode).

    You can select a tv value from 64s to 1/10000s.
    You can use the zoom while running the script.
    You can select a focus mode.
    Continuous shooting is possible.

    the console menu:

    [<-][->]  select a tv value
    [UP][DOWN]  zooming
    [DISP.]  select a focus mode
    [SET][Remote]  shooting
    [MENU]  exit

    In the script parameter menu you can adjust the start value of tv, the key delay und the shoot delay.

    Code: (lua) [Select]
    --[[
    @title Tv mode universal
    @param a integer value  [Tv]
    @default a 0
    @param b key delay [ms]
    @default b 80
    @param c shoot delay [s]
    @default c 0
    ]]
     
    function print_Tv()
    tv_output = {"64s","50s","40s","32s","25s","20s","15s","13s","10s","8s","6s",
    "5s","4s","3.2s","2.5s","2s","1.6s","1.3s","1s","0.8s","0.6s","0.5s","0.4s",
    "0.3s","1/4s","1/5s","1/6s","1/8s","1/10s","1/13s","1/15s","1/20s","1/25s",
    "1/30s","1/40s","1/50s","1/60s","1/80s","1/100s","1/125s","1/160s","1/200s",
    "1/250s","1/320s","1/400s","1/500s","1/640s","1/800s","1/1000s","1/1250s",
    "1/1600s","1/2000s","1/2500s","1/3200s","1/4000s","1/5000s","1/6400s",
    "1/8000s","1/10000s"}
    print_tv = "Tv  : "..tv_output[tv_input+19]
    end

    function mf_mode()
    mf_output = {"normal","macro","","infinite"}
    print_mf = "focus: "..mf_output[mf_input]
    end

    function button()
    local x = 0
    repeat
    wait_click(key_delay)
    if is_pressed "remote" then
      key = "SET"
      x = 1
    end
    if is_pressed "set" then
    key = "SET"
    x = 1
    end
    if is_pressed "menu" then
    key = "MENU"
    x = 1
    end
    if is_pressed "display" then
       key = "DISP"
       x = 1
      end
    if is_pressed "left" then
    key = "LEFT"
    x = 1
    end
    if is_pressed "right" then
    key = "RIGHT"
    x = 1
    end
    if is_pressed "up" then
       key = "UP"
       x = 1
      end
      if is_pressed "down" then
       key = "DOWN"
       x = 1
      end
    until  x == 1
    set_led (8,1)
    sleep (10)
    set_led (8,0)
    end

    --script start

    if a < -18 then a = -18 end
    if a > 40 then a = 40 end
    if b < 50 then b = 50 end
    if c < 0 then c = 0 end

    repeat
    if get_mode() == false then
    cls()
    print("No record mode!")
    print("Stop for changing.")
    sleep(3000)
    exit_alt()
    sleep(2000)
    end
    until get_mode() == true

    tv_input = a
    key_delay = b
    shoot_delay = c
    max_zoom = get_zoom_steps()
    zoom = get_zoom()

    repeat
    if get_propset() == 2 then
    mf_input = get_prop(6)+1
    else
    mf_input = get_prop(11)+1
    end
    cls()
    print_Tv()
    mf_mode()
    print("[<-][->]  ",print_tv)
    print("[Up][Down] zoom:",zoom.."/".. max_zoom)
    print("[DISP.]  ",print_mf)
    print("[SET] [Remote]   shoot")
    print("[MENU]           exit")
    button()

    if key == "DISP" then
    mf_input = mf_input + 1
    if mf_input == 3 then mf_input = 4 end
    if mf_input == 5 then mf_input = 1 end
    if get_propset() == 2 then
    set_prop(6,mf_input-1)
    else
    set_prop(11,mf_input-1)
    end
    end
    if mf_input == 2 then
    set_zoom(0)
    else
    if key == "UP"  then
    zoom = zoom + 1
    if zoom > max_zoom then zoom = max_zoom end
    set_zoom(zoom)
    end
    if key == "DOWN" then
    zoom = zoom - 1
    if zoom < 0 then zoom = 0 end
    set_zoom(zoom)
    end
    end
    if key == "RIGHT" then tv_input = tv_input + 1 end
    if key == "LEFT" then tv_input = tv_input - 1 end
    if tv_input > 40 then tv_input = -18 end
    if tv_input < -18 then tv_input = 40 end
    if key == "SET" then
    if shoot_delay > 0 then
    cls()
    print("wait "..shoot_delay.." s")
    sleep(shoot_delay * 1000)
    end
    TV = tv_input * 32
    press "shoot_half"
    repeat
          until get_shooting() == true
    if get_propset() == 2 then
    set_prop(262,TV)
    else
    set_prop(69,TV)
    end
    press "shoot_full"
    release "shoot_full"
    release "shoot_half"
    end
    until key == "MENU"

    Edit: A little bit safer, using only in record mode possible. You need a new CHDK version rev. 545
    « Last Edit: 28 / October / 2008, 07:02:55 by msl »
    German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
    Note: SDM violates the GPL rules!

    *

    Offline fe50

    • ******
    • 3033
    • IXUS50 & 860, SX10 Star WARs-Star RAWs
      • fe50
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #1 on: 26 / October / 2008, 16:57:27 »
    Works fine on SD870 1.00C, great job !

  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #2 on: 26 / October / 2008, 21:11:30 »
    Sounds cool, and can be really useful.

    When I run it this is all I see:

    uBASIC:1 Unk stmt

    Copied directly from this post and saved as-is. I've done this with dozens of other scripts that did work, so that's not the problem.

    It's erroring out on this (apparently) Lua line:

    --[[


    *

    Offline reyalp

    • ******
    • 9803
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #3 on: 26 / October / 2008, 21:32:22 »
    It's a lua script, not a ubasic script. Either you've renamed to something other than .lua, or your are running a really old build that doesn't have lua support.
    Don't forget what the H stands for.


  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #4 on: 27 / October / 2008, 03:56:47 »
    First ran it on Juciphox build 543, then tried it on build 544 downloaded tonight. Same thing.

    Oh well. So much for "lua" being helpful.


    *

    Offline reyalp

    • ******
    • 9803
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #5 on: 27 / October / 2008, 04:07:52 »
    First ran it on Juciphox build 543, then tried it on build 544 downloaded tonight. Same thing.
    Then you didn't correctly name it with a .lua extension.
    Don't forget what the H stands for.

    *

    Offline msl

    • *****
    • 1172
    • A720 IS, SX220 HS 1.01a
      • CHDK inside
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #6 on: 27 / October / 2008, 04:19:09 »
    ... or you use the attachment of the first posting in this thread.
    German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
    Note: SDM violates the GPL rules!

    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #7 on: 27 / October / 2008, 04:20:04 »
    ... or you didn't use a 'compile complete' build - check if your CHDK/LUALIB folder is present

    wim


  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #8 on: 27 / October / 2008, 05:02:56 »
    First and subsequent attempts: script filename = enhanced_tv_mode.lua

    CHDK/LUALIB/ Folder and files, present and accounted for.

    Used both the posted version (copy paste method) and attachment.

    Results: "uBASIC:1 Unk stmt"

    As I said, Oh well.



    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: Lua script - enhanced tv mode for all cams
    « Reply #9 on: 27 / October / 2008, 05:11:51 »
    trying with an 8.3 name might help (yours is 16.3 , and CHDK, especially with dryos, is not windows !)

    (edit: can't check on dryos, but long name lua scripts do work OK on VxWorks, tested on a620)

    wim
    « Last Edit: 27 / October / 2008, 06:26:55 by whim »

     

    Related Topics