//J A S M I N E C A L I B R A T E get "bcpl.head" //outgoing procedures external JasmineCalibrate //incoming procedures external [ JasmineLoadRam JasmineCoord JasmineScanInit JasmineReadLine JasmineSetDelay //(delay=0 to 15) JasmineSetTime //(ticks = 38usecond units) JasmineSetResolution //(skips=0 to 15) JasmineSetReadMode //readOnly=1, readAndStep=2, readStepAndDelay=3 JasmineSetWindow JasmineScanClose //from GP SetupReadParam;ReadParam //from PressML MulFull;DoubleAddV;MulDiv;DoubleShr ] structure Array : [ pixel^0,1000 byte ] structure JasmineRam : [ blank bit 4 Offset bit 6 Gain bit 6 ] manifest ArraySize = 1024 static [ nAverages=8; A=7;B=8 //threshold for page edge detection mulA=4;mulB=3 //factor for setting gain multiplier ] //calibrate routine returns a block with: // xstart,xlen of page // min,max for 656 time, skip 0 // min,max for 219 time, skip 1 let JasmineCalibrate() = valof [ let resultThingy = table [ 0;0;0;0;0;0] let saved420=@#420 @#420=@saved420 let ramvals = vec ArraySize let block=vec 512*4 let targetGain=0;let targetOffset=0 let ramVal=0; ramVal<>Array.pixel^x ] JasmineScanClose(scanHead) max=0;min=256 for x=0 to ArraySize-2 do //-2 for Prom bug [ let val=(inputArray!x)/nAverages inputArray!x=val if val ls min then min=val if val gr max then max=val ] Ws("Min: ");Wns(dsp,min);Ws(" Max: ");Wns(dsp,max) if targetGain eq 0 then targetGain=max let newCorrection=0 for x=0 to ArraySize-1 do [ let currentVal=(ramvals!x)<>Array.pixel^x if val ls min then min=val if val gr max then max=val ] JasmineSetDelay(15) JasmineSetResolution(0) JasmineSetTime(656) JasmineSetReadMode(2) resultThingy!4=min resultThingy!5=max @#420=saved420 resultis resultThingy ] and abs(x)=(x ge 0)?x,-x (635)\1614b81B