[futurebasic] suggestion sought

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2011 : Group Archive : Group : All Groups

From: "Edwards, Waverly" <Waverly.Edwards@...>
Date: Sun, 27 Feb 2011 17:50:33 -0600
I am performing a simple experiment where the screen is transparently being flashed at a constant rate.
The content of the screen is always visible by use of an overlay window to cover all or most of the screen.
I am using a carbon timer to drive the flash.  My problem is that the flash does not appear to be consistent.
My goal is to drive the screen flash at a maximum of 22Hz (flashes per second).  My second goal is to have
fractional levels of flashing. 10.5, 11.5, 12.5, etc. Hz.  These are for psychology experiments.  Since a screen
is either on or off, how would I derive a .5 or .75 level flash.  The only way I can imagine being able to deliver
a fractional level of flash is to transparently fill a fractional amount of the screen within an interval period.  
I am having problem with a consistent flash so I'm thinking using a carbon timer is out but what else would 
be a better solution that would not cause the CPU to turn in to a volcano due to overheating.

Any suggestions on how I could provide a stable, consistent, transparent flash of the screen.  Also how I might
deliver a fractional level of flash per second.

The basic idea behind this experiment was drawn from research such as this.  My experiments do not follow
these experiments precisely but are drawn from them.

http://www.biomedcentral.com/1471-2202/7/21


Thanks,


W.

This is not the entire program but the two significant portions.


local fn SimpleFlashScreen( ctx as CGContextRef, scrnRect as ptr to CGRect )
'~'1
gCount++// count how many times we flash

// erase old
CGContextClearRect( ctx, @scrnRect )
CGContextFlush( ctx )
CGContextSetRGBFillColor( ctx, 0.4, 0.4, 1.0, 0.6 ) // Transparent, blue hue
CGContextFillRect( ctx, scrnRect )
fn CGContextFlush( ctx )

long if ( fn PollTime )
// Test, are we flashing at the expected rate?
menu 1,0,_enable,str$(gCount)
gCount = 0
end if

end fn


local fn InitProgram
'~'1
dim as double         freqInHz, interval
dim as CGContextRef   ctx

ctx = fn BuildOverlayWindowCoveringScreen 

freqInHz = 18.5
interval = 1.0 / freqInHz

// use timer to call SimpleFlashScreen
fn InstallCarbonTimer( 0, interval, ctx )

// use polltime to validate we are flashing at the desired rate.
fn SetupPollTime( 1000, _false )// 1 second

end fn