Confused.... Help Please!


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    I was unsure as to whether or not you could only shoot down the front number or any number in the line, so long as the number was equal to the target of course.

    The problem I am having is actually getting the nubers to scroll across the LCD you see i have a 2 x 16 LCD running on port.B 4 buttons below it running on Port.A 0-3 the 627 and the required resistors etc (my dad built it specifically for this project)

    The code I originally found for scrolling text across the screen was this

    Code:
      FOR B0 = 144 TO 128 STEP -1
      LCDOUT $FE, 1  ' Clears Screen (not needed)
      LCDOUT $FE,B0,"This Is A Test!!"          'OUTPUT TO LCD SLIDE
      PAUSE 1000                                         'IN FROM RIGHT LINE 1
      NEXT
    The above code simply steps the string in 1 character at a time from the far right of line 1 until it reaches the far left.

    Of course this is using a predefined string and isnt suitable for what I need to be doing, since I need to be bringing them in from the right while removing characters from it and maintaining the position of the existing numbers.

    If how you describe the game being played is actually as it was (similar to the clone I linked)
    then if the below example occured I would need to do the following

    5: 4385559271 ---> 5: 438 9271 and continue adding onto the end and shifting the characters from right to left, at the same time I need to be checking to see if a number has reached the ship... I was thinking of possibly using LCDIN on the cell after the "5:" and checking to see if it had a number in it during the loop which adds another.

    This would of course allow me to determine whether or not the player is out, since if a number is in that cell and another is being added then it would hit the :

    I just dont know how to get them to scroll and remove numbers in between without losing positioning like the example above, I am terrible when it comes to overcomplicating and thus need a little advice for an approach.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by UKIkarus View Post
    5: 4385559271 ---> 5: 438 9271
    It would go from 4385559271 -->4389271. No space in it.

    Don't think of scrolling the display. Think of your array like this:

    If I have 31 positions for the numbers, They will be T(30) to t(0)
    each "scroll" is really just an update to the LCD, sending array positions T(30)-T(0)
    with all the elements shifted 1 place to the left. (new targets enter from the right?)
    you will be able to do MANY operations before time to scroll again. Those many operations are the checking for hits, adjusting the array and so forth.

    Keep this in mind, assuming you are running 4mHz internal clock (no I haven't looked at the datasheet) thats 1 million inscrutions per second. if you want to scroll at a rate of .1 second, you have time left over for 100,00 inscrutions. So the "scrolling" is just a quick task, then done.

    Now I have no idea how to actually write to the LCD, but I am assuming you just send it all the characters serially and not address each charater randomly. So your array may need to be 64 bytes instead of 32.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    It would go from 4385559271 -->4389271. No space in it.

    Don't think of scrolling the display. Think of your array like this:

    If I have 31 positions for the numbers, They will be T(30) to t(0)
    each "scroll" is really just an update to the LCD, sending array positions T(30)-T(0)
    with all the elements shifted 1 place to the left. (new targets enter from the right?)
    you will be able to do MANY operations before time to scroll again. Those many operations are the checking for hits, adjusting the array and so forth.

    Keep this in mind, assuming you are running 4mHz internal clock (no I haven't looked at the datasheet) thats 1 million inscrutions per second. if you want to scroll at a rate of .1 second, you have time left over for 100,00 inscrutions. So the "scrolling" is just a quick task, then done.

    Now I have no idea how to actually write to the LCD, but I am assuming you just send it all the characters serially and not address each charater randomly. So your array may need to be 64 bytes instead of 32.
    So would you shift the 438 right to meet the 9271 or the opposite? because if its the opposite then it isnt really helping the player by shooting the middle numbers now is it? since they continue to be in the same position and will just keep adding on... unless of course they then shoot the front numbers

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by UKIkarus View Post
    So would you shift the 438 right to meet the 9271
    Yes, that way the player keeps the targets from hitting the ship.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default new approach

    Ok, Lets establish some basics first.

    In your first post, you have a program that scrolls numbers across the screen at a rate of 1 sec per number. correct?

    You are reading the numbers from an array, correct?

    So if you take out the pause, it will just instantly display the whole array? If yes, this is your LCD update. call this every time you need to change the display.

    reasons to update or change:
    1. time to scroll
    2. aim button pressed so you need to change the aim number
    3. fire button pressed AND a hit is made

    Now you can forget about the LCD. when you update it, send all 32 characters to it (unless random access is available, but this will take more code and understanding). The game portion of the program will minipulate the array so everytime in update is done, the numbers will be where they should be. Because they will be in the same position as they are in the array.

    If none of this makes sense, please tell me where you are lost. This applies to all of my above posts.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    oh yea, one more thing. Ask dad if there is any hardware de-bouncing on the switches. If not, they will be something you will need to deal with in software.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Ok i can rebuild the array as you say and debouncing i have done in the software, the problem i have is that the scrolling text code only is a for next loop which is running cell by cell on the lcd not updating the whole thing.

    I could update the whole thing by starting with 14 blank array spaces at start rather than filling it all, and adapt the array 1 by 1 that way until 0-13 are filled with the numbers behind them (coming from the right) that way i can just update the lcd everytime with NOS[1-14] which will be the only onscreen values since 1-2 are taken by the number followed by a colon.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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