Hello Mark and Team,
Thank you.
I always enjoying with BASCOM-AVR and more looking for the BASCOM-ARM .
I downloaded new version and tested the multi dimensional array function.
I tried,
$regfile = "m32def.dat"
$crystal = 4000000
$hwstack = 40
$swstack = 16
$framesize = 32
$sim
Dim A(3, 3) As Byte
Dim I As Byte , J As Byte , K As Byte
'
For I = 1 To 3
For J = 1 To 3
K = I : K = K * 10 : K = K + J
A(i , J) = K
Print "I=" ; I ; ", J=" ; J ; ", k= " ; K ;
Print ", A(" ; I ; "," ; J ; ")=" ; A(i , J) ; " ";
Next J
Print
Next I
'
End
expecting results are,
[b:4b66b933ee][size=12:4b66b933ee]I=1,J=1,k=11, A(1,1)=11 I=1,J=2,k=12,A(1,2)=12 I=1, J=3, k= 13, A(1,3)=13
I=2,J=1,k=21, A(2,1)=21 I=2,J=2,k=22,A(2,2)=22 I=2, J=3, k= 23, A(2,3)=23
I=3,J=1,k=31, A(3,1)=31 I=3,J=2,k=32,A(3,2)=32 I=3, J=3, k= 33, A(3,3)=33 [/size:4b66b933ee][/b:4b66b933ee]
but, actual results are,
[b:4b66b933ee][size=12:4b66b933ee]I=1,J=1,k=11, A(1,1)=11 I=1,J=2,k=12,A(1,2)=11 I=1, J=3, k= 13, A(1,3)=11
I=2,J=1,k=21, A(2,1)=21 I=2,J=2,k=22,A(2,2)=21 I=2, J=3, k= 23, A(2,3)=21
I=3,J=1,k=31, A(3,1)=31 I=3,J=2,k=32,A(3,2)=31 I=3, J=3, k= 33, A(3,3)=31 [/size:4b66b933ee][/b:4b66b933ee]
I think, the multi dimensional array varialbles missing some values.
Please check and fix it.
Best Regards from Korea,
[size=12:4b66b933ee]Inkni Kim[size=18][/size:4b66b933ee][/size]
↧
BASCOM-AVR : 2078 : REPLY
↧
BASCOM-AVR : 2078 : REPLY
Hi Kim,
I've had a look at your problem (I really Need multi dimensional arrays for a Project I'm working on) and it looks if the problem is with the print function.
If I modify your code so that the array element is read into a variable, then printed it works (not nice but it works).
[code:1:e970917e93]
$regfile = "m32def.dat"
$crystal = 4000000
$hwstack = 40
$swstack = 16
$framesize = 32
$sim
Dim A(3, 3) As Byte
Dim I As Byte , J As Byte , K As Byte , Z As Byte
'
For I = 1 To 3
For J = 1 To 3
K = I : K = K * 10 : K = K + J
A(i , J) = K
Z = A(i , J)
Print "I=" ; I ; ", J=" ; J ; ", k= " ; K ;
Print ", A(" ; I ; "," ; J ; ")=" ; A(i , J) ; "/" ; Z
Next J
Next I
'
End
[/code:1:e970917e93]
Output
I=1, J=1, k= 11, A(1,1)=11/11
I=1, J=2, k= 12, A(1,2)=11/12
I=1, J=3, k= 13, A(1,3)=11/13
I=2, J=1, k= 21, A(2,1)=21/21
I=2, J=2, k= 22, A(2,2)=21/22
I=2, J=3, k= 23, A(2,3)=21/23
I=3, J=1, k= 31, A(3,1)=31/31
I=3, J=2, k= 32, A(3,2)=31/32
I=3, J=3, k= 33, A(3,3)=31/33
Regards
Ian Dobson
↧
↧
BASCOM-AVR : 2078 : REPLY
Hi Dobson,
Thank you for your reply.
I checked your code.
You are right !
Multi dimentional Arrays work very well.
This is good news for me.
I too really need this fuctions like you.
Thanks again
Regards
Inkni Kim
↧
BASCOM-AVR : 2078 : REPLY
Hello inkni & i.dobson
What would be good is when you make use of the multi dimensional array you could make some examples so others like myself can see how to use them.
Regards Paul
↧
BASCOM-AVR : Dim R1 as Single = Error : REPLY
in version 2.0.7.1 I tested your code and it works no problem !!!!!!
↧
↧
KokkeKat FAT-free SD card lib : Sdcreatefileordir problems.. : REPLY
Hi Svein,
My first guess is that it's Window's file system caching that's causing problems for you. After you have formatted the card, shut down the PC, take out the card, boot the PC, run your AVR program, and then insert it into the PC.
Verify that Sdentrynames is exactly 11 characters.
If this doesn't solve the problem, I'm afraid I will have to ask you to read the pdf document in the download zip file and the sticky threads in this forum.
Also, compare the example code files to your own code.
Thanks for pointing out the 1024 and 512 discrepancy. This looks like a typo.
Best regards
Niclas
↧
BASCOM-AVR : ESP8266 WIFI to serial board gets NTP time : NEWTOPIC
Hello friends,
Here a first try with my newest little toy. this thing is so simple, even I can write some code for it to get it going :D
There is no code for when something goes wrong in the communication. (when the NTP server says huh?, the program stops)
but for a quick try out this does the thing.
My xmega's internal clock is waaay to fast (several minutes every hour) . so I have to come up with a solution to slow it down
Have fun!
Wilfred.
' ESP8266 pinout
' top view
' CH_PD to GND to activate (Chip powers down (when high))
'
' _ _ _ ________
' | |_| |_| |_| antenna on top
'
' GND GPIO2 GPIO0 RX
' | | | |
'
' | | | |
' TX CH_PD RST Vcc
'
'VCC=3.3V !
$regfile = "xm128a3udef.dat"
$crystal = 32000000
$hwstack = 64
$swstack = 40
$framesize = 64
Const Ssid = "Your ssid"
Const Passwort = "your password"
Const Offset_gmt = 3600 'in seconds. I live in GMT+1
Dim Sec_to_ntp_update As Integer
Config Osc = Enabled , 32mhzosc = Enabled ' enable 2 MHz and 32 MHz internal oscillators
'Select the oscillator source for the system clock and prescaler (this must match with $crystal = XXXXXX).
'The following configure the internal 32MHz oscillator as system clock without prescaler so the system
'clock is 32MHz which Match With $crystal = 32000000
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
$lib "datetime.lbx"
$lib "xmega.lib" : $external _xmegafix_clear : $external _xmegafix_rol_r1014
'First Enable The Osc Of Your Choice , make sure to enable 32 KHz clock or use an external 32 KHz clock
Config Osc = Enabled , 32mhzosc = Enabled , 32khzosc = Enabled
'For the CLOCK we use the RTC so make sure the 32 KHZ osc is enabled!!!
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Clock = Soft , Rtc = 1khz_int32khz_ulp , Gosub = Sectic ' we select the internal 1 KHz clock from the 32KHz internal oscillator
Config Priority = Static , Vector = Application , Lo = Enabled ' the RTC uses LO priority interrupts so these must be enabled !!!
' COM1 --> Usartc0 --> RX=pc2(pin18) TX=pc3(pin19)
Config Com1 = 9600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM1:" For Random As #1
'pin nummer 40 41 42 43 39 38
Config Lcdpin = Pin , Db4 = Porte.4 , Db5 = Porte.5 , Db6 = Porte.6 , Db7 = Porte.7 , E = Porte.3 , Rs = Porte.2
Config Lcd = 16 * 2
Config Pina.2 = Output
Led1 Alias Porta.2
Config Date = Dmy , Separator = Minus
Dim Rxstring As String * 100
Dim Check As Bit
' Ntp Stuff
Dim Tt(4) As String * 1
Dim Ss(4) As Byte
Dim L1 As Long At Ss Overlay ' Overlay a long variable to receive-string
Dim L2 As Long ' with overlay you need no transfer from the byte-array to a long-variable
Dim Sec_passed As Bit
Declare Sub Init_esp8266
Declare Sub Ntp
Declare Sub Wait_for_string(byval B As String)
Declare Function Read_string() As String
Enable Interrupts
'==================================================================================
'init
Sec_to_ntp_update = 600
Cls
Locate 1 , 1 : Lcd "init ESP"
Init_esp8266
Locate 1 , 1 : Lcd "Getting NTP time"
Ntp ' we don't have the correct time so lets start with that
Cls
Do
If Sec_to_ntp_update = 0 Then ' update time every hour
Ntp
Sec_to_ntp_update = 600
End If
Locate 1 , 9 : Lcd Time$
Locate 2 , 9 : Lcd Date$
Locate 1 , 1 : Lcd Sec_to_ntp_update
Loop
Sectic:
Set Sec_passed
Decr Sec_to_ntp_update
Return
'*********************** Ask Time From Timeserver Esp8266: ******************************************
Sub Ntp
Print "AT+CIPMUX=1"
Waitms 100
Print "AT+CIPSTART=1," ; Chr(34) ; "UDP" ; Chr(34) ; "," ; Chr(34) ; "193.67.79.202" ; Chr(34) ; ",37"
Waitms 100
Print "AT+CIPSEND=1,3"
Waitms 100
Print "X" 'send capital X to ntp server and you obtain the time
Do
Wait_for_string ":" 'behind the : will be the time.... 4 bytes
Reset Check
Rxstring = Read_string()
Wait_for_string "OK" 'reply from ESP8266
Loop Until Check = 1 'check is set in wait_for string
Reset Check
Tt(1) = Mid(rxstring , 4 , 1) 'from big endian to little endian
Tt(2) = Mid(rxstring , 3 , 1) 'swap the bytes
Tt(3) = Mid(rxstring , 2 , 1)
Tt(4) = Mid(rxstring , 1 , 1)
Ss(1) = Asc(tt(1)) 'this is L1 split in 4s by overlay
Ss(2) = Asc(tt(2))
Ss(3) = Asc(tt(3))
Ss(4) = Asc(tt(4))
L2 = L1 + 1139293696
L2 = L2 + Offset_gmt
Time$ = Time(l2) 'set the time
Date$ = Date(l2) 'set the date
Do
Wait_for_string "SEND OK" 'reply from ESP8266 if all went well
Loop Until Check = 1
Print "AT+CIPCLOSE=1"
End Sub
'*******************************************************************************************************
Sub Init_esp8266
'init the ESP8266
'AT+RST
'At + Cwlap
'At + Cwjap = "SSID" , "PASSWORD"
'At + Cipmux = 1
'At + Cwmode = 3
'At + Cipserver=1,23
Print "AT+RST" 'reset the ESP8266
Do
Wait_for_string "ready" 'reply from ESP8266
Loop Until Check = 1
Reset Check
Print "AT+CWJAP=" ; Chr(34) ; Ssid ; Chr(34) ; "," ; Chr(34) ; Passwort ; Chr(34)
Do
Wait_for_string "OK" 'reply from ESP8266
Loop Until Check = 1
Reset Check
Print "AT+CIPMUX=1"
Waitms 100 'the answer here is "link is builded" but i don't know if that's changed in another version
Print "AT+CWMODE=3"
Waitms 100
Print "AT+CIPSERVER=1,23"
Do
Wait_for_string "OK" 'reply from ESP8266
Loop Until Check = 1
Reset Check
End Sub
'*******************************************************************************
Sub Wait_for_string(byval B As String) As String
Local Ii As Byte
Local Cc As Byte
Ii = 1
M1:
Cc = Inkey()
If Cc <> Mid(b , Ii , 1) Then
Goto M1
Else
Incr Ii
If Ii > Len(b) Then Goto M2
Goto M1
End If
M2:
Set Check
End Sub
'*******************************************************************************
Function Read_string() As String
Local Cc As Byte
Local Sss As String * 100
Local Stringlen As Integer
Sss = ""
While Cc <> Chr(13)
Cc = Inkey()
If Cc = Chr(10) Then Cc = " "
Sss = Sss + Chr(cc)
Wend
Stringlen = Len(sss) - 1
Read_string = Left(sss , Stringlen)
End Function
End[/code]
[b:ec8f6022d4][color=red:ec8f6022d4](BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 )[/b:ec8f6022d4][/color:ec8f6022d4]
↧
BASCOM-AVR : redefining interupt service routines : NEWTOPIC
Hi,
I can't figure out how to do the following:
I have a few (typically 10) [b:da7c7bedb8]very[/b:da7c7bedb8] time critical interrupt service routines. For example let's have these two: isr_200ns and isr_500ns.
Their content is very simple:
isr_200ns:
PORTD.7=1
NOP
PORTD.7=0
return
isr_500ns:
PORTD.7=1
NOP
NOP
PORTD.7=0
return
Now, depending on the value of a certain variable A (e.g. a switch setting) I want to choose which of this isr's is active, so e.g.:
if A=1 then
on int0 isr_200ns
else
on int0 isr_500ns
end if
When compiling I get the error that the ISR is already defined. Why shouldn't it be possible to change isr's during runtime? Or does it have to do with the labels and should I (re)define the isr's in another way? Anybody have a suggestion on how to get this to work? I really can't change the content of the isr's and e.g. do the switching there because as I said they are very time critical.
All help is very much appreciated!
best,
Marc
[b:da7c7bedb8][color=red:da7c7bedb8](BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 )[/b:da7c7bedb8][/color:da7c7bedb8]
↧
BASCOM-AVR : redefining interupt service routines : REPLY
[quote:3e931182ae="marckyh"]Why shouldn't it be possible to change isr's during runtime?[/quote:3e931182ae]
Because the interrupt vector address is calculated by the compiler an written into the interrupt vector table.
Both, ISR and IVT reside in flash and can't thus be changed in runtime.
I doubt that an additional branch within the ISR will mess up the timing.
↧
↧
BASCOM-AVR : redefining interupt service routines : REPLY
marckyh,
This can be made easy with a little ASM code, then you must use NOSAVE option on interrupt, and you must save the registers you will use; then you must verify the value of the variable and jump to the correct code acordly the variable contents.
Paulo
↧
BASCOM-ARDUINO : ILI9327 on Arduino Mega : REPLY
hi, Ben,
Thanks for this code, and happy New Year too !
Paulo
↧
BASCOM-AVR : redefining interupt service routines : REPLY
Assuming you do not use the NOSAVE option when defining the IRQ, you already waste around 100 clock cycles while Bascom saves most of the registers, does your ( admittedly simple ) code, and then recovers the registers. You can damatically reduce the IRQ service time by using ASM to do the actual operation, only saving the couple of registers you actually use, and then you have plenty of time to do the couple of additional compares to check which piece of code you actually use in the ISR, based on what flags are set in the main progrm.
Something like:[code:1:9a4b765a45]
dim A as byte 'use a byte for flag
on int0 gosub int0_isr nosave 'define ISR, tell Bascom not to save any regs
'in main
A = 1 'set the flag value
'in the ISR
#asm 'use asm
int0_isr:
push r16 'save used reg
in r16,sreg 'ALWAYS save sreg !!!
push r16
lds r16,{A} 'get value of A from main
tst r16 'sets processor flags based on value in r16, in particular Z flag if A was zero
sbi portd,7 'set bit in portd.7
breq t200_ns 'branch around extra delay code based on Z flag, 1 clock if branch not taken, 2 if is
'else use longer delay
nop 'each nop is 1 clock, add more for a longer delay
'for even longer delays, set a value in r16 and count it down to zero in a loop
'you could even use the value of A passed as a delay counter, then you can control it from main
t200_ns:
nop 'waste a cycle
cbi portd,7 'reset port bit
pop r16 'recover used reg
out sreg,r16 'recover sreg
pop r16
rti
#end asm
[/code:1:9a4b765a45]
Note that the ISR code sets the output port, then tests for the flag value to get the delay
That way, you avoid complicated branches and multiple bits of code depending on what the flag setting is.
I never tested how many clocks the Bascom NOP command takes, it may well be longer than a NOP in ASM.
There are many other ways of doing similar delays in ASM, when you want really precise and small timing intervals, learning how to do it in ASM well pays the time to learn how to do it.
↧
BASCOM-ARDUINO : ILI9327 on Arduino Mega : REPLY
Well done Ben !
and Happy new year.
as you say : have fun !
Bon courage
JP
:wink:
↧
↧
BASCOM-ARDUINO : ILI9327 on Arduino Mega : REPLY
Working on the touchscreen. Works with Arduino-software but should work with Bascom.
Xtp2046, so a known touchscreen chip.
Have fun
Ben Zijlstra
↧
BASCOM-AVR : redefining interupt service routines : REPLY
Thank you Adrian and the rest! This gave me enough inspiration to implement what I want. Of course it was a little more complicated than I sketched but it seems it is going to workout. Used quite some ASM-code but it's fairly easy to tune the timing once the basic setup was there.
Marc
↧
BASCOM-AVR : Encoder : NEWTOPIC
Greetings to all!
I ask to explain what the problem is?
Here is my code:
[code:1:427925480f]
$regfile = "m8535.dat"
Config Portd.2 = Input
Config Portd.3 = Input
Config Portd.5 = Output
Config Portd.6 = Output
Dim B As Byte
Main:
Do
B = Encoder(pind.2 , Pind.3 , L , R , 10)
Loop
End
L:
Set Portd.6
Waitms 20
Reset Portd.6
Return
R:
Set Portd.5
Waitms 20
Reset Portd.5
Return
[/code:1:427925480f]
It seems all right, but rotate the encoder
sometimes two LEDs flash
[b:427925480f][color=red:427925480f](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b:427925480f][/color:427925480f]
↧
BASCOM-AVR : WRITE VARIABLE TO FLASH MEMORY OF MICROCONTROLLER : NEWTOPIC
Hi
I want to save a variable to a predefined address of flash memory of microcontroller.
who can i do it?
thanks
[b:85289a4016][color=red:85289a4016](BASCOM-AVR version : 2.0.7.8 )[/b:85289a4016][/color:85289a4016]
↧
↧
BASCOM-AVR : WRITE VARIABLE TO FLASH MEMORY OF MICROCONTROLLER : REPLY
The short answer, is no, you cannot write to flash memory from within a running progam in an AVR processor.
But why not use the eeprom ?
That is provided to store 'variables' which will be used after a power cycle. Note that there are still limitations. You cannot write to eeprom an unlimited number of times, so you must use these 'variables' to store only new values needed after a change. System setup 'variables' are often used in this way.
↧
BASCOM-ARDUINO : ILI9327 on Arduino Mega : REPLY
Oke. From my earlier project, the Word Clock, I got the routines for the XTP2046 touchscreen. Have to thank Heiko / Hkipnik and SIX1 for there work, from the variable [b:9be59e4373]"Tasteneu"[/b:9be59e4373] I can see it is from our German friends. Have altered some calculations for the wider screen. Have still to make some kind of menu. A grid or matrix.
[img:9be59e4373]http://members.home.nl/hobbycorner/images/Bascom_forum/touch.jpg[/img:9be59e4373]
As you can see the top left corner has X-value 250, Y-value 122
and the top right corner has X-value 990, Y-value 122
left bottom has X-value 250, Y-value 862
right bottom has X-value 990, Y-value 862
Touch is interrupt driven.
Here pieces of the code you have to integrate in the code for the ILI9327_final from AndersL. INT4 is used for the interrupt. When the touchscreen is touched a interrupt is generated. Variable Tasteneu gets the value 1. The XTP2046 is connected to several other ports. You can find it in the code here
[code:1:9be59e4373]on int4 Touch_int
enable int4
config int4 = falling
enable interrupts
ddre.4 = 0
porte.4 = 1
Clock alias porth.3
Cst alias porte.3
Dout alias portg.5
Din alias pine.5
config Din = input
config Clock = output
config cst = output
config Dout = output
Cst = 1
dim tijdelijk2 as string * 40
[/code:1:9be59e4373]
Tijdelijk2 is used as a temp variable, to display the values.
An interrupt routine is called and this looks like. You have to place it somewhere at the end of your program.
[code:1:9be59e4373]
Touch_int:
tasteneu=1
Return
[/code:1:9be59e4373]
And a do loop with the reading of the XTP2046 can be placed in your ili9327 code at places where you are using some kind of menu
[code:1:9be59e4373]Do
if tasteneu > 0 then
cst = 0
shiftout dout,clock,x_dout,1,8,20
waitms 5
shiftin din, clock, touchx, 1, 12, 20
shiftout dout, clock, y_dout, 1, 8, 20
waitms 5
shiftin din, clock, touchy,1,12,20
cst=1
touchx = touchx / 38
touchx=touchx+200
touchy = touchy / 38
waitms 200
tasteneu = 0
tijdelijk2="X = "+str(touchx)
Call Ili9327_text(tijdelijk2 , 150 , 80 , 5 , red , Black)
tijdelijk2="Y = "+str(touchy)
Call Ili9327_text(tijdelijk2 , 150 , 100 , 5 , red , Black)
call ili9327_text("x=990",340,12,5,white,black)
call ili9327_text("y=122",340,28,5,white,black)
call ili9327_text("x=250",10,12,5,white,black)
call ili9327_text("y=122",10,28,5,white,black)
call ili9327_text("x=250",10,205,5,white,black)
call ili9327_text("y=862",10,220,5,white,black)
call ili9327_text("x=990",340,205,5,white,black)
call ili9327_text("y=862",340,220,5,white,black)
end if
Loop
[/code:1:9be59e4373]
Perhaps this was the hardest part
[code:1:9be59e4373]touchx = touchx / 38
touchx=touchx+200
touchy = touchy / 38
[/code:1:9be59e4373]
How to keep X and Y between reasonal unique values.
You can remove the readtouch(X) and readtouch(Y) from the code of AndersL, or exchange these code with the code above.
Ready for testing...
Have fun
Ben Zijlstra
↧
Share your working BASCOM-AVR code here : Tektronix 4010(4014) graphic terminal (emulator) library : REPLY
The above was corresponds to 4010 (4014) of monochrome display.
"Tera Term" also corresponds to 410x of color display.
Therefore, I added the "Tekcolor" command for specifying the drawing color.
Computer screen [url=http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispj.gif][img:b909ac8d4e]http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/TEK4010/TEK4010gdispjs.jpg[/img:b909ac8d4e][/url]
1.Download and install the latest version of "[url=http://ttssh2.sourceforge.jp/index.html.en]Tera Term[/url]" from "SourceForge.jp".
2.[Setup] -> [Serial port] -> "Serial port setup" dialog box.Set the baud rate.
3.[Setup] -> [Terminal] -> "Terminal setup" dialog box. Enable the "Auto switch (VT<->TEK)".
4.[Control] -> [Open TEK] -> Opens the TEK window.
[Setup] -> [Font] -> "Font" dialog box. Font size is changed into any value. (Example: Size 16)
5.[Setup] -> [Window] -> "Window setup" dialog box. Enable the "Color emulation".
Background color, you can change by "Reverse" button.
6.[VT-window] -> Return to the "VT-window".
[Setup] -> [Save setup] -> "Save setup" dialog box. Save the settings.
[code:1:b909ac8d4e]
'
' ********************************************************
' * Tektronix 4010(4014,410x) Graphic Terminal Library *
' * [Ver.2] O-Family 2015. 1. 5 *
' ********************************************************
'
$regfile = "m88pdef.dat" 'Any chip.
$crystal = 16000000 'Any frequency.
'
$hwstack = 64
$swstack = 32
$framesize = 24
$baud = 9600 'Set the baud rate.
'--------- Include a control instruction of TEK4010. ---------
Dim _temptx As Byte 'Internal variables of the library.
_temptx = &H1F : Printbin _temptx '[US] Changes Terminal to Alpha Mode.
$lib "TEK4010emu.lib" 'Tektronix 4010(4014,410x) graphic terminal (emulator) library.
$external Tekcls , Tekline , Tekbox , Tekpset , Teklocate , Tekgraph , Tekalpha , Tekplot , Tekcolor
Declare Sub Tekcls : Declare Sub Tekalpha : Declare Sub Teklocate(byval _tekx0 As Word , Byval _teky0 As Word)
Declare Sub Tekline(byval _tekx0 As Word , Byval _teky0 As Word , Byval _tekx1 As Word , Byval _teky1 As Word , Byval _tekvt As Byte)
Declare Sub Tekbox(byval _tekx0 As Word , Byval _teky0 As Word , Byval _tekx1 As Word , Byval _teky1 As Word , Byval _tekvt As Byte)
Declare Sub Tekpset(byval _tekx0 As Word , Byval _teky0 As Word) : Declare Sub Tekcolor(byval _tekcol As Byte)
Declare Sub Tekgraph(byval _tekvt As Byte) : Declare Sub Tekplot(byval _tekx0 As Word , Byval _teky0 As Word)
'
' Tekcls <Clear the Vector and Alpha Screen.>
' Tekcolor Color [0 = Black, 1 = Red, 2 = Green, 3 = Yellow, 4 = Blue, 5 = Magenta, 6 = Cyan, 7 = White] <Set a color of the drawing.>
' Tekline X(start) , Y(start) , X(end) , Y(end) , Vector-Type [X = 0 - 1023 , Y = 0 - 778 , Vector-Type = 0 - 23] <Draws a line.>
' [Vector-Type = 0:normal line , 1:dotted line , 2:dot-dashed , 3:short-dashed , 4:long-dashed]
' Tekbox X(left corner) , Y(top position) , X(right corner) , Y(bottom position) , Vector-Type <Write a box.>
' Tekpset X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Set a single pixel.>
' Teklocate X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Moves the Alpha cursor to the specified position.>
' Tekgraph Vector-Type [Vector-Type = 0 - 23] <Sets Terminal to Graph Mode , Select the vector type.>
' Tekplot X(location) , Y(location) [X = 0 - 1023 , Y = 0 - 778] <Plot the graph line.> Note: Perform Tekgraph.
' Tekalpha <Terminal is returned to alpha mode.>
'-------------------------------------------------------------
' ************************
' * Drawing test program *
' ************************
Dim W1 As Word , W2 As Word , W3 As Word , S1 As Single , S2 As Single , B As Byte
Tekcolor 7 'Drawing color [white].
Tekcls 'Clear the Vector and Alpha Screen.
Print "Tektronix 4010(4014,410x) graphic terminal (emulator)"
Tekcolor 1 'Drawing color [Red].
Tekbox 0 , 0 , 1023 , 778 , 1 'Outer frame.
'
Tekcolor 2 'Drawing color [Green].
Tekline 0 , 430 , 1023 , 430 , 0 'Vector Type.
Tekline 0 , 420 , 1023 , 420 , 1
Tekline 0 , 410 , 1023 , 410 , 2
Tekline 0 , 400 , 1023 , 400 , 3
Tekline 0 , 390 , 1023 , 390 , 5
'
Tekcolor 7 'Drawing color [White].
Teklocate 900 , 388 'Moves the Alpha cursor.
Print "Vector Type"
Tekcolor 4 'Drawing color [Blue].
W1 = 448
For B = 1 To 34 'Slanting line.
Tekline 0 , 448 , 1023 , W1 , 0
W1 = W1 + 10
Next B
Tekcolor 3 'Drawing color [Yellow].
Tekbox 80 , 720 , 280 , 580 , 1 'Write a box.
Tekbox 100 , 700 , 200 , 600 , 0
'
Teklocate 134 , 638 'Moves the Alpha cursor.
Print "BOX"
Tekcolor 7 'Drawing color [White].
Tekline 30 , 195 , 390 , 195 , 1 'Scale line.
Tekline 30 , 45 , 30 , 345 , 0
'
Tekcolor 5 'Drawing color [Magenta].
For W1 = 0 To 360 'Sign waveform.
S1 = W1
S1 = Deg2rad(s1)
S1 = Sin(s1)
S1 = S1 * 150
S1 = S1 + 195
W2 = Int(s1)
W3 = W1 + 30
Tekpset W3 , W2 'Set a single pixel.
Next W1
'
Teklocate 240 , 270 'Moves the Alpha cursor.
Print "Sign Wave"
Tekcolor 7 'Drawing color [White].
Tekline 450 , 195 , 710 , 195 , 3 'Scale line.
Tekline 580 , 65 , 580 , 325 , 3
'
Tekcolor 6 'Drawing color [Cyan].
For W1 = 0 To 360 'Circle.
S1 = W1
S1 = Deg2rad(s1)
S2 = Cos(s1)
S1 = Sin(s1)
S1 = S1 * 120
S1 = S1 + 195
W2 = Int(s1)
S2 = S2 * 120
S2 = S2 + 580
W3 = Int(s2)
Tekpset W3 , W2 'Set a single pixel.
Next W1
'
Teklocate 500 , 230 'Moves the Alpha cursor.
Print "Circle"
Tekcolor 7 'Drawing color [White].
Tekline 770 , 80 , 1000 , 80 , 0 'Scale line.
Tekline 770 , 80 , 770 , 310 , 0
'
Tekcolor 1 'Drawing color [Red].
Restore Graphdata 'Drawing a graph.
W1 = 770 'X position.
Tekgraph 1 'Sets Terminal to Graph Mode , Select the vector type.
For B = 1 To 5
Read W2
Tekplot W1 , W2 'Plot the graph line.
W1 = W1 + 50
Next B
Tekalpha 'Terminal is returned to alpha mode.
'
Teklocate 860 , 280 'Moves the Alpha cursor.
Print "Graph"
Tekcolor 7 'Drawing color [White].
Teklocate 50 , 520 'Moves the Alpha cursor.
Print "END"
End
Graphdata:
Data 120% , 220% , 250% , 150% , 180% 'Graph data.[/code:1:b909ac8d4e]
↧