Easy way to do multiple write statements ?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Easy way to do multiple write statements ?

    You spoke in your original post of an "easier way", while this is not exactly what you asked, I find it easier and so offer...

    Keeping track of hours and minutes separately is unnecessary. For me, over and again, I have determined that a word value representing the minutes since midnight (a value of 0 to 1440) is clearer and easier to manipulate. Switching to hours and minutes is as easy as /60 for hours and MOD 60 for minutes. All calculations loose the clumsiness of handling hours and minutes separately and determining if dates change when subtracting or adding periods is less complicated.

    It doesn't save any actual eeprom space, but it could reduce the typing by changing "lightsetHR(counterD),lightsetMN(counterD)," to SetTime(counterD) and "lightoffHR(counterD),lightoffMN(counterD)," to OnOffTime(counterD)

    ... just a thought.

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Easy way to do multiple write statements ?

    Quote Originally Posted by Amoque View Post
    You spoke in your original post of an "easier way", while this is not exactly what you asked, I find it easier and so offer...

    Keeping track of hours and minutes separately is unnecessary. For me, over and again, I have determined that a word value representing the minutes since midnight (a value of 0 to 1440) is clearer and easier to manipulate.
    ... just a thought.
    I agree and that's the way I do the matching of the if then statements. The code reads the RTC, and the end result is placed in two variables, TimeH and TimeM. Then the TimeH is multiplied by 60 and added to TimeM and placed in a variable Counter1. I then have a similar statement CH1_on_Time = (lightsetHR1*60)+lightsetMN1 to convert the values in the above statement which are then placed in a variable, and then it's a simple matter to do the actions required depending on if the two variables match or one is < or > than other.

    Oh and just to update this thread, and for reference for anyone in the future who may stumble on this thread...

    Code:
     address =$50
      for counterd = 0 to 15
         read (address),lightsetHR(counterD),lightsetMN(counterD),lightoffHR(counterD),lightoffMN(counterD),fadeset.lowbyte(counterD),fadeset.highbyte(counterD)
         address = address+6  ' account for the data already filled into the storage
      next counterD
    With the the matching WRITE command, works a treat - thanks Jerson ;-)

Similar Threads

  1. Darrels interrupts and multiple SOUND statements, will it work?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 26th January 2015, 07:42
  2. Programming multiple pics with multiple programs
    By Luckyborg in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd April 2013, 17:47
  3. Multiple IF THEN Statements: PIC16F84A
    By bob425 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th August 2012, 06:01
  4. SD Multiple Write?
    By jimbostlawrence in forum General
    Replies: 1
    Last Post: - 21st October 2011, 17:45
  5. Multiple IF-THEN statements
    By DavidK in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th June 2007, 18:28

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