Project

General

Profile

Revision 277

more cleanup

View differences:

bom.c
109 109
 * @see analog_init
110 110
 **/
111 111
int get_max_bom(void) {
112
	int max_bom_temp = 0;
113
	int a, i, j, h;
114
    h = 255;
112
  int max_bom_temp = 0;
113
  int a, i, j, h;
114
  h = 255;
115 115

  
116
    for (j = 0; j < 16; j++)
117
    {
118
      i = lookup[j];
116
  for (j = 0; j < 16; j++) {
117
    i = lookup[j];
119 118

  
120
      if (i&8)
121
        output_high(MONK3);
122
      else
123
        output_low(MONK3);
119
    if (i&8) {
120
      output_high(MONK3);
121
    } else {
122
      output_low(MONK3);
123
    }
124 124

  
125
      if (i&4)
126
        output_high(MONK2);
127
      else
128
        output_low(MONK2);
125
    if (i&4) {
126
      output_high(MONK2);
127
    } else {
128
      output_low(MONK2);
129
    }
129 130

  
130
      if (i&2)
131
        output_high(MONK1);
132
      else
133
        output_low(MONK1);
131
    if (i&2) {
132
      output_high(MONK1);
133
    } else {
134
      output_low(MONK1);
135
    }
134 136

  
135
      if (i&1)
136
        output_high(MONK0);
137
      else
138
        output_low(MONK0);
137
    if (i&1) {
138
      output_high(MONK0);
139
    } else {
140
      output_low(MONK0);
141
    }
139 142

  
140
      a = analog8(MONKI);
143
    a = analog8(MONKI);
141 144

  
142
      if (a < h)
143
      {
144
        h = a;
145
        max_bom_temp = j;
146
      }
147

  
145
    if (a < h) {
146
      h = a;
147
      max_bom_temp = j;
148 148
    }
149
  }
149 150

  
150
	//threshold on the bom analog value.
151
	//defined in bom.h
152
	// if the analog value read is above the threshold, we cannot see a robot
153
	// (remember, low means higher intensity).
154
	if(h < BOM_VALUE_THRESHOLD) {
155
		return max_bom_temp;
156
	}
157
	else
158
		return -1;
151
  //threshold on the bom analog value.
152
  //defined in bom.h
153
  // if the analog value read is above the threshold, we cannot see a robot
154
  // (remember, low means higher intensity).
155
  if (h < BOM_VALUE_THRESHOLD) {
156
    return max_bom_temp;
157
  } else {
158
    return -1;
159
  }
159 160
}
160 161

  
161 162
/**
......
182 183

  
183 184
/** @} **/ //end group
184 185

  
185
void output_high(int which) {
186
	digital_output(which, 1);
186
void output_high(int which)
187
{
188
  digital_output(which, 1);
187 189
}
188 190

  
189
void output_low(int which) {
190
	digital_output(which, 0);
191
void output_low(int which)
192
{
193
  digital_output(which, 0);
191 194
}
192

  

Also available in: Unified diff