root/trunk/chdk/spacebits.lua @ 13

Revision 13, 2.3 KB (checked in by celso, 3 years ago)

CHDK stuff initial commit

  • Property svn:executable set to *
Line 
1--[[
2@title Spacebits flightplan (IXUS100)
3--]]
4
5capmode=require("capmode")
6
7function printf (...)
8        print(string.format(...))
9end
10
11function log_printf (...)
12        print(string.format(...))
13        log:write(os.date(s,tm),": ",string.format(...),"\n")
14end
15
16function spacebits ()
17        while 1 do
18          take_movie(30)
19          take_photo(10)
20          end
21        -- need this to see display if we switched back to play
22        sleep(1000)
23end
24
25function take_photo (n)
26        log_printf("switch photo")
27        set_backlight(0)
28        blink_led()
29        capmode.set(capmode.name_to_mode["LANDSCAPE"])
30        set_backlight(0)
31        sleep(500)
32        -- flash off
33        set_prop(143,2)
34        -- Picture Quality (0,1,2 = Superfine, Fine, Normal)
35        set_prop(57,0)
36        -- Focus Mode (0,1,3,4,5 = Normal, Macro, Infinity, Manual, Super Macro [SX10])
37        set_prop(6,3)
38        for i = 1,n do
39           log_printf("shooting %3d",i)
40           press("shoot_half")
41           sleep(500)
42           press("shoot_full")
43           sleep(1000)
44           set_backlight(0)
45           sleep(4000)
46           set_backlight(0)
47           release("shoot_full")
48        end
49end
50
51function take_movie (secs)
52        log_printf("switch video")
53        set_backlight(0)
54        blink_led()
55        capmode.set(capmode.name_to_mode["VIDEO_STD"])
56        log_printf("set_record true")
57        set_record(true)
58        set_backlight(0)
59        sleep(1000)
60        set_backlight(0)
61        sleep(4000)
62
63        press("shoot_half")
64        press("shoot_full")
65
66        set_backlight(0)
67        log_printf("wait secs")
68        sleep(secs*1000)
69
70-- releasing the video is tricky. sd card may be slow, we must check the status
71
72        release("shoot_full")
73        press("shoot_full")
74        sleep(1000)
75        release("shoot_full")
76
77        log_printf("set_record false")
78        set_record(false)
79
80        log_printf("waiting for cam")
81        rec,vid,mode=get_mode()
82        i=0
83        set_backlight(0)
84        while vid==true and i<10 do
85          rec,vid,mode=get_mode()
86          log_printf("busy, wait %3d", i)
87          sleep(1000)
88          i=i+1
89          end
90        set_record(true)
91        set_backlight(0)
92        sleep(3000)
93end
94
95function blink_led ()
96        for i = 1,5 do
97                 set_led (1,1)
98                 sleep (10)
99                 set_led (1,0)
100                 set_led (2,1)
101                 sleep (10)
102                 set_led (2,0)
103        end
104end
105
106-- main program
107set_prop(105,2)
108log=io.open("A/spacebits.log","ab")
109log_printf("Flight started")
110-- init the loop
111spacebits()
112log_printf("Flight ended")
113log:close()
Note: See TracBrowser for help on using the browser.