Project

General

Profile

colony_analog.txt

Chris Mar, 10/07/2009 08:51 PM

Download (1.76 KB)

 
1
New Analog API Proposal
2

    
3
***averaging stuff***
4
new analog init function
5
- don't worry about speeding up analog loop for now (do that separately)
6
- will take the number of samples for averaging as an argument
7
  - make old init function a wrapper for this one that uses a default value
8
  - will not handle multiple buffer lengths
9
- initialize averaging buffers
10
- bitfield (or some other way) to determine which ADC ports to average
11

    
12
new "get" functions
13
- take an argument to specify average or immediate value
14
- if averaging, perform division on running sum
15
- deprecate the old get
16

    
17
#define some new error codes
18
- out of range
19
- trying to average, but not enough history values
20

    
21
in the interrupt
22
- fill the ring buffer with the newest reading and add the current readings for the average
23
- don't do the divide for the averaging - do this in get
24

    
25
update rangefinder code accordingly so that people can get averaged rangefinders
26

    
27
***new analog interrupt***
28
init function
29
-takes a bitfield of different analog fields to read
30
-analog loop only reads those analog fields
31

    
32
new "get" function
33
-keep it fresh - return an error if somebody tries to read an old value twice
34

    
35
function to update the bitfield dynamically
36

    
37
eliminate bom_refresh - put bom refresh in the analog loop when the bom bit is asserted in the bitfield
38

    
39
#define some new error codes
40
- analog port not initialized yet
41
- not reading from that analog - bit not asserted in bitfield
42
- reading is not fresh - this particular reading has already been read
43

    
44
no need to start and stop the loop anymore - deprecate the old functions
45
- to do this, user should set all bits in bitfield to 0
46

    
47
issues to consider:
48
- concurrency issue if user disables a port that is currently being read (is this serious?)