private double time_step;
private double ground_altitude;
private ArrayList<Integer> bytes;
+ public int log_id;
String name;
MicroStats stats;
-
+
+ public static final int LOG_ID_MICROPEAK = 0;
+ public static final int LOG_ID_MICROKITE = 1;
+
+ public static final double CLOCK = 0.096;
+
public class FileEndedException extends Exception {
}
if (get_nonwhite(f) == 'M' && get_nonwhite(f) == 'P')
return true;
}
- }
+ }
private int get_32(InputStream f) throws IOException, FileEndedException, NonHexcharException {
int v = 0;
ground_pressure = get_32(f);
min_pressure = get_32(f);
int nsamples = get_16(f);
+
+ log_id = nsamples >> 12;
+ nsamples &= 0xfff;
pressures = new int[nsamples + 1];
ground_altitude = AltosConvert.pressure_to_altitude(ground_pressure);
else
cur = down;
}
-
+
pressures[i+1] = cur;
}
crc_valid = crc == current_crc;
- time_step = 0.192;
+ switch (log_id) {
+ case LOG_ID_MICROPEAK:
+ time_step = 2 * CLOCK;
+ break;
+ case LOG_ID_MICROKITE:
+ time_step = 200 * CLOCK;
+ break;
+ }
stats = new MicroStats(this);
} catch (FileEndedException fe) {
throw new IOException("File Ended Unexpectedly");
pressures = new int[1];
pressures[0] = 101000;
}
-
+
}
private void DownloadData() {
AltosDevice device = MicroDeviceDialog.show(this);
-
+
if (device != null)
new MicroDownload(this, device);
}
if (save.runDialog())
SetName(data.name);
}
-
+
private void Export() {
if (data == null) {
no_data();
easymini-v1.0 easymini-v1.0/flash-loader
AVRDIRS=\
- telescience-v0.1 telescience-pwm micropeak nanopeak-v0.1
+ telescience-v0.1 telescience-pwm micropeak nanopeak-v0.1 microkite
SUBDIRS=
static uint16_t ao_log_offset = STARTING_LOG_OFFSET;
+#define AO_LOG_ID_SHIFT 12
+#define AO_LOG_ID_MASK ((1 << AO_LOG_ID_SHIFT) - 1)
+
void
ao_log_micro_save(void)
{
uint16_t n_samples = (ao_log_offset - STARTING_LOG_OFFSET) / sizeof (uint16_t);
+
+#if AO_LOG_ID
+ n_samples |= AO_LOG_ID << AO_LOG_ID_SHIFT;
+#endif
ao_eeprom_write(PA_GROUND_OFFSET, &pa_ground, sizeof (pa_ground));
ao_eeprom_write(PA_MIN_OFFSET, &pa_min, sizeof (pa_min));
ao_eeprom_write(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
uint16_t crc = 0xffff;
ao_eeprom_read(N_SAMPLES_OFFSET, &n_samples, sizeof (n_samples));
+
if (n_samples == 0xffff)
n_samples = 0;
+#if AO_LOG_ID
+ n_samples &= AO_LOG_ID_MASK;
+#endif
nbytes = STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples;
ao_async_start();
ao_async_byte('M');
ao_microflight(void)
{
int16_t sample_count;
+ int16_t log_count;
uint16_t time;
uint32_t pa_interval_min, pa_interval_max;
int32_t pa_diff;
- uint8_t h, i;
+ uint8_t h;
+ uint8_t i;
uint8_t accel_lock = 0;
uint32_t pa_sum = 0;
}
/* Log the remaining samples so we get a complete history since leaving the ground */
- for (; i != h; i = SKIP_PA_HIST(i,2)) {
+#if LOG_INTERVAL < NUM_PA_HIST
+ for (; i != h; i = SKIP_PA_HIST(i,2))
+#endif
+ {
pa = pa_hist[i];
ao_log_micro_data();
}
/* Now sit around until the pressure is stable again and record the max */
sample_count = 0;
+ log_count = 0;
pa_min = ao_pa;
pa_interval_min = ao_pa;
pa_interval_max = ao_pa;
ao_microsample();
if ((sample_count & 3) == 0)
ao_led_off(AO_LED_REPORT);
- if (sample_count & 1)
+ if (log_count == LOG_INTERVAL - 1) {
ao_log_micro_data();
+ log_count = 0;
+ } else
+ log_count++;
/* If accelerating upwards, don't look for min pressure */
if (ao_pa_accel < ACCEL_LOCK_PA)
--- /dev/null
+ao_product.h
+microkite-*
--- /dev/null
+#
+# Tiny AltOS build
+#
+#
+vpath % ../attiny:../drivers:../kernel:../product:..
+vpath ao-make-product.5c ../util
+vpath make-altitude-pa ../util
+
+include ../avr/Makefile.defs
+
+PROGNAME=microkite-v0.1
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SCRIPT=microkite-load
+
+PUBLISH_DIR=$(HOME)/altusmetrumllc/Binaries
+PUBLISH_HEX=$(PUBLISH_DIR)/$(HEX)
+PUBLISH_SCRIPT=$(PUBLISH_DIR)/$(SCRIPT)
+
+MCU=attiny85
+DUDECPUTYPE=t85
+#PROGRAMMER=stk500v2 -P usb
+LOADSLOW=-i 32 -B 32
+LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
+
+#LDFLAGS=-L$(LDSCRIPTS) -Tavr25.x
+
+ALTOS_SRC = \
+ ao_micropeak.c \
+ ao_spi_attiny.c \
+ ao_led.c \
+ ao_clock.c \
+ ao_ms5607.c \
+ ao_exti.c \
+ ao_convert_pa.c \
+ ao_report_micro.c \
+ ao_notask.c \
+ ao_eeprom_tiny.c \
+ ao_panic.c \
+ ao_log_micro.c \
+ ao_async.c \
+ ao_microflight.c \
+ ao_microkalman.c
+
+INC=\
+ ao.h \
+ ao_pins.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_exti.h \
+ ao_ms5607.h \
+ ao_log_micro.h \
+ ao_micropeak.h \
+ altitude-pa.h
+
+IDPRODUCT=0
+PRODUCT=MicroKite-v0.1
+PRODUCT_DEF=-DMICROPEAK
+CFLAGS = $(PRODUCT_DEF) -I. -I../attiny -I../kernel -I.. -I../drivers -I../product
+CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O2 -mcall-prologues -DATTINY
+
+NICKLE=nickle
+
+SRC=$(ALTOS_SRC)
+OBJ=$(SRC:.c=.o)
+
+V=0
+# The user has explicitly enabled quiet compilation.
+ifeq ($(V),0)
+quiet = @printf " $1 $2 $@\n"; $($1)
+endif
+# Otherwise, print the full command line.
+quiet ?= $($1)
+
+all: $(PROG) $(HEX) microkite-load
+
+CHECK=sh ../util/check-avr-mem
+
+$(PROG): Makefile $(OBJ)
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ)
+ $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1)
+
+$(HEX): $(PROG)
+ avr-size $(PROG)
+ $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@
+
+
+load: $(HEX)
+ $(LOADCMD) $(LOADARG)$(HEX)
+
+load-slow: $(HEX)
+ $(LOADCMD) $(LOADSLOW) $(LOADARG)$(HEX)
+
+ao_product.h: ao-make-product.5c ../Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+ao_product.o: ao_product.c ao_product.h
+
+%.o : %.c $(INC)
+ $(call quiet,CC) -c $(CFLAGS) $<
+
+distclean: clean
+
+clean:
+ rm -f *.o $(PROG) $(HEX) $(SCRIPT)
+ rm -f ao_product.h
+
+publish: $(PUBLISH_HEX) $(PUBLISH_SCRIPT)
+
+$(PUBLISH_HEX): $(HEX)
+ cp -a $(HEX) $@
+
+$(PUBLISH_SCRIPT): $(SCRIPT)
+ cp -a $(SCRIPT) $@
+
+load-product:
+ ./$(SCRIPT) fast
+
+load-product-slow:
+ ./$(SCRIPT) slow
+
+../altitude-pa.h: make-altitude-pa
+ nickle $< > $@
+
+$(SCRIPT): $(SCRIPT).tmpl Makefile ../Version
+ sed -e 's/%HEX%/$(HEX)/' -e 's/%LOADCMD%/$(LOADCMD)/' -e 's/%LOADARG%/$(LOADARG)/' -e 's/%LOADSLOW%/$(LOADSLOW)/' $(SCRIPT).tmpl > $@ || (rm $@ && exit 1)
+ chmod +x $@
+
+install:
+
+uninstall:
+
+$(OBJ): ao_product.h $(INC)
--- /dev/null
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+#include <avr/pgmspace.h>
+
+#define AO_LED_ORANGE (1<<4)
+#define AO_LED_SERIAL 4
+#define AO_LED_PANIC AO_LED_ORANGE
+#define AO_LED_REPORT AO_LED_ORANGE
+#define LEDS_AVAILABLE (AO_LED_ORANGE)
+#define USE_SERIAL_1_STDIN 0
+#define HAS_USB 0
+#define PACKET_HAS_SLAVE 0
+#define HAS_SERIAL_1 0
+#define HAS_TASK 0
+#define HAS_MS5607 1
+#define HAS_MS5611 0
+#define HAS_EEPROM 0
+#define HAS_BEEP 0
+#define AVR_CLOCK 250000UL
+
+/* SPI */
+#define SPI_PORT PORTB
+#define SPI_PIN PINB
+#define SPI_DIR DDRB
+#define AO_MS5607_CS_PORT PORTB
+#define AO_MS5607_CS_PIN 3
+
+/* MS5607 */
+#define AO_MS5607_SPI_INDEX 0
+#define AO_MS5607_MISO_PORT PORTB
+#define AO_MS5607_MISO_PIN 0
+#define AO_MS5607_BARO_OVERSAMPLE 4096
+#define AO_MS5607_TEMP_OVERSAMPLE 1024
+
+/* I2C */
+#define I2C_PORT PORTB
+#define I2C_PIN PINB
+#define I2C_DIR DDRB
+#define I2C_PIN_SCL PINB2
+#define I2C_PIN_SDA PINB0
+
+#define AO_CONST_ATTRIB PROGMEM
+typedef int32_t alt_t;
+#define FETCH_ALT(o) ((alt_t) pgm_read_dword(&altitude_table[o]))
+
+#define AO_ALT_VALUE(x) ((x) * (alt_t) 10)
+
+#define BOOST_DETECT 1200 /* 100m (ish) */
+#define LOG_INTERVAL 200 /* 19.2 seconds */
+
+#define AO_LOG_ID AO_LOG_ID_MICROKITE
+
+#endif /* _AO_PINS_H_ */
--- /dev/null
+#!/bin/sh
+dir=`dirname $0`
+
+HEX="$dir"/"%HEX%"
+LOADCMD="%LOADCMD%"
+LOADARG="%LOADARG%"
+LOADSLOW="%LOADSLOW%"
+LOADFAST=""
+
+case "$1" in
+fast)
+ LOADSPEED="$LOADFAST"
+ ;;
+*)
+ LOADSPEED="$LOADSLOW"
+ ;;
+esac
+
+echo ${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX}
+${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX}
#define BOOST_DETECT 360 /* 30m at sea level, 36m at 2000m */
#endif
+#ifndef LOG_INTERVAL
+#define LOG_INTERVAL 2 /* 192 ms */
+#endif
+
+#define AO_LOG_ID_MICROPEAK 0
+#define AO_LOG_ID_MICROKITE 1
+
+#ifndef AO_LOG_ID
+#define AO_LOG_ID AO_LOG_ID_MICROPEAK
+#endif
+
/* Wait after power on before doing anything to give the user time to assemble the rocket */
#define BOOST_DELAY AO_SEC_TO_TICKS(60)