Canon G9 - I am not able to disable the flash - Script Writing - CHDK Forum

Canon G9 - I am not able to disable the flash

  • 2 Replies
  • 4219 Views
Canon G9 - I am not able to disable the flash
« on: 14 / February / 2015, 04:10:42 »
Advertisements
I am using a script on the Canon G9 to capture weather data every minute.

But at night it flashes every minute - even though I thought I have disabled it.

My Script it here

Code: [Select]
--[[
@title Timelapse for Chris
@param s Sleep Duration
@default s 60000

@param    b Zoom Step (0=none)
 @default b 0
 @range   b 0 500
@param    w Focus @ Infinity?
 @default w 1
 @range   w 0 1
@param    m Status LED
 @default m 0
 @values  m Off 0 1 2 3 4 5 6 7 8
]]

counter = 0
zoom_setpoint = b
status_led = m-1
log_mode = t
focus_at_infinity =  w   
led_state = 0
led_timer = 0
now = get_day_seconds()
timestamp = 86401
   
require("drawings")
props=require("propcase")

function update_zoom()
   if ( zoom_setpoint > 0 ) then
       zsteps=get_zoom_steps()
       if(zoom_setpoint>zsteps) then zoom_setpoint=zsteps end
--       printf("set zoom to step %d of %d",zoom_setpoint,zsteps)
       sleep(2000)
       set_zoom(zoom_setpoint)
       sleep(2000)
    end
end

function led_blinker()
    if ( status_led > -1 ) then
        local tk = get_tick_count()
        if ( tk > led_timer ) then
            if ( led_state == 0 ) then
                led_state = 1
                led_timer= tk + 200
            else
                led_state = 0
                if (error_mode == 0) then
                    led_timer= tk + 2000
                else
                    led_timer= tk + 500
                end
            end
            set_led(status_led,led_state)
        end
    end
end

function camera_reboot()
    print("Reboot countdown")
    local ts=70
    repeat
        ts=ts-1
        sleep(1000)
    until ( ts == 0)
    set_autostart(2)   -- autostart once
    sleep(2000)
    reboot()
end

function check_SD_card_space()
  local z=(get_free_disk_space()*100)/get_disk_size()
  if (z<5) then error_mode=1 end
  return( z )
end

function TakePicture()
print ("Capture #",counter)

StartTick = get_tick_count()

press("shoot_half")
    repeat sleep(50) until get_shooting() == true
press("shoot_full")
release("shoot_full")
repeat sleep(50) until get_shooting() == false
    release "shoot_half"

EndTick = get_tick_count()

-- sleep for 60 seconds - the amount of time waiting + camera time
delay = s - (EndTick - StartTick)
-- Minimum sleep of 1 second
if (delay < 1000) then
delay = 1000
end
sleep(delay)
end

function DeleteFiles(Path)
  for fname in os.idir(Path, false) do
t =os.stat(Path .."/"..fname)
if (os.difftime(os.time(),t.mtime) > 120) then
os.remove(Path .."/"..fname)
print ("Delete "..fname)
end
  end
end


function UpdateCounter()
if (counter > 3) then
set_lcd_display(0)
end   
counter = counter + 1
end

function CheckForRebootConditons()
now = get_day_seconds()
print(now .." seconds")
if ( now < timestamp ) then
camera_reboot()
end
timestamp=now
end

function SetupCamera()
-- disable flash, image stabilization and AF assist lamp
set_prop(props.FLASH_MODE, 2)     -- flash off
set_prop(props.IS_MODE, 3)        -- IS_MODE off
set_prop(props.AF_ASSIST_BEAM,0)  -- AF assist off if supported for this camera
set_prop(props.QUALITY,0)   -- Set JPG Quality


update_zoom()

timestamp=now
end

function DeleteOldPhotos()
DeleteFiles("A/DCIM/100CANON")
DeleteFiles("A/DCIM/101CANON")
end

sleep(1000)

SetupCamera()

print ("Camera Setup")
repeat
UpdateCounter()
CheckForRebootConditons()
TakePicture()
DeleteOldPhotos()
-- blink status LED  - slow (normal) or fast(error or SD card full)
led_blinker()
    collectgarbage()
until false

The script seems to work fine for me, but at night the flash goes off.

Any ideas of why the flash code is not working for me?

In my setup routine I am using

   set_prop(props.FLASH_MODE, 2)     -- flash off


But it does not work, infact it seems to set it to on not off.

Chris

Re: Canon G9 - I am not able to disable the flash
« Reply #1 on: 14 / February / 2015, 11:04:04 »
Apparently this thread continues from here :  http://chdk.setepontos.com/index.php?topic=12212.0


The script seems to work fine for me, but at night the flash goes off. Any ideas of why the flash code is not working for me?

You seem to be doing the right thing using
Code: [Select]
   set_prop(props.FLASH_MODE, 2)     -- flash offI tested your script on my G10 and it disables the flash properly.  So there may be a bug in the G9 code.

Or a remote chance that the value for FLASH_MODE in props=require("propcase") is wrong for the G9?  This seems unlikely as it is 143 for every propset except propset 1.

What happens if you disable the flash using the Canon keys (the lightning symbol on the jog dial on the back of the camera) ?

Another long shot - do you have anything inserted in the G9's hot flash hot shoe?  Even a blank cover?  That can cause problems if so.  There is a menu item in the Enhanced Photo Operations menu that will let you disable the switch in the hot shoe (in case it is broken and stuck in the "on" position).

« Last Edit: 14 / February / 2015, 11:34:46 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Canon G9 - I am not able to disable the flash
« Reply #2 on: 14 / February / 2015, 19:08:51 »
Hi

I did try to manually disable the flash using the keys and then go back to CHDK and start the script but it still flashed all night. Now I did this with a previous script and it did not flash all night. The difference was I was not using the

set_prop(props.FLASH_MODE, 2)     -- flash off

There is nothing in the hot shoe.

I am running the latest firmware for the camera.

I might play around with the values and see if there is a difference for props.FLASH_MODE

Chris
« Last Edit: 14 / February / 2015, 19:11:02 by iisfaq »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal