Shop OBEX P1 Docs P2 Docs Learn Events
code help. — Parallax Forums

code help.

jay117jay117 Posts: 5
edited 2011-05-20 17:21 in BASIC Stamp
I am reading a pot for a configuration menu. Is there an easier way to spread out numbers over a pots range, as opposed using lookdown, lookup?

I have a number of lines of code like this, all with different lookups, it starting to cram my bs2e..

need to stream line, any ideas?..
min and max commands on a variable from rctime, will not do..

LOOKDOWN time, <= [3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,
93,96,99,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,187,190,194], idx
LOOKUP idx, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59], value

ty

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-20 14:31
    I don't understand what you're trying to do. In the case of the LOOKDOWN, it seems like you're trying to reduce a value from 0 to 194 into 1/3 of that range. How about just dividing the time value by 3? In the case of the LOOKUP, I just don't get why you need it. What's wrong with using MAX and MIN operators to set bounds?
  • jay117jay117 Posts: 5
    edited 2011-05-20 15:43
    The lookdown are values the pot returns, the lookup are digits displayed and written to memory.. in this case, 0-59..

    i want to spread out the 0-59 across the full range of the pot. if i read the rctime, and apply min 0 and max 59 to the value returned, it ends up only using 1/3 of the pots full range.

    this particular example is part of a function to set minutes to a clock in a setup menu, using a pot to determine the value, and a button to set it..
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-20 16:08
    I'd use MIN to limit the raw RCTIME values to between 0 and 179, then divide by 3 to get values between 0 and 59.
  • jay117jay117 Posts: 5
    edited 2011-05-20 17:21
    math to the rescue.. ty for ur help
Sign In or Register to comment.