Changeset - 6b1e328f8883
[Not reviewed]
default
0 7 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-02-05 16:41:38
ethanzonca@CL-ENS241-08.cedarville.edu
Trimmed significant amount of memory usage, fixed scope issues and downsized fixed arrays.
7 files changed with 37 insertions and 44 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
@@ -47,7 +47,7 @@
 
// --------------------------------------------------------------------------
 
 
#define MAX_NUM_SLAVES 5  // Maximum number of nodes in the system
 
#define MAX_NUM_SENSORS 20 // Maximum number of unique types of sensors in the system
 
#define MAX_NUM_SENSORS 10 // Maximum number of unique types of sensors in the system
 
 
// Node identifier of log destination xbee
 
#define XBEE_LOGDEST_NAME "HAB-LOGGER"
 
@@ -116,11 +116,6 @@
 
// is pathless. Uncomment the following two lines for WIDE2-1 path:
 
#define DIGI_PATH1      "WIDE2"
 
#define DIGI_PATH1_TTL  1
 

	
 
// APRS comment: this goes in the comment portion of the APRS message. You
 
// might want to keep this short. The longer the packet, the more vulnerable
 
// it is to noise.
 
#define APRS_COMMENT    "[A-30.5 B45.64 C99542]"
 
 
// Transmit the APRS sentence every X milliseconds
 
#define APRS_TRANSMIT_PERIOD 20000
master/master/lib/aprs.c
Show inline comments
 
@@ -17,13 +17,6 @@
 
#include "sensordata.h"
 
#include <stdio.h>
 

	
 
const char *gps_aprs_lat = "39.74744N";
 
const char *gps_aprs_lon = "-83.81249W";
 
const char *gps_time = "081533/";
 
float gps_altitude = 123.5;
 
int gps_course = 5;
 
int gps_speed = 13;
 

	
 
float meters_to_feet(float m)
 
{
 
  // 10000 ft = 3048 m
 
@@ -32,7 +25,6 @@ float meters_to_feet(float m)
 

	
 
void aprs_send()
 
{
 
  char temp[12];                   // Temperature (int/ext)
 
  const struct s_address addresses[] = { 
 
    {D_CALLSIGN, D_CALLSIGN_ID},  // Destination callsign
 
    {S_CALLSIGN, S_CALLSIGN_ID},  // Source callsign (-11 = balloon, -9 = car)
 
@@ -57,9 +49,14 @@ void aprs_send()
 
  ax25_send_string(get_longitude());     // Lon: 000deg and 25.80 min
 
  ax25_send_byte('W');
 
  ax25_send_byte('O');                // Symbol: O=balloon, -=QTH
 
  snprintf(temp, 4, "%03d", (int)(gps_course + 0.5)); 
 
  ax25_send_string(temp);             // Course (degrees)
 
  
 
  //snprintf(temp, 4, "%03d", (int)(get_course() + 0.5));  
 
  // !!!TODO: ENSURE THAT THE COURSE IS FORMATTED CORRECTLY!
 
  ax25_send_string(get_course());             // Course (degrees)
 
  
 
  ax25_send_byte('/');                // and
 
  
 
  // !!!TODO: Check the speed!
 
  //snprintf(temp, 4, "%03d", (int)(gps_speed + 0.5));
 
  ax25_send_string(get_speedKnots());             // speed (knots)
 
  
 
@@ -79,9 +76,7 @@ void aprs_send()
 
  */
 
  
 
  ax25_send_byte(' ');
 
  //ax25_send_string(APRS_COMMENT);     // Comment
 
  ax25_send_string(slavesensors_getAPRScomment());
 
  ax25_send_footer();
 

	
 
  ax25_flush_frame();                 // Tell the modem to go
 
}
master/master/lib/i2c.c
Show inline comments
 
/*
 
 * i2c.c
 
 *
 
 * Created: 11/7/2012 7:18:23 PM
 
 *  Author: kripperger
 
 */ 
 
/*
 
 * Master Firmware: I2C
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#include <inttypes.h>
 
#include <compat/twi.h>
master/master/lib/i2c.h
Show inline comments
 
/*
 
 * i2c.h
 
 *
 
 * Created: 11/7/2012 7:18:33 PM
 
 *  Author: kripperger
 
 */ 
 
 
/*
 
 * Master Firmware: I2C
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
#ifndef I2C_H_
 
#define I2C_H_
master/master/lib/led.h
Show inline comments
 
@@ -41,16 +41,10 @@ static led_t ledList[] = {
 
	{&DDRA, &PORTA, PA3}, // ACT2
 
	{&DDRA, &PORTA, PA4}, // ACT3
 
 
//pcb:
 
	{&DDRB, &PORTB, PB4}, // POWER
 
	{&DDRB, &PORTB, PB3}, // STATUS
 
	{&DDRB, &PORTB, PB2}, // ERROR
 
 
//breadboard:
 
//	{&DDRA, &PORTA, PA2}, // POWER
 
//	{&DDRA, &PORTA, PA0}, // STATUS
 
//	{&DDRA, &PORTA, PA1}, // ERROR
 
 
	{&DDRD, &PORTD, PD6}, // SIDEBOARD
 
	{&DDRD, &PORTD, PD5}, // ACTIVITY
 
	{&DDRD, &PORTD, PD4}, // CYCLE
master/master/lib/sensordata.c
Show inline comments
 
@@ -61,7 +61,7 @@ char* slavesensors_getAPRScomment() {
 
}
 
 

	
 
char logbuf[256];
 
 
bool dataWasReady = false;
 
 
void sensordata_logvalues() {
 
@@ -95,6 +95,7 @@ void sensordata_logvalues() {
 
		}
 
	
 
		// Write CSV sensor values to SD card
 
		char logbuf[256];
 
		logbuf[0] = 0x00;
 
		snprintf(logbuf, 256, "%lu,%d,%s,%s,%s,%s,%s,%s,%s,", time_millis(), sensors_getBoardTemp(),get_timestamp(),get_latitude(),get_longitude(),get_speedKnots(),get_hdop(), get_course(), get_sv());
 
		for(int i=0; i<MAX_NUM_SLAVES; i++) {
master/master/lib/slavesensors.c
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include "looptime.h"
 

	
 
// Label lookup table
 
// Make sure there are never more labels than there are MAX_NUM_SENSORS! 
 
const char label_0[] PROGMEM = "BoardTemp";
 
const char label_1[] PROGMEM = "HeaterStatus";
 
const char label_2[] PROGMEM = "BatteryLevel";
 
@@ -50,13 +51,11 @@ const char *const labelLookup[] PROGMEM 
 
	label_8,
 
};
 

	
 
char labelBuffer[25]; // Size to length of label
 
char labelBuffer[15]; // Size to length of label
 
char* slavesensors_getLabel(uint8_t sensorID) {
 
	//snprintf(labelBuffer, 25, "[%u]", sensorID);
 
	//return labelBuffer;
 
	if(sensorID < 9)
 
	{
 
		strncpy_P(labelBuffer,(char*)pgm_read_word(&(labelLookup[sensorID])),25);
 
		strncpy_P(labelBuffer,(char*)pgm_read_word(&(labelLookup[sensorID])),15);
 
		
 
		return labelBuffer;
 
	}
 
@@ -82,7 +81,7 @@ char* bufPtr = 0x00;
 

	
 
static char slaveAddressLow[MAX_NUM_SLAVES][9];
 
static char slaveAddressHigh[MAX_NUM_SLAVES][9];
 
static char slaveNames[MAX_NUM_SLAVES][20];
 
static char slaveNames[MAX_NUM_SLAVES][15];
 

	
 
uint8_t loggerIndex = 255;
 
uint8_t nodeCount = 0;
 
@@ -142,7 +141,7 @@ void slavesensors_network_scan() {
 
				strncpy(slaveAddressLow[nodeCount],bufPtr, 9);
 
			}
 
			else if(lineCount == 3) {
 
				strncpy(slaveNames[nodeCount], bufPtr, 20);
 
				strncpy(slaveNames[nodeCount], bufPtr, 15);
 
			}
 
			
 
			// If we've finished one chunk (including the newline after it). Can't be else if because it controls increment.
0 comments (0 inline, 0 general)