Moved to Team 9.
Fork of LineScan by
Diff: LineScan.cpp
- Revision:
- 15:4bd1c1d2cf94
- Parent:
- 14:928254a609cb
- Child:
- 16:aaac67b2bce4
--- a/LineScan.cpp Sat Apr 18 00:19:59 2015 +0000 +++ b/LineScan.cpp Sat Apr 18 06:04:30 2015 +0000 @@ -14,7 +14,7 @@ #define FIND_PEAK 1 #define FIND_TROUGH 2 -#define FRAMELEN NUM_PIX - 2 * SKIP +//#define FRAMELEN NUM_PIX - 2 * SKIP uint16_t read1Bit(AnalogIn cam, DigitalOut *camClk){ uint16_t pixel; @@ -38,27 +38,27 @@ } float processFn(uint16_t *array, int arraySz, int* exposure, telemetry::NumericArray<uint16_t, NUM_PIX - 2 * SKIP> &tele_linescan_diff){ //consider adding diff to telemetry - //const static int FRAMELEN = NUM_PIX - 2 * SKIP; - int avg[FRAMELEN]; - int diff[FRAMELEN]; + const static int frameLen = NUM_PIX - 2 * SKIP; + int avg[frameLen]; + int diff[frameLen]; int highest = 0; int lowest = 0; int total = 0; - int h_idx_ary[FRAMELEN]; + int h_idx_ary[frameLen]; int h_idx_pos = 0; - int l_idx_ary[FRAMELEN]; + int l_idx_ary[frameLen]; int l_idx_pos = 0; int state = NEUTRAL; int *l_walker, *h_walker; - int out_width = FRAMELEN; + int out_width = frameLen; float out = -1.0; //for AGC float exposureChange; if(array){ - memset (h_idx_ary, -1, FRAMELEN); - memset (l_idx_ary, -1, FRAMELEN); + memset (h_idx_ary, -1, frameLen); + memset (l_idx_ary, -1, frameLen); avg[0] = array[SKIP - 1]/2 + array[SKIP]/2; diff[0] = 0; @@ -66,7 +66,7 @@ total += avg[0]; //AGC - for(int i = 1; i < FRAMELEN; i++){ + for(int i = 1; i < frameLen; i++){ avg[i] = array[i - 1 + SKIP]/2 + array[i + SKIP]/2; //smoothing diff[i] = avg[i - 1] - avg[i]; //differential tele_linescan_diff[i] = diff[i]; @@ -111,7 +111,7 @@ } } //AGC, simple proportional controller - total = total / FRAMELEN; + total = total / frameLen; exposureChange = ((float)(MEAN_REF - total)) * CAM_CTRL_GAIN; *exposure += (int)exposureChange; if(*exposure < 0) @@ -127,7 +127,7 @@ //if interval is black on white, advance the pointer for the peak array if(*h_walker > *l_walker && (*h_walker - *l_walker) < out_width){ out_width = *h_walker - *l_walker; - out = ((float)(*h_walker + *l_walker)) / (2.0 * (float)FRAMELEN); //0.5 is center + out = ((float)(*h_walker + *l_walker)) / (2.0 * (float)frameLen); //0.5 is center l_walker++; } h_walker++;