You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


OscScope
05-01-2017, 09:33 AM
Post: #1
 (Print Post)
OscScope
Here is small program for fun i have wrote long time ago in Creative Basic:
Code Snippet: [Select]
'Creative Basic/OscScope by Aurel
dim x as int
dim y as int
dim run as int
dim height as int
dim width as int
DEF u,f,fi,s:int
def w1,w2:window
def PI:double
def e,e2,Peak,z:float
def f$,u$tring

WINDOW w1,0,0,600,400,@MINBOX,0,"Grapher",main
Setwindowcolor w1,rgb(180,180,190)

SetFont w1,"Courier New",8,400,0
move w1,10,350
print w1,"http://aurelw.wiz.googlepages.com/aurelsoft"
frontpen w1,rgb(250,250,250)
backpen w1,rgb(140,140,150)
'edit controls
CONTROL w1,"E,Edit1,450,120,70,20,0x50802000,1"
SetFont w1,"MS Sans Serif",8,400,0,1
CONTROL w1,"E,Edit2,450,160,70,20,0x50802000,2"
SetFont w1,"MS Sans Serif",8,400,0,2
'text for controls
move w1,450,105
print w1,"Frequency(Hz)"
move w1,450,145
print w1,"eVoltage(mV)"

CONTROL w1,"B,,450,293,80,22,0x50000001,6"
Setcontroltext w1, 6, "RUN"
SetFont w1,"Tahoma",9,700,0,6

GOSUB display

run=1
Waituntil run=0
Closewindow w1
End
'main loop
SUB main
 Select @class
    case @idclosewindow
        run=0
    case @idcreate
        centerwindow w1

    Case @idcontrol
    case @idcontrol
        IF @controlid=5
            setfocus w1
        Setcontroltext w1,1,str$(f)
        'Setcontroltext w2, 5, getstartpath + "mode1.bmp"
        'Setcontroltext w2, 7, getstartpath + "mode2off.bmp"
        
        Endif

        IF @controlid=6
        'start sim button
        Setfocus w1
        Gosub getnum
        Gosub simulate
        Endif
        
        IF @controlid=7
        Setfocus w1
        'Setcontroltext w2, 7, getstartpath + "mode2.bmp"
        'Setcontroltext w2, 5, getstartpath + "mode1off.bmp"
        Gosub getnum
        Gosub sim2
        Endif
 Endselect
Return
'\\\\\\\\\\\\\\DISPLAY WINDOW\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB display
Window w2,5,5,400,320,@nocaption|@border,w1,"Grapher",main
Setwindowcolor w2,rgb(212,212,212)
'main display panel
Rect w2,0,0,402,290,rgb(143,203,115),rgb(143,203,115)
'button controls
CONTROL w2,"B,,4,294,80,20,0x50000001,5"
Setcontroltext w2, 5, "MODE 1"
SetFont w2,"Courier New",9,400,0,5

CONTROL w2,"B,,94,294,80,20,0x50000001,7"
'Setcontroltext w2, 7, "MODE2"
SetFont w2,"Courier New",9,400,0,7
Setcontroltext w2, 7, "MODE 2"
e=43
PI = 3.141592
s=3
f=s

'display board(down panel)
Rect w2,1,291,396,26,rgb(43,53,115),rgb(143,153,165)
'horizontal lines raster
    For n=9 to 290 step 10
    Line w2,0,n,400,n,rgb(140,190,115)
    Next n
'vertical lines raster
    For n=35 to 400 step 10
    Line w2,n,0,n,290,rgb(140,190,115)
    Next n
'midle line
Line w2,20,140,400,140,rgb(140,86,8)
'count peak of voltage
'Peak = ((1.41 * LOG(e)) / LOG(10)) * PI
Peak = e * 1.4142135
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(0,0,0)
'frames over right uper numbers
Rect w1,448,17,137,20,rgb(72,72,72),rgb(222,222,232)
move w1,450,20
print w1,"                   "              
Rect w1,448,38,137,18,rgb(52,52,52),rgb(222,222,232)
move w1,450,40
print w1,"                   "
Rect w1,448,58,137,18,rgb(52,52,52),rgb(222,222,232)
move w1,450,60
print w1,"                   "
Rect w1,448,78,137,18,rgb(52,52,52),rgb(222,222,232)
move w1,450,80
print w1,"                   "
'main sinus loop
move w2,20,140
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 FOR i = 40 to 400 step 1
       
   y = int(140 + e* SIN(i*( 2*PI) / s))
    line w2,i, y,rgb(0,0,0)
    'print y
    move w1,450,20
    print w1," y = ",(140 + e* SIN(i*( 2*PI) / s)),"  "
    'print freq
    move w1,450,40
    print w1," freq = ",f
    'print Peak
    move w1,450,80
    print w1," peak = ",Peak," mV "
    'print e(voltage mV)
    move w1,450,60
    print w1," e = ",e , " mV "

 NEXT i

'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(182,182,192)

SetFont w2,"Courier New",8,400,0
frontpen w2,rgb(250,250,250)
backpen w2,rgb(140,140,150)
'numbers
    move w2,0,132
    print w2,"-0----"
    move w2,0,82
    print w2," +50--"
    move w2,0,182
    print w2," -50--"
    move w2,0,232
    print w2,"-100--"
    move w2,0,32
    print w2,"+100--"
Return
'////////////// SIMULATION /////////////////////////////////////////
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB simulate
'set butons
'Setcontroltext w2, 5, getstartpath + "mode1.bmp"
'Setcontroltext w2, 7, getstartpath + "mode2off.bmp"
'chek for errors-----------------------------
If val(f$)<1
move w2,100,50
print w2,"   Error,FREQUENCY to Low!        "
move w2,100,64
print w2,"   FREQUENCY Range(1 TO 8000 Hz)  "
Endif
IF val(f$)<1 then return
'--------------------------------------------
If val(f$)>8000
move w2,100,50
print w2,"   Error,FREQUENCY to High!       "
move w2,100,64
print w2,"   FREQUENCY Range(1 TO 8000 Hz)  "
Endif
IF val(f$)>8000 then return
'--------------------------------------------
If val(u$)<1
move w2,100,50
print w2,"   Error,VOLTAGE to Low!          "
move w2,100,64
print w2,"   VOLTAGE Range(1 TO 130 mV)     "
Endif
IF val(u$)<1 then return
'--------------------------------------------
If val(u$)>130
move w2,100,50
print w2,"   Error,VOLTAGE to High!         "
move w2,100,64
print w2,"   VOLTAGE Range(1 TO 130 mV)     "
Endif
IF val(u$)>130 then return
'-------------------------------------------


'main display panel
Rect w2,0,0,402,290,rgb(143,203,115),rgb(143,203,115)

'e=130
PI = 3.141592
's=36
s=f

'display board(down panel)
'Rect w2,1,291,396,26,rgb(43,53,115),rgb(143,153,165)
'horizontal lines raster
    For n=9 to 290 step 10
    Line w2,0,n,400,n,rgb(140,190,115)
    Next n
'vertical lines raster
    For n=35 to 400 step 10
    Line w2,n,0,n,290,rgb(140,190,115)
    Next n
'midle line
Line w2,20,140,400,140,rgb(140,86,8)
'count peak of voltage
'Peak = ((4.44 * LOG(e)) / LOG(10)) * PI
Peak = e * 1.4142135

'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(0,0,0)
'main sinus loop
move w2,20,140
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 FOR i = 40 to 400 step 1
       
       y = int(140 + e* SIN(i*( 2*PI) / s))
       'line w1,i, y,i,y+1
        'RASTERMODE w2, @RMXORPEN
    '    move w2,20,140
        line w2,i, y,rgb(0,0,0)
    'print y
    move w1,450,20
    print w1," y = ",(140 + e* SIN(i*( 2*PI) / s)),"  "
    'print freq
    move w1,450,40
    print w1," freq = ",fi," Hz "
    'print Peak
    move w1,450,80
    print w1," peak = ",Peak, " mV "
    'print e(voltage mV)
    move w1,450,60
    print w1," e = ",e , " mV "

 NEXT i
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(182,182,192)

SetFont w2,"Courier New",8,400,0
frontpen w2,rgb(250,250,250)
backpen w2,rgb(140,140,150)
'numbers
    move w2,0,132
    print w2,"-0----"
    move w2,0,82
    print w2," +50--"
    move w2,0,182
    print w2," -50--"
    move w2,0,232
    print w2,"-100--"
    move w2,0,32
    print w2,"+100--"
Return
'/////////////////////////////////////////////////////////////////////
'////////GET NUMBERS FROM CONTROLS///////////////////////////////////

Sub getnum

f$ = GETCONTROLTEXT (w1, 1)
u$ = GETCONTROLTEXT (W1, 2)
fi=val(f$)
IF val(f$)=0 then return
IF val(u$)=0 then return
'set low range........
IF val(f$)<1200
    f=int(3600/fi)
    move w2,200,295
    print w2,"                   "
    move w2,200,295
    print w2," Low Range 1-1200 Hz "
Endif
'set high range........
IF val(f$)>1200
    f=int(36000/fi)
    move w2,200,295
    print w2,"                   "
    move w2,200,295
    print w2," High Range 1200-8000 Hz "
Endif

e=val(u$)

Return
'///////////////SIMULATE 2////////////////////////////////////////
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SUB sim2
'chek for errors-----------------------------
If val(f$)<1
move w2,100,50
print w2,"   Error,FREQUENCY to Low!        "
move w2,100,64
print w2,"   FREQUENCY Range(1 TO 8000 Hz)  "
Endif
IF val(f$)<1 then return
'--------------------------------------------
If val(f$)>8000
move w2,100,50
print w2,"   Error,FREQUENCY to High!       "
move w2,100,64
print w2,"   FREQUENCY Range(1 TO 8000 Hz)  "
Endif
IF val(f$)>8000 then return
'--------------------------------------------
If val(u$)<1
move w2,100,50
print w2,"   Error,VOLTAGE to Low!          "
move w2,100,64
print w2,"   VOLTAGE Range(1 TO 130 mV)     "
Endif
IF val(u$)<1 then return
'--------------------------------------------
If val(u$)>130
move w2,100,50
print w2,"   Error,VOLTAGE to High!         "
move w2,100,64
print w2,"   VOLTAGE Range(1 TO 130 mV)     "
Endif
IF val(u$)>130 then return
'-------------------------------------------


'main display panel
'Rect w2,0,0,402,290,rgb(143,203,115),rgb(143,203,115)
Rect w2,0,0,402,290,rgb(100,152,165),rgb(100,152,165)
'e=130
PI = 3.141592
's=36
s=f

'display board(doljnji panel)
'Rect w2,1,291,396,26,rgb(43,53,115),rgb(143,153,165)
'horizontal lines raster
    For n=9 to 290 step 10
    Line w2,0,n,400,n,rgb(140,190,115)
    Next n
'vertical lines raster
    For n=35 to 400 step 10
    Line w2,n,0,n,290,rgb(140,190,115)
    Next n
'midle line
Line w2,20,140,400,140,rgb(140,86,8)
'count peak of voltage
'Peak = ((4.44 * LOG(e)) / LOG(10)) * PI
Peak = e * 1.4142135
'efective voltage
e2=e/1.41
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(0,0,0)
'main sinus loop
move w2,20,140
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 FOR i = 40 to 400 step 1
       
       y = int(140 + e* SIN(i*( 2*PI) / s))
       'line w1,i, y,i,y+1
        'RASTERMODE w2, @RMXORPEN
    '    move w2,20,140
        line w2,i, y,rgb(0,0,0)
    'print y
    move w1,450,20
    print w1," y = ",(140 + e* SIN(i*( 2*PI) / s)),"  "
    'print freq
    move w1,450,40
    print w1," freq = ",fi," Hz "
    'print Peak
    move w1,450,80
    print w1," peak = ",Peak, " mV "
    'print e(voltage mV)
    move w1,450,60
    print w1," e = ",e , " mV "

 NEXT i
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(182,182,192)

SetFont w2,"Courier New",8,400,0
frontpen w2,rgb(250,250,250)
backpen w2,rgb(140,140,150)
'numbers
    move w2,0,132
    print w2,"-0----"
    move w2,0,82
    print w2," +50--"
    move w2,0,182
    print w2," -50--"
    move w2,0,232
    print w2,"-100--"
    move w2,0,32
    print w2,"+100--"
'Return
'sinus loop with e2
'left display panel black
Rect w2,0,0,44,290,rgb(142,142,162),rgb(160,0,0)
move w2,20,140
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 FOR i = 40 to 400 step 1
       
       y = int(140 + e2* SIN(i*( 2*PI) / s))
       'line w1,i, y,i,y+1
        'RASTERMODE w2, @RMXORPEN
    '    move w2,20,140
        line w2,i, y,rgb(160,0,0)
    'print y
    move w1,450,20
    print w1," y = ",(140 + e* SIN(i*( 2*PI) / s)),"  "
    'print freq
    move w1,450,40
    print w1," freq = ",fi," Hz "
    'print Peak
    move w1,450,80
    print w1," peak = ",Peak, " mV "
    'print e(voltage mV)
    move w1,450,60
    print w1," e2 = ",e2 , " mV "

 NEXT i
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'left display panel
Rect w2,0,0,44,290,rgb(142,142,162),rgb(182,182,192)

SetFont w2,"Courier New",8,400,0
frontpen w2,rgb(250,250,250)
backpen w2,rgb(140,140,150)
'numbers
    move w2,0,132
    print w2,"-0----"
    move w2,0,82
    print w2," +50--"
    move w2,0,182
    print w2," -50--"
    move w2,0,232
    print w2,"-100--"
    move w2,0,32
    print w2,"+100--"
Return
'///// END SIMULATE 2 /////////////////////////


Attached File(s) Image(s)
   

basicPro forum:
http://basicpro.mipropia.com/smf/index.php
EU Radioboard forum:
http://euradioboard.createmybb3.com/index.php
AurelSoft main site:
http://aurelsoft.ucoz.com
Find all posts by this user
Like Post
The following 2 users Like Aurel's post:
bplus, Waltersmind (Admin)
05-01-2017, 10:31 AM
Post: #2
 (Print Post)
RE: OscScope
Hi Aurel,

So Creative Basic has/had some GUI. Is it still being actively developed?
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Amazon
QB64 Member Project - Othello
QB64 Member Project - Algeria Weather
QB64 Member Project - Quarto
QB64 Member Project - Kings Court
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Spiro Roses
QB64 Member Project - Pivot version two
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Pivet version one
QB64 Member Project - Martin Fractals version two
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Martin Fractals version three
QB64 Member Project - 9 Board
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Blokus
QB64 Member Project - Sabotage
QB64 Member Project - Input
QB64 Member Project - Dreamy Clock
QB64 Member Project - ARB Checkers
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Touche
QB64 Member Project - Rotating Background
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Foursight
QB64 Member Project - Overboard
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Bowditch curve
QB64 Member Project - Swirl
QB64 Member Project - Color Triangles
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Exit
QB64 Member Project - Inside Moves
QB64 Member Project - Score 4
QB64 Member Project - Color Rotating Text
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Domain
QB64 Member Project - Connect Four
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Qubic
QB64 Member Project - Dakapo
QB64 Member Project - Splatter
QB64 Member Project - Basic Dithering
QB64 Member Project - Rubix's Magic
QB64 Member Project - Isolation
QB64 Member Project - Line Thickness
QB64 Member Project - Point Blank
QB64 Member Project - Kings Valley verion one