Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / simulator / libsim / bom.c @ 1037

History | View | Annotate | Download (1.56 KB)

1
#include "bom.h" 
2
#include "util.h" 
3
#include "robot_shared.h"
4

    
5
#define BOM_VALUE_THRESHOLD 200 
6
#define NUM_BOM_LEDS 16
7

    
8
extern RobotShared *shared_state;
9

    
10
static char bom_type = BOM; void bom_init(char type) {
11
    bom_type = type;
12
    
13
    switch(bom_type) {
14
    case BOM:
15
        break;
16
    case BOM15:
17
        break;
18
    case RBOM:
19
        break;
20
    //default:
21
    }
22
}
23

    
24
void bom_refresh(int bitfield) {
25
        /* do nothing, since values are refreshed by simulator */
26
}
27

    
28
int bom_get(int which) {
29
        return (shared_state->bom).led[which];
30
}
31

    
32
int bom_get_max(void) {
33
    int i, lowest_val, lowest_i;
34
    lowest_i = -1;
35
    lowest_val = 255;
36
    for(i = 0; i < NUM_BOM_LEDS; i++) {
37
        if(bom_get(i) < lowest_val) {
38
            lowest_val = bom_get(i);
39
            lowest_i = i;
40
        }
41
    }
42
    
43
    if(lowest_val < BOM_VALUE_THRESHOLD)
44
        return lowest_i;
45
    else
46
        return -1;
47
}
48

    
49
void bom_leds_on(int bit_field) {
50
    switch(bom_type) {
51
    case BOM:
52
        if(bit_field == BOM_ALL) {
53
            (shared_state->bom).bom_on = 1;
54
        }
55
        break;
56
    case BOM15:
57
        //add bom 1.5 code here
58
        break;
59
    case RBOM:
60
        //add rbom code here
61
        break;
62
    }
63
}
64

    
65
void bom_leds_off(int bit_field) {
66
    switch(bom_type) {
67
    case BOM:
68
        if(bit_field == BOM_ALL) {
69
            (shared_state->bom).bom_on = 0;
70
        }
71
        break;
72
    case BOM15:
73
        //add bom 1.5 code here
74
        break;
75
    case RBOM:
76
        //add rbom code here
77
        break;
78
    }
79
}
80

    
81
void bom_on(void) {
82
        bom_leds_on(BOM_ALL);
83
}
84

    
85
void bom_off(void) {
86
        bom_leds_off(BOM_ALL);
87
}