'Bestaande versie samengevoegd met de wereldbol-versie ' 'Status: Display werkt. DDS werkt op 8.655.000 hz. ' ------------------------------------------------------------------------------------------------------------ 'QRP - 80 meter 'Fusebits: '98dcba - Ext. Crystal / Resonator High Freq. 111111 'High F - Disable Jtag 1 'High I - Eeprom Memory Preserved When Erasing Chip 0 'Extended P - Atmega128 Mode '$prog &HFF , &HFF , &HD1 , &HFF ' generated. Take care that the chip supports all fuse bytes. 'Ports 'Option 'PORTB.7 - bij ontvangen is deze hoog (via relais) - input H active 'ATT - Attenuator 'PORTC.0 - output H active 'Encoder 'PORTC.4 - switch - low active 'PORTC.5 - B 'PORTC,6 - C 'PORTC.7 - A 'Push-to-talk 'PORTD.2 - input H active 'Mic. Clipper Limiter 'PORTD.3 - output H active 'PORTD.4 - output H active 'DDS 'PORTD.5 - FQUD - output 'PORTD.6 - WClk - output 'PORTD.7 - Dsdata - output 'Graf. LCD 'PORTE.2 - SDA 'PORTE.3 - SCL 'PORTE.4 - Cs 'PORTE.5 - Rs 'Analoge 'PORTF.0 - RF Power level - input 'PORTF.1 - S meter level - input 'Relais 'PORTF.2 - Relais - output H active 'CW-tone 'PORTF.7 - CW-tone - output $regfile = "m128def.dat" $crystal = 16000000 $hwstack = 128 $swstack = 128 $framesize = 128 $baud = 19200 '$lib "lcd-epson.lbx" 'special color display support '$lib "lcd-pcf8833.lbx" 'Alias Relais Alias Portf.2 Push_to_talk Alias Pind.2 Mic_clipper_lim1 Alias Portd.3 Mic_clipper_lim2 Alias Portd.4 9851_data Alias Portd.7 9851_clk Alias Portd.6 9851_fqud Alias Portd.5 Soundpin Alias Portc.0 'Theo voor Cw Morsepin Alias Pinf.7 'Theo voor Cw Sw_encoder Alias Pinc.4 'First we define that we use a graphic LCD 'Config Graphlcd = Color , Controlport = Porte , Cs = 4 , Rs = 5 , Scl = 3 , Sda = 2 Config Pinb.7 = Input Config Portc.0 = Output ' ATT Config Sw_encoder = Input ' SW-ENCODER Config Pind.2 = Input Config Portd.3 = Output Config Portd.4 = Output Config 9851_fqud = Output Config 9851_clk = Output Config 9851_data = Output Config Pinf.0 = Input Config Pinf.1 = Input Config Relais = Output Config Portf.7 = Output 'Theo voor Cw Config Soundpin = Output 'Theo voor Cw Config Porta.0 = Output Config Porta.1 = Output Config Porta.2 = Output Config Porta.3 = Output Config Porta.4 = Output Config Porta.5 = Output Config Porta.6 = Output Config Porta.7 = Output Config Portb.0 = Output Config Portb.2 = Output Config Portb.3 = Output Config Portb.4 = Output Config Portb.5 = Output Config Portb.6 = Output Config Portb.7 = Output Config Portc.1 = Input Config Portc.2 = Input Config Portc.3 = Input Config Porte.6 = Output Config Porte.7 = Output Config Portf.3 = Output Config Portf.4 = Output Config Portf.5 = Output Config Portf.6 = Output 'encoder configuration Config Portc.7 = Input Config Portc.6 = Input Config Portc.5 = Output Config Adc = Single , Prescaler = Auto , Reference = Internal ' Hiermee configureren we de AD coverter Theo Reset Portc.5 'commen encoder Portc.7 = 1 : Portc.6 = 1 'pull-ups encoder 'CONST 'here we define the colors Const Blue = &B00000011 ''predefined contants are making programming easier Const Yellow = &B11111100 Const Red = &B11100000 Const Green = &B00011100 Const Black = &B00000000 Const White = &B11111111 Const Brightgreen = &B00111110 Const Darkgreen = &B00010100 Const Darkred = &B10100000 Const Darkblue = &B00000010 Const Brightblue = &B00011111 Const Orange = &B11111000 'DIM Dim W As Long Dim Frequ_gen_d As Double Dim Frequ_gen As Long ': Frequ_gen = 8655000 Dim Frequ_anz As Long : Dim Frequ_dsp As String * 10 Dim Frequ_rom As Long 'was eram Dim Sm As Word 'Theo voor Smeter Dim Hi As Word 'Theo voor Smeter2 Dim I As Byte 'Theo voor Smeter2 Dim L As Byte Dim Mi As Byte Dim Etmp As Word Dim G1 As Word Dim G2 As Word Dim G3 As Word Dim L1 As Long Dim Encode As Byte Dim Show_s As Byte Dim Stepsize As Long Dim Temp1 As Byte Dim Temp2 As Byte , Dim Fontsize As Byte Dim Lcd_posx As Byte Dim Lcd_posy As Byte Dim Lcd_fcolor As Byte Dim Rotation As Byte Dim Lcd_bcolor As Byte Dim Fontbreite As Byte , Fonthoehe As Byte , Xpixel As Byte , Ypixel As Byte Dim R As Integer , X1 As Byte , X2 As Byte , Y1 As Byte , Y2 As Byte , Ex As Byte , F As Integer , G As Long , Zeichen As String * 1 Dim A As Byte , B As Byte , C As Integer , D As Integer 'Dim T1 As Byte , T2 As Byte Dim Command As Byte , Lcdout As Byte 'Dim Pix As Byte , Gapx As Double , Gapy As Double , Sx As Byte Dim X As Byte , Y As Byte , Mx As Integer , Pixel As Integer , Schleife As Integer , Hx As Integer , Hy As Integer , Xinc As Integer , Yinc As Integer Dim Temp As Byte Dim Turns As Byte Dim Lx1 As Byte 'declares Declare Sub Reset_ad9851 Declare Sub To_ad9851 Declare Sub S0 'Theo voor Smeter Declare Sub S1 'Theo voor Smeter Declare Sub S2 'Theo voor Smeter Declare Sub S3 'Theo voor Smeter Declare Sub S4 'Theo voor Smeter Declare Sub S5 'Theo voor Smeter Declare Sub S6 'Theo voor Smeter Declare Sub S7 'Theo voor Smeter Declare Sub S8 'Theo voor Smeter Declare Sub S9 'Theo voor Smeter Declare Sub S10 'Theo voor Smeter Declare Sub S20 'Theo voor Smeter Declare Sub S30 'Theo voor Smeter Declare Sub S40 'Theo voor Smeter Declare Sub Enc_temp 'Theo Declare Sub Lcdbasis Declare Sub Lcdbasis2 Declare Sub Encoder_keypress Declare Sub Steprate Declare Sub Menu_click Declare Sub Menu_return Declare Sub Step10 Declare Sub Step100 Declare Sub Step1000 Declare Sub Step10000 Declare Sub Step100000 Declare Sub Step1000000 Declare Sub Place_line Declare Sub Lcd_print(byval Lcd_text As String , Byval Lcd_posx As Byte , Byval Lcd_posy As Byte , Byval Fontsize As Byte , Byval Lcd_fcolor As Byte , Byval Lcd_bcolor As Byte) Declare Sub Lcd_plot(byval Lx1 As Byte , Byval Ly1 As Byte , Byval Color As Byte) Declare Sub Lcd_draw(byval Lx1 As Byte , Byval Ly1 As Byte , Byval Lx2 As Byte , Byval Ly2 As Byte , Byval Color As Byte) Declare Sub Lcd_box(byval Lx1 As Byte , Byval Ly1 As Byte , Byval Lx2 As Byte , Byval Ly2 As Byte , Byval Color As Byte) Declare Sub Lcd_bitmap(byval Lx1 As Byte , Byval Ly1 As Byte , Byval Lx2 As Byte , Byval Ly2 As Byte) Declare Sub Dsp_freq '---------------------------------------------------------------------- Lcd_port Alias Porte 'Using Port C in the program with the command "LCD_Port". Just change if you need to change ports 'Using an ATMega and Port C? Read the manual chapter Problems / Solutions Ddre = &B11111111 'Port C: output of all ports (actually we just need 4 ports): Const Rs = 5 'Port C.0 Const Cs = 4 'Port C.1 Const Sdata = 2 'Port C.2 Const Sclk = 3 'Port C.3 Const Cmd = 0 'A "0" tells the display: now a Command is following Const Parameter = 1 Frequ_rom = 8630000 Frequ_gen = Frequ_rom Frequ_anz = Frequ_gen - 5000000 Stepsize = 100 Show_s = 0 '? Set Portc.4 ' SW-ENCODER Gosub Lcd_init_new Reset_ad9851 Call To_ad9851 Rotation = &H04 'direction for text Gosub Lcd_rotation '------------------------------------------------------------------------------- 'Hauptprogramm '------------------------------------------------------------------------------- Gosub Lcd_cls 'clear screen Call Lcd_box(0 , 13 , 131 , 35 , Darkblue) 'and some text at the end Call Lcd_print( " QRP PA0KN " , 1 , 2 , 2 , Yellow , Darkblue) 'Animated globe Do Restore Globe00 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe01 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe02 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe03 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe04 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe05 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe06 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe07 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe08 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe09 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe10 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe11 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe12 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe13 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe14 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe15 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe16 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe17 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe18 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe19 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe20 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe21 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe22 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe23 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe24 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe25 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe26 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe27 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Restore Globe28 Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Waitms 50 'Restore Globe29 'Call Lcd_bitmap(29 , 50 , 101 , 122) 'graphics size is 60x40 Incr Turns Loop Until Turns = 5 Wait 2 Gosub Lcd_cls Call Lcd_box(11 , 5 , 120 , 40 , Yellow) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(90 , 46 , 119 , 48 , Blue) Call Lcd_print( " LSB " , 16 , 7 , 0 , White , Blue) Call Lcd_box(90 , 56 , 119 , 58 , Blue) Call Lcd_box(90 , 58 , 119 , 59 , Black) Call Dsp_freq Set Mic_clipper_lim2 Start Adc Waitms 50 Mi = 10 'Routine voor analoge S-meter 'op digitaal scherm Do Sm = Getadc(1) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read Hi = Sm / I Etmp = 65 - Hi G1 = Etmp ^ 2 G2 = 4225 - G1 G3 = Sqr(g2) L1 = 120 - G3 L = Abs(l1) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read If Hi > 120 Then Hi = 120 If Hi < 10 Then Hi = 10 Lx1 = Hi Call Lcd_draw(lx1 , L , 65 , 120 , Red) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read If Show_s = 1 Then Select Case Sm Case Is < 100 : Gosub S0 Case 100 To 125 : Gosub S1 Case 125 To 150 : Gosub S2 Case 150 To 175 : Gosub S3 Case 175 To 200 : Gosub S4 Case 200 To 225 : Gosub S5 Case 225 To 250 : Gosub S6 Case 250 To 275 : Gosub S7 Case 275 To 300 : Gosub S8 Case 300 To 325 : Gosub S9 Case 325 To 340 : Gosub S10 Case 340 To 365 : Gosub S20 Case 365 To 370 : Gosub S30 Case Is > 370 : Gosub S40 End Select End If Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read Lx1 = Hi Call Lcd_draw(lx1 , L , 65 , 120 , White) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read Debounce Sw_encoder , 0 , Encoder_keypress , Sub Loop End 'encoder subroutines Levelup: If Encode > 2 Then Show_s = 0 Frequ_anz = Frequ_anz - Stepsize Frequ_gen = Frequ_anz - 5001500 'lsb 5001500 bij ondermenging Frequ_rom = Frequ_gen Call To_ad9851 '4998500 Call Dsp_freq Show_s = 1 End If Return Leveldown: If Encode = 2 Then Show_s = 0 Frequ_anz = Frequ_anz + Stepsize Frequ_gen = Frequ_anz - 5001500 '5001500 Frequ_rom = Frequ_gen Call To_ad9851 Call Dsp_freq Show_s = 1 End If Return Sub Menu_return Call Dsp_freq Call Lcd_box(90 , 46 , 119 , 48 , Blue) Call Lcd_print( " LSB " , 16 , 7 , 0 , White , Blue) Call Lcd_box(90 , 56 , 119 , 58 , Blue) Call Lcd_box(90 , 58 , 119 , 59 , Black) End Sub Sub Dsp_freq Frequ_dsp = " " + Str(frequ_anz) + " " Call Lcd_print(frequ_dsp , 2 , 2 , 2 , Darkred , Yellow) End Sub Sub To_ad9851 Local Lauf As Byte Frequ_gen_d = Frequ_gen Frequ_gen_d = Frequ_gen_d * 23.861210 '= 2 ^ 32 / 29.999647 = delta phi pro Hz 30.000000 'Frequ_gen_d = Frequ_gen_d * 29.826162 '= 2 ^ 32 / 29.999647 = delta phi pro Hz 24.000000 ' 2^32=4294967296 :179.997882 = 23.861210 ' 6 x REFCLCK Frequ_gen_d = Round(frequ_gen_d) W = Frequ_gen_d For Lauf = 1 To 32 9851_data = W.0 Waitus 1 9851_clk = 1 'Clock Waitus 1 9851_clk = 0 Waitus 1 Shift W , Right , 1 'LSB to MSB (W0 till W31) Next Lauf W = &B00000001 '0000001 'W32 to W39; here setting of 6x REFCLOCK For Lauf = 1 To 8 9851_data = W.0 Waitus 1 9851_clk = 1 'Clock Waitus 1 9851_clk = 0 Waitus 1 Shift W , Right , 1 Next Lauf 9851_fqud = 1 'FQ_UD takes the 40 bit Waitus 1 9851_fqud = 0 End Sub Sub Reset_ad9851 9851_clk = 0 9851_fqud = 0 Waitus 1 9851_clk = 1 'Clock takes the parallel data Waitus 1 9851_clk = 0 Waitus 1 9851_fqud = 1 'switch to serial mode Waitus 1 9851_fqud = 0 Waitus 1 End Sub Sub S0 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S0" , 3 , 16 , 0 , Black , White) Call Lcdbasis Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S1 I = 5 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S1" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S2 I = 4.54 Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S2" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S3 I = 4.28 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S3" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S4 I = 4.11 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S4" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S5 I = 4 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S5" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 12 , 0 , Black , Black) Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S6 I = 3.91 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S6" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 11 , 0 , Black , Black) Call Lcd_print( " " , 1 , 12 , 0 , Black , Black) Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S7 I = 3.84 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S7" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 10 , 0 , Black , Black) Call Lcd_print( " " , 1 , 11 , 0 , Black , Black) Call Lcd_print( " " , 1 , 12 , 0 , Black , Black) Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S8 I = 3.79 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S8" , 3 , 16 , 0 , Black , White) Call Lcdbasis Call Lcd_print( " " , 1 , 9 , 0 , Black , Black) Call Lcd_print( " " , 1 , 10 , 0 , Black , Black) Call Lcd_print( " " , 1 , 11 , 0 , Black , Black) Call Lcd_print( " " , 1 , 12 , 0 , Black , Black) Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S9 I = 3.75 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S9" , 3 , 16 , 0 , Black , White) Call Lcd_print( " " , 1 , 3 , 0 , White , White) Call Lcdbasis Call Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S10 I = 3.71 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S9+" , 3 , 16 , 0 , Black , White) Call Lcd_print( " " , 1 , 4 , 0 , White , White) Call Lcd_print( " " , 1 , 5 , 0 , White , White) Call Lcd_print( " " , 1 , 6 , 0 , White , Red) Call Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S20 I = 3.68 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S9++" , 3 , 16 , 0 , Black , White) Call Lcd_print( " " , 1 , 4 , 0 , White , White) Call Lcd_print( " " , 1 , 5 , 0 , White , Red) Call Lcd_print( " " , 1 , 6 , 0 , White , Red) Call Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S30 I = 3.65 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S9+++" , 3 , 16 , 0 , Black , White) Call Lcd_print( " " , 1 , 4 , 0 , White , Red) Call Lcd_print( " " , 1 , 5 , 0 , White , Red) Call Lcd_print( " " , 1 , 6 , 0 , White , Red) Call Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub S40 Call Lcd_print( " " , 3 , 16 , 0 , White , White) Call Lcd_print( "S9++++" , 3 , 16 , 0 , Black , White) Call Lcd_print( " " , 1 , 3 , 0 , White , Red) Call Lcd_print( " " , 1 , 4 , 0 , White , Red) Call Lcd_print( " " , 1 , 5 , 0 , White , Red) Call Lcd_print( " " , 1 , 6 , 0 , White , Red) Call Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub Lcdbasis Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read Call Lcd_print( " " , 1 , 4 , 0 , White , White) Call Lcd_print( " " , 1 , 5 , 0 , White , White) Call Lcd_print( " " , 1 , 6 , 0 , White , White) Call Lcd_print( " " , 1 , 7 , 0 , White , White) Call Lcd_print( " " , 1 , 8 , 0 , White , White) Call Lcd_print( " " , 1 , 9 , 0 , White , White) Call Lcd_print( " " , 1 , 10 , 0 , White , White) Call Lcd_print( " " , 1 , 11 , 0 , White , White) Call Lcd_print( " " , 1 , 12 , 0 , White , White) Call Lcd_print( " " , 1 , 13 , 0 , White , White) Call Lcd_print( " " , 1 , 14 , 0 , White , White) Call Lcd_print( " " , 1 , 15 , 0 , White , White) Call Lcd_print( " " , 1 , 16 , 0 , White , White) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub Lcdbasis2 Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read Call Lcd_print( " " , 1 , 7 , 0 , Black , Black) Call Lcd_print( " " , 1 , 8 , 0 , Black , Black) Call Lcd_print( " " , 1 , 9 , 0 , Black , Black) Call Lcd_print( " " , 1 , 10 , 0 , Black , Black) Call Lcd_print( " " , 1 , 11 , 0 , Black , Black) Call Lcd_print( " " , 1 , 12 , 0 , Black , Black) Call Lcd_print( " " , 1 , 13 , 0 , Black , Black) Call Lcd_print( " " , 1 , 14 , 0 , Black , Black) Call Lcd_print( " " , 1 , 15 , 0 , Black , Black) Call Lcd_print( " " , 1 , 16 , 0 , Black , Black) Encode = Encoder(pinc.6 , Pinc.7 , Leveldown , Levelup , 0) ' A-time Encoder read End Sub Sub Encoder_keypress Local Tijd As Long Call Lcd_print( " " , 15 , 16 , 0 , White , White) Tijd = 0 Do Incr Tijd Loop Until Sw_encoder = 1 Select Case Tijd Case Is < 200000 : Gosub Steprate Case Is > 200000 : Gosub Menu_click End Select End Sub Sub Steprate Call Place_line Do Encode = Encoder(pinc.6 , Pinc.7 , Steprate_down , Steprate_up , 0) ' A-time Encoder read Waitms 5 Debounce Sw_encoder , 0 , End_encoder_keypress Loop End_encoder_keypress: End Sub Steprate_up: If Encode > 2 Then Stepsize = Stepsize * 10 If Stepsize = 10000000 Then Stepsize = 10 End If Call Place_line End If Return Steprate_down: If Encode = 2 Then Stepsize = Stepsize / 10 If Stepsize = 1 Then Stepsize = 1000000 End If Call Place_line End If Return Sub Place_line Select Case Stepsize Case 10 : Gosub Step10 Case 100 : Gosub Step100 Case 1000 : Gosub Step1000 Case 10000 : Gosub Step10000 Case 100000 : Gosub Step100000 Case 1000000 : Gosub Step1000000 End Select End Sub Sub Step10 Call Lcd_print( " 10hz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(87 , 40 , 97 , 42 , White) End Sub Sub Step100 Call Lcd_print( " 100hz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(75 , 40 , 85 , 42 , White) End Sub Sub Step1000 Call Lcd_print( " 1Khz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(63 , 40 , 73 , 42 , White) End Sub Sub Step10000 Call Lcd_print( " 10Khz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(51 , 40 , 61 , 42 , White) End Sub Sub Step100000 Call Lcd_print( "100Khz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(39 , 40 , 49 , 42 , White) End Sub Sub Step1000000 Call Lcd_print( " 1Mhz" , 15 , 16 , 0 , Black , White) Call Lcd_box(11 , 40 , 120 , 42 , Black) Call Lcd_box(27 , 40 , 37 , 42 , White) End Sub Sub Menu_click Gosub Lcd_cls Call Lcd_print( "MENU" , 15 , 16 , 0 , Black , White) Wait 4 'here the rest of the program.... Call Menu_return Call Lcd_print( " " , 15 , 16 , 0 , White , White) Call Place_line End Sub '--------------------------------------------------------------------------------------------- Lcd_cls: Call Lcd_box(0 , 0 , 131 , 131 , 255) 'easy done: draws a white (255) box with full size Return Window: 'Open output Windows with coordinatex x1,y1 and x2,y2 - read Manual Command = Cmd Lcdout = &H15 'Column adress Gosub Lcd_sendbyte Command = Parameter Lcdout = X1 'X-Position upper left corner Gosub Lcd_sendbyte Lcdout = X2 'y-Position upper left corner Gosub Lcd_sendbyte Command = Cmd Lcdout = &H75 'Page adressing Gosub Lcd_sendbyte Command = Parameter Lcdout = Y1 'x-Position of lower right corner Gosub Lcd_sendbyte Lcdout = Y2 'y-Position of lower right corner Gosub Lcd_sendbyte Command = Cmd Lcdout = &H5C Gosub Lcd_sendbyte Return Sub Lcd_plot(byval Lx1 As Byte , Ly1 As Byte , Color As Byte) X1 = Lx1 'output window: only one pixel Y1 = Ly1 X2 = Lx1 Y2 = Ly1 Gosub Window Command = Parameter Lcdout = Color 'set color of pixel Gosub Lcd_sendbyte End Sub Sub Lcd_draw(byval Lx1 As Byte , Ly1 As Byte , Lx2 As Byte , Ly2 As Byte , Color As Byte) 'draws a line from one point (no matter which direction) to another - uses only integer values - very fast X = Lx1 Y = Ly1 D = 0 Hx = Lx2 - Lx1 'number of X-pixels Hy = Ly2 - Ly1 Xinc = 1 Yinc = 1 If Hx < 0 Then Xinc = -1 Hx = Hx * -1 End If If Hy < 0 Then Yinc = -1 Hy = Hy * -1 End If If Hy <= Hx Then C = 2 * Hx Mx = 2 * Hy While X <> Lx2 Call Lcd_plot(x , Y , Color) X = X + Xinc D = D + Mx If D > Hx Then Y = Y + Yinc D = D - C End If Wend Else C = 2 * Hy Mx = 2 * Hx While Y <> Ly2 Call Lcd_plot(x , Y , Color) Y = Y + Yinc D = D + Mx If D > Hy Then X = X + Xinc D = D - C End If Wend End If Call Lcd_plot(x , Y , Color) 'the last pixel has to be drawn seperately End Sub Sub Lcd_box(byval Lx1 As Byte , Ly1 As Byte , Lx2 As Byte , Ly2 As Byte , Color As Byte) X1 = Lx1 'output window Y1 = Ly1 X2 = Lx2 Y2 = Ly2 Gosub Window 'define window X = Lx2 - Lx1 Incr X '# of X-Pixel Y = Ly2 - Ly1 Incr Y '# of Y-Pixel Pixel = X * Y '# of total pixel For Schleife = 1 To Pixel 'plot each pixel in the defined output window (=box) Command = Parameter Lcdout = Color Gosub Lcd_sendbyte Next End Sub Sub Lcd_bitmap(byval Lx1 As Byte , Ly1 As Byte , Lx2 As Byte , Ly2 As Byte ) Rotation = &H00 'daa direction of bitmap data is horizontal Gosub Lcd_rotation X1 = Lx1 Y1 = Ly1 X2 = Lx2 Y2 = Ly2 Gosub Window 'define window X = Lx2 - Lx1 Incr X '# of X-Pixel Y = Ly2 - Ly1 Incr Y '# of Y-Pixel Pixel = X * Y 'Total # of Pixel For Schleife = 1 To Pixel 'as often as there are pixel 'before calling this subroutine you have to set the pointer to the start of the data (in Basic: Restore) Read Lcdout 'Reads data from pointer, stored data = pixel data = pixel color Command = Parameter Gosub Lcd_sendbyte 'and plot this color to screen Next Rotation = &H04 'restore data direction for characters (thus vertical data direction) Gosub Lcd_rotation End Sub '------------------------------------------------------------------------------- 'Routine for displaying characters '------------------------------------------------------------------------------- Sub Lcd_print(byval Lcd_text As String , Byval Lcd_posx As Byte , Byval Lcd_posy As Byte , Byval Fontsize As Byte , Byval Lcd_fcolor As Byte , Byval Lcd_bcolor As Byte) For R = 1 To Len(lcd_text) 'for each charater in string Zeichen = Mid(lcd_text , R , 1) 'read next character from string G = Asc(zeichen) 'get ascii value G = G - 32 'we do not have the first 32 ascii values in eeprom G = G * 5 'each character has 5 values stored in eeprom ' --------- X,Y Position (output window) setzen ------------------ ' ' x1,y1 ****************** ' * * ' * * ' * * ' * * ' * * ' * * ' * * ' ****************** x2,y2 ' Fontbreite = 1 'first we assume small font Fonthoehe = 1 Xpixel = 5 Ypixel = 7 Select Case Fontsize 'change size if needed Case 1 'if double height and single width Fonthoehe = 2 Ypixel = 15 Case 2 'if double height and double width Fontbreite = 2 Fonthoehe = 2 Xpixel = 11 Ypixel = 15 End Select X1 = Lcd_posx - 1 'fängt im Display mit 0 und nicht mit 1 an X1 = X1 * 6 'Jedes Zeichen ist inkl. Leerspalte 6 Pixel breit X1 = X1 * Fontbreite 'Startposition, evtl. verdoppeln, wenn doppelt breit X2 = X1 + Xpixel 'Fenster ist 5 oder 11 Zeichen breit Y1 = Lcd_posy - 1 'fängt im Display mit 0 und nicht mit 1 an Y1 = Y1 * 8 'jedes Zeichen ist 8 Pixel hoch Y1 = Y1 * Fonthoehe 'Startposition evtl. verdoppeln, wenn doppel hoch Incr Y1 Y2 = Y1 + Ypixel 'andere Fensterecke liegt 7 oder 15 pixel tiefer Gosub Window 'opens output window Command = Cmd Lcdout = &H5C Gosub Lcd_sendbyte 'set to send data mode B = 0 For F = 0 To 5 '6 columns for each character (including 1 empty column) C = 1 If Fontsize = 2 Then C = 2 'double width - so write each column 2 times While C > 0 For A = 0 To 7 D = 1 If Fontsize > 0 Then D = 2 'double height - so write each bit 2 times For Ex = 1 To D If B.a = 1 Then 'check every single bit if 1 or 0 and set foregroundcolor if 1, background color if 0 Command = Parameter 'foreground color Lcdout = Lcd_fcolor Gosub Lcd_sendbyte Else Command = Parameter 'background color Lcdout = Lcd_bcolor Gosub Lcd_sendbyte End If Next E Next A Decr C Wend Readeeprom B , G 'read data of next column of this character G = G + 1 Next F Incr Lcd_posx 'next column Next R End Sub '------------------------------------------------------------------------------- 'initializing of the display '------------------------------------------------------------------------------- Lcd_init_new: Reset Lcd_port.rs 'Initializing and Reset. The Command "Set" sets port to 1, "Reset" to 0 Waitms 10 Set Lcd_port.rs Set Lcd_port.cs Set Lcd_port.sdata Set Lcd_port.sclk Command = Cmd Lcdout = &H20 'Power Control Gosub Lcd_sendbyte Command = Parameter Lcdout = &H0F 'P10 to P13 on Gosub Lcd_sendbyte Waitms 40 Command = Cmd 'Sleep out Lcdout = &H94 Gosub Lcd_sendbyte Lcdout = &HAF 'Display on Gosub Lcd_sendbyte Lcdout = &HD1 'Internal oszillation on Gosub Lcd_sendbyte Waitms 40 'now commented as we do use the routine rotation in this program ' Command = Cmd ' Lcdout = &HBC 'DATCTL ' Gosub Lcd_sendbyte ' Command = Parameter ' Lcdout = &H04 'page adressing, ' Gosub Lcd_sendbyte ' Lcdout = &H00 'RGB order ' Gosub Lcd_sendbyte ' Lcdout = &H01 '8-gray scale = 256 colors ' Gosub Lcd_sendbyte Command = Cmd Lcdout = &HBB 'Common scan direction Gosub Lcd_sendbyte Command = Parameter Lcdout = &H01 'do not change Gosub Lcd_sendbyte Command = Cmd Lcdout = &HA7 'Inverse Display; &HA6 would be not inverted (different colors) Gosub Lcd_sendbyte Command = Cmd Lcdout = &HCE '256-colors Gosub Lcd_sendbyte Restore Data_lcd_init 'read predefined color table (256 colors) and init (read manual) For Temp1 = 1 To 20 Read Temp2 Command = Parameter Lcdout = Temp2 Gosub Lcd_sendbyte Next Temp1 Return Lcd_rotation: Command = Cmd Lcdout = &HBC 'DATCTL Gosub Lcd_sendbyte Command = Parameter Lcdout = Rotation ' set rotation to &H00 or &H04 depending if horizontal or vertical data processing is needed Gosub Lcd_sendbyte Lcdout = &H00 'RGB Anordnung Gosub Lcd_sendbyte Lcdout = &H01 '8-gray scale = 256 colors Gosub Lcd_sendbyte Return Data_lcd_init: 'old color table 'Data &H00 , &H02 , &H04 , &H06 , &H09 , &H0B , &H0D , &H0F , &H00 , &H02 , &H04 , &H06 , &H09 , &H0B , &H0D , &H0F , &H00 , &H04 , &H0B , &H0F 'new color table - see manual Data &H00 , &H05 , &H07 , &H0A , &H0C , &H0D , &H0E , &H0F , &H00 , &H05 , &H07 , &H0A , &H0C , &H0D , &H0E , &H0F , &H00 , &H07 , &H0D , &H0F '------------------------------------------------------------------------------- 'Send Commands or parameter or data byte '------------------------------------------------------------------------------- Lcd_sendbyte: Reset Lcd_port.cs 'Cs Leitung to 0 start of sequence Reset Lcd_port.sclk 'Clock line to 0 If Command = Cmd Then Reset Lcd_port.sdata '0 = cmd Else Set Lcd_port.sdata '1 = Parameter End If Set Lcd_port.sclk 'Clock line to 1 Shiftout Lcd_port.sdata , Lcd_port.sclk , Lcdout , Msbl 'send bit after bit of the value of variable "lcdout" (see manual) Set Lcd_port.cs 'Cs to 1 at end of sequence Return '------------------------------------------------------------------------------- $include "globe00.txt" '$include "globe01.txt" $include "globe02.txt" '$include "globe03.txt" $include "globe04.txt" '$include "globe05.txt" $include "globe06.txt" '$include "globe07.txt" $include "globe08.txt" '$include "globe09.txt" $include "globe10.txt" '$include "globe11.txt" $include "globe12.txt" '$include "globe13.txt" $include "globe14.txt" '$include "globe15.txt" $include "globe16.txt" '$include "globe17.txt" $include "globe18.txt" '$include "globe19.txt" $include "globe20.txt" '$include "globe21.txt" $include "globe22.txt" '$include "globe23.txt" $include "globe24.txt" '$include "globe25.txt" $include "globe26.txt" '$include "globe27.txt" $include "globe28.txt" '$include "globe29.txt" $eeprom 'starts eeprom data Data &H00 , &H00 , &H00 , &H00 , &H00 ' space Data &H00 , &H06 , &H5F , &H06 , &H00 ' ! Data &H07 , &H03 , &H00 , &H07 , &H03 ' '' Data &H24 , &H7E , &H24 , &H7E , &H24 ' # Data &H24 , &H2B , &H6A , &H12 , &H00 ' $ Data &H63 , &H13 , &H08 , &H64 , &H63 ' % Data &H36 , &H49 , &H56 , &H20 , &H50 ' & Data &H00 , &H07 , &H03 , &H00 , &H00 ' ' Data &H00 , &H3E , &H41 , &H00 , &H00 ' ( Data &H00 , &H41 , &H3E , &H00 , &H00 ' ) Data &H08 , &H3E , &H1C , &H3E , &H08 ' * Data &H08 , &H08 , &H3E , &H08 , &H08 ' + Data &H00 , &HE0 , &H60 , &H00 , &H00 ' , Data &H08 , &H08 , &H08 , &H08 , &H08 ' - Data &H00 , &H60 , &H60 , &H00 , &H00 ' . Data &H20 , &H10 , &H08 , &H04 , &H02 ' / Data &H3E , &H51 , &H49 , &H45 , &H3E ' 0 Data &H00 , &H42 , &H7F , &H40 , &H00 ' 1 Data &H62 , &H51 , &H49 , &H49 , &H46 ' 2 Data &H22 , &H49 , &H49 , &H49 , &H36 ' 3 Data &H18 , &H14 , &H12 , &H7F , &H10 ' 4 Data &H2F , &H49 , &H49 , &H49 , &H31 ' 5 Data &H3C , &H4A , &H49 , &H49 , &H30 ' 6 Data &H01 , &H71 , &H09 , &H05 , &H03 ' 7 Data &H36 , &H49 , &H49 , &H49 , &H36 ' 8 Data &H06 , &H49 , &H49 , &H29 , &H1E ' 9 Data &H00 , &H6C , &H6C , &H00 , &H00 ' : Data &H00 , &HEC , &H6C , &H00 , &H00 ' ; Data &H08 , &H14 , &H22 , &H41 , &H00 ' < Data &H24 , &H24 , &H24 , &H24 , &H24 ' = Data &H00 , &H41 , &H22 , &H14 , &H08 ' > Data &H02 , &H01 , &H59 , &H09 , &H06 ' ? Data &H3E , &H41 , &H5D , &H55 , &H1E ' @ Data &H7E , &H09 , &H09 , &H09 , &H7E ' A Data &H7F , &H49 , &H49 , &H49 , &H36 ' B Data &H3E , &H41 , &H41 , &H41 , &H22 ' C Data &H7F , &H41 , &H41 , &H41 , &H3E ' D Data &H7F , &H49 , &H49 , &H49 , &H41 ' E Data &H7F , &H09 , &H09 , &H09 , &H01 ' F Data &H3E , &H41 , &H49 , &H49 , &H7A ' G Data &H7F , &H08 , &H08 , &H08 , &H7F ' H Data &H00 , &H41 , &H7F , &H41 , &H00 ' I Data &H30 , &H40 , &H40 , &H40 , &H3F ' J Data &H7F , &H08 , &H14 , &H22 , &H41 'K Data &H7F , &H40 , &H40 , &H40 , &H40 ' L Data &H7F , &H02 , &H04 , &H02 , &H7F ' M Data &H7F , &H02 , &H04 , &H08 , &H7F ' N Data &H3E , &H41 , &H41 , &H41 , &H3E ' O Data &H7F , &H09 , &H09 , &H09 , &H06 'P Data &H3E , &H41 , &H51 , &H21 , &H5E ' Q Data &H7F , &H09 , &H09 , &H19 , &H66 ' R Data &H26 , &H49 , &H49 , &H49 , &H32 ' S Data &H01 , &H01 , &H7F , &H01 , &H01 ' T Data &H3F , &H40 , &H40 , &H40 , &H3F ' U Data &H1F , &H20 , &H40 , &H20 , &H1F ' V Data &H3F , &H40 , &H3C , &H40 , &H3F ' W Data &H63 , &H14 , &H08 , &H14 , &H63 ' X Data &H07 , &H08 , &H70 , &H08 , &H07 ' Y Data &H71 , &H49 , &H45 , &H43 , &H00 ' Z Data &H00 , &H7F , &H41 , &H41 , &H00 ' [ Data &H02 , &H04 , &H08 , &H10 , &H20 ' \ Data &H00 , &H41 , &H41 , &H7F , &H00 ' ] Data &H04 , &H02 , &H01 , &H02 , &H04 ' ^ Data &H80 , &H80 , &H80 , &H80 , &H80 ' _ Data &H00 , &H03 , &H07 , &H00 , &H00 ' ` Data &H20 , &H54 , &H54 , &H54 , &H78 ' a Data &H7F , &H44 , &H44 , &H44 , &H38 ' b Data &H38 , &H44 , &H44 , &H44 , &H28 ' c Data &H38 , &H44 , &H44 , &H44 , &H7F ' d Data &H38 , &H54 , &H54 , &H54 , &H18 ' e Data &H08 , &H7E , &H09 , &H09 , &H00 ' f Data &H18 , &HA4 , &HA4 , &HA4 , &H7C ' g Data &H7F , &H04 , &H04 , &H78 , &H00 ' h Data &H00 , &H00 , &H7D , &H00 , &H00 ' i Data &H40 , &H80 , &H84 , &H7D , &H00 ' j Data &H7F , &H10 , &H28 , &H44 , &H00 ' k Data &H00 , &H00 , &H7F , &H40 , &H00 ' l Data &H7C , &H04 , &H18 , &H04 , &H78 ' m Data &H7C , &H04 , &H04 , &H78 , &H00 ' n Data &H38 , &H44 , &H44 , &H44 , &H38 ' o Data &HFC , &H44 , &H44 , &H44 , &H38 ' p Data &H38 , &H44 , &H44 , &H44 , &HFC ' q Data &H44 , &H78 , &H44 , &H04 , &H08 ' r Data &H08 , &H54 , &H54 , &H54 , &H20 ' s Data &H04 , &H3E , &H44 , &H24 , &H00 ' t Data &H3C , &H40 , &H20 , &H7C , &H00 ' u Data &H1C , &H20 , &H40 , &H20 , &H1C ' v Data &H3C , &H60 , &H30 , &H60 , &H3C ' w Data &H6C , &H10 , &H10 , &H6C , &H00 ' x Data &H9C , &HA0 , &H60 , &H3C , &H00 ' y Data &H64 , &H54 , &H54 , &H4C , &H00 ' z Data &H08 , &H3E , &H41 , &H41 , &H00 ' { Data &H00 , &H00 , &H7F , &H00 , &H00 ' | Data &H00 , &H41 , &H41 , &H3E , &H08 ' } Data &H02 , &H01 , &H02 , &H01 , &H00 ' ~ $data