View Single Post
  #9   Spotlight this post!  
Unread 07-01-2003, 01:05
rwaliany's Avatar
rwaliany rwaliany is offline
R
None #0691 (HartBurn)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2000
Location: http://www.hartrobot.com
Posts: 137
rwaliany will become famous soon enough
well, everytime you check lets say the light sensor is on...for all 8 bits.
It tells you its been there for a long time, or however long your cycles for each bit are.

Combining the bits and using that integer wouldnt really help, example input

assuming your doing right to left bit logic

all 8 bits are 1...signal 255(254 rounded down automatically in debug at least), then lets say you shift over one bit, 254(no signal 1 bit), no signal for 2 bits consecutively, 252...248...240...224....192....128....0....
I guess that would work, lets show going up input from no lights to ful lights
1...3....7...15.....31.....63.....127....255(254 rounded)

so lets say you get 3 in a row, and then 5 consecutive no signals

128+64+32+0+0+0+0+0
224... you get 224 for a run with no signal

if you have any questions about this let me know, this is just some bit logic, might help understand it

1...2...4..8.16.32.64.128.256.512.1024.2048.4096

goes right to left
each 1 in binary counts as first num and moves up
to find sum its (2^n)-1 = 256-1 = 255, its 254 on the default code because two 255's consecutively is a reset

- Ryan
__________________
R

Last edited by rwaliany : 07-01-2003 at 01:38.