Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Giant numbers on alphanumeric display 2x16 (Basic Oshonsoft).

Status
Not open for further replies.

DogFlu66

Member
Giant numbers on alphanumeric display.
Writing large numbers on a 2x16 alphanumeric display
This time I leave you a function to use large numbers on an alphanumeric screen, I hope you like it.

Code:
'*************************************************************
'Writing large numbers in alphanumeric display 2x16.
'By COS, 02/2023
'Pic Basic Compiler (PSI), v8.38, Pic16F88
'*************************************************************
'Generation of patterns
'2x3 digit proportional numbers
'Enlarges the numbers contained in the variable number.
'-------------------------------------------------------------
Define CONFIG = 0x2f70
Define CONFIG2 = 0x3ffc
Define CLOCK_FREQUENCY = 8  'Oscilador a 8Mhz
Define SIMULATION_WAITMS_VALUE = 1  'Activate for simulation.
'Include "_FuncionesPic16F88.bas"
'--------------------------------------------------------------
AllDigital
ConfigPin PORTA = Output
ConfigPin PORTB = Output
'Configuration lcd ports. -------------------------------------
Define LCD_BITS = 4  'Data bus length to 4bits
Define LCD_DREG = PORTA  'Data bus: puerto A
Define LCD_DBIT = 0  'Least significant bit of the data bus.
Define LCD_RSREG = PORTB  'Rs control bit on port B
Define LCD_RSBIT = 7  'RS bit on RB7 pin.
Define LCD_EREG = PORTB  'E control bit on port B.
Define LCD_EBIT = 6  'E pin on RB6 pin
Define LCD_COMMANDUS = 2000  'Wait after each command in uSec.
Define LCD_DATAUS = 100  'Wait after sending a data to the LCD in uSec.
Define LCD_INITMS = 50  'Wait during display initialization in mSec.
'---------------------------------------------------------------------
Lcdinit  'Lcd withou cursor
'---------------------------------------------------------------------
'Initialize characters in the lcd CGRam for big numbers.
Call _IntStrNBig()
Lcdout "Patrones:"
Lcdcmdout LcdLine2Home
Lcdout 0, 1, 2, 3, 4, 5, 6, 7, 255  'Display the new characters.
WaitMs 3000
Lcdcmdout LcdClear  'Clear LCD
'*********************************************************************
void_main:
    'Variables
    Dim _String As String
    Dim numero As Long
    Dim x As Bit
    x = 1
    numero = 0
    While x  'Main loop
        _String = #numero  'Transform numeric variable to string type.
        Call _StrNBig(_String, 1)  'Write bit number.
        Lcdcmdout LcdLine2Pos(_StrNBig)  'Move cursor
        Lcdout #numero  'Write a number in normal size.
        numero++  'Increment then number.
        WaitMs 100
    Wend
End                                            
'*********************************************************************
'Creates the new characters and saves them in then Lcd CGRam.
Proc _IntStrNBig()
    Lcddefchar 0, %11111, %11111, %11111, 0, 0, 0, 0, 0  'Upper horizontal bar.
    Lcddefchar 1, 0, 0, 0, 0, 0, %11111, %11111, %11111  'Bottom horizontal bar.
    Lcddefchar 2, %11111, %11111, %11111, 0, 0, 0, %11111, %11111  'Bars h. upper and lower.
    Lcddefchar 3, %11100, %11110, %11110, %11110, %11110, %11110, %11110, %11100  'Right arrow
    Lcddefchar 4, %00111, %01111, %01111, %01111, %01111, %01111, %01111, %00111  'Left arrow
    Lcddefchar 5, %00000, %00000, %00000, %00000, %00000, %00011, %00111, %01111  'All full.
    Lcddefchar 6, %00011, %00111, %01111, 0, 0, 0, 0, 0  'Short top horizotal bar.
    Lcddefchar 7, 0, 0, 0, 0, 0, %11000, %11100, %11110  'Short bottom horizotal bar.
    Lcdcmdout LcdClear  'Clear LCD
End Proc                                      
'**********************************************************************
'Function that enlarges the numeric characters of a string
'Limited string length, written for 2-line lcd
'_String: numeric string to write.
'Xpos: Starting position to print on the LCD
'_strngrandes: Returns the next position to print
'Call _StrNBig(String, position To print)
'*********************************************************************
Function _StrNBig(_String As String, _Xpos As Byte) As Byte
    Dim _data As Byte  'Mask
    Dim _index As Byte  'Index mask.
    Dim _x As Byte  'Character position of then string.
    Dim _bucle As Bit  'Loop check.
    _bucle = True
    _x = 0
    'Loop
    While _bucle = True
        Lcdcmdout LcdLine1Pos(_Xpos)  'Lcd cursor position.
        For _index = 0 To 5  'Upper and lower mask print control loop.
            If _String(_x) = "0" Then _data = LookUp(4, 0, 3, 4, 1, 3), _index  'Mask for "0"
            If _String(_x) = "1" Then _data = LookUp(6, 255, " ", 5, 255, 7), _index  'Mask for "1"
            If _String(_x) = "2" Then _data = LookUp(6, 2, 3, 4, 1, 7), _index  'Mask for "2"
            If _String(_x) = "3" Then _data = LookUp(6, 2, 3, 5, 1, 3), _index  'M. for "3"
            If _String(_x) = "4" Then _data = LookUp(4, 1, 255, " ", " ", 255), _index  'M. for "4"
            If _String(_x) = "5" Then _data = LookUp(4, 2, 0, 5, 1, 3), _index  'M. "5"
            If _String(_x) = "6" Then _data = LookUp(4, 2, " ", 4, 1, 3), _index  'M. for "6"
            If _String(_x) = "7" Then _data = LookUp(6, 0, 3, " ", 255, " "), _index  'M. for "7"
            If _String(_x) = "8" Then _data = LookUp(4, 2, 3, 4, 1, 3), _index  'M. for "8"
            If _String(_x) = "9" Then _data = LookUp(4, 2, 3, " ", " ", 255), _index  'M. for "9"
            Lcdout _data  'Printe current mask.
            If _index = 2 Then
                Lcdcmdout LcdLine2Pos(_Xpos)  'Sets position on line 2
                _Xpos = _Xpos + 3  'Position of the new digit.
            Endif
        Next _index
        _x++  'Next digit to print.
        If _String(_x) = 0 Then  'If end of string?.
            _StrNBig = _Xpos  'Function returns the next position to write to the lcd.
            Exit  'End, it returns.
        Endif
    Wend
End Function

Video:
Big Numbers on Lcd 2x16.

BigNumbers.jpg
 
Last edited:
Giant numbers on alphanumeric display.
Writing large numbers on a 2x16 alphanumeric display
This time I leave you a function to use large numbers on an alphanumeric screen, I hope you like it.

Code:
'*************************************************************
'Writing large numbers in alphanumeric display 2x16.
'By COS, 02/2023
'Pic Basic Compiler (PSI), v8.38, Pic16F88
'*************************************************************
'Generation of patterns
'2x3 digit proportional numbers
'Enlarges the numbers contained in the variable number.
'-------------------------------------------------------------
Define CONFIG = 0x2f70
Define CONFIG2 = 0x3ffc
Define CLOCK_FREQUENCY = 8  'Oscilador a 8Mhz
Define SIMULATION_WAITMS_VALUE = 1  'Activate for simulation.
'Include "_FuncionesPic16F88.bas"
'--------------------------------------------------------------
AllDigital
ConfigPin PORTA = Output
ConfigPin PORTB = Output
'Configuration lcd ports. -------------------------------------
Define LCD_BITS = 4  'Data bus length to 4bits
Define LCD_DREG = PORTA  'Data bus: puerto A
Define LCD_DBIT = 0  'Least significant bit of the data bus.
Define LCD_RSREG = PORTB  'Rs control bit on port B
Define LCD_RSBIT = 7  'RS bit on RB7 pin.
Define LCD_EREG = PORTB  'E control bit on port B.
Define LCD_EBIT = 6  'E pin on RB6 pin
Define LCD_COMMANDUS = 2000  'Wait after each command in uSec.
Define LCD_DATAUS = 100  'Wait after sending a data to the LCD in uSec.
Define LCD_INITMS = 50  'Wait during display initialization in mSec.
'---------------------------------------------------------------------
Lcdinit  'Lcd withou cursor
'---------------------------------------------------------------------
'Initialize characters in the lcd CGRam for big numbers.
Call _IntStrNBig()
Lcdout "Patrones:"
Lcdcmdout LcdLine2Home
Lcdout 0, 1, 2, 3, 4, 5, 6, 7, 255  'Display the new characters.
WaitMs 3000
Lcdcmdout LcdClear  'Clear LCD
'*********************************************************************
void_main:
    'Variables
    Dim _String As String
    Dim numero As Long
    Dim x As Bit
    x = 1
    numero = 0
    While x  'Main loop
        _String = #numero  'Transform numeric variable to string type.
        Call _StrNBig(_String, 1)  'Write bit number.
        Lcdcmdout LcdLine2Pos(_StrNBig)  'Move cursor
        Lcdout #numero  'Write a number in normal size.
        numero++  'Increment then number.
        WaitMs 100
    Wend
End                                         
'*********************************************************************
'Creates the new characters and saves them in then Lcd CGRam.
Proc _IntStrNBig()
    Lcddefchar 0, %11111, %11111, %11111, 0, 0, 0, 0, 0  'Upper horizontal bar.
    Lcddefchar 1, 0, 0, 0, 0, 0, %11111, %11111, %11111  'Bottom horizontal bar.
    Lcddefchar 2, %11111, %11111, %11111, 0, 0, 0, %11111, %11111  'Bars h. upper and lower.
    Lcddefchar 3, %11100, %11110, %11110, %11110, %11110, %11110, %11110, %11100  'Right arrow
    Lcddefchar 4, %00111, %01111, %01111, %01111, %01111, %01111, %01111, %00111  'Left arrow
    Lcddefchar 5, %00000, %00000, %00000, %00000, %00000, %00011, %00111, %01111  'All full.
    Lcddefchar 6, %00011, %00111, %01111, 0, 0, 0, 0, 0  'Short top horizotal bar.
    Lcddefchar 7, 0, 0, 0, 0, 0, %11000, %11100, %11110  'Short bottom horizotal bar.
    Lcdcmdout LcdClear  'Clear LCD
End Proc                                   
'**********************************************************************
'Function that enlarges the numeric characters of a string
'Limited string length, written for 2-line lcd
'_String: numeric string to write.
'Xpos: Starting position to print on the LCD
'_strngrandes: Returns the next position to print
'Call _StrNBig(String, position To print)
'*********************************************************************
Function _StrNBig(_String As String, _Xpos As Byte) As Byte
    Dim _data As Byte  'Mask
    Dim _index As Byte  'Index mask.
    Dim _x As Byte  'Character position of then string.
    Dim _bucle As Bit  'Loop check.
    _bucle = True
    _x = 0
    'Loop
    While _bucle = True
        Lcdcmdout LcdLine1Pos(_Xpos)  'Lcd cursor position.
        For _index = 0 To 5  'Upper and lower mask print control loop.
            If _String(_x) = "0" Then _data = LookUp(4, 0, 3, 4, 1, 3), _index  'Mask for "0"
            If _String(_x) = "1" Then _data = LookUp(6, 255, " ", 5, 255, 7), _index  'Mask for "1"
            If _String(_x) = "2" Then _data = LookUp(6, 2, 3, 4, 1, 7), _index  'Mask for "2"
            If _String(_x) = "3" Then _data = LookUp(6, 2, 3, 5, 1, 3), _index  'M. for "3"
            If _String(_x) = "4" Then _data = LookUp(4, 1, 255, " ", " ", 255), _index  'M. for "4"
            If _String(_x) = "5" Then _data = LookUp(4, 2, 0, 5, 1, 3), _index  'M. "5"
            If _String(_x) = "6" Then _data = LookUp(4, 2, " ", 4, 1, 3), _index  'M. for "6"
            If _String(_x) = "7" Then _data = LookUp(6, 0, 3, " ", 255, " "), _index  'M. for "7"
            If _String(_x) = "8" Then _data = LookUp(4, 2, 3, 4, 1, 3), _index  'M. for "8"
            If _String(_x) = "9" Then _data = LookUp(4, 2, 3, " ", " ", 255), _index  'M. for "9"
            Lcdout _data  'Printe current mask.
            If _index = 2 Then
                Lcdcmdout LcdLine2Pos(_Xpos)  'Sets position on line 2
                _Xpos = _Xpos + 3  'Position of the new digit.
            Endif
        Next _index
        _x++  'Next digit to print.
        If _String(_x) = 0 Then  'If end of string?.
            _StrNBig = _Xpos  'Function returns the next position to write to the lcd.
            Exit  'End, it returns.
        Endif
    Wend
End Function

Video:
Big Numbers on Lcd 2x16.

View attachment 140541
Hi D,
It looks interesting, and I've copied it for a later date.
I don't have the IDE for that PIC installed, so I'll look again later. (I'm using the mid range 18 series)

I'm using Nokia phone screens at the moment (I can post link) , and hope to advance to TFT screen later.
Cheers, C
 
Last edited:
The function is compatible with any other oshonsoft compiler, you just have to reconfigure the fuses and ports.

Cheers.
It may be ok for the “Basic Compiler” versions, but not for the IDE which does not support elements like x++
i will recheck with latest version of IDE, to see if there was an update, so I may be wrong ( but my ide fails to compile the x++ type of element).
 
Can I ask why you do,
Code:
    Dim x As Bit
    x = 1
    While x  'Main loop
Instead of
Code:
    While 1
I'm slowly learning Oshonsoft and wonder if this is a limitation of the compiler.

Mike.
Edit BTW, might have a go at converting this to C but will credit you of course.
 
That is true, you have to update to the latest version that allows several expressions equivalent to the C language.

x++ => x=x+1
I tried the latest version of the IDE and it does not support those constructs. There are 2 versions of Oshonsoft, the IDE with perpetual license and the Basic Compiler version that has those C types of constructs, but requires annual license renewals. Both products are current. The IDE is an older product but owner does not put new development into it, just bug fixes.
The IDE can compile as well, and does a good job at it, but developer just was not making much money at it so he launched a new version that requires annual license .
 
While 1; I did not know that it was allowed, until a few weeks ago it would give an error when compiling. I use the version with annual license (OshonSoft PICxx Basic Compiler), but I also have the others (Picxx Simulator IDE), I will check the others.
 
If you have the annual Basic Compiler version, then you have a license for the "extensions" that may be used by the IDE. There are paid-for options for the IDE (I think?), so I suspect your Full Basic version has those libraries on your system and the IDE picks them up.
The IDE only systems do not support that "out of the box".
Oh well, it is what it is....
 
Last edited:
I have the standard full registered licenses for the IDE, but they are several years old...

EDIT: Ok, I just downloaded the latest IDE version (Feb. 2023), and it now accepts the X++ statement.
 
Last edited:
I bought the commercial license of OshonSoft many years ago in an offer for a few euros. And I continue to maintain it over the years. In any case, this is just as a hobby because the commercial automations that I develop are programmed in C from CCS.
Basic is just a hobby since I started programming on it with the Spectrum 48K.
 
I bought the commercial license of OshonSoft many years ago in an offer for a few euros. And I continue to maintain it over the years. In any case, this is just as a hobby because the commercial automations that I develop are programmed in C from CCS.
Basic is just a hobby since I started programming on it with the Spectrum 48K.
Hi D,
I also started programming with my sons Christmas present 48K Spectrum, because the Tv was the screen, so by osmosis. I'm no programmmer, and haven't moved on like you to the 'C's.
C
 
Hi,
My best thing was a photographic lab, for 35mm to large format B/W and transparency film processing, and 16x24 colour prints, all controlled by Specrums.

I have the greatest respect for them, and the well designed instruction book.
C
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top