Shop OBEX P1 Docs P2 Docs Learn Events
Shift << >> — Parallax Forums

Shift << >>

mdawebmdaweb Posts: 8
edited 2013-01-04 11:43 in BASIC Stamp
Hello, this is my first post, I'm having problems with vertical scroll, I can scroll up, I can not scroll down, swapped the shifft by Shift << >> but only the first number and rolled down, the second does not appear , which may be wrong.

Ay help will be appreciated thanks.

MDAWEB

Rio de Janeiro Brasil.
 xScroll_V_UP_MAX7219: 
 LOOKUP UltimaMarcha,[um,dois,trez,quatr,cinco,re_,neutro], UltimaUP
 LOOKUP marchaatual, [um,dois,trez,quatr,cinco,re_,neutro], AtualUP
 FOR row = 1 TO 9

     FOR col = 1 TO 5

        READ (UltimaUP + col - 1),vScroll.LowByte
        READ (atualUP + col - 1),vScroll.HighByte

        d7219 = vScroll >> (row - 1) ' get "frame"

        SHIFTOUT Dpin,Clock,MSBFirst,[col,d7219]

        PULSOUT Load,Speed 

     NEXT

     PAUSE 600

 NEXT

 PAUSE 100
 return 
 xScroll_V_DW_MAX7219: 


 LOOKUP UltimaMarcha,[um,dois,trez,quatr,cinco,re_,neutro], UltimaDW
 LOOKUP marchaatual, [um,dois,trez,quatr,cinco,re_,neutro], AtualDW

 FOR row = 1 TO 9 

     FOR col = 1 TO 5

        READ (UltimaDW + col - 1),vScroll.LowByte
        READ (AtualDW + col - 1),vScroll.HighByte

        vScroll.LwByte is Scrolled
        vScroll.HighByte is Blank on Display

        d7219 = vScroll << (row - 1) ' get "frame" 

        SHIFTOUT Dpin,Clock,MSBFIRST,[col,d7219]

        PULSOUT Load,Speed 

     NEXT

     PAUSE 1000

 NEXT

 PAUSE 100
 return

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2013-01-02 06:09
    Hello and welcome to the forum. It's really hard to read code when it is not indented. Take a look at this:

    attachment.php?attachmentid=78421&d=1297987572

    BTW the easiest way to think about the shift operators is that they double or half the left hand quantity the number of times specified by the right hand operand.

    So 2 << 3 yields 16 because it can be written out as 2 * (2 * 2 * 2))

    Conversely 16 >> 3 yields 2 because it can be written out as 16 / (2 * 2 * 2).
  • mdawebmdaweb Posts: 8
    edited 2013-01-02 06:30
    Hello Martin_H, sorry about the code, fix now.

    But I still do not understand what could be wrong, sorry I do not understand. as would be the solution in code?
  • Martin_HMartin_H Posts: 4,051
    edited 2013-01-02 08:01
    I read through the two routines and except for different variable names they're basically the same, but differ with this line of code.
    In xScroll_V_UP_MAX7219 you have
    
            d7219 = vScroll >> (row - 1) ' get "frame"
    
    and in xScroll_V_DW_MAX7219 you have
    
            d7219 = vScroll << (row - 1) ' get "frame" 
    

    In the top case you are dividing vScoll by 1, 2, 4, 8, ..., 256 and in the bottom case you are multiplying by the same numbers. So the result deposited into d7219 is really going to depend upon what you put into vScoll and if that's what you expected when you read from the EEPROM. Are you familiar with PBasic's DEBUG statement? I would add

    DEBUG "row = ", DEC row, " vScroll = ", DEC vScroll, CR

    to see what's going on with that variable.
  • mdawebmdaweb Posts: 8
    edited 2013-01-02 09:32
    Ok, I'll add a debug line, good idea, I was trying bebug in Proteus ISIS, but the window variables, problems with this, and I can not see its value.

    Tk's
  • mdawebmdaweb Posts: 8
    edited 2013-01-03 03:50
    Hi, I'm having trouble with command DEBUG, garbage out only on the ISIS Virtual Terminal, the settings are as follows:

    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 1
    DEFINE DEBUG_REG PORTB
    DEFINE DEBUG_BIT 7

    The Virtual Terminal ISIS is configured as:

    9600
    8
    N
    1

    I'm just sending this: DEBUG "UP"

    Any trick? I never used this command!

    Any tips, idea of what can be?

    Tnk´s
  • Martin_HMartin_H Posts: 4,051
    edited 2013-01-03 09:55
    Are you using the PBasic IDE? It has a built in serial terminal that is preconfigured to work. It also automatically pops up when it receives debug output.

    If not then take a look at page 33 of the manual http://www.parallax.com/dl/docs/prod/stamps/web-bsm-v2.2.pdf

    It discusses a simple hello world program and seeing the output in a serial terminal. The code is:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DEBUG "Hello World!"
    

    The serial terminal should be set to the same COM port you downloaded the program over, 9600 baud rate, 8 data bits, no flow control, and no parity bits.
  • mdawebmdaweb Posts: 8
    edited 2013-01-03 11:48
    Ok, the problem was the define OSC sets in this Picbasic with 4MHz, PIC and was 20MHZ, debug resolved.
  • mdawebmdaweb Posts: 8
    edited 2013-01-04 07:10
    Ok Guys, I managed to make UP and Down, was easy, was obvious.

    Net Regards
  • Martin_HMartin_H Posts: 4,051
    edited 2013-01-04 07:15
    mdaweb wrote: »
    Ok Guys, I managed to make UP and Down, was easy, was obvious.

    Net Regards

    Great, glad to hear it.

    BTW If you edit your first post in the thread and go advanced, you can change the status to solved.
  • mdawebmdaweb Posts: 8
    edited 2013-01-04 11:36
    What does BTW?
  • Martin_HMartin_H Posts: 4,051
    edited 2013-01-04 11:37
    mdaweb wrote: »
    What does BTW?

    BTW = By the way

    It looks like someone marked this solved.
  • mdawebmdaweb Posts: 8
    edited 2013-01-04 11:43
    I myself who scored solved!!

    Thank you for your attention, show the ball!!

    [] '

    Mauro de Amorim
Sign In or Register to comment.