Numeric conversion trouble - Page 2


+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20

Thread: Numeric conversion trouble882 days old

  1. #16
    NEX
    Guest NEX's Avatar

    0 Not allowed!

    Default Re: Numeric conversion trouble

    Hi John
    Sorry for my not clear explanation , in my first example I have insert also preamble code, any way I need only 4 bytes big endian conversion, I are sure it will be necessary a Dword variable because a value number could exceed 65535 limit. I show you some sample :

    9800 = 48 26 00 00
    70000 = 70 11 01 00
    1800 = 08 07 00 00
    269 = 0D 01 00 00

    Unfortunately Nextion display send numeric value as BIG ENDIAN (motorola standard) , instead little endian is (intel standard)

    Thanks NEX

  2. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #17
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,887
    Thumbs Up
    Received: 91
    Given: 34
    Total Downloaded
    4.60 GB

    0 Not allowed!

    Default Re: Numeric conversion trouble

    That's helpful Nex.
    I'll have a try at a different solution. Might be a day or two.
    John
    Last edited by John Drew; 10th January 2018 at 12:07. Reason: tablet changed name by itself- sorry

  4. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #18
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,354
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    1 Not allowed!

    Default Re: Numeric conversion trouble

    Again I'm sure this isn't the best way to do it but
    Code:
    Device = 16F690
      
      Dim Dwd As Dword ' Create a 32-bit unsigned variable named Dwd
      Dim Part1 As Dwd.Byte0 ' Alias unsigned Part1 to the low byte of Dwd
      Dim Part2 As Dwd.Byte1 ' Alias unsigned Part2 to the 2nd byte of Dwd
      Dim Part3 As Dwd.Byte2 ' Alias unsigned Part3 to the 3rd byte of Dwd
      Dim Part4 As Dwd.Byte3 ' Alias unsigned Part3 to the high (4th) byte of Dwd
      
      '  9800 = 48 26 00 00
      '  70000 = 70 11 01 00
      '  1800 = 08 07 00 00
      '  269 = 0D 01 00 00
      
      Part1 = $48
      Part2 = $26
      Part3 = $00
      Part4 = $00
      ' Dwd = 9800 = $2648
    
      Part1 = $70
      Part2 = $11
      Part3 = $01
      Part4 = $00
      ' Dwd = 70000 = $11170
      
      Part1 = $08
      Part2 = $07
      Part3 = $00
      Part4 = $00
      ' Dwd = 1800  = $708
      
      Part1 = $0D
      Part2 = $01
      Part3 = $00
      Part4 = $00
      ' Dwd = 269  = $10D
      Stop
    George.

  6. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #19
    NEX
    Guest NEX's Avatar

    0 Not allowed!

    Default Re: Numeric conversion trouble

    Yes , thanks a lot , this is a possible way

  8. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #20
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,596
    Thumbs Up
    Received: 339
    Given: 162
    Total Downloaded
    1.99 GB

    1 Not allowed!

    Default Re: Numeric conversion trouble

    If it is just the byte order that requires converting, George's code is extremely efficient, and a good choice.

    You can also use the Swap command to reverse the byte orders and make a meta-macro to make the code easier to read:

    For example:
    Code:
        Device = 18F25K20
        Declare Xtal = 64 
    
        Dim MyDword As Dword
    
    '---------------------------------------------
    ' Reverse the byte order of a 16-bit variable
    ' Input     : pVariable holds the variable to reverse
    ' Output    : pVariable holds the variable reversed
    ' Notes     : Only for 16-bit variables
    '   
    $define Rev_Endian16(pVariable) Swap pVariable.Byte0, pVariable.Byte1
          
    '---------------------------------------------
    ' Reverse the byte order of a 32-bit variable
    ' Input     : pVariable holds the variable to reverse
    ' Output    : pVariable holds the variable reversed
    ' Notes     : Only for 32-bit variables
    '  
    $define Rev_Endian32(pVariable)           '   
        Swap pVariable.Byte0, pVariable.Byte3 '
        Swap pVariable.Byte1, pVariable.Byte2
        
              
    '--------------------------------------------------------------
    Main:
        MyDword = $01020304             ' Pre-load MyDword with a value to reverse
        Rev_Endian32(MyDword)           ' Reverse the bytes in MyDword
        Stop
    In the above example. the original value of MyDword is $01020304, but after using Rev_Endian32, MyDword contains $04030201 and the byte order is reversed. It's also quite efficient and only required 8 asm mnemonics to do the reversing.

    If a Word variable needs reversing, use Rev_Endian16.
    Last edited by top204; 11th January 2018 at 19:59.

  10. Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. 3x4 alpha numeric keypad
    By amod in forum Absolute Beginners Section
    Replies: 21
    Last Post: 26th September 2019, 17:53
  2. Print using a SPI I/O expander to a Alpha numeric display
    By yvesmazzon in forum Projects discussion
    Replies: 1
    Last Post: 22nd September 2017, 11:42
  3. “Print” command for SPI Alfa numeric LCD?
    By barak in forum LCD module
    Replies: 16
    Last Post: 9th February 2011, 10:43
  4. [SOLVED !] Large numeric font for GLCD
    By ~ Sy ~ in forum The Lounge
    Replies: 3
    Last Post: 10th August 2009, 08:58
  5. Text and numeric data to strings.
    By RGV250 in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 22nd October 2007, 00:31

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts