Project

General

Profile

Revision 0bd4bb32

ID0bd4bb32e635bcc968c90d896920bf6618df9f48

Added by Thomas Mullins about 12 years ago

Added motor code for forklift, and fixed analog and i2c code after testing.

View differences:

forklift/code/analog.c
1 1
#include <avr/io.h>
2
#include "analog.h"
2
#include "analog.h"
3

  
4
int line_threshold = 150;
3 5

  
4 6
int line_read(int which);
5 7
void line_update(int* values);
......
60 62
{
61 63
  int i;
62 64
  for(i = 0; i<5; i++)
63
    values[i] = line_read(i) < 150 ? LWHITE : LBLACK;
65
    values[i] = line_read(i) < line_threshold ? LWHITE : LBLACK;
64 66
}
65 67

  
66 68
int line_locate(int* values)
......
87 89
  line_update(values);
88 90
  return line_locate(values);
89 91
}
92

  
93
void line_set_threshold_high(uint8_t threshold)
94
{
95
  line_threshold = ((int)(threshold & 3) << 8) | (line_threshold & 0xFF);
96
}
97

  
98
void line_set_threshold_low(uint8_t threshold)
99
{
100
  line_threshold = (line_threshold & 0x300) | (uint16_t) threshold;
101
}

Also available in: Unified diff