| 12345678910111213141516171819202122232425262728293031 | 
							- #include "schmidt_trigger.h"
 
- int schmidt_init(struct schmidt *schmidt, float low, float high)
 
- {
 
- 	if (low > high)
 
- 		return -1;
 
- 	schmidt->high = high;
 
- 	schmidt->low = low;
 
- 	schmidt->value = 0;
 
- 	return 0;
 
- }
 
- int schmidt_trig(struct schmidt *schmidt, float level)
 
- {
 
- 	if ((schmidt->value == 1 && level <= schmidt->low) ||
 
- 	    (schmidt->value == 0 && level >= schmidt->high)) {
 
- 		schmidt->value ^= 1;
 
- 		return 1;
 
- 	}
 
- 	return 0;
 
- }
 
- int schmidt_get(struct schmidt *schmidt)
 
- {
 
- 	return schmidt->value;
 
- }
 
- /* vim: set ts=8 sw=8 sts=8 noet: */
 
 
  |