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

    Hey guys, thanks for the support before...

    I was indeed heading down the wrong path with my approaches in the end I just put the Ascii equivilents of the numbers 0-9 and "n" into the array instead of trying to tell the LCD to display the Decimal values...

    MUCH EASIER

    Timing is a bit of a pain, since the main loop counts and GoSub's to other areas (this adds about half a second to the count sometimes) but I'm working on that.

    Guess my main problem is my habit of keep looking at "visual" syntax as a reference, since everything appears to run simultaniously... where as on this its loops in loops all the time hehe.


    EDIT: Now that I have that sorted, once the code is working and bugs ironed out I will rename the variables to something that makes sense to others reading it and upload the source with the hardware layout for those interested.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    COOL!!!
    I am looking forward to seeing/playing it. could use a little fun!
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I seem to have hit a bit of a problem, when I compile the code everything is fine it shows 0 errors 0 warnings but 2 suppressed (cant seem to get any output on these).

    However when I go to program the PIC with the compiled code it just loops forever on programming and will not actually write to the PIC.

    I have checked all settings including con bits all is fine, I had an issue like this before when i placed a return in the code without anything to return to but that is no longer the case... I am stuck

    EDIT: Nevermind power ran out on the pack powering the board
    Last edited by UKIkarus; - 7th October 2010 at 15:47.

  4. #4
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Hi Guys,

    According to the manual, the "BUTTON" function acts as a "GOTO" to a defined label (the last argument) with the added bonus of disabling auto-repeat and or debounce... does anybody know if the same can be used to GOSUB?

    or know of a solution to do the same?

    Since I have loops within loops the button presses keep being registered, but I cannot use the BUTTON function to GOTO since it will reset the count on the main loop

    Code:
    MAIN:
      FOR CNT2 = 1 TO CNT
      IF PORTA.3 = 1 THEN GOSUB SHIP
      IF PORTA.0 = 1 THEN GOSUB FIRE
      IF CNT2 == CNT THEN GOSUB ADD
      GOSUB LCDUPDATE
      PAUSE 5
      NEXT
      GOTO MAIN
    As you can see I am using GOSUB as to not interrupt the "for..next" loop doing the count, but I need a way of stopping auto repeat on the button checks... (without pausing since this messes up the count timing) unless there is another way to have a definitive count?

    (watchdog timer perhaps? never used it)

    Basically so that when the user presses the button it will only increment by 1 and not auto repeat (due to the instructions per second) and increment by about 70 per press

    Any help will be greatly appreciated!

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


    Did you find this post helpful? Yes | No

    Default

    To make the button gosub instead of goto to, 1 solution is :
    Code:
    main 
     button goto no_ship 'if button is NOT pressed, skip the gosub
     gosub ship   ' if button was pressed gosub and return
    no_ship
     button goto no_fire 
     gosub fire
    no_fire
    ....
    goto main
    As for the multi press and the way you are doing it, you have to check for when the button is released also. So when you have a button press, set a flag, then next time through the loop, if the flag is set, ignore the press. when the button is released, clear the flag.

    If cnt2==cnt gosub add

    you can move this line outside of the for next loop. It will be true each time the loop counts to cnt. so just process it before jumping back to main.

    as for the counting, you could use a timer setup as a counter. Just load it with a number, then in your mainloop check for an overflow. If it did, call your add. This way, as the levels get harder, just change the preload for the timer.
    Last edited by cncmachineguy; - 7th October 2010 at 18:31.
    -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
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    ahhh yes of course... *facepalms*

    I will go about adding a flag in there now, seems I had a bit of a well I dunno what to call it actually lol

    That will solve the final few problems and a first draft version will be ready =)

    I havnt added the "n" bit yet or proper scoring system (it just counts the ammount you shot) but it does have lives, levels, shooting anywhere, etc etc etc...

    just a matter of time

  7. #7
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Version 1

    Forgot about this thread,

    First version is complete and has basic scoring with increasing difficulty and levels, will be adding proper scoring, motherships (n) and sound when I can get the bits.

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