Project

General

Profile

Revision 1460

put lcd and rangefinder lookup tables into program space
removed TODO inline comments from wireless library

View differences:

rangefinder.c
57 57
  4.) Set Vin high for 2ms or more to turn off rangefinder
58 58

  
59 59
*/
60
#include <avr/pgmspace.h>
60 61

  
61 62
#include "rangefinder.h"
62 63
#include "analog.h"
......
87 88
   10cm from the detector.  See the datasheet for more information.
88 89
*/
89 90

  
90
static int IR_dist_conversion[114] = {
91
static int IR_dist_conversion[114] PROGMEM = {
91 92
  800,791,751,714,681,651,623,597,574,552,531,512,494,478,462,447
92 93
  ,434,421,408,397,386,375,365,356,347,338,330,322,315,307,301,294
93 94
  ,288,282,276,270,265,260,255,250,245,241,237,232,228,224,221,217
......
137 138
 * Transforms distance readings from logarithmic to linear scale.
138 139
 * This probably isn't the function you are looking for.
139 140
 *
141
 * Note: pgm_read_word() needs additional testing
142
 *
140 143
 * @param value the 8-bit analog value from rangefinder
141 144
 *
142 145
 * @return linearized distance reading from rangefinder (integer in [101,800])
......
147 150
  } else if(value > MAX_IR_ADC8) {
148 151
    return -1;
149 152
  } else {
150
    return IR_dist_conversion[value - MIN_IR_ADC8];
153
    return pgm_read_word(&(IR_dist_conversion[value - MIN_IR_ADC8]));
151 154
  }
152 155
}
153 156

  

Also available in: Unified diff