' ********************************************************************** ' ** Program name: KAD08au2.BAS - Version : 1.2 - 06 March 2001 ** ' ** Compiler : BASCOM AVR (IDE V. 1.11.5.0, LIB V. 1.11.5.0) ** ' ** Board : KAD 08 ** ' ** Firm: grifo(r) ITALIAN TECHNOLOGY ** ' ** Via Dell' Artigiano 8/6 40016 San Giorgio di Piano (BO) ** ' ** Tel.+39 051 892 052 Fax +39 051 893 661 ** ' ** http://www.grifo.com http://www.grifo.it ** ' ** sales@grifo.it tech@grifo.it grifo@grifo.it ** ' ** ** ' ** Written by: Graziano GAIBA ** ' ********************************************************************** ' ' This program allows to manage the resources on the KAD 08 board through a ' menu and 2 TTL lines driven by a microcontroller of the 51 family. ' This program is controlled through the RS 232 serial line so it is essential ' to connect a free COM port on the PC to the connector CN2 of K51-AVR. ' Configure the BASCOM terminal using menu Option/Communication, select ' the COM port and set baud rate to 19200, parity to none, databits to 8 and ' stopbits to 1. ' The master board is K51-AVR which must be connected to KAD 08 as follows: ' L1 (pin4 CN6) ----> SC (pin2 CN1 KAD08) ' L2 (pin5 CN6) ----> SD (pin1 CN1 KAD08) ' Supply both the boards. ' ' ++++++********** ATTENTION **********++++++ ' + + ' + To compile correctly the program: + ' + 1) enter menu Options/Compiler/Chip + ' + 2) set to 130 the value of Stacksize + ' + 3) set to 80 the value of Framesize + ' + + ' ++++++********** ATTENTION **********++++++ ' '*********************************************************************** ' '********************* Compiler Directives ***************************** ' $regfile = "8515def.DAT" ' AT90s8515 registers list $romstart = &H0 ' code start address $crystal = 5529600 ' micro clock frequence $baud = 19200 ' baud rate ' Configures timer 0 as timer and set prescaler to divide clock signal by 256 Config Timer0 = Timer , Prescale = 256 ' '********************* Constants declaration *************************** ' Pclk Alias Portd.3 ' line L1 on CN6 of K51-AVR Config Pind.3 = Output ' drives Clock signal. Psda Alias Portd.4 ' line L2 on CN6 of K51-AVR Config Pind.4 = Output ' drives Data signal. Const Ric = 151 ' generates an interrupt every ' 4.88 mS with clock ' frequence 5.5296MHz. Const Cler = 12 ' clear screen code Const Bel = 7 ' Bell code ' '*********************** Variables declaration ******************************** ' Dim Tasto As Byte ' general purpose Dim Led1 As Bit ' indicates status of Led 1, 1=On Dim Led2 As Bit ' indicates status of Led 2, 1=On Dim Led3 As Bit ' indicates status of Led 3, 1=On Dim Led4 As Bit ' indicates status of Led 4, 1=On Dim C1 As Byte ' code for DY4/1 Dp1 Alias C1.7 ' decimal point of DY4/1, 1=On Dim C2 As Byte ' code for DY4/2 Dp2 Alias C2.7 ' decimal point of DY4/2, 1=On Dim C3 As Byte ' code for DY3/1 Dp3 Alias C3.7 ' decimal point of DY3/1, 1=On Dim C4 As Byte ' code for DY3/2 Dp4 Alias C4.7 ' decimal point of DY3/2, 1=On Dim C5 As Byte ' code for DY2/1 Dp5 Alias C5.7 ' decimal point of DY2/1, 1=On Dim C6 As Byte ' code for DY2/2 Dp6 Alias C6.7 ' decimal point of DY2/2, 1=On Dim C7 As Byte ' code for DY1/1 Dp7 Alias C7.7 ' decimal point of DY1/1, 1=On Dim C8 As Byte ' code for DY1/2 Dp8 Alias C8.7 ' decimal point of DY1/2, 1=On Dim N As Byte ' general purpose variable ' ' ************************************************************************ ' * Following variables are essntial for interrupt, they can be changed * ' * in any moment. * ' ************************************************************************ ' Dim Bit32 As Long ' 32 bits wide variable that ' stores the bit frame for M5480 Dim Bit3 As Byte ' 3 bits for M5451 frame Dim Cifra As Byte ' keeps digit conversion Dim Disp As Byte ' indicates which display is ' currently visualizing Dim Cifh As Byte ' digit on DY4 and DY3 Dim Cifl As Byte ' digit on DY2 and DY1 ' ****************************************************************************** ' '************************** Procedure declarations ***************************** ' Declare Function Iv() As Long ' Decimal value input Declare Sub Iniz ' Peripherals initialization etc. Declare Function Att_key() As Byte ' wait for key pressed Declare Sub Press ' "Press a key..." message Declare Sub Demo ' display management example Declare Sub Decimal_point ' decimal point activation Declare Sub Ins_car ' show ASCII char on displays Declare Sub Leds ' On / Off LEDs management Declare Sub Sendclk ' outputs a CLK signal Declare Sub Sinc5451 ' resets M5451 outputs Declare Sub Testbit0 ' sets Psda as status of Bit0 Declare Sub Send5451 ' Communicates to M5451 the ' status of the outputs, through ' a 32+3 bits variable Declare Sub Ruota ' rotates left the displays Declare Function Conv14 (byval Cifra As Byte) As Word ' converts a number from 0 to 127 ' in 14 segments (see ASCII code) Declare Sub Conv_bit (byval Cifh As Byte , Byval Cifl As Byte) ' converts figures in bits for ' 5480 On Timer0 T0_int ' Response procedure to timer 0 ' interrupt ' ' ****************************** Main Program ********************************** ' Main: Waitms 1 ' Delay for signals settling Call Iniz ' variables initializations etc. N = 0 ' reset the variable Do ' visualize a ROM message C8 = Lookup(n , Messaggio) ' read a character of the message ' and display it on DY1/2 If C8 <> 0 Then ' if character is not null Incr N ' increment by 1 the variable Waitms 150 ' delay Call Ruota ' left shift of the 8 displays End If Loop Until C8 = 0 ' exit only if character is = 0 Do Do Print Chr(cler) ; ' clear the screen Print "** DEMO for KAD 08 connected to K51-AVR REL.1.2 06.03.2001 **" Print Print "1) Example of use" Print "2) Show an ASCII char from 0 to 127" Print "3) Decimal point activation" Print "4) Turn LEDs On and Off" Print "5) Reset" Print Print "SELECT THE DESIRED MENU : " Print Tasto = Att_key() ' wait for a key Print "Key=" ; If Tasto <> 0 Then Print Chr(tasto); End If ' Show last key pressed Print Chr(13); ' back to beginning of line Loop Until Tasto <> 0 ' exit if received a character Select Case Tasto Case "1" : Call Demo ' example of display management Case "2" : Call Ins_car ' display an ASCII char Case "3" : Call Decimal_point ' decimal point activation Case "4" : Call Leds ' LEDs management Case "5" : Led1 = 0 ' turn off Led 1 Led2 = 0 ' turn off Led 2 Led3 = 0 ' turn off Led 3 Led4 = 0 ' turn off Led 4 C1 = 32 ' put blank character on DY4/1 C2 = 32 ' put blank character on DY4/2 C3 = 32 ' put blank character on DY3/1 C4 = 32 ' put blank character on DY3/2 C5 = 32 ' put blank character on DY2/1 C6 = 32 ' put blank character on DY2/2 C7 = 32 ' put blank character on DY1/1 C8 = 32 ' put blank character on DY1/2 Call Press ' "Press a key.." message Tasto = Att_key() ' wait for a key Case Else : Print Chr(bel); ' key is not valid End Select Loop ' ' ******************** Response to Timer0 interrupt ************************ ' * Response to Timer0 interrupt ( Timer1 is used for serial port) * ' * Every 5mS (see Const Ric) the visualization of two 14 segments displays* ' * are updated, the next interrupt updates the other two ones until all * ' * 8 displays are updated in four passages lasting 5 ms each * ' ************************************************************************** ' T0_int: Stop Timer0 ' stop timer0 Timer0 = Ric ' reload starting value Start Timer0 ' restart timer0 Select Case Disp ' according to selected display Case 0 : Call Conv_bit(c1 , C5) ' prepare bit for DY4/1 and DY2/1 Incr Disp ' switch to next display match Case 1 : Call Conv_bit(c2 , C6) ' prepare bit for DY4/2 and DY2/2 Incr Disp ' switch to next display match Case 2 : Call Conv_bit(c3 , C7) ' prepare bit for DY3/1 and DY1/1 Incr Disp ' switch to next display match Case Is => 3 : Call Conv_bit(c4 , C8) ' prepare bit for DY3/2 and DY1/2 Disp = 0 ' point displays DY4/1 and DY2/1 End Select Call Send5451 ' send informations to M5451 IC1 Return End ' ' ******************************** Program end ********************************* ' ' ' ******************************* Procedures *********************************** ' ' ************************ variables initialization etc. ********************** ' This procedure performs all the variables initializations, activates the ' TIMER 0 interrupt management. ' Parameters: ' Input : nothing ' Output : nothing ' ***************************************************************************** ' Sub Iniz ' variables initialization etc. Pclk = 0 ' set to low CLK signal Psda = 0 ' set to low Data signal Disp = 0 ' point displays DY4/1 and DY2/1 Led1 = 0 ' turn off Led 1 Led2 = 0 ' turn off Led 2 Led3 = 0 ' turn off Led 3 Led4 = 0 ' turn off Led 4 C1 = 32 ' put blank character on DY4/1 C2 = 32 ' put blank character on DY4/2 C3 = 32 ' put blank character on DY3/1 C4 = 32 ' put blank character on DY3/2 C5 = 32 ' put blank character on DY2/1 C6 = 32 ' put blank character on DY2/2 C7 = 32 ' put blank character on DY1/1 C8 = 32 ' put blank character on DY1/2 Timer0 = Ric ' when timer0 reaches 0, ' interrupt is triggered Enable Interrupts ' enable interrupts Enable Timer0 ' enable interrupt of timer0 Start Timer0 ' timer0 starts Waitms 1 ' Delay for signals settling End Sub ' ' *********************** Rotate left the 8 displays *************************** ' This procedure performs the sliding to the left of the content of the 8 ' displays, making possible to realize sliding strings from right to left. ' The characters shift one display to the left, the new character of the string ' is put in display C8 (DY1/2). ' Parameters: ' Input : nothing ' Output : nothing ' ***************************************************************************** ' Sub Ruota ' rotate left the 8 displays C1 = C2 ' clear character on DY4/1, and ' copy character from DY4/2. C2 = C3 ' clear character on DY4/2, and ' copy character from DY3/1. C3 = C4 ' clear character on DY3/1, and ' copy character from DY3/2. C4 = C5 ' clear character on DY3/2, and ' copy character from DY2/1. C5 = C6 ' clear character on DY2/1, and ' copy character from DY2/2. C6 = C7 ' clear character on DY2/2, and ' copy character from DY1/1. C7 = C8 ' clear character on DY1/1, and ' copy character from DY1/2. End Sub ' ' ************************************************************************** ' * This procedure prepares the bits to send to M5451 (IC1 on KAD 08) * ' * Each display is matched to a variable from C1 to C8, if the variable * ' * contains a number greater than 127 the decimal point of hte matched * ' * display is automatically turned on. * ' * * ' * Parameters: 3 inputs, 2 outputs * ' * Inputs: var. Disp byte (from 0 to 3), indicates which display will * ' * be managed * ' * 0 -> DY4/1 and DY2/1 * ' * 1 -> DY4/2 and DY2/2 * ' * 2 -> DY3/1 and DY1/1 * ' * 3 -> DY3/2 and DY1/2 * ' * var. cif_h byte ( from 0 to 127), digit for DY4 and DY3 * ' * var. cif_l byte ( from 0 to 127), digit for DY2 and DY1 * ' * * ' * Output : var. Bit32 Long * ' * Variable Bit32 ( 4 byte) is structured like this: * ' * Bit32+0 -> byte 0 0..7 indicates segment a,b,c,d,e,f,g,h on DY4 and DY3* ' * * ' * Bit32+1 -> byte 1 0..6 indicates segment j,k,l,m,n,p,dp on DY4 and DY3 * ' * byte 1.7 indicates segment a on DY2 and DY1 * ' * * ' * Bit32+2 -> byte 2 0..7 indicates segment b,c,d,e,f,g,h,j on DY2 and DY1* ' * * ' * Bit32+3 -> byte 3 0..5 indicates segment k,l,m,n,p,dp on DY2 and DY1 * ' * byte 3.6 if = 0 activates displays DY3/2 and DY1/2, LD1 * ' * byte 3.7 if = 0 activates displays DY3/1 and DY1/1, LD2 * ' * * ' * Bit 3 -> bit 0 if = 0 activates displays DY4/2 e DY2/2, LD3 * ' * bit 1 if = 0 activates displays DY4/1 e DY2/1, LD4 * ' * bit 2 if = 0 enables the 4 LEDs. LD1, LD2, LD3, LD4 * ' * * ' * A general puprpose variable called X8 is used. * ' * Variables X8, bit32 and bit3 must be declared in internal RAM, * ' * otherwise assembler instructions cannot be executed. * ' * * ' * var. Led1 bit (=1 led on) * ' * var. Led2 bit (=1 led on) * ' * var. Led3 bit (=1 led on) * ' * var. Led4 bit (=1 led on) * ' ************************************************************************** ' Sub Conv_bit (byval Cifh As Byte , Byval Cifl As Byte) ' converts 2 digits for 5451 IC1 Local Tmp32 As Long Local Digit_0 As Word , Digit_1 As Word Bit32 = 0 Digit_0 = Conv14(cifh) ' converts a character in 14 segments ' low byte a,b,c,d,e,f,g,h for DY4 and DY3 ' high byte j,k,l,m,n,p,dp for DY4 and DY3 If Cifh > 127 Then ' is character > 127 ? ' turn on decimal point Digit_0 = Digit_0 Or &H4000 ' bit 14 = 1 End If Digit_1 = Conv14(cifl) ' converts a character in 14 segments ' byte 2 b,c,d,e,f,g,h,j for DY2 and DY1 ' byte 3 k,l,m,n,p,dp for DY2 and DY1 ' byte 3.6 = 1 DY1/2 and DY3/2 Off ' byte 3.7 = 1 DY1/1 and DY3/1 Off If Digit_1.0 = 1 Then ' if bit 0 ON Digit_0 = Digit_0 Or &H8000 ' set bit 15 to 1 End If Digit_1 = Digit_1 And &HFFFE ' clear bit 0 Shift Digit_1 , Right ' shift right onr bit If Cifl > 127 Then ' is character > 127 ? ' turn on decimal point Digit_1 = Digit_1 Or &H2000 ' bit 13 = 1 End If Digit_1 = Digit_1 Or &HC000 ' keep DY3 and DY1 OFF 'Assemble the 32 bits value of bit32 Bit32 = Digit_0 ' Low Word of bit 32 Tmp32 = Digit_1 ' High Word of bit 32 Shift Tmp32 , Left , 16 ' Shift word to more significant Bit32 = Bit32 + Tmp32 ' Merge the two word Bit3 = 3 ' bit3.0 = 1 DY2/2 and DY4/2 Off ' bit3.1 = 1 DY2/1 and DY4/1 Off ' bit3.2 = 0 LED1, 2, 3, 4 Off Select Case Disp ' which display match? Case 0 : Bit3.1 = 0 ' DY2/1 and DY4/1 ON If Led4 = 1 Then ' if LED4 to be ON Bit3.2 = 1 ' turn ON LED4 End If Case 1 : Bit3.0 = 0 ' DY2/2 and DY4/2 ON If Led3 = 1 Then ' if LED3 to be ON Bit3.2 = 1 ' turn ON LED3 End If Case 2 : Bit32 = Bit32 And &H7FFFFFFF ' DY1/1 and DY3/1 On If Led2 = 1 Then ' if LED2 to be ON Bit3.2 = 1 ' turn ON LED2 End If Case Is => 3 : Bit32 = Bit32 And &HBFFFFFFF ' DY1/2 and DY3/2 On If Led1 = 1 Then ' if LED1 to be ON Bit3.2 = 1 ' turn ON LED1 End If End Select End Sub ' ' ********* Converts a number from 0 to 127 in 14 segments code ******** ' * * ' * Parameters: 1 input, 1 output * ' * input : variable Digit type word (from 0 to 127) * ' * output: variable Digit type Word (conversion for 14 segments) * ' * * ' ********************************************************************** ' Function Conv14(byval Cifra As Byte) As Word ' Converts a number from 0 to 127 ' in 14 segments code Local Bit8 As Byte Bit8 = Cifra And &H7F ' mask values greater than 127 Conv14 = Lookup(bit8 , Tab_16seg) ' read from table ASCII character ' matched to the number End Function ' ' ************* Communicates to M5451 IC1 the outputs status *********** ' * Sends the content of variables Bit32 type Long, and Bit3. * ' * Variables Bit32 and Bit3 must be declared in internal RAM, * ' * otherwise assembler instructions cannot be executed. * ' * * ' * Parameters: 2 inputs * ' * input : variable bit32 type Long and Bit3 type byte * ' * output : nothing * ' ********************************************************************** ' Sub Send5451 ' Communicates to M5451 IC1 the ' outputs status, through the ' content of a 32+3 bit variable. Local I As Byte Call Sinc5451 ' Synchronize the sequence Psda = 1 ' start Call Sendclk ' start the sequence For I = 1 To 32 Call Testbit0 ' send bits from 0 to 31 Call Sendclk ' sequences from 1 to 32 Shift Bit32 , Right ' pins from 2 to 40 of 5451 ' connected to segments and dp Next I Bit32 = Bit3 ' Save bit3 to send it For I = 1 To 3 Call Testbit0 ' send bits from 32 to 34 Call Sendclk ' sequences from 33 to 35 Shift Bit32 , Right ' pins from 23 to 25 of 5451 Next I Psda = 0 Call Sendclk ' sequence 36 Call Sendclk ' sequence 37 End Sub ' ' *************** Moves bit0 of accumulator in bit Psda ********************** ' Parameters: none ' Input : nothing ' Output : nothing ' **************************************************************************** ' Sub Testbit0 Psda = Bit32.0 ' Least significant bit of ' Bit32 is sent to Data signal End Sub ' ' ************************ Outputs a CLK impulse ******************************* ' Parameters: ' Input : nothing ' Output : nothing ' ****************************************************************************** ' Sub Sendclk Pclk = 0 ' set CLK to zero Waitus 2 ' Waits for 2 usec Pclk = 1 ' set CLK to one Waitus 2 ' Waits for 2 usec End Sub ' ' *************************** Synchronize M5480 sequence *********************** ' This procedure outputs 37 CLK impulses to synchronize the data ' sequence. ' Parameters: ' Input : nothing ' Output : nothing ' ****************************************************************************** ' Sub Sinc5451 Local X As Byte Psda = 0 ' set data signal to zero For X = 1 To 37 ' repeat 37 times Call Sendclk ' output CLK impulse Next X End Sub ' ' ************************** LEDs On / Off management ************************** ' This procedure allows to turn on and off the 4 LEDs on the KAD 08 board. ' Parameters: ' Input : nothing ' Output : nothing ' ***************************************************************************** ' Sub Leds ' LEDs On / Off management Local T As Byte ' character received Print Chr(cler) ; ' clear the screen Print Print "LEDs On / Off management" Print "1) On / Off LED 1" Print "2) On / Off LED 2" Print "3) On / Off LED 3" Print "4) On / Off LED 4" Print "5) Exit" Print Print "SELECT DESIDERED LED : " Print Do T = Att_key() ' wait a key Select Case T Case "1" : Led1 = Not Led1 ' Turn On or Off LED 1 Case "2" : Led2 = Not Led2 ' Turn On or Off LED 2 Case "3" : Led3 = Not Led3 ' Turn On or Off LED 3 Case "4" : Led4 = Not Led4 ' Turn On or Off LED 4 End Select Loop Until T = "5" ' exit if "5" is pressed End Sub ' ' ******************** Input and display an ASCII character ******************* ' * This procedure allowa to show an ASCII character on the display. * ' * Parameters: nothing * ' * Ingresso: nothing * ' * Uscita: nothing * ' ***************************************************************************** ' Sub Ins_car ' Input and display an ASCII char Local Dis As Long ' indicates which decimal point is on Local T As Byte ' character received Print Print Do Print "Selezionare un display (1...8) ? " ; Dis = Iv() Loop Until Dis > 0 And Dis < 9 ' exit if lower than 9 Print Print "Input an ASCII character : "; Do T = Inkey() ' read a char from serial port Loop Until T <> 0 ' exit if received a char Print Chr(t) Select Case Dis Case 1 : C1 = T ' display character on DY4/1 Case 2 : C2 = T ' display character on DY4/2 Case 3 : C3 = T ' display character on DY3/1 Case 4 : C4 = T ' display character on DY3/2 Case 5 : C5 = T ' display character on DY2/1 Case 6 : C6 = T ' display character on DY2/2 Case 7 : C7 = T ' display character on DY1/1 Case 8 : C8 = T ' display character on DY1/2 End Select Call Press ' "Press a key..." message T = Att_key() ' wait for a key End Sub ' ' ************************ Insert decimal point ******************************* ' This procudire allows to turn on one of the 8 decimal points on the displays. ' Parameters: ' Input : nothing ' Output : nothing ' ****************************************************************************** ' Sub Decimal_point ' Insert decimal point Local T As Byte ' character received Print Print " Decimal point management" Print " 0) Turn off all decimal points" Print " 1) Turn on decimal point on DY4/1" Print " 2) Turn on decimal point on DY4/2" Print " 3) Turn on decimal point on DY3/1" Print " 4) Turn on decimal point on DY3/2" Print " 5) Turn on decimal point on DY2/1" Print " 6) Turn on decimal point on DY2/2" Print " 7) Turn on decimal point on DY1/1" Print " 8) Turn on decimal point on DY1/2" Print " 9) Exit" Print Do T = Att_key() ' wait for a key Select Case T Case "0" : Dp1 = 0 ' turn off Dp, reset bit7 of C1 Dp2 = 0 ' turn off Dp, reset bit7 of C2 Dp3 = 0 ' turn off Dp, reset bit7 of C3 Dp4 = 0 ' turn off Dp, reset bit7 of C4 Dp5 = 0 ' turn off Dp, reset bit7 of C5 Dp6 = 0 ' turn off Dp, reset bit7 of C6 Dp7 = 0 ' turn off Dp, reset bit7 of C7 Dp8 = 0 ' turn off Dp, reset bit7 of C8 Case "1" : Dp1 = 1 ' turn on Dp 1 Case "2" : Dp2 = 1 ' turn on Dp 2 Case "3" : Dp3 = 1 ' turn on Dp 3 Case "4" : Dp4 = 1 ' turn on Dp 4 Case "5" : Dp5 = 1 ' turn on Dp 5 Case "6" : Dp6 = 1 ' turn on Dp 6 Case "7" : Dp7 = 1 ' turn on Dp 7 Case "8" : Dp8 = 1 ' turn on Dp 8 End Select Loop Until T = "9" ' exit if "9" is pressed End Sub ' ' ***************** Display management demo ************************************ ' * This procedure shows the whole ASCII table sliding it from right to left * ' * character by character * ' * The non-printable characters are shown as a decimal point, also LEDs are * ' * turned on. * ' * Parameters: * ' * Input : nothing * ' * Output : nothing * ' ****************************************************************************** ' Sub Demo ' Display management demo Local D As Long ' general purpose Local T As Byte ' character received Call Press ' "Press a key..." message Do For D = 32 To 127 C8 = D Led1 = 0 ' turn off Led 1 Led2 = 1 ' turn on Led 2 Led3 = 0 ' turn off Led 3 Led4 = 1 ' turn on Led 4 Waitms 100 ' delay Led1 = 1 ' turn on Led 1 Led2 = 0 ' turn off Led 2 Led3 = 1 ' turn on Led 3 Led4 = 0 ' turn off Led 4 Waitms 100 ' delay T = Inkey() ' read char from serial port If T <> 0 Then ' a character is present Exit For ' exit from cycle For Else Call Ruota ' left shift the 8 displays End If Next D Loop Until T <> 0 ' exit if a key was pressed End Sub ' ' ****************** Wait for a key suspending the program ********************* ' Parameters: 1 output ' Input: nothing ' Output: type byte, contains the code received from the serial line ' ****************************************************************************** ' Function Att_key() As Byte Local T As Byte Do T = Inkey() ' read character from the serial Loop Until T <> 0 ' wait for a valid character Att_key = T ' Return the character End Function ' ' ****************************************************************************** ' Sub Press ' Press a key... message Print Print Print Print "Press a key to continue..." Print End Sub ' ' ************************ Decimal value input ****************************** ' * Parameters: 1 output * ' * Ingresso: * ' * Uscita: type byte, contains the value input through serial port * ' **************************************************************************** ' Function Iv() As Long Local Count As Byte ' number of characters received Local Key As Byte ' characters read Local Valore As String * 10 ' final string Local Strkey As String * 1 ' character read -> string Count = 0 ' Inizialize counter Valore = "" ' Inizialize string Do Do Key = Inkey() ' read one character Loop Until Key <> 0 ' exit if valid character If Count < 10 Then ' read less than 10 characters? Select Case Key ' If key read is... Case "0" To "9": ' ...a decimal figure Strkey = Chr(key) ' Converts in string Print Strkey; ' Echo Valore = Valore + Strkey ' Queues to final string Incr Count ' Increments counter End Select End If Loop Until Key = 13 ' Exits if Enter Print ' New line Iv = Val(valore) ' Returns final string End Function ' ' ****************************************************************************** ' Messaggio: Data " MENU " , 0 ' ' ************* Table for conversion from ASCII to 14 segments ***************** Tab_16seg: ' cod. 00 01 02 03 04 05 06 07 Data &H0000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% ' cod. 08 09 0A 0B 0C 0D 0E 0F Data &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% ' cod. 10 11 12 13 14 15 16 17 Data &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% ' cod. 18 19 1A 1B 1C 1D 1E 1F Data &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% , &H4000% ' cod. 20 SP 21 ! 22 " 23 # 24 $ 25 % 26 & 27 ' Data &H0000% , &H0880% , &H0082% , &H4000% , &H266D% , &H4000% , &H4000% , &H0040% ' cod. 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / Data &H0039% , &H000F% , &H3FC0% , &H2A80% , &H1000% , &H2200% , &H4000% , &H1100% ' cod. 30 0 31 1 32 2 33 3 34 4 35 5 36 6 37 7 Data &H113F% , &H0006% , &H221B% , &H220F% , &H2226% , &H222D% , &H223D% , &H0027% ' cod. 38 8 39 9 3A : 3B ; 3C < 3D = 3E > 3F ? Data &H223F% , &H222F% , &H4000% , &H4000% , &H0500% , &H2208% , &H1040% , &H0A23% ' cod. 40 @ 41 A 42 B 43 C 44 D 45 E 46 F 47 G Data &H02BB% , &H2237% , &H0A8F% , &H0039% , &H088F% , &H2039% , &H2031% , &H023D% ' cod. 48 H 49 I 4A J 4B K 4C L 4D M 4E N 4F O Data &H2236% , &H0889% , &H001E% , &H2530% , &H0038% , &H00B7% , &H0476% , &H003F% ' cod. 50 P 51 Q 52 R 53 S 54 T 55 U 56 V 57 W Data &H2233% , &H043F% , &H2633% , &H222D% , &H0881% , &H003E% , &H1130% , &H083E% ' cod. 58 X 59 Y 5A Z 5B [ 5C \ 5D ] 5E ^ 5F - Data &H1540% , &H0940% , &H1109% , &H0039% , &H0440% , &H000F% , &H0102% , &H2200% ' cod. 60 ` 61 a 62 b 63 c 64 d 65 e 66 f 67 g Data &H0100% , &H2237% , &H223C% , &H2218% , &H221E% , &H2039% , &H2231% , &H023D% ' cod. 68 h 69 i 6A j 6B k 6C l 6D m 6E n 6F o Data &H2234% , &H0800% , &H001E% , &H2530% , &H0880% , &H2A14% , &H2A04% , &H221C% ' cod. 70 p 71 q 72 r 73 s 74 t 75 u 76 v 77 w Data &H2233% , &H2227% , &H0A00% , &H222D% , &H2038% , &H001C% , &H1010% , &H081C% ' cod. 78 x 79 y 7A z 7B { 7C | 7D } 7E ~ 7F Data &H1540% , &H1140% , &H1109% , &H4000% , &H0880% , &H4000% , &H4000% , &H4000% ' ****************************************************************************** '