#!/bin/bash# delay (in seconds) between shots, not including time spent in command + file transfer# This must be long enough to allow JPEG writing to finishdelay=300zoom=0path=/home/pi/photoslogfile=$path/log-`date +'%F'`.logCHDKPTP_DIR=/home/pi/chdkexport LUA_PATH="$CHDKPTP_DIR/lua/?.lua"CHDK=$CHDKPTP_DIR/chdkptpecho "Backlight off"#$CHDK -c -e"luar return get_buildinfo()"$CHDK -c -e"luar set_backlight(0)"sleep 5datum_x=`date +'%F_%I-%M'`function log {curenttime_x=`date +"+%Y-%m-%d %H:%M:%S"`echo "$curenttime_x - $1 $2 $3 $4 $5 $6 $7 $8 $9" >> $logfileecho "$curenttime_x - $1 $2 $3 $4 $5 $6 $7 $8 $9"}take_photo(){ echo "Shooting" $CHDK -c -erec -e"luar set_zoom($zoom)" echo "rec mode" #LUMI=`$CHDK -c -e"luar press(\"shoot_half\") repeat sleep(50) until get_shooting() == true release(\"shoot_half\") repeat sleep(50) until get_shooting() == false return get_bv96()" | cut -d: -f3` log "Shooting" $CHDK -c -eshoot LUMI=`$CHDK -c -e"luar return get_bv96()" | cut -d: -f3` log "Luminance: "$LUMI" / 400" if [ $LUMI -gt 400 ] then sleep 2 copy_image fi $CHDK -c -eplay echo "play mode" sleep 2 $CHDK -c -e"luar set_backlight(0)"}copy_image(){ latest=`$CHDK -c -e"luar return string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count())" | cut -d: -f3` $CHDK -c -e"d $latest $path" latest=$latest | cut -d\> -f1 log "Saved "$latest}# transfer latest image from cameraremove_latest_images(){ #-e"mdl -fmatch=%.JPG$ DCIM $path" $CHDK -c -e"rm -nodirs -fmatch=%.JPG$ DCIM"}while [ "$quit" != "1" ]; do take_photo echo "sleeping, press q to exit" read -t $delay -n 1 key if [ "$key" == "q" ]; then quit=1 log "Exiting, but first cleaning up..." fi VBatt=`$CHDK -c -e"luar return get_vbatt()" | cut -d: -f3` #If less than 100 photos space, clear. Should help with wear on SD card not doing it every time if [ `$CHDK -c -e"luar return get_jpg_count()" | cut -d: -f3` -lt 100 ] then echo "mem full - deleting" remove_latest_images log "Cleared images. Battery level: "$VBatt fi if [ $VBatt -lt 3300 ] then log "************* WARNING: Battery Low! ***************" fidonelog "Turning backlight on"$CHDK -c -e"luar set_backlight(1)"log "done."
Or maybe my camera has newer firmware than was ported for...
1. Reset command seems to crash camera (powers off) - I put this first since having it available would be a workaround for other bugs
2. When I leave the timelapse script running, after 30 shots or so, shoot() stops working. Nothing is saved; get_exp_count doesn't increase. I had my script doing a press("shoot_half") repeat sleep(50) until get_shooting() but it kept getting stuck there after so many shots - it seems the camera is unwilling to lock focus.
Or the button presses and shoot command are not getting through. When I look at the camera once it's in this state, it seems like the shutter button presses are reaching the ALT mode screen instead of actually shooting.
3. RemoteShoot works fine (as long as camera not in the state as mentioned above) but on entering play mode the camera crashes. Powering back on is the only solution.
Excellent, thanks for responding. Nice to know it's not just me being a noob. I'll try the set_focus idea, or in P mode. Maybe that'll help. It's on a tripod pointing out of a window; so the only thing changing is the light as it gets dark. But perhaps it's trying to focus on the glass, though, if it sees its own reflection or something.
I tried the 1.3 build but that crashes after shoot when returning to play mode.
I'll stick with 1.2 since I'm almost there with the script. I looked into set_resolution, too, but gave up with that. I managed to do a set prop but the camera seemed to ignore the setting. Might end up clicking buttons if I can get it predictable.
I think P mode should help with the shoot failing, but the shots might be out of focus if it's refusing shoot because it can't find anything to lock on.
In 1.2, I think set_focus will only work if you use set_aflock() and set propcase AF_LOCK to 1, or set AF lock manually in the canon UI.
con 2673> luar release("shoot_half") con 2674> playcon 2675> reccon 2676> luar return set_prop(11,1)con 2677> luar return set_focus(50)con 2678> luar set_aflock(1)con 2679> luar return get_focus()2680:return:-1con 2680> luar return set_focus(50)con 2681> luar return get_focus()2682:return:-1con 2682> shoot con 2683> luar return get_focus()2684:return:-1con 2684> luar return set_focus(95)con 2685> shootcon 2686> luar return get_focus()2687:return:-1con 2687> luar return set_focus(95)con 2688> luar set_aflock(1)con 2689> shootcon 2690> luar return get_focus()2691:return:2846con 2691> luar return get_exp_count()2692:return:415con 2692> shootcon 2693> luar get_exp_count()con 2694> luar return get_exp_count()2695:return:415con 2695> luar set_focus(2846)con 2696> luar set_aflock(1)con 2697> shootcon 2698> luar return get_focus()2699:return:4486con 2699> luar return get_exp_count()2700:return:415con 2700> luar press("shoot_half")con 2701> luar return get_shooting()2702:return:falsecon 2702> luar release("shoot_half")con 2703> luar return get_focus()2704:return:4486con 2704> luar set_focus(5000)con 2705> luar set_aflock(1)con 2706> luar return set_prop(11,1)con 2707> shootcon 2708> luar return get_focus()2709:return:3469con 2709> luar return get_exp_count()2710:return:415
After some extensive debugging on IRC, the root cause appears to be the alt state getting confused, which causes shoot to fail. The "confused" state involves the alt OSD being displayed, but key presses going to the original canon firmware (and chdk?), and scripted presses of shoot etc not going to the canon firmware.Using enter_alt() before running the shooting sequence appears to avoid this.
$CHDK -c -erec -e"luar set_zoom($zoom)" -e"luar press(\"shoot_half\")" sleep 1 shooting=`$CHDK -c -e"luar return get_shooting()" | cut -d: -f3` if [ shooting == 'false' ] then $CHDK -c -e"luar enter_alt()" log "---- ALT mode confused; resetting" $CHDK -c -e"luar exit_alt()" fi
I confirmed on my 100a camera that reboot crashes without a romlog
Started by GrAnd Forum related topics (including issues)
Started by chr DryOS Development
Started by jonasr Script Writing
Started by unknowjuzam General Help and Assistance on using CHDK stable releases
Started by koshy General Discussion and Assistance