' BitWhackerUBW FlashOutPins12 nomainwin UpperLeftX = 10 UpperLeftY = 20 WindowWidth = 850 WindowHeight = 520 dim pattern( 5000) global i$, k, tt, x, hdc, p tt = 50 k = 0 x = 0 textbox #w.t, 40, 20, 350, 80 textbox #w.t2, 40, 320, 100, 20 graphicbox #w.g, 40, 120, 750, 60 graphicbox #w.g2, 40, 240, 750, 20 statictext #w.st1, "Scaled text in font ", 40, 210, 350, 30 open "Timed sequencing of UBW output pins by examining pixels of text." for graphics as #w fontdialog "courier_new 12 bold", chosenFont$ ' Provides fontname, size, attributes if chosenFont$ = "" then chosenFont$ ="courier_new 6 12 bold" if instr( chosenFont$, "bold") then b$ =" bold" else b$ =" " if instr( chosenFont$, "italic") then i$ =" italic" else i$ =" " open "user32" for dll as #user32 h = hwnd( #w.g2) calldll #user32, "GetDC", h as long, hdc as long #w "trapclose [quit]" #w.t "!font courier_new bold 48" open "COM6: 9600, 8, N, 1, RS, DS0, CS0" for random as #c #c "c,0,0,0,0" #w.g, "down ; size 2 ; color yellow ; fill black ; flush" #w.st1, "Scaled text in font " +word$( chosenFont$, 1) +" 6 12" +i$ +b$ #w.g2, "font " +word$( chosenFont$, 1) +" 6 12" +i$ +b$ #w.g2, "down" #w.g2 "place 2 12" #w.g2, "\John0123456789abcdefghijklmnopqrstuvwxyz" timer tt, itHappened wait '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' [quit] #w.g, "flush" timer 0 open "flashdata.dat" for binary as #h for kj =0 to 200 print #h, chr$( pattern( kj) ); next kj close #h prompt "Close or ump"; answer$ if answer$ ="D" then open "flashdata.dat" for binary as #h line input #h, i$ for h =1 to 100 for hh =1 to len( i$) i1$ =mid$( i$, hh, 1) #c "O,0"; ","; i1$; ",0" next hh next h close #h end if print "Closing com port & window" #c "O,0,0,0" close #user32 close #w close #c end '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' sub itHappened timer 0 i$ ="" for jk =1 to 8 i =getPixel( x, 12 -1 *jk) if i <4 then i$ =i$ +"1" else i$ =i$ +"0" next jk x =x +1 if x >200 then x =200 #w.t, i$ i =binToDec( i$) #w.t2, x; " "; i pattern( x) =i #c "O,0"; ","; str$( i); ",0" for kk =1 to 8 if mid$( i$, kk, 1) ="1" then #w.g, "set "; k; " "; 50 -4 *kk next kk k =k +4 timer tt, itHappened end sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' function binToDec( inp$) v =0 for j =1 to 8 v =v *2 v =v +val( mid$( inp$, j, 1)) next j binToDec =v end function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' function getPixel( xp, yp) open "gdi32" for dll as #gdi calldll #gdi32, "GetPixel", hdc as ulong, xp as ulong, yp as ulong, p as ulong close #gdi CallDll #user32, "ReleaseDC", hw as word, hdc as word, result as ushort r =int( p /256 /256) p =p -r *256 *256 g =int( p /256) b =p -g*256 getPixel =int( ( r +g +b) /3) end function