Detecting change on software inputs


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425

    Default Detecting change on software inputs

    I'm not sure how to do this but I need to compare two or three (could be up to 8) values and whichever one changes, make that new value a different variable. I don't want to use an if/then statement because I need to check a lot of these variables and I'm trying to keep code space at a minimum.

    So it would be something like this (This isn't ode, it's just a view on how I want it to work):

    PACKET 1: A=10, B=20, C=30 STARTING POINT, NO CHANGE.
    PACKET 2: A=10, B=22, C=30 - LIGHT = 22
    PACKET 3: A=10, B=22, C=37 - LIGHT = 37
    PACKET 4: A=15, B=22, C=37 - LIGHT = 15
    PACKET 5: A=15, B=22, C=09 - LIGHT = 09
    PACKET 6: A=15, B=22, C=09 - LIGHT = 09
    PACKET 7: A=15, B=22, C=09 - LIGHT = 09
    PACKET 8: A=03, B=22, C=09 - LIGHT = 03
    PACKET 9: A=03, B=21, C=09 - LIGHT = 21
    PACKET 10: A=03, B=21, C=24 - LIGHT = 24


    Is there a way to do this efficiently?



    Is there an easier way?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Detecting change on software inputs

    Here's one way ...

    Code:
    Packet_Size   CON 3
    Old_Packet    VAR BYTE[Packet_Size]
    New_Packet    VAR BYTE[Packet_Size]
    Idx           VAR BYTE
    LIGHT         VAR BYTE
    
    FOR Idx = 0 TO Packet_Size - 1
        IF (Old_Packet(Idx) ^ New_Packet(Idx)) > 0 THEN LIGHT = New_Packet(Idx)
        Old_Packet(Idx) = New_Packet(Idx)
    NEXT Idx
    DT

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