Project

General

Profile

Revision 1460

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

View differences:

trunk/code/projects/libwireless/lib/wl_token_ring.c
47 47
#include <time.h>
48 48
#endif
49 49

  
50
//TODO: why is this in both this file and sensor_matrix.c?  If it is needed in both places,
51
// put it in sensor_matrix.h.  This file already includes sensor_matrix.h
52
#define DEFAULT_SENSOR_MATRIX_SIZE 20
53 50

  
51
//#define DEFAULT_SENSOR_MATRIX_SIZE 20
52

  
54 53
/*Ring States*/
55 54

  
56 55
#define NONMEMBER 0
......
155 154
 * alerting others of its location, but continues storing the
156 155
 * locations of other robots.
157 156
 **/
158
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
159
// it reduces code size or not should be done to be sure.
160 157
void wl_token_ring_leave()
161 158
{
162 159
	ringState = LEAVING;
......
190 187
/**
191 188
 * Removes the packet group from the wireless library.
192 189
 **/
193
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
194
// it reduces code size or not should be done to be sure.
195 190
void wl_token_ring_unregister()
196 191
{
197 192
	wl_unregister_packet_group(&wl_token_ring_handler);
......
220 215
/**
221 216
 * Called to cleanup the token ring packet group.
222 217
 **/
223
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
224
// it reduces code size or not should be done to be sure.
225 218
static void wl_token_ring_cleanup()
226 219
{
227 220
}
......
362 355
 * @return a BOM reading from us to robot dest, in the range
363 356
 * 0-15, or -1 if it is unkown
364 357
 **/
365
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
366
// it reduces code size or not should be done to be sure.
367 358
int wl_token_get_my_sensor_reading(int dest)
368 359
{
369 360
	return wl_token_get_sensor_reading(wl_get_xbee_id(), dest);
......
375 366
 *
376 367
 * @return the number of robots in the token ring
377 368
 **/
378
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
379
// it reduces code size or not should be done to be sure.
380 369
int wl_token_get_robots_in_ring(void)
381 370
{
382 371
	return sensor_matrix_get_joined();
......
389 378
 * @param robot the robot to check for whether it is in the token ring
390 379
 * @return nonzero if the robot is in the token ring, zero otherwise
391 380
 **/
392
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
393
// it reduces code size or not should be done to be sure.
394 381
int wl_token_is_robot_in_ring(int robot)
395 382
{
396 383
	return sensor_matrix_get_in_ring(robot);
......
429 416
 *
430 417
 * @see wl_token_iterator_begin, wl_token_iterator_next
431 418
 **/
432
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
433
// it reduces code size or not should be done to be sure.
434 419
int wl_token_iterator_has_next(void)
435 420
{
436 421
	return iteratorCount != -1;
......
473 458
 *
474 459
 * @return the number of robots in the token ring
475 460
 **/
476
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
477
// it reduces code size or not should be done to be sure.
478 461
int wl_token_get_num_robots(void)
479 462
{
480 463
	return sensor_matrix_get_joined();
......
485 468
 *
486 469
 * @return the number of robots in the sensor matrix
487 470
 **/
488
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
489
// it reduces code size or not should be done to be sure.
490 471
int wl_token_get_matrix_size(void)
491 472
{
492 473
	return sensor_matrix_get_size();
trunk/code/projects/libwireless/lib/wl_error_group.c
61 61
 * This function must be called before any other wl_error
62 62
 * function.
63 63
 **/
64
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
65
// it reduces code size or not should be done to be sure.
66 64
void wl_error_register(void)
67 65
{
68 66
	wl_register_packet_group(&wl_error_handler);
......
74 72
 *
75 73
 * @see wl_error_register
76 74
 **/
77
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
78
// it reduces code size or not should be done to be sure.
79 75
void wl_error_unregister(void)
80 76
{
81 77
	wl_unregister_packet_group(&wl_error_handler);
......
118 114
 *
119 115
 * @param str the error message to send
120 116
 **/
121
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
122
// it reduces code size or not should be done to be sure.
123 117
void wl_error_send_string(char* str)
124 118
{
125 119
	wl_send_global_packet(WL_ERROR_GROUP, WL_ERROR_STRING_TYPE,
trunk/code/projects/libwireless/lib/wireless.c
180 180
 *
181 181
 * @see wl_get_pan
182 182
 **/
183
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
184
// it reduces code size or not should be done to be sure.
185 183
int wl_set_pan(int pan)
186 184
{
187 185
	return xbee_set_pan_id(pan);
......
194 192
 *
195 193
 * @see wl_set_pan
196 194
 **/
197
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
198
// it reduces code size or not should be done to be sure.
199 195
int wl_get_pan(void)
200 196
{
201 197
	return xbee_get_pan_id();
......
208 204
 *
209 205
 * @see wl_get_channel
210 206
 **/
211
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
212
// it reduces code size or not should be done to be sure.
213 207
int wl_set_channel(int channel)
214 208
{
215 209
	return xbee_set_channel(channel);
......
222 216
 *
223 217
 * @see wl_set_channel
224 218
 **/
225
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
226
// it reduces code size or not should be done to be sure.
227 219
int wl_get_channel(void)
228 220
{
229 221
	return xbee_get_channel();
......
234 226
 *
235 227
 * @return the 16-bit address of the XBee module.
236 228
 **/
237
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
238
// it reduces code size or not should be done to be sure.
239 229
int wl_get_xbee_id()
240 230
{
241 231
	return xbee_get_address();
......
251 241
 * @param dest the 16-bit address of the XBee to send the packet to
252 242
 * @param frame the frame number to see with a TX_STATUS response
253 243
 **/
254
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
255
// it reduces code size or not should be done to be sure.
256 244
int wl_send_robot_to_robot_global_packet(char group, char type, char* data, int len, int dest, char frame)
257 245
{
258 246
	return wl_send_packet(group, type, data, len, dest, XBEE_OPTIONS_BROADCAST_ALL_PANS, frame);
......
268 256
 * @param dest the 16-bit address of the XBee to send the packet to
269 257
 * @param frame the frame number to see with a TX_STATUS response
270 258
 **/
271
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
272
// it reduces code size or not should be done to be sure.
273 259
int wl_send_robot_to_robot_packet(char group, char type, char* data, int len, int dest, char frame)
274 260
{
275 261
	return wl_send_packet(group, type, data, len, dest, XBEE_OPTIONS_NONE, frame);
......
284 270
 * @param len the packet length in bytes
285 271
 * @param frame the frame number to see with a TX_STATUS response
286 272
 **/
287
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
288
// it reduces code size or not should be done to be sure.
289 273
int wl_send_global_packet(char group, char type, char* data, int len, char frame)
290 274
{
291 275
	return wl_send_packet(group, type, data, len, XBEE_BROADCAST, XBEE_OPTIONS_BROADCAST_ALL_PANS, frame);
......
300 284
 * @param len the packet length in bytes
301 285
 * @param frame the frame number to see with a TX_STATUS response
302 286
 **/
303
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
304
// it reduces code size or not should be done to be sure.
305 287
void wl_send_pan_packet(char group, char type, char* data, int len, char frame)
306 288
{
307 289
	wl_send_packet(group, type, data, len, XBEE_BROADCAST,
......
476 458

  
477 459

  
478 460
#ifndef ROBOT
479
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
480
// it reduces code size or not should be done to be sure.
481 461
void wl_set_com_port(char* port)
482 462
{
483 463
	xbee_set_com_port(port);
trunk/code/projects/libdragonfly/lcd.c
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35 35
#include <avr/io.h>
36
#include <avr/pgmspace.h>
37

  
36 38
#include "lcd.h"
37 39
#include "time.h"
38 40

  
......
56 58
/*
57 59
  FontLookup - a lookup table for all characters
58 60
*/
59
static const unsigned char FontLookup [][5] =
61
static const unsigned char FontLookup [][5] PROGMEM =
60 62
  {
61 63
    { 0x00, 0x00, 0x00, 0x00, 0x00 },  // sp
62 64
    { 0x00, 0x00, 0x5f, 0x00, 0x00 },   // !
......
215 217
 * Prints a character on the LCD screen. lcd_init
216 218
 * must be called before this function may be used.
217 219
 *
220
 * Note: pgm_read_byte() is untested
221
 *
218 222
 * @param c the character to print
219 223
 *
220 224
 * @see lcd_init
......
223 227
  int i;
224 228
	
225 229
  for (i = 0; i < 5; i++)
226
    lcd_putbyte(FontLookup[c-32][i]);
230
    lcd_putbyte(pgm_read_byte(&(FontLookup[c-32][i])));
227 231
  lcd_putbyte(0);
228 232
}
229 233

  
trunk/code/projects/libdragonfly/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