## Revision 1692 demos/john/projects/libdragonfly/bom.c

View differences:

bom.c
266 266
``` * see bom_refresh
```
267 267
``` **/
```
268 268
```int bom_get(int which) {
```
269
```    return bom_val[which];
```
269
```	//return bom_val[which];      deleted because we got rid of the analog loop
```
270
```	bom_select(which);
```
271
```    return analog_get8(analog_pin);
```
270 272
```}
```
271 273

272 274
```/**
```
......
277 279
``` *    BOM_VALUE_THRESHOLD
```
278 280
``` **/
```
279 281
```int bom_get_max(void) {
```
280
```    int i, lowest_val, lowest_i;
```
282
```    int i, lowest_val, lowest_i, i_val;
```
281 283
```    lowest_i = -1;
```
282 284
```    lowest_val = 255;
```
283 285
```    for(i = 0; i < NUM_BOM_LEDS; i++) {
```
284
```        if(bom_val[i] < lowest_val) {
```
285
```            lowest_val = bom_val[i];
```
286
```		i_val = bom_get(i);
```
287
```        if(i_val < lowest_val) {
```
288
```            lowest_val = i_val;
```
286 289
```            lowest_i = i;
```
287 290
```        }
```
288 291
```    }
```
......
511 514
```    /* Record values into an array */
```
512 515
```    for (i = 0; i < NUM_BOM_LEDS; i++) {
```
513 516
```        int idx = ((i + (NUM_BOM_LEDS/2 - max) + NUM_BOM_LEDS) % NUM_BOM_LEDS) - (NUM_BOM_LEDS/2 - max);
```
514
```        int val = 255 - bom_val[i];
```
517
```        int val = 255 - bom_get(i);
```
515 518
```        mean += idx * val;
```
516 519
```        sum += val;
```
517 520
```    }
```

Also available in: Unified diff