Shop OBEX P1 Docs P2 Docs Learn Events
New Project that is almost Done I would like some one to look at this code rout — Parallax Forums

New Project that is almost Done I would like some one to look at this code rout

sam_sam_samsam_sam_sam Posts: 2,286
edited 2008-03-16 16:48 in General Discussion
Hi Every One

I have been working on this project for three month now when i have had the time

I would like for any one to tell me if i can clean up this routine in any way

I am think about putting an LCD Display to this Project but·I have used up ·67% of the memory·so this may not happen

Just an· idea.gif

So let me know what you think
I want to Thank·any one that· look at this code routine for me

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·idea.gif·that you may have and all of your time finding them

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 3/15/2008 9:04:32 PM GMT

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-15 21:21
    You used this twice:
    HIGH led             '  Some changes where made for this this code to work
    LOW chg              '  In My Project I would like to Thank Sid For Posting
    PAUSE dly1           '  His Code This made this part easer for me to make this
    'charge              '  work
    LOW led              '  This is One LED Switch
    HIGH chg
    PAUSE dly1
    'input
    LOW led
    INPUT chg
    PAUSE dly2            'Changing This Value Will Change The Light Level Respone
    DEBUG CR, DEC ? chg, DEC3 ? cntr
    

    So, I made it into a subroutine called consolidate

    You have·a lot·of DEBUG statements and everything in quotes takes up program memory.· So, using TIMER1 instead TIMER 1 and CLK instead of CLOCK·can save a lot of·program memory.

    By incorporating consolidate and just a few abbreviations, I saved you 68 bytes (going from $2c1 to $305 = $44)
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-16 01:15
    PJ Allen
    Thank You for your help and input that has help a lot

    I must be going brain dead

    I guess because I have so many little routine that go back and forth I got a little lost···



    ······························································· idea.gif·s


    Now i will be able to control the out side lights and save some money on the electric meter bill

    I do not like clock that you have to set the time and adj for Day Light Saving or timer that do not adj to out side world that why i built my own
    Timers

    Here is the revised code that PJ help with Thank Again

    ········· That all folks·· smile.gif
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 3/16/2008 1:21:29 AM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 03:14
    Looking over your program, I saw that in each of your Timer routines you used·--

    ·hrs· = $00
    ·mins = $00
    ·secs = $00


    so I made that into a subroutine (init_hms).

    Also, each time you used GOSUB Set_Time you followed that with DEBUG CLS, CLS.· So, I incorporated the DEBUG into Set_Time.

    That saved 48 bytes ($30)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-16 03:22
    If you make · DEBUG HOME, HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs
    part of Get_Time, then you can save even more.
    ·
    Get_Time:                               ' DS1302 Burst Read
      HIGH CS1302                           ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
      SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs, mins, hrs, date, month, day, year]
      LOW CS1302                            ' Deselect DS1302
      DEBUG HOME, HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs
      RETURN
    


    Instead of --
    GOSUB Get_Time

    DEBUG HOME, HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs


    If I go too far... I may have to stay there.

    Post Edited (PJ Allen) : 3/16/2008 3:41:30 AM GMT
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-03-16 16:48
    PJ Allen
    Thanks for your help

    You help learn a lot

    ·How to put all of these small·same type of routines all in to one or two main routine and call up the routine when need

    I am going to try when·I write a·working code then go back and consolidate all of the same type of routines

    Thank for the·· idea.gif·s I will use them


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
Sign In or Register to comment.