From fa813bcb6afc851cf4029b56c19ba46a3ae578f5 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Mon, 9 Feb 2015 08:35:24 -0600 Subject: Minor typo in man page --- ao-tools/ao-usbtrng/ao-usbtrng.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ao-tools/ao-usbtrng/ao-usbtrng.1 b/ao-tools/ao-usbtrng/ao-usbtrng.1 index 7a1311b9..b4a3e5ec 100644 --- a/ao-tools/ao-usbtrng/ao-usbtrng.1 +++ b/ao-tools/ao-usbtrng/ao-usbtrng.1 @@ -16,7 +16,7 @@ .\" 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. .\" .\" -.TH AO-LOAD 1 "ao-usbtrng" "" +.TH AO-USBTRNG 1 "ao-usbtrng" "" .SH NAME ao-usbtrng \- dump random numbers from USBtrng .SH SYNOPSIS -- cgit v1.2.3 From 65837616a6d073da8e3e2bf9da524a48cffb77c2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 9 Feb 2015 07:28:18 -0800 Subject: altos/stmf0: Add ao_crc_stm.c Tom discovered that this was missing Signed-off-by: Keith Packard --- src/stmf0/ao_crc_stm.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/stmf0/ao_crc_stm.c diff --git a/src/stmf0/ao_crc_stm.c b/src/stmf0/ao_crc_stm.c new file mode 100644 index 00000000..78efa93a --- /dev/null +++ b/src/stmf0/ao_crc_stm.c @@ -0,0 +1,90 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +#include +#include + +#ifndef AO_CRC_WIDTH +#error "Must define AO_CRC_WIDTH" +#endif + +/* Only the STM32F07x and ST32F09x series have + * programmable CRC units. Others can only do the ANSI CRC-32 computation + */ + +#if !AO_HAVE_PROGRAMMABLE_CRC_UNIT && AO_CRC_WIDTH != 32 +#error "Target hardware does not have programmable CRC unit" +#endif + +#ifndef AO_CRC_POLY +#if AO_CRC_WIDTH == 16 +#define AO_CRC_POLY AO_CRC_16_DEFAULT +#endif +#if AO_CRC_WIDTH == 32 +#define AO_CRC_POLY AO_CRC_32_DEFAULT +#endif +#endif + +#if !AO_HAVE_PROGRAMMABLE_CRC_UNIT && (AO_CRC_WIDTH != 32 || AO_CRC_POLY != AO_CRC_32_ANSI) +#error "Target hardware does not have programmable CRC unit" +#endif + +#if AO_CRC_WIDTH == 32 +#define AO_CRC_CR_POLYSIZE STM_CRC_CR_POLYSIZE_32 +#endif + +#if AO_CRC_WIDTH == 16 +#define AO_CRC_CR_POLYSIZE STM_CRC_CR_POLYSIZE_16 +#endif + +#if AO_CRC_WIDTH == 8 +#define AO_CRC_CR_POLYSIZE STM_CRC_CR_POLYSIZE_8 +#endif + +#if AO_CRC_WIDTH == 7 +#define AO_CRC_CR_POLYSIZE STM_CRC_CR_POLYSIZE_7 +#endif + +#ifndef AO_CRC_INIT +#define AO_CRC_INIT 0xffffffff; +#endif + +void +ao_crc_reset(void) +{ + stm_crc.cr |= (1 << STM_CRC_CR_RESET); + while ((stm_crc.cr & (1 << STM_CRC_CR_RESET)) != 0) + ; +} + +void +ao_crc_init(void) +{ + /* Turn on the CRC clock */ + stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_CRCEN); + + /* Need to initialize CR even on non-programmable hardware, + * the write to the POLYSIZE bits will be ignored in that + * case + */ + stm_crc.cr = (AO_CRC_CR_POLYSIZE << STM_CRC_CR_POLYSIZE); + stm_crc.init = AO_CRC_INIT; +#if AO_HAVE_PROGRAMMABLE_CRC_UNIT + stm_crc.pol = AO_CRC_POLY; +#endif + ao_crc_reset(); +} -- cgit v1.2.3 From 1445725b983134d5a967dee88ef997bf15d4a422 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Wed, 11 Feb 2015 08:21:27 -0600 Subject: Added continuous output option to ao-usbtrng --- ao-tools/ao-usbtrng/ao-usbtrng.1 | 20 +++++++++--------- ao-tools/ao-usbtrng/ao-usbtrng.c | 44 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ao-tools/ao-usbtrng/ao-usbtrng.1 b/ao-tools/ao-usbtrng/ao-usbtrng.1 index b4a3e5ec..eabdd8a1 100644 --- a/ao-tools/ao-usbtrng/ao-usbtrng.1 +++ b/ao-tools/ao-usbtrng/ao-usbtrng.1 @@ -20,24 +20,24 @@ .SH NAME ao-usbtrng \- dump random numbers from USBtrng .SH SYNOPSIS -.B "ao-usbtrng" -[\-T \fItty-device\fP] -[\--tty \fItty-device\fP] -[\-D \fIaltos-device\fP] -[\--device \fIaltos-device\fP] -\fIkbytes\fP +.B "ao-usbtrng" [OPTION...] [KBYTES] .SH DESCRIPTION .I ao-usbtrng -dumps random numbers from a USBtrng device +dumps random numbers from a USBtrng device. If provided KBYTES specifies the number of 1024 byte blocks to produce on standard output. Without KBYTES +.I ao-usbtrng +produces random bytes continuously until killed. .SH OPTIONS .TP -\-T tty-device | --tty tty-device +\-v, --verbose +increase verbosity +.TP +\-T, -tty=TTYDEVICE This selects which tty device the debugger uses to communicate with the target device. The special name 'BITBANG' directs ao-dbg to use the cp2103 connection, otherwise this should be a usb serial port connected to a suitable cc1111 debug node. .TP -\-D AltOS-device | --device AltOS-device +\-D, --device=ALTOSDEVICE Search for a connected device. This requires an argument of one of the following forms: .IP @@ -52,7 +52,7 @@ product, leaving out the serial number will cause the tool to match one of the available devices. .SH USAGE .I ao-usbtrng -opens the target device and reads the specified number of kbytes of +opens the target device and reads the specified number of KBYTES of random data. .SH AUTHOR Keith Packard diff --git a/ao-tools/ao-usbtrng/ao-usbtrng.c b/ao-tools/ao-usbtrng/ao-usbtrng.c index 232f4e3e..456885d9 100644 --- a/ao-tools/ao-usbtrng/ao-usbtrng.c +++ b/ao-tools/ao-usbtrng/ao-usbtrng.c @@ -35,14 +35,13 @@ static const struct option options[] = { { .name = "tty", .has_arg = 1, .val = 'T' }, { .name = "device", .has_arg = 1, .val = 'D' }, - { .name = "raw", .has_arg = 0, .val = 'r' }, - { .name = "verbose", .has_arg = 1, .val = 'v' }, + { .name = "verbose", .has_arg = 0, .val = 'v' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--verbose=] [--device=] [-tty=] \n", program); + fprintf(stderr, "usage: %s [--verbose] [--device=] [-tty=] []\n", program); exit(1); } @@ -58,21 +57,17 @@ main (int argc, char **argv) { char *device = NULL; char *filename; - Elf *e; - unsigned int s; int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0; - int expected_size; - int kbytes; + int kbytes = 0; /* 0 == continuous */ + int written; uint8_t bits[1024]; - while ((c = getopt_long(argc, argv, "rT:D:c:s:v:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "vT:D:", options, NULL)) != -1) { switch (c) { case 'T': tty = optarg; @@ -89,12 +84,8 @@ main (int argc, char **argv) } } - if (!argv[optind]) - usage(argv[0]); - - kbytes = atoi(argv[optind]); - if (kbytes < 1) - kbytes = 1; + if (optind < argc) + kbytes = atoi(argv[optind]); ao_verbose = verbose; @@ -113,13 +104,22 @@ main (int argc, char **argv) if (!cc) exit(1); - cc_usb_printf(cc, "f %d\n", kbytes); + if (kbytes) { + cc_usb_printf(cc, "f %d\n", kbytes); - while (kbytes--) { - int i; - for (i = 0; i < 1024; i++) - bits[i] = cc_usb_getchar(cc); - write(1, bits, 1024); + while (kbytes--) { + for (i = 0; i < 1024; i++) + bits[i] = cc_usb_getchar(cc); + write(1, bits, 1024); + } + } else { /* 0 == continuous */ + written = 0; + while (written >= 0) { + cc_usb_printf(cc, "f 1\n"); + for (i = 0; i < 1024; i++) + bits[i] = cc_usb_getchar(cc); + written = write(1, bits, 1024); + } } done(cc, ret); -- cgit v1.2.3 From f4c812bef76a2cd95f675cb27ea89059561ceec7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Feb 2015 23:51:10 -0800 Subject: altos: Replace ao_alarm/ao_clear_alarm with ao_sleep_for Having arbitrary alarms firing in the middle of complicated device logic makes no sense at all. Therefore only correct use of ao_alarm and ao_clear_alarm was around a specific ao_sleep call, with correct recovery in case the alarm fires. This patch replaces all uses of ao_alarm/ao_sleep/ao_clear_alarm with ao_sleep_for, a new function which takes the alarm timeout directly. A few cases which weren't simply calling ao_sleep have been reworked to pass the timeout value down to the place where sleep *is* being called, and having that code deal with the return correctly. Signed-off-by: Keith Packard --- src/cc1111/ao_arch.h | 2 +- src/cc1111/ao_button.c | 4 ++-- src/cc1111/ao_radio.c | 6 +----- src/drivers/ao_btm.c | 8 +++----- src/drivers/ao_cc1120.c | 16 +++------------- src/drivers/ao_cc1200.c | 8 +------- src/drivers/ao_companion.c | 3 +-- src/drivers/ao_hmc5883.c | 4 +--- src/drivers/ao_packet.c | 4 ++-- src/drivers/ao_packet_master.c | 8 ++------ src/drivers/ao_packet_slave.c | 2 +- src/kernel/ao_packet.h | 2 +- src/kernel/ao_pyro.c | 4 +--- src/kernel/ao_serial.h | 8 ++++---- src/kernel/ao_task.c | 20 +++++++++++++++----- src/kernel/ao_task.h | 10 ++++++++++ src/kernel/ao_telemetry.c | 4 +--- src/product/ao_terraui.c | 4 +--- src/stm/ao_i2c_stm.c | 18 +++++------------- src/stm/ao_serial_stm.c | 16 ++++++++-------- src/telebt-v3.0/ao_pins.h | 2 +- src/telelco-v0.1/ao_lco.c | 6 +----- src/telelco-v0.2/ao_lco.c | 4 +--- 23 files changed, 67 insertions(+), 96 deletions(-) diff --git a/src/cc1111/ao_arch.h b/src/cc1111/ao_arch.h index b3c6b5dc..6eb1a111 100644 --- a/src/cc1111/ao_arch.h +++ b/src/cc1111/ao_arch.h @@ -228,7 +228,7 @@ void ao_button_init(void); char -ao_button_get(void) __critical; +ao_button_get(uint16_t timeout) __critical; void ao_button_clear(void) __critical; diff --git a/src/cc1111/ao_button.c b/src/cc1111/ao_button.c index 69f3475f..a0f221c2 100644 --- a/src/cc1111/ao_button.c +++ b/src/cc1111/ao_button.c @@ -72,12 +72,12 @@ ao_button_mask(uint8_t reg) } char -ao_button_get(void) __critical +ao_button_get(uint16_t timeout) __critical { char b; while (ao_fifo_empty(ao_button_fifo)) - if (ao_sleep(&ao_button_fifo)) + if (ao_sleep_for(&ao_button_fifo, timeout)) return 0; ao_fifo_remove(ao_button_fifo, b); return b; diff --git a/src/cc1111/ao_radio.c b/src/cc1111/ao_radio.c index b9821a42..cead0364 100644 --- a/src/cc1111/ao_radio.c +++ b/src/cc1111/ao_radio.c @@ -451,13 +451,9 @@ ao_radio_recv(__xdata void *packet, uint8_t size, uint8_t timeout) __reentrant /* Wait for DMA to be done, for the radio receive process to * get aborted or for a receive timeout to fire */ - if (timeout) - ao_alarm(timeout); __critical while (!ao_radio_dma_done && !ao_radio_abort) - if (ao_sleep(&ao_radio_dma_done)) + if (ao_sleep_for(&ao_radio_dma_done, timeout)) break; - if (timeout) - ao_clear_alarm(); /* If recv was aborted, clean up by stopping the DMA engine * and idling the radio diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index e6b28688..93d9dd9d 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -23,7 +23,7 @@ #ifndef ao_serial_btm_getchar #define ao_serial_btm_putchar ao_serial1_putchar #define _ao_serial_btm_pollchar _ao_serial1_pollchar -#define _ao_serial_btm_sleep() ao_sleep((void *) &ao_serial1_rx_fifo) +#define _ao_serial_btm_sleep_for(timeout) ao_sleep_for((void *) &ao_serial1_rx_fifo, timeout) #define ao_serial_btm_set_speed ao_serial1_set_speed #define ao_serial_btm_drain ao_serial1_drain #endif @@ -111,7 +111,7 @@ ao_btm_do_echo(void) while (ao_btm_enable) { ao_arch_block_interrupts(); while ((c = _ao_serial_btm_pollchar()) == AO_READ_AGAIN && ao_btm_enable) - _ao_serial_btm_sleep(); + _ao_serial_btm_sleep_for(0); ao_arch_release_interrupts(); if (c != AO_READ_AGAIN) { putchar(c); @@ -166,9 +166,7 @@ ao_btm_getchar(void) ao_arch_block_interrupts(); while ((c = _ao_serial_btm_pollchar()) == AO_READ_AGAIN) { - ao_alarm(AO_MS_TO_TICKS(10)); - c = _ao_serial_btm_sleep(); - ao_clear_alarm(); + c = _ao_serial_btm_sleep_for(AO_MS_TO_TICKS(10)); if (c) { c = AO_READ_AGAIN; break; diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 90d6cc75..5b814667 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -837,15 +837,11 @@ ao_radio_test_cmd(void) static void ao_radio_wait_isr(uint16_t timeout) { - if (timeout) - ao_alarm(timeout); ao_arch_block_interrupts(); while (!ao_radio_wake && !ao_radio_mcu_wake && !ao_radio_abort) - if (ao_sleep(&ao_radio_wake)) + if (ao_sleep_for(&ao_radio_wake, timeout)) ao_radio_abort = 1; ao_arch_release_interrupts(); - if (timeout) - ao_clear_alarm(); if (ao_radio_mcu_wake) ao_radio_check_marc_status(); } @@ -1060,19 +1056,17 @@ ao_radio_rx_isr(void) static uint16_t ao_radio_rx_wait(void) { - ao_alarm(AO_MS_TO_TICKS(100)); ao_arch_block_interrupts(); rx_waiting = 1; while (rx_data_cur - rx_data_consumed < AO_FEC_DECODE_BLOCK && !ao_radio_abort && !ao_radio_mcu_wake) { - if (ao_sleep(&ao_radio_wake)) + if (ao_sleep_for(&ao_radio_wake, AO_MS_TO_TICKS(100))) ao_radio_abort = 1; } rx_waiting = 0; ao_arch_release_interrupts(); - ao_clear_alarm(); if (ao_radio_abort || ao_radio_mcu_wake) return 0; rx_data_consumed += AO_FEC_DECODE_BLOCK; @@ -1133,19 +1127,15 @@ ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) ao_radio_strobe(CC1120_SRX); - if (timeout) - ao_alarm(timeout); ao_arch_block_interrupts(); while (rx_starting && !ao_radio_abort) { - if (ao_sleep(&ao_radio_wake)) + if (ao_sleep_for(&ao_radio_wake, timeout)) ao_radio_abort = 1; } uint8_t rx_task_id_save = rx_task_id; rx_task_id = 0; rx_starting = 0; ao_arch_release_interrupts(); - if (timeout) - ao_clear_alarm(); if (ao_radio_abort) { if (rx_task_id_save == 0) diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index 8546900e..df4bd335 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -715,17 +715,11 @@ ao_radio_show_state(char *where) static void ao_radio_wait_isr(uint16_t timeout) { - if (timeout) - ao_alarm(timeout); - ao_arch_block_interrupts(); while (!ao_radio_wake && !ao_radio_abort) - if (ao_sleep(&ao_radio_wake)) + if (ao_sleep_for(&ao_radio_wake, timeout)) ao_radio_abort = 1; ao_arch_release_interrupts(); - - if (timeout) - ao_clear_alarm(); } static void diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index 570b9e40..7e02939b 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -102,8 +102,7 @@ ao_companion(void) break; } while (ao_companion_running) { - ao_alarm(ao_companion_setup.update_period); - if (ao_sleep(DATA_TO_XDATA(&ao_flight_state))) + if (ao_sleep_for(DATA_TO_XDATA(&ao_flight_state), ao_companion_setup.update_period)) ao_companion_get_data(); else ao_companion_notify(); diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c index 2d217bcf..f761671a 100644 --- a/src/drivers/ao_hmc5883.c +++ b/src/drivers/ao_hmc5883.c @@ -75,13 +75,11 @@ ao_hmc5883_sample(struct ao_hmc5883_sample *sample) ao_exti_enable(AO_HMC5883_INT_PORT, AO_HMC5883_INT_PIN); ao_hmc5883_reg_write(HMC5883_MODE, HMC5883_MODE_SINGLE); - ao_alarm(AO_MS_TO_TICKS(10)); ao_arch_block_interrupts(); while (!ao_hmc5883_done) - if (ao_sleep(&ao_hmc5883_done)) + if (ao_sleep_for(&ao_hmc5883_done, AO_MS_TO_TICKS(10))) ++ao_hmc5883_missed_irq; ao_arch_release_interrupts(); - ao_clear_alarm(); ao_hmc5883_read(HMC5883_X_MSB, (uint8_t *) sample, sizeof (struct ao_hmc5883_sample)); #if __BYTE_ORDER == __LITTLE_ENDIAN diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c index 8cdf85a9..18330ead 100644 --- a/src/drivers/ao_packet.c +++ b/src/drivers/ao_packet.c @@ -54,14 +54,14 @@ ao_packet_send(void) } uint8_t -ao_packet_recv(void) +ao_packet_recv(uint16_t timeout) { uint8_t dma_done; #ifdef AO_LED_GREEN ao_led_on(AO_LED_GREEN); #endif - dma_done = ao_radio_recv(&ao_rx_packet, sizeof (struct ao_packet_recv), 0); + dma_done = ao_radio_recv(&ao_rx_packet, sizeof (struct ao_packet_recv), timeout); #ifdef AO_LED_GREEN ao_led_off(AO_LED_GREEN); #endif diff --git a/src/drivers/ao_packet_master.c b/src/drivers/ao_packet_master.c index 42a4f5bf..5e440db0 100644 --- a/src/drivers/ao_packet_master.c +++ b/src/drivers/ao_packet_master.c @@ -97,9 +97,7 @@ ao_packet_master(void) if (ao_tx_packet.len) ao_packet_master_busy(); ao_packet_master_check_busy(); - ao_alarm(AO_PACKET_MASTER_RECV_DELAY); - r = ao_packet_recv(); - ao_clear_alarm(); + r = ao_packet_recv(AO_PACKET_MASTER_RECV_DELAY); if (r) { /* if we can transmit data, do so */ if (ao_packet_tx_used && ao_tx_packet.len == 0) @@ -107,9 +105,7 @@ ao_packet_master(void) if (ao_rx_packet.packet.len) ao_packet_master_busy(); ao_packet_master_sleeping = 1; - ao_alarm(ao_packet_master_delay); - ao_sleep(&ao_packet_master_sleeping); - ao_clear_alarm(); + ao_sleep_for(&ao_packet_master_sleeping, ao_packet_master_delay); ao_packet_master_sleeping = 0; } } diff --git a/src/drivers/ao_packet_slave.c b/src/drivers/ao_packet_slave.c index e75df0d6..0872682f 100644 --- a/src/drivers/ao_packet_slave.c +++ b/src/drivers/ao_packet_slave.c @@ -24,7 +24,7 @@ ao_packet_slave(void) ao_tx_packet.len = AO_PACKET_SYN; ao_packet_restart = 1; while (ao_packet_enable) { - if (ao_packet_recv()) { + if (ao_packet_recv(0)) { ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN); #if HAS_FLIGHT ao_flight_force_idle = TRUE; diff --git a/src/kernel/ao_packet.h b/src/kernel/ao_packet.h index b8426cf9..136609c3 100644 --- a/src/kernel/ao_packet.h +++ b/src/kernel/ao_packet.h @@ -54,7 +54,7 @@ void ao_packet_send(void); uint8_t -ao_packet_recv(void); +ao_packet_recv(uint16_t timeout); void ao_packet_flush(void); diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 3044d565..43e73de4 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -375,9 +375,7 @@ ao_pyro(void) ao_sleep(&ao_flight_state); for (;;) { - ao_alarm(AO_MS_TO_TICKS(100)); - ao_sleep(&ao_pyro_wakeup); - ao_clear_alarm(); + ao_sleep_for(&ao_pyro_wakeup, AO_MS_TO_TICKS(100)); if (ao_flight_state >= ao_flight_landed) break; any_waiting = ao_pyro_check(); diff --git a/src/kernel/ao_serial.h b/src/kernel/ao_serial.h index dbc9f8e4..e21643ac 100644 --- a/src/kernel/ao_serial.h +++ b/src/kernel/ao_serial.h @@ -35,7 +35,7 @@ int _ao_serial0_pollchar(void); uint8_t -_ao_serial0_sleep(void); +_ao_serial0_sleep_for(uint16_t timeout); void ao_serial0_putchar(char c); @@ -58,7 +58,7 @@ int _ao_serial1_pollchar(void); uint8_t -_ao_serial1_sleep(void); +_ao_serial1_sleep_for(uint16_t timeout); void ao_serial1_putchar(char c); @@ -81,7 +81,7 @@ int _ao_serial2_pollchar(void); uint8_t -_ao_serial2_sleep(void); +_ao_serial2_sleep_for(uint16_t timeout); void ao_serial2_putchar(char c); @@ -104,7 +104,7 @@ int _ao_serial3_pollchar(void); uint8_t -_ao_serial3_sleep(void); +_ao_serial3_sleep_for(uint16_t timeout); void ao_serial3_putchar(char c); diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index bafb4943..1ecdd7dd 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -450,7 +450,7 @@ ao_wakeup(__xdata void *wchan) __reentrant ao_check_stack(); } -void +static void ao_alarm(uint16_t delay) { #if HAS_TASK_QUEUE @@ -468,7 +468,7 @@ ao_alarm(uint16_t delay) #endif } -void +static void ao_clear_alarm(void) { #if HAS_TASK_QUEUE @@ -483,14 +483,24 @@ ao_clear_alarm(void) #endif } +uint8_t +ao_sleep_for(__xdata void *wchan, uint16_t timeout) +{ + uint8_t ret; + if (timeout) + ao_alarm(timeout); + ret = ao_sleep(wchan); + if (timeout) + ao_clear_alarm(); + return ret; +} + static __xdata uint8_t ao_forever; void ao_delay(uint16_t ticks) { - ao_alarm(ticks); - ao_sleep(&ao_forever); - ao_clear_alarm(); + ao_sleep_for(&ao_forever, ticks); } void diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h index 9c56b480..c6bec0e3 100644 --- a/src/kernel/ao_task.h +++ b/src/kernel/ao_task.h @@ -68,10 +68,19 @@ extern __data uint8_t ao_task_minimize_latency; /* Reduce IRQ latency */ uint8_t ao_sleep(__xdata void *wchan); +/* Suspend the current task until wchan is awoken or the timeout + * expires. returns: + * 0 on normal wake + * 1 on alarm + */ +uint8_t +ao_sleep_for(__xdata void *wchan, uint16_t timeout); + /* Wake all tasks sleeping on wchan */ void ao_wakeup(__xdata void *wchan) __reentrant; +#if 0 /* set an alarm to go off in 'delay' ticks */ void ao_alarm(uint16_t delay); @@ -79,6 +88,7 @@ ao_alarm(uint16_t delay); /* Clear any pending alarm */ void ao_clear_alarm(void); +#endif /* Yield the processor to another task */ void diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index e2197f7a..854ac898 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -486,9 +486,7 @@ ao_telemetry(void) #endif /* HAS_APRS */ delay = time - ao_time(); if (delay > 0) { - ao_alarm(delay); - ao_sleep(&telemetry); - ao_clear_alarm(); + ao_sleep_for(&telemetry, delay); } } } diff --git a/src/product/ao_terraui.c b/src/product/ao_terraui.c index 8fd97033..1e7b5dcd 100644 --- a/src/product/ao_terraui.c +++ b/src/product/ao_terraui.c @@ -539,9 +539,7 @@ ao_terraui(void) else ao_terraui_page[ao_current_page](); - ao_alarm(AO_SEC_TO_TICKS(1)); - b = ao_button_get(); - ao_clear_alarm(); + b = ao_button_get(AO_SEC_TO_TICKS(1)); if (b > 0) { ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(10)); diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c index 1c90cdb8..158f5b21 100644 --- a/src/stm/ao_i2c_stm.c +++ b/src/stm/ao_i2c_stm.c @@ -195,15 +195,13 @@ ao_i2c_start(uint8_t index, uint16_t addr) if (!(stm_i2c->cr1 & (1 << STM_I2C_CR1_START))) break; } - ao_alarm(AO_MS_TO_TICKS(250)); ao_arch_block_interrupts(); stm_i2c->cr2 = AO_STM_I2C_CR2 | (1 << STM_I2C_CR2_ITEVTEN) | (1 << STM_I2C_CR2_ITERREN); ao_i2c_ev_isr(index); while (ao_i2c_state[index] == I2C_IDLE) - if (ao_sleep(&ao_i2c_state[index])) + if (ao_sleep_for(&ao_i2c_state[index], AO_MS_TO_TICKS(250))) break; ao_arch_release_interrupts(); - ao_clear_alarm(); return ao_i2c_state[index] == I2C_RUNNING; } @@ -258,16 +256,14 @@ ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop) (STM_DMA_CCR_DIR_MEM_TO_PER << STM_DMA_CCR_DIR)); ao_dma_start(tx_dma_index); - ao_alarm(1 + len); ao_arch_block_interrupts(); while (!ao_dma_done[tx_dma_index]) - if (ao_sleep(&ao_dma_done[tx_dma_index])) + if (ao_sleep_for(&ao_dma_done[tx_dma_index], 1 + len)) break; - ao_clear_alarm(); ao_dma_done_transfer(tx_dma_index); stm_i2c->cr2 = AO_STM_I2C_CR2 | (1 << STM_I2C_CR2_ITEVTEN) | (1 << STM_I2C_CR2_ITERREN); while ((stm_i2c->sr1 & (1 << STM_I2C_SR1_BTF)) == 0) - if (ao_sleep(&ao_i2c_state[index])) + if (ao_sleep_for(&ao_i2c_state[index], 1 + len)) break; stm_i2c->cr2 = AO_STM_I2C_CR2; ao_arch_release_interrupts(); @@ -321,14 +317,12 @@ ao_i2c_recv(void *block, uint16_t len, uint8_t index, uint8_t stop) if (stop) stm_i2c->cr1 = AO_STM_I2C_CR1 | (1 << STM_I2C_CR1_STOP); - ao_alarm(1); ao_arch_block_interrupts(); while (ao_i2c_recv_len[index]) - if (ao_sleep(&ao_i2c_recv_len[index])) + if (ao_sleep_for(&ao_i2c_recv_len[index], 1)) break; ao_arch_release_interrupts(); ret = ao_i2c_recv_len[index] == 0; - ao_clear_alarm(); } else { uint8_t rx_dma_index = ao_i2c_stm_info[index].rx_dma_index; ao_dma_set_transfer(rx_dma_index, @@ -351,13 +345,11 @@ ao_i2c_recv(void *block, uint16_t len, uint8_t index, uint8_t stop) ao_i2c_wait_addr(index); ao_dma_start(rx_dma_index); - ao_alarm(len); ao_arch_block_interrupts(); while (!ao_dma_done[rx_dma_index]) - if (ao_sleep(&ao_dma_done[rx_dma_index])) + if (ao_sleep_for(&ao_dma_done[rx_dma_index], len)) break; ao_arch_release_interrupts(); - ao_clear_alarm(); ret = ao_dma_done[rx_dma_index]; ao_dma_done_transfer(rx_dma_index); stm_i2c->cr1 = AO_STM_I2C_CR1 | (1 << STM_I2C_CR1_STOP); diff --git a/src/stm/ao_serial_stm.c b/src/stm/ao_serial_stm.c index 2568cf43..88f2d029 100644 --- a/src/stm/ao_serial_stm.c +++ b/src/stm/ao_serial_stm.c @@ -86,9 +86,9 @@ ao_usart_getchar(struct ao_stm_usart *usart) } static inline uint8_t -_ao_usart_sleep(struct ao_stm_usart *usart) +_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout) { - return ao_sleep(&usart->rx_fifo); + return ao_sleep_for(&usart->rx_fifo, timeout); } void @@ -217,9 +217,9 @@ _ao_serial1_pollchar(void) } uint8_t -_ao_serial1_sleep(void) +_ao_serial1_sleep_for(uint16_t timeout) { - return _ao_usart_sleep(&ao_stm_usart1); + return _ao_usart_sleep_for(&ao_stm_usart1, timeout); } void @@ -260,9 +260,9 @@ _ao_serial2_pollchar(void) } uint8_t -_ao_serial2_sleep(void) +_ao_serial2_sleep_for(uint16_t timeout) { - return _ao_usart_sleep(&ao_stm_usart2); + return _ao_usart_sleep_for(&ao_stm_usart2, timeout); } void @@ -303,9 +303,9 @@ _ao_serial3_pollchar(void) } uint8_t -_ao_serial3_sleep(void) +_ao_serial3_sleep_for(uint16_t timeout) { - return _ao_usart_sleep(&ao_stm_usart3); + return _ao_usart_sleep_for(&ao_stm_usart3, timeout); } void diff --git a/src/telebt-v3.0/ao_pins.h b/src/telebt-v3.0/ao_pins.h index 838f0dfc..6e90afcc 100644 --- a/src/telebt-v3.0/ao_pins.h +++ b/src/telebt-v3.0/ao_pins.h @@ -168,7 +168,7 @@ struct ao_adc { #define ao_serial_btm_getchar ao_serial2_getchar #define ao_serial_btm_putchar ao_serial2_putchar #define _ao_serial_btm_pollchar _ao_serial2_pollchar -#define _ao_serial_btm_sleep _ao_serial2_sleep +#define _ao_serial_btm_sleep_for _ao_serial2_sleep_for #define ao_serial_btm_set_speed ao_serial2_set_speed #define ao_serial_btm_drain ao_serial2_drain #define ao_serial_btm_rx_fifo (ao_stm_usart2.rx_fifo) diff --git a/src/telelco-v0.1/ao_lco.c b/src/telelco-v0.1/ao_lco.c index 79f3896b..cb2195ef 100644 --- a/src/telelco-v0.1/ao_lco.c +++ b/src/telelco-v0.1/ao_lco.c @@ -280,9 +280,7 @@ ao_lco_igniter_status(void) uint16_t delay; for (;;) { -// ao_alarm(delay); ao_sleep(&ao_pad_query); -// ao_clear_alarm(); if (!ao_lco_valid) { ao_led_on(AO_LED_RED); ao_led_off(AO_LED_GREEN); @@ -364,9 +362,7 @@ ao_lco_monitor(void) delay = AO_MS_TO_TICKS(100); else delay = AO_SEC_TO_TICKS(1); - ao_alarm(delay); - ao_sleep(&ao_lco_armed); - ao_clear_alarm(); + ao_sleep_for(&ao_lco_armed, delay); } } diff --git a/src/telelco-v0.2/ao_lco.c b/src/telelco-v0.2/ao_lco.c index 4b5f7a9b..12a247bf 100644 --- a/src/telelco-v0.2/ao_lco.c +++ b/src/telelco-v0.2/ao_lco.c @@ -369,9 +369,7 @@ ao_lco_monitor(void) delay = AO_MS_TO_TICKS(100); else delay = AO_SEC_TO_TICKS(1); - ao_alarm(delay); - ao_sleep(&ao_lco_armed); - ao_clear_alarm(); + ao_sleep_for(&ao_lco_armed, delay); } } -- cgit v1.2.3 From 0e929ee2d0a3d1b1bacd36c2c3723ab860eb40b6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Feb 2015 01:11:30 -0800 Subject: altosui: Run all igniter status requests from non-GUI thread Anything run from the UI thread blocks the UI entirely; the Fire Igniters startup code to collect the number of pyro channels when building the UI was doing that from the UI thread. Switch that around so that the UI doesn't get built until that reply comes back, allowing the user to see the 'connecting' dialog, and cancel it if required. Signed-off-by: Keith Packard --- altosui/AltosIgniteUI.java | 60 ++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 944c659b..1a2dc4f1 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -50,8 +50,6 @@ public class AltosIgniteUI LinkedBlockingQueue command_queue; - LinkedBlockingQueue reply_queue; - class Igniter { JRadioButton button; JLabel status_label; @@ -150,8 +148,7 @@ public class AltosIgniteUI } reply = "status"; } else if (command.equals("get_npyro")) { - put_reply(String.format("%d", ignite.npyro())); - continue; + reply = String.format("npyro %d", ignite.npyro()); } else if (command.equals("quit")) { ignite.close(); break; @@ -211,6 +208,9 @@ public class AltosIgniteUI set_ignite_status(); } else if (reply.equals("fired")) { fired(); + } else if (reply.startsWith("npyro")) { + npyro = Integer.parseInt(reply.substring(6)); + make_ui(); } } @@ -250,24 +250,6 @@ public class AltosIgniteUI } } - void put_reply(String reply) { - try { - reply_queue.put(reply); - } catch (Exception ex) { - ignite_exception(ex); - } - } - - String get_reply() { - String reply = ""; - try { - reply = reply_queue.take(); - } catch (Exception ex) { - ignite_exception(ex); - } - return reply; - } - boolean getting_status = false; boolean visible = false; @@ -287,12 +269,6 @@ public class AltosIgniteUI } } - int get_npyro() { - send_command("get_npyro"); - String reply = get_reply(); - return Integer.parseInt(reply); - } - boolean firing = false; void start_fire(String which) { @@ -310,8 +286,9 @@ public class AltosIgniteUI void close() { if (opened) { send_command("quit"); - timer.stop(); } + if (timer != null) + timer.stop(); setVisible(false); dispose(); } @@ -383,7 +360,6 @@ public class AltosIgniteUI private boolean open() { command_queue = new LinkedBlockingQueue(); - reply_queue = new LinkedBlockingQueue(); opened = false; device = AltosDeviceUIDialog.show(owner, Altos.product_any); @@ -403,13 +379,7 @@ public class AltosIgniteUI return false; } - public AltosIgniteUI(JFrame in_owner) { - - owner = in_owner; - - if (!open()) - return; - + private void make_ui() { group = new ButtonGroup(); Container pane = getContentPane(); @@ -422,8 +392,6 @@ public class AltosIgniteUI timer_running = false; timer.restart(); - owner = in_owner; - pane.setLayout(new GridBagLayout()); c.fill = GridBagConstraints.NONE; @@ -443,8 +411,6 @@ public class AltosIgniteUI y++; - int npyro = get_npyro(); - igniters = new Igniter[2 + npyro]; igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++); @@ -492,4 +458,14 @@ public class AltosIgniteUI addWindowListener(new ConfigListener(this)); } -} \ No newline at end of file + + public AltosIgniteUI(JFrame in_owner) { + + owner = in_owner; + + if (!open()) + return; + + send_command("get_npyro"); + } +} -- cgit v1.2.3 From c4f9d96bdea192486f0e3f2d80b846c39a05c0ab Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Feb 2015 01:13:21 -0800 Subject: altosuilib: Detect pair programming by product name, not USB id With TeleDongle, TeleBT and TeleMetrum coming in both pair- and self- programmable versions, we can't use the USB id to tell them apart. Instead, fetch the device name and use that instead. Signed-off-by: Keith Packard --- altosuilib/AltosFlashUI.java | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/altosuilib/AltosFlashUI.java b/altosuilib/AltosFlashUI.java index 6e497c42..ace8fbe5 100644 --- a/altosuilib/AltosFlashUI.java +++ b/altosuilib/AltosFlashUI.java @@ -54,7 +54,7 @@ public class AltosFlashUI // Flash controller AltosProgrammer programmer; - private static String[] pair_programmed = { + private static final String[] pair_programmed_files = { "teleballoon", "telebt-v1", "teledongle-v0", @@ -67,20 +67,34 @@ public class AltosFlashUI "teleterra" }; + private static final String[] pair_programmed_devices = { + "TeleBalloon", + "TeleBT-v1", + "TeleDongle-v0", + "TeleFire", + "TeleMetrum-v0", + "TeleMetrum-v1", + "TeleMini", + "TeleNano", + "TeleShield", + "TeleTerra" + }; + private boolean is_pair_programmed() { if (file != null) { String name = file.getName(); - for (int i = 0; i < pair_programmed.length; i++) { - if (name.startsWith(pair_programmed[i])) + for (int i = 0; i < pair_programmed_files.length; i++) { + if (name.startsWith(pair_programmed_files[i])) return true; } } if (device != null) { - if (!device.matchProduct(AltosLib.product_altusmetrum) && - (device.matchProduct(AltosLib.product_teledongle) || - device.matchProduct(AltosLib.product_telebt))) - return true; + String name = device.toString(); + for (int i = 0; i < pair_programmed_devices.length; i++) { + if (name.startsWith(pair_programmed_devices[i])) + return true; + } } return false; } -- cgit v1.2.3 From cc64e0e9d35e01b349680159a5bbd68d059134cd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Feb 2015 01:16:42 -0800 Subject: ao-bringup/turnon_telemini: Detect which programmer to use by $USER Bdale uses TD 100, keithp uses TD 186. Signed-off-by: Keith Packard --- ao-bringup/turnon_telemini | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ao-bringup/turnon_telemini b/ao-bringup/turnon_telemini index 4450d6f6..6aef7f51 100755 --- a/ao-bringup/turnon_telemini +++ b/ao-bringup/turnon_telemini @@ -18,11 +18,13 @@ else exit 1 fi -echo "TeleMini v1.0 Turn-On and Calibration Program" +VERSION=1.0 + +echo "TeleMini v$VERSION Turn-On and Calibration Program" echo "Copyright 2011 by Bdale Garbee. Released under GPL v2" echo echo "Expectations:" -echo "\tTeleMini v1.0 powered from LiPo" +echo "\tTeleMini v$VERSION powered from LiPo" echo "\t\twith TeleDongle (on /dev/ttyACM0) cabled to debug header" echo "\t\twith frequency counter able to sample RF output" echo @@ -31,18 +33,27 @@ read SERIAL echo $RAWLOAD -$RAWLOAD -D 100 -r ao_led_blink.ihx +case $USER in + bdale) + programmer=100 + ;; + keithp) + programmer=186 + ;; +esac + +$RAWLOAD -D $programmer -r ao_led_blink.ihx echo "LEDs should be blinking" sleep 5 -$RAWLOAD -D 100 -r ao_radio_xmit.ihx +$RAWLOAD -D $programmer -r ao_radio_xmit.ihx echo -n "Generating RF carrier. Please enter measured frequency: " read FREQ CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` echo "Programming flash with cal value " $CAL_VALUE -$AOLOAD -D 100 --cal $CAL_VALUE /usr/share/altos/stable/telemini-v1.0*.ihx $SERIAL +$AOLOAD -D $programmer --cal $CAL_VALUE ~/altusmetrumllc/Binaries/telemini-v$VERSION-*.ihx $SERIAL echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE echo "Unplug and replug USB, cu to the board, confirm freq and record power" -- cgit v1.2.3 From 9c75faf1ec51eb2f9a8dc9402653490143a784d9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Feb 2015 08:35:47 -0800 Subject: altos: embed ao_alarm and ao_clear_alarm in ao_sleep_for sdcc won't embed these itself, and thus consumes too much flash for telemetrum-v1.0 Signed-off-by: Keith Packard --- src/kernel/ao_task.c | 54 +++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index 1ecdd7dd..55e423bb 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -450,48 +450,38 @@ ao_wakeup(__xdata void *wchan) __reentrant ao_check_stack(); } -static void -ao_alarm(uint16_t delay) +uint8_t +ao_sleep_for(__xdata void *wchan, uint16_t timeout) { + uint8_t ret; + if (timeout) { #if HAS_TASK_QUEUE - uint32_t flags; - /* Make sure we sleep *at least* delay ticks, which means adding - * one to account for the fact that we may be close to the next tick - */ - flags = ao_arch_irqsave(); + uint32_t flags; + /* Make sure we sleep *at least* delay ticks, which means adding + * one to account for the fact that we may be close to the next tick + */ + flags = ao_arch_irqsave(); #endif - if (!(ao_cur_task->alarm = ao_time() + delay + 1)) - ao_cur_task->alarm = 1; + if (!(ao_cur_task->alarm = ao_time() + timeout + 1)) + ao_cur_task->alarm = 1; #if HAS_TASK_QUEUE - ao_task_to_alarm_queue(ao_cur_task); - ao_arch_irqrestore(flags); + ao_task_to_alarm_queue(ao_cur_task); + ao_arch_irqrestore(flags); #endif -} - -static void -ao_clear_alarm(void) -{ + } + ret = ao_sleep(wchan); + if (timeout) { #if HAS_TASK_QUEUE - uint32_t flags; + uint32_t flags; - flags = ao_arch_irqsave(); + flags = ao_arch_irqsave(); #endif - ao_cur_task->alarm = 0; + ao_cur_task->alarm = 0; #if HAS_TASK_QUEUE - ao_task_from_alarm_queue(ao_cur_task); - ao_arch_irqrestore(flags); + ao_task_from_alarm_queue(ao_cur_task); + ao_arch_irqrestore(flags); #endif -} - -uint8_t -ao_sleep_for(__xdata void *wchan, uint16_t timeout) -{ - uint8_t ret; - if (timeout) - ao_alarm(timeout); - ret = ao_sleep(wchan); - if (timeout) - ao_clear_alarm(); + } return ret; } -- cgit v1.2.3 From 135abf0e7c5ceb5738a0b5f68fe2be4b7abdae5e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Feb 2015 23:18:38 -0800 Subject: altos/cc1200: Adjust bit-sync configuration The default bit timing adjustment mechanism allows for only a 0.2% deviation from the programmed bit timing. I found one TeleMini device which is beyond that tolerance as it was built with an older crystal with more error. Switch to the more expensive synchronization mechanism which allows up to 2% timing error, but requires a multi-byte preamble (which we have). This fixes packet mode nicely. Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.h | 32 ++++++++++++++++++++++++++++++++ src/drivers/ao_cc1200_CC1200.h | 9 +++++++++ src/drivers/ao_packet.c | 14 ++++++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/drivers/ao_cc1200.h b/src/drivers/ao_cc1200.h index b04775fd..b2b63cde 100644 --- a/src/drivers/ao_cc1200.h +++ b/src/drivers/ao_cc1200.h @@ -438,6 +438,38 @@ #define CC1200_IF_MIX_CFG (CC1200_EXTENDED_BIT | 0x00) #define CC1200_FREQOFF_CFG (CC1200_EXTENDED_BIT | 0x01) #define CC1200_TOC_CFG (CC1200_EXTENDED_BIT | 0x02) + +#define CC1200_TOC_CFG_TOC_LIMIT 6 +#define CC1200_TOC_CFG_TOC_LIMIT_0_2 0 +#define CC1200_TOC_CFG_TOC_LIMIT_2 1 +#define CC1200_TOC_CFG_TOC_LIMIT_12 3 + +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN 3 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_8 0 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_16 1 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_32 2 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_64 3 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_128 4 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_256 5 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_8_16 0 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_6_16 1 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_2_16 2 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_1_16 3 +#define CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_1_16_SYNC 4 + +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN 0 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_8 0 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_16 1 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_32 2 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_64 3 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_128 4 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_256 5 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_FREEZE 0 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_6_32 1 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_2_32 2 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_1_32 3 +#define CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_1_32_SYNC 4 + #define CC1200_MARC_SPARE (CC1200_EXTENDED_BIT | 0x03) #define CC1200_ECG_CFG (CC1200_EXTENDED_BIT | 0x04) #define CC1200_MDMCFG2 (CC1200_EXTENDED_BIT | 0x05) diff --git a/src/drivers/ao_cc1200_CC1200.h b/src/drivers/ao_cc1200_CC1200.h index 35673123..f0214c2a 100644 --- a/src/drivers/ao_cc1200_CC1200.h +++ b/src/drivers/ao_cc1200_CC1200.h @@ -101,6 +101,15 @@ (CC1200_MDMCFG2_SYMBOL_MAP_CFG_MODE_0 << CC1200_MDMCFG2_SYMBOL_MAP_CFG) | (CC1200_MDMCFG2_UPSAMPLER_P_8 << CC1200_MDMCFG2_UPSAMPLER_P) | (0 << CC1200_MDMCFG2_CFM_DATA_EN)), + CC1200_MDMCFG0, /* General Modem Parameter Configuration Reg. 0 */ + ((0 << CC1200_MDMCFG0_TRANSPARENT_MODE_EN) | + (0 << CC1200_MDMCFG0_TRANSPARENT_INTFACT) | + (0 << CC1200_MDMCFG0_DATA_FILTER_EN) | + (1 << CC1200_MDMCFG0_VITERBI_EN)), + CC1200_TOC_CFG, /* Timing Offset Correction Configuration */ + ((CC1200_TOC_CFG_TOC_LIMIT_2 << CC1200_TOC_CFG_TOC_LIMIT) | + (CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN_6_16 << CC1200_TOC_CFG_TOC_PRE_SYNC_BLOCKLEN)| + (CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN_2_32 << CC1200_TOC_CFG_TOC_POST_SYNC_BLOCKLEN)), CC1200_FREQ2, 0x6c, /* Frequency Configuration [23:16] */ CC1200_FREQ1, 0xa3, /* Frequency Configuration [15:8] */ CC1200_FREQ0, 0x33, /* Frequency Configuration [7:0] */ diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c index 18330ead..8c2db275 100644 --- a/src/drivers/ao_packet.c +++ b/src/drivers/ao_packet.c @@ -81,8 +81,16 @@ ao_packet_recv(uint16_t timeout) /* Check to see if we got a valid packet */ if (!dma_done) return 0; - if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK)) + if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK)) { + printf("bad crc addr %d len %d seq %d ack %d callsign %8.8s\n", + ao_rx_packet.packet.addr, + ao_rx_packet.packet.len, + ao_rx_packet.packet.seq, + ao_rx_packet.packet.ack, + ao_rx_packet.packet.callsign); + flush(); return 0; + } /* Accept packets with matching call signs, or any packet if * our callsign hasn't been configured @@ -90,8 +98,10 @@ ao_packet_recv(uint16_t timeout) if (ao_xmemcmp(ao_rx_packet.packet.callsign, ao_config.callsign, AO_MAX_CALLSIGN) != 0 && - ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0) + ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0) { + printf ("bad call\n"); flush(); return 0; + } /* SYN packets carry no data */ if (ao_rx_packet.packet.len == AO_PACKET_SYN) { -- cgit v1.2.3 From 2ebb4dff758058ae9512cf36518416eb69b928f0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Feb 2015 08:57:55 -0800 Subject: altos: Remove some accidental debug printfs from ao_packet.c While fixing the cc1200 configuration, I added some debug printfs to this code. They were accidentally committed with the fix... Signed-off-by: Keith Packard --- src/drivers/ao_packet.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/drivers/ao_packet.c b/src/drivers/ao_packet.c index 8c2db275..18330ead 100644 --- a/src/drivers/ao_packet.c +++ b/src/drivers/ao_packet.c @@ -81,16 +81,8 @@ ao_packet_recv(uint16_t timeout) /* Check to see if we got a valid packet */ if (!dma_done) return 0; - if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK)) { - printf("bad crc addr %d len %d seq %d ack %d callsign %8.8s\n", - ao_rx_packet.packet.addr, - ao_rx_packet.packet.len, - ao_rx_packet.packet.seq, - ao_rx_packet.packet.ack, - ao_rx_packet.packet.callsign); - flush(); + if (!(ao_rx_packet.status & AO_RADIO_STATUS_CRC_OK)) return 0; - } /* Accept packets with matching call signs, or any packet if * our callsign hasn't been configured @@ -98,10 +90,8 @@ ao_packet_recv(uint16_t timeout) if (ao_xmemcmp(ao_rx_packet.packet.callsign, ao_config.callsign, AO_MAX_CALLSIGN) != 0 && - ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0) { - printf ("bad call\n"); flush(); + ao_xmemcmp(ao_config.callsign, CODE_TO_XDATA("N0CALL"), 7) != 0) return 0; - } /* SYN packets carry no data */ if (ao_rx_packet.packet.len == AO_PACKET_SYN) { -- cgit v1.2.3 From b13a78e4f457f67605fc6dafc7f9733746a4f70c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 20:49:39 -0800 Subject: ao-bringup: Changes for telebt for keith's hacking Make the programming device auto-detect by username. Load binary from ~/altusmetrumllc Signed-off-by: Keith Packard --- ao-bringup/turnon_telebt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ao-bringup/turnon_telebt b/ao-bringup/turnon_telebt index c4902f31..f4100ae2 100755 --- a/ao-bringup/turnon_telebt +++ b/ao-bringup/turnon_telebt @@ -1,8 +1,5 @@ #!/bin/sh -# serial number of the TeleDongle being used as the flash programmer -DONGLE=612 - if [ -x ../ao-tools/ao-load/ao-load ]; then AOLOAD=../ao-tools/ao-load/ao-load elif [ -x /usr/bin/ao-load ]; then @@ -34,6 +31,19 @@ read SERIAL echo $RAWLOAD +case $USER in + bdale) + DONGLE=100 + ;; + keithp) + DONGLE=186 + ;; + *) + echo "Unknow user" + exit 1 + ;; +esac + $RAWLOAD -D $DONGLE -r ao_led_blink.ihx echo "LEDs should be blinking" sleep 5 @@ -45,7 +55,7 @@ read FREQ CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` echo "Programming flash with cal value " $CAL_VALUE -$AOLOAD -D $DONGLE --cal $CAL_VALUE /usr/share/altos/telebt-v1.0*.ihx $SERIAL +$AOLOAD -D $DONGLE --cal $CAL_VALUE ~/altusmetrumllc/Binaries/telebt-v1.0*.ihx $SERIAL echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE echo $SERIAL","$CAL_VALUE >> cal_values -- cgit v1.2.3 From c51d39c7ea1153cd2d0dc02c47824a9f35b22fb9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 20:57:11 -0800 Subject: altosdroid: Lots of bluetooth connection changes Appears to more reliably abort in-progress connection attempts so you can switch TBT devices without having the previous device in operation. Shows which device the connection is being attempted for. Eliminate the 10-second timer and just disable the service when the GUI shuts down while no BT connection is running. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 175 ++++++++---- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 38 +-- .../AltosDroid/AltosDroidPreferences.java | 18 +- .../org/altusmetrum/AltosDroid/AltosDroidTab.java | 8 +- .../altusmetrum/AltosDroid/DeviceListActivity.java | 14 +- .../altusmetrum/AltosDroid/TelemetryService.java | 302 ++++++++++++--------- .../org/altusmetrum/AltosDroid/TelemetryState.java | 9 +- 7 files changed, 330 insertions(+), 234 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 3740f55d..973250a5 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -62,6 +62,65 @@ public class AltosBluetooth extends AltosLink { } + private void connected() { + try { + synchronized(this) { + if (socket != null) { + input = socket.getInputStream(); + output = socket.getOutputStream(); + + input_thread = new Thread(this); + input_thread.start(); + + // Configure the newly connected device for telemetry + print("~\nE 0\n"); + set_monitor(false); + if (D) Log.d(TAG, "ConnectThread: connected"); + + /* Let TelemetryService know we're connected + */ + handler.obtainMessage(TelemetryService.MSG_CONNECTED).sendToTarget(); + + /* Notify other waiting threads that we're connected now + */ + notifyAll(); + } + } + } catch (IOException io) { + connect_failed(); + } + } + + private void connect_failed() { + synchronized (this) { + if (socket != null) { + try { + socket.close(); + } catch (IOException e2) { + if (D) Log.e(TAG, "ConnectThread: Failed to close() socket after failed connection"); + } + socket = null; + } + input = null; + output = null; + handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED).sendToTarget(); + if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); + } + } + + private Object closing_lock = new Object(); + private boolean closing = false; + + private void disconnected() { + synchronized(closing_lock) { + if (D) Log.e(TAG, String.format("Connection lost during I/O. Closing %b", closing)); + if (!closing) { + if (D) Log.d(TAG, "Sending disconnected message"); + handler.obtainMessage(TelemetryService.MSG_DISCONNECTED).sendToTarget(); + } + } + } + private class ConnectThread extends Thread { private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); @@ -83,54 +142,44 @@ public class AltosBluetooth extends AltosLink { // Always cancel discovery because it will slow down a connection adapter.cancelDiscovery(); - synchronized (AltosBluetooth.this) { - // Make a connection to the BluetoothSocket - try { - // This is a blocking call and will only return on a - // successful connection or an exception - socket.connect(); + BluetoothSocket local_socket; - input = socket.getInputStream(); - output = socket.getOutputStream(); - } catch (IOException e) { - // Close the socket - try { - socket.close(); - } catch (IOException e2) { - if (D) Log.e(TAG, "ConnectThread: Failed to close() socket after failed connection"); - } - input = null; - output = null; - AltosBluetooth.this.notifyAll(); - handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED).sendToTarget(); - if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); - return; + try { + synchronized (AltosBluetooth.this) { + local_socket = socket; } - input_thread = new Thread(AltosBluetooth.this); - input_thread.start(); - - // Configure the newly connected device for telemetry - print("~\nE 0\n"); - set_monitor(false); + if (local_socket != null) { + // Make a connection to the BluetoothSocket + // This is a blocking call and will only return on a + // successful connection or an exception + local_socket.connect(); + } - // Let TelemetryService know we're connected - handler.obtainMessage(TelemetryService.MSG_CONNECTED).sendToTarget(); + connected(); - // Notify other waiting threads, now that we're connected - AltosBluetooth.this.notifyAll(); + } catch (IOException e) { + connect_failed(); + } - // Reset the ConnectThread because we're done + synchronized (AltosBluetooth.this) { + /* Reset the ConnectThread because we're done + */ connect_thread = null; - - if (D) Log.d(TAG, "ConnectThread: Connect completed"); } + if (D) Log.d(TAG, "ConnectThread: Connect completed"); } public void cancel() { try { - if (socket != null) - socket.close(); + BluetoothSocket local_socket; + synchronized(AltosBluetooth.this) { + local_socket = socket; + socket = null; + } + if (local_socket != null) + local_socket.close(); + } catch (IOException e) { if (D) Log.e(TAG, "ConnectThread: close() of connect socket failed", e); } @@ -154,17 +203,13 @@ public class AltosBluetooth extends AltosLink { } private synchronized void wait_connected() throws InterruptedException, IOException { - if (input == null) { + if (input == null && socket != null) { if (D) Log.d(TAG, "wait_connected..."); wait(); if (D) Log.d(TAG, "wait_connected done"); - if (input == null) throw new IOException(); } - } - - private void connection_lost() { - if (D) Log.e(TAG, "Connection lost during I/O"); - handler.obtainMessage(TelemetryService.MSG_DISCONNECTED).sendToTarget(); + if (socket == null) + throw new IOException(); } public void print(String data) { @@ -175,9 +220,9 @@ public class AltosBluetooth extends AltosLink { output.write(bytes); if (D) Log.d(TAG, "print(): Wrote bytes: '" + data.replace('\n', '\\') + "'"); } catch (IOException e) { - connection_lost(); + disconnected(); } catch (InterruptedException e) { - connection_lost(); + disconnected(); } } @@ -189,9 +234,9 @@ public class AltosBluetooth extends AltosLink { output.write(bytes); if (D) Log.d(TAG, "print(): Wrote byte: '" + c + "'"); } catch (IOException e) { - connection_lost(); + disconnected(); } catch (InterruptedException e) { - connection_lost(); + disconnected(); } } @@ -208,32 +253,44 @@ public class AltosBluetooth extends AltosLink { buffer_len = input.read(buffer); buffer_off = 0; } catch (IOException e) { - connection_lost(); + if (D) Log.d(TAG, "getchar IOException"); + disconnected(); return AltosLink.ERROR; } catch (java.lang.InterruptedException e) { - connection_lost(); + if (D) Log.d(TAG, "getchar Interrupted"); + disconnected(); return AltosLink.ERROR; } } return buffer[buffer_off++]; } + public void closing() { + synchronized(closing_lock) { + if (D) Log.d(TAG, "Marked closing true"); + closing = true; + } + } + + public void close() { if (D) Log.d(TAG, "close(): begin"); + + closing(); + synchronized(this) { if (D) Log.d(TAG, "close(): synched"); - if (connect_thread != null) { - if (D) Log.d(TAG, "close(): stopping connect_thread"); - connect_thread.cancel(); - connect_thread = null; - } - if (D) Log.d(TAG, "close(): Closing socket"); - try { - socket.close(); - } catch (IOException e) { - if (D) Log.e(TAG, "close(): unable to close() socket"); + if (socket != null) { + if (D) Log.d(TAG, "close(): Closing socket"); + try { + socket.close(); + } catch (IOException e) { + if (D) Log.e(TAG, "close(): unable to close() socket"); + } + socket = null; } + connect_thread = null; if (input_thread != null) { if (D) Log.d(TAG, "close(): stopping input_thread"); try { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 53963f25..10e735c8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -207,9 +207,12 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } break; case TelemetryState.CONNECT_CONNECTING: - mTitle.setText(R.string.title_connecting); + if (telemetry_state.address != null) + mTitle.setText(String.format("Connecting to %s...", telemetry_state.address.name)); + else + mTitle.setText("Connecting to something..."); break; - case TelemetryState.CONNECT_READY: + case TelemetryState.CONNECT_DISCONNECTED: case TelemetryState.CONNECT_NONE: mTitle.setText(R.string.title_not_connected); break; @@ -244,8 +247,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { update_ui(telemetry_state.state, telemetry_state.location); if (telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) start_timer(); - else - stop_timer(); } boolean same_string(String a, String b) { @@ -267,8 +268,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { void update_ui(AltosState state, Location location) { - Log.d(TAG, "update_ui"); - int prev_state = AltosLib.ao_flight_invalid; AltosGreatCircle from_receiver = null; @@ -277,7 +276,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { prev_state = saved_state.state; if (state != null) { - Log.d(TAG, String.format("prev state %d new state %d\n", prev_state, state.state)); if (state.state == AltosLib.ao_flight_stateless) { boolean prev_locked = false; boolean locked = false; @@ -297,7 +295,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } else { if (prev_state != state.state) { String currentTab = mTabHost.getCurrentTabTag(); - Log.d(TAG, "switch state"); switch (state.state) { case AltosLib.ao_flight_boost: if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("ascent"); @@ -328,22 +325,18 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } if (saved_state == null || !same_string(saved_state.callsign, state.callsign)) { - Log.d(TAG, "update callsign"); mCallsignView.setText(state.callsign); } if (saved_state == null || state.serial != saved_state.serial) { - Log.d(TAG, "update serial"); mSerialView.setText(String.format("%d", state.serial)); } if (saved_state == null || state.flight != saved_state.flight) { - Log.d(TAG, "update flight"); if (state.flight == AltosLib.MISSING) mFlightView.setText(""); else mFlightView.setText(String.format("%d", state.flight)); } if (saved_state == null || state.state != saved_state.state) { - Log.d(TAG, "update state"); if (state.state == AltosLib.ao_flight_stateless) { mStateLayout.setVisibility(View.GONE); } else { @@ -352,7 +345,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } } if (saved_state == null || state.rssi != saved_state.rssi) { - Log.d(TAG, "update rssi"); mRSSIView.setText(String.format("%d", state.rssi)); } } @@ -495,13 +487,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } @Override - public synchronized void onResume() { + public void onResume() { super.onResume(); if(D) Log.e(TAG, "+ ON RESUME +"); } @Override - public synchronized void onPause() { + public void onPause() { super.onPause(); if(D) Log.e(TAG, "- ON PAUSE -"); } @@ -548,21 +540,19 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } } - private void connectDevice(String address) { + private void connectDevice(Intent data) { // Attempt to connect to the device try { - if (D) Log.d(TAG, "Connecting to " + address); - mService.send(Message.obtain(null, TelemetryService.MSG_CONNECT, address)); + String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); + String name = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_NAME); + + if (D) Log.d(TAG, "Connecting to " + address + name); + DeviceAddress a = new DeviceAddress(address, name); + mService.send(Message.obtain(null, TelemetryService.MSG_CONNECT, a)); } catch (RemoteException e) { } } - private void connectDevice(Intent data) { - // Get the device MAC address - String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); - connectDevice(address); - } - @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index 7ab70147..372500c1 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -22,9 +22,10 @@ import org.altusmetrum.altoslib_6.*; public class AltosDroidPreferences extends AltosPreferences { /* Active device preference name */ - final static String activeDevicePreference = "ACTIVE-DEVICE"; + final static String activeDeviceAddressPreference = "ACTIVE-DEVICE-ADDRESS"; + final static String activeDeviceNamePreference = "ACTIVE-DEVICE-NAME"; - static String active_device_address; + static DeviceAddress active_device_address; public static void init(Context context) { if (backend != null) @@ -32,18 +33,23 @@ public class AltosDroidPreferences extends AltosPreferences { AltosPreferences.init(new AltosDroidPreferencesBackend(context)); - active_device_address = backend.getString(activeDevicePreference, null); + String address = backend.getString(activeDeviceAddressPreference, null); + String name = backend.getString(activeDeviceNamePreference, null); + + if (address != null && name != null) + active_device_address = new DeviceAddress (address, name); } - public static void set_active_device(String address) { + public static void set_active_device(DeviceAddress address) { synchronized(backend) { active_device_address = address; - backend.putString(activeDevicePreference, active_device_address); + backend.putString(activeDeviceAddressPreference, active_device_address.address); + backend.putString(activeDeviceNamePreference, active_device_address.name); flush_preferences(); } } - public static String active_device() { + public static DeviceAddress active_device() { synchronized(backend) { return active_device_address; } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index cbb20045..f61e7ef2 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -71,13 +71,9 @@ public abstract class AltosDroidTab extends Fragment implements AltosUnitsListen last_state = state; last_from_receiver = from_receiver; last_receiver = receiver; - if (is_current) { - if (AltosDroid.D) Log.d(AltosDroid.TAG, String.format("%s: visible, performing update", tab_name())); - + if (is_current) show(state, from_receiver, receiver); - } else { - if (AltosDroid.D) Log.d(AltosDroid.TAG, String.format("%s: not visible, skipping update", tab_name())); + else return; - } } } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java index 71692122..fd6abe0f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java @@ -50,7 +50,8 @@ public class DeviceListActivity extends Activity { private static final boolean D = true; // Return Intent extra - public static String EXTRA_DEVICE_ADDRESS = "device_address"; + public static final String EXTRA_DEVICE_ADDRESS = "device_address"; + public static final String EXTRA_DEVICE_NAME = "device_name"; // Member fields private BluetoothAdapter mBtAdapter; @@ -164,9 +165,20 @@ public class DeviceListActivity extends Activity { String info = ((TextView) v).getText().toString(); String address = info.substring(info.length() - 17); + int newline = info.indexOf('\n'); + + String name = null; + if (newline > 0) + name = info.substring(0, newline); + else + name = info; + + if (D) Log.d(TAG, String.format("******* selected item '%s'", info)); + // Create the result Intent and include the MAC address Intent intent = new Intent(); intent.putExtra(EXTRA_DEVICE_ADDRESS, address); + intent.putExtra(EXTRA_DEVICE_NAME, name); // Set result and finish this Activity setResult(Activity.RESULT_OK, intent); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index d4ac66aa..5e34d610 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -69,24 +69,21 @@ public class TelemetryService extends Service implements LocationListener { private int NOTIFICATION = R.string.telemetry_service_label; //private NotificationManager mNM; - // Timer - we wake up every now and then to decide if the service should stop - private Timer timer = new Timer(); - - ArrayList mClients = new ArrayList(); // Keeps track of all current registered clients. - final Handler mHandler = new IncomingHandler(this); - final Messenger mMessenger = new Messenger(mHandler); // Target we publish for clients to send messages to IncomingHandler. + ArrayList clients = new ArrayList(); // Keeps track of all current registered clients. + final Handler handler = new IncomingHandler(this); + final Messenger messenger = new Messenger(handler); // Target we publish for clients to send messages to IncomingHandler. // Name of the connected device - String address; - private AltosBluetooth mAltosBluetooth = null; - private TelemetryReader mTelemetryReader = null; - private TelemetryLogger mTelemetryLogger = null; - // Local Bluetooth adapter - private BluetoothAdapter mBluetoothAdapter = null; + DeviceAddress address; + private AltosBluetooth altos_bluetooth = null; + private TelemetryReader telemetry_reader = null; + private TelemetryLogger telemetry_logger = null; - private TelemetryState telemetry_state; + // Local Bluetooth adapter + private BluetoothAdapter bluetooth_adapter = null; // Last data seen; send to UI when it starts + private TelemetryState telemetry_state; // Handler of incoming messages from clients. static class IncomingHandler extends Handler { @@ -99,27 +96,46 @@ public class TelemetryService extends Service implements LocationListener { if (s == null) return; switch (msg.what) { + + /* Messages from application */ case MSG_REGISTER_CLIENT: - s.mClients.add(msg.replyTo); - try { - // Now we try to send the freshly connected UI any relavant information about what - // we're talking to - msg.replyTo.send(s.message()); - } catch (RemoteException e) { - s.mClients.remove(msg.replyTo); - } - if (D) Log.d(TAG, "Client bound to service"); + s.add_client(msg.replyTo); break; case MSG_UNREGISTER_CLIENT: - s.mClients.remove(msg.replyTo); - if (D) Log.d(TAG, "Client unbound from service"); + s.remove_client(msg.replyTo); break; case MSG_CONNECT: if (D) Log.d(TAG, "Connect command received"); - String address = (String) msg.obj; + DeviceAddress address = (DeviceAddress) msg.obj; AltosDroidPreferences.set_active_device(address); - s.startAltosBluetooth(address); + s.start_altos_bluetooth(address); + break; + case MSG_SETFREQUENCY: + if (D) Log.d(TAG, "MSG_SETFREQUENCY"); + s.telemetry_state.frequency = (Double) msg.obj; + if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { + try { + s.altos_bluetooth.set_radio_frequency(s.telemetry_state.frequency); + s.altos_bluetooth.save_frequency(); + } catch (InterruptedException e) { + } catch (TimeoutException e) { + } + } + s.send_to_clients(); + break; + case MSG_SETBAUD: + if (D) Log.d(TAG, "MSG_SETBAUD"); + s.telemetry_state.telemetry_rate = (Integer) msg.obj; + if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { + s.altos_bluetooth.set_telemetry_rate(s.telemetry_state.telemetry_rate); + s.altos_bluetooth.save_telemetry_rate(); + } + s.send_to_clients(); break; + + /* + *Messages from AltosBluetooth + */ case MSG_CONNECTED: if (D) Log.d(TAG, "Connected to device"); try { @@ -128,51 +144,40 @@ public class TelemetryService extends Service implements LocationListener { } break; case MSG_CONNECT_FAILED: - if (D) Log.d(TAG, "Connection failed... retrying"); - if (s.address != null) - s.startAltosBluetooth(s.address); + if (s.address != null && !s.clients.isEmpty()) { + if (D) Log.d(TAG, "Connection failed... retrying"); + s.start_altos_bluetooth(s.address); + } else { + s.stop_altos_bluetooth(true); + } break; case MSG_DISCONNECTED: Log.d(TAG, "MSG_DISCONNECTED"); - s.stopAltosBluetooth(); + if (s.address != null && !s.clients.isEmpty()) { + if (D) Log.d(TAG, "Connection lost... retrying"); + s.start_altos_bluetooth(s.address); + } else { + s.stop_altos_bluetooth(true); + } break; + + /* + * Messages from TelemetryReader + */ case MSG_TELEMETRY: - // forward telemetry messages s.telemetry_state.state = (AltosState) msg.obj; if (s.telemetry_state.state != null) { if (D) Log.d(TAG, "Save state"); AltosPreferences.set_state(0, s.telemetry_state.state, null); } if (D) Log.d(TAG, "MSG_TELEMETRY"); - s.sendMessageToClients(); + s.send_to_clients(); break; case MSG_CRC_ERROR: // forward crc error messages s.telemetry_state.crc_errors = (Integer) msg.obj; if (D) Log.d(TAG, "MSG_CRC_ERROR"); - s.sendMessageToClients(); - break; - case MSG_SETFREQUENCY: - if (D) Log.d(TAG, "MSG_SETFREQUENCY"); - s.telemetry_state.frequency = (Double) msg.obj; - if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { - try { - s.mAltosBluetooth.set_radio_frequency(s.telemetry_state.frequency); - s.mAltosBluetooth.save_frequency(); - } catch (InterruptedException e) { - } catch (TimeoutException e) { - } - } - s.sendMessageToClients(); - break; - case MSG_SETBAUD: - if (D) Log.d(TAG, "MSG_SETBAUD"); - s.telemetry_state.telemetry_rate = (Integer) msg.obj; - if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { - s.mAltosBluetooth.set_telemetry_rate(s.telemetry_state.telemetry_rate); - s.mAltosBluetooth.save_telemetry_rate(); - } - s.sendMessageToClients(); + s.send_to_clients(); break; default: super.handleMessage(msg); @@ -180,6 +185,8 @@ public class TelemetryService extends Service implements LocationListener { } } + /* Construct the message to deliver to clients + */ private Message message() { if (telemetry_state == null) Log.d(TAG, "telemetry_state null!"); @@ -188,117 +195,149 @@ public class TelemetryService extends Service implements LocationListener { return Message.obtain(null, AltosDroid.MSG_STATE, telemetry_state); } - private void sendMessageToClients() { - Message m = message(); - if (D) Log.d(TAG, String.format("Send message to %d clients", mClients.size())); - for (int i=mClients.size()-1; i>=0; i--) { - try { - if (D) Log.d(TAG, String.format("Send message to client %d", i)); - mClients.get(i).send(m); - } catch (RemoteException e) { - mClients.remove(i); - } + /* A new friend has connected + */ + private void add_client(Messenger client) { + + clients.add(client); + if (D) Log.d(TAG, "Client bound to service"); + + /* On connect, send the current state to the new client + */ + send_to_client(client, message()); + + /* If we've got an address from a previous session, then + * go ahead and try to reconnect to the device + */ + if (address != null && telemetry_state.connect == TelemetryState.CONNECT_DISCONNECTED) { + if (D) Log.d(TAG, "Reconnecting now..."); + start_altos_bluetooth(address); } } - private void stopAltosBluetooth() { - if (D) Log.d(TAG, "stopAltosBluetooth(): begin"); - telemetry_state.connect = TelemetryState.CONNECT_READY; - if (mTelemetryReader != null) { - if (D) Log.d(TAG, "stopAltosBluetooth(): stopping TelemetryReader"); - mTelemetryReader.interrupt(); + /* A client has disconnected, clean up + */ + private void remove_client(Messenger client) { + clients.remove(client); + if (D) Log.d(TAG, "Client unbound from service"); + + /* When the list of clients is empty, stop the service if + * we have no current telemetry source + */ + + if (clients.isEmpty() && telemetry_state.connect == TelemetryState.CONNECT_DISCONNECTED) { + if (!D) Log.d(TAG, "No clients, no connection. Stopping\n"); + stopSelf(); + } + } + + private void send_to_client(Messenger client, Message m) { + try { + if (D) Log.d(TAG, String.format("Send message to client %s", client.toString())); + client.send(m); + } catch (RemoteException e) { + if (D) Log.e(TAG, String.format("Client %s disappeared", client.toString())); + remove_client(client); + } + } + + private void send_to_clients() { + Message m = message(); + if (D) Log.d(TAG, String.format("Send message to %d clients", clients.size())); + for (Messenger client : clients) + send_to_client(client, m); + } + + private void stop_altos_bluetooth(boolean notify) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): begin"); + telemetry_state.connect = TelemetryState.CONNECT_DISCONNECTED; + telemetry_state.address = null; + + if (altos_bluetooth != null) + altos_bluetooth.closing(); + + if (telemetry_reader != null) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping TelemetryReader"); + telemetry_reader.interrupt(); try { - mTelemetryReader.join(); + telemetry_reader.join(); } catch (InterruptedException e) { } - mTelemetryReader = null; + telemetry_reader = null; } - if (mTelemetryLogger != null) { - if (D) Log.d(TAG, "stopAltosBluetooth(): stopping TelemetryLogger"); - mTelemetryLogger.stop(); - mTelemetryLogger = null; + if (telemetry_logger != null) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping TelemetryLogger"); + telemetry_logger.stop(); + telemetry_logger = null; } - if (mAltosBluetooth != null) { - if (D) Log.d(TAG, "stopAltosBluetooth(): stopping AltosBluetooth"); - mAltosBluetooth.close(); - mAltosBluetooth = null; + if (altos_bluetooth != null) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping AltosBluetooth"); + altos_bluetooth.close(); + altos_bluetooth = null; } telemetry_state.config = null; - if (D) Log.d(TAG, "stopAltosBluetooth(): send message to clients"); - sendMessageToClients(); + if (notify) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): send message to clients"); + send_to_clients(); + if (clients.isEmpty()) { + if (D) Log.d(TAG, "stop_altos_bluetooth(): no clients, terminating"); + stopSelf(); + } + } } - private void startAltosBluetooth(String address) { + private void start_altos_bluetooth(DeviceAddress address) { // Get the BLuetoothDevice object - BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); + BluetoothDevice device = bluetooth_adapter.getRemoteDevice(address.address); + stop_altos_bluetooth(false); this.address = address; - if (mAltosBluetooth == null) { - if (D) Log.d(TAG, String.format("startAltosBluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); - mAltosBluetooth = new AltosBluetooth(device, mHandler); - telemetry_state.connect = TelemetryState.CONNECT_CONNECTING; - sendMessageToClients(); - } else { - // This is a bit of a hack - if it appears we're still connected, we treat this as a restart. - // So, to give a suitable delay to teardown/bringup, we just schedule a resend of a message - // to ourselves in a few seconds time that will ultimately call this method again. - // ... then we tear down the existing connection. - // We do it this way around so that we don't lose a reference to the device when this method - // is called on reception of MSG_CONNECT_FAILED in the handler above. - mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, address), 3000); - stopAltosBluetooth(); - } + if (D) Log.d(TAG, String.format("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); + altos_bluetooth = new AltosBluetooth(device, handler); + telemetry_state.connect = TelemetryState.CONNECT_CONNECTING; + telemetry_state.address = address; + send_to_clients(); } private void connected() throws InterruptedException { if (D) Log.d(TAG, "connected top"); try { - if (mAltosBluetooth == null) + if (altos_bluetooth == null) throw new InterruptedException("no bluetooth"); - telemetry_state.config = mAltosBluetooth.config_data(); - mAltosBluetooth.set_radio_frequency(telemetry_state.frequency); - mAltosBluetooth.set_telemetry_rate(telemetry_state.telemetry_rate); + telemetry_state.config = altos_bluetooth.config_data(); + altos_bluetooth.set_radio_frequency(telemetry_state.frequency); + altos_bluetooth.set_telemetry_rate(telemetry_state.telemetry_rate); } catch (TimeoutException e) { // If this timed out, then we really want to retry it, but // probably safer to just retry the connection from scratch. - mHandler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); + handler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); return; } if (D) Log.d(TAG, "connected bluetooth configured"); telemetry_state.connect = TelemetryState.CONNECT_CONNECTED; + telemetry_state.address = address; - mTelemetryReader = new TelemetryReader(mAltosBluetooth, mHandler, telemetry_state.state); - mTelemetryReader.start(); + telemetry_reader = new TelemetryReader(altos_bluetooth, handler, telemetry_state.state); + telemetry_reader.start(); if (D) Log.d(TAG, "connected TelemetryReader started"); - mTelemetryLogger = new TelemetryLogger(this, mAltosBluetooth); + telemetry_logger = new TelemetryLogger(this, altos_bluetooth); if (D) Log.d(TAG, "Notify UI of connection"); - sendMessageToClients(); - } - - private void onTimerTick() { - if (D) Log.d(TAG, "Timer wakeup"); - try { - if (mClients.size() <= 0 && telemetry_state.connect != TelemetryState.CONNECT_CONNECTED) { - stopSelf(); - } - } catch (Throwable t) { - Log.e(TAG, "Timer failed: ", t); - } + send_to_clients(); } @Override public void onCreate() { // Get local Bluetooth adapter - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + bluetooth_adapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported - if (mBluetoothAdapter == null) { + if (bluetooth_adapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); } @@ -310,7 +349,8 @@ public class TelemetryService extends Service implements LocationListener { // Create a reference to the NotificationManager so that we can update our notifcation text later //mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); - telemetry_state.connect = TelemetryState.CONNECT_READY; + telemetry_state.connect = TelemetryState.CONNECT_DISCONNECTED; + telemetry_state.address = null; AltosSavedState saved_state = AltosPreferences.state(0); @@ -319,17 +359,14 @@ public class TelemetryService extends Service implements LocationListener { telemetry_state.state = saved_state.state; } - // Start our timer - first event in 10 seconds, then every 10 seconds after that. - timer.scheduleAtFixedRate(new TimerTask(){ public void run() {onTimerTick();}}, 10000L, 10000L); - // Listen for GPS and Network position updates LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this); - String address = AltosDroidPreferences.active_device(); + DeviceAddress address = AltosDroidPreferences.active_device(); if (address != null) - startAltosBluetooth(address); + start_altos_bluetooth(address); } @Override @@ -366,28 +403,25 @@ public class TelemetryService extends Service implements LocationListener { ((LocationManager) getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this); // Stop the bluetooth Comms threads - stopAltosBluetooth(); + stop_altos_bluetooth(true); // Demote us from the foreground, and cancel the persistent notification. stopForeground(true); - // Stop our timer - if (timer != null) {timer.cancel();} - // Tell the user we stopped. Toast.makeText(this, R.string.telemetry_service_stopped, Toast.LENGTH_SHORT).show(); } @Override public IBinder onBind(Intent intent) { - return mMessenger.getBinder(); + return messenger.getBinder(); } public void onLocationChanged(Location location) { telemetry_state.location = location; if (D) Log.d(TAG, "location changed"); - sendMessageToClients(); + send_to_clients(); } public void onStatusChanged(String provider, int status, Bundle extras) { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java index 862847d2..ca066fc2 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java @@ -21,12 +21,13 @@ import org.altusmetrum.altoslib_6.*; import android.location.Location; public class TelemetryState { - public static final int CONNECT_NONE = 0; - public static final int CONNECT_READY = 1; - public static final int CONNECT_CONNECTING = 2; - public static final int CONNECT_CONNECTED = 3; + public static final int CONNECT_NONE = 0; + public static final int CONNECT_DISCONNECTED = 1; + public static final int CONNECT_CONNECTING = 2; + public static final int CONNECT_CONNECTED = 3; int connect; + DeviceAddress address; AltosConfigData config; AltosState state; Location location; -- cgit v1.2.3 From 877609a60a9f2c61c1efad8285b2a3c22f59be28 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 21:19:09 -0800 Subject: altosdroid: Explicitly disconnect BT on termination or 'disconnect' This adds an explicit message to the telemetry service telling it when to stop trying to talk to the bluetooth device. Until this message is received, the service will reconnect to the specified BT device. That message is sent when you 'quit' the application, or when you 'disconnect'. Signed-off-by: Keith Packard --- altosdroid/res/menu/option_menu.xml | 3 +++ altosdroid/res/values/strings.xml | 1 + altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 14 +++++++++++++- .../src/org/altusmetrum/AltosDroid/TelemetryService.java | 10 ++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/altosdroid/res/menu/option_menu.xml b/altosdroid/res/menu/option_menu.xml index 3bd5a54e..f005e881 100644 --- a/altosdroid/res/menu/option_menu.xml +++ b/altosdroid/res/menu/option_menu.xml @@ -17,6 +17,9 @@ + diff --git a/altosdroid/res/values/strings.xml b/altosdroid/res/values/strings.xml index 0cc99349..8a5b29b4 100644 --- a/altosdroid/res/values/strings.xml +++ b/altosdroid/res/values/strings.xml @@ -27,6 +27,7 @@ Connect a device + Disconnect device Quit Select radio frequency Select data rate diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 10e735c8..273688d8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -553,6 +553,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } } + private void disconnectDevice() { + try { + mService.send(Message.obtain(null, TelemetryService.MSG_DISCONNECT, null)); + } catch (RemoteException e) { + } + } + @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); @@ -610,9 +617,14 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { serverIntent = new Intent(this, DeviceListActivity.class); startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE); return true; + case R.id.disconnect: + /* Disconnect the bluetooth device + */ + disconnectDevice(); + return true; case R.id.quit: Log.d(TAG, "R.id.quit"); - stopService(new Intent(AltosDroid.this, TelemetryService.class)); + disconnectDevice(); finish(); return true; case R.id.select_freq: diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 5e34d610..5f138972 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -63,6 +63,7 @@ public class TelemetryService extends Service implements LocationListener { static final int MSG_SETFREQUENCY = 8; static final int MSG_CRC_ERROR = 9; static final int MSG_SETBAUD = 10; + static final int MSG_DISCONNECT = 11; // Unique Identification Number for the Notification. // We use it on Notification start, and to cancel it. @@ -110,6 +111,11 @@ public class TelemetryService extends Service implements LocationListener { AltosDroidPreferences.set_active_device(address); s.start_altos_bluetooth(address); break; + case MSG_DISCONNECT: + if (D) Log.d(TAG, "Disconnect command received"); + s.address = null; + s.stop_altos_bluetooth(true); + break; case MSG_SETFREQUENCY: if (D) Log.d(TAG, "MSG_SETFREQUENCY"); s.telemetry_state.frequency = (Double) msg.obj; @@ -144,7 +150,7 @@ public class TelemetryService extends Service implements LocationListener { } break; case MSG_CONNECT_FAILED: - if (s.address != null && !s.clients.isEmpty()) { + if (s.address != null) { if (D) Log.d(TAG, "Connection failed... retrying"); s.start_altos_bluetooth(s.address); } else { @@ -153,7 +159,7 @@ public class TelemetryService extends Service implements LocationListener { break; case MSG_DISCONNECTED: Log.d(TAG, "MSG_DISCONNECTED"); - if (s.address != null && !s.clients.isEmpty()) { + if (s.address != null) { if (D) Log.d(TAG, "Connection lost... retrying"); s.start_altos_bluetooth(s.address); } else { -- cgit v1.2.3 From 8f2d82461f3cf5da157b23ea45a2fa60d56b196b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 21:32:54 -0800 Subject: altosdroid: Only speak when GUI is running Create voice in onStart, stop it in onStop. This way, if some other application is in use, the voice won't be annoying you. Signed-off-by: Keith Packard --- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 273688d8..41045f03 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -352,7 +352,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { for (AltosDroidTab mTab : mTabs) mTab.update_ui(state, from_receiver, location, mTab == mTabsAdapter.currentItem()); - if (state != null) + if (state != null && mAltosVoice != null) mAltosVoice.tell(state, from_receiver); saved_state = state; @@ -465,8 +465,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { mStateLayout = (RelativeLayout) findViewById(R.id.state_container); mStateView = (TextView) findViewById(R.id.state_value); mAgeView = (TextView) findViewById(R.id.age_value); - - mAltosVoice = new AltosVoice(this); } @Override @@ -484,6 +482,8 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { doBindService(); + if (mAltosVoice == null) + mAltosVoice = new AltosVoice(this); } @Override @@ -504,6 +504,10 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { if(D) Log.e(TAG, "-- ON STOP --"); doUnbindService(); + if (mAltosVoice != null) { + mAltosVoice.stop(); + mAltosVoice = null; + } } @Override -- cgit v1.2.3 From e6630ac41ca0d8563cf9a0df5d4acba8192e9624 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 21:35:34 -0800 Subject: altosdroid: Missing file: DeviceAddress.java Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/DeviceAddress.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/DeviceAddress.java diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceAddress.java b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceAddress.java new file mode 100644 index 00000000..673d72dd --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceAddress.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.AltosDroid; + +public class DeviceAddress { + public String address; + public String name; + + public DeviceAddress(String address, String name) { + this.address = address; + this.name = name; + } +} -- cgit v1.2.3 From 106b16b4d5d024543d7ad8c4b4762151e253f3c4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Feb 2015 22:22:37 -0800 Subject: altosdroid: Ignore automatic tab changing while activity is saved When the activity state is saved (after onSaveInstanceState()), we can't update the UI until the activity is restarted or restored; that means any UI changes we make, like switching tabs, must deal with this by allowing those changes to be ignored, using commitAllowingStateLoss instead of commit. Signed-off-by: Keith Packard --- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index f61e7ef2..0896b3a3 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -64,7 +64,7 @@ public abstract class AltosDroidTab extends Fragment implements AltosUnitsListen ft.show(this); } else ft.hide(this); - ft.commit(); + ft.commitAllowingStateLoss(); } public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver, boolean is_current) { -- cgit v1.2.3 From 91b1a80650a7dcd7c5bf819618a8cea0fceb37d9 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Sun, 8 Feb 2015 09:29:01 -0700 Subject: swap names so v3.0 is the default TeleDongle version to turn on --- ao-bringup/turnon_teledongle | 99 +++++++++++++++++++++++++-------------- ao-bringup/turnon_teledongle_v0.2 | 58 +++++++++++++++++++++++ ao-bringup/turnon_teledonglev3 | 89 ----------------------------------- 3 files changed, 123 insertions(+), 123 deletions(-) create mode 100755 ao-bringup/turnon_teledongle_v0.2 delete mode 100755 ao-bringup/turnon_teledonglev3 diff --git a/ao-bringup/turnon_teledongle b/ao-bringup/turnon_teledongle index 058e72ce..e6750c45 100755 --- a/ao-bringup/turnon_teledongle +++ b/ao-bringup/turnon_teledongle @@ -1,58 +1,89 @@ #!/bin/sh -if [ -x ../ao-tools/ao-load/ao-load ]; then - AOLOAD=../ao-tools/ao-load/ao-load -elif [ -x /usr/bin/ao-load ]; then - AOLOAD=/usr/bin/ao-load +if [ -x ../ao-tools/ao-flash/ao-flash-lpc ]; then + FLASH_LPC=../ao-tools/ao-flash/ao-flash-lpc +elif [ -x /usr/bin/ao-flash-lpc ]; then + FLASH_LPC=/usr/bin/ao-flash-lpc else - echo "Can't find ao-load! Aborting." + echo "Can't find ao-flash-lpc! Aborting." exit 1 fi -if [ -x ../ao-tools/ao-rawload/ao-rawload ]; then - RAWLOAD=../ao-tools/ao-rawload/ao-rawload -elif [ -x /usr/bin/ao-rawload ]; then - RAWLOAD=/usr/bin/ao-rawload +if [ -x /usr/bin/ao-usbload ]; then + USBLOAD=/usr/bin/ao-usbload else - echo "Can't find ao-rawload! Aborting." + echo "Can't find ao-usbload! Aborting." exit 1 fi -echo "TeleDongle v0.2 Turn-On and Calibration Program" -echo "Copyright 2010 by Bdale Garbee. Released under GPL v2" +PRODUCT=teledongle +PRODUCT_NAME=TeleDongle +VERSION=3.0 + +echo "$PRODUCT_NAME v$VERSION Turn-On and Calibration Program" +echo "Copyright © 2015 by Bdale Garbee. Released under GPL v2" echo echo "Expectations:" -echo "\tTeleDongle v0.2 powered from USB" -echo "\t\twith TIdongle (on /dev/ttyACM0) cabled to debug header" -echo "\t\twith coax from SMA to frequency counter" +echo "\t$PRODUCT_NAME v$VERSION powered from USB" +echo "\t\twith ST-Link-V2 cabled to debug header" +echo "\t\twith coax from UHF to frequency counter" echo -echo -n "TeleDongle serial number: " +echo -n "$PRODUCT_NAME-$VERSION serial number: " read SERIAL -echo $RAWLOAD +BINARIES=$HOME/altusmetrumllc/Binaries + +LOADER="$BINARIES/loaders/$PRODUCT-v$VERSION-"*.elf +ALTOS="$BINARIES/$PRODUCT-v$VERSION"*.elf + +$FLASH_LPC $LOADER || exit 1 -case $USER in - bdale) - programmer=100 +sleep 2 + +$USBLOAD --serial=$SERIAL $ALTOS || exit 1 + +sleep 5 + +dev=`ao-list | awk '/TeleDongle-v'"$VERSION"'/ { print $3; exit(0); }'` + +case "$dev" in +/dev/tty*) + echo "TeleDongle found on $dev" ;; - keithp) - programmer=186 +*) + echo 'No TeleDongle-v'"$VERSION"' found' + exit 1 ;; esac -$RAWLOAD -D $programmer -r ao_led_blink.ihx -echo "LEDs should be blinking" -sleep 5 +echo 'E 0' > $dev + +./cal-freq-file $dev $SERIAL + +case $? in + 0) + ;; + *) + echo "Frequency calibration failed" + exit 1 + ;; +esac + +CAL_VALUE=`grep "^$SERIAL," cal_values | tail -1 | sed 's/^[^,]*,//'` + +case "$CAL_VALUE" in + [1-9]*) + ;; + *) + echo "Invalid calibration value: $CAL_VALUE" + exit 1 + ;; +esac -$RAWLOAD -D $programmer -r ao_radio_xmit.ihx -echo -n "Generating RF carrier. Please enter measured frequency: " -read FREQ +echo "Reflashing with calibration: $CAL_VALUE" -CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` +$USBLOAD --cal=$CAL_VALUE --tty=$dev $ALTOS || exit 1 -echo "Programming flash with cal value " $CAL_VALUE -$AOLOAD -D $programmer --cal $CAL_VALUE /usr/share/altos/teledongle-v0.2*.ihx $SERIAL +echo "$PRODUCT_NAME-v$VERSION $SERIAL is ready to ship" -echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE -echo $SERIAL","$CAL_VALUE >> cal_values -echo "Unplug and replug USB, cu to the board, confirm freq and record power" +exit $? diff --git a/ao-bringup/turnon_teledongle_v0.2 b/ao-bringup/turnon_teledongle_v0.2 new file mode 100755 index 00000000..058e72ce --- /dev/null +++ b/ao-bringup/turnon_teledongle_v0.2 @@ -0,0 +1,58 @@ +#!/bin/sh + +if [ -x ../ao-tools/ao-load/ao-load ]; then + AOLOAD=../ao-tools/ao-load/ao-load +elif [ -x /usr/bin/ao-load ]; then + AOLOAD=/usr/bin/ao-load +else + echo "Can't find ao-load! Aborting." + exit 1 +fi + +if [ -x ../ao-tools/ao-rawload/ao-rawload ]; then + RAWLOAD=../ao-tools/ao-rawload/ao-rawload +elif [ -x /usr/bin/ao-rawload ]; then + RAWLOAD=/usr/bin/ao-rawload +else + echo "Can't find ao-rawload! Aborting." + exit 1 +fi + +echo "TeleDongle v0.2 Turn-On and Calibration Program" +echo "Copyright 2010 by Bdale Garbee. Released under GPL v2" +echo +echo "Expectations:" +echo "\tTeleDongle v0.2 powered from USB" +echo "\t\twith TIdongle (on /dev/ttyACM0) cabled to debug header" +echo "\t\twith coax from SMA to frequency counter" +echo +echo -n "TeleDongle serial number: " +read SERIAL + +echo $RAWLOAD + +case $USER in + bdale) + programmer=100 + ;; + keithp) + programmer=186 + ;; +esac + +$RAWLOAD -D $programmer -r ao_led_blink.ihx +echo "LEDs should be blinking" +sleep 5 + +$RAWLOAD -D $programmer -r ao_radio_xmit.ihx +echo -n "Generating RF carrier. Please enter measured frequency: " +read FREQ + +CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` + +echo "Programming flash with cal value " $CAL_VALUE +$AOLOAD -D $programmer --cal $CAL_VALUE /usr/share/altos/teledongle-v0.2*.ihx $SERIAL + +echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE +echo $SERIAL","$CAL_VALUE >> cal_values +echo "Unplug and replug USB, cu to the board, confirm freq and record power" diff --git a/ao-bringup/turnon_teledonglev3 b/ao-bringup/turnon_teledonglev3 deleted file mode 100755 index e6750c45..00000000 --- a/ao-bringup/turnon_teledonglev3 +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh - -if [ -x ../ao-tools/ao-flash/ao-flash-lpc ]; then - FLASH_LPC=../ao-tools/ao-flash/ao-flash-lpc -elif [ -x /usr/bin/ao-flash-lpc ]; then - FLASH_LPC=/usr/bin/ao-flash-lpc -else - echo "Can't find ao-flash-lpc! Aborting." - exit 1 -fi - -if [ -x /usr/bin/ao-usbload ]; then - USBLOAD=/usr/bin/ao-usbload -else - echo "Can't find ao-usbload! Aborting." - exit 1 -fi - -PRODUCT=teledongle -PRODUCT_NAME=TeleDongle -VERSION=3.0 - -echo "$PRODUCT_NAME v$VERSION Turn-On and Calibration Program" -echo "Copyright © 2015 by Bdale Garbee. Released under GPL v2" -echo -echo "Expectations:" -echo "\t$PRODUCT_NAME v$VERSION powered from USB" -echo "\t\twith ST-Link-V2 cabled to debug header" -echo "\t\twith coax from UHF to frequency counter" -echo -echo -n "$PRODUCT_NAME-$VERSION serial number: " -read SERIAL - -BINARIES=$HOME/altusmetrumllc/Binaries - -LOADER="$BINARIES/loaders/$PRODUCT-v$VERSION-"*.elf -ALTOS="$BINARIES/$PRODUCT-v$VERSION"*.elf - -$FLASH_LPC $LOADER || exit 1 - -sleep 2 - -$USBLOAD --serial=$SERIAL $ALTOS || exit 1 - -sleep 5 - -dev=`ao-list | awk '/TeleDongle-v'"$VERSION"'/ { print $3; exit(0); }'` - -case "$dev" in -/dev/tty*) - echo "TeleDongle found on $dev" - ;; -*) - echo 'No TeleDongle-v'"$VERSION"' found' - exit 1 - ;; -esac - -echo 'E 0' > $dev - -./cal-freq-file $dev $SERIAL - -case $? in - 0) - ;; - *) - echo "Frequency calibration failed" - exit 1 - ;; -esac - -CAL_VALUE=`grep "^$SERIAL," cal_values | tail -1 | sed 's/^[^,]*,//'` - -case "$CAL_VALUE" in - [1-9]*) - ;; - *) - echo "Invalid calibration value: $CAL_VALUE" - exit 1 - ;; -esac - -echo "Reflashing with calibration: $CAL_VALUE" - -$USBLOAD --cal=$CAL_VALUE --tty=$dev $ALTOS || exit 1 - -echo "$PRODUCT_NAME-v$VERSION $SERIAL is ready to ship" - -exit $? -- cgit v1.2.3 From ec2d758844202108b446e6b12ec1da8812ceb265 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 15:07:16 -0800 Subject: altos: Allow software to offer other USB interface classes than CDC This lets some boards offer non-CDC class USB interfaces so that the modem driver doesn't pick them up. Signed-off-by: Keith Packard --- src/kernel/ao_product.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kernel/ao_product.c b/src/kernel/ao_product.c index b9327bac..baee8dd6 100644 --- a/src/kernel/ao_product.c +++ b/src/kernel/ao_product.c @@ -33,6 +33,10 @@ const char ao_product[] = AO_iProduct_STRING; #define AO_USB_MAX_POWER 100 #endif +#ifndef AO_USB_INTERFACE_CLASS +#define AO_USB_INTERFACE_CLASS 0x02 +#endif + #include "ao_usb.h" /* USB descriptors in one giant block of bytes */ AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] = @@ -69,7 +73,7 @@ AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] = 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndPoints */ - 0x02, /* bInterfaceClass */ + AO_USB_INTERFACE_CLASS, /* bInterfaceClass */ 0x02, /* bInterfaceSubClass */ 0x01, /* bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */ 0x00, /* iInterface */ -- cgit v1.2.3 From 27aef593fb4c037fdb65c9fb397829b42d72d0f2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 15:59:30 -0800 Subject: altos/stmf0: Fix fast ADC interface This was configuring the hardware wrong, and wasn't keeping the output ring full. Signed-off-by: Keith Packard --- src/stmf0/ao_adc_fast.c | 31 ++++++++++++++++++++----------- src/stmf0/ao_adc_fast.h | 10 +++------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/stmf0/ao_adc_fast.c b/src/stmf0/ao_adc_fast.c index be9b5986..7d2a4fd7 100644 --- a/src/stmf0/ao_adc_fast.c +++ b/src/stmf0/ao_adc_fast.c @@ -18,43 +18,52 @@ #include #include -uint16_t ao_adc_ring[AO_ADC_RING_SIZE]; +uint16_t ao_adc_ring[AO_ADC_RING_SIZE] __attribute__((aligned(4))); + +/* Maximum number of samples fetched per _ao_adc_start call */ +#define AO_ADC_RING_CHUNK (AO_ADC_RING_SIZE >> 1) uint16_t ao_adc_ring_head, ao_adc_ring_tail; -uint8_t ao_adc_running; +uint16_t ao_adc_running; /* * Callback from DMA ISR * - * Mark time in ring, shut down DMA engine + * Wakeup any waiting processes, mark the DMA as done, start the ADC + * if there's still lots of space in the ring */ static void ao_adc_dma_done(int index) { (void) index; - ao_adc_ring_head += AO_ADC_RING_CHUNK; + ao_adc_ring_head += ao_adc_running; if (ao_adc_ring_head == AO_ADC_RING_SIZE) ao_adc_ring_head = 0; ao_adc_running = 0; ao_wakeup(&ao_adc_ring_head); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1)); + _ao_adc_start(); } void _ao_adc_start(void) { uint16_t *buf; + uint16_t count; if (ao_adc_running) return; - if (_ao_adc_space() < AO_ADC_RING_CHUNK) + count = _ao_adc_space(); + if (count == 0) return; - ao_adc_running = 1; + if (count > AO_ADC_RING_CHUNK) + count = AO_ADC_RING_CHUNK; + ao_adc_running = count; buf = ao_adc_ring + ao_adc_ring_head; stm_adc.isr = 0; ao_dma_set_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1), &stm_adc.dr, buf, - AO_ADC_RING_CHUNK, + count, (0 << STM_DMA_CCR_MEM2MEM) | (STM_DMA_CCR_PL_HIGH << STM_DMA_CCR_PL) | (STM_DMA_CCR_MSIZE_16 << STM_DMA_CCR_MSIZE) | @@ -140,7 +149,6 @@ ao_adc_init(void) #if AO_NUM_ADC > 8 #error Need more ADC defines #endif - stm_adc.chselr = chselr; /* Set the clock */ stm_adc.cfgr2 = STM_ADC_CFGR2_CKMODE_PCLK_2 << STM_ADC_CFGR2_CKMODE; @@ -160,14 +168,16 @@ ao_adc_init(void) while ((stm_adc.isr & (1 << STM_ADC_ISR_ADRDY)) == 0) ; + stm_adc.chselr = chselr; + stm_adc.cfgr1 = ((0 << STM_ADC_CFGR1_AWDCH) | (0 << STM_ADC_CFGR1_AWDEN) | (0 << STM_ADC_CFGR1_AWDSGL) | (0 << STM_ADC_CFGR1_DISCEN) | (0 << STM_ADC_CFGR1_AUTOOFF) | - (1 << STM_ADC_CFGR1_WAIT) | + (0 << STM_ADC_CFGR1_WAIT) | (1 << STM_ADC_CFGR1_CONT) | - (0 << STM_ADC_CFGR1_OVRMOD) | + (1 << STM_ADC_CFGR1_OVRMOD) | (STM_ADC_CFGR1_EXTEN_DISABLE << STM_ADC_CFGR1_EXTEN) | (0 << STM_ADC_CFGR1_ALIGN) | (STM_ADC_CFGR1_RES_12 << STM_ADC_CFGR1_RES) | @@ -186,5 +196,4 @@ ao_adc_init(void) stm_syscfg.cfgr1 &= ~(1 << STM_SYSCFG_CFGR1_ADC_DMA_RMP); ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1)); - ao_dma_set_isr(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1), ao_adc_dma_done); } diff --git a/src/stmf0/ao_adc_fast.h b/src/stmf0/ao_adc_fast.h index eec45505..ca5f7fb9 100644 --- a/src/stmf0/ao_adc_fast.h +++ b/src/stmf0/ao_adc_fast.h @@ -26,15 +26,13 @@ ao_adc_init(void); /* Total ring size in samples */ #define AO_ADC_RING_SIZE 256 -/* Number of samples fetched per ao_adc_start call */ -#define AO_ADC_RING_CHUNK (AO_ADC_RING_SIZE >> 1) extern uint16_t ao_adc_ring[AO_ADC_RING_SIZE]; #define ao_adc_ring_step(pos,inc) (((pos) + (inc)) & (AO_ADC_RING_SIZE - 1)) extern uint16_t ao_adc_ring_head, ao_adc_ring_tail; -extern uint8_t ao_adc_running; +extern uint16_t ao_adc_running; void _ao_adc_start(void); @@ -50,9 +48,7 @@ _ao_adc_remain(void) static inline uint16_t _ao_adc_space(void) { - if (ao_adc_ring_head == ao_adc_ring_tail) - return AO_ADC_RING_SIZE; - if (ao_adc_ring_head > ao_adc_ring_tail) + if (ao_adc_ring_head >= ao_adc_ring_tail) return AO_ADC_RING_SIZE - ao_adc_ring_head; return ao_adc_ring_tail - ao_adc_ring_head; } @@ -81,7 +77,7 @@ ao_adc_ack(uint16_t n) ao_adc_ring_tail += n; if (ao_adc_ring_tail == AO_ADC_RING_SIZE) ao_adc_ring_tail = 0; - if (!ao_adc_running && _ao_adc_space() >= AO_ADC_RING_CHUNK) + if (!ao_adc_running) _ao_adc_start(); ao_arch_release_interrupts(); } -- cgit v1.2.3 From e4b415cc8f839ceae48916b5e9d78f78589186cf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 16:00:17 -0800 Subject: altos/stmf0: Typo in ao_crc_stm.c Extra semicolon Signed-off-by: Keith Packard --- src/stmf0/ao_crc_stm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stmf0/ao_crc_stm.c b/src/stmf0/ao_crc_stm.c index 78efa93a..863f5ef5 100644 --- a/src/stmf0/ao_crc_stm.c +++ b/src/stmf0/ao_crc_stm.c @@ -60,7 +60,7 @@ #endif #ifndef AO_CRC_INIT -#define AO_CRC_INIT 0xffffffff; +#define AO_CRC_INIT 0xffffffff #endif void -- cgit v1.2.3 From 476c5b87ea0901f70fe98b581ecca9afaf957607 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 16:00:45 -0800 Subject: altos/stmf0: Allocate USB buffers at startup This lets the extra allocations used from ao_usb_alloc_buffers be allocated before the first USB connection happens. Signed-off-by: Keith Packard --- src/stmf0/ao_usb_stm.c | 87 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 27 deletions(-) diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c index 3ea7da5e..b8146c21 100644 --- a/src/stmf0/ao_usb_stm.c +++ b/src/stmf0/ao_usb_stm.c @@ -83,9 +83,13 @@ static uint16_t ao_usb_sram_addr; static uint16_t *ao_usb_ep0_tx_buffer; static uint16_t *ao_usb_ep0_rx_buffer; +/* Pointer to interrupt buffer in USB memory */ +static uint16_t ao_usb_int_tx_offset; + /* Pointer to bulk data tx/rx buffers in USB memory */ static uint16_t ao_usb_in_tx_offset; static uint16_t *ao_usb_in_tx_buffer; +static uint16_t ao_usb_out_rx_offset; static uint16_t *ao_usb_out_rx_buffer; /* System ram shadow of USB buffer; writing individual bytes is @@ -146,12 +150,10 @@ static inline uint16_t *ao_usb_packet_buffer_addr(uint16_t sram_addr) return (uint16_t *) (stm_usb_sram + sram_addr); } -#if AO_USB_DIRECTIO static inline uint16_t ao_usb_packet_buffer_offset(uint16_t *addr) { return (uint16_t) ((uint8_t *) addr - stm_usb_sram); } -#endif static inline uint32_t ao_usb_epr_stat_rx(uint32_t epr) { return (epr >> STM_USB_EPR_STAT_RX) & STM_USB_EPR_STAT_RX_MASK; @@ -323,27 +325,42 @@ ao_usb_init_ep(uint8_t ep, uint32_t addr, uint32_t type, uint32_t stat_rx, uint3 } static void -ao_usb_init_btable(void) +ao_usb_alloc_buffers(void) { ao_usb_sram_addr = 0; ao_usb_bdt = (void *) stm_usb_sram; - ao_usb_sram_addr += 8 * STM_USB_BDT_SIZE; - /* Set up EP 0 - a Control end point with 32 bytes of in and out buffers */ - - ao_usb_bdt[0].single.addr_tx = ao_usb_sram_addr; - ao_usb_bdt[0].single.count_tx = 0; ao_usb_ep0_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); ao_usb_sram_addr += AO_USB_CONTROL_SIZE; - ao_usb_bdt[0].single.addr_rx = ao_usb_sram_addr; - ao_usb_bdt[0].single.count_rx = ((1 << STM_USB_BDT_COUNT_RX_BL_SIZE) | - (((AO_USB_CONTROL_SIZE / 32) - 1) << STM_USB_BDT_COUNT_RX_NUM_BLOCK)); ao_usb_ep0_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); ao_usb_sram_addr += AO_USB_CONTROL_SIZE; + ao_usb_int_tx_offset = ao_usb_sram_addr; + ao_usb_sram_addr += AO_USB_INT_SIZE; + + ao_usb_out_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); + ao_usb_out_rx_offset = ao_usb_sram_addr; + ao_usb_sram_addr += AO_USB_OUT_SIZE; + + ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); + ao_usb_in_tx_offset = ao_usb_sram_addr; + ao_usb_sram_addr += AO_USB_IN_SIZE; +} + +static void +ao_usb_init_btable(void) +{ + /* Set up EP 0 - a Control end point with 32 bytes of in and out buffers */ + + ao_usb_bdt[0].single.addr_tx = ao_usb_packet_buffer_offset(ao_usb_ep0_tx_buffer); + ao_usb_bdt[0].single.count_tx = 0; + + ao_usb_bdt[0].single.addr_rx = ao_usb_packet_buffer_offset(ao_usb_ep0_rx_buffer); + ao_usb_bdt[0].single.count_rx = ((1 << STM_USB_BDT_COUNT_RX_BL_SIZE) | + (((AO_USB_CONTROL_SIZE / 32) - 1) << STM_USB_BDT_COUNT_RX_NUM_BLOCK)); } static void @@ -370,6 +387,8 @@ ao_usb_set_ep0(void) } ao_usb_set_address(0); + + ao_usb_running = 0; } static void @@ -378,9 +397,8 @@ ao_usb_set_configuration(void) debug ("ao_usb_set_configuration\n"); /* Set up the INT end point */ - ao_usb_bdt[AO_USB_INT_EPR].single.addr_tx = ao_usb_sram_addr; + ao_usb_bdt[AO_USB_INT_EPR].single.addr_tx = ao_usb_int_tx_offset; ao_usb_bdt[AO_USB_INT_EPR].single.count_tx = 0; - ao_usb_sram_addr += AO_USB_INT_SIZE; ao_usb_init_ep(AO_USB_INT_EPR, AO_USB_INT_EP, @@ -389,11 +407,9 @@ ao_usb_set_configuration(void) STM_USB_EPR_STAT_TX_NAK); /* Set up the OUT end point */ - ao_usb_bdt[AO_USB_OUT_EPR].single.addr_rx = ao_usb_sram_addr; + ao_usb_bdt[AO_USB_OUT_EPR].single.addr_rx = ao_usb_out_rx_offset; ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx = ((1 << STM_USB_BDT_COUNT_RX_BL_SIZE) | (((AO_USB_OUT_SIZE / 32) - 1) << STM_USB_BDT_COUNT_RX_NUM_BLOCK)); - ao_usb_out_rx_buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); - ao_usb_sram_addr += AO_USB_OUT_SIZE; ao_usb_init_ep(AO_USB_OUT_EPR, AO_USB_OUT_EP, @@ -402,11 +418,8 @@ ao_usb_set_configuration(void) STM_USB_EPR_STAT_TX_DISABLED); /* Set up the IN end point */ - ao_usb_bdt[AO_USB_IN_EPR].single.addr_tx = ao_usb_sram_addr; + ao_usb_bdt[AO_USB_IN_EPR].single.addr_tx = ao_usb_in_tx_offset; ao_usb_bdt[AO_USB_IN_EPR].single.count_tx = 0; - ao_usb_in_tx_offset = ao_usb_sram_addr; - ao_usb_in_tx_buffer = ao_usb_packet_buffer_addr(ao_usb_in_tx_offset); - ao_usb_sram_addr += AO_USB_IN_SIZE; ao_usb_init_ep(AO_USB_IN_EPR, AO_USB_IN_EP, @@ -415,6 +428,9 @@ ao_usb_set_configuration(void) STM_USB_EPR_STAT_TX_NAK); ao_usb_running = 1; +#if AO_USB_DIRECTIO + ao_wakeup(&ao_usb_running); +#endif } static uint16_t control_count; @@ -916,8 +932,6 @@ ao_usb_alloc(void) { uint16_t *buffer; - if (!ao_usb_running) - return NULL; buffer = ao_usb_packet_buffer_addr(ao_usb_sram_addr); ao_usb_sram_addr += AO_USB_IN_SIZE; return buffer; @@ -936,12 +950,28 @@ ao_usb_write(uint16_t *buffer, uint16_t len) { ao_arch_block_interrupts(); - /* Flush any pending regular */ - if (ao_usb_tx_count) - _ao_usb_in_send(); + /* Wait for everything to be ready at the same time */ + for (;;) { + /* Make sure USB is connected */ + if (!ao_usb_running) { + ao_sleep(&ao_usb_running); + continue; + } + + /* Flush any pending regular I/O */ + if (ao_usb_tx_count) { + _ao_usb_in_send(); + continue; + } + + /* Wait for an idle IN buffer */ + if (ao_usb_in_pending) { + ao_sleep(&ao_usb_in_pending); + continue; + } + break; + } - while (ao_usb_in_pending) - ao_sleep(&ao_usb_in_pending); ao_usb_in_pending = 1; ao_usb_in_flushed = (len != AO_USB_IN_SIZE); ao_usb_bdt[AO_USB_IN_EPR].single.addr_tx = ao_usb_packet_buffer_offset(buffer); @@ -1083,6 +1113,9 @@ ao_usb_init(void) debug ("ao_usb_init\n"); ao_usb_ep0_state = AO_USB_EP0_IDLE; + + ao_usb_alloc_buffers(); + #if USB_ECHO ao_add_task(&ao_usb_echo_task, ao_usb_echo, "usb echo"); #endif -- cgit v1.2.3 From a4c436a1c39da971b72d4302623f27af9d56cc38 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 16:02:17 -0800 Subject: altos: Create chaoskey product Signed-off-by: Keith Packard --- src/chaoskey-v0.1/Makefile | 69 +++++++++++++++++++++++++++++++++++++++++ src/chaoskey-v0.1/ao_chaoskey.c | 41 ++++++++++++++++++++++++ src/chaoskey-v0.1/ao_pins.h | 67 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 src/chaoskey-v0.1/Makefile create mode 100644 src/chaoskey-v0.1/ao_chaoskey.c create mode 100644 src/chaoskey-v0.1/ao_pins.h diff --git a/src/chaoskey-v0.1/Makefile b/src/chaoskey-v0.1/Makefile new file mode 100644 index 00000000..bf4b3ca6 --- /dev/null +++ b/src/chaoskey-v0.1/Makefile @@ -0,0 +1,69 @@ +# +# AltOS build +# +# + +include ../stmf0/Makefile.defs + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_pins.h \ + ao_product.h \ + ao_task.h \ + ao_adc_fast.h \ + stm32f0.h + +# +# Common AltOS sources +# +ALTOS_SRC = \ + ao_interrupt.c \ + ao_timer.c \ + ao_panic.c \ + ao_mutex.c \ + ao_dma_stm.c \ + ao_adc_fast.c \ + ao_crc_stm.c \ + ao_stdio.c \ + ao_led.c \ + ao_romconfig.c \ + ao_boot_chain.c \ + ao_usb_stm.c \ + ao_trng_send.c \ + ao_task.c \ + ao_product.c + +PRODUCT=ChaosKey-v0.1 +PRODUCT_DEF=-DCHAOSKEY_V_0_1 +IDPRODUCT=0x0028 + +CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os + +PROGNAME=chaoskey-v0.1 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SRC=$(ALTOS_SRC) ao_chaoskey.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) $(HEX) + +$(PROG): Makefile $(OBJ) altos.ld + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +$(OBJ): $(INC) + +distclean: clean + +clean: + rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/chaoskey-v0.1/ao_chaoskey.c b/src/chaoskey-v0.1/ao_chaoskey.c new file mode 100644 index 00000000..48c8bf04 --- /dev/null +++ b/src/chaoskey-v0.1/ao_chaoskey.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +#include +#include +#include +#include + +void main(void) +{ + ao_led_init(LEDS_AVAILABLE); + ao_led_on(AO_LED_RED); + ao_clock_init(); + ao_task_init(); + ao_timer_init(); + ao_dma_init(); + ao_adc_init(); + ao_crc_init(); + + ao_usb_init(); + + ao_trng_send_init(); + + ao_led_off(AO_LED_RED); + + ao_start_scheduler(); +} diff --git a/src/chaoskey-v0.1/ao_pins.h b/src/chaoskey-v0.1/ao_pins.h new file mode 100644 index 00000000..72963dba --- /dev/null +++ b/src/chaoskey-v0.1/ao_pins.h @@ -0,0 +1,67 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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_ + +#define LED_PORT_ENABLE STM_RCC_AHBENR_IOPAEN +#define LED_PORT (&stm_gpioa) +#define LED_PIN_RED 2 +#define LED_PIN_GREEN 3 +#define AO_LED_RED (1 << LED_PIN_RED) +#define AO_LED_GREEN (1 << LED_PIN_GREEN) + +#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN) + +#define HAS_BEEP 0 + +/* 48MHz clock based on USB */ +#define AO_HSI48 1 + +/* HCLK = 48MHz */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* APB = 48MHz */ +#define AO_APB_PRESCALER 1 +#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1 + +#define HAS_USB 1 +#define AO_USB_DIRECTIO 1 +#define AO_PA11_PA12_RMP 0 +#define AO_USB_INTERFACE_CLASS 0xff + +#define IS_FLASH_LOADER 0 + +/* ADC */ + +#define AO_ADC_PIN0_PORT (&stm_gpioa) +#define AO_ADC_PIN0_PIN 6 +#define AO_ADC_PIN0_CH 6 + +#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_IOPAEN)) + +#define AO_NUM_ADC 1 + +/* CRC */ +#define AO_CRC_WIDTH 32 +#define AO_CRC_INIT 0xffffffff + +/* TRNG */ +#define AO_LED_TRNG_ACTIVE AO_LED_GREEN + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From bd18bc5a42fcecfb710477371b9f62610a1ea640 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 16:04:00 -0800 Subject: altos: Add chaoskey flash loader Signed-off-by: Keith Packard --- src/chaoskey-v0.1/flash-loader/.gitignore | 2 + src/chaoskey-v0.1/flash-loader/ao_pins.h | 36 ++++++++++++++++++ src/drivers/ao_trng_send.c | 62 +++++++++++++++++++++++++++++++ src/drivers/ao_trng_send.h | 24 ++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 src/chaoskey-v0.1/flash-loader/.gitignore create mode 100644 src/chaoskey-v0.1/flash-loader/ao_pins.h create mode 100644 src/drivers/ao_trng_send.c create mode 100644 src/drivers/ao_trng_send.h diff --git a/src/chaoskey-v0.1/flash-loader/.gitignore b/src/chaoskey-v0.1/flash-loader/.gitignore new file mode 100644 index 00000000..32dbbbcf --- /dev/null +++ b/src/chaoskey-v0.1/flash-loader/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +usbtrng* diff --git a/src/chaoskey-v0.1/flash-loader/ao_pins.h b/src/chaoskey-v0.1/flash-loader/ao_pins.h new file mode 100644 index 00000000..295e0258 --- /dev/null +++ b/src/chaoskey-v0.1/flash-loader/ao_pins.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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 + +/* Pin 5 on debug connector */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpioa +#define AO_BOOT_APPLICATION_PIN 15 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +/* USB */ +#define HAS_USB 1 +#define AO_USB_DIRECTIO 0 +#define AO_PA11_PA12_RMP 0 + +#endif /* _AO_PINS_H_ */ diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c new file mode 100644 index 00000000..34a8a981 --- /dev/null +++ b/src/drivers/ao_trng_send.c @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +#include +#include +#include +#include + +static void +ao_trng_send(void) +{ + static uint16_t *buffer[2]; + int usb_buf_id; + uint16_t i; + uint16_t *buf; + uint32_t *rnd; + + if (!buffer[0]) { + buffer[0] = ao_usb_alloc(); + buffer[1] = ao_usb_alloc(); + if (!buffer[0]) + return; + } + + usb_buf_id = 0; + + ao_crc_reset(); + + for (;;) { + ao_led_on(AO_LED_TRNG_ACTIVE); + rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */ + buf = buffer[usb_buf_id]; + for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) + *buf++ = ao_crc_in_32_out_16(*rnd++); + ao_adc_ack(AO_USB_IN_SIZE); + ao_led_off(AO_LED_TRNG_ACTIVE); + ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE); + usb_buf_id = 1-usb_buf_id; + } +} + +static struct ao_task ao_trng_send_task; + +void +ao_trng_send_init(void) +{ + ao_add_task(&ao_trng_send_task, ao_trng_send, "trng_send"); +} diff --git a/src/drivers/ao_trng_send.h b/src/drivers/ao_trng_send.h new file mode 100644 index 00000000..83312d59 --- /dev/null +++ b/src/drivers/ao_trng_send.h @@ -0,0 +1,24 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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_TRNG_SEND_H_ +#define _AO_TRNG_SEND_H_ + +void +ao_trng_send_init(void); + +#endif /* _AO_TRNG_SEND_H_ */ -- cgit v1.2.3 From 0724cc334a3bd8d81bbd4641d90a7e4040330efe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Feb 2015 16:06:23 -0800 Subject: altos/usbtrng: Split out random number generating code to separate driver Signed-off-by: Keith Packard --- src/drivers/ao_trng.c | 76 +++++++++++++++++++++++++++++++++++++++++++ src/drivers/ao_trng.h | 24 ++++++++++++++ src/usbtrng-v2.0/Makefile | 2 ++ src/usbtrng-v2.0/ao_pins.h | 4 +++ src/usbtrng-v2.0/ao_usbtrng.c | 56 ++----------------------------- 5 files changed, 109 insertions(+), 53 deletions(-) create mode 100644 src/drivers/ao_trng.c create mode 100644 src/drivers/ao_trng.h diff --git a/src/drivers/ao_trng.c b/src/drivers/ao_trng.c new file mode 100644 index 00000000..db742928 --- /dev/null +++ b/src/drivers/ao_trng.c @@ -0,0 +1,76 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +#include +#include +#include +#include + +static void +ao_trng_fetch(void) +{ + static uint16_t *buffer[2]; + uint32_t kbytes = 1; + uint32_t count; + int usb_buf_id; + uint16_t i; + uint16_t *buf; + uint32_t *rnd; + + if (!buffer[0]) { + buffer[0] = ao_usb_alloc(); + buffer[1] = ao_usb_alloc(); + if (!buffer[0]) + return; + } + + ao_cmd_decimal(); + if (ao_cmd_status == ao_cmd_success) + kbytes = ao_cmd_lex_u32; + else + ao_cmd_status = ao_cmd_success; + usb_buf_id = 0; + count = kbytes * (1024/AO_USB_IN_SIZE); + + ao_crc_reset(); + + ao_led_on(AO_LED_TRNG_READ); + while (count--) { + rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */ + buf = buffer[usb_buf_id]; + for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) + *buf++ = ao_crc_in_32_out_16(*rnd++); + ao_adc_ack(AO_USB_IN_SIZE); + ao_led_toggle(AO_LED_TRNG_READ|AO_LED_TRNG_WRITE); + ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE); + ao_led_toggle(AO_LED_TRNG_READ|AO_LED_TRNG_WRITE); + usb_buf_id = 1-usb_buf_id; + } + ao_led_off(AO_LED_TRNG_READ|AO_LED_TRNG_WRITE); + flush(); +} + +static const struct ao_cmds ao_trng_cmds[] = { + { ao_trng_fetch, "f \0Fetch a block of numbers" }, + { 0, NULL }, +}; + +void +ao_trng_init(void) +{ + ao_cmd_register(ao_trng_cmds); +} diff --git a/src/drivers/ao_trng.h b/src/drivers/ao_trng.h new file mode 100644 index 00000000..78577428 --- /dev/null +++ b/src/drivers/ao_trng.h @@ -0,0 +1,24 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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_TRNG_H_ +#define _AO_TRNG_H_ + +void +ao_trng_init(void); + +#endif /* _AO_TRNG_H_ */ diff --git a/src/usbtrng-v2.0/Makefile b/src/usbtrng-v2.0/Makefile index abbdbbcc..49798f1c 100644 --- a/src/usbtrng-v2.0/Makefile +++ b/src/usbtrng-v2.0/Makefile @@ -12,6 +12,7 @@ INC = \ ao_pins.h \ ao_product.h \ ao_task.h \ + ao_adc_fast.h \ stm32f0.h # @@ -31,6 +32,7 @@ ALTOS_SRC = \ ao_boot_chain.c \ ao_cmd.c \ ao_usb_stm.c \ + ao_trng.c \ ao_task.c \ ao_product.c diff --git a/src/usbtrng-v2.0/ao_pins.h b/src/usbtrng-v2.0/ao_pins.h index 23759444..1997d205 100644 --- a/src/usbtrng-v2.0/ao_pins.h +++ b/src/usbtrng-v2.0/ao_pins.h @@ -60,4 +60,8 @@ #define AO_CRC_WIDTH 32 #define AO_CRC_INIT 0xffffffff +/* TRNG */ +#define AO_LED_TRNG_READ AO_LED_RED +#define AO_LED_TRNG_WRITE AO_LED_GREEN + #endif /* _AO_PINS_H_ */ diff --git a/src/usbtrng-v2.0/ao_usbtrng.c b/src/usbtrng-v2.0/ao_usbtrng.c index e1f43cdd..42713b6e 100644 --- a/src/usbtrng-v2.0/ao_usbtrng.c +++ b/src/usbtrng-v2.0/ao_usbtrng.c @@ -18,58 +18,7 @@ #include #include #include - -static void -ao_trng_fetch(void) -{ - static uint16_t *buffer[2]; - uint32_t kbytes = 1; - uint32_t count; - int usb_buf_id; - int i; - uint16_t *buf; - uint32_t *rnd; - - if (!buffer[0]) { - buffer[0] = ao_usb_alloc(); - buffer[1] = ao_usb_alloc(); - if (!buffer[0]) - return; - } - - ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success) - kbytes = ao_cmd_lex_u32; - else - ao_cmd_status = ao_cmd_success; - usb_buf_id = 0; - count = kbytes * (1024/AO_USB_IN_SIZE); - - ao_crc_reset(); - - ao_led_on(AO_LED_GREEN); - while (count--) { - buf = buffer[usb_buf_id]; -// printf ("before get: head %3d tail %3d running %d\n", ao_adc_ring_head, ao_adc_ring_tail, ao_adc_running); flush(); - rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */ -// printf ("after get: head %3d tail %3d running %d\n", ao_adc_ring_head, ao_adc_ring_tail, ao_adc_running); flush(); - for (i = 0; i < 32; i++) - *buf++ = ao_crc_in_32_out_16(*rnd++); - ao_adc_ack(AO_USB_IN_SIZE); -// printf ("after ack: head %3d tail %3d running %d\n", ao_adc_ring_head, ao_adc_ring_tail, ao_adc_running); flush(); - ao_led_toggle(AO_LED_GREEN|AO_LED_RED); - ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE); - ao_led_toggle(AO_LED_GREEN|AO_LED_RED); - usb_buf_id = 1-usb_buf_id; - } - ao_led_off(AO_LED_GREEN|AO_LED_RED); - flush(); -} - -static const struct ao_cmds usbtrng_cmds[] = { - { ao_trng_fetch, "f \0Fetch a block of numbers" }, - { 0, NULL }, -}; +#include void main(void) { @@ -86,7 +35,8 @@ void main(void) ao_usb_init(); - ao_cmd_register(usbtrng_cmds); + ao_trng_init(); + ao_led_off(AO_LED_RED); ao_start_scheduler(); -- cgit v1.2.3 From 2614d20b324ab215ef22f178e3635d48e757fa9b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:02:31 -0800 Subject: altos: Make APRS format (compressed/uncompressed) configurable This provides a choice of compressed vs uncompressed when sending APRS packets to deal with receivers that still do not have support for the more useful compressed format. Signed-off-by: Keith Packard --- src/drivers/ao_aprs.c | 98 +++++++++++++++++++++++++++++++++++++++++--------- src/kernel/ao_config.c | 23 ++++++++++++ src/kernel/ao_config.h | 9 ++++- 3 files changed, 112 insertions(+), 18 deletions(-) diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index 19beb78f..2e977612 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -707,8 +707,7 @@ static int tncPositionPacket(void) static int32_t latitude; static int32_t longitude; static int32_t altitude; - int32_t lat, lon, alt; - uint8_t *buf; + uint8_t *buf; if (ao_gps_data.flags & AO_GPS_VALID) { latitude = ao_gps_data.latitude; @@ -719,28 +718,93 @@ static int tncPositionPacket(void) } buf = tncBuffer; - *buf++ = '!'; - /* Symbol table ID */ - *buf++ = '/'; + switch (ao_config.aprs_format) { + case AO_APRS_FORMAT_COMPRESSED: + default: + { + int32_t lat, lon, alt; + + *buf++ = '!'; + + /* Symbol table ID */ + *buf++ = '/'; + + lat = ((uint64_t) 380926 * (900000000 - latitude)) / 10000000; + lon = ((uint64_t) 190463 * (1800000000 + longitude)) / 10000000; + + alt = ao_aprs_encode_altitude(altitude); + + tncCompressInt(buf, lat, 4); + buf += 4; + tncCompressInt(buf, lon, 4); + buf += 4; - lat = ((uint64_t) 380926 * (900000000 - latitude)) / 10000000; - lon = ((uint64_t) 190463 * (1800000000 + longitude)) / 10000000; + /* Symbol code */ + *buf++ = '\''; - alt = ao_aprs_encode_altitude(altitude); + tncCompressInt(buf, alt, 2); + buf += 2; - tncCompressInt(buf, lat, 4); - buf += 4; - tncCompressInt(buf, lon, 4); - buf += 4; + *buf++ = 33 + ((1 << 5) | (2 << 3)); - /* Symbol code */ - *buf++ = '\''; + break; + } + case AO_APRS_FORMAT_UNCOMPRESSED: + { + char lat_sign = 'N', lon_sign = 'E'; + int32_t lat = latitude; + int32_t lon = longitude; + int32_t alt = altitude; + uint16_t lat_deg; + uint16_t lon_deg; + uint16_t lat_min; + uint16_t lat_frac; + uint16_t lon_min; + uint16_t lon_frac; + + if (lat < 0) { + lat_sign = 'S'; + lat = -lat; + } - tncCompressInt(buf, alt, 2); - buf += 2; + if (lon < 0) { + lon_sign = 'W'; + lon = -lon; + } - *buf++ = 33 + ((1 << 5) | (2 << 3)); + /* Round latitude and longitude by 0.005 minutes */ + lat = lat + 833; + if (lat > 900000000) + lat = 900000000; + lon = lon + 833; + if (lon > 1800000000) + lon = 1800000000; + + lat_deg = lat / 10000000; + lat -= lat_deg * 10000000; + lat *= 60; + lat_min = lat / 10000000; + lat -= lat_min * 10000000; + lat_frac = lat / 100000; + + lon_deg = lon / 10000000; + lon -= lon_deg * 10000000; + lon *= 60; + lon_min = lon / 10000000; + lon -= lon_min * 10000000; + lon_frac = lon / 100000; + + /* Convert from meters to feet */ + alt = (alt * 328 + 50) / 100; + + buf += sprintf((char *) tncBuffer, "!%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06u ", + lat_deg, lat_min, lat_frac, lat_sign, + lon_deg, lon_min, lon_frac, lon_sign, + alt); + break; + } + } buf += tncComment(buf); diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 8dab7c42..b0d3e541 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -219,6 +219,10 @@ _ao_config_get(void) #if HAS_RADIO_FORWARD if (minor < 21) ao_config.send_frequency = 434550; +#endif +#if HAS_APRS + if (minor < 22) + ao_config.aprs_format = AO_CONFIG_DEFAULT_APRS_FORMAT; #endif ao_config.minor = AO_CONFIG_MINOR; ao_config_dirty = 1; @@ -876,6 +880,23 @@ ao_config_aprs_ssid_set(void) ao_config.aprs_ssid = ao_cmd_lex_i; _ao_config_edit_finish(); } + +void +ao_config_aprs_format_set(void) +{ + ao_cmd_decimal(); + if (ao_cmd_status != ao_cmd_success) + return; + _ao_config_edit_start(); + ao_config.aprs_format = ao_cmd_lex_i != 0; + _ao_config_edit_finish(); +} + +void +ao_config_aprs_format_show(void) +{ + printf ("APRS format: %d\n", ao_config.aprs_format); +} #endif /* HAS_APRS */ struct ao_config_var { @@ -969,6 +990,8 @@ __code struct ao_config_var ao_config_vars[] = { #if HAS_APRS { "S \0Set APRS SSID (0-15)", ao_config_aprs_ssid_set, ao_config_aprs_ssid_show }, + { "C <0 compressed, 1 uncompressed>\0APRS format", + ao_config_aprs_format_set, ao_config_aprs_format_show }, #endif { "s\0Show", ao_config_show, 0 }, diff --git a/src/kernel/ao_config.h b/src/kernel/ao_config.h index 164584a5..cfe8555c 100644 --- a/src/kernel/ao_config.h +++ b/src/kernel/ao_config.h @@ -57,7 +57,7 @@ #endif #define AO_CONFIG_MAJOR 1 -#define AO_CONFIG_MINOR 21 +#define AO_CONFIG_MINOR 22 #define AO_AES_LEN 16 @@ -115,8 +115,15 @@ struct ao_config { #if HAS_RADIO_FORWARD uint32_t send_frequency; /* minor version 21 */ #endif +#if HAS_APRS + uint8_t aprs_format; /* minor version 22 */ +#endif }; +#define AO_APRS_FORMAT_COMPRESSED 0 +#define AO_APRS_FORMAT_UNCOMPRESSED 1 +#define AO_CONFIG_DEFAULT_APRS_FORMAT AO_APRS_FORMAT_COMPRESSED + #if HAS_RADIO_FORWARD extern __xdata uint32_t ao_send_radio_setting; #endif -- cgit v1.2.3 From e637367e8b940e1642a07b3b7c99147561de9cf1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:06:02 -0800 Subject: altosui/telegps: Add config option for APRS format Allow configuration of APRS compressed/uncompressed Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 8 ++++++ altoslib/AltosConfigValues.java | 4 +++ altoslib/AltosLib.java | 7 +++++ altosui/AltosConfigUI.java | 62 +++++++++++++++++++++++++++++++++++++---- telegps/TeleGPSConfigUI.java | 60 +++++++++++++++++++++++++++++++++++---- 5 files changed, 130 insertions(+), 11 deletions(-) diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index d8f4d945..0ffdcf60 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -75,6 +75,7 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ public int aprs_interval; public int aprs_ssid; + public int aprs_format; /* HAS_BEEP */ public int beep; @@ -270,6 +271,7 @@ public class AltosConfigData implements Iterable { aprs_interval = -1; aprs_ssid = -1; + aprs_format = -1; beep = -1; @@ -370,6 +372,7 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} try { aprs_ssid = get_int(line, "APRS SSID:"); } catch (Exception e) {} + try { aprs_format = get_int(line, "APRS format:"); } catch (Exception e) {} /* HAS_BEEP */ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} @@ -518,6 +521,8 @@ public class AltosConfigData implements Iterable { aprs_interval = source.aprs_interval(); if (aprs_ssid >= 0) aprs_ssid = source.aprs_ssid(); + if (aprs_format >= 0) + aprs_format = source.aprs_format(); /* HAS_BEEP */ if (beep >= 0) @@ -572,6 +577,7 @@ public class AltosConfigData implements Iterable { dest.set_pyro_firing_time(pyro_firing_time); dest.set_aprs_interval(aprs_interval); dest.set_aprs_ssid(aprs_ssid); + dest.set_aprs_format(aprs_format); dest.set_beep(beep); dest.set_tracker_motion(tracker_motion); dest.set_tracker_interval(tracker_interval); @@ -674,6 +680,8 @@ public class AltosConfigData implements Iterable { link.printf("c A %d\n", aprs_interval); if (aprs_ssid >= 0) link.printf("c S %d\n", aprs_ssid); + if (aprs_format >= 0) + link.printf("c C %d\n", aprs_format); /* HAS_BEEP */ if (beep >= 0) diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index cfe9fc8b..3f26a078 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -91,6 +91,10 @@ public interface AltosConfigValues { public abstract void set_aprs_ssid(int new_aprs_ssid); + public abstract int aprs_format() throws AltosConfigDataException; + + public abstract void set_aprs_format(int new_aprs_format); + public abstract int beep() throws AltosConfigDataException; public abstract void set_beep(int new_beep); diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index b19f9f52..405a3acc 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -190,6 +190,13 @@ public class AltosLib { 38400, 9600, 2400 }; + public static final int ao_aprs_format_compressed = 0; + public static final int ao_aprs_format_uncompressed = 1; + + public static final String[] ao_aprs_format_name = { + "Compressed", "Uncompressed" + }; + public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt"; // public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt"; diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 54f06065..b072ede7 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -43,6 +43,7 @@ public class AltosConfigUI JLabel rate_label; JLabel aprs_interval_label; JLabel aprs_ssid_label; + JLabel aprs_format_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; @@ -66,6 +67,7 @@ public class AltosConfigUI AltosUIRateList rate_value; JComboBox aprs_interval_value; JComboBox aprs_ssid_value; + JComboBox aprs_format_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; JComboBox pad_orientation_value; @@ -218,11 +220,20 @@ public class AltosConfigUI void set_aprs_ssid_tool_tip() { if (aprs_ssid_value.isEnabled()) - aprs_interval_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); - else if (aprs_interval_value.isEnabled()) - aprs_interval_value.setToolTipText("Software version doesn't support setting the APRS SSID"); + aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); + else if (aprs_ssid_value.isEnabled()) + aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID"); else - aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); + aprs_ssid_value.setToolTipText("Hardware doesn't support APRS"); + } + + void set_aprs_format_tool_tip() { + if (aprs_format_value.isEnabled()) + aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)"); + else if (aprs_format_value.isEnabled()) + aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format"); + else + aprs_format_value.setToolTipText("Hardware doesn't support APRS"); } void set_flight_log_max_tool_tip() { @@ -577,6 +588,33 @@ public class AltosConfigUI set_aprs_ssid_tool_tip(); row++; + /* APRS format */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + aprs_format_label = new JLabel("APRS format:"); + pane.add(aprs_format_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + aprs_format_value = new JComboBox(AltosLib.ao_aprs_format_name); + aprs_format_value.setEditable(false); + aprs_format_value.addItemListener(this); + aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length); + pane.add(aprs_format_value, c); + set_aprs_format_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -943,7 +981,7 @@ public class AltosConfigUI } String get_main_deploy_label() { - return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units()); + return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); } String[] main_deploy_values() { @@ -1207,7 +1245,7 @@ public class AltosConfigUI } String get_tracker_motion_label() { - return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); } void set_tracker_tool_tip() { @@ -1313,4 +1351,16 @@ public class AltosConfigUI Integer i = (Integer) aprs_ssid_value.getSelectedItem(); return i; } + + public void set_aprs_format(int new_aprs_format) { + aprs_format_value.setVisible(new_aprs_format >= 0); + aprs_format_label.setVisible(new_aprs_format >= 0); + + aprs_format_value.setSelectedIndex(Math.max(0,new_aprs_format)); + set_aprs_format_tool_tip(); + } + + public int aprs_format() throws AltosConfigDataException { + return aprs_format_value.getSelectedIndex(); + } } diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 5e700b72..0189a809 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -40,6 +40,7 @@ public class TeleGPSConfigUI JLabel rate_label; JLabel aprs_interval_label; JLabel aprs_ssid_label; + JLabel aprs_format_label; JLabel flight_log_max_label; JLabel callsign_label; JLabel tracker_motion_label; @@ -57,6 +58,7 @@ public class TeleGPSConfigUI AltosUIRateList rate_value; JComboBox aprs_interval_value; JComboBox aprs_ssid_value; + JComboBox aprs_format_value; JComboBox flight_log_max_value; JTextField callsign_value; JComboBox tracker_motion_value; @@ -165,11 +167,20 @@ public class TeleGPSConfigUI void set_aprs_ssid_tool_tip() { if (aprs_ssid_value.isEnabled()) - aprs_interval_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); - else if (aprs_interval_value.isEnabled()) - aprs_interval_value.setToolTipText("Software version doesn't support setting the APRS SSID"); + aprs_ssid_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); + else if (aprs_ssid_value.isEnabled()) + aprs_ssid_value.setToolTipText("Software version doesn't support setting the APRS SSID"); else - aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); + aprs_ssid_value.setToolTipText("Hardware doesn't support APRS"); + } + + void set_aprs_format_tool_tip() { + if (aprs_format_value.isEnabled()) + aprs_format_value.setToolTipText("Set the APRS format (compressed/uncompressed)"); + else if (aprs_format_value.isEnabled()) + aprs_format_value.setToolTipText("Software version doesn't support setting the APRS format"); + else + aprs_format_value.setToolTipText("Hardware doesn't support APRS"); } void set_flight_log_max_tool_tip() { @@ -413,6 +424,33 @@ public class TeleGPSConfigUI set_aprs_ssid_tool_tip(); row++; + /* APRS format */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + aprs_format_label = new JLabel("APRS format:"); + pane.add(aprs_format_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + aprs_format_value = new JComboBox(AltosLib.ao_aprs_format_name); + aprs_format_value.setEditable(false); + aprs_format_value.addItemListener(this); + aprs_format_value.setMaximumRowCount(AltosLib.ao_aprs_format_name.length); + pane.add(aprs_format_value, c); + set_aprs_format_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -824,7 +862,7 @@ public class TeleGPSConfigUI } String get_tracker_motion_label() { - return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); } void set_tracker_tool_tip() { @@ -894,4 +932,16 @@ public class TeleGPSConfigUI Integer i = (Integer) aprs_ssid_value.getSelectedItem(); return i; } + + public void set_aprs_format(int new_aprs_format) { + aprs_format_value.setVisible(new_aprs_format >= 0); + aprs_format_label.setVisible(new_aprs_format >= 0); + + aprs_format_value.setSelectedIndex(Math.max(0,new_aprs_format)); + set_aprs_format_tool_tip(); + } + + public int aprs_format() throws AltosConfigDataException { + return aprs_format_value.getSelectedIndex(); + } } -- cgit v1.2.3 From ff3c27e3b842107680dc48084f71eb8c63f1bcab Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:06:51 -0800 Subject: altoslib: Round frequency when configuring radio This makes sure we set the right frequency, instead of being off by 1kHz on a regular basis... Signed-off-by: Keith Packard --- altoslib/AltosLink.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 01c37864..0105398d 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -354,7 +354,7 @@ public abstract class AltosLink implements Runnable { if (frequency == 0) return; if (has_frequency) - set_radio_freq((int) Math.floor (frequency * 1000)); + set_radio_freq((int) Math.floor (frequency * 1000 + 0.5)); else if (has_setting) set_radio_setting(AltosConvert.radio_frequency_to_setting(frequency, cal)); else -- cgit v1.2.3 From 112f528755b6c8a2f6eef3bfec21fac981ffb44f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:08:44 -0800 Subject: ao-tools: Add ao-flash-stm32f0x This new script uses openocd to flash stm32f0x parts Signed-off-by: Keith Packard --- ao-tools/ao-flash/Makefile.am | 4 ++-- ao-tools/ao-flash/ao-flash-stm32f0x | 16 ++++++++++++++++ ao-tools/ao-flash/ao-flash-stm32f0x.1 | 36 +++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 ao-tools/ao-flash/ao-flash-stm32f0x create mode 100644 ao-tools/ao-flash/ao-flash-stm32f0x.1 diff --git a/ao-tools/ao-flash/Makefile.am b/ao-tools/ao-flash/Makefile.am index 6b7ea6bb..4231dc21 100644 --- a/ao-tools/ao-flash/Makefile.am +++ b/ao-tools/ao-flash/Makefile.am @@ -1,3 +1,3 @@ -bin_SCRIPTS=ao-flash-stm ao-flash-lpc +bin_SCRIPTS=ao-flash-stm ao-flash-lpc ao-flash-stm32f0x -man_MANS = ao-flash-stm.1 ao-flash-lpc.1 \ No newline at end of file +man_MANS = ao-flash-stm.1 ao-flash-lpc.1 ao-flash-stm32f0x.1 diff --git a/ao-tools/ao-flash/ao-flash-stm32f0x b/ao-tools/ao-flash/ao-flash-stm32f0x new file mode 100755 index 00000000..45643a4f --- /dev/null +++ b/ao-tools/ao-flash/ao-flash-stm32f0x @@ -0,0 +1,16 @@ +#!/bin/sh +case "$#" in +0) + echo "usage: $0 ..." + exit 1 + ;; +esac +cmds=/tmp/flash$$ +trap "rm $cmds" 0 1 15 +file="$1" +echo "program $file verify reset" > $cmds +openocd \ + -f interface/stlink-v2.cfg \ + -f target/stm32f0x_stlink.cfg \ + -f $cmds \ + -c shutdown diff --git a/ao-tools/ao-flash/ao-flash-stm32f0x.1 b/ao-tools/ao-flash/ao-flash-stm32f0x.1 new file mode 100644 index 00000000..07ff5b59 --- /dev/null +++ b/ao-tools/ao-flash/ao-flash-stm32f0x.1 @@ -0,0 +1,36 @@ +.\" +.\" Copyright © 2013 Keith Packard +.\" +.\" 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; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" 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. +.\" +.\" +.TH AO-FLASH-LPC 1 "ao-flash-stm32f0x" "" +.SH NAME +ao-flash-stm32f0x \- flash a program to a STM32F0x-based AltOS device using openocd +.SH SYNOPSIS +.B "ao-flash-stm32f0x" +\fIfile.elf\fP +.SH DESCRIPTION +.I ao-flash-stm32f0x +loads the specified .elf file into the target device flash memory. +.SH USAGE +.I ao-flash-stm32f0x +is a simple script that passes the correct arguments to openocd to +load a file into the target device via a connected STlink +debugging dongle. +.SH "SEE ALSO" +openocd(1) +.SH AUTHOR +Keith Packard -- cgit v1.2.3 From 3b133656df4698ceb7af5902711edf9253a29227 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:11:33 -0800 Subject: altos: Wait for BT disconnect before sending command If AltosDroid manages to connect to the BT module before we've configured it, we won't be able to talk to it as we can't force the module to ignore connection attempts. Wait for AltosDroid to give up and let us configure the device. Eventually, we'll manage, if AltosDroid's delay interval is longer than the time it takes to configure the unit. Signed-off-by: Keith Packard --- src/drivers/ao_btm.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index 93d9dd9d..8e7052cb 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -263,6 +263,15 @@ uint8_t ao_btm_cmd(__code char *cmd) { ao_btm_drain(); + +#ifdef AO_BTM_INT_PORT + /* Trust that AltosDroid will eventually disconnect and let us + * get things set up. The BTM module doesn't appear to listen + * for +++, so we have no way to force a disconnect. + */ + while (ao_btm_connected) + ao_sleep(&ao_btm_connected); +#endif ao_btm_string(cmd); return ao_btm_wait_reply(); } @@ -350,6 +359,10 @@ __xdata struct ao_task ao_btm_task; void ao_btm(void) { +#ifdef AO_BTM_INT_PORT + ao_exti_enable(AO_BTM_INT_PORT, AO_BTM_INT_PIN); +#endif + /* * Wait for the bluetooth device to boot */ @@ -380,6 +393,8 @@ ao_btm(void) /* Turn off status reporting */ ao_btm_cmd("ATQ1\r"); + ao_btm_drain(); + ao_btm_stdio = ao_add_stdio(_ao_serial_btm_pollchar, ao_serial_btm_putchar, NULL); @@ -388,10 +403,6 @@ ao_btm(void) /* Check current pin state */ ao_btm_check_link(); -#ifdef AO_BTM_INT_PORT - ao_exti_enable(AO_BTM_INT_PORT, AO_BTM_INT_PIN); -#endif - for (;;) { while (!ao_btm_connected) ao_sleep(&ao_btm_connected); -- cgit v1.2.3 From bef7c89dac68956a94ae386fa6b87165ab6cb484 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 21:16:06 -0800 Subject: altos: Missing pad field in TMv2 data packet The normal ARM padding would have filled this in correctly, but it's best to be explicit about the structure. This also adds a test to make sure the resulting telemetry declaration is exactly 32 bytes, Signed-off-by: Keith Packard --- src/kernel/ao_telemetry.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kernel/ao_telemetry.h b/src/kernel/ao_telemetry.h index 711e0d36..672d2317 100644 --- a/src/kernel/ao_telemetry.h +++ b/src/kernel/ao_telemetry.h @@ -258,13 +258,14 @@ struct ao_telemetry_metrum_data { uint16_t serial; /* 0 */ uint16_t tick; /* 2 */ uint8_t type; /* 4 */ + uint8_t pad5[3]; /* 5 */ - int32_t ground_pres; /* 8 average pres on pad */ + int32_t ground_pres; /* 8 average pres on pad */ int16_t ground_accel; /* 12 average accel on pad */ int16_t accel_plus_g; /* 14 accel calibration at +1g */ int16_t accel_minus_g; /* 16 accel calibration at -1g */ - uint8_t pad[14]; /* 18 */ + uint8_t pad18[14]; /* 18 */ /* 32 */ }; @@ -332,6 +333,8 @@ union ao_telemetry_all { struct ao_telemetry_baro baro; }; +typedef char ao_check_telemetry_size[sizeof(union ao_telemetry_all) == 32 ? 1 : -1]; + struct ao_telemetry_all_recv { union ao_telemetry_all telemetry; int8_t rssi; -- cgit v1.2.3 From d446c90dab0aca7e501a0228f24c210758d84a1d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Mar 2015 22:23:22 -0800 Subject: altosui/telegps: Change from variable-units snuck into master show_units_name(double) only exists on the variable-units branch... Signed-off-by: Keith Packard --- altosui/AltosConfigUI.java | 4 ++-- telegps/TeleGPSConfigUI.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index b072ede7..67decaa4 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -981,7 +981,7 @@ public class AltosConfigUI } String get_main_deploy_label() { - return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); + return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units()); } String[] main_deploy_values() { @@ -1245,7 +1245,7 @@ public class AltosConfigUI } String get_tracker_motion_label() { - return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); } void set_tracker_tool_tip() { diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 0189a809..97ab34b4 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -862,7 +862,7 @@ public class TeleGPSConfigUI } String get_tracker_motion_label() { - return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units_name(AltosLib.MISSING)); + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); } void set_tracker_tool_tip() { -- cgit v1.2.3 From cdd7ad469728fde178c69b9c99d70d6e0ab3f12d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 10:18:57 -0800 Subject: altosdroid: Deal with bluetooth connection failures better Remember when we've closed the bluetooth connection so that we stop operations, including reporting connection status messages or even starting a connection attempt. Pass the AltosBluetooth object back in connection status messages so that TelemetryService can tell when messages from closed objects get delivered. There's a queue between the two, so the above fix catches most of these instances, but not all of them. Stick a delay during reconnect -- if the TeleBT device is getting power-cycled, it will need a few seconds to reconfigure the device at startup, if AltosDroid manages to connect during that time, the configuration commands will be ignored. Unlock the AltosBluetooth device while we connect so that cancel calls will actually work. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 187 +++++++++++---------- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 4 +- .../altusmetrum/AltosDroid/TelemetryService.java | 48 +++++- 3 files changed, 146 insertions(+), 93 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 973250a5..da75ffdd 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -45,24 +45,36 @@ public class AltosBluetooth extends AltosLink { private Handler handler; private BluetoothAdapter adapter; - private BluetoothDevice device; private BluetoothSocket socket; private InputStream input; private OutputStream output; // Constructor - public AltosBluetooth(BluetoothDevice in_device, Handler in_handler) { + public AltosBluetooth(BluetoothDevice device, Handler handler) { // set_debug(D); adapter = BluetoothAdapter.getDefaultAdapter(); - device = in_device; - handler = in_handler; + this.handler = handler; - connect_thread = new ConnectThread(device); + create_socket(device); + connect_thread = new ConnectThread(); connect_thread.start(); + } + + private Object closed_lock = new Object(); + private boolean closed = false; + private boolean closed() { + synchronized(closed_lock) { + return closed; + } } private void connected() { + if (closed()) { + if (D) Log.d(TAG, "connected after closed"); + return; + } + try { synchronized(this) { if (socket != null) { @@ -79,7 +91,7 @@ public class AltosBluetooth extends AltosLink { /* Let TelemetryService know we're connected */ - handler.obtainMessage(TelemetryService.MSG_CONNECTED).sendToTarget(); + handler.obtainMessage(TelemetryService.MSG_CONNECTED, this).sendToTarget(); /* Notify other waiting threads that we're connected now */ @@ -92,97 +104,104 @@ public class AltosBluetooth extends AltosLink { } private void connect_failed() { - synchronized (this) { - if (socket != null) { - try { - socket.close(); - } catch (IOException e2) { - if (D) Log.e(TAG, "ConnectThread: Failed to close() socket after failed connection"); - } - socket = null; - } - input = null; - output = null; - handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED).sendToTarget(); - if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); + if (closed()) { + if (D) Log.d(TAG, "connect_failed after closed"); + return; } - } - private Object closing_lock = new Object(); - private boolean closing = false; + close_socket(); + input = null; + output = null; + handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED, this).sendToTarget(); + if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); + } private void disconnected() { - synchronized(closing_lock) { - if (D) Log.e(TAG, String.format("Connection lost during I/O. Closing %b", closing)); - if (!closing) { - if (D) Log.d(TAG, "Sending disconnected message"); - handler.obtainMessage(TelemetryService.MSG_DISCONNECTED).sendToTarget(); - } + if (closed()) { + if (D) Log.d(TAG, "disconnected after closed"); + return; } + + if (D) Log.d(TAG, "Sending disconnected message"); + handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); } - private class ConnectThread extends Thread { - private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); + private void close_socket() { + BluetoothSocket tmp_socket; - public ConnectThread(BluetoothDevice device) { - BluetoothSocket tmp_socket = null; + synchronized(this) { + tmp_socket = socket; + socket = null; + } + if (tmp_socket != null) { try { - tmp_socket = device.createInsecureRfcommSocketToServiceRecord(SPP_UUID); + tmp_socket.close(); } catch (IOException e) { - e.printStackTrace(); + if (D) Log.e(TAG, "close_socket failed"); } + } + } + + private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); + + private void create_socket(BluetoothDevice device) { + + BluetoothSocket tmp_socket = null; + + try { + tmp_socket = device.createInsecureRfcommSocketToServiceRecord(SPP_UUID); + } catch (IOException e) { + e.printStackTrace(); + } + if (socket != null) { + if (D) Log.d(TAG, String.format("Socket already allocated %s", socket.toString())); + close_socket(); + } + synchronized (this) { socket = tmp_socket; } + } + + private class ConnectThread extends Thread { public void run() { if (D) Log.d(TAG, "ConnectThread: BEGIN"); setName("ConnectThread"); // Always cancel discovery because it will slow down a connection - adapter.cancelDiscovery(); + try { + adapter.cancelDiscovery(); + } catch (Exception e) { + if (D) Log.d(TAG, String.format("cancelDiscovery exception %s", e.toString())); + } - BluetoothSocket local_socket; + BluetoothSocket local_socket = null; - try { - synchronized (AltosBluetooth.this) { + synchronized (AltosBluetooth.this) { + if (!closed()) local_socket = socket; - } + } - if (local_socket != null) { + if (local_socket != null) { + try { // Make a connection to the BluetoothSocket // This is a blocking call and will only return on a // successful connection or an exception local_socket.connect(); + } catch (IOException e) { + if (D) Log.d(TAG, String.format("Connect exception %s", e.toString())); + local_socket = null; } + } + if (local_socket != null) { connected(); - - } catch (IOException e) { + } else { connect_failed(); } - synchronized (AltosBluetooth.this) { - /* Reset the ConnectThread because we're done - */ - connect_thread = null; - } - if (D) Log.d(TAG, "ConnectThread: Connect completed"); - } - - public void cancel() { - try { - BluetoothSocket local_socket; - synchronized(AltosBluetooth.this) { - local_socket = socket; - socket = null; - } - if (local_socket != null) - local_socket.close(); - - } catch (IOException e) { - if (D) Log.e(TAG, "ConnectThread: close() of connect socket failed", e); - } + if (D) Log.d(TAG, "ConnectThread: completed"); } } @@ -246,6 +265,19 @@ public class AltosBluetooth extends AltosLink { private int buffer_len = 0; private int buffer_off = 0; + private byte[] debug_chars = new byte[buffer_size]; + private int debug_off; + + private void debug_input(byte b) { + if (b == '\n') { + Log.d(TAG, " " + new String(debug_chars, 0, debug_off)); + debug_off = 0; + } else { + if (debug_off < buffer_size) + debug_chars[debug_off++] = b; + } + } + public int getchar() { while (buffer_off == buffer_len) { try { @@ -262,13 +294,15 @@ public class AltosBluetooth extends AltosLink { return AltosLink.ERROR; } } + if (D) + debug_input(buffer[buffer_off]); return buffer[buffer_off++]; } public void closing() { - synchronized(closing_lock) { - if (D) Log.d(TAG, "Marked closing true"); - closing = true; + synchronized(closed_lock) { + if (D) Log.d(TAG, "Marked closed true"); + closed = true; } } @@ -278,19 +312,10 @@ public class AltosBluetooth extends AltosLink { closing(); + close_socket(); + synchronized(this) { - if (D) Log.d(TAG, "close(): synched"); - if (socket != null) { - if (D) Log.d(TAG, "close(): Closing socket"); - try { - socket.close(); - } catch (IOException e) { - if (D) Log.e(TAG, "close(): unable to close() socket"); - } - socket = null; - } - connect_thread = null; if (input_thread != null) { if (D) Log.d(TAG, "close(): stopping input_thread"); try { @@ -307,14 +332,6 @@ public class AltosBluetooth extends AltosLink { } } - - // We override this method so that we can add some debugging. Not 100% elegant, but more useful - // than debugging one char at a time above in getchar()! - public void add_reply(AltosLine line) throws InterruptedException { - if (D) Log.d(TAG, String.format("Got REPLY: %s", line.line)); - super.add_reply(line); - } - //public void flush_output() { super.flush_output(); } // Stubs of required methods when extending AltosLink diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 41045f03..4e7bdd6b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -550,10 +550,12 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); String name = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_NAME); - if (D) Log.d(TAG, "Connecting to " + address + name); + if (D) Log.d(TAG, "Connecting to " + address + " " + name); DeviceAddress a = new DeviceAddress(address, name); mService.send(Message.obtain(null, TelemetryService.MSG_CONNECT, a)); + if (D) Log.d(TAG, "Sent connecting message"); } catch (RemoteException e) { + if (D) Log.e(TAG, "connect device message failed"); } } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 5f138972..65eabf11 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -94,6 +94,7 @@ public class TelemetryService extends Service implements LocationListener { @Override public void handleMessage(Message msg) { TelemetryService s = service.get(); + AltosBluetooth bt = null; if (s == null) return; switch (msg.what) { @@ -109,7 +110,7 @@ public class TelemetryService extends Service implements LocationListener { if (D) Log.d(TAG, "Connect command received"); DeviceAddress address = (DeviceAddress) msg.obj; AltosDroidPreferences.set_active_device(address); - s.start_altos_bluetooth(address); + s.start_altos_bluetooth(address, false); break; case MSG_DISCONNECT: if (D) Log.d(TAG, "Disconnect command received"); @@ -143,6 +144,13 @@ public class TelemetryService extends Service implements LocationListener { *Messages from AltosBluetooth */ case MSG_CONNECTED: + Log.d(TAG, "MSG_CONNECTED"); + bt = (AltosBluetooth) msg.obj; + + if (bt != s.altos_bluetooth) { + if (D) Log.d(TAG, "Stale message"); + break; + } if (D) Log.d(TAG, "Connected to device"); try { s.connected(); @@ -150,18 +158,31 @@ public class TelemetryService extends Service implements LocationListener { } break; case MSG_CONNECT_FAILED: + Log.d(TAG, "MSG_CONNECT_FAILED"); + bt = (AltosBluetooth) msg.obj; + + if (bt != s.altos_bluetooth) { + if (D) Log.d(TAG, "Stale message"); + break; + } if (s.address != null) { if (D) Log.d(TAG, "Connection failed... retrying"); - s.start_altos_bluetooth(s.address); + s.start_altos_bluetooth(s.address, true); } else { s.stop_altos_bluetooth(true); } break; case MSG_DISCONNECTED: Log.d(TAG, "MSG_DISCONNECTED"); + bt = (AltosBluetooth) msg.obj; + + if (bt != s.altos_bluetooth) { + if (D) Log.d(TAG, "Stale message"); + break; + } if (s.address != null) { if (D) Log.d(TAG, "Connection lost... retrying"); - s.start_altos_bluetooth(s.address); + s.start_altos_bluetooth(s.address, true); } else { s.stop_altos_bluetooth(true); } @@ -217,7 +238,7 @@ public class TelemetryService extends Service implements LocationListener { */ if (address != null && telemetry_state.connect == TelemetryState.CONNECT_DISCONNECTED) { if (D) Log.d(TAG, "Reconnecting now..."); - start_altos_bluetooth(address); + start_altos_bluetooth(address, false); } } @@ -292,11 +313,17 @@ public class TelemetryService extends Service implements LocationListener { } } - private void start_altos_bluetooth(DeviceAddress address) { + private void start_altos_bluetooth(DeviceAddress address, boolean pause) { // Get the BLuetoothDevice object BluetoothDevice device = bluetooth_adapter.getRemoteDevice(address.address); stop_altos_bluetooth(false); + if (pause) { + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + } + } this.address = address; if (D) Log.d(TAG, String.format("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); altos_bluetooth = new AltosBluetooth(device, handler); @@ -316,7 +343,14 @@ public class TelemetryService extends Service implements LocationListener { } catch (TimeoutException e) { // If this timed out, then we really want to retry it, but // probably safer to just retry the connection from scratch. - handler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); + if (D) Log.d(TAG, "connected timeout"); + if (address != null) { + if (D) Log.d(TAG, "connected timeout, retrying"); + start_altos_bluetooth(address, true); + } else { + handler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); + stop_altos_bluetooth(true); + } return; } @@ -372,7 +406,7 @@ public class TelemetryService extends Service implements LocationListener { DeviceAddress address = AltosDroidPreferences.active_device(); if (address != null) - start_altos_bluetooth(address); + start_altos_bluetooth(address, false); } @Override -- cgit v1.2.3 From 4862bec43b29264c361950700f935604f41b840b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 12:33:36 -0800 Subject: doc: Update telemetry docs to include new packet formats Add TeleMega TeleMetrum v2 and companion data packet formats. List which radio parts each product uses. Document modulation parameters for new data rates. Signed-off-by: Keith Packard --- doc/telemetry.xsl | 499 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 459 insertions(+), 40 deletions(-) diff --git a/doc/telemetry.xsl b/doc/telemetry.xsl index e4101507..2e0b3ea1 100644 --- a/doc/telemetry.xsl +++ b/doc/telemetry.xsl @@ -110,7 +110,7 @@
- Sensor Data + TeleMetrum v1.x, TeleMini and TeleNano Sensor Data @@ -124,7 +124,7 @@ 0x01 - TeleMetrum Sensor Data + TeleMetrum v1.x Sensor Data 0x02 @@ -138,7 +138,7 @@ - TeleMetrum, TeleMini and TeleNano share this same packet + TeleMetrum v1.x, TeleMini and TeleNano share this same packet format for sensor data. Each uses a distinct packet type so that the receiver knows which data values are valid and which are undefined. @@ -213,6 +213,316 @@
+
+ TeleMega Sensor Data + + + + + + + Type + Description + + + + + 0x08 + TeleMega IMU Sensor Data + + + 0x09 + TeleMega Kalman and Voltage Data + + + + + + TeleMega has a lot of sensors, and so it splits the sensor + data into two packets. The raw IMU data are sent more often; + the voltage values don't change very fast, and the Kalman + values can be reconstructed from the IMU data. + + + IMU Sensor Data packets are transmitted once per second on the + ground, 10 times per second during ascent and once per second + during descent and landing + + + Kalman and Voltage Data packets are transmitted once per second on the + ground, 5 times per second during ascent and once per second + during descent and landing + + + The high-g accelerometer is reported separately from the data + for the 9-axis IMU (accel/gyro/mag). The 9-axis IMU is mounted + so that the X axis is "across" the board (along the short + axis0, the Y axis is "along" the board (along the long axis, + with the high-g accelerometer) and the Z axis is "through" the + board (perpendicular to the board). Rotation measurements are + around the respective axis, so Y rotation measures the spin + rate of the rocket while X and Z rotation measure the tilt + rate. + + + The overall tilt angle of the rocket is computed by first + measuring the orientation of the rocket on the pad using the 3 + axis accelerometer, and then integrating the overall tilt rate + from the 3 axis gyroscope to compute the total orientation + change of the airframe since liftoff. + + + TeleMega IMU Sensor Packet Contents + + + + + + + + Offset + Data Type + Name + Description + + + + + 5uint8_torientAngle from vertical in degrees + + + 6int16_taccelHigh G accelerometer + + + 8int32_tprespressure (Pa * 10) + + + 12int16_ttemptemperature (°C * 100) + + + 14int16_taccel_xX axis acceleration (across) + + + 16int16_taccel_yY axis acceleration (along) + + + 18int16_taccel_zZ axis acceleration (through) + + + 20int16_tgyro_xX axis rotation (across) + + + 22int16_tgyro_yY axis rotation (along) + + + 24int16_tgyro_zZ axis rotation (through) + + + 26int16_tmag_xX field strength (across) + + + 28int16_tmag_yY field strength (along) + + + 30int16_tmag_zZ field strength (through) + + + 32 + + + +
+ + TeleMega Kalman and Voltage Data Packet Contents + + + + + + + + Offset + Data Type + Name + Description + + + + + 5uint8_tstateFlight state + + + 6int16_tv_battbattery voltage + + + 8int16_tv_pyropyro battery voltage + + + 10int8_t[6]sensepyro continuity sense + + + 16int32_tground_presAverage barometer reading on ground + + + 20int16_tground_accelAverage accelerometer reading on ground + + + 22int16_taccel_plus_gAccel calibration at +1g + + + 24int16_taccel_minus_gAccel calibration at -1g + + + 26int16_taccelerationm/s² * 16 + + + 28int16_tspeedm/s * 16 + + + 30int16_theightm + + + 32 + + + +
+
+
+ TeleMetrum v2 Sensor Data + + + + + + + Type + Description + + + + + 0x0A + TeleMetrum v2 Sensor Data + + + 0x0B + TeleMetrum v2 Calibration Data + + + + + + TeleMetrum v2 has higher resolution barometric data than + TeleMetrum v1, and so the constant calibration data is + split out into a separate packet. + + + TeleMetrum v2 Sensor Data packets are transmitted once per second on the + ground, 10 times per second during ascent and once per second + during descent and landing + + + TeleMetrum v2 Calibration Data packets are always transmitted once per second. + + + TeleMetrum v2 Sensor Packet Contents + + + + + + + + Offset + Data Type + Name + Description + + + + + 5uint8_tstateFlight state + + + 6int16_taccelaccelerometer + + + 8int32_tprespressure sensor (Pa * 10) + + + 12int16_ttemptemperature sensor (°C * 100) + + + + 14int16_taccelerationm/s² * 16 + + + 16int16_tspeedm/s * 16 + + + 18int16_theightm + + + + 20int16_tv_battbattery voltage + + + 22int16_tsense_ddrogue continuity sense + + + 24int16_tsense_mmain continuity sense + + + 26pad[6]pad bytes + + + 32 + + + +
+ + TeleMetrum v2 Calibration Data Packet Contents + + + + + + + + Offset + Data Type + Name + Description + + + + + 5pad[3]pad bytes + + + 8int32_tground_presAverage barometer reading on ground + + + 12int16_tground_accelAverage accelerometer reading on ground + + + 14int16_taccel_plus_gAccel calibration at +1g + + + 16int16_taccel_minus_gAccel calibration at -1g + + + 18pad[14]pad bytes + + + 32 + + + +
+
Configuration Data @@ -315,7 +625,7 @@ This packet provides all of the information available from the - Venus SkyTraq GPS receiver—position, time, speed and precision + GPS receiver—position, time, speed and precision estimates. @@ -604,62 +914,169 @@
+
+ Companion Data Data + + + + + + + Type + Description + + + + + 0x07 + Companion Data Data + + + + + + When a companion board is attached to TeleMega or TeleMetrum, + it can provide telemetry data to be included in the + downlink. The companion board can provide up to 12 16-bit data + values. + + + The companion board itself specifies the transmission rate. On + the ground and during descent, that rate is limited to one + packet per second. During ascent, that rate is limited to 10 + packets per second. + + + Companion Data Contents + + + + + + + + Offset + Data Type + Name + Description + + + + + 5uint8_tboard_id + Type of companion board attached + + + 6uint8_tupdate_period + How often telemetry is sent, in 1/100ths of a second + + + 7uint8_tchannels + Number of data channels supplied + + + 8uint16_t[12]companion_data + Up to 12 channels of 16-bit companion data + + + 32 + + + +
+
Data Transmission - Altus Metrum devices use the Texas Instruments CC1111 - microcontroller which includes an integrated sub-GHz digital - transceiver. This transceiver is used to both transmit and - receive the telemetry packets. This section discusses what - modulation scheme is used and how this device is configured. + Altus Metrum devices use Texas Instruments sub-GHz digital radio + products. Ground stations use parts with HW FEC while some + flight computers perform FEC in software. TeleGPS is + transmit-only. + + Altus Metrum Radio Parts + + + + + + + Part Number + Description + Used in + + + + + CC111110mW transceiver with integrated SoC + TeleDongle v0.2, TeleBT v1.0, TeleMetrum v1.x, TeleMini + + + CC112035mW transceiver with SW FEC + TeleMetrum v2, TeleMega + + + CC120035mW transceiver with HW FEC + TeleDongle v3.0, TeleBT v3.0 + + + CC115L14mW transmitter with SW FEC + TeleGPS + + + +
Modulation Scheme Texas Instruments provides a tool for computing modulation parameters given a desired modulation format and basic bit - rate. For AltOS, the basic bit rate was specified as 38 kBaud, - resulting in the following signal parmeters: + rate. + + While we might like to use something with better low-signal + performance like BPSK, the radios we use don't support that, + but do support Gaussian frequency shift keying (GFSK). Regular + frequency shift keying (FSK) encodes the signal by switching + the carrier between two frequencies. The Gaussian version is + essentially the same, but the shift between frequencies gently + follows a gaussian curve, rather than switching + immediately. This tames the bandwidth of the signal without + affecting the ability to transmit data. + + For AltOS, there are three available bit rates, 38.4kBaud, + 9.6kBaud and 2.4kBaud resulting in the following signal + parmeters: + Modulation Scheme - - - + + + - Parameter - Value - Description + Rate + Deviation + Receiver Bandwidth - Modulation - GFSK - Gaussian Frequency Shift Keying - - - Deviation - 20.507812 kHz - Frequency modulation - - - Data rate - 38.360596 kBaud - Raw bit rate + 38.4kBaud + 20.5kHz + 100kHz - RX Filter Bandwidth - 93.75 kHz - Receiver Band pass filter bandwidth + 9.6kBaud + 5.125kHz + 25kHz - IF Frequency - 140.62 kHz - Receiver intermediate frequency + 2.4kBaud + 1.5kHz + 5kHz @@ -668,10 +1085,12 @@
Error Correction - The cc1111 provides forward error correction in hardware, - which AltOS uses to improve reception of weak signals. The - overall effect of this is to halve the available bandwidth for - data from 38 kBaud to 19 kBaud. + The cc1111 and cc1200 provide forward error correction in + hardware; on the cc1120 and cc115l that's done in + software. AltOS uses this to improve reception of weak + signals. As it's a rate 1/2 encoding, each bit of data takes + two bits when transmitted, so the effective data rate is half + of the raw transmitted bit rate.
Error Correction -- cgit v1.2.3 From f3406f38d71d0c9b55c9a3ae2356a778328509a9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 12:36:57 -0800 Subject: altos: Add .gitignore for chaoskey Signed-off-by: Keith Packard --- src/chaoskey-v0.1/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/chaoskey-v0.1/.gitignore diff --git a/src/chaoskey-v0.1/.gitignore b/src/chaoskey-v0.1/.gitignore new file mode 100644 index 00000000..b0adba26 --- /dev/null +++ b/src/chaoskey-v0.1/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +chaoskey-* -- cgit v1.2.3 From 601f33f5e2f833fed9ab10b24a9df91905d7f766 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 12:38:08 -0800 Subject: altos: Build chaoskey by default Signed-off-by: Keith Packard --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 05e99c7f..d4c8a86f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -40,7 +40,8 @@ ARMM3DIRS=\ telebt-v3.0 telebt-v3.0/flash-loader ARMM0DIRS=\ - easymini-v1.0 easymini-v1.0/flash-loader + easymini-v1.0 easymini-v1.0/flash-loader \ + chaoskey-v0.1 chaoskey-v0.1/flash-loader AVRDIRS=\ telescience-v0.1 telescience-pwm micropeak nanopeak-v0.1 microkite -- cgit v1.2.3 From 4e53a5da5a8921829a3bb290e7c051950a66ab75 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 16:40:30 -0800 Subject: altos: Add makefile for chaoskey flash loader Signed-off-by: Keith Packard --- src/chaoskey-v0.1/flash-loader/.gitignore | 2 +- src/chaoskey-v0.1/flash-loader/Makefile | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/chaoskey-v0.1/flash-loader/Makefile diff --git a/src/chaoskey-v0.1/flash-loader/.gitignore b/src/chaoskey-v0.1/flash-loader/.gitignore index 32dbbbcf..a60a4945 100644 --- a/src/chaoskey-v0.1/flash-loader/.gitignore +++ b/src/chaoskey-v0.1/flash-loader/.gitignore @@ -1,2 +1,2 @@ ao_product.h -usbtrng* +chaoskey* diff --git a/src/chaoskey-v0.1/flash-loader/Makefile b/src/chaoskey-v0.1/flash-loader/Makefile new file mode 100644 index 00000000..4f61a240 --- /dev/null +++ b/src/chaoskey-v0.1/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=chaoskey-v0.1 +include $(TOPDIR)/stmf0/Makefile-flash.defs -- cgit v1.2.3 From dec8de9c642fea1df924a667a4779a6c6c8c3453 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Mar 2015 16:53:58 -0800 Subject: altos/stmf0: Need ao_exti.h for pin configuration Flash loader uses pin configuration to set up GPIOs for boot selection Signed-off-by: Keith Packard --- src/stmf0/ao_exti.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/stmf0/ao_exti.h diff --git a/src/stmf0/ao_exti.h b/src/stmf0/ao_exti.h new file mode 100644 index 00000000..ebea224d --- /dev/null +++ b/src/stmf0/ao_exti.h @@ -0,0 +1,48 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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_EXTI_H_ +#define _AO_EXTI_H_ + +#define AO_EXTI_MODE_RISING 1 +#define AO_EXTI_MODE_FALLING 2 +#define AO_EXTI_MODE_PULL_UP 4 +#define AO_EXTI_MODE_PULL_DOWN 8 +#define AO_EXTI_PRIORITY_LOW 16 +#define AO_EXTI_PRIORITY_MED 0 +#define AO_EXTI_PRIORITY_HIGH 32 +#define AO_EXTI_PIN_NOCONFIGURE 64 + +void +ao_exti_setup(struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback)()); + +void +ao_exti_set_mode(struct stm_gpio *gpio, uint8_t pin, uint8_t mode); + +void +ao_exti_set_callback(struct stm_gpio *gpio, uint8_t pin, void (*callback)()); + +void +ao_exti_enable(struct stm_gpio *gpio, uint8_t pin); + +void +ao_exti_disable(struct stm_gpio *gpio, uint8_t pin); + +void +ao_exti_init(void); + +#endif /* _AO_EXTI_H_ */ -- cgit v1.2.3 From 2c4ebe9b4b392531cd1a5bbafc4ddc38a9391af5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Mar 2015 09:29:52 -0600 Subject: altosui: Add map to MonitorIdle display Nice to be able to verify that maps are working by using this mode, instead of needing to use flight monitoring. Signed-off-by: Keith Packard --- altosui/AltosIdleMonitorUI.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 204d81ed..88243c5d 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -35,9 +35,11 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl AltosFlightStatus flightStatus; AltosIgnitor ignitor; AltosIdleMonitor thread; + AltosUIMap sitemap; int serial; boolean remote; boolean has_ignitor; + boolean has_map; void stop_display() { if (thread != null) { @@ -83,11 +85,26 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl has_ignitor = false; } } + if (state.gps != null && state.gps.connected) { + if (!has_map) { + pane.add("Site Map", sitemap); + has_map = true; + } + } else { + if (has_map) { + pane.remove(sitemap); + has_map = false; + } + } + // try { pad.show(state, listener_state); flightStatus.show(state, listener_state); flightInfo.show(state, listener_state); - ignitor.show(state, listener_state); + if (has_ignitor) + ignitor.show(state, listener_state); + if (has_map) + sitemap.show(state, listener_state); // } catch (Exception e) { // System.out.print("Show exception " + e); // } @@ -261,6 +278,8 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl ignitor = new AltosIgnitor(); + sitemap = new AltosUIMap(); + /* Make the tabbed pane use the rest of the window space */ bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH)); -- cgit v1.2.3 From 46f2a759dc21ebf3a7bf7e0566903fc1e7364719 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Mar 2015 09:30:53 -0600 Subject: ao-tools/ao-mega: Clean up formatting of pyro status messages There was an extra newline and missing space. Signed-off-by: Keith Packard --- ao-tools/ao-mega/ao-mega.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ao-tools/ao-mega/ao-mega.c b/ao-tools/ao-mega/ao-mega.c index 523229e6..cfb58bb4 100644 --- a/ao-tools/ao-mega/ao-mega.c +++ b/ao-tools/ao-mega/ao-mega.c @@ -85,7 +85,7 @@ main (int argc, char **argv) if (cc_mega_parse(line, &log)) { if (log.is_config) { - printf ("kind %d\n", log.u.config_int.kind); + printf ("config %2d %s", log.u.config_int.kind, line); } else { printf ("tick %5d ", log.tick); switch (log.type) { @@ -126,8 +126,7 @@ main (int argc, char **argv) printf (" s%d %6d", j, log.u.volt.sense[j]); } - printf ("pyro %04x\n", log.u.volt.pyro); - printf ("\n"); + printf (" pyro %04x\n", log.u.volt.pyro); break; default: printf ("type %c\n", log.type, log.tick); -- cgit v1.2.3 From f92be7e22150b2de4c899e687d3bbfc1eb842f9e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Mar 2015 09:32:20 -0600 Subject: altos/test: Make aprs test code compile again Adding the compressed/uncompressed config option broke the APRS test harness. Signed-off-by: Keith Packard --- src/drivers/ao_aprs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index 2e977612..a8016673 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -719,7 +719,13 @@ static int tncPositionPacket(void) buf = tncBuffer; +#ifdef AO_APRS_TEST +#define AO_APRS_FORMAT_COMPRESSED 0 +#define AO_APRS_FORMAT_UNCOMPRESSED 1 + switch (AO_APRS_FORMAT_COMPRESSED) { +#else switch (ao_config.aprs_format) { +#endif case AO_APRS_FORMAT_COMPRESSED: default: { -- cgit v1.2.3 From ce99807ef942de54a3f934d321baf3c3d26442bb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Mar 2015 09:34:01 -0600 Subject: altos/test: Support old telemega eeprom file formats in ao_flight_test The old eeprom format used different stoarge for the accel calibration data, which doesn't matter to this code, but the change in the format value does. Signed-off-by: Keith Packard --- src/test/ao_flight_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index fbbc4bd9..f71c3052 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -554,9 +554,9 @@ ao_insert(void) ao_quaternion_rotate(&ao_out, &ao_x, &ao_rotation); +#if 0 int out = floor (atan2(ao_out.y, ao_out.x) * 180 / M_PI); -#if 0 printf ("%7.2f state %-8.8s height %8.4f tilt %4d rot %4d mag_tilt %4d mag_rot %4d\n", time, ao_state_names[ao_flight_state], @@ -717,7 +717,7 @@ ao_sleep(void *wchan) break; } #if TELEMEGA - if (log_format == AO_LOG_FORMAT_TELEMEGA && nword == 30 && strlen(words[0]) == 1) { + if ((log_format == AO_LOG_FORMAT_TELEMEGA_OLD || log_format == AO_LOG_FORMAT_TELEMEGA) && nword == 30 && strlen(words[0]) == 1) { int i; struct ao_ms5607_value value; @@ -895,7 +895,6 @@ ao_sleep(void *wchan) ao_config.accel_zero_along = atoi(words[3]); ao_config.accel_zero_across = atoi(words[5]); ao_config.accel_zero_through = atoi(words[7]); - printf ("%d %d %d\n", ao_config.accel_zero_along, ao_config.accel_zero_across, ao_config.accel_zero_through); #endif } else if (nword >= 4 && strcmp(words[0], "Main") == 0) { ao_config.main_deploy = atoi(words[2]); -- cgit v1.2.3 From fce4e6926de7cb5ef6ea64a8db134c442b86153b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Mar 2015 09:35:02 -0600 Subject: ao-tools/ao-list: Show devices that have no TTY chaoskey doesn't advertise itself as a modem, so the kernel doesn't allocate a tty device. Signed-off-by: Keith Packard --- ao-tools/ao-list/ao-list.c | 4 ++-- ao-tools/lib/cc-usbdev.c | 6 +++--- ao-tools/lib/cc.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ao-tools/ao-list/ao-list.c b/ao-tools/ao-list/ao-list.c index c4b43d8f..4c065e79 100644 --- a/ao-tools/ao-list/ao-list.c +++ b/ao-tools/ao-list/ao-list.c @@ -28,12 +28,12 @@ main (int argc, char **argv) struct cc_usbdev *dev; int i; - devs = cc_usbdevs_scan(); + devs = cc_usbdevs_scan(TRUE); if (devs) { for (i = 0; i < devs->ndev; i++) { dev = devs->dev[i]; printf ("%-20.20s %6d %s\n", - dev->product, dev->serial, dev->tty); + dev->product, dev->serial, dev->tty ? dev->tty : "(none)"); } cc_usbdevs_free(devs); } diff --git a/ao-tools/lib/cc-usbdev.c b/ao-tools/lib/cc-usbdev.c index 95bfa244..6c3ba591 100644 --- a/ao-tools/lib/cc-usbdev.c +++ b/ao-tools/lib/cc-usbdev.c @@ -219,7 +219,7 @@ is_am(int idVendor, int idProduct) { } struct cc_usbdevs * -cc_usbdevs_scan(void) +cc_usbdevs_scan(int non_tty) { int e; struct dirent **ents; @@ -241,7 +241,7 @@ cc_usbdevs_scan(void) dir = cc_fullname(USB_DEVICES, ents[e]->d_name); dev = usb_scan_device(dir); free(dir); - if (is_am(dev->idVendor, dev->idProduct) && dev->tty) { + if (is_am(dev->idVendor, dev->idProduct) && (non_tty || dev->tty)) { if (devs->dev) devs->dev = realloc(devs->dev, (devs->ndev + 1) * sizeof (struct usbdev *)); @@ -274,7 +274,7 @@ match_dev(char *product, int serial) int i; char *tty = NULL; - devs = cc_usbdevs_scan(); + devs = cc_usbdevs_scan(FALSE); if (!devs) return NULL; for (i = 0; i < devs->ndev; i++) { diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index bff4b2c9..ff95e4fc 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -50,7 +50,7 @@ void cc_usbdevs_free(struct cc_usbdevs *usbdevs); struct cc_usbdevs * -cc_usbdevs_scan(void); +cc_usbdevs_scan(int non_tty); char * cc_usbdevs_find_by_arg(char *arg, char *default_product); -- cgit v1.2.3 From c3321bd9f73c89686fe983a8d99f4e54fa91550e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Mar 2015 01:11:33 -0700 Subject: altos: Add the ability to configure a different USB vendor ID ChaosKey will use an OpenMoko vid/pid, so we need the ability to configure a different USB vendor ID for each product. Signed-off-by: Keith Packard --- src/kernel/ao_product.c | 2 +- src/util/ao-make-product.5c | 49 +++++++++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/kernel/ao_product.c b/src/kernel/ao_product.c index baee8dd6..c711a4d2 100644 --- a/src/kernel/ao_product.c +++ b/src/kernel/ao_product.c @@ -49,7 +49,7 @@ AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] = 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ AO_USB_CONTROL_SIZE, /* bMaxPacketSize */ - LE_WORD(0xFFFE), /* idVendor */ + LE_WORD(AO_idVendor_NUMBER), /* idVendor */ LE_WORD(AO_idProduct_NUMBER), /* idProduct */ LE_WORD(0x0100), /* bcdDevice */ 0x01, /* iManufacturer */ diff --git a/src/util/ao-make-product.5c b/src/util/ao-make-product.5c index 5f2eb8e8..3ab8d16e 100644 --- a/src/util/ao-make-product.5c +++ b/src/util/ao-make-product.5c @@ -1,54 +1,58 @@ -#!/bin/sh +#!/usr/bin/nickle autoimport ParseArgs; +file out = stdout; + void write_ucs2(string a, string description) { int len = String::length(a); - printf("/* %s */\n", description); - printf("#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2); - printf("#define AO_%s_STRING \"%s\"\n", description, a); - printf("#define AO_%s_UCS2", description); + File::fprintf(out, "/* %s */\n", description); + File::fprintf(out, "#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2); + File::fprintf(out, "#define AO_%s_STRING \"%s\"\n", description, a); + File::fprintf(out, "#define AO_%s_UCS2", description); for (int i = 0; i < len; i++) { int c = a[i]; if (i > 0) - printf(","); + File::fprintf(out, ","); if (0x20 <= c && c < 128) - printf(" '%c', 0", c); + File::fprintf(out, " '%c', 0", c); else - printf(" LE_WORD(0x%04x),", c); + File::fprintf(out, " LE_WORD(0x%04x),", c); } - printf("\n\n"); + File::fprintf(out, "\n\n"); } void write_string(string a, string description) { - printf ("/* %s */\n", description); - printf ("#define AO_%s_STRING \"%s\"\n", description, a); + File::fprintf(out, "/* %s */\n", description); + File::fprintf(out, "#define AO_%s_STRING \"%s\"\n", description, a); } void write_int(int a, string description) { - printf ("/* %s */\n", description); - printf ("#define AO_%s_NUMBER %d\n\n", description, a); + File::fprintf(out, "/* %s */\n", description); + File::fprintf(out, "#define AO_%s_NUMBER %d\n\n", description, a); } void write_hex(int a, string description) { - printf ("/* %s */\n", description); - printf ("#define AO_%s_NUMBER 0x%04x\n\n", description, a); + File::fprintf(out, "/* %s */\n", description); + File::fprintf(out, "#define AO_%s_NUMBER 0x%04x\n\n", description, a); } string manufacturer = "altusmetrum.org"; string product = "TeleMetrum"; string version = "0.0"; +string output = ""; int serial = 1; int user_argind = 0; +int id_vendor = 0xfffe; int id_product = 0x000a; argdesc argd = { @@ -65,6 +69,12 @@ argdesc argd = { .name = "product", .expr_name = "prod", .desc = "Product name." }, + { + .var = { .arg_int = &id_vendor }, + .abbr = 'V', + .name = "id_vendor", + .expr_name = "id_v", + .desc = "Vendor ID." }, { .var = { .arg_int = &id_product }, .abbr = 'i', @@ -83,6 +93,12 @@ argdesc argd = { .name = "version", .expr_name = "string", .desc = "Program version." }, + { + .var = { .arg_string = &output }, + .abbr = 'o', + .name = "output", + .expr_name = "out", + .desc = "Output file." }, }, .prog_name = "usb descriptors", }; @@ -92,11 +108,14 @@ main() { string[dim(argv)-1] nargv = {[n] = argv[n+1]}; parseargs(&argd, &nargv); + if (output != "") + out = File::open(output, "w"); write_ucs2(manufacturer, "iManufacturer"); write_ucs2(product, "iProduct"); write_ucs2(sprintf("%06d", serial), "iSerial"); write_int(serial, "iSerial"); write_hex(id_product, "idProduct"); + write_hex(id_vendor, "idVendor"); write_string(version, "iVersion"); } -- cgit v1.2.3 From 43b4044dc71d44cb25be6397b4d66fd792580eed Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Mar 2015 01:12:24 -0700 Subject: altos/chaoskey: Set USB VID/PID to 0x1d50/0x60c6 These are allocated from the OpenMoko USB vendor ID page and offer a more 'official' number than from using the 0xfffe space. Signed-off-by: Keith Packard --- src/chaoskey-v0.1/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chaoskey-v0.1/Makefile b/src/chaoskey-v0.1/Makefile index bf4b3ca6..ac4a6788 100644 --- a/src/chaoskey-v0.1/Makefile +++ b/src/chaoskey-v0.1/Makefile @@ -37,7 +37,8 @@ ALTOS_SRC = \ PRODUCT=ChaosKey-v0.1 PRODUCT_DEF=-DCHAOSKEY_V_0_1 -IDPRODUCT=0x0028 +IDVENDOR=0x1d50 +IDPRODUCT=0x60c6 CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -g -Os @@ -54,7 +55,7 @@ $(PROG): Makefile $(OBJ) altos.ld $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -V $(IDVENDOR) -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) -o $@ $(OBJ): $(INC) -- cgit v1.2.3 From b1b69c8b73cbffb56c688f6a968d144b642cdff2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Mar 2015 15:09:20 -0700 Subject: altos/stmf0: Have fast ADC ring buffer code use wrap-around Instead of requiring that the whole set of returned values fit precisely in the ring, allow for wrap-around so that we can fetch an odd number of ADC values. The previous version required that the fetch amount always be a factor of the ADC buffer size. Signed-off-by: Keith Packard --- src/drivers/ao_trng.c | 11 +++++++---- src/drivers/ao_trng_send.c | 11 +++++++---- src/stmf0/ao_adc_fast.c | 3 ++- src/stmf0/ao_adc_fast.h | 41 +++++++++++++++++++++-------------------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/drivers/ao_trng.c b/src/drivers/ao_trng.c index db742928..e69cd30b 100644 --- a/src/drivers/ao_trng.c +++ b/src/drivers/ao_trng.c @@ -29,7 +29,8 @@ ao_trng_fetch(void) int usb_buf_id; uint16_t i; uint16_t *buf; - uint32_t *rnd; + uint16_t t; + uint32_t *rnd = (uint32_t *) ao_adc_ring; if (!buffer[0]) { buffer[0] = ao_usb_alloc(); @@ -50,10 +51,12 @@ ao_trng_fetch(void) ao_led_on(AO_LED_TRNG_READ); while (count--) { - rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */ + t = ao_adc_get(AO_USB_IN_SIZE) >> 1; /* one 16-bit value per output byte */ buf = buffer[usb_buf_id]; - for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) - *buf++ = ao_crc_in_32_out_16(*rnd++); + for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) { + *buf++ = ao_crc_in_32_out_16(rnd[t]); + t = (t + 1) & ((AO_ADC_RING_SIZE>>1) - 1); + } ao_adc_ack(AO_USB_IN_SIZE); ao_led_toggle(AO_LED_TRNG_READ|AO_LED_TRNG_WRITE); ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE); diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c index 34a8a981..bac6035c 100644 --- a/src/drivers/ao_trng_send.c +++ b/src/drivers/ao_trng_send.c @@ -27,7 +27,8 @@ ao_trng_send(void) int usb_buf_id; uint16_t i; uint16_t *buf; - uint32_t *rnd; + uint16_t t; + uint32_t *rnd = (uint32_t *) ao_adc_ring; if (!buffer[0]) { buffer[0] = ao_usb_alloc(); @@ -42,10 +43,12 @@ ao_trng_send(void) for (;;) { ao_led_on(AO_LED_TRNG_ACTIVE); - rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */ + t = ao_adc_get(AO_USB_IN_SIZE) >> 1; /* one 16-bit value per output byte */ buf = buffer[usb_buf_id]; - for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) - *buf++ = ao_crc_in_32_out_16(*rnd++); + for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) { + *buf++ = ao_crc_in_32_out_16(rnd[t]); + t = (t + 1) & ((AO_ADC_RING_SIZE>>1) - 1); + } ao_adc_ack(AO_USB_IN_SIZE); ao_led_off(AO_LED_TRNG_ACTIVE); ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE); diff --git a/src/stmf0/ao_adc_fast.c b/src/stmf0/ao_adc_fast.c index 7d2a4fd7..26e6691c 100644 --- a/src/stmf0/ao_adc_fast.c +++ b/src/stmf0/ao_adc_fast.c @@ -23,7 +23,7 @@ uint16_t ao_adc_ring[AO_ADC_RING_SIZE] __attribute__((aligned(4))); /* Maximum number of samples fetched per _ao_adc_start call */ #define AO_ADC_RING_CHUNK (AO_ADC_RING_SIZE >> 1) -uint16_t ao_adc_ring_head, ao_adc_ring_tail; +uint16_t ao_adc_ring_head, ao_adc_ring_remain; uint16_t ao_adc_running; /* @@ -36,6 +36,7 @@ static void ao_adc_dma_done(int index) { (void) index; ao_adc_ring_head += ao_adc_running; + ao_adc_ring_remain += ao_adc_running; if (ao_adc_ring_head == AO_ADC_RING_SIZE) ao_adc_ring_head = 0; ao_adc_running = 0; diff --git a/src/stmf0/ao_adc_fast.h b/src/stmf0/ao_adc_fast.h index ca5f7fb9..c6903e9f 100644 --- a/src/stmf0/ao_adc_fast.h +++ b/src/stmf0/ao_adc_fast.h @@ -31,52 +31,53 @@ extern uint16_t ao_adc_ring[AO_ADC_RING_SIZE]; #define ao_adc_ring_step(pos,inc) (((pos) + (inc)) & (AO_ADC_RING_SIZE - 1)) -extern uint16_t ao_adc_ring_head, ao_adc_ring_tail; +extern uint16_t ao_adc_ring_head, ao_adc_ring_remain; extern uint16_t ao_adc_running; -void -_ao_adc_start(void); - +/* + * Place to start fetching values from + */ static inline uint16_t -_ao_adc_remain(void) +ao_adc_ring_tail(void) { - if (ao_adc_ring_tail > ao_adc_ring_head) - return AO_ADC_RING_SIZE - ao_adc_ring_tail; - return ao_adc_ring_head - ao_adc_ring_tail; + return (ao_adc_ring_head - ao_adc_ring_remain) & (AO_ADC_RING_SIZE - 1); } +void +_ao_adc_start(void); + +/* + * Space available to write ADC values into + */ static inline uint16_t _ao_adc_space(void) { - if (ao_adc_ring_head >= ao_adc_ring_tail) + /* Free to end of buffer? */ + if (ao_adc_ring_remain <= ao_adc_ring_head) return AO_ADC_RING_SIZE - ao_adc_ring_head; - return ao_adc_ring_tail - ao_adc_ring_head; + + /* no, return just the unused entries beyond head */ + return AO_ADC_RING_SIZE - ao_adc_ring_remain; } -static inline uint16_t * +static inline uint16_t ao_adc_get(uint16_t n) { - if (ao_adc_ring_tail + n > AO_ADC_RING_SIZE) - ao_panic(AO_PANIC_ADC); ao_arch_block_interrupts(); - while (_ao_adc_remain() < n) { + while (ao_adc_ring_remain < n) { if (!ao_adc_running) _ao_adc_start(); ao_sleep(&ao_adc_ring_head); } ao_arch_release_interrupts(); - return &ao_adc_ring[ao_adc_ring_tail]; + return ao_adc_ring_tail(); } static inline void ao_adc_ack(uint16_t n) { - if (ao_adc_ring_tail + n > AO_ADC_RING_SIZE) - ao_panic(AO_PANIC_ADC); ao_arch_block_interrupts(); - ao_adc_ring_tail += n; - if (ao_adc_ring_tail == AO_ADC_RING_SIZE) - ao_adc_ring_tail = 0; + ao_adc_ring_remain -= n; if (!ao_adc_running) _ao_adc_start(); ao_arch_release_interrupts(); -- cgit v1.2.3 From fe76229618643f0af7eae965e7a8fc6c70410d27 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 29 Mar 2015 12:08:42 -0700 Subject: icon: Convert windows stub into launcher program Instead of an empty windows stub that exists only to hold icons, add useful code that allows it to find and run the related java application. This also adds more resources to that application to provide more information to Windows too. Signed-off-by: Keith Packard --- icon/Makefile.am | 11 ++- icon/make-rc | 53 ++++++++++++++ icon/windows-stub.c | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 263 insertions(+), 4 deletions(-) create mode 100755 icon/make-rc diff --git a/icon/Makefile.am b/icon/Makefile.am index c08e9236..af238ac4 100644 --- a/icon/Makefile.am +++ b/icon/Makefile.am @@ -150,14 +150,21 @@ SUFFIXES=.svg .build .icns .ico .rc .o .exe icotool -c -o $@ $(shell for i in $(WIN_RES); do echo $*-$$i.png; done) .ico.rc: - echo '101 ICON "$*.ico"' > $@ + ./make-rc "$*" $(VERSION) > $@ MINGCC32=i686-w64-mingw32-gcc MINGWINDRES=i686-w64-mingw32-windres +MINGFLAGS=-Wall -DWINDOWS -mwindows +MINGLIBS=-lshlwapi .rc.o: $(MINGWINDRES) $*.rc $@ .o.exe: - $(MINGCC32) -o $@ windows-stub.c $*.o + $(MINGCC32) -o $@ $(MINGFLAGS) windows-stub.o $*.o $(MINGLIBS) + +$(EXE_FILES): windows-stub.o make-rc + +windows-stub.o: windows-stub.c + $(MINGCC32) -c $(MINGFLAGS) windows-stub.c diff --git a/icon/make-rc b/icon/make-rc new file mode 100755 index 00000000..de647278 --- /dev/null +++ b/icon/make-rc @@ -0,0 +1,53 @@ +#!/bin/sh + +COMPANY="Altus Metrum, LLC" +PRODUCT="Altus Metrum" + +case "$1" in + *altosui*) + PRODUCT="AltosUI" + ;; + *telegps*) + PRODUCT="TeleGPS" + ;; + *micropeak*) + PRODUCT="MicroPeak" + ;; +esac + +VERSION="$2" +VERSION_COMMA=`echo "$VERSION" | sed 's/\./,/g'` +INTERNAL_NAME=`basename $1` +EXE_NAME="$INTERNAL_NAME".exe +YEAR=`date +%Y` + +cat < + * + * 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. + */ + +/* A windows stub program to launch a java program with suitable parameters + * + * Given that the name of this exe is altusmetrum-foo.exe living in directory bar, and + * that it was run with 'args' extra command line parameters, run: + * + * javaw.exe -Djava.library.path="bar" -jar "bar/foo-fat.jar" args + */ + +#define _UNICODE +#define UNICODE +#include +#include +#include +#include +#include +#include + +/* Concatenate a list of strings together + */ +static LPTSTR +wcsbuild(LPTSTR first, ...) +{ + va_list args; + int len; + LPTSTR buf; + LPTSTR arg; + + buf = wcsdup(first); + va_start(args, first); + while ((arg = va_arg(args, LPTSTR)) != NULL) { + len = wcslen(buf) + wcslen(arg) + 1; + buf = realloc(buf, len * sizeof (wchar_t)); + wcscat(buf, arg); + } + va_end(args); + return buf; +} + +/* Quote a single string, taking care to escape embedded quote and + * backslashes within + */ +static LPTSTR +quote_arg(LPTSTR arg) +{ + LPTSTR result; + LPTSTR in, out; + int out_len = 3; /* quotes and terminating null */ + + /* Find quote and backslashes */ + for (in = arg; *in; in++) { + switch (*in) { + case '"': + case '\\': + out_len += 2; + break; + default: + out_len++; + break; + } + } + + result = malloc ((out_len + 1) * sizeof (wchar_t)); + out = result; + *out++ = '"'; + for (in = arg; *in; in++) { + switch (*in) { + case '"': + case '\\': + *out++ = '\\'; + break; + } + *out++ = *in; + } + *out++ = '"'; + *out++ = '\0'; + return result; +} + +/* Construct a single string from a list of arguments + */ +static LPTSTR +quote_args(LPTSTR *argv, int argc) +{ + LPTSTR result = NULL, arg; + int i; + + result = malloc(1 * sizeof (wchar_t)); + result[0] = '\0'; + for (i = 0; i < argc; i++) { + arg = quote_arg(argv[i]); + result = realloc(result, (wcslen(result) + 1 + wcslen(arg) + 1) * sizeof (wchar_t)); + wcscat(result, L" "); + wcscat(result, arg); + free(arg); + } + return result; +} + +/* Return the directory portion of the provided file + */ +static LPTSTR +get_dir(LPTSTR file) +{ + DWORD len = GetFullPathName(file, 0, NULL, NULL); + LPTSTR full = malloc (len * sizeof (wchar_t)); + GetFullPathName(file, len, full, NULL); + PathRemoveFileSpec(full); + return full; +} + +/* Convert a .exe name into a -fat.jar name, starting + * by computing the complete path name of the source filename + */ +static LPTSTR +make_jar(LPTSTR file) +{ + DWORD len = GetFullPathName(file, 0, NULL, NULL); + LPTSTR full = malloc (len * sizeof (wchar_t)); + LPTSTR base_part; + LPTSTR jar; + LPTSTR dot; + GetFullPathName(file, len, full, &base_part); + static const wchar_t head[] = L"altusmetrum-"; + + if (wcsncmp(base_part, head, wcslen(head)) == 0) + base_part += wcslen(head); + dot = wcsrchr(base_part, '.'); + if (dot) + *dot = '\0'; + jar = wcsdup(base_part); + PathRemoveFileSpec(full); + return wcsbuild(full, L"\\", jar, L"-fat.jar", NULL); +} + +/* Build the complete command line from the pieces + */ +static LPTSTR +make_cmd(LPTSTR dir, LPTSTR jar, LPTSTR quote_args) +{ + LPTSTR quote_dir = quote_arg(dir); + LPTSTR quote_jar = quote_arg(jar); + LPTSTR cmd; + + cmd = wcsbuild(L"javaw.exe -Djava.library.path=", quote_dir, L" -jar ", quote_jar, quote_args, NULL); + free(quote_jar); + free(jar); + free(quote_dir); + return cmd; +} + +int WINAPI +WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line_a, int cmd_show) +{ + STARTUPINFO startup_info; + PROCESS_INFORMATION process_information; + BOOL result; + wchar_t *command_line; + int argc; + LPTSTR *argv = CommandLineToArgvW(GetCommandLine(), &argc); + LPTSTR my_dir; + LPTSTR my_jar; + LPTSTR args = quote_args(argv + 1, argc - 1); + + my_dir = get_dir(argv[0]); + my_jar = make_jar(argv[0]); + command_line = make_cmd(my_dir, my_jar, args); + memset(&startup_info, '\0', sizeof startup_info); + startup_info.cb = sizeof startup_info; + result = CreateProcess(NULL, + command_line, + NULL, + NULL, + FALSE, + CREATE_NO_WINDOW, + NULL, + NULL, + &startup_info, + &process_information); + if (result) { + CloseHandle(process_information.hProcess); + CloseHandle(process_information.hThread); + } + exit(0); +} -- cgit v1.2.3 From 356617a3476e237311b8bbcefd6beda8271b120d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 29 Mar 2015 12:10:47 -0700 Subject: windows: Use new windows stub to launch applications This avoids needing to locate javaw on the system while also making the registry entries less fragile. Signed-off-by: Keith Packard --- altosui/altos-windows.nsi.in | 12 +++++------- micropeak/micropeak-windows.nsi.in | 10 ++++------ telegps/telegps-windows.nsi.in | 12 +++++------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in index 6d4dabfa..2f22a4a3 100644 --- a/altosui/altos-windows.nsi.in +++ b/altosui/altos-windows.nsi.in @@ -103,16 +103,17 @@ Section "${REG_NAME} Application" File "freetts.jar" File "jfreechart.jar" File "jcommon.jar" + File "../icon/${WIN_APP_EXE}" File "*.dll" File "../icon/${WIN_APP_ICON}" - CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "${REG_NAME} Desktop Shortcut" - CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "Firmware" @@ -153,7 +154,6 @@ Section "File Associations" SetOutPath $INSTDIR - File "../icon/${WIN_APP_EXE}" File "../icon/${WIN_TELEM_EXE}" File "../icon/${WIN_EEPROM_EXE}" @@ -165,15 +165,13 @@ Section "File Associations" DeleteRegKey HKCR ".telem\${PROG_ID_EEPROM}" DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_EEPROM}" - SearchPath $1 "javaw.exe" - ; .eeprom elements WriteRegStr HKCR "${PROG_ID_EEPROM}" "" "Altus Metrum Log File" WriteRegStr HKCR "${PROG_ID_EEPROM}" "FriendlyTypeName" "Altus Metrum Log File" WriteRegStr HKCR "${PROG_ID_EEPROM}\CurVer" "" "${PROG_ID_EEPROM}" WriteRegStr HKCR "${PROG_ID_EEPROM}\DefaultIcon" "" '"$INSTDIR\${WIN_EEPROM_EXE}",-101' - WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" "" '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"' + WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" "" '"$INSTDIR\${WIN_APP_EXE}" "%1"' WriteRegStr HKCR ".eeprom" "" "${PROG_ID_EEPROM}" WriteRegStr HKCR ".eeprom" "PerceivedType" "Altus Metrum Log File" @@ -188,7 +186,7 @@ Section "File Associations" WriteRegStr HKCR "${PROG_ID_TELEM}" "FriendlyTypeName" "Altus Metrum Telemetry File" WriteRegStr HKCR "${PROG_ID_TELEM}\CurVer" "" "${PROG_ID_TELEM}" WriteRegStr HKCR "${PROG_ID_TELEM}\DefaultIcon" "" '"$INSTDIR\${WIN_TELEM_EXE}",-101' - WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" "" '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"' + WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" "" '"$INSTDIR\${WIN_APP_EXE}" "%1"' WriteRegStr HKCR ".telem" "" "${PROG_ID_TELEM}" WriteRegStr HKCR ".telem" "PerceivedType" "Altus Metrum Telemetry File" diff --git a/micropeak/micropeak-windows.nsi.in b/micropeak/micropeak-windows.nsi.in index a3779630..e210f8a0 100644 --- a/micropeak/micropeak-windows.nsi.in +++ b/micropeak/micropeak-windows.nsi.in @@ -104,16 +104,17 @@ Section "${REG_NAME} Application" File "altosuilib_@ALTOSUILIB_VERSION@.jar" File "jfreechart.jar" File "jcommon.jar" + File "../icon/${WIN_APP_EXE}" File "*.dll" File "../icon/${WIN_APP_ICON}" - CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "${REG_NAME} Desktop Shortcut" - CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "Documentation" @@ -129,11 +130,8 @@ Section "File Associations" SetOutPath $INSTDIR - File "../icon/${WIN_APP_EXE}" File "../icon/${WIN_MPD_EXE}" - SearchPath $1 "javaw.exe" - ; application elements DeleteRegKey HKCR "${PROG_ID}" @@ -143,7 +141,7 @@ Section "File Associations" WriteRegStr HKCR "${PROG_ID_MPD}" "FriendlyTypeName" "MicroPeak Data File" WriteRegStr HKCR "${PROG_ID_MPD}\CurVer" "" "${PROG_ID_MPD}" WriteRegStr HKCR "${PROG_ID_MPD}\DefaultIcon" "" '"$INSTDIR\${WIN_MPD_EXE}",-101' - WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" "" '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"' + WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" "" '"$INSTDIR\${WIN_APP_EXE}" "%1"' ; .mpd elements diff --git a/telegps/telegps-windows.nsi.in b/telegps/telegps-windows.nsi.in index 44656715..b0b5d6a6 100644 --- a/telegps/telegps-windows.nsi.in +++ b/telegps/telegps-windows.nsi.in @@ -103,16 +103,17 @@ Section "${REG_NAME} Application" File "freetts.jar" File "jfreechart.jar" File "jcommon.jar" + File "../icon/${WIN_APP_EXE}" File "*.dll" File "../icon/${WIN_APP_ICON}" - CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "${REG_NAME} Desktop Shortcut" - CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}" + CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}" SectionEnd Section "TeleGPS, TeleDongle and TeleBT Firmware" @@ -141,7 +142,6 @@ Section "File Associations" SetOutPath $INSTDIR - File "../icon/${WIN_APP_EXE}" File "../icon/${WIN_TELEM_EXE}" File "../icon/${WIN_EEPROM_EXE}" @@ -153,15 +153,13 @@ Section "File Associations" DeleteRegKey HKCR ".telem\${PROG_ID_EEPROM}" DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_EEPROM}" - SearchPath $1 "javaw.exe" - ; .eeprom elements WriteRegStr HKCR "${PROG_ID_EEPROM}" "" "Altus Metrum Log File" WriteRegStr HKCR "${PROG_ID_EEPROM}" "FriendlyTypeName" "Altus Metrum Log File" WriteRegStr HKCR "${PROG_ID_EEPROM}\CurVer" "" "${PROG_ID_EEPROM}" WriteRegStr HKCR "${PROG_ID_EEPROM}\DefaultIcon" "" '"$INSTDIR\${WIN_EEPROM_EXE}",-101' - WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" "" '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"' + WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" "" '"$INSTDIR\${WIN_APP_EXE}" "%1"' WriteRegStr HKCR ".eeprom" "" "${PROG_ID_EEPROM}" WriteRegStr HKCR ".eeprom" "PerceivedType" "Altus Metrum Log File" @@ -176,7 +174,7 @@ Section "File Associations" WriteRegStr HKCR "${PROG_ID_TELEM}" "FriendlyTypeName" "Altus Metrum Telemetry File" WriteRegStr HKCR "${PROG_ID_TELEM}\CurVer" "" "${PROG_ID_TELEM}" WriteRegStr HKCR "${PROG_ID_TELEM}\DefaultIcon" "" '"$INSTDIR\${WIN_TELEM_EXE}",-101' - WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" "" '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"' + WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" "" '"$INSTDIR\${WIN_APP_EXE}" "%1"' WriteRegStr HKCR ".telem" "" "${PROG_ID_TELEM}" WriteRegStr HKCR ".telem" "PerceivedType" "Altus Metrum Telemetry File" -- cgit v1.2.3 From 7bfa8841b65707d629b425b306ec4cc3acfc156c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 27 Apr 2015 21:20:22 -0700 Subject: altosdroid: Add USB support for TeleDongle/TeleBT This lets AltosDroid use a USB-connected receiver as well as Bluetooth devices. Signed-off-by: Keith Packard --- altosdroid/AndroidManifest.xml | 23 +- altosdroid/default.properties | 2 +- altosdroid/project.properties | 2 +- altosdroid/res/values/CustomTheme.xml | 7 + altosdroid/res/xml/device_filter.xml | 6 + .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 178 +++------------- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 156 ++++++++++++-- .../org/altusmetrum/AltosDroid/AltosDroidLink.java | 224 ++++++++++++++++++++ .../src/org/altusmetrum/AltosDroid/AltosUsb.java | 235 +++++++++++++++++++++ .../altusmetrum/AltosDroid/TelemetryReader.java | 2 + .../altusmetrum/AltosDroid/TelemetryService.java | 125 ++++++----- 11 files changed, 733 insertions(+), 227 deletions(-) create mode 100644 altosdroid/res/values/CustomTheme.xml create mode 100644 altosdroid/res/xml/device_filter.xml create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index 19e5a6dc..71c6fb12 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -19,7 +19,7 @@ package="org.altusmetrum.AltosDroid" android:versionCode="6" android:versionName="1.5"> - + @@ -38,18 +38,35 @@ android:protectionLevel="signature"/> + + + android:allowBackup="true" + android:theme="@style/CustomTheme"> + android:configChanges="orientation|keyboardHidden" + android:launchMode="singleTop"> + + + + + + + + + + + + diff --git a/altosdroid/res/xml/device_filter.xml b/altosdroid/res/xml/device_filter.xml new file mode 100644 index 00000000..84b09c06 --- /dev/null +++ b/altosdroid/res/xml/device_filter.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index da75ffdd..32b7a65b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -33,16 +33,13 @@ import android.util.Log; import org.altusmetrum.altoslib_6.*; -public class AltosBluetooth extends AltosLink { +public class AltosBluetooth extends AltosDroidLink { // Debugging private static final String TAG = "AltosBluetooth"; private static final boolean D = true; private ConnectThread connect_thread = null; - private Thread input_thread = null; - - private Handler handler; private BluetoothAdapter adapter; private BluetoothSocket socket; @@ -51,6 +48,7 @@ public class AltosBluetooth extends AltosLink { // Constructor public AltosBluetooth(BluetoothDevice device, Handler handler) { + super(handler); // set_debug(D); adapter = BluetoothAdapter.getDefaultAdapter(); this.handler = handler; @@ -60,16 +58,7 @@ public class AltosBluetooth extends AltosLink { connect_thread.start(); } - private Object closed_lock = new Object(); - private boolean closed = false; - - private boolean closed() { - synchronized(closed_lock) { - return closed; - } - } - - private void connected() { + void connected() { if (closed()) { if (D) Log.d(TAG, "connected after closed"); return; @@ -80,24 +69,11 @@ public class AltosBluetooth extends AltosLink { if (socket != null) { input = socket.getInputStream(); output = socket.getOutputStream(); - - input_thread = new Thread(this); - input_thread.start(); - - // Configure the newly connected device for telemetry - print("~\nE 0\n"); - set_monitor(false); - if (D) Log.d(TAG, "ConnectThread: connected"); - - /* Let TelemetryService know we're connected - */ - handler.obtainMessage(TelemetryService.MSG_CONNECTED, this).sendToTarget(); - - /* Notify other waiting threads that we're connected now - */ - notifyAll(); + super.connected(); } } + } catch (InterruptedException ie) { + connect_failed(); } catch (IOException io) { connect_failed(); } @@ -109,24 +85,14 @@ public class AltosBluetooth extends AltosLink { return; } - close_socket(); + close_device(); input = null; output = null; handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED, this).sendToTarget(); if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); } - private void disconnected() { - if (closed()) { - if (D) Log.d(TAG, "disconnected after closed"); - return; - } - - if (D) Log.d(TAG, "Sending disconnected message"); - handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); - } - - private void close_socket() { + void close_device() { BluetoothSocket tmp_socket; synchronized(this) { @@ -143,6 +109,12 @@ public class AltosBluetooth extends AltosLink { } } + public void close() { + super.close(); + input = null; + output = null; + } + private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); private void create_socket(BluetoothDevice device) { @@ -156,7 +128,7 @@ public class AltosBluetooth extends AltosLink { } if (socket != null) { if (D) Log.d(TAG, String.format("Socket already allocated %s", socket.toString())); - close_socket(); + close_device(); } synchronized (this) { socket = tmp_socket; @@ -205,22 +177,6 @@ public class AltosBluetooth extends AltosLink { } } - public double frequency() { - return frequency; - } - - public int telemetry_rate() { - return telemetry_rate; - } - - public void save_frequency() { - AltosPreferences.set_frequency(0, frequency); - } - - public void save_telemetry_rate() { - AltosPreferences.set_telemetry_rate(0, telemetry_rate); - } - private synchronized void wait_connected() throws InterruptedException, IOException { if (input == null && socket != null) { if (D) Log.d(TAG, "wait_connected..."); @@ -231,109 +187,23 @@ public class AltosBluetooth extends AltosLink { throw new IOException(); } - public void print(String data) { - byte[] bytes = data.getBytes(); - if (D) Log.d(TAG, "print(): begin"); + int write(byte[] buffer, int len) { try { - wait_connected(); - output.write(bytes); - if (D) Log.d(TAG, "print(): Wrote bytes: '" + data.replace('\n', '\\') + "'"); - } catch (IOException e) { - disconnected(); - } catch (InterruptedException e) { - disconnected(); + output.write(buffer, 0, len); + } catch (IOException ie) { + return -1; } + return len; } - public void putchar(byte c) { - byte[] bytes = { c }; - if (D) Log.d(TAG, "print(): begin"); + int read(byte[] buffer, int len) { try { - wait_connected(); - output.write(bytes); - if (D) Log.d(TAG, "print(): Wrote byte: '" + c + "'"); - } catch (IOException e) { - disconnected(); - } catch (InterruptedException e) { - disconnected(); - } - } - - private static final int buffer_size = 1024; - - private byte[] buffer = new byte[buffer_size]; - private int buffer_len = 0; - private int buffer_off = 0; - - private byte[] debug_chars = new byte[buffer_size]; - private int debug_off; - - private void debug_input(byte b) { - if (b == '\n') { - Log.d(TAG, " " + new String(debug_chars, 0, debug_off)); - debug_off = 0; - } else { - if (debug_off < buffer_size) - debug_chars[debug_off++] = b; + return input.read(buffer, 0, len); + } catch (IOException ie) { + return -1; } } - public int getchar() { - while (buffer_off == buffer_len) { - try { - wait_connected(); - buffer_len = input.read(buffer); - buffer_off = 0; - } catch (IOException e) { - if (D) Log.d(TAG, "getchar IOException"); - disconnected(); - return AltosLink.ERROR; - } catch (java.lang.InterruptedException e) { - if (D) Log.d(TAG, "getchar Interrupted"); - disconnected(); - return AltosLink.ERROR; - } - } - if (D) - debug_input(buffer[buffer_off]); - return buffer[buffer_off++]; - } - - public void closing() { - synchronized(closed_lock) { - if (D) Log.d(TAG, "Marked closed true"); - closed = true; - } - } - - - public void close() { - if (D) Log.d(TAG, "close(): begin"); - - closing(); - - close_socket(); - - synchronized(this) { - - if (input_thread != null) { - if (D) Log.d(TAG, "close(): stopping input_thread"); - try { - if (D) Log.d(TAG, "close(): input_thread.interrupt()....."); - input_thread.interrupt(); - if (D) Log.d(TAG, "close(): input_thread.join()....."); - input_thread.join(); - } catch (Exception e) {} - input_thread = null; - } - input = null; - output = null; - notifyAll(); - } - } - - //public void flush_output() { super.flush_output(); } - // Stubs of required methods when extending AltosLink public boolean can_cancel_reply() { return false; } public boolean show_reply_timeout() { return true; } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 4e7bdd6b..27ebf206 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -23,6 +23,7 @@ import java.util.Timer; import java.util.TimerTask; import android.app.Activity; +import android.app.PendingIntent; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.Intent; @@ -51,6 +52,7 @@ import android.widget.RelativeLayout; import android.widget.Toast; import android.app.AlertDialog; import android.location.Location; +import android.hardware.usb.*; import org.altusmetrum.altoslib_6.*; @@ -59,6 +61,11 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { static final String TAG = "AltosDroid"; static final boolean D = true; + // Actions sent to the telemetry server at startup time + + public static final String ACTION_BLUETOOTH = "org.altusmetrum.AltosDroid.BLUETOOTH"; + public static final String ACTION_USB = "org.altusmetrum.AltosDroid.USB"; + // Message types received by our Handler public static final int MSG_STATE = 1; @@ -101,6 +108,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { private Timer timer; AltosState saved_state; + UsbDevice pending_usb_device; + boolean start_with_usb; + // Service private boolean mIsBound = false; private Messenger mService = null; @@ -148,6 +158,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } catch (RemoteException e) { // In this case the service has crashed before we could even do anything with it } + if (pending_usb_device != null) { + try { + mService.send(Message.obtain(null, TelemetryService.MSG_OPEN_USB, pending_usb_device)); + pending_usb_device = null; + } catch (RemoteException e) { + } + } } public void onServiceDisconnected(ComponentName className) { @@ -395,15 +412,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { super.onCreate(savedInstanceState); if(D) Log.e(TAG, "+++ ON CREATE +++"); - // Get local Bluetooth adapter - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - - // If the adapter is null, then Bluetooth is not supported - if (mBluetoothAdapter == null) { - Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); - finish(); - } - fm = getSupportFragmentManager(); // Set up the window layout @@ -467,23 +475,117 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { mAgeView = (TextView) findViewById(R.id.age_value); } + private boolean ensureBluetooth() { + // Get local Bluetooth adapter + mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + + // If the adapter is null, then Bluetooth is not supported + if (mBluetoothAdapter == null) { + Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); + return false; + } + + if (!mBluetoothAdapter.isEnabled()) { + Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); + startActivityForResult(enableIntent, AltosDroid.REQUEST_ENABLE_BT); + } + + return true; + } + + private boolean check_usb() { + UsbDevice device = AltosUsb.find_device(this, AltosLib.product_basestation); + + if (device != null) { + Intent i = new Intent(this, AltosDroid.class); + PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent("hello world", null, this, AltosDroid.class), 0); + + if (AltosUsb.request_permission(this, device, pi)) { + connectUsb(device); + } + start_with_usb = true; + return true; + } + + start_with_usb = false; + + return false; + } + + private void noticeIntent(Intent intent) { + + /* Ok, this is pretty convenient. + * + * When a USB device is plugged in, and our 'hotplug' + * intent registration fires, we get an Intent with + * EXTRA_DEVICE set. + * + * When we start up and see a usb device and request + * permission to access it, that queues a + * PendingIntent, which has the EXTRA_DEVICE added in, + * along with the EXTRA_PERMISSION_GRANTED field as + * well. + * + * So, in both cases, we get the device name using the + * same call. We check to see if access was granted, + * in which case we ignore the device field and do our + * usual startup thing. + */ + + UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + boolean granted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, true); + + if (D) Log.e(TAG, "intent " + intent + " device " + device + " granted " + granted); + + if (!granted) + device = null; + + if (device != null) { + if (D) Log.d(TAG, "intent has usb device " + device.toString()); + connectUsb(device); + } else { + + /* 'granted' is only false if this intent came + * from the request_permission call and + * permission was denied. In which case, we + * don't want to loop forever... + */ + if (granted) { + if (D) Log.d(TAG, "check for a USB device at startup"); + if (check_usb()) + return; + } + if (D) Log.d(TAG, "Starting by looking for bluetooth devices"); + if (ensureBluetooth()) + return; + finish(); + } + } + @Override public void onStart() { super.onStart(); if(D) Log.e(TAG, "++ ON START ++"); + noticeIntent(getIntent()); + // Start Telemetry Service - startService(new Intent(AltosDroid.this, TelemetryService.class)); + String action = start_with_usb ? ACTION_USB : ACTION_BLUETOOTH; - if (!mBluetoothAdapter.isEnabled()) { - Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); - startActivityForResult(enableIntent, AltosDroid.REQUEST_ENABLE_BT); - } + startService(new Intent(action, null, AltosDroid.this, TelemetryService.class)); doBindService(); if (mAltosVoice == null) mAltosVoice = new AltosVoice(this); + + } + + @Override + public void onNewIntent(Intent intent) { + super.onNewIntent(intent); + if(D) Log.d(TAG, "onNewIntent"); + noticeIntent(intent); } @Override @@ -519,7 +621,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { stop_timer(); } - public void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(D) Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE: @@ -544,6 +646,20 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { } } + private void connectUsb(UsbDevice device) { + if (mService == null) + pending_usb_device = device; + else { + // Attempt to connect to the device + try { + mService.send(Message.obtain(null, TelemetryService.MSG_OPEN_USB, device)); + if (D) Log.d(TAG, "Sent OPEN_USB message"); + } catch (RemoteException e) { + if (D) Log.e(TAG, "connect device message failed"); + } + } + } + private void connectDevice(Intent data) { // Attempt to connect to the device try { @@ -619,12 +735,14 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { Intent serverIntent = null; switch (item.getItemId()) { case R.id.connect_scan: - // Launch the DeviceListActivity to see devices and do scan - serverIntent = new Intent(this, DeviceListActivity.class); - startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE); + if (ensureBluetooth()) { + // Launch the DeviceListActivity to see devices and do scan + serverIntent = new Intent(this, DeviceListActivity.class); + startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE); + } return true; case R.id.disconnect: - /* Disconnect the bluetooth device + /* Disconnect the device */ disconnectDevice(); return true; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java new file mode 100644 index 00000000..badb2caa --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java @@ -0,0 +1,224 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.AltosDroid; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; + +import android.os.Handler; +import android.util.Log; + +import org.altusmetrum.altoslib_6.*; + +public abstract class AltosDroidLink extends AltosLink { + + // Debugging + private static final String TAG = "AltosDroidLink"; + private static final boolean D = true; + + Handler handler; + + Thread input_thread = null; + + public double frequency() { + return frequency; + } + + public int telemetry_rate() { + return telemetry_rate; + } + + public void save_frequency() { + AltosPreferences.set_frequency(0, frequency); + } + + public void save_telemetry_rate() { + AltosPreferences.set_telemetry_rate(0, telemetry_rate); + } + + Object closed_lock = new Object(); + boolean closing = false; + boolean closed = false; + + public boolean closed() { + synchronized(closed_lock) { + return closing; + } + } + + void connected() throws InterruptedException { + input_thread = new Thread(this); + input_thread.start(); + + // Configure the newly connected device for telemetry + print("~\nE 0\n"); + set_monitor(false); + if (D) Log.d(TAG, "ConnectThread: connected"); + + /* Let TelemetryService know we're connected + */ + handler.obtainMessage(TelemetryService.MSG_CONNECTED, this).sendToTarget(); + + /* Notify other waiting threads that we're connected now + */ + notifyAll(); + } + + public void closing() { + synchronized(closed_lock) { + if (D) Log.d(TAG, "Marked closing true"); + closing = true; + } + } + + private boolean actually_closed() { + synchronized(closed_lock) { + return closed; + } + } + + abstract void close_device(); + + public void close() { + if (D) Log.d(TAG, "close(): begin"); + + closing(); + + flush_output(); + + synchronized (closed_lock) { + if (D) Log.d(TAG, "Marked closed true"); + closed = true; + } + + close_device(); + + synchronized(this) { + + if (input_thread != null) { + if (D) Log.d(TAG, "close(): stopping input_thread"); + try { + if (D) Log.d(TAG, "close(): input_thread.interrupt()....."); + input_thread.interrupt(); + if (D) Log.d(TAG, "close(): input_thread.join()....."); + input_thread.join(); + } catch (Exception e) {} + input_thread = null; + } + notifyAll(); + } + } + + abstract int write(byte[] buffer, int len); + + abstract int read(byte[] buffer, int len); + + private static final int buffer_size = 64; + + private byte[] in_buffer = new byte[buffer_size]; + private byte[] out_buffer = new byte[buffer_size]; + private int buffer_len = 0; + private int buffer_off = 0; + private int out_buffer_off = 0; + + private byte[] debug_chars = new byte[buffer_size]; + private int debug_off; + + private void debug_input(byte b) { + if (b == '\n') { + Log.d(TAG, " " + new String(debug_chars, 0, debug_off)); + debug_off = 0; + } else { + if (debug_off < buffer_size) + debug_chars[debug_off++] = b; + } + } + + private void disconnected() { + if (closed()) { + if (D) Log.d(TAG, "disconnected after closed"); + return; + } + + if (D) Log.d(TAG, "Sending disconnected message"); + handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); + } + + public int getchar() { + + if (actually_closed()) + return ERROR; + + while (buffer_off == buffer_len) { + buffer_len = read(in_buffer, buffer_size); + if (buffer_len < 0) { + Log.d(TAG, "ERROR returned from getchar()"); + disconnected(); + return ERROR; + } + buffer_off = 0; + } + if (D) + debug_input(in_buffer[buffer_off]); + return in_buffer[buffer_off++]; + } + + public void flush_output() { + super.flush_output(); + + if (actually_closed()) { + out_buffer_off = 0; + return; + } + + while (out_buffer_off != 0) { + int sent = write(out_buffer, out_buffer_off); + + if (sent <= 0) { + Log.d(TAG, "flush_output() failed"); + out_buffer_off = 0; + break; + } + + if (sent < out_buffer_off) + System.arraycopy(out_buffer, 0, out_buffer, sent, out_buffer_off - sent); + + out_buffer_off -= sent; + } + } + + public void putchar(byte c) { + out_buffer[out_buffer_off++] = c; + if (out_buffer_off == buffer_size) + flush_output(); + } + + public void print(String data) { + byte[] bytes = data.getBytes(); + if (D) Log.d(TAG, "print(): begin"); + for (byte b : bytes) + putchar(b); + if (D) Log.d(TAG, "print(): Wrote bytes: '" + data.replace('\n', '\\') + "'"); + } + + public AltosDroidLink(Handler handler) { + this.handler = handler; + } +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java new file mode 100644 index 00000000..81d50ab3 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java @@ -0,0 +1,235 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.AltosDroid; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; +import java.util.HashMap; + +import android.content.Context; +import android.hardware.usb.*; +import android.app.*; +import android.os.Handler; +import android.util.Log; + +import org.altusmetrum.altoslib_6.*; + +public class AltosUsb extends AltosDroidLink { + + // Debugging + private static final String TAG = "AltosUsb"; + private static final boolean D = true; + + private Thread input_thread = null; + + private Handler handler; + + private UsbManager manager; + private UsbDevice device; + private UsbDeviceConnection connection; + private UsbInterface iface; + private UsbEndpoint in, out; + + private InputStream input; + private OutputStream output; + + // Constructor + public AltosUsb(Context context, UsbDevice device, Handler handler) { + super(handler); +// set_debug(D); + this.handler = handler; + + iface = null; + in = null; + out = null; + + int niface = device.getInterfaceCount(); + + for (int i = 0; i < niface; i++) { + + iface = device.getInterface(i); + + in = null; + out = null; + + int nendpoints = iface.getEndpointCount(); + + for (int e = 0; e < nendpoints; e++) { + UsbEndpoint endpoint = iface.getEndpoint(e); + + if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) { + switch (endpoint.getDirection()) { + case UsbConstants.USB_DIR_OUT: + out = endpoint; + break; + case UsbConstants.USB_DIR_IN: + in = endpoint; + break; + } + } + } + + if (in != null && out != null) + break; + } + + if (in != null && out != null) { + Log.d(TAG, String.format("\tin %s out %s\n", in.toString(), out.toString())); + + manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); + + if (manager == null) { + Log.d(TAG, "USB_SERVICE failed"); + return; + } + + connection = manager.openDevice(device); + + if (connection == null) { + Log.d(TAG, "openDevice failed"); + return; + } + + connection.claimInterface(iface, true); + + input_thread = new Thread(this); + input_thread.start(); + + // Configure the newly connected device for telemetry + print("~\nE 0\n"); + set_monitor(false); + } + } + + static private boolean isAltusMetrum(UsbDevice device) { + if (device.getVendorId() != AltosLib.vendor_altusmetrum) + return false; + if (device.getProductId() < AltosLib.product_altusmetrum_min) + return false; + if (device.getProductId() > AltosLib.product_altusmetrum_max) + return false; + return true; + } + + static boolean matchProduct(int want_product, UsbDevice device) { + + if (!isAltusMetrum(device)) + return false; + + if (want_product == AltosLib.product_any) + return true; + + int have_product = device.getProductId(); + + if (want_product == AltosLib.product_basestation) + return have_product == AltosLib.product_teledongle || + have_product == AltosLib.product_teleterra || + have_product == AltosLib.product_telebt || + have_product == AltosLib.product_megadongle; + + if (want_product == AltosLib.product_altimeter) + return have_product == AltosLib.product_telemetrum || + have_product == AltosLib.product_telemega || + have_product == AltosLib.product_easymega || + have_product == AltosLib.product_telegps || + have_product == AltosLib.product_easymini || + have_product == AltosLib.product_telemini; + + if (have_product == AltosLib.product_altusmetrum) /* old devices match any request */ + return true; + + if (want_product == have_product) + return true; + + return false; + } + + static public boolean request_permission(Context context, UsbDevice device, PendingIntent pi) { + UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); + +// if (manager.hasPermission(device)) +// return true; + + Log.d(TAG, "request permission for USB device " + device.toString()); + + manager.requestPermission(device, pi); + return false; + } + + static public UsbDevice find_device(Context context, int match_product) { + UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); + + HashMap devices = manager.getDeviceList(); + + for (UsbDevice device : devices.values()) { + int vendor = device.getVendorId(); + int product = device.getProductId(); + + if (matchProduct(match_product, device)) { + Log.d(TAG, "found USB device " + device.toString()); + return device; + } + } + + return null; + } + + private void disconnected() { + if (closed()) { + if (D) Log.d(TAG, "disconnected after closed"); + return; + } + + if (D) Log.d(TAG, "Sending disconnected message"); + handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); + } + + void close_device() { + UsbDeviceConnection tmp_connection; + + synchronized(this) { + tmp_connection = connection; + connection = null; + } + + if (tmp_connection != null) { + if (D) Log.d(TAG, "Closing USB device"); + tmp_connection.close(); + } + } + + int read(byte[] buffer, int len) { + int ret = connection.bulkTransfer(in, buffer, len, -1); + if (D) Log.d(TAG, String.format("read(%d) = %d\n", len, ret)); + return ret; + } + + int write(byte[] buffer, int len) { + int ret = connection.bulkTransfer(out, buffer, len, -1); + if (D) Log.d(TAG, String.format("write(%d) = %d\n", len, ret)); + return ret; + } + + // Stubs of required methods when extending AltosLink + public boolean can_cancel_reply() { return false; } + public boolean show_reply_timeout() { return true; } + public void hide_reply_timeout() { } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index 4e4408d5..bdb2bae4 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -81,6 +81,8 @@ public class TelemetryReader extends Thread { } } catch (InterruptedException ee) { } catch (IOException ie) { + Log.e(TAG, "IO exception in telemetry reader"); + handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, link).sendToTarget(); } finally { close(); } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 65eabf11..e7f958b9 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -29,6 +29,7 @@ import android.app.PendingIntent; import android.app.Service; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothAdapter; +import android.hardware.usb.*; import android.content.Intent; import android.content.Context; import android.os.Bundle; @@ -56,14 +57,15 @@ public class TelemetryService extends Service implements LocationListener { static final int MSG_REGISTER_CLIENT = 1; static final int MSG_UNREGISTER_CLIENT = 2; static final int MSG_CONNECT = 3; - static final int MSG_CONNECTED = 4; - static final int MSG_CONNECT_FAILED = 5; - static final int MSG_DISCONNECTED = 6; - static final int MSG_TELEMETRY = 7; - static final int MSG_SETFREQUENCY = 8; - static final int MSG_CRC_ERROR = 9; - static final int MSG_SETBAUD = 10; - static final int MSG_DISCONNECT = 11; + static final int MSG_OPEN_USB = 4; + static final int MSG_CONNECTED = 5; + static final int MSG_CONNECT_FAILED = 6; + static final int MSG_DISCONNECTED = 7; + static final int MSG_TELEMETRY = 8; + static final int MSG_SETFREQUENCY = 9; + static final int MSG_CRC_ERROR = 10; + static final int MSG_SETBAUD = 11; + static final int MSG_DISCONNECT = 12; // Unique Identification Number for the Notification. // We use it on Notification start, and to cancel it. @@ -76,7 +78,7 @@ public class TelemetryService extends Service implements LocationListener { // Name of the connected device DeviceAddress address; - private AltosBluetooth altos_bluetooth = null; + private AltosDroidLink altos_link = null; private TelemetryReader telemetry_reader = null; private TelemetryLogger telemetry_logger = null; @@ -94,7 +96,7 @@ public class TelemetryService extends Service implements LocationListener { @Override public void handleMessage(Message msg) { TelemetryService s = service.get(); - AltosBluetooth bt = null; + AltosDroidLink bt = null; if (s == null) return; switch (msg.what) { @@ -112,18 +114,23 @@ public class TelemetryService extends Service implements LocationListener { AltosDroidPreferences.set_active_device(address); s.start_altos_bluetooth(address, false); break; + case MSG_OPEN_USB: + if (D) Log.d(TAG, "Open USB command received"); + UsbDevice device = (UsbDevice) msg.obj; + s.start_usb(device); + break; case MSG_DISCONNECT: if (D) Log.d(TAG, "Disconnect command received"); s.address = null; - s.stop_altos_bluetooth(true); + s.disconnect(true); break; case MSG_SETFREQUENCY: if (D) Log.d(TAG, "MSG_SETFREQUENCY"); s.telemetry_state.frequency = (Double) msg.obj; if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { try { - s.altos_bluetooth.set_radio_frequency(s.telemetry_state.frequency); - s.altos_bluetooth.save_frequency(); + s.altos_link.set_radio_frequency(s.telemetry_state.frequency); + s.altos_link.save_frequency(); } catch (InterruptedException e) { } catch (TimeoutException e) { } @@ -134,8 +141,8 @@ public class TelemetryService extends Service implements LocationListener { if (D) Log.d(TAG, "MSG_SETBAUD"); s.telemetry_state.telemetry_rate = (Integer) msg.obj; if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { - s.altos_bluetooth.set_telemetry_rate(s.telemetry_state.telemetry_rate); - s.altos_bluetooth.save_telemetry_rate(); + s.altos_link.set_telemetry_rate(s.telemetry_state.telemetry_rate); + s.altos_link.save_telemetry_rate(); } s.send_to_clients(); break; @@ -145,9 +152,9 @@ public class TelemetryService extends Service implements LocationListener { */ case MSG_CONNECTED: Log.d(TAG, "MSG_CONNECTED"); - bt = (AltosBluetooth) msg.obj; + bt = (AltosDroidLink) msg.obj; - if (bt != s.altos_bluetooth) { + if (bt != s.altos_link) { if (D) Log.d(TAG, "Stale message"); break; } @@ -159,9 +166,9 @@ public class TelemetryService extends Service implements LocationListener { break; case MSG_CONNECT_FAILED: Log.d(TAG, "MSG_CONNECT_FAILED"); - bt = (AltosBluetooth) msg.obj; + bt = (AltosDroidLink) msg.obj; - if (bt != s.altos_bluetooth) { + if (bt != s.altos_link) { if (D) Log.d(TAG, "Stale message"); break; } @@ -169,14 +176,16 @@ public class TelemetryService extends Service implements LocationListener { if (D) Log.d(TAG, "Connection failed... retrying"); s.start_altos_bluetooth(s.address, true); } else { - s.stop_altos_bluetooth(true); + s.disconnect(true); } break; case MSG_DISCONNECTED: + + /* This can be sent by either AltosDroidLink or TelemetryReader */ Log.d(TAG, "MSG_DISCONNECTED"); - bt = (AltosBluetooth) msg.obj; + bt = (AltosDroidLink) msg.obj; - if (bt != s.altos_bluetooth) { + if (bt != s.altos_link) { if (D) Log.d(TAG, "Stale message"); break; } @@ -184,7 +193,7 @@ public class TelemetryService extends Service implements LocationListener { if (D) Log.d(TAG, "Connection lost... retrying"); s.start_altos_bluetooth(s.address, true); } else { - s.stop_altos_bluetooth(true); + s.disconnect(true); } break; @@ -275,16 +284,17 @@ public class TelemetryService extends Service implements LocationListener { send_to_client(client, m); } - private void stop_altos_bluetooth(boolean notify) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): begin"); + private void disconnect(boolean notify) { + if (D) Log.d(TAG, "disconnect(): begin"); + telemetry_state.connect = TelemetryState.CONNECT_DISCONNECTED; telemetry_state.address = null; - if (altos_bluetooth != null) - altos_bluetooth.closing(); + if (altos_link != null) + altos_link.closing(); if (telemetry_reader != null) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping TelemetryReader"); + if (D) Log.d(TAG, "disconnect(): stopping TelemetryReader"); telemetry_reader.interrupt(); try { telemetry_reader.join(); @@ -293,31 +303,44 @@ public class TelemetryService extends Service implements LocationListener { telemetry_reader = null; } if (telemetry_logger != null) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping TelemetryLogger"); + if (D) Log.d(TAG, "disconnect(): stopping TelemetryLogger"); telemetry_logger.stop(); telemetry_logger = null; } - if (altos_bluetooth != null) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): stopping AltosBluetooth"); - altos_bluetooth.close(); - altos_bluetooth = null; + if (altos_link != null) { + if (D) Log.d(TAG, "disconnect(): stopping AltosDroidLink"); + altos_link.close(); + altos_link = null; } telemetry_state.config = null; if (notify) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): send message to clients"); + if (D) Log.d(TAG, "disconnect(): send message to clients"); send_to_clients(); if (clients.isEmpty()) { - if (D) Log.d(TAG, "stop_altos_bluetooth(): no clients, terminating"); + if (D) Log.d(TAG, "disconnect(): no clients, terminating"); stopSelf(); } } } + private void start_usb(UsbDevice device) { + AltosUsb d = new AltosUsb(this, device, handler); + + if (d != null) { + disconnect(false); + altos_link = d; + try { + connected(); + } catch (InterruptedException ie) { + } + } + } + private void start_altos_bluetooth(DeviceAddress address, boolean pause) { // Get the BLuetoothDevice object BluetoothDevice device = bluetooth_adapter.getRemoteDevice(address.address); - stop_altos_bluetooth(false); + disconnect(false); if (pause) { try { Thread.sleep(4000); @@ -326,7 +349,7 @@ public class TelemetryService extends Service implements LocationListener { } this.address = address; if (D) Log.d(TAG, String.format("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); - altos_bluetooth = new AltosBluetooth(device, handler); + altos_link = new AltosBluetooth(device, handler); telemetry_state.connect = TelemetryState.CONNECT_CONNECTING; telemetry_state.address = address; send_to_clients(); @@ -335,11 +358,11 @@ public class TelemetryService extends Service implements LocationListener { private void connected() throws InterruptedException { if (D) Log.d(TAG, "connected top"); try { - if (altos_bluetooth == null) + if (altos_link == null) throw new InterruptedException("no bluetooth"); - telemetry_state.config = altos_bluetooth.config_data(); - altos_bluetooth.set_radio_frequency(telemetry_state.frequency); - altos_bluetooth.set_telemetry_rate(telemetry_state.telemetry_rate); + telemetry_state.config = altos_link.config_data(); + altos_link.set_radio_frequency(telemetry_state.frequency); + altos_link.set_telemetry_rate(telemetry_state.telemetry_rate); } catch (TimeoutException e) { // If this timed out, then we really want to retry it, but // probably safer to just retry the connection from scratch. @@ -349,7 +372,7 @@ public class TelemetryService extends Service implements LocationListener { start_altos_bluetooth(address, true); } else { handler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); - stop_altos_bluetooth(true); + disconnect(true); } return; } @@ -358,12 +381,12 @@ public class TelemetryService extends Service implements LocationListener { telemetry_state.connect = TelemetryState.CONNECT_CONNECTED; telemetry_state.address = address; - telemetry_reader = new TelemetryReader(altos_bluetooth, handler, telemetry_state.state); + telemetry_reader = new TelemetryReader(altos_link, handler, telemetry_state.state); telemetry_reader.start(); if (D) Log.d(TAG, "connected TelemetryReader started"); - telemetry_logger = new TelemetryLogger(this, altos_bluetooth); + telemetry_logger = new TelemetryLogger(this, altos_link); if (D) Log.d(TAG, "Notify UI of connection"); @@ -403,10 +426,6 @@ public class TelemetryService extends Service implements LocationListener { LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this); - - DeviceAddress address = AltosDroidPreferences.active_device(); - if (address != null) - start_altos_bluetooth(address, false); } @Override @@ -431,6 +450,14 @@ public class TelemetryService extends Service implements LocationListener { // Move us into the foreground. startForeground(NOTIFICATION, notification); + String action = intent.getAction(); + + if (action.equals(AltosDroid.ACTION_BLUETOOTH)) { + DeviceAddress address = AltosDroidPreferences.active_device(); + if (address != null && !address.address.startsWith("USB")) + start_altos_bluetooth(address, false); + } + // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; @@ -443,7 +470,7 @@ public class TelemetryService extends Service implements LocationListener { ((LocationManager) getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this); // Stop the bluetooth Comms threads - stop_altos_bluetooth(true); + disconnect(true); // Demote us from the foreground, and cancel the persistent notification. stopForeground(true); -- cgit v1.2.3 From 1cc1900e13d79e0451587439c23bbb062d86cee3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 27 Apr 2015 22:29:45 -0700 Subject: altosdroid: Fix tab label height problems With a newer android API versions, we can set the indicator to a View instead of just a string. This lets us wrap the desired string in a TextView and show just that for the indicator, making it exactly the right size. Signed-off-by: Keith Packard --- altosdroid/res/layout/tab_layout.xml | 16 +++++++++ .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 41 ++++++++-------------- 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 altosdroid/res/layout/tab_layout.xml diff --git a/altosdroid/res/layout/tab_layout.xml b/altosdroid/res/layout/tab_layout.xml new file mode 100644 index 00000000..2c21c648 --- /dev/null +++ b/altosdroid/res/layout/tab_layout.xml @@ -0,0 +1,16 @@ + + + + diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 27ebf206..b4fc3bc3 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -37,6 +37,7 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; +import android.content.res.Resources; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.util.DisplayMetrics; @@ -46,6 +47,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.Window; import android.view.View; +import android.view.LayoutInflater; import android.widget.TabHost; import android.widget.TextView; import android.widget.RelativeLayout; @@ -407,6 +409,14 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { return String.format(format, value); } + private View create_tab_view(String label) { + LayoutInflater inflater = (LayoutInflater) this.getLayoutInflater(); + View tab_view = inflater.inflate(R.layout.tab_layout, null); + TextView text_view = (TextView) tab_view.findViewById (R.id.tabLabel); + text_view.setText(label); + return tab_view; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -428,32 +438,11 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); - mTabsAdapter.addTab(mTabHost.newTabSpec("pad").setIndicator("Pad"), TabPad.class, null); - mTabsAdapter.addTab(mTabHost.newTabSpec("ascent").setIndicator("Ascent"), TabAscent.class, null); - mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator("Descent"), TabDescent.class, null); - mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator("Landed"), TabLanded.class, null); - mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator("Map"), TabMap.class, null); - - - // Scale the size of the Tab bar for different screen densities - // This probably won't be needed when we start supporting ICS+ tabs. - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - int density = metrics.densityDpi; - - if (density==DisplayMetrics.DENSITY_XHIGH) - tabHeight = 65; - else if (density==DisplayMetrics.DENSITY_HIGH) - tabHeight = 45; - else if (density==DisplayMetrics.DENSITY_MEDIUM) - tabHeight = 35; - else if (density==DisplayMetrics.DENSITY_LOW) - tabHeight = 25; - else - tabHeight = 65; - - for (int i = 0; i < 5; i++) - mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = tabHeight; + mTabsAdapter.addTab(mTabHost.newTabSpec("pad").setIndicator(create_tab_view("Pad")), TabPad.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("ascent").setIndicator(create_tab_view("Ascent")), TabAscent.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator(create_tab_view("Descent")), TabDescent.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator(create_tab_view("Landed")), TabLanded.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator(create_tab_view("Map")), TabMap.class, null); // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text); -- cgit v1.2.3 From 3fbf0a29a1b8a67b90ef965ee3e2e972c0ec33a1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 18 May 2015 10:52:24 -0700 Subject: altoslib: Use Locale.ROOT for KML export This avoids locale-specific number formatting, which breaks googleearth when importing the resulting file. Signed-off-by: Keith Packard --- altoslib/AltosKML.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index aa80fc21..1a0fcf3d 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -18,11 +18,22 @@ package org.altusmetrum.altoslib_6; import java.io.*; +import java.util.*; + +class KMLWriter extends PrintWriter { + public PrintWriter printf(String format, Object ... arguments) { + return printf(Locale.ROOT, format, arguments); + } + + public KMLWriter(File name) throws FileNotFoundException { + super(name); + } +} public class AltosKML implements AltosWriter { File name; - PrintStream out; + PrintWriter out; int flight_state = -1; AltosState prev = null; double gps_start_altitude; @@ -137,6 +148,10 @@ public class AltosKML implements AltosWriter { end(); prev = null; } + if (out != null) { + out.close(); + out = null; + } } public void write(AltosState state) { @@ -177,7 +192,7 @@ public class AltosKML implements AltosWriter { public AltosKML(File in_name) throws FileNotFoundException { name = in_name; - out = new PrintStream(name); + out = new KMLWriter(name); } public AltosKML(String in_string) throws FileNotFoundException { -- cgit v1.2.3 From 3e5e9333420ede74d998556c1bbd5888e8ff75ae Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:09:22 -0700 Subject: altoslib: Expose locale and non-locale floating point parsing functions UI bits use locale-specific floating point formats, so parsing those needs to use the locale. Network-based data, like .kml bits need to use non-locale-specific parsing code, so now we've got both APIs available, and each used as appropriate. Signed-off-by: Keith Packard --- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 5 ++-- altoslib/AltosGPS.java | 6 ++--- altoslib/AltosParse.java | 21 ++++++++++++--- altoslib/AltosUnits.java | 21 +++++++++++---- altosui/AltosConfigPyroUI.java | 15 ++++++----- altosui/AltosConfigUI.java | 30 +++++++++++++++++----- altosuilib/AltosConfigFreqUI.java | 5 ++-- altosuilib/AltosUIMapPreload.java | 23 +++++++++-------- telegps/TeleGPS.java | 9 +++++-- telegps/TeleGPSConfigUI.java | 14 ++++++++-- 10 files changed, 105 insertions(+), 44 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index b4fc3bc3..db065b3f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -21,6 +21,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Timer; import java.util.TimerTask; +import java.text.*; import android.app.Activity; import android.app.PendingIntent; @@ -687,8 +688,8 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { void setFrequency(String freq) { try { - setFrequency (Double.parseDouble(freq.substring(11, 17))); - } catch (NumberFormatException e) { + setFrequency (AltosParse.parse_double_net(freq.substring(11, 17))); + } catch (ParseException e) { } } diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 2139efb2..e3aee4ea 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -195,10 +195,10 @@ public class AltosGPS implements Cloneable, Serializable { lon = AltosParse.parse_coord(words[i++]); alt = AltosParse.parse_int(words[i++]); if (version > 1 || (i < words.length && !words[i].equals("SAT"))) { - ground_speed = AltosParse.parse_double(AltosParse.strip_suffix(words[i++], "m/s(H)")); + ground_speed = AltosParse.parse_double_net(AltosParse.strip_suffix(words[i++], "m/s(H)")); course = AltosParse.parse_int(words[i++]); - climb_rate = AltosParse.parse_double(AltosParse.strip_suffix(words[i++], "m/s(V)")); - hdop = AltosParse.parse_double(AltosParse.strip_suffix(words[i++], "(hdop)")); + climb_rate = AltosParse.parse_double_net(AltosParse.strip_suffix(words[i++], "m/s(V)")); + hdop = AltosParse.parse_double_net(AltosParse.strip_suffix(words[i++], "(hdop)")); h_error = AltosParse.parse_int(words[i++]); v_error = AltosParse.parse_int(words[i++]); } diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 2fb69c15..a8b02b56 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -17,6 +17,7 @@ package org.altusmetrum.altoslib_6; +import java.util.*; import java.text.*; public class AltosParse { @@ -40,11 +41,23 @@ public class AltosParse { } } - public static double parse_double(String v) throws ParseException { + static NumberFormat nf_locale = NumberFormat.getInstance(); + + static NumberFormat nf_net = NumberFormat.getInstance(Locale.ROOT); + + public static double parse_double_locale(String str) throws ParseException { try { - return Double.parseDouble(v); - } catch (NumberFormatException e) { - throw new ParseException("error parsing double " + v, 0); + return nf_locale.parse(str.trim()).doubleValue(); + } catch (ParseException pe) { + throw new ParseException("error parsing double " + str, 0); + } + } + + public static double parse_double_net(String str) throws ParseException { + try { + return nf_net.parse(str.trim()).doubleValue(); + } catch (ParseException pe) { + throw new ParseException("error parsing double " + str, 0); } } diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index f6e34e77..e266b243 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -17,6 +17,8 @@ package org.altusmetrum.altoslib_6; +import java.text.*; + public abstract class AltosUnits { public abstract double value(double v, boolean imperial_units); @@ -29,13 +31,22 @@ public abstract class AltosUnits { public abstract int show_fraction(int width, boolean imperial_units); - public double parse(String s, boolean imperial_units) throws NumberFormatException { - double v = Double.parseDouble(s); + public double parse_locale(String s, boolean imperial_units) throws ParseException { + double v = AltosParse.parse_double_locale(s); + return inverse(v, imperial_units); + } + + public double parse_net(String s, boolean imperial_units) throws ParseException { + double v = AltosParse.parse_double_net(s); return inverse(v, imperial_units); } - public double parse(String s) throws NumberFormatException { - return parse(s, AltosConvert.imperial_units); + public double parse_locale(String s) throws ParseException { + return parse_locale(s, AltosConvert.imperial_units); + } + + public double parse_net(String s) throws ParseException { + return parse_net(s, AltosConvert.imperial_units); } public double value(double v) { @@ -105,4 +116,4 @@ public abstract class AltosUnits { public String say_units(double v) { return say_units(v, AltosConvert.imperial_units); } -} \ No newline at end of file +} diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 61208dfe..69b31ff5 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -17,6 +17,7 @@ package altosui; +import java.text.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; @@ -87,9 +88,9 @@ public class AltosConfigPyroUI if (units != null) { try { - double v = units.parse(value.getText(), !imperial_units); + double v = units.parse_locale(value.getText(), !imperial_units); set(enabled(), v); - } catch (NumberFormatException ne) { + } catch (ParseException pe) { set(enabled(), 0.0); } } @@ -129,9 +130,9 @@ public class AltosConfigPyroUI AltosUnits units = AltosPyro.pyro_to_units(flag); try { if (units != null) - return units.parse(value.getText()); - return Double.parseDouble(value.getText()); - } catch (NumberFormatException e) { + return units.parse_locale(value.getText()); + return AltosParse.parse_double_locale(value.getText()); + } catch (ParseException e) { throw new AltosConfigDataException("\"%s\": %s\n", value.getText(), e.getMessage()); } } @@ -298,8 +299,8 @@ public class AltosConfigPyroUI String v = pyro_firing_time_value.getSelectedItem().toString(); try { - return Double.parseDouble(v); - } catch (NumberFormatException e) { + return AltosParse.parse_double_locale(v); + } catch (ParseException e) { throw new AltosConfigDataException("Invalid pyro firing time \"%s\"", v); } } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 67decaa4..ef477ca9 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -21,6 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; +import java.text.*; import org.altusmetrum.altoslib_6.*; import org.altusmetrum.altosuilib_6.*; @@ -976,8 +977,13 @@ public class AltosConfigUI } - public int main_deploy() { - return (int) (AltosConvert.height.parse(main_deploy_value.getSelectedItem().toString()) + 0.5); + public int main_deploy() throws AltosConfigDataException { + String str = main_deploy_value.getSelectedItem().toString(); + try { + return (int) (AltosConvert.height.parse_locale(str) + 0.5); + } catch (ParseException pe) { + throw new AltosConfigDataException("invalid main deploy height %s", str); + } } String get_main_deploy_label() { @@ -1006,14 +1012,21 @@ public class AltosConfigUI String v = main_deploy_value.getSelectedItem().toString(); main_deploy_label.setText(get_main_deploy_label()); set_main_deploy_values(); - int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5); - set_main_deploy(m); + try { + int m = (int) (AltosConvert.height.parse_locale(v, !imperial_units) + 0.5); + set_main_deploy(m); + } catch (ParseException pe) { + } if (tracker_motion_value.isEnabled()) { String motion = tracker_motion_value.getSelectedItem().toString(); tracker_motion_label.setText(get_tracker_motion_label()); set_tracker_motion_values(); - set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5)); + try { + int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5); + set_tracker_motion(m); + } catch (ParseException pe) { + } } if (!was_dirty) @@ -1272,7 +1285,12 @@ public class AltosConfigUI } public int tracker_motion() throws AltosConfigDataException { - return (int) AltosConvert.height.parse(tracker_motion_value.getSelectedItem().toString()); + String str = tracker_motion_value.getSelectedItem().toString(); + try { + return (int) (AltosConvert.height.parse_locale(str) + 0.5); + } catch (ParseException pe) { + throw new AltosConfigDataException("invalid tracker motion %s", str); + } } public void set_tracker_interval(int tracker_interval) { diff --git a/altosuilib/AltosConfigFreqUI.java b/altosuilib/AltosConfigFreqUI.java index 6253e3e4..21514a81 100644 --- a/altosuilib/AltosConfigFreqUI.java +++ b/altosuilib/AltosConfigFreqUI.java @@ -18,6 +18,7 @@ package org.altusmetrum.altosuilib_6; import java.awt.*; +import java.text.*; import java.awt.event.*; import javax.swing.*; import java.util.*; @@ -51,10 +52,10 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { String d_s = description.getText(); try { - double f_d = Double.parseDouble(f_s); + double f_d = AltosParse.parse_double_locale(f_s); return new AltosFrequency(f_d, d_s); - } catch (NumberFormatException ne) { + } catch (ParseException ne) { } return null; } diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java index e82b6c60..1973ae6e 100644 --- a/altosuilib/AltosUIMapPreload.java +++ b/altosuilib/AltosUIMapPreload.java @@ -53,33 +53,33 @@ class AltosUIMapPos extends Box { hemi.setSelectedIndex(h); } - public double get_value() throws NumberFormatException { + public double get_value() throws ParseException { int h = hemi.getSelectedIndex(); String d_t = deg.getText(); String m_t = min.getText(); double d, m, v; try { - d = Double.parseDouble(d_t); - } catch (NumberFormatException ne) { + d = AltosParse.parse_double_locale(d_t); + } catch (ParseException pe) { JOptionPane.showMessageDialog(owner, String.format("Invalid degrees \"%s\"", d_t), "Invalid number", JOptionPane.ERROR_MESSAGE); - throw ne; + throw pe; } try { if (m_t.equals("")) m = 0; else - m = Double.parseDouble(m_t); - } catch (NumberFormatException ne) { + m = AltosParse.parse_double_locale(m_t); + } catch (ParseException pe) { JOptionPane.showMessageDialog(owner, String.format("Invalid minutes \"%s\"", m_t), "Invalid number", JOptionPane.ERROR_MESSAGE); - throw ne; + throw pe; } v = d + m/60.0; if (h == 1) @@ -142,9 +142,9 @@ class AltosUISite { name = elements[0]; try { - latitude = Double.parseDouble(elements[1]); - longitude = Double.parseDouble(elements[2]); - } catch (NumberFormatException ne) { + latitude = AltosParse.parse_double_net(elements[1]); + longitude = AltosParse.parse_double_net(elements[2]); + } catch (ParseException pe) { throw new ParseException(String.format("Invalid site line %s", line), 0); } } @@ -171,6 +171,7 @@ class AltosUISites extends Thread { try { add(new AltosUISite(line)); } catch (ParseException pe) { + System.out.printf("parse exception %s\n", pe.toString()); } } @@ -394,7 +395,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I max_z = min_z; r = (Integer) radius.getSelectedItem(); loading = true; - } catch (NumberFormatException ne) { + } catch (ParseException pe) { load_button.setSelected(false); } start_load(); diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index fe335176..7570d380 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -23,6 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; +import java.text.*; import org.altusmetrum.altoslib_6.*; import org.altusmetrum.altosuilib_6.*; @@ -679,9 +680,13 @@ public class TeleGPS if (args.length < i + 3) { help(1); } else { - double lat = Double.parseDouble(args[i+1]); - double lon = Double.parseDouble(args[i+2]); + try { + double lat = AltosParse.parse_double_locale(args[i+1]); + double lon = AltosParse.parse_double_locale(args[i+2]); AltosUIMap.prefetch_maps(lat, lon); + } catch (ParseException e) { + System.out.printf("Can't parse number %s\n", e.toString()); + } i += 2; } } else if (args[i].equals("--replay")) diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 97ab34b4..4e657586 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -17,6 +17,7 @@ package org.altusmetrum.telegps; +import java.text.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; @@ -686,7 +687,11 @@ public class TeleGPSConfigUI String motion = tracker_motion_value.getSelectedItem().toString(); tracker_motion_label.setText(get_tracker_motion_label()); set_tracker_motion_values(); - set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5)); + try { + int m = (int) (AltosConvert.height.parse_locale(motion, !imperial_units) + 0.5); + set_tracker_motion(m); + } catch (ParseException pe) { + } } if (!was_dirty) set_clean(); @@ -886,7 +891,12 @@ public class TeleGPSConfigUI } public int tracker_motion() throws AltosConfigDataException { - return (int) AltosConvert.height.parse(tracker_motion_value.getSelectedItem().toString()); + String str = tracker_motion_value.getSelectedItem().toString(); + try { + return (int) (AltosConvert.height.parse_locale(str) + 0.5); + } catch (ParseException pe) { + throw new AltosConfigDataException("invalid tracker motion %s", str); + } } public void set_tracker_interval(int tracker_interval) { -- cgit v1.2.3 From 2b57158737f85c7009658b3e923c66794f01bbdf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:12:52 -0700 Subject: altosui: Remove un-implemented --fetchmaps argument This has been stubbed out for a while, so just remove it. Signed-off-by: Keith Packard --- altosui/AltosUI.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 0af09651..5dd532bd 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -587,16 +587,7 @@ public class AltosUI extends AltosUIFrame { for (int i = 0; i < args.length; i++) { if (args[i].equals("--help")) help(0); - else if (args[i].equals("--fetchmaps")) { - if (args.length < i + 3) { - help(1); - } else { - double lat = Double.parseDouble(args[i+1]); - double lon = Double.parseDouble(args[i+2]); -// AltosSiteMap.prefetchMaps(lat, lon); - i += 2; - } - } else if (args[i].equals("--replay")) + else if (args[i].equals("--replay")) process = process_replay; else if (args[i].equals("--kml")) process = process_kml; -- cgit v1.2.3 From b67e6ae8ce34ef119da96b442776bb3d78b4f874 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:14:43 -0700 Subject: ao-dump-up: Add --wait option to make testing µPusb easier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The --wait option hangs around until a suitable device appears, so that you can test a pile of µPusb devices without needing to constantly interact with the command line. Signed-off-by: Keith Packard --- ao-tools/ao-dump-up/ao-dump-up.c | 28 +++++++++++++++++++++++----- ao-tools/lib/cc-usb.c | 4 +++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ao-tools/ao-dump-up/ao-dump-up.c b/ao-tools/ao-dump-up/ao-dump-up.c index 6268dc8b..b1f85af6 100644 --- a/ao-tools/ao-dump-up/ao-dump-up.c +++ b/ao-tools/ao-dump-up/ao-dump-up.c @@ -29,12 +29,13 @@ static const struct option options[] = { { .name = "tty", .has_arg = 1, .val = 'T' }, { .name = "device", .has_arg = 1, .val = 'D' }, + { .name = "wait", .has_arg = 0, .val = 'w' }, { 0, 0, 0, 0}, }; static void usage(char *program) { - fprintf(stderr, "usage: %s [--tty ] [--device ]\n", program); + fprintf(stderr, "usage: %s [--tty ] [--device ] [--wait]\n", program); exit(1); } @@ -134,7 +135,7 @@ static int swap16(int i) static int find_header(struct cc_usb *cc) { for (;;) { - if (get_nonwhite(cc, 0) == 'M' && get_nonwhite(cc, 1000) == 'P') + if (get_nonwhite(cc, -1) == 'M' && get_nonwhite(cc, 1000) == 'P') return 1; } } @@ -165,9 +166,13 @@ main (int argc, char **argv) int i; int crc; int current_crc; + int wait = 0; - while ((c = getopt_long(argc, argv, "T:D:", options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "wT:D:", options, NULL)) != -1) { switch (c) { + case 'w': + wait = 1; + break; case 'T': tty = optarg; break; @@ -179,8 +184,21 @@ main (int argc, char **argv) break; } } - if (!tty) - tty = cc_usbdevs_find_by_arg(device, "FT230X Basic UART"); + if (!tty) { + for (;;) { + tty = cc_usbdevs_find_by_arg(device, "FT230X Basic UART"); + if (tty) { + if (wait) { + printf("tty is %s\n", tty); + sleep(1); + } + break; + } + if (!wait) + break; + sleep(1); + } + } if (!tty) tty = getenv("ALTOS_TTY"); if (!tty) diff --git a/ao-tools/lib/cc-usb.c b/ao-tools/lib/cc-usb.c index 1a4dc7a1..1e023c7e 100644 --- a/ao-tools/lib/cc-usb.c +++ b/ao-tools/lib/cc-usb.c @@ -207,8 +207,10 @@ _cc_usb_sync(struct cc_usb *cc, int wait_for_input, int write_timeout) write(2, cc->in_buf, cc->in_count); cc->in_count = 0; } - } else if (ret < 0) + } else if (ret <= 0) { perror("read"); + return -1; + } } if (fds.revents & POLLOUT) { ret = write(cc->fd, cc->out_buf, -- cgit v1.2.3 From fcb523cd083503591fa1277648e5deb258bbbaf4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:16:10 -0700 Subject: doc: Clarify what 'after motor' means Note that this means after motor burn-out, not after motor start. Signed-off-by: Keith Packard --- doc/altusmetrum.xsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/altusmetrum.xsl b/doc/altusmetrum.xsl index 1631983a..d44cd784 100644 --- a/doc/altusmetrum.xsl +++ b/doc/altusmetrum.xsl @@ -2620,9 +2620,9 @@ NAR #88757, TRA #12200 After Motor. The flight software counts each time the - rocket starts accelerating (presumably due to a motor or - motors igniting). Use this value to count ignitions for - multi-staged or multi-airstart launches. + rocket starts accelerating and then decelerating + (presumably due to a motor or motors burning). Use this + value for multi-staged or multi-airstart launches. -- cgit v1.2.3 From dba00b3d9102db99592f5822a703e64d98ace8bb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:17:01 -0700 Subject: altos: Support 32MHz xtal on cc1200 I ended up building some cc1200-based boards with 32MHz xtals, so just make this an option when building the driver. Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index df4bd335..6547be39 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -41,7 +41,11 @@ int8_t ao_radio_rssi; /* Last received RSSI value */ extern const uint32_t ao_radio_cal; +#ifdef AO_CC1200_FOSC +#define FOSC AO_CC1200_FOSC +#else #define FOSC 40000000 +#endif #define ao_radio_select() ao_spi_get_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS,AO_SPI_SPEED_FAST) #define ao_radio_deselect() ao_spi_put_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS) @@ -301,20 +305,28 @@ ao_radio_idle(void) * CHANBW = 5.0 (round to 9.5) */ +#if FOSC == 40000000 #define PACKET_SYMBOL_RATE_M 1013008 - #define PACKET_SYMBOL_RATE_E_384 8 +#define PACKET_SYMBOL_RATE_E_96 6 +#define PACKET_SYMBOL_RATE_E_24 4 +#endif + +#if FOSC == 32000000 +#define PACKET_SYMBOL_RATE_M 239914 +#define PACKET_SYMBOL_RATE_E_384 9 +#define PACKET_SYMBOL_RATE_E_96 7 +#define PACKET_SYMBOL_RATE_E_24 5 +#endif /* 200 / 2 = 100 */ #define PACKET_CHAN_BW_384 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_12 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (16 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -#define PACKET_SYMBOL_RATE_E_96 6 /* 200 / 10 = 20 */ #define PACKET_CHAN_BW_96 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_48 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (16 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -#define PACKET_SYMBOL_RATE_E_24 4 /* 200 / 25 = 8 */ #define PACKET_CHAN_BW_24 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_48 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (44 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -- cgit v1.2.3 From eac71f2b871357ff69581c713059a3741a82a932 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:22:10 -0700 Subject: microsplash: Add 'publish' target to Makefile This dumps the resulting binary and -load script into the Binaries directory of the altusmetrumllc repo Signed-off-by: Keith Packard --- src/microsplash/.gitignore | 3 ++- src/microsplash/Makefile | 43 +++++++++++++++++++++++------------ src/microsplash/microsplash-load.tmpl | 21 +++++++++++++++++ 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 src/microsplash/microsplash-load.tmpl diff --git a/src/microsplash/.gitignore b/src/microsplash/.gitignore index 5f6fe3b2..c2062c34 100644 --- a/src/microsplash/.gitignore +++ b/src/microsplash/.gitignore @@ -1,2 +1,3 @@ ao_product.h -microsplash-* +microsplash-v* +microsplash-load diff --git a/src/microsplash/Makefile b/src/microsplash/Makefile index 10cb825b..9bb636f1 100644 --- a/src/microsplash/Makefile +++ b/src/microsplash/Makefile @@ -8,8 +8,15 @@ vpath make-altitude-pa ../util include ../avr/Makefile.defs +PROGNAME=microsplash-v1.0 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SCRIPT=microsplash-load + PUBLISH_DIR=$(HOME)/altusmetrumllc/Binaries -PUBLISH_FILE=$(PUBLISH_DIR)/$(PROG)-$(VERSION).hex +PUBLISH_HEX=$(PUBLISH_DIR)/$(HEX) +PUBLISH_SCRIPT=$(PUBLISH_DIR)/$(SCRIPT) MCU=attiny85 DUDECPUTYPE=t85 @@ -48,15 +55,13 @@ INC=\ altitude-pa.h IDPRODUCT=0 -PRODUCT=MicroSplash-v0.1 +PRODUCT=MicroSplash-v1.0 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 -PROG=microsplash-v1.0 - SRC=$(ALTOS_SRC) OBJ=$(SRC:.c=.o) @@ -68,7 +73,7 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: $(PROG) $(PROG).hex +all: $(PROG) $(HEX) $(SCRIPT) CHECK=sh ../util/check-avr-mem @@ -76,16 +81,16 @@ $(PROG): Makefile $(OBJ) $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1) -$(PROG).hex: $(PROG) +$(HEX): $(PROG) avr-size $(PROG) $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@ -load: $(PROG).hex - $(LOADCMD) $(LOADARG)$(PROG).hex +load: $(HEX) + $(LOADCMD) $(LOADARG)$(HEX) -load-slow: $(PROG).hex - $(LOADCMD) $(LOADSLOW) $(LOADARG)$(PROG).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) > $@ @@ -98,22 +103,30 @@ ao_product.o: ao_product.c ao_product.h distclean: clean clean: - rm -f *.o $(PROG) $(PROG).hex + rm -f *.o $(PROG) $(HEX) $(SCRIPT) rm -f ao_product.h +publish: $(PUBLISH_HEX) $(PUBLISH_SCRIPT) -publish: $(PROG).hex - cp -a $(PROG).hex $(PUBLISH_FILE) +$(PUBLISH_HEX): $(HEX) + cp -a $(HEX) $@ + +$(PUBLISH_SCRIPT): $(SCRIPT) + cp -a $(SCRIPT) $@ load-product: - $(LOADCMD) $(LOADARG)$(PUBLISH_FILE) + ./$(SCRIPT) fast load-product-slow: - $(LOADCMD) $(LOADSLOW) $(LOADARG)$(PUBLISH_FILE) + ./$(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: diff --git a/src/microsplash/microsplash-load.tmpl b/src/microsplash/microsplash-load.tmpl new file mode 100644 index 00000000..c061559d --- /dev/null +++ b/src/microsplash/microsplash-load.tmpl @@ -0,0 +1,21 @@ +#!/bin/sh +dir=`dirname $0` + +HEX="$dir"/"%HEX%" +LOADCMD="%LOADCMD%" +LOADARG="%LOADARG%" +LOADSLOW="%LOADSLOW%" +LOADFAST="" + +case "$1" in +slow) + LOADSPEED="$LOADSLOW" + ;; +*) + LOADSPEED="$LOADFAST" + ;; +esac + +echo ${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX} +${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX} +/usr/games/xcowsay --cow-size=large --at=1000,500 "${HEX} finished" -- cgit v1.2.3 From f3ddaae82215e365726f2a62a3dc46bfb29eb1b5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:23:09 -0700 Subject: micropeak: Use fast load mode by default in -load script Speed up flashing in default config Signed-off-by: Keith Packard --- src/micropeak/micropeak-load.tmpl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/micropeak/micropeak-load.tmpl b/src/micropeak/micropeak-load.tmpl index 08236a15..c061559d 100644 --- a/src/micropeak/micropeak-load.tmpl +++ b/src/micropeak/micropeak-load.tmpl @@ -8,13 +8,14 @@ LOADSLOW="%LOADSLOW%" LOADFAST="" case "$1" in -fast) - LOADSPEED="$LOADFAST" +slow) + LOADSPEED="$LOADSLOW" ;; *) - LOADSPEED="$LOADSLOW" + LOADSPEED="$LOADFAST" ;; esac echo ${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX} ${LOADCMD} ${LOADSPEED} ${LOADARG}${HEX} +/usr/games/xcowsay --cow-size=large --at=1000,500 "${HEX} finished" -- cgit v1.2.3 From 59a28811cb19d315b483df296145a2769c445f80 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:25:05 -0700 Subject: Flip version to 1.6.0.2 Tag a version for development builds Signed-off-by: Keith Packard --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b09daa82..180da1cf 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ(2.57) -AC_INIT([altos], 1.6) +AC_INIT([altos], 1.6.0.2) AC_CONFIG_SRCDIR([src/kernel/ao.h]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 29edc37a8de56cb6eb028e3bf3f56aa70f109eba Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 21 May 2015 13:49:28 -0700 Subject: altoslib: Create display-independent map support code This takes the swing-specific map code and creates a generic version. Signed-off-by: Keith Packard --- altoslib/.gitignore | 1 + altoslib/AltosFlightDisplay.java | 26 +++ altoslib/AltosFontListener.java | 22 +++ altoslib/AltosImage.java | 25 +++ altoslib/AltosLatLon.java | 34 ++++ altoslib/AltosMap.java | 355 ++++++++++++++++++++++++++++++++++++ altoslib/AltosMapCache.java | 207 +++++++++++++++++++++ altoslib/AltosMapCacheListener.java | 22 +++ altoslib/AltosMapInterface.java | 47 +++++ altoslib/AltosMapLine.java | 83 +++++++++ altoslib/AltosMapMark.java | 38 ++++ altoslib/AltosMapPath.java | 67 +++++++ altoslib/AltosMapRectangle.java | 45 +++++ altoslib/AltosMapStore.java | 196 ++++++++++++++++++++ altoslib/AltosMapStoreListener.java | 22 +++ altoslib/AltosMapTile.java | 114 ++++++++++++ altoslib/AltosMapTileListener.java | 22 +++ altoslib/AltosMapTransform.java | 101 ++++++++++ altoslib/AltosMapZoomListener.java | 22 +++ altoslib/AltosPointDouble.java | 41 +++++ altoslib/AltosPointInt.java | 31 ++++ altoslib/AltosPreferences.java | 39 ++++ altoslib/AltosVersion.java.in | 28 +++ altoslib/Makefile.am | 23 ++- 24 files changed, 1610 insertions(+), 1 deletion(-) create mode 100644 altoslib/AltosFlightDisplay.java create mode 100644 altoslib/AltosFontListener.java create mode 100644 altoslib/AltosImage.java create mode 100644 altoslib/AltosLatLon.java create mode 100644 altoslib/AltosMap.java create mode 100644 altoslib/AltosMapCache.java create mode 100644 altoslib/AltosMapCacheListener.java create mode 100644 altoslib/AltosMapInterface.java create mode 100644 altoslib/AltosMapLine.java create mode 100644 altoslib/AltosMapMark.java create mode 100644 altoslib/AltosMapPath.java create mode 100644 altoslib/AltosMapRectangle.java create mode 100644 altoslib/AltosMapStore.java create mode 100644 altoslib/AltosMapStoreListener.java create mode 100644 altoslib/AltosMapTile.java create mode 100644 altoslib/AltosMapTileListener.java create mode 100644 altoslib/AltosMapTransform.java create mode 100644 altoslib/AltosMapZoomListener.java create mode 100644 altoslib/AltosPointDouble.java create mode 100644 altoslib/AltosPointInt.java create mode 100644 altoslib/AltosVersion.java.in diff --git a/altoslib/.gitignore b/altoslib/.gitignore index ff0fd710..dc8b7e5e 100644 --- a/altoslib/.gitignore +++ b/altoslib/.gitignore @@ -1,3 +1,4 @@ bin classaltoslib.stamp altoslib*.jar +AltosVersion.java diff --git a/altoslib/AltosFlightDisplay.java b/altoslib/AltosFlightDisplay.java new file mode 100644 index 00000000..157a0710 --- /dev/null +++ b/altoslib/AltosFlightDisplay.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosFlightDisplay extends AltosUnitsListener, AltosFontListener { + void reset(); + + void show(AltosState state, AltosListenerState listener_state); + + String getName(); +} diff --git a/altoslib/AltosFontListener.java b/altoslib/AltosFontListener.java new file mode 100644 index 00000000..74988139 --- /dev/null +++ b/altoslib/AltosFontListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosFontListener { + void font_size_changed(int font_size); +} diff --git a/altoslib/AltosImage.java b/altoslib/AltosImage.java new file mode 100644 index 00000000..9a9b5777 --- /dev/null +++ b/altoslib/AltosImage.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; + +public interface AltosImage { + /* Discard storage for image */ + public abstract void flush(); +} diff --git a/altoslib/AltosLatLon.java b/altoslib/AltosLatLon.java new file mode 100644 index 00000000..f1ecfc90 --- /dev/null +++ b/altoslib/AltosLatLon.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosLatLon { + public double lat; + public double lon; + + public boolean equals(AltosLatLon other) { + if (other == null) + return false; + return lat == other.lat && lon == other.lon; + } + + public AltosLatLon(double lat, double lon) { + this.lat = lat; + this.lon = lon; + } +} diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java new file mode 100644 index 00000000..b42f9f85 --- /dev/null +++ b/altoslib/AltosMap.java @@ -0,0 +1,355 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.util.concurrent.*; + +public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, AltosMapStoreListener { + + static final int px_size = 512; + + static final int maptype_hybrid = 0; + static final int maptype_roadmap = 1; + static final int maptype_satellite = 2; + static final int maptype_terrain = 3; + static final int maptype_default = maptype_hybrid; + + static final int default_zoom = 15; + static final int min_zoom = 3; + static final int max_zoom = 21; + + static final String[] maptype_names = { + "hybrid", + "roadmap", + "satellite", + "terrain" + }; + + public static final String[] maptype_labels = { + "Hybrid", + "Roadmap", + "Satellite", + "Terrain" + }; + + AltosMapInterface map_interface; + + AltosMapCache cache; + + LinkedList marks = new LinkedList(); + + LinkedList zoom_listeners = new LinkedList(); + + public void add_zoom_listener(AltosMapZoomListener listener) { + if (!zoom_listeners.contains(listener)) + zoom_listeners.add(listener); + } + + public void remove_zoom_listener(AltosMapZoomListener listener) { + zoom_listeners.remove(listener); + } + + boolean have_boost = false; + boolean have_landed = false; + + ConcurrentHashMap tiles = new ConcurrentHashMap(); + int load_radius; + AltosLatLon load_centre = null; + AltosMapTileListener load_listener; + + int zoom = AltosMap.default_zoom; + int maptype = AltosMap.maptype_default; + + long user_input_time; + + /* Milliseconds to wait after user action before auto-scrolling + */ + static final long auto_scroll_delay = 20 * 1000; + + AltosMapTransform transform; + AltosLatLon centre; + + public void reset() { + // nothing + } + + /* MapInterface wrapping functions */ + public void set_units() { + map_interface.set_units(); + } + + public void repaint(AltosMapRectangle damage, int pad) { + map_interface.repaint(damage, pad); + } + + public void repaint(double x, double y, double w, double h) { + map_interface.repaint(x, y, w, h); + } + + public void repaint() { + map_interface.repaint(); + } + + public int width() { + return map_interface.width(); + } + + public int height() { + return map_interface.height(); + } + + public AltosPointInt floor(AltosPointDouble point) { + return new AltosPointInt ((int) Math.floor(point.x / AltosMap.px_size) * AltosMap.px_size, + (int) Math.floor(point.y / AltosMap.px_size) * AltosMap.px_size); + } + + public AltosPointInt ceil(AltosPointDouble point) { + return new AltosPointInt ((int) Math.ceil(point.x / AltosMap.px_size) * AltosMap.px_size, + (int) Math.ceil(point.y / AltosMap.px_size) * AltosMap.px_size); + } + + public void notice_user_input() { + user_input_time = System.currentTimeMillis(); + } + + public boolean recent_user_input() { + return (System.currentTimeMillis() - user_input_time) < auto_scroll_delay; + } + + public boolean far_from_centre(AltosLatLon lat_lon) { + + if (centre == null || transform == null) + return true; + + AltosPointDouble screen = transform.screen(lat_lon); + + int width = width(); + int dx = Math.abs ((int) (double) screen.x - width/2); + + if (dx > width / 4) + return true; + + int height = height(); + int dy = Math.abs ((int) (double) screen.y - height/2); + + if (dy > height / 4) + return true; + + return false; + } + + public void font_size_changed(int font_size) { + map_interface.line.font_size_changed(font_size); + for (AltosMapTile tile : tiles.values()) + tile.font_size_changed(font_size); + repaint(); + } + + public void units_changed(boolean imperial_units) { + } + + private void set_transform() { + transform = new AltosMapTransform(width(), height(), zoom, centre); + repaint(); + } + + public boolean set_zoom(int zoom) { + if (AltosMap.min_zoom <= zoom && zoom <= AltosMap.max_zoom && zoom != this.zoom) { + this.zoom = zoom; + tiles.clear(); + set_transform(); + + for (AltosMapZoomListener listener : zoom_listeners) + listener.zoom_changed(this.zoom); + + return true; + } + return false; + } + + public int get_zoom() { + return zoom; + } + + public boolean set_maptype(int maptype) { + if (maptype != this.maptype) { + this.maptype = maptype; + tiles.clear(); + repaint(); + return true; + } + return false; + } + + public void show(AltosState state, AltosListenerState listener_state) { + + /* If insufficient gps data, nothing to update + */ + AltosGPS gps = state.gps; + + if (gps == null) + return; + + if (!gps.locked && gps.nsat < 4) + return; + + AltosMapRectangle damage = map_interface.path.add(gps.lat, gps.lon, state.state); + + switch (state.state) { + case AltosLib.ao_flight_boost: + if (!have_boost) { + add_mark(gps.lat, gps.lon, state.state); + have_boost = true; + } + break; + case AltosLib.ao_flight_landed: + if (!have_landed) { + add_mark(gps.lat, gps.lon, state.state); + have_landed = true; + } + break; + } + + if (damage != null) + repaint(damage, AltosMapPath.stroke_width); + maybe_centre(gps.lat, gps.lon); + } + + public void centre(AltosLatLon lat_lon) { + centre = lat_lon; + set_transform(); + } + + public void centre(double lat, double lon) { + centre(new AltosLatLon(lat, lon)); + } + + public void centre(AltosState state) { + if (!state.gps.locked && state.gps.nsat < 4) + return; + centre(state.gps.lat, state.gps.lon); + } + + public void maybe_centre(double lat, double lon) { + AltosLatLon lat_lon = new AltosLatLon(lat, lon); + if (centre == null || (!recent_user_input() && far_from_centre(lat_lon))) + centre(lat_lon); + } + + public void add_mark(double lat, double lon, int state) { + synchronized(marks) { + marks.add(map_interface.new_mark(lat, lon, state)); + } + repaint(); + } + + public void clear_marks() { + synchronized(marks) { + marks.clear(); + } + } + + private void make_tiles() { + AltosPointInt upper_left; + AltosPointInt lower_right; + + if (load_centre != null) { + AltosPointInt centre = floor(transform.point(load_centre)); + + upper_left = new AltosPointInt(centre.x - load_radius * AltosMap.px_size, + centre.y - load_radius * AltosMap.px_size); + lower_right = new AltosPointInt(centre.x + load_radius * AltosMap.px_size, + centre.y + load_radius * AltosMap.px_size); + } else { + upper_left = floor(transform.screen_point(new AltosPointDouble(0.0, 0.0))); + lower_right = floor(transform.screen_point(new AltosPointDouble(width(), height()))); + } + LinkedList to_remove = new LinkedList(); + + for (AltosPointInt point : tiles.keySet()) { + if (point.x < upper_left.x || lower_right.x < point.x || + point.y < upper_left.y || lower_right.y < point.y) { + to_remove.add(point); + } + } + + for (AltosPointInt point : to_remove) + tiles.remove(point); + + cache.set_cache_size((width() / AltosMap.px_size + 2) * (height() / AltosMap.px_size + 2)); + for (int y = (int) upper_left.y; y <= lower_right.y; y += AltosMap.px_size) { + for (int x = (int) upper_left.x; x <= lower_right.x; x += AltosMap.px_size) { + AltosPointInt point = new AltosPointInt(x, y); + + if (!tiles.containsKey(point)) { + AltosLatLon ul = transform.lat_lon(new AltosPointDouble(x, y)); + AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); + AltosMapTile tile = new AltosMapTile(this, ul, center, zoom, maptype, + AltosMap.px_size); + tiles.put(point, tile); + } + } + } + } + + public void set_load_params(double lat, double lon, int radius, AltosMapTileListener listener) { + load_centre = new AltosLatLon(lat, lon); + load_radius = radius; + load_listener = listener; + centre(lat, lon); + make_tiles(); + for (AltosMapTile tile : tiles.values()) { + tile.add_store_listener(this); + if (tile.store_status() != AltosMapTile.loading) + listener.notify_tile(tile, tile.store_status()); + } + repaint(); + } + + public String getName() { + return "Map"; + } + + /* AltosMapTileListener methods */ + public synchronized void notify_tile(AltosMapTile tile, int status) { + for (AltosPointInt point : tiles.keySet()) { + if (tile == tiles.get(point)) { + AltosPointInt screen = transform.screen(point); + repaint(screen.x, screen.y, AltosMap.px_size, AltosMap.px_size); + } + } + } + + /* AltosMapStoreListener methods */ + public synchronized void notify_store(AltosMapStore store, int status) { + if (load_listener != null) { + for (AltosMapTile tile : tiles.values()) + if (store.equals(tile.store)) + load_listener.notify_tile(tile, status); + } + } + + public AltosMap(AltosMapInterface map_interface) { + this.map_interface = map_interface; + cache = new AltosMapCache(map_interface); + centre(0, 0); + } +} diff --git a/altoslib/AltosMapCache.java b/altoslib/AltosMapCache.java new file mode 100644 index 00000000..d94bae6c --- /dev/null +++ b/altoslib/AltosMapCache.java @@ -0,0 +1,207 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.net.*; + +public class AltosMapCache implements AltosMapCacheListener { + + /* An entry in the MapCache */ + class MapCacheElement implements AltosMapStoreListener { + + AltosMapTile tile; /* Notify when image has been loaded */ + AltosImage image; + AltosMapStore store; + long used; + + class loader implements Runnable { + public void run() { + if (image != null) + tile.notify_image(image); + try { + image = map_interface.load_image(store.file); + } catch (Exception ex) { + } + if (image == null) + tile.set_status(AltosMapTile.failed); + else + tile.set_status(AltosMapTile.success); + tile.notify_image(image); + } + } + + private void load() { + loader l = new loader(); + Thread lt = new Thread(l); + lt.start(); + } + + public void flush() { + if (image != null) { + image.flush(); + image = null; + } + } + + public boolean has_map() { + return store.status() == AltosMapTile.success; + } + + public synchronized void notify_store(AltosMapStore store, int status) { + switch (status) { + case AltosMapTile.loading: + break; + case AltosMapTile.success: + load(); + break; + default: + tile.set_status(status); + tile.notify_image(null); + } + } + + public MapCacheElement(AltosMapTile tile, AltosMapStore store) throws IOException { + this.tile = tile; + this.image = null; + this.store = store; + this.used = 0; + + int status = store.status(); + switch (status) { + case AltosMapTile.loading: + store.add_listener(this); + break; + case AltosMapTile.success: + load(); + break; + default: + tile.set_status(status); + tile.notify_image(null); + break; + } + } + } + + int min_cache_size; /* configured minimum cache size */ + int cache_size; /* current cache size */ + int requested_cache_size; /* cache size computed by application */ + + private Object fetch_lock = new Object(); + private Object cache_lock = new Object(); + + AltosMapInterface map_interface; + + MapCacheElement[] elements = new MapCacheElement[cache_size]; + + long used; + + public void set_cache_size(int new_size) { + + requested_cache_size = new_size; + + if (new_size < min_cache_size) + new_size = min_cache_size; + + if (new_size == cache_size) + return; + + synchronized(cache_lock) { + MapCacheElement[] new_elements = new MapCacheElement[new_size]; + + for (int i = 0; i < cache_size; i++) { + if (i < new_size) + new_elements[i] = elements[i]; + else if (elements[i] != null) + elements[i].flush(); + } + elements = new_elements; + cache_size = new_size; + } + } + + public AltosImage get(AltosMapTile tile, AltosMapStore store, int width, int height) { + int oldest = -1; + long age = used; + + synchronized(cache_lock) { + MapCacheElement element = null; + for (int i = 0; i < cache_size; i++) { + element = elements[i]; + + if (element == null) { + oldest = i; + break; + } + if (store.equals(element.store)) { + element.used = used++; + return element.image; + } + if (element.used < age) { + oldest = i; + age = element.used; + } + } + + try { + element = new MapCacheElement(tile, store); + element.used = used++; + if (elements[oldest] != null) + elements[oldest].flush(); + + elements[oldest] = element; + + if (element.image == null) + tile.set_status(AltosMapTile.loading); + else + tile.set_status(AltosMapTile.success); + + return element.image; + } catch (IOException e) { + tile.set_status(AltosMapTile.failed); + return null; + } + } + } + + public void map_cache_changed(int map_cache) { + min_cache_size = map_cache; + + set_cache_size(requested_cache_size); + } + + public void dispose() { + AltosPreferences.unregister_map_cache_listener(this); + + for (int i = 0; i < cache_size; i++) { + MapCacheElement element = elements[i]; + + if (element != null) + element.flush(); + } + } + + public AltosMapCache(AltosMapInterface map_interface) { + this.map_interface = map_interface; + min_cache_size = AltosPreferences.map_cache(); + + set_cache_size(0); + + AltosPreferences.register_map_cache_listener(this); + } +} diff --git a/altoslib/AltosMapCacheListener.java b/altoslib/AltosMapCacheListener.java new file mode 100644 index 00000000..49b075dd --- /dev/null +++ b/altoslib/AltosMapCacheListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosMapCacheListener { + public void map_cache_changed(int map_cache); +} diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java new file mode 100644 index 00000000..ea5454de --- /dev/null +++ b/altoslib/AltosMapInterface.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.net.*; + +public abstract class AltosMapInterface { + + public AltosMapPath path; + public AltosMapLine line; + + public abstract AltosImage load_image(File file) throws Exception; + + public abstract AltosMapMark new_mark(double lat, double lon, int state); + + public abstract int width(); + public abstract int height(); + + public abstract void repaint(); + + public abstract void repaint(AltosMapRectangle damage, int pad); + + public abstract void repaint(double x, double y, double w, double h); + + public abstract void set_units(); + + public AltosMapInterface (AltosMapPath path, AltosMapLine line) { + this.path = path; + this.line = line; + } +} diff --git a/altoslib/AltosMapLine.java b/altoslib/AltosMapLine.java new file mode 100644 index 00000000..83de47f9 --- /dev/null +++ b/altoslib/AltosMapLine.java @@ -0,0 +1,83 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.Math; +import java.util.*; +import java.util.concurrent.*; + +public abstract class AltosMapLine implements AltosFontListener { + AltosLatLon start, end; + + static public int stroke_width = 6; + + public abstract void font_size_changed(int font_size); + + private AltosLatLon lat_lon(AltosPointDouble pt, AltosMapTransform t) { + return t.screen_lat_lon(pt); + } + + public void dragged(AltosPointDouble pt, AltosMapTransform t) { + end = lat_lon(pt, t); + } + + public void pressed(AltosPointDouble pt, AltosMapTransform t) { + start = lat_lon(pt, t); + end = null; + } + + private String line_dist() { + String format; + AltosGreatCircle g = new AltosGreatCircle(start.lat, start.lon, + end.lat, end.lon); + double distance = g.distance; + + if (AltosConvert.imperial_units) { + distance = AltosConvert.meters_to_feet(distance); + if (distance < 10000) { + format = "%4.0fft"; + } else { + distance /= 5280; + if (distance < 10) + format = "%5.3fmi"; + else if (distance < 100) + format = "%5.2fmi"; + else if (distance < 1000) + format = "%5.1fmi"; + else + format = "%5.0fmi"; + } + } else { + if (distance < 10000) { + format = "%4.0fm"; + } else { + distance /= 1000; + if (distance < 100) + format = "%5.2fkm"; + else if (distance < 1000) + format = "%5.1fkm"; + else + format = "%5.0fkm"; + } + } + return String.format(format, distance); + } + + public abstract void paint(AltosMapTransform t); +} diff --git a/altoslib/AltosMapMark.java b/altoslib/AltosMapMark.java new file mode 100644 index 00000000..9b77d539 --- /dev/null +++ b/altoslib/AltosMapMark.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.Math; +import java.util.*; +import java.util.concurrent.*; + +public abstract class AltosMapMark { + + AltosLatLon lat_lon; + int state; + + static public int stroke_width = 6; + + public abstract void paint(AltosMapTransform t); + + public AltosMapMark (double lat, double lon, int state) { + lat_lon = new AltosLatLon(lat, lon); + this.state = state; + } +} diff --git a/altoslib/AltosMapPath.java b/altoslib/AltosMapPath.java new file mode 100644 index 00000000..272a4316 --- /dev/null +++ b/altoslib/AltosMapPath.java @@ -0,0 +1,67 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.Math; +import java.util.*; +import java.util.concurrent.*; + +class PathPoint { + AltosLatLon lat_lon; + int state; + + public PathPoint(AltosLatLon lat_lon, int state) { + this.lat_lon = lat_lon; + this.state = state; + } + + public boolean equals(PathPoint other) { + if (other == null) + return false; + + return lat_lon.equals(other.lat_lon) && state == other.state; + } +} + +public abstract class AltosMapPath { + + LinkedList points = new LinkedList(); + PathPoint last_point = null; + + static public int stroke_width = 6; + + public abstract void paint(AltosMapTransform t); + + public AltosMapRectangle add(double lat, double lon, int state) { + PathPoint point = new PathPoint(new AltosLatLon (lat, lon), state); + AltosMapRectangle rect = null; + + if (!point.equals(last_point)) { + if (last_point != null) + rect = new AltosMapRectangle(last_point.lat_lon, point.lat_lon); + points.add (point); + last_point = point; + } + return rect; + } + + public void clear () { + points = new LinkedList(); + } +} diff --git a/altoslib/AltosMapRectangle.java b/altoslib/AltosMapRectangle.java new file mode 100644 index 00000000..f2f30103 --- /dev/null +++ b/altoslib/AltosMapRectangle.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosMapRectangle { + AltosLatLon ul, lr; + + public AltosMapRectangle(AltosLatLon a, AltosLatLon b) { + double ul_lat, ul_lon; + double lr_lat, lr_lon; + + if (a.lat > b.lat) { + ul_lat = a.lat; + lr_lat = b.lat; + } else { + ul_lat = b.lat; + lr_lat = a.lat; + } + if (a.lon < b.lon) { + ul_lon = a.lon; + lr_lon = b.lon; + } else { + ul_lon = b.lon; + lr_lon = a.lon; + } + + ul = new AltosLatLon(ul_lat, ul_lon); + lr = new AltosLatLon(lr_lat, lr_lon); + } +} diff --git a/altoslib/AltosMapStore.java b/altoslib/AltosMapStore.java new file mode 100644 index 00000000..2f52edb6 --- /dev/null +++ b/altoslib/AltosMapStore.java @@ -0,0 +1,196 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.net.*; +import java.util.*; + +public class AltosMapStore { + String url; + public File file; + LinkedList listeners = new LinkedList(); + + int status; + + public int status() { + return status; + } + + public synchronized void add_listener(AltosMapStoreListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public synchronized void remove_listener(AltosMapStoreListener listener) { + listeners.remove(listener); + } + + private synchronized void notify_listeners(int status) { + this.status = status; + for (AltosMapStoreListener listener : listeners) + listener.notify_store(this, status); + } + + static Object forbidden_lock = new Object(); + static long forbidden_time; + static boolean forbidden_set; + + private int fetch_url() { + URL u; + + try { + u = new URL(url); + } catch (java.net.MalformedURLException e) { + return AltosMapTile.bad_request; + } + + byte[] data; + URLConnection uc = null; + try { + uc = u.openConnection(); + String type = uc.getContentType(); + int contentLength = uc.getContentLength(); + if (uc instanceof HttpURLConnection) { + int response = ((HttpURLConnection) uc).getResponseCode(); + switch (response) { + case HttpURLConnection.HTTP_FORBIDDEN: + case HttpURLConnection.HTTP_PAYMENT_REQUIRED: + case HttpURLConnection.HTTP_UNAUTHORIZED: + synchronized (forbidden_lock) { + forbidden_time = System.nanoTime(); + forbidden_set = true; + return AltosMapTile.forbidden; + } + } + } + InputStream in = new BufferedInputStream(uc.getInputStream()); + int bytesRead = 0; + int offset = 0; + data = new byte[contentLength]; + while (offset < contentLength) { + bytesRead = in.read(data, offset, data.length - offset); + if (bytesRead == -1) + break; + offset += bytesRead; + } + in.close(); + + if (offset != contentLength) + return AltosMapTile.failed; + + } catch (IOException e) { + return AltosMapTile.failed; + } + + try { + FileOutputStream out = new FileOutputStream(file); + out.write(data); + out.flush(); + out.close(); + } catch (FileNotFoundException e) { + return AltosMapTile.bad_request; + } catch (IOException e) { + if (file.exists()) + file.delete(); + return AltosMapTile.bad_request; + } + return AltosMapTile.success; + } + + static Object fetch_lock = new Object(); + + static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; + static final long google_maps_ratelimit_ms = 1200; + + class loader implements Runnable { + + public void run() { + if (file.exists()) { + notify_listeners(AltosMapTile.success); + return; + } + + synchronized(forbidden_lock) { + if (forbidden_set && (System.nanoTime() - forbidden_time) < forbidden_interval) { + notify_listeners(AltosMapTile.forbidden); + return; + } + } + + int new_status; + + if (!AltosVersion.has_google_maps_api_key()) { + synchronized (fetch_lock) { + long startTime = System.nanoTime(); + new_status = fetch_url(); + if (new_status == AltosMapTile.success) { + long duration_ms = (System.nanoTime() - startTime) / 1000000; + if (duration_ms < google_maps_ratelimit_ms) { + try { + Thread.sleep(google_maps_ratelimit_ms - duration_ms); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + } + } + } else { + new_status = fetch_url(); + } + notify_listeners(new_status); + } + } + + private void load() { + loader l = new loader(); + Thread lt = new Thread(l); + lt.start(); + } + + private AltosMapStore (String url, File file) { + this.url = url; + this.file = file; + + if (file.exists()) + status = AltosMapTile.success; + else { + status = AltosMapTile.loading; + load(); + } + } + + public boolean equals(AltosMapStore other) { + return url.equals(other.url); + } + + static HashMap stores = new HashMap(); + + public static AltosMapStore get(String url, File file) { + AltosMapStore store; + synchronized(stores) { + if (stores.containsKey(url)) { + store = stores.get(url); + } else { + store = new AltosMapStore(url, file); + stores.put(url, store); + } + } + return store; + } +} diff --git a/altoslib/AltosMapStoreListener.java b/altoslib/AltosMapStoreListener.java new file mode 100644 index 00000000..a272e864 --- /dev/null +++ b/altoslib/AltosMapStoreListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosMapStoreListener { + abstract void notify_store(AltosMapStore store, int status); +} diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java new file mode 100644 index 00000000..b5dee7a4 --- /dev/null +++ b/altoslib/AltosMapTile.java @@ -0,0 +1,114 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.util.*; + +public class AltosMapTile implements AltosFontListener { + AltosMapTileListener listener; + AltosLatLon upper_left, center; + int px_size; + int zoom; + int maptype; + AltosMapStore store; + AltosMapCache cache; + int status; + + static public final int success = 0; + static public final int loading = 1; + static public final int failed = 2; + static public final int bad_request = 3; + static public final int forbidden = 4; + + private File map_file() { + double lat = center.lat; + double lon = center.lon; + char chlat = lat < 0 ? 'S' : 'N'; + char chlon = lon < 0 ? 'W' : 'E'; + + if (lat < 0) lat = -lat; + if (lon < 0) lon = -lon; + String maptype_string = String.format("%s-", AltosMap.maptype_names[maptype]); + String format_string; + if (maptype == AltosMap.maptype_hybrid || maptype == AltosMap.maptype_satellite || maptype == AltosMap.maptype_terrain) + format_string = "jpg"; + else + format_string = "png"; + return new File(AltosPreferences.mapdir(), + String.format("map-%c%.6f,%c%.6f-%s%d.%s", + chlat, lat, chlon, lon, maptype_string, zoom, format_string)); + } + + private String map_url() { + String format_string; + if (maptype == AltosMap.maptype_hybrid || maptype == AltosMap.maptype_satellite || maptype == AltosMap.maptype_terrain) + format_string = "jpg"; + else + format_string = "png32"; + + if (AltosVersion.has_google_maps_api_key()) + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s&key=%s", + center.lat, center.lon, zoom, px_size, px_size, AltosMap.maptype_names[maptype], format_string, AltosVersion.google_maps_api_key); + else + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", + center.lat, center.lon, zoom, px_size, px_size, AltosMap.maptype_names[maptype], format_string); + } + + public void font_size_changed(int font_size) { + } + + public void set_status(int status) { + this.status = status; + listener.notify_tile(this, status); + } + + public void notify_image(AltosImage image) { + listener.notify_tile(this, status); + } + + public int store_status() { + return store.status(); + } + + public void add_store_listener(AltosMapStoreListener listener) { + store.add_listener(listener); + } + + public void remove_store_listener(AltosMapStoreListener listener) { + store.remove_listener(listener); + } + + public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + this.listener = listener; + this.upper_left = upper_left; + + while (center.lon < -180.0) + center.lon += 360.0; + while (center.lon > 180.0) + center.lon -= 360.0; + + this.center = center; + this.zoom = zoom; + this.maptype = maptype; + this.px_size = px_size; + + status = AltosMapTile.loading; + store = AltosMapStore.get(map_url(), map_file()); + } +} diff --git a/altoslib/AltosMapTileListener.java b/altoslib/AltosMapTileListener.java new file mode 100644 index 00000000..8abc8b5a --- /dev/null +++ b/altoslib/AltosMapTileListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosMapTileListener { + abstract public void notify_tile(AltosMapTile tile, int status); +} diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java new file mode 100644 index 00000000..f5fc5ebe --- /dev/null +++ b/altoslib/AltosMapTransform.java @@ -0,0 +1,101 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.Math; +import java.util.*; +import java.util.concurrent.*; + +public class AltosMapTransform { + + double scale_x, scale_y; + + double offset_x, offset_y; + + public AltosLatLon lat_lon (AltosPointDouble point) { + double lat, lon; + double rads; + + lon = point.x/scale_x; + rads = 2 * Math.atan(Math.exp(-point.y/scale_y)); + lat = Math.toDegrees(rads - Math.PI/2); + + return new AltosLatLon(lat,lon); + } + + public AltosPointDouble screen_point(AltosPointDouble screen) { + return new AltosPointDouble(screen.x + offset_x, screen.y + offset_y); + } + + public AltosLatLon screen_lat_lon(AltosPointDouble screen) { + return lat_lon(screen_point(screen)); + } + + public AltosPointDouble point(AltosLatLon lat_lon) { + double x, y; + double e; + + x = lat_lon.lon * scale_x; + + e = Math.sin(Math.toRadians(lat_lon.lat)); + e = Math.max(e,-(1-1.0E-15)); + e = Math.min(e, 1-1.0E-15 ); + + y = 0.5*Math.log((1+e)/(1-e))*-scale_y; + + return new AltosPointDouble(x, y); + } + + public AltosPointDouble screen(AltosPointDouble point) { + return new AltosPointDouble(point.x - offset_x, point.y - offset_y); + } + + public AltosPointInt screen(AltosPointInt point) { + return new AltosPointInt((int) (point.x - offset_x + 0.5), + (int) (point.y - offset_y + 0.5)); + } + +// public Rectangle screen(AltosMapRectangle map_rect) { +// AltosPoint2D ul = screen(map_rect.ul); +// AltosPoint2D lr = screen(map_rect.lr); +// +// return new Rectangle((int) ul.x, (int) ul.y, (int) (lr.x - ul.x), (int) (lr.y - ul.y)); +// } + + public AltosPointDouble screen(AltosLatLon lat_lon) { + return screen(point(lat_lon)); + } + + private boolean has_location; + + public boolean has_location() { + return has_location; + } + + public AltosMapTransform(int width, int height, int zoom, AltosLatLon centre_lat_lon) { + scale_x = 256/360.0 * Math.pow(2, zoom); + scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); + + AltosPointDouble centre_pt = point(centre_lat_lon); + + has_location = (centre_lat_lon.lat != 0 || centre_lat_lon.lon != 0); + offset_x = centre_pt.x - width / 2.0; + offset_y = centre_pt.y - height / 2.0; + } +} diff --git a/altoslib/AltosMapZoomListener.java b/altoslib/AltosMapZoomListener.java new file mode 100644 index 00000000..34edb19b --- /dev/null +++ b/altoslib/AltosMapZoomListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public interface AltosMapZoomListener { + abstract public void zoom_changed(int zoom); +} diff --git a/altoslib/AltosPointDouble.java b/altoslib/AltosPointDouble.java new file mode 100644 index 00000000..96fb9161 --- /dev/null +++ b/altoslib/AltosPointDouble.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosPointDouble { + public double x, y; + + public boolean equals(AltosPointDouble n) { + return n.x == x && n.y == y; + } + + public AltosPointDouble(double x, double y) { + this.x = x; + this.y = y; + } + + public AltosPointDouble(int x, int y) { + this.x = x; + this.y = y; + } + + public AltosPointDouble(AltosPointInt p) { + this.x = p.x; + this.y = p.y; + } +} diff --git a/altoslib/AltosPointInt.java b/altoslib/AltosPointInt.java new file mode 100644 index 00000000..6ee077ab --- /dev/null +++ b/altoslib/AltosPointInt.java @@ -0,0 +1,31 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosPointInt { + public int x, y; + + public boolean equals(AltosPointInt n) { + return n.x == x && n.y == y; + } + + public AltosPointInt(int x, int y) { + this.x = x; + this.y = y; + } +} diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 5aa45d3f..9c4cadff 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -118,6 +118,13 @@ public class AltosPreferences { public final static String unitsPreference = "IMPERIAL-UNITS"; + /* Maps cache size preference name */ + final static String mapCachePreference = "MAP-CACHE"; + + static LinkedList map_cache_listeners; + + public static int map_cache = 9; + public static AltosFrequency[] load_common_frequencies() { AltosFrequency[] frequencies = null; boolean existing = false; @@ -208,6 +215,9 @@ public class AltosPreferences { common_frequencies = load_common_frequencies(); AltosConvert.imperial_units = backend.getBoolean(unitsPreference, false); + + map_cache = backend.getInt(mapCachePreference, 9); + map_cache_listeners = new LinkedList(); } public static void flush_preferences() { @@ -548,4 +558,33 @@ public class AltosPreferences { units_listeners.remove(l); } } + + + public static void register_map_cache_listener(AltosMapCacheListener l) { + synchronized(backend) { + map_cache_listeners.add(l); + } + } + + public static void unregister_map_cache_listener(AltosMapCacheListener l) { + synchronized (backend) { + map_cache_listeners.remove(l); + } + } + + public static void set_map_cache(int new_map_cache) { + synchronized(backend) { + map_cache = new_map_cache; + backend.putInt(mapCachePreference, map_cache); + flush_preferences(); + for (AltosMapCacheListener l: map_cache_listeners) + l.map_cache_changed(map_cache); + } + } + + public static int map_cache() { + synchronized(backend) { + return map_cache; + } + } } diff --git a/altoslib/AltosVersion.java.in b/altoslib/AltosVersion.java.in new file mode 100644 index 00000000..6bfef181 --- /dev/null +++ b/altoslib/AltosVersion.java.in @@ -0,0 +1,28 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosVersion { + public final static String version = "@VERSION@"; + + public final static String google_maps_api_key = @GOOGLEKEY@; + + static boolean has_google_maps_api_key() { + return google_maps_api_key != null && google_maps_api_key.length() > 1; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index c640c69c..0ee7b935 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -128,7 +128,28 @@ altoslib_JAVA = \ AltosPyro.java \ AltosWriter.java \ AltosQuaternion.java \ - AltosRotation.java + AltosRotation.java \ + AltosImage.java \ + AltosLatLon.java \ + AltosMap.java \ + AltosMapCache.java \ + AltosMapCacheListener.java \ + AltosMapInterface.java \ + AltosMapLine.java \ + AltosMapMark.java \ + AltosMapPath.java \ + AltosMapRectangle.java \ + AltosMapStore.java \ + AltosMapStoreListener.java \ + AltosMapTile.java \ + AltosMapTileListener.java \ + AltosMapTransform.java \ + AltosMapZoomListener.java \ + AltosPointDouble.java \ + AltosPointInt.java \ + AltosFlightDisplay.java \ + AltosFontListener.java \ + AltosVersion.java JAR=altoslib_$(ALTOSLIB_VERSION).jar -- cgit v1.2.3 From e7c25e3ba04b1e9f8e6fa31e2d464fe96a074dad Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 24 May 2015 17:25:25 -0700 Subject: telefire: Make 'good' RSSI value configurable Different radios will have different 'good' RSSI values, so let each product configure it, leaving the default set to -90dBm, which is a solid signal value for the CC1111. Signed-off-by: Keith Packard --- src/drivers/ao_pad.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index dc2c83fe..3ad239cc 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -29,6 +29,10 @@ static __pdata uint8_t ao_pad_box; static __xdata uint8_t ao_pad_disabled; static __pdata uint16_t ao_pad_packet_time; +#ifndef AO_PAD_RSSI_MINIMUM +#define AO_PAD_RSSI_MINIMUM -90 +#endif + #define DEBUG 1 #if DEBUG @@ -36,8 +40,8 @@ static __pdata uint8_t ao_pad_debug; #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0) #define FLUSHD() (ao_pad_debug ? (flush(), 0) : 0) #else -#define PRINTD(...) -#define FLUSHD() +#define PRINTD(...) +#define FLUSHD() #endif static void @@ -138,7 +142,7 @@ ao_pad_monitor(void) } if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2)) cur |= AO_LED_RED; - else if (ao_radio_cmac_rssi < -90) + else if (ao_radio_cmac_rssi < AO_PAD_RSSI_MINIMUM) cur |= AO_LED_AMBER; else cur |= AO_LED_GREEN; @@ -255,7 +259,7 @@ ao_pad(void) if (ret != AO_RADIO_CMAC_OK) continue; ao_pad_packet_time = ao_time(); - + ao_pad_box = ao_pad_read_box(); PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n", -- cgit v1.2.3 From 0e76cb2a7d5db24b6cecdccb6fb8d5bf5527fadf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 24 May 2015 17:28:07 -0700 Subject: altos: Only set CMAC RSSI value on valid packet received This ignores spurious packets for the purpose of showing the RSSI value in telelco/telefire, avoiding warning about 'low RSSI' when the radio receives noise. Signed-off-by: Keith Packard --- src/kernel/ao_radio_cmac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kernel/ao_radio_cmac.c b/src/kernel/ao_radio_cmac.c index bff848f6..b6835346 100644 --- a/src/kernel/ao_radio_cmac.c +++ b/src/kernel/ao_radio_cmac.c @@ -91,7 +91,6 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant return AO_RADIO_CMAC_TIMEOUT; } - ao_radio_cmac_rssi = ao_radio_rssi; if (!(cmac_data[len + AO_CMAC_KEY_LEN +1] & AO_RADIO_STATUS_CRC_OK)) return AO_RADIO_CMAC_CRC_ERROR; @@ -114,13 +113,15 @@ radio_cmac_recv(uint8_t len, uint16_t timeout) __reentrant /* Check the packet signature against the signature provided * over the link */ - + if (memcmp(&cmac_data[len], &cmac_data[len + AO_CMAC_KEY_LEN + 2], AO_CMAC_KEY_LEN) != 0) { return AO_RADIO_CMAC_MAC_ERROR; } + ao_radio_cmac_rssi = ao_radio_rssi; + return AO_RADIO_CMAC_OK; } @@ -161,4 +162,3 @@ ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentr ao_mutex_put(&ao_radio_cmac_mutex); return i; } - -- cgit v1.2.3 From 9b268351aee44de959dcc4c792189c10a00428fe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 13:23:54 -0700 Subject: telefire: Report telefire battery voltage over telemetry link Signed-off-by: Keith Packard --- src/drivers/ao_pad.c | 2 ++ src/drivers/ao_pad.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/drivers/ao_pad.c b/src/drivers/ao_pad.c index 3ad239cc..ffe46c68 100644 --- a/src/drivers/ao_pad.c +++ b/src/drivers/ao_pad.c @@ -127,6 +127,8 @@ ao_pad_monitor(void) #define VOLTS_TO_PYRO(x) ((int16_t) ((x) * 27.0 / 127.0 / 3.3 * 32767.0)) + /* convert ADC value to voltage in tenths, then add .2 for the diode drop */ + query.battery = (packet->adc.batt + 96) / 192 + 2; cur = 0; if (pyro > VOLTS_TO_PYRO(10)) { query.arm_status = AO_PAD_ARM_STATUS_ARMED; diff --git a/src/drivers/ao_pad.h b/src/drivers/ao_pad.h index 23062899..d77d105a 100644 --- a/src/drivers/ao_pad.h +++ b/src/drivers/ao_pad.h @@ -39,6 +39,7 @@ struct ao_pad_query { uint8_t channels; /* which chanels are present */ uint8_t armed; /* which channels are armed */ uint8_t arm_status; /* status of arming switch */ + uint8_t battery; /* battery voltage in decivolts */ uint8_t igniter_status[AO_PAD_MAX_CHANNELS]; /* status for each igniter */ }; -- cgit v1.2.3 From a54aac3361b7bd18f111e5ba06fb89015504b8a4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 15:47:46 -0700 Subject: altos: Add telelco v0.3 (v0.2 with cc1200 instead of cc1120) Signed-off-by: Keith Packard --- src/Makefile | 1 + src/drivers/ao_lco.c | 399 ++++++++++++++++++++++++++++++++ src/drivers/ao_lco.h | 24 ++ src/telelco-v0.2/ao_lco.c | 399 -------------------------------- src/telelco-v0.2/ao_lco.h | 24 -- src/telelco-v0.3/.gitignore | 2 + src/telelco-v0.3/Makefile | 108 +++++++++ src/telelco-v0.3/ao_pins.h | 269 +++++++++++++++++++++ src/telelco-v0.3/ao_telelco.c | 70 ++++++ src/telelco-v0.3/flash-loader/Makefile | 8 + src/telelco-v0.3/flash-loader/ao_pins.h | 34 +++ 11 files changed, 915 insertions(+), 423 deletions(-) create mode 100644 src/drivers/ao_lco.c create mode 100644 src/drivers/ao_lco.h delete mode 100644 src/telelco-v0.2/ao_lco.c delete mode 100644 src/telelco-v0.2/ao_lco.h create mode 100644 src/telelco-v0.3/.gitignore create mode 100644 src/telelco-v0.3/Makefile create mode 100644 src/telelco-v0.3/ao_pins.h create mode 100644 src/telelco-v0.3/ao_telelco.c create mode 100644 src/telelco-v0.3/flash-loader/Makefile create mode 100644 src/telelco-v0.3/flash-loader/ao_pins.h diff --git a/src/Makefile b/src/Makefile index d4c8a86f..dc74bf8c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,6 +34,7 @@ ARMM3DIRS=\ telegps-v0.3 telegps-v0.3/flash-loader \ telegps-v1.0 telegps-v1.0/flash-loader \ telelco-v0.2 telelco-v0.2/flash-loader \ + telelco-v0.3 telelco-v0.3/flash-loader \ telescience-v0.2 telescience-v0.2/flash-loader \ teledongle-v3.0 teledongle-v3.0/flash-loader \ teleballoon-v2.0 \ diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c new file mode 100644 index 00000000..12a247bf --- /dev/null +++ b/src/drivers/ao_lco.c @@ -0,0 +1,399 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG 1 + +#if DEBUG +static uint8_t ao_lco_debug; +#define PRINTD(...) do { if (!ao_lco_debug) break; printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0) +#else +#define PRINTD(...) +#endif + +#define AO_LCO_PAD_DIGIT 0 +#define AO_LCO_BOX_DIGIT_1 1 +#define AO_LCO_BOX_DIGIT_10 2 + +static uint8_t ao_lco_min_box, ao_lco_max_box; +static uint8_t ao_lco_pad; +static uint8_t ao_lco_box; +static uint8_t ao_lco_armed; +static uint8_t ao_lco_firing; +static uint8_t ao_lco_valid; +static uint8_t ao_lco_got_channels; +static uint16_t ao_lco_tick_offset; + +static struct ao_pad_query ao_pad_query; + +static void +ao_lco_set_pad(uint8_t pad) +{ + ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad + 1); +} + +static void +ao_lco_set_box(uint8_t box) +{ + ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10); + ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10); +} + +#define MASK_SIZE(n) (((n) + 7) >> 3) +#define MASK_ID(n) ((n) >> 3) +#define MASK_SHIFT(n) ((n) & 7) + +static uint8_t ao_lco_box_mask[MASK_SIZE(AO_PAD_MAX_BOXES)]; + +static uint8_t +ao_lco_box_present(uint8_t box) +{ + if (box >= AO_PAD_MAX_BOXES) + return 0; + return (ao_lco_box_mask[MASK_ID(box)] >> MASK_SHIFT(box)) & 1; +} + +static uint8_t +ao_lco_pad_present(uint8_t pad) +{ + if (!ao_lco_got_channels || !ao_pad_query.channels) + return pad == 0; + if (pad >= AO_PAD_MAX_CHANNELS) + return 0; + return (ao_pad_query.channels >> pad) & 1; +} + +static uint8_t +ao_lco_pad_first(void) +{ + uint8_t pad; + + for (pad = 0; pad < AO_PAD_MAX_CHANNELS; pad++) + if (ao_lco_pad_present(pad)) + return pad; + return 0; +} + +static void +ao_lco_input(void) +{ + static struct ao_event event; + int8_t dir, new_box, new_pad; + + ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); + for (;;) { + ao_event_get(&event); + PRINTD("event type %d unit %d value %d\n", + event.type, event.unit, event.value); + switch (event.type) { + case AO_EVENT_QUADRATURE: + switch (event.unit) { + case AO_QUADRATURE_PAD: + if (!ao_lco_armed) { + dir = (int8_t) event.value; + new_pad = ao_lco_pad; + do { + new_pad += dir; + if (new_pad > AO_PAD_MAX_CHANNELS) + new_pad = 0; + else if (new_pad < 0) + new_pad = AO_PAD_MAX_CHANNELS - 1; + if (new_pad == ao_lco_pad) + break; + } while (!ao_lco_pad_present(new_pad)); + if (new_pad != ao_lco_pad) { + ao_lco_pad = new_pad; + ao_lco_set_pad(ao_lco_pad); + } + } + break; + case AO_QUADRATURE_BOX: + if (!ao_lco_armed) { + dir = (int8_t) event.value; + new_box = ao_lco_box; + do { + new_box += dir; + if (new_box > ao_lco_max_box) + new_box = ao_lco_min_box; + else if (new_box < ao_lco_min_box) + new_box = ao_lco_max_box; + if (new_box == ao_lco_box) + break; + } while (!ao_lco_box_present(new_box)); + if (ao_lco_box != new_box) { + ao_lco_box = new_box; + ao_lco_got_channels = 0; + ao_lco_set_box(ao_lco_box); + } + } + break; + } + break; + case AO_EVENT_BUTTON: + switch (event.unit) { + case AO_BUTTON_ARM: + ao_lco_armed = event.value; + PRINTD("Armed %d\n", ao_lco_armed); + ao_wakeup(&ao_lco_armed); + break; + case AO_BUTTON_FIRE: + if (ao_lco_armed) { + ao_lco_firing = event.value; + PRINTD("Firing %d\n", ao_lco_firing); + ao_wakeup(&ao_lco_armed); + } + break; + } + break; + } + } +} + +static AO_LED_TYPE continuity_led[AO_LED_CONTINUITY_NUM] = { +#ifdef AO_LED_CONTINUITY_0 + AO_LED_CONTINUITY_0, +#endif +#ifdef AO_LED_CONTINUITY_1 + AO_LED_CONTINUITY_1, +#endif +#ifdef AO_LED_CONTINUITY_2 + AO_LED_CONTINUITY_2, +#endif +#ifdef AO_LED_CONTINUITY_3 + AO_LED_CONTINUITY_3, +#endif +#ifdef AO_LED_CONTINUITY_4 + AO_LED_CONTINUITY_4, +#endif +#ifdef AO_LED_CONTINUITY_5 + AO_LED_CONTINUITY_5, +#endif +#ifdef AO_LED_CONTINUITY_6 + AO_LED_CONTINUITY_6, +#endif +#ifdef AO_LED_CONTINUITY_7 + AO_LED_CONTINUITY_7, +#endif +}; + +static void +ao_lco_update(void) +{ + int8_t r; + uint8_t c; + + r = ao_lco_query(ao_lco_box, &ao_pad_query, &ao_lco_tick_offset); + if (r == AO_RADIO_CMAC_OK) { + c = ao_lco_got_channels; + ao_lco_got_channels = 1; + ao_lco_valid = 1; + if (!c) { + ao_lco_pad = ao_lco_pad_first(); + ao_lco_set_pad(ao_lco_pad); + } + } else + ao_lco_valid = 0; + +#if 0 + PRINTD("lco_query success arm_status %d i0 %d i1 %d i2 %d i3 %d\n", + query.arm_status, + query.igniter_status[0], + query.igniter_status[1], + query.igniter_status[2], + query.igniter_status[3]); +#endif + ao_wakeup(&ao_pad_query); +} + +static void +ao_lco_box_reset_present(void) +{ + ao_lco_min_box = 0xff; + ao_lco_max_box = 0x00; + memset(ao_lco_box_mask, 0, sizeof (ao_lco_box_mask)); +} + +static void +ao_lco_box_set_present(uint8_t box) +{ + if (box < ao_lco_min_box) + ao_lco_min_box = box; + if (box > ao_lco_max_box) + ao_lco_max_box = box; + if (box >= AO_PAD_MAX_BOXES) + return; + ao_lco_box_mask[MASK_ID(box)] |= 1 << MASK_SHIFT(box); +} + +static void +ao_lco_search(void) +{ + uint16_t tick_offset; + int8_t r; + int8_t try; + uint8_t box; + + ao_lco_box_reset_present(); + for (box = 0; box < AO_PAD_MAX_BOXES; box++) { + if ((box % 10) == 0) + ao_lco_set_box(box); + for (try = 0; try < 3; try++) { + tick_offset = 0; + r = ao_lco_query(box, &ao_pad_query, &tick_offset); + PRINTD("box %d result %d\n", box, r); + if (r == AO_RADIO_CMAC_OK) { + ao_lco_box_set_present(box); + ao_delay(AO_MS_TO_TICKS(30)); + break; + } + } + } + if (ao_lco_min_box <= ao_lco_max_box) + ao_lco_box = ao_lco_min_box; + else + ao_lco_min_box = ao_lco_max_box = ao_lco_box = 0; + ao_lco_valid = 0; + ao_lco_got_channels = 0; + ao_lco_pad = 0; + ao_lco_set_pad(ao_lco_pad); + ao_lco_set_box(ao_lco_box); +} + +static void +ao_lco_igniter_status(void) +{ + uint8_t c; + + for (;;) { + ao_sleep(&ao_pad_query); + if (!ao_lco_valid) { + ao_led_on(AO_LED_RED); + ao_led_off(AO_LED_GREEN|AO_LED_AMBER); + continue; + } + PRINTD("RSSI %d\n", ao_radio_cmac_rssi); + if (ao_radio_cmac_rssi < -90) { + ao_led_on(AO_LED_AMBER); + ao_led_off(AO_LED_RED|AO_LED_GREEN); + } else { + ao_led_on(AO_LED_GREEN); + ao_led_off(AO_LED_RED|AO_LED_AMBER); + } + if (ao_pad_query.arm_status) + ao_led_on(AO_LED_REMOTE_ARM); + else + ao_led_off(AO_LED_REMOTE_ARM); + for (c = 0; c < AO_LED_CONTINUITY_NUM; c++) { + uint8_t status; + + if (ao_pad_query.channels & (1 << c)) + status = ao_pad_query.igniter_status[c]; + else + status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN; + if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN) + ao_led_on(continuity_led[c]); + else + ao_led_off(continuity_led[c]); + } + } +} + +static void +ao_lco_arm_warn(void) +{ + for (;;) { + while (!ao_lco_armed) + ao_sleep(&ao_lco_armed); + ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); + ao_delay(AO_MS_TO_TICKS(200)); + } +} + +static struct ao_task ao_lco_input_task; +static struct ao_task ao_lco_monitor_task; +static struct ao_task ao_lco_arm_warn_task; +static struct ao_task ao_lco_igniter_status_task; + +static void +ao_lco_monitor(void) +{ + uint16_t delay; + + ao_lco_search(); + ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input"); + ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn"); + ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status"); + for (;;) { + PRINTD("monitor armed %d firing %d offset %d\n", + ao_lco_armed, ao_lco_firing, ao_lco_tick_offset); + + if (ao_lco_armed && ao_lco_firing) { + PRINTD("Firing box %d pad %d: valid %d\n", + ao_lco_box, ao_lco_pad, ao_lco_valid); + if (!ao_lco_valid) + ao_lco_update(); + if (ao_lco_valid) + ao_lco_ignite(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); + } else if (ao_lco_armed) { + PRINTD("Arming box %d pad %d\n", + ao_lco_box, ao_lco_pad); + if (!ao_lco_valid) + ao_lco_update(); + ao_lco_arm(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); + ao_lco_update(); + } else { + ao_lco_update(); + } + if (ao_lco_armed && ao_lco_firing) + delay = AO_MS_TO_TICKS(100); + else + delay = AO_SEC_TO_TICKS(1); + ao_sleep_for(&ao_lco_armed, delay); + } +} + +#if DEBUG +void +ao_lco_set_debug(void) +{ + ao_cmd_decimal(); + if (ao_cmd_status == ao_cmd_success) + ao_lco_debug = ao_cmd_lex_i != 0; +} + +__code struct ao_cmds ao_lco_cmds[] = { + { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, + { ao_lco_search, "s\0Search for pad boxes" }, + { 0, NULL } +}; +#endif + +void +ao_lco_init(void) +{ + ao_add_task(&ao_lco_monitor_task, ao_lco_monitor, "lco monitor"); +#if DEBUG + ao_cmd_register(&ao_lco_cmds[0]); +#endif +} diff --git a/src/drivers/ao_lco.h b/src/drivers/ao_lco.h new file mode 100644 index 00000000..253f9702 --- /dev/null +++ b/src/drivers/ao_lco.h @@ -0,0 +1,24 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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_LCO_H_ +#define _AO_LCO_H_ + +void +ao_lco_init(void); + +#endif /* _AO_LCO_H_ */ diff --git a/src/telelco-v0.2/ao_lco.c b/src/telelco-v0.2/ao_lco.c deleted file mode 100644 index 12a247bf..00000000 --- a/src/telelco-v0.2/ao_lco.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG 1 - -#if DEBUG -static uint8_t ao_lco_debug; -#define PRINTD(...) do { if (!ao_lco_debug) break; printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0) -#else -#define PRINTD(...) -#endif - -#define AO_LCO_PAD_DIGIT 0 -#define AO_LCO_BOX_DIGIT_1 1 -#define AO_LCO_BOX_DIGIT_10 2 - -static uint8_t ao_lco_min_box, ao_lco_max_box; -static uint8_t ao_lco_pad; -static uint8_t ao_lco_box; -static uint8_t ao_lco_armed; -static uint8_t ao_lco_firing; -static uint8_t ao_lco_valid; -static uint8_t ao_lco_got_channels; -static uint16_t ao_lco_tick_offset; - -static struct ao_pad_query ao_pad_query; - -static void -ao_lco_set_pad(uint8_t pad) -{ - ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad + 1); -} - -static void -ao_lco_set_box(uint8_t box) -{ - ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10); - ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10); -} - -#define MASK_SIZE(n) (((n) + 7) >> 3) -#define MASK_ID(n) ((n) >> 3) -#define MASK_SHIFT(n) ((n) & 7) - -static uint8_t ao_lco_box_mask[MASK_SIZE(AO_PAD_MAX_BOXES)]; - -static uint8_t -ao_lco_box_present(uint8_t box) -{ - if (box >= AO_PAD_MAX_BOXES) - return 0; - return (ao_lco_box_mask[MASK_ID(box)] >> MASK_SHIFT(box)) & 1; -} - -static uint8_t -ao_lco_pad_present(uint8_t pad) -{ - if (!ao_lco_got_channels || !ao_pad_query.channels) - return pad == 0; - if (pad >= AO_PAD_MAX_CHANNELS) - return 0; - return (ao_pad_query.channels >> pad) & 1; -} - -static uint8_t -ao_lco_pad_first(void) -{ - uint8_t pad; - - for (pad = 0; pad < AO_PAD_MAX_CHANNELS; pad++) - if (ao_lco_pad_present(pad)) - return pad; - return 0; -} - -static void -ao_lco_input(void) -{ - static struct ao_event event; - int8_t dir, new_box, new_pad; - - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - for (;;) { - ao_event_get(&event); - PRINTD("event type %d unit %d value %d\n", - event.type, event.unit, event.value); - switch (event.type) { - case AO_EVENT_QUADRATURE: - switch (event.unit) { - case AO_QUADRATURE_PAD: - if (!ao_lco_armed) { - dir = (int8_t) event.value; - new_pad = ao_lco_pad; - do { - new_pad += dir; - if (new_pad > AO_PAD_MAX_CHANNELS) - new_pad = 0; - else if (new_pad < 0) - new_pad = AO_PAD_MAX_CHANNELS - 1; - if (new_pad == ao_lco_pad) - break; - } while (!ao_lco_pad_present(new_pad)); - if (new_pad != ao_lco_pad) { - ao_lco_pad = new_pad; - ao_lco_set_pad(ao_lco_pad); - } - } - break; - case AO_QUADRATURE_BOX: - if (!ao_lco_armed) { - dir = (int8_t) event.value; - new_box = ao_lco_box; - do { - new_box += dir; - if (new_box > ao_lco_max_box) - new_box = ao_lco_min_box; - else if (new_box < ao_lco_min_box) - new_box = ao_lco_max_box; - if (new_box == ao_lco_box) - break; - } while (!ao_lco_box_present(new_box)); - if (ao_lco_box != new_box) { - ao_lco_box = new_box; - ao_lco_got_channels = 0; - ao_lco_set_box(ao_lco_box); - } - } - break; - } - break; - case AO_EVENT_BUTTON: - switch (event.unit) { - case AO_BUTTON_ARM: - ao_lco_armed = event.value; - PRINTD("Armed %d\n", ao_lco_armed); - ao_wakeup(&ao_lco_armed); - break; - case AO_BUTTON_FIRE: - if (ao_lco_armed) { - ao_lco_firing = event.value; - PRINTD("Firing %d\n", ao_lco_firing); - ao_wakeup(&ao_lco_armed); - } - break; - } - break; - } - } -} - -static AO_LED_TYPE continuity_led[AO_LED_CONTINUITY_NUM] = { -#ifdef AO_LED_CONTINUITY_0 - AO_LED_CONTINUITY_0, -#endif -#ifdef AO_LED_CONTINUITY_1 - AO_LED_CONTINUITY_1, -#endif -#ifdef AO_LED_CONTINUITY_2 - AO_LED_CONTINUITY_2, -#endif -#ifdef AO_LED_CONTINUITY_3 - AO_LED_CONTINUITY_3, -#endif -#ifdef AO_LED_CONTINUITY_4 - AO_LED_CONTINUITY_4, -#endif -#ifdef AO_LED_CONTINUITY_5 - AO_LED_CONTINUITY_5, -#endif -#ifdef AO_LED_CONTINUITY_6 - AO_LED_CONTINUITY_6, -#endif -#ifdef AO_LED_CONTINUITY_7 - AO_LED_CONTINUITY_7, -#endif -}; - -static void -ao_lco_update(void) -{ - int8_t r; - uint8_t c; - - r = ao_lco_query(ao_lco_box, &ao_pad_query, &ao_lco_tick_offset); - if (r == AO_RADIO_CMAC_OK) { - c = ao_lco_got_channels; - ao_lco_got_channels = 1; - ao_lco_valid = 1; - if (!c) { - ao_lco_pad = ao_lco_pad_first(); - ao_lco_set_pad(ao_lco_pad); - } - } else - ao_lco_valid = 0; - -#if 0 - PRINTD("lco_query success arm_status %d i0 %d i1 %d i2 %d i3 %d\n", - query.arm_status, - query.igniter_status[0], - query.igniter_status[1], - query.igniter_status[2], - query.igniter_status[3]); -#endif - ao_wakeup(&ao_pad_query); -} - -static void -ao_lco_box_reset_present(void) -{ - ao_lco_min_box = 0xff; - ao_lco_max_box = 0x00; - memset(ao_lco_box_mask, 0, sizeof (ao_lco_box_mask)); -} - -static void -ao_lco_box_set_present(uint8_t box) -{ - if (box < ao_lco_min_box) - ao_lco_min_box = box; - if (box > ao_lco_max_box) - ao_lco_max_box = box; - if (box >= AO_PAD_MAX_BOXES) - return; - ao_lco_box_mask[MASK_ID(box)] |= 1 << MASK_SHIFT(box); -} - -static void -ao_lco_search(void) -{ - uint16_t tick_offset; - int8_t r; - int8_t try; - uint8_t box; - - ao_lco_box_reset_present(); - for (box = 0; box < AO_PAD_MAX_BOXES; box++) { - if ((box % 10) == 0) - ao_lco_set_box(box); - for (try = 0; try < 3; try++) { - tick_offset = 0; - r = ao_lco_query(box, &ao_pad_query, &tick_offset); - PRINTD("box %d result %d\n", box, r); - if (r == AO_RADIO_CMAC_OK) { - ao_lco_box_set_present(box); - ao_delay(AO_MS_TO_TICKS(30)); - break; - } - } - } - if (ao_lco_min_box <= ao_lco_max_box) - ao_lco_box = ao_lco_min_box; - else - ao_lco_min_box = ao_lco_max_box = ao_lco_box = 0; - ao_lco_valid = 0; - ao_lco_got_channels = 0; - ao_lco_pad = 0; - ao_lco_set_pad(ao_lco_pad); - ao_lco_set_box(ao_lco_box); -} - -static void -ao_lco_igniter_status(void) -{ - uint8_t c; - - for (;;) { - ao_sleep(&ao_pad_query); - if (!ao_lco_valid) { - ao_led_on(AO_LED_RED); - ao_led_off(AO_LED_GREEN|AO_LED_AMBER); - continue; - } - PRINTD("RSSI %d\n", ao_radio_cmac_rssi); - if (ao_radio_cmac_rssi < -90) { - ao_led_on(AO_LED_AMBER); - ao_led_off(AO_LED_RED|AO_LED_GREEN); - } else { - ao_led_on(AO_LED_GREEN); - ao_led_off(AO_LED_RED|AO_LED_AMBER); - } - if (ao_pad_query.arm_status) - ao_led_on(AO_LED_REMOTE_ARM); - else - ao_led_off(AO_LED_REMOTE_ARM); - for (c = 0; c < AO_LED_CONTINUITY_NUM; c++) { - uint8_t status; - - if (ao_pad_query.channels & (1 << c)) - status = ao_pad_query.igniter_status[c]; - else - status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN; - if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN) - ao_led_on(continuity_led[c]); - else - ao_led_off(continuity_led[c]); - } - } -} - -static void -ao_lco_arm_warn(void) -{ - for (;;) { - while (!ao_lco_armed) - ao_sleep(&ao_lco_armed); - ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); - ao_delay(AO_MS_TO_TICKS(200)); - } -} - -static struct ao_task ao_lco_input_task; -static struct ao_task ao_lco_monitor_task; -static struct ao_task ao_lco_arm_warn_task; -static struct ao_task ao_lco_igniter_status_task; - -static void -ao_lco_monitor(void) -{ - uint16_t delay; - - ao_lco_search(); - ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input"); - ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn"); - ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status"); - for (;;) { - PRINTD("monitor armed %d firing %d offset %d\n", - ao_lco_armed, ao_lco_firing, ao_lco_tick_offset); - - if (ao_lco_armed && ao_lco_firing) { - PRINTD("Firing box %d pad %d: valid %d\n", - ao_lco_box, ao_lco_pad, ao_lco_valid); - if (!ao_lco_valid) - ao_lco_update(); - if (ao_lco_valid) - ao_lco_ignite(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); - } else if (ao_lco_armed) { - PRINTD("Arming box %d pad %d\n", - ao_lco_box, ao_lco_pad); - if (!ao_lco_valid) - ao_lco_update(); - ao_lco_arm(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); - ao_lco_update(); - } else { - ao_lco_update(); - } - if (ao_lco_armed && ao_lco_firing) - delay = AO_MS_TO_TICKS(100); - else - delay = AO_SEC_TO_TICKS(1); - ao_sleep_for(&ao_lco_armed, delay); - } -} - -#if DEBUG -void -ao_lco_set_debug(void) -{ - ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = ao_cmd_lex_i != 0; -} - -__code struct ao_cmds ao_lco_cmds[] = { - { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, - { ao_lco_search, "s\0Search for pad boxes" }, - { 0, NULL } -}; -#endif - -void -ao_lco_init(void) -{ - ao_add_task(&ao_lco_monitor_task, ao_lco_monitor, "lco monitor"); -#if DEBUG - ao_cmd_register(&ao_lco_cmds[0]); -#endif -} diff --git a/src/telelco-v0.2/ao_lco.h b/src/telelco-v0.2/ao_lco.h deleted file mode 100644 index 253f9702..00000000 --- a/src/telelco-v0.2/ao_lco.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * 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_LCO_H_ -#define _AO_LCO_H_ - -void -ao_lco_init(void); - -#endif /* _AO_LCO_H_ */ diff --git a/src/telelco-v0.3/.gitignore b/src/telelco-v0.3/.gitignore new file mode 100644 index 00000000..a32ec26e --- /dev/null +++ b/src/telelco-v0.3/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +telelco*.elf diff --git a/src/telelco-v0.3/Makefile b/src/telelco-v0.3/Makefile new file mode 100644 index 00000000..83d3fc43 --- /dev/null +++ b/src/telelco-v0.3/Makefile @@ -0,0 +1,108 @@ +# +# AltOS build for TeleLCO +# +# + +include ../stm/Makefile.defs + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_boot.h \ + ao_companion.h \ + ao_data.h \ + ao_sample.h \ + ao_pins.h \ + ao_product.h \ + ao_seven_segment.h \ + ao_lco.h \ + ao_lco_cmd.h \ + ao_lco_func.h \ + ao_radio_spi.h \ + ao_radio_cmac.h \ + ao_cc1200_CC1200.h \ + ao_cc1200.h \ + ao_debounce.h \ + stm32l.h + +# +# Common AltOS sources +# + +#PROFILE=ao_profile.c +#PROFILE_DEF=-DAO_PROFILE=1 + +ALTOS_SRC = \ + ao_boot_chain.c \ + ao_interrupt.c \ + ao_product.c \ + ao_romconfig.c \ + ao_cmd.c \ + ao_config.c \ + ao_task.c \ + ao_led.c \ + ao_stdio.c \ + ao_panic.c \ + ao_timer.c \ + ao_mutex.c \ + ao_freq.c \ + ao_dma_stm.c \ + ao_spi_stm.c \ + ao_beep_stm.c \ + ao_eeprom_stm.c \ + ao_fast_timer.c \ + ao_lcd_stm.c \ + ao_usb_stm.c \ + ao_exti_stm.c \ + ao_cc1200.c \ + ao_radio_cmac.c \ + ao_aes.c \ + ao_aes_tables.c \ + ao_fec_tx.c \ + ao_fec_rx.c \ + ao_seven_segment.c \ + ao_debounce.c \ + ao_quadrature.c \ + ao_button.c \ + ao_event.c \ + ao_lco.c \ + ao_lco_cmd.c \ + ao_lco_func.c \ + ao_radio_cmac_cmd.c + +PRODUCT=TeleLCO-v0.3 +PRODUCT_DEF=-DTELELCO +IDPRODUCT=0x0023 + +CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) -Os -g + +PROGNAME=telelco-v0.3 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SRC=$(ALTOS_SRC) ao_telelco.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) $(HEX) + +$(PROG): Makefile $(OBJ) altos.ld + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + +../altitude.h: make-altitude + nickle $< > $@ + +$(OBJ): $(INC) + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +distclean: clean + +clean: + rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/telelco-v0.3/ao_pins.h b/src/telelco-v0.3/ao_pins.h new file mode 100644 index 00000000..92095a7c --- /dev/null +++ b/src/telelco-v0.3/ao_pins.h @@ -0,0 +1,269 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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_ + +/* 8MHz High speed external crystal */ +#define AO_HSE 8000000 + +/* PLLVCO = 96MHz (so that USB will work) */ +#define AO_PLLMUL 12 +#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12) + +#define AO_CC1200_FOSC 40000000 + +/* SYSCLK = 32MHz (no need to go faster than CPU) */ +#define AO_PLLDIV 3 +#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3) + +/* HCLK = 32MHz (CPU clock) */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* Run APB1 at 16MHz (HCLK/2) */ +#define AO_APB1_PRESCALER 2 +#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2 + +/* Run APB2 at 16MHz (HCLK/2) */ +#define AO_APB2_PRESCALER 2 +#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2 + +#define HAS_EEPROM 1 +#define USE_INTERNAL_FLASH 1 +#define USE_EEPROM_CONFIG 1 +#define USE_STORAGE_CONFIG 0 +#define HAS_USB 1 +#define HAS_BEEP 1 +#define HAS_RADIO 1 +#define HAS_RADIO_RATE 1 +#define HAS_TELEMETRY 0 +#define HAS_AES 1 + +#define HAS_SPI_1 0 +#define SPI_1_PA5_PA6_PA7 0 +#define SPI_1_PB3_PB4_PB5 0 +#define SPI_1_PE13_PE14_PE15 0 + +#define HAS_SPI_2 1 /* CC1120 */ +#define SPI_2_PB13_PB14_PB15 0 +#define SPI_2_PD1_PD3_PD4 1 +#define SPI_2_GPIO (&stm_gpiod) +#define SPI_2_SCK 1 +#define SPI_2_MISO 3 +#define SPI_2_MOSI 4 +#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz + +#define HAS_I2C_1 0 + +#define HAS_I2C_2 0 + +#define PACKET_HAS_SLAVE 0 +#define PACKET_HAS_MASTER 0 + +#define FAST_TIMER_FREQ 10000 /* .1ms for debouncing */ + +/* + * Radio is a cc1200 connected via SPI + */ + +#define AO_RADIO_CAL_DEFAULT 5695733 + +#define AO_FEC_DEBUG 0 +#define AO_CC1200_SPI_CS_PORT (&stm_gpiod) +#define AO_CC1200_SPI_CS_PIN 0 +#define AO_CC1200_SPI_BUS AO_SPI_2_PD1_PD3_PD4 +#define AO_CC1200_SPI stm_spi2 + +#define AO_CC1200_INT_PORT (&stm_gpioc) +#define AO_CC1200_INT_PIN (15) + +#define AO_CC1200_INT_GPIO 2 +#define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2 + +#define LOW_LEVEL_DEBUG 0 + +#define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOCEN +#define LED_PORT (&stm_gpioc) +#define LED_PIN_RED 7 +#define LED_PIN_AMBER 8 +#define LED_PIN_GREEN 9 +#define LED_PIN_CONTINUITY_3 10 +#define LED_PIN_CONTINUITY_2 11 +#define LED_PIN_CONTINUITY_1 12 +#define LED_PIN_CONTINUITY_0 13 +#define LED_PIN_REMOTE_ARM 14 +#define AO_LED_RED (1 << LED_PIN_RED) +#define AO_LED_AMBER (1 << LED_PIN_AMBER) +#define AO_LED_GREEN (1 << LED_PIN_GREEN) +#define AO_LED_CONTINUITY_3 (1 << LED_PIN_CONTINUITY_3) +#define AO_LED_CONTINUITY_2 (1 << LED_PIN_CONTINUITY_2) +#define AO_LED_CONTINUITY_1 (1 << LED_PIN_CONTINUITY_1) +#define AO_LED_CONTINUITY_0 (1 << LED_PIN_CONTINUITY_0) + +#define AO_LED_CONTINUITY_NUM 4 + +#define AO_LED_REMOTE_ARM (1 << LED_PIN_REMOTE_ARM) + +#define LEDS_AVAILABLE (AO_LED_RED | \ + AO_LED_AMBER | \ + AO_LED_GREEN | \ + AO_LED_CONTINUITY_3 | \ + AO_LED_CONTINUITY_2 | \ + AO_LED_CONTINUITY_1 | \ + AO_LED_CONTINUITY_0 | \ + AO_LED_REMOTE_ARM) + +/* LCD displays */ + +#define LCD_DEBUG 0 +#define SEVEN_SEGMENT_DEBUG 0 + +#define AO_LCD_STM_SEG_ENABLED_0 ( \ + (1 << 0) | /* PA1 */ \ + (1 << 1) | /* PA2 */ \ + (1 << 2) | /* PA3 */ \ + (1 << 3) | /* PA6 */ \ + (1 << 4) | /* PA7 */ \ + (1 << 5) | /* PB0 */ \ + (1 << 6) | /* PB1 */ \ + (1 << 7) | /* PB3 */ \ + (1 << 8) | /* PB4 */ \ + (1 << 9) | /* PB5 */ \ + (1 << 10) | /* PB10 */ \ + (1 << 11) | /* PB11 */ \ + (1 << 12) | /* PB12 */ \ + (1 << 13) | /* PB13 */ \ + (1 << 14) | /* PB14 */ \ + (1 << 15) | /* PB15 */ \ + (1 << 16) | /* PB8 */ \ + (1 << 17) | /* PA15 */ \ + (1 << 18) | /* PC0 */ \ + (1 << 19) | /* PC1 */ \ + (1 << 20) | /* PC2 */ \ + (1 << 21) | /* PC3 */ \ + (1 << 22) | /* PC4 */ \ + (1 << 23) | /* PC5 */ \ + (0 << 24) | /* PC6 */ \ + (0 << 25) | /* PC7 */ \ + (0 << 26) | /* PC8 */ \ + (0 << 27) | /* PC9 */ \ + (0 << 28) | /* PC10 or PD8 */ \ + (0 << 29) | /* PC11 or PD9 */ \ + (0 << 30) | /* PC12 or PD10 */ \ + (0 << 31)) /* PD2 or PD11 */ + +#define AO_LCD_STM_SEG_ENABLED_1 ( \ + (0 << 0) | /* PD12 */ \ + (0 << 1) | /* PD13 */ \ + (0 << 2) | /* PD14 */ \ + (0 << 3) | /* PD15 */ \ + (0 << 4) | /* PE0 */ \ + (0 << 5) | /* PE1 */ \ + (0 << 6) | /* PE2 */ \ + (0 << 7)) /* PE3 */ + +#define AO_LCD_STM_COM_ENABLED ( \ + (1 << 0) | /* PA8 */ \ + (0 << 1) | /* PA9 */ \ + (0 << 2) | /* PA10 */ \ + (0 << 3) | /* PB9 */ \ + (0 << 4) | /* PC10 */ \ + (0 << 5) | /* PC11 */ \ + (0 << 6)) /* PC12 */ + +#define AO_LCD_28_ON_C 0 + +#define AO_LCD_DUTY STM_LCD_CR_DUTY_STATIC + +#define AO_LCD_PER_DIGIT 1 + +#define AO_LCD_DIGITS 3 +#define AO_LCD_SEGMENTS 8 + +#define AO_SEGMENT_MAP { \ + /* pad segments */ \ + { 0, 14 }, \ + { 0, 13 }, \ + { 0, 15 }, \ + { 0, 17 }, \ + { 0, 16 }, \ + { 0, 8 }, \ + { 0, 9 }, \ + { 0, 7 }, \ + /* box1 segments */ \ + { 0, 10 }, \ + { 0, 6 }, \ + { 0, 11 }, \ + { 0, 12 }, \ + { 0, 21 }, \ + { 0, 19 }, \ + { 0, 20 }, \ + { 0, 18 }, \ + /* box0 segments */ \ + { 0, 22 }, \ + { 0, 4 }, \ + { 0, 23 }, \ + { 0, 5 }, \ + { 0, 3 }, \ + { 0, 1 }, \ + { 0, 2 }, \ + { 0, 0 }, \ +} + +/* + * Use event queue for input devices + */ + +#define AO_EVENT 1 + +/* + * Knobs + */ + +#define AO_QUADRATURE_COUNT 2 + +#define AO_QUADRATURE_0_PORT &stm_gpioe +#define AO_QUADRATURE_0_A 3 +#define AO_QUADRATURE_0_B 2 + +#define AO_QUADRATURE_PAD 0 + +#define AO_QUADRATURE_1_PORT &stm_gpioe +#define AO_QUADRATURE_1_A 1 +#define AO_QUADRATURE_1_B 0 + +#define AO_QUADRATURE_BOX 1 + +/* + * Buttons + */ + +#define AO_BUTTON_COUNT 2 +#define AO_BUTTON_MODE AO_EXTI_MODE_PULL_UP + +#define AO_BUTTON_0_PORT &stm_gpioe +#define AO_BUTTON_0 4 + +#define AO_BUTTON_ARM 0 + +#define AO_BUTTON_1_PORT &stm_gpioe +#define AO_BUTTON_1 5 + +#define AO_BUTTON_FIRE 1 + +#endif /* _AO_PINS_H_ */ diff --git a/src/telelco-v0.3/ao_telelco.c b/src/telelco-v0.3/ao_telelco.c new file mode 100644 index 00000000..d9f7c693 --- /dev/null +++ b/src/telelco-v0.3/ao_telelco.c @@ -0,0 +1,70 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(void) +{ + ao_clock_init(); + + ao_led_init(LEDS_AVAILABLE); + ao_led_on(AO_LED_GREEN); + ao_task_init(); + + ao_timer_init(); + + ao_spi_init(); + ao_dma_init(); + ao_exti_init(); + + ao_beep_init(); + ao_cmd_init(); + + ao_lcd_stm_init(); + ao_seven_segment_init(); + ao_quadrature_init(); + ao_button_init(); + + ao_eeprom_init(); + + ao_radio_init(); + + ao_usb_init(); + + ao_config_init(); + + ao_lco_init(); + ao_lco_cmd_init(); +// ao_radio_cmac_cmd_init(); + + ao_start_scheduler(); + return 0; +} diff --git a/src/telelco-v0.3/flash-loader/Makefile b/src/telelco-v0.3/flash-loader/Makefile new file mode 100644 index 00000000..679e61ba --- /dev/null +++ b/src/telelco-v0.3/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=telelco-v0.2 +include $(TOPDIR)/stm/Makefile-flash.defs diff --git a/src/telelco-v0.3/flash-loader/ao_pins.h b/src/telelco-v0.3/flash-loader/ao_pins.h new file mode 100644 index 00000000..6c8ff7e2 --- /dev/null +++ b/src/telelco-v0.3/flash-loader/ao_pins.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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_ + +/* External crystal at 8MHz */ +#define AO_HSE 8000000 + +#include + +/* Arm switch. Press at power on to get boot loader */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpioe +#define AO_BOOT_APPLICATION_PIN 4 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#endif /* _AO_PINS_H_ */ -- cgit v1.2.3 From 91f617d450c187500593d1ae785958187f68ca14 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 15:49:21 -0700 Subject: altos/telelco: Display telefire battery voltage When the firing button is pressed while unarmed, show the telefire battery voltage in the display. Signed-off-by: Keith Packard --- src/drivers/ao_lco.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c index 12a247bf..9250d444 100644 --- a/src/drivers/ao_lco.c +++ b/src/drivers/ao_lco.c @@ -44,6 +44,7 @@ static uint8_t ao_lco_firing; static uint8_t ao_lco_valid; static uint8_t ao_lco_got_channels; static uint16_t ao_lco_tick_offset; +static uint8_t ao_lco_show_voltage; static struct ao_pad_query ao_pad_query; @@ -60,6 +61,19 @@ ao_lco_set_box(uint8_t box) ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10); } +static void +ao_lco_set_voltage(uint16_t decivolts) +{ + uint8_t tens, ones, tenths; + + tenths = decivolts % 10; + ones = (decivolts / 10) % 10; + tens = (decivolts / 100) % 10; + ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths); + ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10); + ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, tens); +} + #define MASK_SIZE(n) (((n) + 7) >> 3) #define MASK_ID(n) ((n) >> 3) #define MASK_SHIFT(n) ((n) & 7) @@ -124,6 +138,7 @@ ao_lco_input(void) } while (!ao_lco_pad_present(new_pad)); if (new_pad != ao_lco_pad) { ao_lco_pad = new_pad; + ao_lco_set_box(ao_lco_box); ao_lco_set_pad(ao_lco_pad); } } @@ -145,6 +160,7 @@ ao_lco_input(void) ao_lco_box = new_box; ao_lco_got_channels = 0; ao_lco_set_box(ao_lco_box); + ao_lco_set_pad(ao_lco_pad); } } break; @@ -160,8 +176,18 @@ ao_lco_input(void) case AO_BUTTON_FIRE: if (ao_lco_armed) { ao_lco_firing = event.value; + ao_lco_show_voltage = 0; PRINTD("Firing %d\n", ao_lco_firing); ao_wakeup(&ao_lco_armed); + } else { + if (event.value) { + if (ao_lco_got_channels) + ao_lco_set_voltage(ao_pad_query.battery); + } else { + ao_lco_set_box(ao_lco_box); + ao_lco_set_pad(ao_lco_pad); + } + ao_lco_show_voltage = event.value; } break; } @@ -210,8 +236,11 @@ ao_lco_update(void) ao_lco_valid = 1; if (!c) { ao_lco_pad = ao_lco_pad_first(); - ao_lco_set_pad(ao_lco_pad); + if (!ao_lco_show_voltage) + ao_lco_set_pad(ao_lco_pad); } + if (ao_lco_show_voltage) + ao_lco_set_voltage(ao_pad_query.battery); } else ao_lco_valid = 0; @@ -223,6 +252,7 @@ ao_lco_update(void) query.igniter_status[2], query.igniter_status[3]); #endif + PRINTD("ao_lco_update valid %d\n", ao_lco_valid); ao_wakeup(&ao_pad_query); } @@ -253,8 +283,10 @@ ao_lco_search(void) int8_t r; int8_t try; uint8_t box; + uint8_t boxes = 0; ao_lco_box_reset_present(); + ao_lco_set_pad(-1); for (box = 0; box < AO_PAD_MAX_BOXES; box++) { if ((box % 10) == 0) ao_lco_set_box(box); @@ -263,7 +295,9 @@ ao_lco_search(void) r = ao_lco_query(box, &ao_pad_query, &tick_offset); PRINTD("box %d result %d\n", box, r); if (r == AO_RADIO_CMAC_OK) { + ++boxes; ao_lco_box_set_present(box); + ao_lco_set_pad((boxes % 10) - 1); ao_delay(AO_MS_TO_TICKS(30)); break; } @@ -287,12 +321,12 @@ ao_lco_igniter_status(void) for (;;) { ao_sleep(&ao_pad_query); + PRINTD("RSSI %d VALID %d\n", ao_radio_cmac_rssi, ao_lco_valid); if (!ao_lco_valid) { ao_led_on(AO_LED_RED); ao_led_off(AO_LED_GREEN|AO_LED_AMBER); continue; } - PRINTD("RSSI %d\n", ao_radio_cmac_rssi); if (ao_radio_cmac_rssi < -90) { ao_led_on(AO_LED_AMBER); ao_led_off(AO_LED_RED|AO_LED_GREEN); @@ -361,6 +395,7 @@ ao_lco_monitor(void) if (!ao_lco_valid) ao_lco_update(); ao_lco_arm(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); + ao_delay(AO_MS_TO_TICKS(30)); ao_lco_update(); } else { ao_lco_update(); -- cgit v1.2.3 From dcbd87bc685924a6587a5f4dae47d34f417601b0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 16:26:01 -0700 Subject: altos/telelco: Show box voltage with pad knob instead of firing button Turn left past '1' and see the firing box battery voltage instead of pushing the firing button with the box disarmed. This seems like a safer UI. Signed-off-by: Keith Packard --- src/drivers/ao_lco.c | 75 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c index 9250d444..b8698a80 100644 --- a/src/drivers/ao_lco.c +++ b/src/drivers/ao_lco.c @@ -44,14 +44,13 @@ static uint8_t ao_lco_firing; static uint8_t ao_lco_valid; static uint8_t ao_lco_got_channels; static uint16_t ao_lco_tick_offset; -static uint8_t ao_lco_show_voltage; static struct ao_pad_query ao_pad_query; static void ao_lco_set_pad(uint8_t pad) { - ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad + 1); + ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad); } static void @@ -74,6 +73,17 @@ ao_lco_set_voltage(uint16_t decivolts) ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, tens); } +static void +ao_lco_set_display(void) +{ + if (ao_lco_pad == 0) { + ao_lco_set_voltage(ao_pad_query.battery); + } else { + ao_lco_set_pad(ao_lco_pad); + ao_lco_set_box(ao_lco_box); + } +} + #define MASK_SIZE(n) (((n) + 7) >> 3) #define MASK_ID(n) ((n) >> 3) #define MASK_SHIFT(n) ((n) & 7) @@ -93,9 +103,12 @@ ao_lco_pad_present(uint8_t pad) { if (!ao_lco_got_channels || !ao_pad_query.channels) return pad == 0; - if (pad >= AO_PAD_MAX_CHANNELS) + /* voltage measurement is always valid */ + if (pad == 0) + return 1; + if (pad > AO_PAD_MAX_CHANNELS) return 0; - return (ao_pad_query.channels >> pad) & 1; + return (ao_pad_query.channels >> (pad - 1)) & 1; } static uint8_t @@ -103,7 +116,7 @@ ao_lco_pad_first(void) { uint8_t pad; - for (pad = 0; pad < AO_PAD_MAX_CHANNELS; pad++) + for (pad = 1; pad <= AO_PAD_MAX_CHANNELS; pad++) if (ao_lco_pad_present(pad)) return pad; return 0; @@ -131,15 +144,14 @@ ao_lco_input(void) new_pad += dir; if (new_pad > AO_PAD_MAX_CHANNELS) new_pad = 0; - else if (new_pad < 0) - new_pad = AO_PAD_MAX_CHANNELS - 1; + if (new_pad < 0) + new_pad = AO_PAD_MAX_CHANNELS; if (new_pad == ao_lco_pad) break; } while (!ao_lco_pad_present(new_pad)); if (new_pad != ao_lco_pad) { ao_lco_pad = new_pad; - ao_lco_set_box(ao_lco_box); - ao_lco_set_pad(ao_lco_pad); + ao_lco_set_display(); } } break; @@ -158,9 +170,9 @@ ao_lco_input(void) } while (!ao_lco_box_present(new_box)); if (ao_lco_box != new_box) { ao_lco_box = new_box; + ao_lco_pad = 1; ao_lco_got_channels = 0; - ao_lco_set_box(ao_lco_box); - ao_lco_set_pad(ao_lco_pad); + ao_lco_set_display(); } } break; @@ -176,18 +188,8 @@ ao_lco_input(void) case AO_BUTTON_FIRE: if (ao_lco_armed) { ao_lco_firing = event.value; - ao_lco_show_voltage = 0; PRINTD("Firing %d\n", ao_lco_firing); ao_wakeup(&ao_lco_armed); - } else { - if (event.value) { - if (ao_lco_got_channels) - ao_lco_set_voltage(ao_pad_query.battery); - } else { - ao_lco_set_box(ao_lco_box); - ao_lco_set_pad(ao_lco_pad); - } - ao_lco_show_voltage = event.value; } break; } @@ -235,12 +237,12 @@ ao_lco_update(void) ao_lco_got_channels = 1; ao_lco_valid = 1; if (!c) { - ao_lco_pad = ao_lco_pad_first(); - if (!ao_lco_show_voltage) - ao_lco_set_pad(ao_lco_pad); + if (ao_lco_pad != 0) + ao_lco_pad = ao_lco_pad_first(); + ao_lco_set_display(); } - if (ao_lco_show_voltage) - ao_lco_set_voltage(ao_pad_query.battery); + if (ao_lco_pad == 0) + ao_lco_set_display(); } else ao_lco_valid = 0; @@ -286,7 +288,7 @@ ao_lco_search(void) uint8_t boxes = 0; ao_lco_box_reset_present(); - ao_lco_set_pad(-1); + ao_lco_set_pad(0); for (box = 0; box < AO_PAD_MAX_BOXES; box++) { if ((box % 10) == 0) ao_lco_set_box(box); @@ -297,7 +299,7 @@ ao_lco_search(void) if (r == AO_RADIO_CMAC_OK) { ++boxes; ao_lco_box_set_present(box); - ao_lco_set_pad((boxes % 10) - 1); + ao_lco_set_pad(boxes % 10); ao_delay(AO_MS_TO_TICKS(30)); break; } @@ -309,9 +311,8 @@ ao_lco_search(void) ao_lco_min_box = ao_lco_max_box = ao_lco_box = 0; ao_lco_valid = 0; ao_lco_got_channels = 0; - ao_lco_pad = 0; - ao_lco_set_pad(ao_lco_pad); - ao_lco_set_box(ao_lco_box); + ao_lco_pad = 1; + ao_lco_set_display(); } static void @@ -387,16 +388,18 @@ ao_lco_monitor(void) ao_lco_box, ao_lco_pad, ao_lco_valid); if (!ao_lco_valid) ao_lco_update(); - if (ao_lco_valid) - ao_lco_ignite(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); + if (ao_lco_valid && ao_lco_pad) + ao_lco_ignite(ao_lco_box, 1 << (ao_lco_pad - 1), ao_lco_tick_offset); } else if (ao_lco_armed) { PRINTD("Arming box %d pad %d\n", ao_lco_box, ao_lco_pad); if (!ao_lco_valid) ao_lco_update(); - ao_lco_arm(ao_lco_box, 1 << ao_lco_pad, ao_lco_tick_offset); - ao_delay(AO_MS_TO_TICKS(30)); - ao_lco_update(); + if (ao_lco_pad) { + ao_lco_arm(ao_lco_box, 1 << (ao_lco_pad - 1), ao_lco_tick_offset); + ao_delay(AO_MS_TO_TICKS(30)); + ao_lco_update(); + } } else { ao_lco_update(); } -- cgit v1.2.3 From 6ca2c42061b3c0160bf0137c9cd65989c522b826 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 16:35:23 -0700 Subject: altoslib: Build AltosVersion.java in configure.ac Signed-off-by: Keith Packard --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 180da1cf..171d1410 100644 --- a/configure.ac +++ b/configure.ac @@ -514,6 +514,7 @@ AC_OUTPUT([ Makefile src/Makedefs altoslib/Makefile +altoslib/AltosVersion.java icon/Makefile altosuilib/Makefile altosuilib/AltosUIVersion.java -- cgit v1.2.3 From 00aca369c4070901e0400f291d5f269b5fb8015c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 20:10:37 -0700 Subject: altoslib: Get new abstract mapping code compiling Not useful yet, but at least it compiles now? Signed-off-by: Keith Packard --- altoslib/AltosMap.java | 48 +++++++++++++++++++++++++++-------------- altoslib/AltosMapInterface.java | 15 ++++++------- altoslib/AltosMapLine.java | 14 ++++++------ altoslib/AltosMapPath.java | 25 ++++----------------- altoslib/AltosMapPathPoint.java | 41 +++++++++++++++++++++++++++++++++++ altoslib/AltosMapTile.java | 4 +++- altoslib/AltosMapTransform.java | 20 +++++++++++------ altoslib/AltosRectangle.java | 29 +++++++++++++++++++++++++ altoslib/Makefile.am | 2 ++ 9 files changed, 138 insertions(+), 60 deletions(-) create mode 100644 altoslib/AltosMapPathPoint.java create mode 100644 altoslib/AltosRectangle.java diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index b42f9f85..f8c3a36b 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -24,19 +24,19 @@ import java.util.concurrent.*; public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, AltosMapStoreListener { - static final int px_size = 512; + public static final int px_size = 512; - static final int maptype_hybrid = 0; - static final int maptype_roadmap = 1; - static final int maptype_satellite = 2; - static final int maptype_terrain = 3; - static final int maptype_default = maptype_hybrid; + public static final int maptype_hybrid = 0; + public static final int maptype_roadmap = 1; + public static final int maptype_satellite = 2; + public static final int maptype_terrain = 3; + public static final int maptype_default = maptype_hybrid; - static final int default_zoom = 15; - static final int min_zoom = 3; - static final int max_zoom = 21; + public static final int default_zoom = 15; + public static final int min_zoom = 3; + public static final int max_zoom = 21; - static final String[] maptype_names = { + public static final String[] maptype_names = { "hybrid", "roadmap", "satellite", @@ -157,7 +157,7 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos } public void font_size_changed(int font_size) { - map_interface.line.font_size_changed(font_size); + map_interface.line().font_size_changed(font_size); for (AltosMapTile tile : tiles.values()) tile.font_size_changed(font_size); repaint(); @@ -211,7 +211,7 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos if (!gps.locked && gps.nsat < 4) return; - AltosMapRectangle damage = map_interface.path.add(gps.lat, gps.lon, state.state); + AltosMapRectangle damage = map_interface.path().add(gps.lat, gps.lon, state.state); switch (state.state) { case AltosLib.ao_flight_boost: @@ -279,8 +279,8 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos lower_right = new AltosPointInt(centre.x + load_radius * AltosMap.px_size, centre.y + load_radius * AltosMap.px_size); } else { - upper_left = floor(transform.screen_point(new AltosPointDouble(0.0, 0.0))); - lower_right = floor(transform.screen_point(new AltosPointDouble(width(), height()))); + upper_left = floor(transform.screen_point(new AltosPointInt(0, 0))); + lower_right = floor(transform.screen_point(new AltosPointInt(width(), height()))); } LinkedList to_remove = new LinkedList(); @@ -302,8 +302,8 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos if (!tiles.containsKey(point)) { AltosLatLon ul = transform.lat_lon(new AltosPointDouble(x, y)); AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); - AltosMapTile tile = new AltosMapTile(this, ul, center, zoom, maptype, - AltosMap.px_size); + AltosMapTile tile = map_interface.new_tile(this, ul, center, zoom, maptype, + AltosMap.px_size); tiles.put(point, tile); } } @@ -328,6 +328,22 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos return "Map"; } + public void paint() { + make_tiles(); + + for (AltosMapTile tile : tiles.values()) + tile.paint(transform); + + synchronized(marks) { + for (AltosMapMark mark : marks) + mark.paint(transform); + } + + map_interface.path().paint(transform); + + map_interface.line().paint(transform); + } + /* AltosMapTileListener methods */ public synchronized void notify_tile(AltosMapTile tile, int status) { for (AltosPointInt point : tiles.keySet()) { diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index ea5454de..c548744b 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -20,16 +20,18 @@ package org.altusmetrum.altoslib_6; import java.io.*; import java.net.*; -public abstract class AltosMapInterface { - - public AltosMapPath path; - public AltosMapLine line; +public interface AltosMapInterface { + public abstract AltosMapPath path(); + public abstract AltosMapLine line(); public abstract AltosImage load_image(File file) throws Exception; public abstract AltosMapMark new_mark(double lat, double lon, int state); + public abstract AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size); + public abstract int width(); + public abstract int height(); public abstract void repaint(); @@ -39,9 +41,4 @@ public abstract class AltosMapInterface { public abstract void repaint(double x, double y, double w, double h); public abstract void set_units(); - - public AltosMapInterface (AltosMapPath path, AltosMapLine line) { - this.path = path; - this.line = line; - } } diff --git a/altoslib/AltosMapLine.java b/altoslib/AltosMapLine.java index 83de47f9..77807b94 100644 --- a/altoslib/AltosMapLine.java +++ b/altoslib/AltosMapLine.java @@ -23,26 +23,28 @@ import java.util.*; import java.util.concurrent.*; public abstract class AltosMapLine implements AltosFontListener { - AltosLatLon start, end; + public AltosLatLon start, end; static public int stroke_width = 6; public abstract void font_size_changed(int font_size); - private AltosLatLon lat_lon(AltosPointDouble pt, AltosMapTransform t) { + public abstract void paint(AltosMapTransform t); + + private AltosLatLon lat_lon(AltosPointInt pt, AltosMapTransform t) { return t.screen_lat_lon(pt); } - public void dragged(AltosPointDouble pt, AltosMapTransform t) { + public void dragged(AltosPointInt pt, AltosMapTransform t) { end = lat_lon(pt, t); } - public void pressed(AltosPointDouble pt, AltosMapTransform t) { + public void pressed(AltosPointInt pt, AltosMapTransform t) { start = lat_lon(pt, t); end = null; } - private String line_dist() { + public String line_dist() { String format; AltosGreatCircle g = new AltosGreatCircle(start.lat, start.lon, end.lat, end.lon); @@ -78,6 +80,4 @@ public abstract class AltosMapLine implements AltosFontListener { } return String.format(format, distance); } - - public abstract void paint(AltosMapTransform t); } diff --git a/altoslib/AltosMapPath.java b/altoslib/AltosMapPath.java index 272a4316..e7224b57 100644 --- a/altoslib/AltosMapPath.java +++ b/altoslib/AltosMapPath.java @@ -22,34 +22,17 @@ import java.lang.Math; import java.util.*; import java.util.concurrent.*; -class PathPoint { - AltosLatLon lat_lon; - int state; - - public PathPoint(AltosLatLon lat_lon, int state) { - this.lat_lon = lat_lon; - this.state = state; - } - - public boolean equals(PathPoint other) { - if (other == null) - return false; - - return lat_lon.equals(other.lat_lon) && state == other.state; - } -} - public abstract class AltosMapPath { - LinkedList points = new LinkedList(); - PathPoint last_point = null; + public LinkedList points = new LinkedList(); + public AltosMapPathPoint last_point = null; static public int stroke_width = 6; public abstract void paint(AltosMapTransform t); public AltosMapRectangle add(double lat, double lon, int state) { - PathPoint point = new PathPoint(new AltosLatLon (lat, lon), state); + AltosMapPathPoint point = new AltosMapPathPoint(new AltosLatLon (lat, lon), state); AltosMapRectangle rect = null; if (!point.equals(last_point)) { @@ -62,6 +45,6 @@ public abstract class AltosMapPath { } public void clear () { - points = new LinkedList(); + points = new LinkedList(); } } diff --git a/altoslib/AltosMapPathPoint.java b/altoslib/AltosMapPathPoint.java new file mode 100644 index 00000000..757211af --- /dev/null +++ b/altoslib/AltosMapPathPoint.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +import java.io.*; +import java.lang.Math; +import java.util.*; +import java.util.concurrent.*; + +public class AltosMapPathPoint { + public AltosLatLon lat_lon; + public int state; + + public boolean equals(AltosMapPathPoint other) { + if (other == null) + return false; + + return lat_lon.equals(other.lat_lon) && state == other.state; + } + + public AltosMapPathPoint(AltosLatLon lat_lon, int state) { + this.lat_lon = lat_lon; + this.state = state; + } +} + diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index b5dee7a4..923b7c6b 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -20,7 +20,7 @@ package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; -public class AltosMapTile implements AltosFontListener { +public abstract class AltosMapTile implements AltosFontListener { AltosMapTileListener listener; AltosLatLon upper_left, center; int px_size; @@ -94,6 +94,8 @@ public class AltosMapTile implements AltosFontListener { store.remove_listener(listener); } + public abstract void paint(AltosMapTransform t); + public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { this.listener = listener; this.upper_left = upper_left; diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java index f5fc5ebe..384c1744 100644 --- a/altoslib/AltosMapTransform.java +++ b/altoslib/AltosMapTransform.java @@ -39,10 +39,18 @@ public class AltosMapTransform { return new AltosLatLon(lat,lon); } + public AltosPointDouble screen_point(AltosPointInt screen) { + return new AltosPointDouble(screen.x + offset_x, screen.y + offset_y); + } + public AltosPointDouble screen_point(AltosPointDouble screen) { return new AltosPointDouble(screen.x + offset_x, screen.y + offset_y); } + public AltosLatLon screen_lat_lon(AltosPointInt screen) { + return lat_lon(screen_point(screen)); + } + public AltosLatLon screen_lat_lon(AltosPointDouble screen) { return lat_lon(screen_point(screen)); } @@ -71,12 +79,12 @@ public class AltosMapTransform { (int) (point.y - offset_y + 0.5)); } -// public Rectangle screen(AltosMapRectangle map_rect) { -// AltosPoint2D ul = screen(map_rect.ul); -// AltosPoint2D lr = screen(map_rect.lr); -// -// return new Rectangle((int) ul.x, (int) ul.y, (int) (lr.x - ul.x), (int) (lr.y - ul.y)); -// } + public AltosRectangle screen(AltosMapRectangle map_rect) { + AltosPointDouble ul = screen(map_rect.ul); + AltosPointDouble lr = screen(map_rect.lr); + + return new AltosRectangle((int) ul.x, (int) ul.y, (int) (lr.x - ul.x), (int) (lr.y - ul.y)); + } public AltosPointDouble screen(AltosLatLon lat_lon) { return screen(point(lat_lon)); diff --git a/altoslib/AltosRectangle.java b/altoslib/AltosRectangle.java new file mode 100644 index 00000000..c55fd613 --- /dev/null +++ b/altoslib/AltosRectangle.java @@ -0,0 +1,29 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_6; + +public class AltosRectangle { + public int x, y, width, height; + + public AltosRectangle(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.width = w; + this.height = h; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 0ee7b935..481c974f 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -138,6 +138,7 @@ altoslib_JAVA = \ AltosMapLine.java \ AltosMapMark.java \ AltosMapPath.java \ + AltosMapPathPoint.java \ AltosMapRectangle.java \ AltosMapStore.java \ AltosMapStoreListener.java \ @@ -147,6 +148,7 @@ altoslib_JAVA = \ AltosMapZoomListener.java \ AltosPointDouble.java \ AltosPointInt.java \ + AltosRectangle.java \ AltosFlightDisplay.java \ AltosFontListener.java \ AltosVersion.java -- cgit v1.2.3 From 68effc6e39f731a2d7bbe2963999c1e785118897 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 20:33:28 -0700 Subject: altoslib: More frobbing with new map bits Signed-off-by: Keith Packard --- altoslib/AltosMapTile.java | 10 +++++----- altosui/AltosFlightUI.java | 4 ++-- altosuilib/AltosFlightDisplay.java | 28 ---------------------------- altosuilib/AltosFontListener.java | 22 ---------------------- altosuilib/AltosUIMapView.java | 15 --------------- altosuilib/Makefile.am | 4 ++-- configure.ac | 4 ++-- 7 files changed, 11 insertions(+), 76 deletions(-) delete mode 100644 altosuilib/AltosFlightDisplay.java delete mode 100644 altosuilib/AltosFontListener.java diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index 923b7c6b..92b7a985 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -22,13 +22,13 @@ import java.util.*; public abstract class AltosMapTile implements AltosFontListener { AltosMapTileListener listener; - AltosLatLon upper_left, center; - int px_size; + public AltosLatLon upper_left, center; + public int px_size; int zoom; int maptype; - AltosMapStore store; - AltosMapCache cache; - int status; + public AltosMapStore store; + public AltosMapCache cache; + public int status; static public final int success = 0; static public final int loading = 1; diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 424c57da..6ef85a96 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -40,7 +40,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { AltosDescent descent; AltosLanded landed; AltosCompanionInfo companion; - AltosUIMap sitemap; + AltosUIMapNew sitemap; boolean has_map; boolean has_companion; boolean has_state; @@ -319,7 +319,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { has_companion = false; has_state = false; - sitemap = new AltosUIMap(); + sitemap = new AltosUIMapNew(); displays.add(sitemap); has_map = false; diff --git a/altosuilib/AltosFlightDisplay.java b/altosuilib/AltosFlightDisplay.java deleted file mode 100644 index ac65c49e..00000000 --- a/altosuilib/AltosFlightDisplay.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_6; - -import org.altusmetrum.altoslib_6.*; - -public interface AltosFlightDisplay extends AltosUnitsListener, AltosFontListener { - void reset(); - - void show(AltosState state, AltosListenerState listener_state); - - String getName(); -} diff --git a/altosuilib/AltosFontListener.java b/altosuilib/AltosFontListener.java deleted file mode 100644 index 93625278..00000000 --- a/altosuilib/AltosFontListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_6; - -public interface AltosFontListener { - void font_size_changed(int font_size); -} diff --git a/altosuilib/AltosUIMapView.java b/altosuilib/AltosUIMapView.java index c8632b99..d110f803 100644 --- a/altosuilib/AltosUIMapView.java +++ b/altosuilib/AltosUIMapView.java @@ -426,21 +426,6 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo } public void paint(Graphics g) { - VolatileImage back_buffer = create_back_buffer(); - do { - GraphicsConfiguration gc = getGraphicsConfiguration(); - int code = back_buffer.validate(gc); - if (code == VolatileImage.IMAGE_INCOMPATIBLE) - back_buffer = create_back_buffer(); - - Graphics g_back = back_buffer.getGraphics(); - g_back.setClip(g.getClip()); - do_paint(g_back); - g_back.dispose(); - - g.drawImage(back_buffer, 0, 0, this); - } while (back_buffer.contentsLost()); - back_buffer.flush(); } public void update(Graphics g) { diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index d51da91d..30d003e9 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -12,8 +12,6 @@ altosuilib_JAVA = \ GrabNDrag.java \ AltosDevice.java \ AltosDeviceDialog.java \ - AltosFlightDisplay.java \ - AltosFontListener.java \ AltosPositionListener.java \ AltosUIConfigure.java \ AltosUIAxis.java \ @@ -61,6 +59,7 @@ altosuilib_JAVA = \ AltosBTManage.java \ AltosBTKnown.java \ AltosUIMap.java \ + AltosUIMapNew.java \ AltosUIMapView.java \ AltosUIMapLine.java \ AltosUIMapMark.java \ @@ -84,6 +83,7 @@ altosuilib_JAVA = \ AltosUIFreqList.java \ AltosUITelemetryList.java \ AltosUIRateList.java \ + AltosUIImage.java \ OSXAdapter.java JAR=altosuilib_$(ALTOSUILIB_VERSION).jar diff --git a/configure.ac b/configure.ac index 171d1410..0564f4f8 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,8 @@ AC_SUBST(VERSION_DASH) dnl ========================================================================== dnl Java library versions -ALTOSUILIB_VERSION=6 -ALTOSLIB_VERSION=6 +ALTOSUILIB_VERSION=7 +ALTOSLIB_VERSION=7 AC_SUBST(ALTOSLIB_VERSION) AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package]) -- cgit v1.2.3 From cb23b992be8ba40c97d8988c134a814a13ccd58c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 25 May 2015 20:34:05 -0700 Subject: altoslib/altosuilib: Update library version to 7 So many ABI/API changes Signed-off-by: Keith Packard --- altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java | 2 +- .../src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java | 2 +- altoslib/AltosAccel.java | 2 +- altoslib/AltosCRCException.java | 2 +- altoslib/AltosCSV.java | 2 +- altoslib/AltosCompanion.java | 2 +- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigDataException.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/AltosConvert.java | 2 +- altoslib/AltosDebug.java | 2 +- altoslib/AltosDistance.java | 2 +- altoslib/AltosEeprom.java | 2 +- altoslib/AltosEepromChunk.java | 2 +- altoslib/AltosEepromDownload.java | 2 +- altoslib/AltosEepromFile.java | 2 +- altoslib/AltosEepromGPS.java | 2 +- altoslib/AltosEepromHeader.java | 2 +- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromList.java | 2 +- altoslib/AltosEepromLog.java | 2 +- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMetrum2.java | 2 +- altoslib/AltosEepromMini.java | 2 +- altoslib/AltosEepromMonitor.java | 2 +- altoslib/AltosEepromTM.java | 2 +- altoslib/AltosEepromTm.java | 2 +- altoslib/AltosFile.java | 2 +- altoslib/AltosFlash.java | 2 +- altoslib/AltosFlashListener.java | 2 +- altoslib/AltosFlightDisplay.java | 2 +- altoslib/AltosFlightReader.java | 2 +- altoslib/AltosFlightStats.java | 2 +- altoslib/AltosFontListener.java | 2 +- altoslib/AltosFrequency.java | 2 +- altoslib/AltosGPS.java | 2 +- altoslib/AltosGPSSat.java | 2 +- altoslib/AltosGreatCircle.java | 2 +- altoslib/AltosHeight.java | 2 +- altoslib/AltosHexfile.java | 2 +- altoslib/AltosHexsym.java | 2 +- altoslib/AltosIMU.java | 2 +- altoslib/AltosIdle.java | 2 +- altoslib/AltosIdleFetch.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosIdleMonitorListener.java | 2 +- altoslib/AltosIgnite.java | 2 +- altoslib/AltosImage.java | 2 +- altoslib/AltosKML.java | 2 +- altoslib/AltosLatLon.java | 2 +- altoslib/AltosLatitude.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLine.java | 2 +- altoslib/AltosLink.java | 2 +- altoslib/AltosListenerState.java | 2 +- altoslib/AltosLocation.java | 2 +- altoslib/AltosLog.java | 2 +- altoslib/AltosLongitude.java | 2 +- altoslib/AltosMag.java | 2 +- altoslib/AltosMap.java | 2 +- altoslib/AltosMapCache.java | 2 +- altoslib/AltosMapCacheListener.java | 2 +- altoslib/AltosMapInterface.java | 2 +- altoslib/AltosMapLine.java | 2 +- altoslib/AltosMapMark.java | 2 +- altoslib/AltosMapPath.java | 2 +- altoslib/AltosMapPathPoint.java | 2 +- altoslib/AltosMapRectangle.java | 2 +- altoslib/AltosMapStore.java | 2 +- altoslib/AltosMapStoreListener.java | 2 +- altoslib/AltosMapTile.java | 2 +- altoslib/AltosMapTileListener.java | 2 +- altoslib/AltosMapTransform.java | 2 +- altoslib/AltosMapZoomListener.java | 2 +- altoslib/AltosMma655x.java | 2 +- altoslib/AltosMs5607.java | 2 +- altoslib/AltosNoSymbol.java | 2 +- altoslib/AltosOrient.java | 2 +- altoslib/AltosParse.java | 2 +- altoslib/AltosPointDouble.java | 2 +- altoslib/AltosPointInt.java | 2 +- altoslib/AltosPreferences.java | 2 +- altoslib/AltosPreferencesBackend.java | 2 +- altoslib/AltosProgrammer.java | 2 +- altoslib/AltosPyro.java | 2 +- altoslib/AltosQuaternion.java | 2 +- altoslib/AltosRectangle.java | 2 +- altoslib/AltosReplayReader.java | 2 +- altoslib/AltosRomconfig.java | 2 +- altoslib/AltosRotation.java | 2 +- altoslib/AltosSavedState.java | 2 +- altoslib/AltosSelfFlash.java | 2 +- altoslib/AltosSensorEMini.java | 2 +- altoslib/AltosSensorMM.java | 2 +- altoslib/AltosSensorMega.java | 2 +- altoslib/AltosSensorMetrum.java | 2 +- altoslib/AltosSensorTGPS.java | 2 +- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSensorTMini.java | 2 +- altoslib/AltosSpeed.java | 2 +- altoslib/AltosState.java | 2 +- altoslib/AltosStateIterable.java | 2 +- altoslib/AltosStateUpdate.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryConfiguration.java | 2 +- altoslib/AltosTelemetryFile.java | 2 +- altoslib/AltosTelemetryIterable.java | 2 +- altoslib/AltosTelemetryLegacy.java | 2 +- altoslib/AltosTelemetryLocation.java | 2 +- altoslib/AltosTelemetryMap.java | 2 +- altoslib/AltosTelemetryMegaData.java | 2 +- altoslib/AltosTelemetryMegaSensor.java | 2 +- altoslib/AltosTelemetryMetrumData.java | 2 +- altoslib/AltosTelemetryMetrumSensor.java | 2 +- altoslib/AltosTelemetryMini.java | 2 +- altoslib/AltosTelemetryRaw.java | 2 +- altoslib/AltosTelemetryReader.java | 2 +- altoslib/AltosTelemetrySatellite.java | 2 +- altoslib/AltosTelemetrySensor.java | 2 +- altoslib/AltosTelemetryStandard.java | 2 +- altoslib/AltosTemperature.java | 2 +- altoslib/AltosUnits.java | 2 +- altoslib/AltosUnitsListener.java | 2 +- altoslib/AltosVersion.java.in | 2 +- altoslib/AltosVoltage.java | 2 +- altoslib/AltosWriter.java | 2 +- altosui/Altos.java | 4 ++-- altosui/AltosAscent.java | 4 ++-- altosui/AltosCompanionInfo.java | 4 ++-- altosui/AltosConfig.java | 4 ++-- altosui/AltosConfigPyroUI.java | 4 ++-- altosui/AltosConfigTD.java | 4 ++-- altosui/AltosConfigTDUI.java | 4 ++-- altosui/AltosConfigUI.java | 4 ++-- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDescent.java | 4 ++-- altosui/AltosFlightStatus.java | 4 ++-- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 4 ++-- altosui/AltosGraphUI.java | 4 ++-- altosui/AltosIdleMonitorUI.java | 4 ++-- altosui/AltosIgniteUI.java | 4 ++-- altosui/AltosIgnitor.java | 4 ++-- altosui/AltosLanded.java | 4 ++-- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosPad.java | 4 ++-- altosui/AltosUI.java | 4 ++-- altosuilib/AltosBTDevice.java | 4 ++-- altosuilib/AltosBTDeviceIterator.java | 4 ++-- altosuilib/AltosBTKnown.java | 4 ++-- altosuilib/AltosBTManage.java | 4 ++-- altosuilib/AltosCSVUI.java | 4 ++-- altosuilib/AltosConfigFreqUI.java | 4 ++-- altosuilib/AltosDataChooser.java | 4 ++-- altosuilib/AltosDevice.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosDeviceUIDialog.java | 2 +- altosuilib/AltosDisplayThread.java | 4 ++-- altosuilib/AltosEepromDelete.java | 4 ++-- altosuilib/AltosEepromManage.java | 4 ++-- altosuilib/AltosEepromMonitor.java | 2 +- altosuilib/AltosEepromMonitorUI.java | 4 ++-- altosuilib/AltosEepromSelect.java | 4 ++-- altosuilib/AltosFlashUI.java | 4 ++-- altosuilib/AltosFlightInfoTableModel.java | 2 +- altosuilib/AltosFlightStatsTable.java | 4 ++-- altosuilib/AltosGraph.java | 4 ++-- altosuilib/AltosGraphDataPoint.java | 4 ++-- altosuilib/AltosGraphDataSet.java | 4 ++-- altosuilib/AltosInfoTable.java | 4 ++-- altosuilib/AltosLed.java | 2 +- altosuilib/AltosLights.java | 2 +- altosuilib/AltosPositionListener.java | 2 +- altosuilib/AltosRomconfigUI.java | 4 ++-- altosuilib/AltosScanUI.java | 4 ++-- altosuilib/AltosSerial.java | 4 ++-- altosuilib/AltosSerialInUseException.java | 2 +- altosuilib/AltosUIAxis.java | 4 ++-- altosuilib/AltosUIConfigure.java | 2 +- altosuilib/AltosUIDataMissing.java | 2 +- altosuilib/AltosUIDataPoint.java | 2 +- altosuilib/AltosUIDataSet.java | 2 +- altosuilib/AltosUIDialog.java | 2 +- altosuilib/AltosUIEnable.java | 4 ++-- altosuilib/AltosUIFlightTab.java | 4 ++-- altosuilib/AltosUIFrame.java | 2 +- altosuilib/AltosUIFreqList.java | 4 ++-- altosuilib/AltosUIGraph.java | 4 ++-- altosuilib/AltosUIGrapher.java | 4 ++-- altosuilib/AltosUIIndicator.java | 4 ++-- altosuilib/AltosUILatLon.java | 4 ++-- altosuilib/AltosUILib.java | 4 ++-- altosuilib/AltosUIListener.java | 2 +- altosuilib/AltosUIMap.java | 4 ++-- altosuilib/AltosUIMapCache.java | 2 +- altosuilib/AltosUIMapCacheListener.java | 2 +- altosuilib/AltosUIMapImage.java | 2 +- altosuilib/AltosUIMapLine.java | 4 ++-- altosuilib/AltosUIMapMark.java | 4 ++-- altosuilib/AltosUIMapPath.java | 4 ++-- altosuilib/AltosUIMapPreload.java | 4 ++-- altosuilib/AltosUIMapRectangle.java | 2 +- altosuilib/AltosUIMapStore.java | 2 +- altosuilib/AltosUIMapStoreListener.java | 2 +- altosuilib/AltosUIMapTile.java | 4 ++-- altosuilib/AltosUIMapTileListener.java | 2 +- altosuilib/AltosUIMapTransform.java | 4 ++-- altosuilib/AltosUIMapView.java | 4 ++-- altosuilib/AltosUIMapZoomListener.java | 2 +- altosuilib/AltosUIMarker.java | 4 ++-- altosuilib/AltosUIPreferences.java | 4 ++-- altosuilib/AltosUIPreferencesBackend.java | 4 ++-- altosuilib/AltosUIRateList.java | 4 ++-- altosuilib/AltosUISeries.java | 4 ++-- altosuilib/AltosUITelemetryList.java | 4 ++-- altosuilib/AltosUIUnitsIndicator.java | 4 ++-- altosuilib/AltosUIVersion.java.in | 2 +- altosuilib/AltosUIVoltageIndicator.java | 4 ++-- altosuilib/AltosUSBDevice.java | 2 +- altosuilib/AltosVoice.java | 2 +- altosuilib/GrabNDrag.java | 2 +- altosuilib/OSXAdapter.java | 2 +- micropeak/MicroData.java | 4 ++-- micropeak/MicroDataPoint.java | 2 +- micropeak/MicroDeviceDialog.java | 2 +- micropeak/MicroDownload.java | 4 ++-- micropeak/MicroExport.java | 4 ++-- micropeak/MicroFile.java | 4 ++-- micropeak/MicroFileChooser.java | 4 ++-- micropeak/MicroFrame.java | 2 +- micropeak/MicroGraph.java | 4 ++-- micropeak/MicroPeak.java | 4 ++-- micropeak/MicroRaw.java | 4 ++-- micropeak/MicroSave.java | 4 ++-- micropeak/MicroSerial.java | 2 +- micropeak/MicroSerialLog.java | 2 +- micropeak/MicroStats.java | 4 ++-- micropeak/MicroStatsTable.java | 4 ++-- micropeak/MicroUSB.java | 4 ++-- telegps/TeleGPS.java | 4 ++-- telegps/TeleGPSConfig.java | 4 ++-- telegps/TeleGPSConfigUI.java | 4 ++-- telegps/TeleGPSDisplayThread.java | 4 ++-- telegps/TeleGPSGraphUI.java | 4 ++-- telegps/TeleGPSInfo.java | 4 ++-- telegps/TeleGPSPreferences.java | 2 +- telegps/TeleGPSState.java | 4 ++-- telegps/TeleGPSStatus.java | 4 ++-- telegps/TeleGPSStatusUpdate.java | 2 +- 266 files changed, 350 insertions(+), 350 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 32b7a65b..e68b1885 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -31,7 +31,7 @@ import android.os.Handler; //import android.os.Message; import android.util.Log; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosBluetooth extends AltosDroidLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index db065b3f..eff24b10 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -57,7 +57,7 @@ import android.app.AlertDialog; import android.location.Location; import android.hardware.usb.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosDroid extends FragmentActivity implements AltosUnitsListener { // Debugging diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java index badb2caa..62090774 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java @@ -25,7 +25,7 @@ import java.util.UUID; import android.os.Handler; import android.util.Log; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public abstract class AltosDroidLink extends AltosLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index 372500c1..cda35f1d 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; import android.content.Context; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosDroidPreferences extends AltosPreferences { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java index bc5300fd..75676e28 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferencesBackend.java @@ -24,7 +24,7 @@ import android.content.SharedPreferences; import android.os.Environment; import android.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosDroidPreferencesBackend implements AltosPreferencesBackend { public final static String NAME = "org.altusmetrum.AltosDroid"; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index 0896b3a3..f91ddf58 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.location.Location; import android.app.Activity; import android.graphics.Color; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java index 81d50ab3..4685a824 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java @@ -29,7 +29,7 @@ import android.app.*; import android.os.Handler; import android.util.Log; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUsb extends AltosDroidLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index 2d32dc07..e79972e3 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -21,7 +21,7 @@ package org.altusmetrum.AltosDroid; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosVoice { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java index 23de9622..797dc7c3 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java index 4ec6f409..f3f5a0f1 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java index 4c69d869..d37891f7 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java index 871b94a1..83c8f7f8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -19,7 +19,7 @@ package org.altusmetrum.AltosDroid; import java.util.Arrays; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java index 0ac78219..f7eb43db 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java index 9764ab72..0cd9b2c1 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -1,6 +1,6 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index bdb2bae4..3f31fa6b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -25,7 +25,7 @@ import java.util.concurrent.*; import android.util.Log; import android.os.Handler; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class TelemetryReader extends Thread { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index e7f958b9..82c546c5 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -46,7 +46,7 @@ import android.location.LocationManager; import android.location.LocationListener; import android.location.Criteria; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class TelemetryService extends Service implements LocationListener { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java index ca066fc2..fb7e1893 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryState.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import android.location.Location; public class TelemetryState { diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index b11dc3a1..a358eda9 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 4167aecf..8100f4f6 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosCSV.java b/altoslib/AltosCSV.java index 02f7806f..f4e50ff1 100644 --- a/altoslib/AltosCSV.java +++ b/altoslib/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosCompanion.java b/altoslib/AltosCompanion.java index 8992b018..f4221c4b 100644 --- a/altoslib/AltosCompanion.java +++ b/altoslib/AltosCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 0ffdcf60..a722a689 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.*; import java.text.*; diff --git a/altoslib/AltosConfigDataException.java b/altoslib/AltosConfigDataException.java index 11aa4d24..32f1ab51 100644 --- a/altoslib/AltosConfigDataException.java +++ b/altoslib/AltosConfigDataException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosConfigDataException extends Exception { diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 3f26a078..d11bcde1 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index a5eb7ff8..5750afad 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosConvert { /* diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java index ef5edc6a..004ab566 100644 --- a/altoslib/AltosDebug.java +++ b/altoslib/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index b0666f33..e00f9500 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index 777988e7..4aed6ba2 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index 19a8807d..75dd2998 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 9598bd93..868571e4 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index c8443549..ac537856 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java index 96cfc0e1..564cd70c 100644 --- a/altoslib/AltosEepromGPS.java +++ b/altoslib/AltosEepromGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index fc4e9caa..5483ebb7 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 94487ab5..515efda7 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromList.java b/altoslib/AltosEepromList.java index 39768a21..086483e3 100644 --- a/altoslib/AltosEepromList.java +++ b/altoslib/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index 0fc82ab4..fe1c25dc 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index c2edcf23..49ea3b5d 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index 39425e10..4dacb7cb 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index ef13d0a7..c9b41004 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMonitor.java b/altoslib/AltosEepromMonitor.java index 35ed5a6e..c1a7fdf8 100644 --- a/altoslib/AltosEepromMonitor.java +++ b/altoslib/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosEepromMonitor { diff --git a/altoslib/AltosEepromTM.java b/altoslib/AltosEepromTM.java index 2bdd64f0..39bbb336 100644 --- a/altoslib/AltosEepromTM.java +++ b/altoslib/AltosEepromTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromTm.java b/altoslib/AltosEepromTm.java index 36500393..2f857667 100644 --- a/altoslib/AltosEepromTm.java +++ b/altoslib/AltosEepromTm.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index a79216a2..80468079 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index e58b652e..95ea73b5 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosFlashListener.java b/altoslib/AltosFlashListener.java index 1c7cd77d..03404a4e 100644 --- a/altoslib/AltosFlashListener.java +++ b/altoslib/AltosFlashListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosFlashListener { public void position(String label, int percent); diff --git a/altoslib/AltosFlightDisplay.java b/altoslib/AltosFlightDisplay.java index 157a0710..e87865bd 100644 --- a/altoslib/AltosFlightDisplay.java +++ b/altoslib/AltosFlightDisplay.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosFlightDisplay extends AltosUnitsListener, AltosFontListener { void reset(); diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 03c53ff4..9c4b7351 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index 82e477f8..8bdd43cf 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosFontListener.java b/altoslib/AltosFontListener.java index 74988139..0d8effa3 100644 --- a/altoslib/AltosFontListener.java +++ b/altoslib/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index 1dd4819d..15ace0c2 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index e3aee4ea..6793adf1 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index 57491f4d..3cbdcd9b 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index c48755be..f64a3662 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.lang.Math; import java.io.*; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index c4419ae6..b7b3529b 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 9f45d65a..6a66a869 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.LinkedList; diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java index 0c61fd02..fba50527 100644 --- a/altoslib/AltosHexsym.java +++ b/altoslib/AltosHexsym.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosHexsym { String name; diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index 8c219d9f..fe264d3c 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.*; import java.io.*; diff --git a/altoslib/AltosIdle.java b/altoslib/AltosIdle.java index 82b18ca2..89f8ed64 100644 --- a/altoslib/AltosIdle.java +++ b/altoslib/AltosIdle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 4c5e8285..e1658683 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 4d0968bf..74536204 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index fdf4be9d..86135a2e 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosIdleMonitorListener { public void update(AltosState state, AltosListenerState listener_state); diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index ffb6ed15..8701aec9 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.*; import java.io.*; diff --git a/altoslib/AltosImage.java b/altoslib/AltosImage.java index 9a9b5777..6360ecea 100644 --- a/altoslib/AltosImage.java +++ b/altoslib/AltosImage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index 1a0fcf3d..0c9f46c9 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosLatLon.java b/altoslib/AltosLatLon.java index f1ecfc90..e0fd45e7 100644 --- a/altoslib/AltosLatLon.java +++ b/altoslib/AltosLatLon.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosLatLon { public double lat; diff --git a/altoslib/AltosLatitude.java b/altoslib/AltosLatitude.java index 191a46ee..f4580cde 100644 --- a/altoslib/AltosLatitude.java +++ b/altoslib/AltosLatitude.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosLatitude extends AltosLocation { public String pos() { return "N"; } diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 405a3acc..a4afd269 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.*; import java.io.*; diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index a65ba593..33737e95 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 0105398d..fca8beb8 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java index d7e18008..ac31e198 100644 --- a/altoslib/AltosListenerState.java +++ b/altoslib/AltosListenerState.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosLocation.java b/altoslib/AltosLocation.java index b21014db..5fc4a368 100644 --- a/altoslib/AltosLocation.java +++ b/altoslib/AltosLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public abstract class AltosLocation extends AltosUnits { diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 9241581a..704dfc68 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.text.*; diff --git a/altoslib/AltosLongitude.java b/altoslib/AltosLongitude.java index ff4f0c2b..65e1402c 100644 --- a/altoslib/AltosLongitude.java +++ b/altoslib/AltosLongitude.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosLongitude extends AltosLocation { public String pos() { return "E"; } diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index f7595639..e03108d6 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.*; import java.io.*; diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index f8c3a36b..7c7c7305 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.*; diff --git a/altoslib/AltosMapCache.java b/altoslib/AltosMapCache.java index d94bae6c..929fbb01 100644 --- a/altoslib/AltosMapCache.java +++ b/altoslib/AltosMapCache.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.net.*; diff --git a/altoslib/AltosMapCacheListener.java b/altoslib/AltosMapCacheListener.java index 49b075dd..26618c0f 100644 --- a/altoslib/AltosMapCacheListener.java +++ b/altoslib/AltosMapCacheListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosMapCacheListener { public void map_cache_changed(int map_cache); diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index c548744b..0dcd646e 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.net.*; diff --git a/altoslib/AltosMapLine.java b/altoslib/AltosMapLine.java index 77807b94..e727e338 100644 --- a/altoslib/AltosMapLine.java +++ b/altoslib/AltosMapLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.Math; diff --git a/altoslib/AltosMapMark.java b/altoslib/AltosMapMark.java index 9b77d539..5eb1907b 100644 --- a/altoslib/AltosMapMark.java +++ b/altoslib/AltosMapMark.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.Math; diff --git a/altoslib/AltosMapPath.java b/altoslib/AltosMapPath.java index e7224b57..a238ba1a 100644 --- a/altoslib/AltosMapPath.java +++ b/altoslib/AltosMapPath.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.Math; diff --git a/altoslib/AltosMapPathPoint.java b/altoslib/AltosMapPathPoint.java index 757211af..9f82f02a 100644 --- a/altoslib/AltosMapPathPoint.java +++ b/altoslib/AltosMapPathPoint.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.Math; diff --git a/altoslib/AltosMapRectangle.java b/altoslib/AltosMapRectangle.java index f2f30103..941bad9e 100644 --- a/altoslib/AltosMapRectangle.java +++ b/altoslib/AltosMapRectangle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosMapRectangle { AltosLatLon ul, lr; diff --git a/altoslib/AltosMapStore.java b/altoslib/AltosMapStore.java index 2f52edb6..1107bec2 100644 --- a/altoslib/AltosMapStore.java +++ b/altoslib/AltosMapStore.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.net.*; diff --git a/altoslib/AltosMapStoreListener.java b/altoslib/AltosMapStoreListener.java index a272e864..b744b88c 100644 --- a/altoslib/AltosMapStoreListener.java +++ b/altoslib/AltosMapStoreListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosMapStoreListener { abstract void notify_store(AltosMapStore store, int status); diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index 92b7a985..e61746f8 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosMapTileListener.java b/altoslib/AltosMapTileListener.java index 8abc8b5a..60d92c75 100644 --- a/altoslib/AltosMapTileListener.java +++ b/altoslib/AltosMapTileListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosMapTileListener { abstract public void notify_tile(AltosMapTile tile, int status); diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java index 384c1744..e0e8afb0 100644 --- a/altoslib/AltosMapTransform.java +++ b/altoslib/AltosMapTransform.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.lang.Math; diff --git a/altoslib/AltosMapZoomListener.java b/altoslib/AltosMapZoomListener.java index 34edb19b..d50774b4 100644 --- a/altoslib/AltosMapZoomListener.java +++ b/altoslib/AltosMapZoomListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosMapZoomListener { abstract public void zoom_changed(int zoom); diff --git a/altoslib/AltosMma655x.java b/altoslib/AltosMma655x.java index c0b94b8c..a24e76bd 100644 --- a/altoslib/AltosMma655x.java +++ b/altoslib/AltosMma655x.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.*; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 2bd4ba8f..8e6f2658 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.*; import java.io.*; diff --git a/altoslib/AltosNoSymbol.java b/altoslib/AltosNoSymbol.java index 77410a25..2e1da598 100644 --- a/altoslib/AltosNoSymbol.java +++ b/altoslib/AltosNoSymbol.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosNoSymbol extends Exception { public AltosNoSymbol(String name) { diff --git a/altoslib/AltosOrient.java b/altoslib/AltosOrient.java index 8cdde750..d9350554 100644 --- a/altoslib/AltosOrient.java +++ b/altoslib/AltosOrient.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosOrient extends AltosUnits { diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index a8b02b56..de79c2fb 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.*; import java.text.*; diff --git a/altoslib/AltosPointDouble.java b/altoslib/AltosPointDouble.java index 96fb9161..4a940676 100644 --- a/altoslib/AltosPointDouble.java +++ b/altoslib/AltosPointDouble.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosPointDouble { public double x, y; diff --git a/altoslib/AltosPointInt.java b/altoslib/AltosPointInt.java index 6ee077ab..e133ae9c 100644 --- a/altoslib/AltosPointInt.java +++ b/altoslib/AltosPointInt.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosPointInt { public int x, y; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 9c4cadff..2fad96fd 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index c83eaa47..b68eea19 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.File; diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java index 7a92c2d0..6c53e1db 100644 --- a/altoslib/AltosProgrammer.java +++ b/altoslib/AltosProgrammer.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 502e34de..c5b3e0eb 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.*; import java.text.*; diff --git a/altoslib/AltosQuaternion.java b/altoslib/AltosQuaternion.java index 4ad1f3d6..af7667d0 100644 --- a/altoslib/AltosQuaternion.java +++ b/altoslib/AltosQuaternion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosQuaternion { double r; /* real bit */ diff --git a/altoslib/AltosRectangle.java b/altoslib/AltosRectangle.java index c55fd613..cfa2ea60 100644 --- a/altoslib/AltosRectangle.java +++ b/altoslib/AltosRectangle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosRectangle { public int x, y, width, height; diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 98f0e7d5..bcc07587 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index c93a01c3..d0912f4b 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosRotation.java b/altoslib/AltosRotation.java index 49225f77..4e4127cf 100644 --- a/altoslib/AltosRotation.java +++ b/altoslib/AltosRotation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosRotation { private AltosQuaternion rotation; diff --git a/altoslib/AltosSavedState.java b/altoslib/AltosSavedState.java index 552e4533..f557801a 100644 --- a/altoslib/AltosSavedState.java +++ b/altoslib/AltosSavedState.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 83be4be1..1be45998 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosSensorEMini.java b/altoslib/AltosSensorEMini.java index cb8356a1..cdcd9f20 100644 --- a/altoslib/AltosSensorEMini.java +++ b/altoslib/AltosSensorEMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index 9d5649aa..95edea22 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMega.java b/altoslib/AltosSensorMega.java index a3c2a033..939bae16 100644 --- a/altoslib/AltosSensorMega.java +++ b/altoslib/AltosSensorMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMetrum.java b/altoslib/AltosSensorMetrum.java index 39592b50..6feb26c0 100644 --- a/altoslib/AltosSensorMetrum.java +++ b/altoslib/AltosSensorMetrum.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTGPS.java b/altoslib/AltosSensorTGPS.java index 32607fba..e9265bce 100644 --- a/altoslib/AltosSensorTGPS.java +++ b/altoslib/AltosSensorTGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index c82ba93c..1c439817 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index 0fc70e71..ee51a8f6 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index b714412f..093d196d 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index d363027c..ad032a16 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 3b58fc32..6202f970 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosStateUpdate.java b/altoslib/AltosStateUpdate.java index 93b9f1c0..55007eb1 100644 --- a/altoslib/AltosStateUpdate.java +++ b/altoslib/AltosStateUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosStateUpdate { public void update_state(AltosState state) throws InterruptedException; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 449384d5..3825ab8f 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; diff --git a/altoslib/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java index 8c922b03..1cce0f24 100644 --- a/altoslib/AltosTelemetryConfiguration.java +++ b/altoslib/AltosTelemetryConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryConfiguration extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index 738e4dd7..d28795c4 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index 131389d5..ced29121 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index 923d139e..5aad8e62 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 85da27d5..2cd75621 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryLocation extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index e8c02e9b..36b5b1c8 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index 2b80df4a..30752365 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index a01c0826..bb3fdb37 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { int accel; diff --git a/altoslib/AltosTelemetryMetrumData.java b/altoslib/AltosTelemetryMetrumData.java index e53f1283..6d593467 100644 --- a/altoslib/AltosTelemetryMetrumData.java +++ b/altoslib/AltosTelemetryMetrumData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryMetrumData extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index 415b00a6..6d4cbea0 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java index 02537c9c..fa722fa5 100644 --- a/altoslib/AltosTelemetryMini.java +++ b/altoslib/AltosTelemetryMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryMini extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryRaw.java b/altoslib/AltosTelemetryRaw.java index 4254fc83..a6e5ca49 100644 --- a/altoslib/AltosTelemetryRaw.java +++ b/altoslib/AltosTelemetryRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetryRaw extends AltosTelemetryStandard { public AltosTelemetryRaw(int[] bytes) { diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 908fb5c7..cd5a08c4 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; import java.io.*; diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index 474789ba..e3d52b46 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetrySatellite extends AltosTelemetryStandard { int channels; diff --git a/altoslib/AltosTelemetrySensor.java b/altoslib/AltosTelemetrySensor.java index b0c84fd3..8dd2c225 100644 --- a/altoslib/AltosTelemetrySensor.java +++ b/altoslib/AltosTelemetrySensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTelemetrySensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index fb8a162e..d4aaff5b 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public abstract class AltosTelemetryStandard extends AltosTelemetry { int[] bytes; diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java index 494f4e3e..d729b576 100644 --- a/altoslib/AltosTemperature.java +++ b/altoslib/AltosTemperature.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosTemperature extends AltosUnits { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index e266b243..7ca2f03c 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; import java.text.*; diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index 1b66eb45..c5539fc9 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/AltosVersion.java.in b/altoslib/AltosVersion.java.in index 6bfef181..546d4353 100644 --- a/altoslib/AltosVersion.java.in +++ b/altoslib/AltosVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosVersion { public final static String version = "@VERSION@"; diff --git a/altoslib/AltosVoltage.java b/altoslib/AltosVoltage.java index 986d74b4..0469fb14 100644 --- a/altoslib/AltosVoltage.java +++ b/altoslib/AltosVoltage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public class AltosVoltage extends AltosUnits { diff --git a/altoslib/AltosWriter.java b/altoslib/AltosWriter.java index b125bd87..70fadd2e 100644 --- a/altoslib/AltosWriter.java +++ b/altoslib/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_6; +package org.altusmetrum.altoslib_7; public interface AltosWriter { diff --git a/altosui/Altos.java b/altosui/Altos.java index e82931b2..a4077a38 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class Altos extends AltosUILib { diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 10080efd..ef7c1cdb 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -21,8 +21,8 @@ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosAscent extends AltosUIFlightTab { JLabel cur, max; diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 68dab227..20004ad4 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -19,8 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosCompanionInfo extends JTable implements AltosFlightDisplay { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 3c5415d2..570354a3 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,8 +22,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfig implements ActionListener { diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 69b31ff5..694226be 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -22,8 +22,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfigPyroUI extends AltosUIDialog diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index cd20a174..9b9cdcaa 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfigTD implements ActionListener { diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 52225108..e17af47d 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfigTDUI extends AltosUIDialog diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index ef477ca9..3872ff83 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfigUI extends AltosUIDialog diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 7bc50570..543711b2 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class AltosConfigureUI extends AltosUIConfigure diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 0db1a4c2..d37f6f66 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -21,8 +21,8 @@ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosDescent extends AltosUIFlightTab { diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index c0d3312b..42127b1c 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,8 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index f2031698..5238e14b 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,7 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index 3f6494b8..44c3261a 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -18,7 +18,7 @@ package altosui; import java.awt.event.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosFlightStatusUpdate implements ActionListener { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 6ef85a96..3160fd95 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay { AltosVoice voice; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index f5e339a5..42a17658 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 88243c5d..2c7ff5fc 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -24,8 +24,8 @@ import javax.swing.event.*; import java.io.*; import java.util.concurrent.*; import java.util.Arrays; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosIdleMonitorListener, DocumentListener { AltosDevice device; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 1a2dc4f1..4fff5d72 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -24,8 +24,8 @@ import java.io.*; import java.text.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosIgniteUI extends AltosUIDialog diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index 82582a28..deb96a5e 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosIgnitor extends AltosUIFlightTab { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 2237df0c..6a4bdbd7 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosLanded extends AltosUIFlightTab implements ActionListener { diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 37077c42..67bbddc2 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -20,7 +20,7 @@ package altosui; import java.io.*; import java.util.concurrent.*; import java.awt.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class AltosLaunch { AltosDevice device; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 4c205d44..52587e58 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; class FireButton extends JButton { protected void processMouseEvent(MouseEvent e) { diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 6214fa5a..687fe6f7 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -18,8 +18,8 @@ package altosui; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosPad extends AltosUIFlightTab { diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 5dd532bd..9061a8ad 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class AltosUI extends AltosUIFrame { public AltosVoice voice = new AltosVoice(); diff --git a/altosuilib/AltosBTDevice.java b/altosuilib/AltosBTDevice.java index 0dd1cab2..76221df2 100644 --- a/altosuilib/AltosBTDevice.java +++ b/altosuilib/AltosBTDevice.java @@ -15,10 +15,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import libaltosJNI.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosBTDevice extends altos_bt_device implements AltosDevice { diff --git a/altosuilib/AltosBTDeviceIterator.java b/altosuilib/AltosBTDeviceIterator.java index eebad36b..1e46899a 100644 --- a/altosuilib/AltosBTDeviceIterator.java +++ b/altosuilib/AltosBTDeviceIterator.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosBTDeviceIterator implements Iterator { AltosBTDevice current; diff --git a/altosuilib/AltosBTKnown.java b/altosuilib/AltosBTKnown.java index 73ee473f..27897836 100644 --- a/altosuilib/AltosBTKnown.java +++ b/altosuilib/AltosBTKnown.java @@ -15,10 +15,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); diff --git a/altosuilib/AltosBTManage.java b/altosuilib/AltosBTManage.java index c4ac363f..94468a03 100644 --- a/altosuilib/AltosBTManage.java +++ b/altosuilib/AltosBTManage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.plaf.basic.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosBTManage extends AltosUIDialog implements ActionListener, Iterable { LinkedBlockingQueue found_devices; diff --git a/altosuilib/AltosCSVUI.java b/altosuilib/AltosCSVUI.java index 94d523fe..353b5127 100644 --- a/altosuilib/AltosCSVUI.java +++ b/altosuilib/AltosCSVUI.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosCSVUI extends AltosUIDialog diff --git a/altosuilib/AltosConfigFreqUI.java b/altosuilib/AltosConfigFreqUI.java index 21514a81..de7b4bed 100644 --- a/altosuilib/AltosConfigFreqUI.java +++ b/altosuilib/AltosConfigFreqUI.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.text.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class AltosEditFreqUI extends AltosUIDialog implements ActionListener { Frame frame; diff --git a/altosuilib/AltosDataChooser.java b/altosuilib/AltosDataChooser.java index 3fe76687..ea8a5648 100644 --- a/altosuilib/AltosDataChooser.java +++ b/altosuilib/AltosDataChooser.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosDataChooser extends JFileChooser { JFrame frame; diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java index 401387a4..b7cfe97e 100644 --- a/altosuilib/AltosDevice.java +++ b/altosuilib/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import libaltosJNI.*; diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 5fb1331e..53e3ed84 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosDeviceUIDialog.java b/altosuilib/AltosDeviceUIDialog.java index 9618895e..d82892a5 100644 --- a/altosuilib/AltosDeviceUIDialog.java +++ b/altosuilib/AltosDeviceUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosDisplayThread.java b/altosuilib/AltosDisplayThread.java index ccf8b3ef..d3783860 100644 --- a/altosuilib/AltosDisplayThread.java +++ b/altosuilib/AltosDisplayThread.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; import java.io.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosDisplayThread extends Thread { diff --git a/altosuilib/AltosEepromDelete.java b/altosuilib/AltosEepromDelete.java index 9fb21cf4..57ebb4c1 100644 --- a/altosuilib/AltosEepromDelete.java +++ b/altosuilib/AltosEepromDelete.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosEepromDelete implements Runnable { AltosEepromList flights; diff --git a/altosuilib/AltosEepromManage.java b/altosuilib/AltosEepromManage.java index 47a62ef7..522fac45 100644 --- a/altosuilib/AltosEepromManage.java +++ b/altosuilib/AltosEepromManage.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosEepromManage implements ActionListener { diff --git a/altosuilib/AltosEepromMonitor.java b/altosuilib/AltosEepromMonitor.java index 83c5c1d0..52a4b640 100644 --- a/altosuilib/AltosEepromMonitor.java +++ b/altosuilib/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosEepromMonitorUI.java b/altosuilib/AltosEepromMonitorUI.java index ac39fb1d..dd01ce25 100644 --- a/altosuilib/AltosEepromMonitorUI.java +++ b/altosuilib/AltosEepromMonitorUI.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMonitor { JFrame owner; diff --git a/altosuilib/AltosEepromSelect.java b/altosuilib/AltosEepromSelect.java index b291c35a..2c9d10cf 100644 --- a/altosuilib/AltosEepromSelect.java +++ b/altosuilib/AltosEepromSelect.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class AltosEepromItem implements ActionListener { AltosEepromLog log; diff --git a/altosuilib/AltosFlashUI.java b/altosuilib/AltosFlashUI.java index ace8fbe5..6b4a5238 100644 --- a/altosuilib/AltosFlashUI.java +++ b/altosuilib/AltosFlashUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosFlashUI extends AltosUIDialog diff --git a/altosuilib/AltosFlightInfoTableModel.java b/altosuilib/AltosFlightInfoTableModel.java index f9d7d180..76fe682a 100644 --- a/altosuilib/AltosFlightInfoTableModel.java +++ b/altosuilib/AltosFlightInfoTableModel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.table.*; diff --git a/altosuilib/AltosFlightStatsTable.java b/altosuilib/AltosFlightStatsTable.java index 8a686646..4240bf9f 100644 --- a/altosuilib/AltosFlightStatsTable.java +++ b/altosuilib/AltosFlightStatsTable.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosFlightStatsTable extends JComponent implements AltosFontListener { GridBagLayout layout; diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java index d7739228..34a5e1b3 100644 --- a/altosuilib/AltosGraph.java +++ b/altosuilib/AltosGraph.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosGraphDataPoint.java b/altosuilib/AltosGraphDataPoint.java index 47989d0e..b849dd7c 100644 --- a/altosuilib/AltosGraphDataPoint.java +++ b/altosuilib/AltosGraphDataPoint.java @@ -15,9 +15,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosGraphDataPoint implements AltosUIDataPoint { diff --git a/altosuilib/AltosGraphDataSet.java b/altosuilib/AltosGraphDataSet.java index b9c9d2a8..f0cda986 100644 --- a/altosuilib/AltosGraphDataSet.java +++ b/altosuilib/AltosGraphDataSet.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class AltosGraphIterator implements Iterator { AltosGraphDataSet dataSet; diff --git a/altosuilib/AltosInfoTable.java b/altosuilib/AltosInfoTable.java index 89a656c9..99f17617 100644 --- a/altosuilib/AltosInfoTable.java +++ b/altosuilib/AltosInfoTable.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosInfoTable extends JTable implements AltosFlightDisplay, HierarchyListener { private AltosFlightInfoTableModel model; diff --git a/altosuilib/AltosLed.java b/altosuilib/AltosLed.java index fa33c4b6..e328b717 100644 --- a/altosuilib/AltosLed.java +++ b/altosuilib/AltosLed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; diff --git a/altosuilib/AltosLights.java b/altosuilib/AltosLights.java index 05d06ac4..b2c1cbcc 100644 --- a/altosuilib/AltosLights.java +++ b/altosuilib/AltosLights.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; diff --git a/altosuilib/AltosPositionListener.java b/altosuilib/AltosPositionListener.java index 1274a64a..81e2cbaf 100644 --- a/altosuilib/AltosPositionListener.java +++ b/altosuilib/AltosPositionListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosPositionListener { public void position_changed(int position); diff --git a/altosuilib/AltosRomconfigUI.java b/altosuilib/AltosRomconfigUI.java index 99e4d004..e7977cf4 100644 --- a/altosuilib/AltosRomconfigUI.java +++ b/altosuilib/AltosRomconfigUI.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosRomconfigUI extends AltosUIDialog diff --git a/altosuilib/AltosScanUI.java b/altosuilib/AltosScanUI.java index 5a7e21b1..03115824 100644 --- a/altosuilib/AltosScanUI.java +++ b/altosuilib/AltosScanUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class AltosScanResult { String callsign; diff --git a/altosuilib/AltosSerial.java b/altosuilib/AltosSerial.java index 95815a7b..280887a6 100644 --- a/altosuilib/AltosSerial.java +++ b/altosuilib/AltosSerial.java @@ -19,13 +19,13 @@ * Deal with TeleDongle on a serial port */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.*; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import libaltosJNI.*; /* diff --git a/altosuilib/AltosSerialInUseException.java b/altosuilib/AltosSerialInUseException.java index 0487e146..1ca8e792 100644 --- a/altosuilib/AltosSerialInUseException.java +++ b/altosuilib/AltosSerialInUseException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java index 89f5493b..4173232f 100644 --- a/altosuilib/AltosUIAxis.java +++ b/altosuilib/AltosUIAxis.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index b022aeec..0bd8fb96 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIDataMissing.java b/altosuilib/AltosUIDataMissing.java index a0e41fef..b2a76165 100644 --- a/altosuilib/AltosUIDataMissing.java +++ b/altosuilib/AltosUIDataMissing.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public class AltosUIDataMissing extends Exception { public int id; diff --git a/altosuilib/AltosUIDataPoint.java b/altosuilib/AltosUIDataPoint.java index 82ce862f..fcbfbe95 100644 --- a/altosuilib/AltosUIDataPoint.java +++ b/altosuilib/AltosUIDataPoint.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIDataPoint { public abstract double x() throws AltosUIDataMissing; diff --git a/altosuilib/AltosUIDataSet.java b/altosuilib/AltosUIDataSet.java index 6293911d..f25a6bcb 100644 --- a/altosuilib/AltosUIDataSet.java +++ b/altosuilib/AltosUIDataSet.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIDataSet { public abstract String name(); diff --git a/altosuilib/AltosUIDialog.java b/altosuilib/AltosUIDialog.java index 77e549c4..a0c180c1 100644 --- a/altosuilib/AltosUIDialog.java +++ b/altosuilib/AltosUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index 481e5b87..0f9ed8ff 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIFlightTab.java b/altosuilib/AltosUIFlightTab.java index ea4f0cb0..270466a6 100644 --- a/altosuilib/AltosUIFlightTab.java +++ b/altosuilib/AltosUIFlightTab.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public abstract class AltosUIFlightTab extends JComponent implements AltosFlightDisplay, HierarchyListener { public GridBagLayout layout; diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index 39b1eb73..9ee4fab4 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIFreqList.java b/altosuilib/AltosUIFreqList.java index 430069f5..744a05dd 100644 --- a/altosuilib/AltosUIFreqList.java +++ b/altosuilib/AltosUIFreqList.java @@ -15,10 +15,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIFreqList extends JComboBox { diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index d20aa54b..3b34a988 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index fcd3546f..80b3acd7 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIIndicator.java b/altosuilib/AltosUIIndicator.java index f2e77218..989af389 100644 --- a/altosuilib/AltosUIIndicator.java +++ b/altosuilib/AltosUIIndicator.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public abstract class AltosUIIndicator implements AltosFontListener, AltosUnitsListener { JLabel label; diff --git a/altosuilib/AltosUILatLon.java b/altosuilib/AltosUILatLon.java index 72ff74d8..c9fb8e92 100644 --- a/altosuilib/AltosUILatLon.java +++ b/altosuilib/AltosUILatLon.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUILatLon { public double lat; diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index 2fa6cbd6..abd9e7e1 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIListener.java b/altosuilib/AltosUIListener.java index 9eec0b24..80c18c35 100644 --- a/altosuilib/AltosUIListener.java +++ b/altosuilib/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosuilib/AltosUIMap.java b/altosuilib/AltosUIMap.java index 5c6d5bdf..5d6fae40 100644 --- a/altosuilib/AltosUIMap.java +++ b/altosuilib/AltosUIMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMap extends JComponent implements AltosFlightDisplay, AltosUIMapZoomListener { diff --git a/altosuilib/AltosUIMapCache.java b/altosuilib/AltosUIMapCache.java index 73401e3c..d08b634d 100644 --- a/altosuilib/AltosUIMapCache.java +++ b/altosuilib/AltosUIMapCache.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import javax.imageio.ImageIO; diff --git a/altosuilib/AltosUIMapCacheListener.java b/altosuilib/AltosUIMapCacheListener.java index 1eec7b0a..9ae66f66 100644 --- a/altosuilib/AltosUIMapCacheListener.java +++ b/altosuilib/AltosUIMapCacheListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIMapCacheListener { public void map_cache_changed(int map_cache); diff --git a/altosuilib/AltosUIMapImage.java b/altosuilib/AltosUIMapImage.java index 97220a40..e0ac7b5a 100644 --- a/altosuilib/AltosUIMapImage.java +++ b/altosuilib/AltosUIMapImage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; import javax.imageio.ImageIO; diff --git a/altosuilib/AltosUIMapLine.java b/altosuilib/AltosUIMapLine.java index 2634f843..62ed4360 100644 --- a/altosuilib/AltosUIMapLine.java +++ b/altosuilib/AltosUIMapLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMapLine { AltosUILatLon start, end; diff --git a/altosuilib/AltosUIMapMark.java b/altosuilib/AltosUIMapMark.java index b4b98efa..09990da8 100644 --- a/altosuilib/AltosUIMapMark.java +++ b/altosuilib/AltosUIMapMark.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMapMark { diff --git a/altosuilib/AltosUIMapPath.java b/altosuilib/AltosUIMapPath.java index e77af580..b75dccea 100644 --- a/altosuilib/AltosUIMapPath.java +++ b/altosuilib/AltosUIMapPath.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class PathPoint { AltosUILatLon lat_lon; diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java index 1973ae6e..5b99ec03 100644 --- a/altosuilib/AltosUIMapPreload.java +++ b/altosuilib/AltosUIMapPreload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -26,7 +26,7 @@ import java.text.*; import java.lang.Math; import java.net.URL; import java.net.URLConnection; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; class AltosUIMapPos extends Box { AltosUIFrame owner; diff --git a/altosuilib/AltosUIMapRectangle.java b/altosuilib/AltosUIMapRectangle.java index dc0e4cc1..008623cb 100644 --- a/altosuilib/AltosUIMapRectangle.java +++ b/altosuilib/AltosUIMapRectangle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public class AltosUIMapRectangle { AltosUILatLon ul, lr; diff --git a/altosuilib/AltosUIMapStore.java b/altosuilib/AltosUIMapStore.java index 70bb6fed..ba505a7c 100644 --- a/altosuilib/AltosUIMapStore.java +++ b/altosuilib/AltosUIMapStore.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.net.*; diff --git a/altosuilib/AltosUIMapStoreListener.java b/altosuilib/AltosUIMapStoreListener.java index ccda8983..5a522387 100644 --- a/altosuilib/AltosUIMapStoreListener.java +++ b/altosuilib/AltosUIMapStoreListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIMapStoreListener { abstract void notify_store(AltosUIMapStore store, int status); diff --git a/altosuilib/AltosUIMapTile.java b/altosuilib/AltosUIMapTile.java index afd1bbc6..755dbde2 100644 --- a/altosuilib/AltosUIMapTile.java +++ b/altosuilib/AltosUIMapTile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.image.*; @@ -25,7 +25,7 @@ import java.awt.geom.*; import java.io.*; import java.util.*; import java.awt.RenderingHints.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMapTile { AltosUIMapTileListener listener; diff --git a/altosuilib/AltosUIMapTileListener.java b/altosuilib/AltosUIMapTileListener.java index dace5b76..01e5146b 100644 --- a/altosuilib/AltosUIMapTileListener.java +++ b/altosuilib/AltosUIMapTileListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIMapTileListener { abstract public void notify_tile(AltosUIMapTile tile, int status); diff --git a/altosuilib/AltosUIMapTransform.java b/altosuilib/AltosUIMapTransform.java index 25497403..3b85ca6a 100644 --- a/altosuilib/AltosUIMapTransform.java +++ b/altosuilib/AltosUIMapTransform.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -25,7 +25,7 @@ import java.lang.Math; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMapTransform { diff --git a/altosuilib/AltosUIMapView.java b/altosuilib/AltosUIMapView.java index d110f803..331b0aea 100644 --- a/altosuilib/AltosUIMapView.java +++ b/altosuilib/AltosUIMapView.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; @@ -26,7 +26,7 @@ import java.lang.*; import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIMapView extends Component implements MouseMotionListener, MouseListener, MouseWheelListener, ComponentListener, AltosUIMapTileListener, AltosUIMapStoreListener { diff --git a/altosuilib/AltosUIMapZoomListener.java b/altosuilib/AltosUIMapZoomListener.java index 9f74baca..6d7f5fa7 100644 --- a/altosuilib/AltosUIMapZoomListener.java +++ b/altosuilib/AltosUIMapZoomListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public interface AltosUIMapZoomListener { abstract public void zoom_changed(int zoom); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index 843ee939..287468bd 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 9760494c..6394f537 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index 91fe42ec..5fbfa7f9 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosUIRateList.java b/altosuilib/AltosUIRateList.java index 0c783a89..12d791b1 100644 --- a/altosuilib/AltosUIRateList.java +++ b/altosuilib/AltosUIRateList.java @@ -15,10 +15,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUIRateList extends JComboBox { diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 4cd5ccd1..c91c1204 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUITelemetryList.java b/altosuilib/AltosUITelemetryList.java index 77eef567..b4f80b0b 100644 --- a/altosuilib/AltosUITelemetryList.java +++ b/altosuilib/AltosUITelemetryList.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.util.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class AltosUITelemetryList extends JComboBox { diff --git a/altosuilib/AltosUIUnitsIndicator.java b/altosuilib/AltosUIUnitsIndicator.java index f86e274f..6f398808 100644 --- a/altosuilib/AltosUIUnitsIndicator.java +++ b/altosuilib/AltosUIUnitsIndicator.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public abstract class AltosUIUnitsIndicator extends AltosUIIndicator { diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in index beb62cbf..f65b41cd 100644 --- a/altosuilib/AltosUIVersion.java.in +++ b/altosuilib/AltosUIVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; public class AltosUIVersion { public final static String version = "@VERSION@"; diff --git a/altosuilib/AltosUIVoltageIndicator.java b/altosuilib/AltosUIVoltageIndicator.java index 44ad2ea2..840e5ad0 100644 --- a/altosuilib/AltosUIVoltageIndicator.java +++ b/altosuilib/AltosUIVoltageIndicator.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public abstract class AltosUIVoltageIndicator extends AltosUIUnitsIndicator { diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index e940493f..48daf131 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.util.*; import libaltosJNI.*; diff --git a/altosuilib/AltosVoice.java b/altosuilib/AltosVoice.java index 867f6619..98cc3c83 100644 --- a/altosuilib/AltosVoice.java +++ b/altosuilib/AltosVoice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; diff --git a/altosuilib/GrabNDrag.java b/altosuilib/GrabNDrag.java index 5d9ce2d9..cf0eacee 100644 --- a/altosuilib/GrabNDrag.java +++ b/altosuilib/GrabNDrag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/OSXAdapter.java b/altosuilib/OSXAdapter.java index 28b00ce1..7397e2a0 100755 --- a/altosuilib/OSXAdapter.java +++ b/altosuilib/OSXAdapter.java @@ -55,7 +55,7 @@ Copyright © 2003-2007 Apple, Inc., All Rights Reserved */ -package org.altusmetrum.altosuilib_6; +package org.altusmetrum.altosuilib_7; import java.lang.reflect.*; import java.util.HashMap; diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index 857dbe58..1001a370 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; class MicroIterator implements Iterator { int i; diff --git a/micropeak/MicroDataPoint.java b/micropeak/MicroDataPoint.java index 45d5ba27..1d42032f 100644 --- a/micropeak/MicroDataPoint.java +++ b/micropeak/MicroDataPoint.java @@ -17,7 +17,7 @@ package org.altusmetrum.micropeak; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class MicroDataPoint implements AltosUIDataPoint { public double time; diff --git a/micropeak/MicroDeviceDialog.java b/micropeak/MicroDeviceDialog.java index 55328482..91c3306b 100644 --- a/micropeak/MicroDeviceDialog.java +++ b/micropeak/MicroDeviceDialog.java @@ -21,7 +21,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class MicroDeviceDialog extends AltosDeviceDialog { diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index a03d7b3a..028f4431 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener, MicroSerialLog, WindowListener { MicroPeak owner; diff --git a/micropeak/MicroExport.java b/micropeak/MicroExport.java index 93c8cae8..7e75574d 100644 --- a/micropeak/MicroExport.java +++ b/micropeak/MicroExport.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroExport extends JFileChooser { diff --git a/micropeak/MicroFile.java b/micropeak/MicroFile.java index 78f7dac2..1d2447fc 100644 --- a/micropeak/MicroFile.java +++ b/micropeak/MicroFile.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroFile { diff --git a/micropeak/MicroFileChooser.java b/micropeak/MicroFileChooser.java index 5ac22e30..a48df6d1 100644 --- a/micropeak/MicroFileChooser.java +++ b/micropeak/MicroFileChooser.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroFileChooser extends JFileChooser { JFrame frame; diff --git a/micropeak/MicroFrame.java b/micropeak/MicroFrame.java index 47b03a12..4cb156f2 100644 --- a/micropeak/MicroFrame.java +++ b/micropeak/MicroFrame.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class MicroFrame extends AltosUIFrame { static String[] micro_icon_names = { diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index a6d511c3..d2c6a9e3 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index 9f7095f3..be50ac18 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index 587fe927..ed5410e0 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import java.io.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroRaw extends JTextArea { diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index 65026bda..15916ba0 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -24,8 +24,8 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroSave extends JFileChooser { diff --git a/micropeak/MicroSerial.java b/micropeak/MicroSerial.java index 4282aba1..c0ec161c 100644 --- a/micropeak/MicroSerial.java +++ b/micropeak/MicroSerial.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class MicroSerial extends InputStream { SWIGTYPE_p_altos_file file; diff --git a/micropeak/MicroSerialLog.java b/micropeak/MicroSerialLog.java index 3ee44649..a8c8b2ad 100644 --- a/micropeak/MicroSerialLog.java +++ b/micropeak/MicroSerialLog.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public interface MicroSerialLog { diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 47ef2a79..8cb64f4d 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -18,8 +18,8 @@ package org.altusmetrum.micropeak; import java.io.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroStats { double coast_height; diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java index 139c4416..ef6023dc 100644 --- a/micropeak/MicroStatsTable.java +++ b/micropeak/MicroStatsTable.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroStatsTable extends JComponent implements AltosFontListener { GridBagLayout layout; diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index fa20488d..906458c4 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class MicroUSB extends altos_device implements AltosDevice { diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 7570d380..8ff5ac28 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -24,8 +24,8 @@ import java.io.*; import java.util.concurrent.*; import java.util.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPS extends AltosUIFrame diff --git a/telegps/TeleGPSConfig.java b/telegps/TeleGPSConfig.java index 55763e22..e44c528c 100644 --- a/telegps/TeleGPSConfig.java +++ b/telegps/TeleGPSConfig.java @@ -22,8 +22,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSConfig implements ActionListener { diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 4e657586..8c3d0c2e 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -22,8 +22,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSConfigUI extends AltosUIDialog diff --git a/telegps/TeleGPSDisplayThread.java b/telegps/TeleGPSDisplayThread.java index 09610f59..d0d97876 100644 --- a/telegps/TeleGPSDisplayThread.java +++ b/telegps/TeleGPSDisplayThread.java @@ -21,8 +21,8 @@ import java.awt.*; import javax.swing.*; import java.io.*; import java.text.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSDisplayThread extends Thread { diff --git a/telegps/TeleGPSGraphUI.java b/telegps/TeleGPSGraphUI.java index d3adc748..ab094ac9 100644 --- a/telegps/TeleGPSGraphUI.java +++ b/telegps/TeleGPSGraphUI.java @@ -26,8 +26,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java index f20a8830..a5efb059 100644 --- a/telegps/TeleGPSInfo.java +++ b/telegps/TeleGPSInfo.java @@ -21,8 +21,8 @@ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSInfo extends AltosUIFlightTab { diff --git a/telegps/TeleGPSPreferences.java b/telegps/TeleGPSPreferences.java index 6d7b8985..b62ea5a8 100644 --- a/telegps/TeleGPSPreferences.java +++ b/telegps/TeleGPSPreferences.java @@ -22,7 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSPreferences extends AltosUIConfigure diff --git a/telegps/TeleGPSState.java b/telegps/TeleGPSState.java index 18f500b9..6fbd0b5e 100644 --- a/telegps/TeleGPSState.java +++ b/telegps/TeleGPSState.java @@ -21,8 +21,8 @@ import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSState extends AltosUIFlightTab { diff --git a/telegps/TeleGPSStatus.java b/telegps/TeleGPSStatus.java index 050a8449..cc9966b8 100644 --- a/telegps/TeleGPSStatus.java +++ b/telegps/TeleGPSStatus.java @@ -19,8 +19,8 @@ package org.altusmetrum.telegps; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_6.*; -import org.altusmetrum.altosuilib_6.*; +import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altosuilib_7.*; public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/telegps/TeleGPSStatusUpdate.java b/telegps/TeleGPSStatusUpdate.java index 9c085a5b..1d545927 100644 --- a/telegps/TeleGPSStatusUpdate.java +++ b/telegps/TeleGPSStatusUpdate.java @@ -18,7 +18,7 @@ package org.altusmetrum.telegps; import java.awt.event.*; -import org.altusmetrum.altoslib_6.*; +import org.altusmetrum.altoslib_7.*; public class TeleGPSStatusUpdate implements ActionListener { -- cgit v1.2.3 From 501fa41111b93cc213a1114a33612858e1e93ab5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 00:29:53 -0700 Subject: altoslib/altosuilib: Get new Map display code running in altosui and telegps Looks like the display is all hooked up. Still need to replace the preload UIs. Signed-off-by: Keith Packard --- altoslib/AltosMap.java | 103 ++++--- altoslib/AltosMapInterface.java | 11 +- altoslib/AltosMapLine.java | 4 +- altoslib/AltosMapMark.java | 4 +- altoslib/AltosMapTile.java | 1 + altoslib/AltosMapTileListener.java | 2 + altosuilib/AltosUIMapNew.java | 539 +++++++++++++++++++++++++++++++++++++ telegps/TeleGPS.java | 4 +- 8 files changed, 620 insertions(+), 48 deletions(-) create mode 100644 altosuilib/AltosUIMapNew.java diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index 7c7c7305..b54c66cf 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -22,7 +22,7 @@ import java.lang.*; import java.util.*; import java.util.concurrent.*; -public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, AltosMapStoreListener { +public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { public static final int px_size = 512; @@ -54,18 +54,12 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos AltosMapCache cache; - LinkedList marks = new LinkedList(); - - LinkedList zoom_listeners = new LinkedList(); + public AltosMapCache cache() { return cache; } - public void add_zoom_listener(AltosMapZoomListener listener) { - if (!zoom_listeners.contains(listener)) - zoom_listeners.add(listener); - } + LinkedList marks = new LinkedList(); - public void remove_zoom_listener(AltosMapZoomListener listener) { - zoom_listeners.remove(listener); - } + AltosMapPath path; + AltosMapLine line; boolean have_boost = false; boolean have_landed = false; @@ -84,7 +78,7 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos */ static final long auto_scroll_delay = 20 * 1000; - AltosMapTransform transform; + public AltosMapTransform transform; AltosLatLon centre; public void reset() { @@ -92,16 +86,14 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos } /* MapInterface wrapping functions */ - public void set_units() { - map_interface.set_units(); - } - public void repaint(AltosMapRectangle damage, int pad) { - map_interface.repaint(damage, pad); + public void repaint(int x, int y, int w, int h) { + map_interface.repaint(new AltosRectangle(x, y, w, h)); } - public void repaint(double x, double y, double w, double h) { - map_interface.repaint(x, y, w, h); + public void repaint(AltosMapRectangle damage, int pad) { + AltosRectangle r = transform.screen(damage); + repaint(r.x - pad, r.y - pad, r.width + pad * 2, r.height + pad * 2); } public void repaint() { @@ -156,30 +148,22 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos return false; } - public void font_size_changed(int font_size) { - map_interface.line().font_size_changed(font_size); - for (AltosMapTile tile : tiles.values()) - tile.font_size_changed(font_size); + public void set_transform() { + transform = new AltosMapTransform(width(), height(), zoom, centre); repaint(); } - public void units_changed(boolean imperial_units) { + private void set_zoom_label() { + map_interface.set_zoom_label(String.format("Zoom %d", get_zoom() - default_zoom)); } - private void set_transform() { - transform = new AltosMapTransform(width(), height(), zoom, centre); - repaint(); - } public boolean set_zoom(int zoom) { if (AltosMap.min_zoom <= zoom && zoom <= AltosMap.max_zoom && zoom != this.zoom) { this.zoom = zoom; tiles.clear(); set_transform(); - - for (AltosMapZoomListener listener : zoom_listeners) - listener.zoom_changed(this.zoom); - + set_zoom_label(); return true; } return false; @@ -211,7 +195,7 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos if (!gps.locked && gps.nsat < 4) return; - AltosMapRectangle damage = map_interface.path().add(gps.lat, gps.lon, state.state); + AltosMapRectangle damage = path.add(gps.lat, gps.lon, state.state); switch (state.state) { case AltosLib.ao_flight_boost: @@ -339,9 +323,9 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos mark.paint(transform); } - map_interface.path().paint(transform); + path.paint(transform); - map_interface.line().paint(transform); + line.paint(transform); } /* AltosMapTileListener methods */ @@ -363,9 +347,58 @@ public class AltosMap implements AltosFlightDisplay, AltosMapTileListener, Altos } } + /* UI elements */ + + AltosPointInt drag_start; + + private void drag(int x, int y) { + if (drag_start == null) + return; + + int dx = x - drag_start.x; + int dy = y - drag_start.y; + + AltosLatLon new_centre = transform.screen_lat_lon(new AltosPointInt(width() / 2 - dx, height() / 2 - dy)); + centre(new_centre); + drag_start = new AltosPointInt(x, y); + } + + private void drag_start(int x, int y) { + drag_start = new AltosPointInt(x, y); + } + + private void line_start(int x, int y) { + line.pressed(new AltosPointInt(x, y), transform); + repaint(); + } + + private void line(int x, int y) { + line.dragged(new AltosPointInt(x, y), transform); + repaint(); + } + + public void touch_start(int x, int y, boolean is_drag) { + notice_user_input(); + if (is_drag) + drag_start(x, y); + else + line_start(x, y); + } + + public void touch_continue(int x, int y, boolean is_drag) { + notice_user_input(); + if (is_drag) + drag(x, y); + else + line(x, y); + } + public AltosMap(AltosMapInterface map_interface) { this.map_interface = map_interface; cache = new AltosMapCache(map_interface); + line = map_interface.new_line(); + path = map_interface.new_path(); + set_zoom_label(); centre(0, 0); } } diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index 0dcd646e..195574e9 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -21,8 +21,9 @@ import java.io.*; import java.net.*; public interface AltosMapInterface { - public abstract AltosMapPath path(); - public abstract AltosMapLine line(); + public abstract AltosMapPath new_path(); + + public abstract AltosMapLine new_line(); public abstract AltosImage load_image(File file) throws Exception; @@ -36,9 +37,7 @@ public interface AltosMapInterface { public abstract void repaint(); - public abstract void repaint(AltosMapRectangle damage, int pad); - - public abstract void repaint(double x, double y, double w, double h); + public abstract void repaint(AltosRectangle damage); - public abstract void set_units(); + public abstract void set_zoom_label(String label); } diff --git a/altoslib/AltosMapLine.java b/altoslib/AltosMapLine.java index e727e338..23a6f889 100644 --- a/altoslib/AltosMapLine.java +++ b/altoslib/AltosMapLine.java @@ -22,13 +22,11 @@ import java.lang.Math; import java.util.*; import java.util.concurrent.*; -public abstract class AltosMapLine implements AltosFontListener { +public abstract class AltosMapLine { public AltosLatLon start, end; static public int stroke_width = 6; - public abstract void font_size_changed(int font_size); - public abstract void paint(AltosMapTransform t); private AltosLatLon lat_lon(AltosPointInt pt, AltosMapTransform t) { diff --git a/altoslib/AltosMapMark.java b/altoslib/AltosMapMark.java index 5eb1907b..74e6790f 100644 --- a/altoslib/AltosMapMark.java +++ b/altoslib/AltosMapMark.java @@ -24,8 +24,8 @@ import java.util.concurrent.*; public abstract class AltosMapMark { - AltosLatLon lat_lon; - int state; + public AltosLatLon lat_lon; + public int state; static public int stroke_width = 6; diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index e61746f8..165f9e6f 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -99,6 +99,7 @@ public abstract class AltosMapTile implements AltosFontListener { public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { this.listener = listener; this.upper_left = upper_left; + this.cache = listener.cache(); while (center.lon < -180.0) center.lon += 360.0; diff --git a/altoslib/AltosMapTileListener.java b/altoslib/AltosMapTileListener.java index 60d92c75..ed47e833 100644 --- a/altoslib/AltosMapTileListener.java +++ b/altoslib/AltosMapTileListener.java @@ -19,4 +19,6 @@ package org.altusmetrum.altoslib_7; public interface AltosMapTileListener { abstract public void notify_tile(AltosMapTile tile, int status); + + abstract public AltosMapCache cache(); } diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java new file mode 100644 index 00000000..4191a562 --- /dev/null +++ b/altosuilib/AltosUIMapNew.java @@ -0,0 +1,539 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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. + */ + +package org.altusmetrum.altosuilib_7; + +import java.awt.*; +import java.awt.event.*; +import java.awt.image.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.*; +import java.util.*; +import java.util.concurrent.*; +import javax.imageio.*; +import org.altusmetrum.altoslib_7.*; + +public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, AltosMapInterface { + + AltosMap map; + Graphics2D g; + Font tile_font; + Font line_font; + + static Point2D.Double point2d(AltosPointDouble pt) { + return new Point2D.Double(pt.x, pt.y); + } + + static final AltosPointDouble point_double(Point pt) { + return new AltosPointDouble(pt.x, pt.y); + } + + class MapMark extends AltosMapMark { + public void paint(AltosMapTransform t) { + AltosPointDouble pt = t.screen(lat_lon); + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + + if (0 <= state && state < AltosUIMapNew.stateColors.length) + g.setColor(AltosUIMapNew.stateColors[state]); + else + g.setColor(AltosUIMapNew.stateColors[AltosLib.ao_flight_invalid]); + + g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); + g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); + g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); + } + + MapMark(double lat, double lon, int state) { + super(lat, lon, state); + } + } + + class MapView extends JComponent implements MouseMotionListener, MouseListener, ComponentListener, MouseWheelListener { + + private VolatileImage create_back_buffer() { + return getGraphicsConfiguration().createCompatibleVolatileImage(getWidth(), getHeight()); + } + + private void do_paint(Graphics my_g) { + g = (Graphics2D) my_g; + + map.paint(); + } + + public void paint(Graphics my_g) { + VolatileImage back_buffer = create_back_buffer(); + + Graphics2D top_g = (Graphics2D) my_g; + + do { + GraphicsConfiguration gc = getGraphicsConfiguration(); + int code = back_buffer.validate(gc); + if (code == VolatileImage.IMAGE_INCOMPATIBLE) + back_buffer = create_back_buffer(); + + Graphics g_back = back_buffer.getGraphics(); + g_back.setClip(top_g.getClip()); + do_paint(g_back); + g_back.dispose(); + + top_g.drawImage(back_buffer, 0, 0, this); + } while (back_buffer.contentsLost()); + back_buffer.flush(); + } + + public void repaint(AltosRectangle damage) { + repaint(damage.x, damage.y, damage.width, damage.height); + } + + private boolean is_drag_event(MouseEvent e) { + return e.getModifiers() == InputEvent.BUTTON1_MASK; + } + + /* MouseMotionListener methods */ + + public void mouseDragged(MouseEvent e) { + map.touch_continue(e.getPoint().x, e.getPoint().y, is_drag_event(e)); + } + + public void mouseMoved(MouseEvent e) { + } + + /* MouseListener methods */ + public void mouseClicked(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + map.touch_start(e.getPoint().x, e.getPoint().y, is_drag_event(e)); + } + + public void mouseReleased(MouseEvent e) { + } + + /* MouseWheelListener methods */ + + public void mouseWheelMoved(MouseWheelEvent e) { + int zoom_change = e.getWheelRotation(); + + map.notice_user_input(); + AltosLatLon mouse_lat_lon = map.transform.screen_lat_lon(new AltosPointInt(e.getPoint().x, e.getPoint().y)); + map.set_zoom(map.get_zoom() - zoom_change); + + AltosPointDouble new_mouse = map.transform.screen(mouse_lat_lon); + + int dx = getWidth()/2 - e.getPoint().x; + int dy = getHeight()/2 - e.getPoint().y; + + AltosLatLon new_centre = map.transform.screen_lat_lon(new AltosPointInt((int) new_mouse.x + dx, (int) new_mouse.y + dy)); + + map.centre(new_centre); + } + + /* ComponentListener methods */ + + public void componentHidden(ComponentEvent e) { + } + + public void componentMoved(ComponentEvent e) { + } + + public void componentResized(ComponentEvent e) { + map.set_transform(); + } + + public void componentShown(ComponentEvent e) { + map.set_transform(); + } + + MapView() { + addComponentListener(this); + addMouseMotionListener(this); + addMouseListener(this); + addMouseWheelListener(this); + } + } + + class MapLine extends AltosMapLine { + + public void paint(AltosMapTransform t) { + + if (start == null || end == null) + return; + + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + Line2D.Double line = new Line2D.Double(point2d(t.screen(start)), + point2d(t.screen(end))); + + g.setColor(Color.WHITE); + g.setStroke(new BasicStroke(stroke_width+4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + g.draw(line); + + g.setColor(Color.BLUE); + g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + g.draw(line); + + String message = line_dist(); + Rectangle2D bounds; + bounds = line_font.getStringBounds(message, g.getFontRenderContext()); + + float x = (float) line.x1; + float y = (float) line.y1 + (float) bounds.getHeight() / 2.0f; + + if (line.x1 < line.x2) { + x -= (float) bounds.getWidth() + 2.0f; + } else { + x += 2.0f; + } + + g.setFont(line_font); + g.setColor(Color.WHITE); + for (int dy = -2; dy <= 2; dy += 2) + for (int dx = -2; dx <= 2; dx += 2) + g.drawString(message, x + dx, y + dy); + g.setColor(Color.BLUE); + g.drawString(message, x, y); + } + + public MapLine() { + } + } + + class MapPath extends AltosMapPath { + public void paint(AltosMapTransform t) { + Point2D.Double prev = null; + + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + + for (AltosMapPathPoint point : points) { + Point2D.Double cur = point2d(t.screen(point.lat_lon)); + if (prev != null) { + Line2D.Double line = new Line2D.Double (prev, cur); + Rectangle bounds = line.getBounds(); + + if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { + if (0 <= point.state && point.state < AltosUIMapNew.stateColors.length) + g.setColor(AltosUIMapNew.stateColors[point.state]); + else + g.setColor(AltosUIMapNew.stateColors[AltosLib.ao_flight_invalid]); + + g.draw(line); + } + } + prev = cur; + } + } + } + + class MapTile extends AltosMapTile { + public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + super(listener, upper_left, center, zoom, maptype, px_size); + } + + public void paint(AltosMapTransform t) { + + AltosPointDouble point_double = t.screen(upper_left); + Point point = new Point((int) (point_double.x + 0.5), + (int) (point_double.y + 0.5)); + + if (!g.hitClip(point.x, point.y, px_size, px_size)) + return; + + AltosImage altos_image = cache.get(this, store, px_size, px_size); + + AltosUIImage ui_image = (AltosUIImage) altos_image; + + Image image = null; + + if (ui_image != null) + image = ui_image.image; + + if (image != null) { + g.drawImage(image, point.x, point.y, null); + } else { + g.setColor(Color.GRAY); + g.fillRect(point.x, point.y, px_size, px_size); + + if (t.has_location()) { + String message = null; + switch (status) { + case AltosUIMapCache.loading: + message = "Loading..."; + break; + case AltosUIMapCache.bad_request: + message = "Internal error"; + break; + case AltosUIMapCache.failed: + message = "Network error, check connection"; + break; + case AltosUIMapCache.forbidden: + message = "Too many requests, try later"; + break; + } + if (message != null && tile_font != null) { + g.setFont(tile_font); + g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + Rectangle2D bounds = tile_font.getStringBounds(message, g.getFontRenderContext()); + + float x = px_size / 2.0f; + float y = px_size / 2.0f; + x = x - (float) bounds.getWidth() / 2.0f; + y = y + (float) bounds.getHeight() / 2.0f; + g.setColor(Color.BLACK); + g.drawString(message, (float) point_double.x + x, (float) point_double.y + y); + } + } + } + } + } + + public static final Color stateColors[] = { + Color.WHITE, // startup + Color.WHITE, // idle + Color.WHITE, // pad + Color.RED, // boost + Color.PINK, // fast + Color.YELLOW, // coast + Color.CYAN, // drogue + Color.BLUE, // main + Color.BLACK, // landed + Color.BLACK, // invalid + Color.CYAN, // stateless + }; + + /* AltosMapInterface functions */ + + public AltosMapPath new_path() { + return new MapPath(); + } + + public AltosMapLine new_line() { + return new MapLine(); + } + + public AltosImage load_image(File file) throws Exception { + return new AltosUIImage(ImageIO.read(file)); + } + + public AltosMapMark new_mark(double lat, double lon, int state) { + return new MapMark(lat, lon, state); + } + + public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + return new MapTile(listener, upper_left, center, zoom, maptype, px_size); + } + + public int width() { + return view.getWidth(); + } + + public int height() { + return view.getHeight(); + } + + public void repaint() { + view.repaint(); + } + + public void repaint(AltosRectangle damage) { + view.repaint(damage); + } + + public void set_zoom_label(String label) { + zoom_label.setText(label); + } + + /* AltosFlightDisplay interface */ + + public void set_font() { + tile_font = AltosUILib.value_font; + line_font = AltosUILib.status_font; + } + + public void font_size_changed(int font_size) { + set_font(); + repaint(); + } + + public void units_changed(boolean imperial_units) { + repaint(); + } + + JLabel zoom_label; + + public void set_maptype(int type) { + map.set_maptype(type); + maptype_combo.setSelectedIndex(type); + } + + /* AltosUIMapPreload functions */ + + public void set_zoom(int zoom) { + map.set_zoom(zoom); + } + + public void add_mark(double lat, double lon, int status) { + map.add_mark(lat, lon, status); + } + + public void clear_marks() { + map.clear_marks(); + } + + /* AltosFlightDisplay interface */ + public void reset() { + // nothing + } + + public void show(AltosState state, AltosListenerState listener_state) { + map.show(state, listener_state); + } + + public String getName() { + return "Map"; + } + + /* internal layout bits */ + private GridBagLayout layout = new GridBagLayout(); + + JComboBox maptype_combo; + + public void set_load_params(double lat, double lon, int radius, AltosMapTileListener listener) { + map.set_load_params(lat, lon, radius, listener); + } + + MapView view; + + public AltosUIMapNew() { + + set_font(); + + view = new MapView(); + + view.setPreferredSize(new Dimension(500,500)); + view.setVisible(true); + view.setEnabled(true); + + GridBagLayout my_layout = new GridBagLayout(); + + setLayout(my_layout); + + GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 1; + c.gridheight = 10; + c.weightx = 1; + c.weighty = 1; + add(view, c); + + int y = 0; + + zoom_label = new JLabel("", JLabel.CENTER); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_label, c); + + JButton zoom_reset = new JButton("0"); + zoom_reset.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + map.set_zoom(map.default_zoom); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_reset, c); + + JButton zoom_in = new JButton("+"); + zoom_in.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + map.set_zoom(map.get_zoom() + 1); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_in, c); + + JButton zoom_out = new JButton("-"); + zoom_out.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + map.set_zoom(map.get_zoom() - 1); + } + }); + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(zoom_out, c); + + maptype_combo = new JComboBox(map.maptype_labels); + + maptype_combo.setEditable(false); + maptype_combo.setMaximumRowCount(maptype_combo.getItemCount()); + maptype_combo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + map.set_maptype(maptype_combo.getSelectedIndex()); + } + }); + + c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 1; + c.gridy = y++; + c.weightx = 0; + c.weighty = 0; + add(maptype_combo, c); + + map = new AltosMap(this); + } +} diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 8ff5ac28..1e134900 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -71,7 +71,7 @@ public class TeleGPS JTabbedPane pane; - AltosUIMap map; + AltosUIMapNew map; TeleGPSInfo gps_info; TeleGPSState gps_state; AltosInfoTable info_table; @@ -542,7 +542,7 @@ public class TeleGPS c.gridwidth = 2; bag.add(pane, c); - map = new AltosUIMap(); + map = new AltosUIMapNew(); pane.add(map.getName(), map); displays.add(map); -- cgit v1.2.3 From cd0f4de98ea709e5f070d5f1337658590d2004a1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 00:33:02 -0700 Subject: altosuilib: Add AltosUIImage.java Signed-off-by: Keith Packard --- altosuilib/AltosUIImage.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 altosuilib/AltosUIImage.java diff --git a/altosuilib/AltosUIImage.java b/altosuilib/AltosUIImage.java new file mode 100644 index 00000000..3a2e2c01 --- /dev/null +++ b/altosuilib/AltosUIImage.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_7; + +import javax.swing.*; +import javax.imageio.ImageIO; +import java.awt.image.*; +import java.awt.*; +import java.io.*; +import java.net.*; + +public class AltosUIImage implements AltosImage { + public Image image; + + /* Discard storage for image */ + public void flush() { + image.flush(); + } + + public AltosUIImage(Image image) { + this.image = image; + } +} -- cgit v1.2.3 From f41fe2291891b28327c332098bdc601bc75fc4c0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 00:46:21 -0700 Subject: altosuilib: Use new map code for map preload UI Signed-off-by: Keith Packard --- altosui/AltosUI.java | 2 +- altosuilib/AltosUIMapPreloadNew.java | 609 +++++++++++++++++++++++++++++++++++ altosuilib/Makefile.am | 1 + telegps/TeleGPS.java | 2 +- 4 files changed, 612 insertions(+), 2 deletions(-) create mode 100644 altosuilib/AltosUIMapPreloadNew.java diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 9061a8ad..32490b65 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -295,7 +295,7 @@ public class AltosUI extends AltosUIFrame { } void LoadMaps() { - new AltosUIMapPreload(AltosUI.this); + new AltosUIMapPreloadNew(AltosUI.this); } void LaunchController() { diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java new file mode 100644 index 00000000..7d3c2a0b --- /dev/null +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -0,0 +1,609 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altosuilib_7; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.lang.Math; +import java.net.URL; +import java.net.URLConnection; +import org.altusmetrum.altoslib_7.*; + +class AltosUIMapPos extends Box { + AltosUIFrame owner; + JLabel label; + JComboBox hemi; + JTextField deg; + JLabel deg_label; + JTextField min; + JLabel min_label; + + public void set_value(double new_value) { + double d, m; + int h; + + h = 0; + if (new_value < 0) { + h = 1; + new_value = -new_value; + } + d = Math.floor(new_value); + deg.setText(String.format("%3.0f", d)); + m = (new_value - d) * 60.0; + min.setText(String.format("%7.4f", m)); + hemi.setSelectedIndex(h); + } + + public double get_value() throws ParseException { + int h = hemi.getSelectedIndex(); + String d_t = deg.getText(); + String m_t = min.getText(); + double d, m, v; + try { + d = AltosParse.parse_double_locale(d_t); + } catch (ParseException pe) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid degrees \"%s\"", + d_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw pe; + } + try { + if (m_t.equals("")) + m = 0; + else + m = AltosParse.parse_double_locale(m_t); + } catch (ParseException pe) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid minutes \"%s\"", + m_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw pe; + } + v = d + m/60.0; + if (h == 1) + v = -v; + return v; + } + + public AltosUIMapPos(AltosUIFrame in_owner, + String label_value, + String[] hemi_names, + double default_value) { + super(BoxLayout.X_AXIS); + owner = in_owner; + label = new JLabel(label_value); + hemi = new JComboBox(hemi_names); + hemi.setEditable(false); + deg = new JTextField(5); + deg.setMinimumSize(deg.getPreferredSize()); + deg.setHorizontalAlignment(JTextField.RIGHT); + deg_label = new JLabel("°"); + min = new JTextField(9); + min.setMinimumSize(min.getPreferredSize()); + min_label = new JLabel("'"); + set_value(default_value); + add(label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(hemi); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg_label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min_label); + } +} + +class AltosUISite { + String name; + double latitude; + double longitude; + + public String toString() { + return name; + } + + public AltosUISite(String in_name, double in_latitude, double in_longitude) { + name = in_name; + latitude = in_latitude; + longitude = in_longitude; + } + + public AltosUISite(String line) throws ParseException { + String[] elements = line.split(":"); + + if (elements.length < 3) + throw new ParseException(String.format("Invalid site line %s", line), 0); + + name = elements[0]; + + try { + latitude = AltosParse.parse_double_net(elements[1]); + longitude = AltosParse.parse_double_net(elements[2]); + } catch (ParseException pe) { + throw new ParseException(String.format("Invalid site line %s", line), 0); + } + } +} + +class AltosUISites extends Thread { + AltosUIMapPreloadNew preload; + URL url; + LinkedList sites; + + void notify_complete() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + preload.set_sites(); + } + }); + } + + void add(AltosUISite site) { + sites.add(site); + } + + void add(String line) { + try { + add(new AltosUISite(line)); + } catch (ParseException pe) { + System.out.printf("parse exception %s\n", pe.toString()); + } + } + + public void run() { + try { + URLConnection uc = url.openConnection(); + //int length = uc.getContentLength(); + + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); + BufferedReader in = new BufferedReader(in_stream); + + for (;;) { + String line = in.readLine(); + if (line == null) + break; + add(line); + } + } catch (IOException e) { + } finally { + notify_complete(); + } + } + + public AltosUISites(AltosUIMapPreloadNew in_preload) { + sites = new LinkedList(); + preload = in_preload; + try { + url = new URL(AltosLib.launch_sites_url); + } catch (java.net.MalformedURLException e) { + notify_complete(); + } + start(); + } +} + +public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener { + AltosUIFrame owner; + AltosUIMapNew map; + AltosMapCache cache; + + AltosUIMapPos lat; + AltosUIMapPos lon; + + JProgressBar pbar; + int pbar_max; + int pbar_cur; + + AltosUISites sites; + JLabel site_list_label; + JComboBox site_list; + + JToggleButton load_button; + boolean loading; + JButton close_button; + + JCheckBox[] maptypes = new JCheckBox[AltosUIMap.maptype_terrain - AltosUIMap.maptype_hybrid + 1]; + + JComboBox min_zoom; + JComboBox max_zoom; + JComboBox radius; + + Integer[] zooms = { -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 }; + Integer[] radii = { 1, 2, 3, 4, 5 }; + + static final String[] lat_hemi_names = { "N", "S" }; + static final String[] lon_hemi_names = { "E", "W" }; + + class updatePbar implements Runnable { + String s; + + public updatePbar(String in_s) { + s = in_s; + } + + public void run() { + int n = ++pbar_cur; + + pbar.setMaximum(pbar_max); + pbar.setValue(n); + pbar.setString(s); + } + } + + double latitude, longitude; + int min_z; + int max_z; + int cur_z; + int all_types; + int cur_type; + int r; + + int tiles_per_layer; + int tiles_loaded; + int layers_total; + int layers_loaded; + + + private void do_load() { + tiles_loaded = 0; + map.set_zoom(cur_z + AltosUIMapView.default_zoom); + map.set_maptype(cur_type); + map.set_load_params(latitude, longitude, r, this); + } + + private int next_type(int start) { + int next_type; + for (next_type = start; + next_type <= AltosUIMap.maptype_terrain && (all_types & (1 << next_type)) == 0; + next_type++) + ; + return next_type; + } + + private void next_load() { + int next_type = next_type(cur_type + 1); + + if (next_type > AltosUIMap.maptype_terrain) { + if (cur_z == max_z) { + return; + } else { + cur_z++; + } + next_type = next_type(0); + } + cur_type = next_type; + do_load(); + } + + private void start_load() { + cur_z = min_z; + int ntype = 0; + all_types = 0; + for (int t = AltosUIMap.maptype_hybrid; t <= AltosUIMap.maptype_terrain; t++) + if (maptypes[t].isSelected()) { + all_types |= (1 << t); + ntype++; + } + if (ntype == 0) { + all_types |= (1 << AltosUIMap.maptype_hybrid); + ntype = 1; + } + + cur_type = next_type(0); + tiles_per_layer = (r * 2 + 1) * (r * 2 + 1); + layers_total = (max_z - min_z + 1) * ntype; + layers_loaded = 0; + pbar_max = layers_total * tiles_per_layer; + pbar_cur = 0; + + map.clear_marks(); + map.add_mark(latitude,longitude, AltosLib.ao_flight_boost); + do_load(); + } + + /* AltosMapTileListener methods */ + + public synchronized void notify_tile(AltosMapTile tile, int status) { + if (status == AltosMapTile.loading) + return; + + SwingUtilities.invokeLater(new updatePbar(tile.store.file.toString())); + ++tiles_loaded; + if (tiles_loaded == tiles_per_layer) { + ++layers_loaded; + if (layers_loaded == layers_total) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + pbar.setValue(0); + pbar.setString(""); + load_button.setSelected(false); + loading = false; + } + }); + } else { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + next_load(); + } + }); + } + } + } + + public AltosMapCache cache() { return cache; } + + public void set_sites() { + int i = 1; + for (AltosUISite site : sites.sites) { + site_list.insertItemAt(site, i); + i++; + } + } + + public void itemStateChanged(ItemEvent e) { + int state = e.getStateChange(); + + if (state == ItemEvent.SELECTED) { + Object o = e.getItem(); + if (o instanceof AltosUISite) { + AltosUISite site = (AltosUISite) o; + lat.set_value(site.latitude); + lon.set_value(site.longitude); + } + } + } + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + + if (cmd.equals("close")) + setVisible(false); + + if (cmd.equals("load")) { + if (!loading) { + try { + latitude = lat.get_value(); + longitude = lon.get_value(); + min_z = (Integer) min_zoom.getSelectedItem(); + max_z = (Integer) max_zoom.getSelectedItem(); + if (max_z < min_z) + max_z = min_z; + r = (Integer) radius.getSelectedItem(); + loading = true; + } catch (ParseException pe) { + load_button.setSelected(false); + } + start_load(); + } + } + } + + public AltosUIMapPreloadNew(AltosUIFrame in_owner) { + owner = in_owner; + + Container pane = getContentPane(); + GridBagConstraints c = new GridBagConstraints(); + Insets i = new Insets(4,4,4,4); + + setTitle("AltOS Load Maps"); + + pane.setLayout(new GridBagLayout()); + + map = new AltosUIMapNew(); + cache = new AltosMapCache(map); + + c.fill = GridBagConstraints.BOTH; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 1; + + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 10; + c.anchor = GridBagConstraints.CENTER; + + pane.add(map, c); + + pbar = new JProgressBar(); + pbar.setMinimum(0); + pbar.setMaximum(1); + pbar.setValue(0); + pbar.setString(""); + pbar.setStringPainted(true); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 10; + + pane.add(pbar, c); + + site_list_label = new JLabel ("Known Launch Sites:"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list_label, c); + + site_list = new JComboBox(new AltosUISite[] { new AltosUISite("Site List", 0, 0) }); + site_list.addItemListener(this); + + sites = new AltosUISites(this); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list, c); + + lat = new AltosUIMapPos(owner, + "Latitude:", + lat_hemi_names, + 37.167833333); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lat, c); + + lon = new AltosUIMapPos(owner, + "Longitude:", + lon_hemi_names, + -97.73975); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lon, c); + + load_button = new JToggleButton("Load Map"); + load_button.addActionListener(this); + load_button.setActionCommand("load"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(load_button, c); + + close_button = new JButton("Close"); + close_button.addActionListener(this); + close_button.setActionCommand("close"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(close_button, c); + + JLabel types_label = new JLabel("Map Types"); + c.gridx = 2; + c.gridwidth = 2; + c.gridy = 2; + pane.add(types_label, c); + + c.gridwidth = 1; + + for (int type = AltosUIMap.maptype_hybrid; type <= AltosUIMap.maptype_terrain; type++) { + maptypes[type] = new JCheckBox(AltosUIMap.maptype_labels[type], + type == AltosUIMap.maptype_hybrid); + c.gridx = 2 + (type >> 1); + c.fill = GridBagConstraints.HORIZONTAL; + c.gridy = (type & 1) + 3; + pane.add(maptypes[type], c); + } + + JLabel min_zoom_label = new JLabel("Minimum Zoom"); + c.gridx = 4; + c.gridy = 2; + pane.add(min_zoom_label, c); + + min_zoom = new JComboBox(zooms); + min_zoom.setSelectedItem(zooms[10]); + min_zoom.setEditable(false); + c.gridx = 5; + c.gridy = 2; + pane.add(min_zoom, c); + + JLabel max_zoom_label = new JLabel("Maximum Zoom"); + c.gridx = 4; + c.gridy = 3; + pane.add(max_zoom_label, c); + + max_zoom = new JComboBox(zooms); + max_zoom.setSelectedItem(zooms[14]); + max_zoom.setEditable(false); + c.gridx = 5; + c.gridy = 3; + pane.add(max_zoom, c); + + JLabel radius_label = new JLabel("Tile Radius"); + c.gridx = 4; + c.gridy = 4; + pane.add(radius_label, c); + + radius = new JComboBox(radii); + radius.setSelectedItem(radii[4]); + radius.setEditable(true); + c.gridx = 5; + c.gridy = 4; + pane.add(radius, c); + + pack(); + setLocationRelativeTo(owner); + setVisible(true); + } +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 30d003e9..7ec94ba0 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -60,6 +60,7 @@ altosuilib_JAVA = \ AltosBTKnown.java \ AltosUIMap.java \ AltosUIMapNew.java \ + AltosUIMapPreloadNew.java \ AltosUIMapView.java \ AltosUIMapLine.java \ AltosUIMapMark.java \ diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 1e134900..0e46a780 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -173,7 +173,7 @@ public class TeleGPS } void load_maps() { - new AltosUIMapPreload(this); + new AltosUIMapPreloadNew(this); } void disconnect() { -- cgit v1.2.3 From 4895f443e4a748de2677e51869f20c05d265c944 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 00:56:17 -0700 Subject: altosuilib: Remove old map bits Signed-off-by: Keith Packard --- altosui/AltosGraphUI.java | 4 +- altosui/AltosIdleMonitorUI.java | 4 +- altosuilib/AltosUILatLon.java | 44 --- altosuilib/AltosUIMap.java | 250 ------------- altosuilib/AltosUIMapCache.java | 137 ------- altosuilib/AltosUIMapCacheListener.java | 22 -- altosuilib/AltosUIMapImage.java | 113 ------ altosuilib/AltosUIMapLine.java | 129 ------- altosuilib/AltosUIMapMark.java | 59 ---- altosuilib/AltosUIMapNew.java | 13 +- altosuilib/AltosUIMapPath.java | 96 ----- altosuilib/AltosUIMapPreload.java | 608 -------------------------------- altosuilib/AltosUIMapPreloadNew.java | 18 +- altosuilib/AltosUIMapRectangle.java | 45 --- altosuilib/AltosUIMapStore.java | 203 ----------- altosuilib/AltosUIMapStoreListener.java | 22 -- altosuilib/AltosUIMapTile.java | 192 ---------- altosuilib/AltosUIMapTileListener.java | 24 -- altosuilib/AltosUIMapTransform.java | 106 ------ altosuilib/AltosUIMapView.java | 457 ------------------------ altosuilib/AltosUIMapZoomListener.java | 22 -- altosuilib/AltosUIPreferences.java | 35 -- altosuilib/Makefile.am | 17 - telegps/TeleGPS.java | 16 +- telegps/TeleGPSGraphUI.java | 4 +- 25 files changed, 25 insertions(+), 2615 deletions(-) delete mode 100644 altosuilib/AltosUILatLon.java delete mode 100644 altosuilib/AltosUIMap.java delete mode 100644 altosuilib/AltosUIMapCache.java delete mode 100644 altosuilib/AltosUIMapCacheListener.java delete mode 100644 altosuilib/AltosUIMapImage.java delete mode 100644 altosuilib/AltosUIMapLine.java delete mode 100644 altosuilib/AltosUIMapMark.java delete mode 100644 altosuilib/AltosUIMapPath.java delete mode 100644 altosuilib/AltosUIMapPreload.java delete mode 100644 altosuilib/AltosUIMapRectangle.java delete mode 100644 altosuilib/AltosUIMapStore.java delete mode 100644 altosuilib/AltosUIMapStoreListener.java delete mode 100644 altosuilib/AltosUIMapTile.java delete mode 100644 altosuilib/AltosUIMapTileListener.java delete mode 100644 altosuilib/AltosUIMapTransform.java delete mode 100644 altosuilib/AltosUIMapView.java delete mode 100644 altosuilib/AltosUIMapZoomListener.java diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 42a17658..70543610 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -35,7 +35,7 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt JTabbedPane pane; AltosGraph graph; AltosUIEnable enable; - AltosUIMap map; + AltosUIMapNew map; AltosState state; AltosGraphDataSet graphDataSet; AltosFlightStats stats; @@ -47,7 +47,7 @@ public class AltosGraphUI extends AltosUIFrame implements AltosFontListener, Alt for (AltosState state : states) { if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { if (map == null) - map = new AltosUIMap(); + map = new AltosUIMapNew(); map.show(state, null); has_gps = true; } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 2c7ff5fc..4f6fdd48 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -35,7 +35,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl AltosFlightStatus flightStatus; AltosIgnitor ignitor; AltosIdleMonitor thread; - AltosUIMap sitemap; + AltosUIMapNew sitemap; int serial; boolean remote; boolean has_ignitor; @@ -278,7 +278,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl ignitor = new AltosIgnitor(); - sitemap = new AltosUIMap(); + sitemap = new AltosUIMapNew(); /* Make the tabbed pane use the rest of the window space */ bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH)); diff --git a/altosuilib/AltosUILatLon.java b/altosuilib/AltosUILatLon.java deleted file mode 100644 index c9fb8e92..00000000 --- a/altosuilib/AltosUILatLon.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUILatLon { - public double lat; - public double lon; - - public boolean equals(AltosUILatLon other) { - if (other == null) - return false; - return lat == other.lat && lon == other.lon; - } - - public AltosUILatLon(double lat, double lon) { - this.lat = lat; - this.lon = lon; - } -} diff --git a/altosuilib/AltosUIMap.java b/altosuilib/AltosUIMap.java deleted file mode 100644 index 5d6fae40..00000000 --- a/altosuilib/AltosUIMap.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMap extends JComponent implements AltosFlightDisplay, AltosUIMapZoomListener { - - static final int px_size = 512; - - static final int maptype_hybrid = 0; - static final int maptype_roadmap = 1; - static final int maptype_satellite = 2; - static final int maptype_terrain = 3; - static final int maptype_default = maptype_hybrid; - - static final String[] maptype_names = { - "hybrid", - "roadmap", - "satellite", - "terrain" - }; - - public static final String[] maptype_labels = { - "Hybrid", - "Roadmap", - "Satellite", - "Terrain" - }; - - public static final Color stateColors[] = { - Color.WHITE, // startup - Color.WHITE, // idle - Color.WHITE, // pad - Color.RED, // boost - Color.PINK, // fast - Color.YELLOW, // coast - Color.CYAN, // drogue - Color.BLUE, // main - Color.BLACK, // landed - Color.BLACK, // invalid - Color.CYAN, // stateless - }; - - public void reset() { - // nothing - } - - public void font_size_changed(int font_size) { - view.set_font(); - } - - public void units_changed(boolean imperial_units) { - view.set_units(); - } - - JLabel zoom_label; - - private void set_zoom_label() { - zoom_label.setText(String.format("Zoom %d", view.zoom() - view.default_zoom)); - } - - public void zoom_changed(int zoom) { - set_zoom_label(); - } - - public void set_zoom(int zoom) { - view.set_zoom(zoom); - } - - public int get_zoom() { - return view.zoom(); - } - - public void set_maptype(int type) { - view.set_maptype(type); - maptype_combo.setSelectedIndex(type); - } - - public void show(AltosState state, AltosListenerState listener_state) { - view.show(state, listener_state); - } - - public void centre(double lat, double lon) { - view.centre(lat, lon); - } - - public void centre(AltosState state) { - if (!state.gps.locked && state.gps.nsat < 4) - return; - centre(state.gps.lat, state.gps.lon); - } - - public void add_mark(double lat, double lon, int state) { - view.add_mark(lat, lon, state); - } - - public void clear_marks() { - view.clear_marks(); - } - - AltosUIMapView view; - - private GridBagLayout layout = new GridBagLayout(); - - JComboBox maptype_combo; - - public void set_load_params(double lat, double lon, int radius, AltosUIMapTileListener listener) { - view.set_load_params(lat, lon, radius, listener); - } - - public boolean all_fetched() { - return view.all_fetched(); - } - - public static void prefetch_maps(double lat, double lon) { - } - - public String getName() { - return "Map"; - } - - public AltosUIMap() { - - view = new AltosUIMapView(); - - view.setPreferredSize(new Dimension(500,500)); - view.setVisible(true); - view.setEnabled(true); - view.add_zoom_listener(this); - - GridBagLayout my_layout = new GridBagLayout(); - - setLayout(my_layout); - - GridBagConstraints c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.BOTH; - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 1; - c.gridheight = 10; - c.weightx = 1; - c.weighty = 1; - add(view, c); - - int y = 0; - - zoom_label = new JLabel("", JLabel.CENTER); - set_zoom_label(); - - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 1; - c.gridy = y++; - c.weightx = 0; - c.weighty = 0; - add(zoom_label, c); - - JButton zoom_reset = new JButton("0"); - zoom_reset.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - set_zoom(view.default_zoom); - } - }); - - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 1; - c.gridy = y++; - c.weightx = 0; - c.weighty = 0; - add(zoom_reset, c); - - JButton zoom_in = new JButton("+"); - zoom_in.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - set_zoom(get_zoom() + 1); - } - }); - - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 1; - c.gridy = y++; - c.weightx = 0; - c.weighty = 0; - add(zoom_in, c); - - JButton zoom_out = new JButton("-"); - zoom_out.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - set_zoom(get_zoom() - 1); - } - }); - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 1; - c.gridy = y++; - c.weightx = 0; - c.weighty = 0; - add(zoom_out, c); - - maptype_combo = new JComboBox(maptype_labels); - - maptype_combo.setEditable(false); - maptype_combo.setMaximumRowCount(maptype_combo.getItemCount()); - maptype_combo.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - view.set_maptype(maptype_combo.getSelectedIndex()); - } - }); - - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridx = 1; - c.gridy = y++; - c.weightx = 0; - c.weighty = 0; - add(maptype_combo, c); - } -} diff --git a/altosuilib/AltosUIMapCache.java b/altosuilib/AltosUIMapCache.java deleted file mode 100644 index d08b634d..00000000 --- a/altosuilib/AltosUIMapCache.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import javax.swing.*; -import javax.imageio.ImageIO; -import java.awt.image.*; -import java.awt.*; -import java.io.*; -import java.net.*; - -public class AltosUIMapCache implements AltosUIMapCacheListener { - static final int success = 0; - static final int loading = 1; - static final int failed = 2; - static final int bad_request = 3; - static final int forbidden = 4; - - int min_cache_size; /* configured minimum cache size */ - int cache_size; /* current cache size */ - int requested_cache_size; /* cache size computed by application */ - - private Object fetch_lock = new Object(); - private Object cache_lock = new Object(); - - AltosUIMapImage[] images = new AltosUIMapImage[cache_size]; - - long used; - - public void set_cache_size(int new_size) { - - requested_cache_size = new_size; - - if (new_size < min_cache_size) - new_size = min_cache_size; - - if (new_size == cache_size) - return; - - synchronized(cache_lock) { - AltosUIMapImage[] new_images = new AltosUIMapImage[new_size]; - - for (int i = 0; i < cache_size; i++) { - if (i < new_size) - new_images[i] = images[i]; - else if (images[i] != null) - images[i].flush(); - } - images = new_images; - cache_size = new_size; - } - } - - public Image get(AltosUIMapTile tile, AltosUIMapStore store, int width, int height) { - int oldest = -1; - long age = used; - - synchronized(cache_lock) { - AltosUIMapImage image = null; - for (int i = 0; i < cache_size; i++) { - image = images[i]; - - if (image == null) { - oldest = i; - break; - } - if (store.equals(image.store)) { - image.used = used++; - return image.image; - } - if (image.used < age) { - oldest = i; - age = image.used; - } - } - - try { - image = new AltosUIMapImage(tile, store); - image.used = used++; - if (images[oldest] != null) - images[oldest].flush(); - - images[oldest] = image; - - if (image.image == null) - tile.set_status(loading); - else - tile.set_status(success); - - return image.image; - } catch (IOException e) { - tile.set_status(failed); - return null; - } - } - } - - public void map_cache_changed(int map_cache) { - min_cache_size = map_cache; - - set_cache_size(requested_cache_size); - } - - public void dispose() { - AltosUIPreferences.unregister_map_cache_listener(this); - - for (int i = 0; i < cache_size; i++) { - AltosUIMapImage image = images[i]; - - if (image != null) - image.flush(); - } - } - - public AltosUIMapCache() { - min_cache_size = AltosUIPreferences.map_cache(); - - set_cache_size(0); - - AltosUIPreferences.register_map_cache_listener(this); - } -} diff --git a/altosuilib/AltosUIMapCacheListener.java b/altosuilib/AltosUIMapCacheListener.java deleted file mode 100644 index 9ae66f66..00000000 --- a/altosuilib/AltosUIMapCacheListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public interface AltosUIMapCacheListener { - public void map_cache_changed(int map_cache); -} diff --git a/altosuilib/AltosUIMapImage.java b/altosuilib/AltosUIMapImage.java deleted file mode 100644 index e0ac7b5a..00000000 --- a/altosuilib/AltosUIMapImage.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import javax.swing.*; -import javax.imageio.ImageIO; -import java.awt.image.*; -import java.awt.*; -import java.io.*; -import java.net.*; - -public class AltosUIMapImage implements AltosUIMapStoreListener { - static final long google_maps_ratelimit_ms = 1200; - // Google limits static map queries to 50 per minute per IP, so - // each query should take at least 1.2 seconds. - - static final int success = 0; - static final int loading = 1; - static final int failed = 2; - static final int bad_request = 3; - static final int forbidden = 4; - - static long forbidden_time; - static boolean forbidden_set = false; - static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; - - AltosUIMapTile tile; /* Notify when image has been loaded */ - Image image; - AltosUIMapStore store; - long used; - - class loader implements Runnable { - public void run() { - if (image != null) - tile.notify_image(image); - try { - image = ImageIO.read(store.file); - } catch (Exception ex) { - } - if (image == null) - tile.set_status(failed); - else - tile.set_status(success); - tile.notify_image(image); - } - } - - private void load() { - loader l = new loader(); - Thread lt = new Thread(l); - lt.start(); - } - - public void flush() { - if (image != null) { - image.flush(); - image = null; - } - } - - public boolean has_map() { - return store.status() == AltosUIMapStore.success; - } - - public synchronized void notify_store(AltosUIMapStore store, int status) { - switch (status) { - case AltosUIMapStore.loading: - break; - case AltosUIMapStore.success: - load(); - break; - default: - tile.set_status(status); - tile.notify_image(null); - } - } - - public AltosUIMapImage(AltosUIMapTile tile, AltosUIMapStore store) throws IOException { - this.tile = tile; - this.image = null; - this.store = store; - this.used = 0; - - int status = store.status(); - switch (status) { - case AltosUIMapStore.loading: - store.add_listener(this); - break; - case AltosUIMapStore.success: - load(); - break; - default: - tile.set_status(status); - tile.notify_image(null); - break; - } - } -} diff --git a/altosuilib/AltosUIMapLine.java b/altosuilib/AltosUIMapLine.java deleted file mode 100644 index 62ed4360..00000000 --- a/altosuilib/AltosUIMapLine.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMapLine { - AltosUILatLon start, end; - - private Font font = null; - static public int stroke_width = 6; - - public void set_font(Font font) { - this.font = font; - } - - private AltosUILatLon lat_lon(MouseEvent e, AltosUIMapTransform t) { - return t.screen_lat_lon(e.getPoint()); - } - - public void dragged(MouseEvent e, AltosUIMapTransform t) { - end = lat_lon(e, t); - } - - public void pressed(MouseEvent e, AltosUIMapTransform t) { - start = lat_lon(e, t); - end = null; - } - - private String line_dist() { - String format; - AltosGreatCircle g = new AltosGreatCircle(start.lat, start.lon, - end.lat, end.lon); - double distance = g.distance; - - if (AltosConvert.imperial_units) { - distance = AltosConvert.meters_to_feet(distance); - if (distance < 10000) { - format = "%4.0fft"; - } else { - distance /= 5280; - if (distance < 10) - format = "%5.3fmi"; - else if (distance < 100) - format = "%5.2fmi"; - else if (distance < 1000) - format = "%5.1fmi"; - else - format = "%5.0fmi"; - } - } else { - if (distance < 10000) { - format = "%4.0fm"; - } else { - distance /= 1000; - if (distance < 100) - format = "%5.2fkm"; - else if (distance < 1000) - format = "%5.1fkm"; - else - format = "%5.0fkm"; - } - } - return String.format(format, distance); - } - - public void paint(Graphics2D g, AltosUIMapTransform t) { - - if (start == null || end == null) - return; - - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - - Line2D.Double line = new Line2D.Double(t.screen(start), - t.screen(end)); - - g.setColor(Color.WHITE); - g.setStroke(new BasicStroke(stroke_width+4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - g.draw(line); - - g.setColor(Color.BLUE); - g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - g.draw(line); - - String message = line_dist(); - Rectangle2D bounds; - bounds = font.getStringBounds(message, g.getFontRenderContext()); - - float x = (float) line.x1; - float y = (float) line.y1 + (float) bounds.getHeight() / 2.0f; - - if (line.x1 < line.x2) { - x -= (float) bounds.getWidth() + 2.0f; - } else { - x += 2.0f; - } - - g.setFont(font); - g.setColor(Color.WHITE); - for (int dy = -2; dy <= 2; dy += 2) - for (int dx = -2; dx <= 2; dx += 2) - g.drawString(message, x + dx, y + dy); - g.setColor(Color.BLUE); - g.drawString(message, x, y); - } -} diff --git a/altosuilib/AltosUIMapMark.java b/altosuilib/AltosUIMapMark.java deleted file mode 100644 index 09990da8..00000000 --- a/altosuilib/AltosUIMapMark.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMapMark { - - AltosUILatLon lat_lon; - int state; - - static public int stroke_width = 6; - - public void paint(Graphics2D g, AltosUIMapTransform t) { - - Point2D.Double pt = t.screen(lat_lon); - - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - - if (0 <= state && state < AltosUIMap.stateColors.length) - g.setColor(AltosUIMap.stateColors[state]); - else - g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]); - - g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); - g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); - g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); - } - - public AltosUIMapMark (double lat, double lon, int state) { - lat_lon = new AltosUILatLon(lat, lon); - this.state = state; - } -} diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java index 4191a562..511d8fe6 100644 --- a/altosuilib/AltosUIMapNew.java +++ b/altosuilib/AltosUIMapNew.java @@ -283,16 +283,16 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt if (t.has_location()) { String message = null; switch (status) { - case AltosUIMapCache.loading: + case AltosMapTile.loading: message = "Loading..."; break; - case AltosUIMapCache.bad_request: + case AltosMapTile.bad_request: message = "Internal error"; break; - case AltosUIMapCache.failed: + case AltosMapTile.failed: message = "Network error, check connection"; break; - case AltosUIMapCache.forbidden: + case AltosMapTile.forbidden: message = "Too many requests, try later"; break; } @@ -419,6 +419,11 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt return "Map"; } + /* AltosGraphUI interface */ + public void centre(AltosState state) { + map.centre(state); + } + /* internal layout bits */ private GridBagLayout layout = new GridBagLayout(); diff --git a/altosuilib/AltosUIMapPath.java b/altosuilib/AltosUIMapPath.java deleted file mode 100644 index b75dccea..00000000 --- a/altosuilib/AltosUIMapPath.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -class PathPoint { - AltosUILatLon lat_lon; - int state; - - public PathPoint(AltosUILatLon lat_lon, int state) { - this.lat_lon = lat_lon; - this.state = state; - } - - public boolean equals(PathPoint other) { - if (other == null) - return false; - - return lat_lon.equals(other.lat_lon) && state == other.state; - } -} - -public class AltosUIMapPath { - - LinkedList points = new LinkedList(); - PathPoint last_point = null; - - static public int stroke_width = 6; - - public void paint(Graphics2D g, AltosUIMapTransform t) { - Point2D.Double prev = null; - - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - - for (PathPoint point : points) { - Point2D.Double cur = t.screen(point.lat_lon); - if (prev != null) { - Line2D.Double line = new Line2D.Double (prev, cur); - Rectangle bounds = line.getBounds(); - - if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) { - if (0 <= point.state && point.state < AltosUIMap.stateColors.length) - g.setColor(AltosUIMap.stateColors[point.state]); - else - g.setColor(AltosUIMap.stateColors[AltosLib.ao_flight_invalid]); - - g.draw(line); - } - } - prev = cur; - } - } - - public AltosUIMapRectangle add(double lat, double lon, int state) { - PathPoint point = new PathPoint(new AltosUILatLon (lat, lon), state); - AltosUIMapRectangle rect = null; - - if (!point.equals(last_point)) { - if (last_point != null) - rect = new AltosUIMapRectangle(last_point.lat_lon, point.lat_lon); - points.add (point); - last_point = point; - } - return rect; - } - - public void clear () { - points = new LinkedList(); - } -} diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java deleted file mode 100644 index 5b99ec03..00000000 --- a/altosuilib/AltosUIMapPreload.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.util.*; -import java.text.*; -import java.lang.Math; -import java.net.URL; -import java.net.URLConnection; -import org.altusmetrum.altoslib_7.*; - -class AltosUIMapPos extends Box { - AltosUIFrame owner; - JLabel label; - JComboBox hemi; - JTextField deg; - JLabel deg_label; - JTextField min; - JLabel min_label; - - public void set_value(double new_value) { - double d, m; - int h; - - h = 0; - if (new_value < 0) { - h = 1; - new_value = -new_value; - } - d = Math.floor(new_value); - deg.setText(String.format("%3.0f", d)); - m = (new_value - d) * 60.0; - min.setText(String.format("%7.4f", m)); - hemi.setSelectedIndex(h); - } - - public double get_value() throws ParseException { - int h = hemi.getSelectedIndex(); - String d_t = deg.getText(); - String m_t = min.getText(); - double d, m, v; - try { - d = AltosParse.parse_double_locale(d_t); - } catch (ParseException pe) { - JOptionPane.showMessageDialog(owner, - String.format("Invalid degrees \"%s\"", - d_t), - "Invalid number", - JOptionPane.ERROR_MESSAGE); - throw pe; - } - try { - if (m_t.equals("")) - m = 0; - else - m = AltosParse.parse_double_locale(m_t); - } catch (ParseException pe) { - JOptionPane.showMessageDialog(owner, - String.format("Invalid minutes \"%s\"", - m_t), - "Invalid number", - JOptionPane.ERROR_MESSAGE); - throw pe; - } - v = d + m/60.0; - if (h == 1) - v = -v; - return v; - } - - public AltosUIMapPos(AltosUIFrame in_owner, - String label_value, - String[] hemi_names, - double default_value) { - super(BoxLayout.X_AXIS); - owner = in_owner; - label = new JLabel(label_value); - hemi = new JComboBox(hemi_names); - hemi.setEditable(false); - deg = new JTextField(5); - deg.setMinimumSize(deg.getPreferredSize()); - deg.setHorizontalAlignment(JTextField.RIGHT); - deg_label = new JLabel("°"); - min = new JTextField(9); - min.setMinimumSize(min.getPreferredSize()); - min_label = new JLabel("'"); - set_value(default_value); - add(label); - add(Box.createRigidArea(new Dimension(5, 0))); - add(hemi); - add(Box.createRigidArea(new Dimension(5, 0))); - add(deg); - add(Box.createRigidArea(new Dimension(5, 0))); - add(deg_label); - add(Box.createRigidArea(new Dimension(5, 0))); - add(min); - add(Box.createRigidArea(new Dimension(5, 0))); - add(min_label); - } -} - -class AltosUISite { - String name; - double latitude; - double longitude; - - public String toString() { - return name; - } - - public AltosUISite(String in_name, double in_latitude, double in_longitude) { - name = in_name; - latitude = in_latitude; - longitude = in_longitude; - } - - public AltosUISite(String line) throws ParseException { - String[] elements = line.split(":"); - - if (elements.length < 3) - throw new ParseException(String.format("Invalid site line %s", line), 0); - - name = elements[0]; - - try { - latitude = AltosParse.parse_double_net(elements[1]); - longitude = AltosParse.parse_double_net(elements[2]); - } catch (ParseException pe) { - throw new ParseException(String.format("Invalid site line %s", line), 0); - } - } -} - -class AltosUISites extends Thread { - AltosUIMapPreload preload; - URL url; - LinkedList sites; - - void notify_complete() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - preload.set_sites(); - } - }); - } - - void add(AltosUISite site) { - sites.add(site); - } - - void add(String line) { - try { - add(new AltosUISite(line)); - } catch (ParseException pe) { - System.out.printf("parse exception %s\n", pe.toString()); - } - } - - public void run() { - try { - URLConnection uc = url.openConnection(); - //int length = uc.getContentLength(); - - InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); - BufferedReader in = new BufferedReader(in_stream); - - for (;;) { - String line = in.readLine(); - if (line == null) - break; - add(line); - } - } catch (IOException e) { - } finally { - notify_complete(); - } - } - - public AltosUISites(AltosUIMapPreload in_preload) { - sites = new LinkedList(); - preload = in_preload; - try { - url = new URL(AltosLib.launch_sites_url); - } catch (java.net.MalformedURLException e) { - notify_complete(); - } - start(); - } -} - -public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, ItemListener, AltosUIMapTileListener { - AltosUIFrame owner; - AltosUIMap map; - AltosUIMapCache cache = new AltosUIMapCache(); - - AltosUIMapPos lat; - AltosUIMapPos lon; - - JProgressBar pbar; - int pbar_max; - int pbar_cur; - - AltosUISites sites; - JLabel site_list_label; - JComboBox site_list; - - JToggleButton load_button; - boolean loading; - JButton close_button; - - JCheckBox[] maptypes = new JCheckBox[AltosUIMap.maptype_terrain - AltosUIMap.maptype_hybrid + 1]; - - JComboBox min_zoom; - JComboBox max_zoom; - JComboBox radius; - - Integer[] zooms = { -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 }; - Integer[] radii = { 1, 2, 3, 4, 5 }; - - static final String[] lat_hemi_names = { "N", "S" }; - static final String[] lon_hemi_names = { "E", "W" }; - - class updatePbar implements Runnable { - String s; - - public updatePbar(String in_s) { - s = in_s; - } - - public void run() { - int n = ++pbar_cur; - - pbar.setMaximum(pbar_max); - pbar.setValue(n); - pbar.setString(s); - } - } - - double latitude, longitude; - int min_z; - int max_z; - int cur_z; - int all_types; - int cur_type; - int r; - - int tiles_per_layer; - int tiles_loaded; - int layers_total; - int layers_loaded; - - - private void do_load() { - tiles_loaded = 0; - map.set_zoom(cur_z + AltosUIMapView.default_zoom); - map.set_maptype(cur_type); - map.set_load_params(latitude, longitude, r, this); - } - - private int next_type(int start) { - int next_type; - for (next_type = start; - next_type <= AltosUIMap.maptype_terrain && (all_types & (1 << next_type)) == 0; - next_type++) - ; - return next_type; - } - - private void next_load() { - int next_type = next_type(cur_type + 1); - - if (next_type > AltosUIMap.maptype_terrain) { - if (cur_z == max_z) { - return; - } else { - cur_z++; - } - next_type = next_type(0); - } - cur_type = next_type; - do_load(); - } - - private void start_load() { - cur_z = min_z; - int ntype = 0; - all_types = 0; - for (int t = AltosUIMap.maptype_hybrid; t <= AltosUIMap.maptype_terrain; t++) - if (maptypes[t].isSelected()) { - all_types |= (1 << t); - ntype++; - } - if (ntype == 0) { - all_types |= (1 << AltosUIMap.maptype_hybrid); - ntype = 1; - } - - cur_type = next_type(0); - tiles_per_layer = (r * 2 + 1) * (r * 2 + 1); - layers_total = (max_z - min_z + 1) * ntype; - layers_loaded = 0; - pbar_max = layers_total * tiles_per_layer; - pbar_cur = 0; - - map.clear_marks(); - map.add_mark(latitude,longitude, AltosLib.ao_flight_boost); - do_load(); - } - - /* AltosUIMapTileListener methods */ - - public synchronized void notify_tile(AltosUIMapTile tile, int status) { - if (status == AltosUIMapStore.loading) - return; - - SwingUtilities.invokeLater(new updatePbar(tile.store.file.toString())); - ++tiles_loaded; - if (tiles_loaded == tiles_per_layer) { - ++layers_loaded; - if (layers_loaded == layers_total) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - pbar.setValue(0); - pbar.setString(""); - load_button.setSelected(false); - loading = false; - } - }); - } else { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - next_load(); - } - }); - } - } - } - - public AltosUIMapCache cache() { return cache; } - - public void set_sites() { - int i = 1; - for (AltosUISite site : sites.sites) { - site_list.insertItemAt(site, i); - i++; - } - } - - public void itemStateChanged(ItemEvent e) { - int state = e.getStateChange(); - - if (state == ItemEvent.SELECTED) { - Object o = e.getItem(); - if (o instanceof AltosUISite) { - AltosUISite site = (AltosUISite) o; - lat.set_value(site.latitude); - lon.set_value(site.longitude); - } - } - } - - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - - if (cmd.equals("close")) - setVisible(false); - - if (cmd.equals("load")) { - if (!loading) { - try { - latitude = lat.get_value(); - longitude = lon.get_value(); - min_z = (Integer) min_zoom.getSelectedItem(); - max_z = (Integer) max_zoom.getSelectedItem(); - if (max_z < min_z) - max_z = min_z; - r = (Integer) radius.getSelectedItem(); - loading = true; - } catch (ParseException pe) { - load_button.setSelected(false); - } - start_load(); - } - } - } - - public AltosUIMapPreload(AltosUIFrame in_owner) { - owner = in_owner; - - Container pane = getContentPane(); - GridBagConstraints c = new GridBagConstraints(); - Insets i = new Insets(4,4,4,4); - - setTitle("AltOS Load Maps"); - - pane.setLayout(new GridBagLayout()); - - map = new AltosUIMap(); - - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 1; - - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 10; - c.anchor = GridBagConstraints.CENTER; - - pane.add(map, c); - - pbar = new JProgressBar(); - pbar.setMinimum(0); - pbar.setMaximum(1); - pbar.setValue(0); - pbar.setString(""); - pbar.setStringPainted(true); - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 1; - c.gridwidth = 10; - - pane.add(pbar, c); - - site_list_label = new JLabel ("Known Launch Sites:"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 2; - c.gridwidth = 1; - - pane.add(site_list_label, c); - - site_list = new JComboBox(new AltosUISite[] { new AltosUISite("Site List", 0, 0) }); - site_list.addItemListener(this); - - sites = new AltosUISites(this); - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 2; - c.gridwidth = 1; - - pane.add(site_list, c); - - lat = new AltosUIMapPos(owner, - "Latitude:", - lat_hemi_names, - 37.167833333); - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 0; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 3; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(lat, c); - - lon = new AltosUIMapPos(owner, - "Longitude:", - lon_hemi_names, - -97.73975); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 0; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 3; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(lon, c); - - load_button = new JToggleButton("Load Map"); - load_button.addActionListener(this); - load_button.setActionCommand("load"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 4; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(load_button, c); - - close_button = new JButton("Close"); - close_button.addActionListener(this); - close_button.setActionCommand("close"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 4; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(close_button, c); - - JLabel types_label = new JLabel("Map Types"); - c.gridx = 2; - c.gridwidth = 2; - c.gridy = 2; - pane.add(types_label, c); - - c.gridwidth = 1; - - for (int type = AltosUIMap.maptype_hybrid; type <= AltosUIMap.maptype_terrain; type++) { - maptypes[type] = new JCheckBox(AltosUIMap.maptype_labels[type], - type == AltosUIMap.maptype_hybrid); - c.gridx = 2 + (type >> 1); - c.fill = GridBagConstraints.HORIZONTAL; - c.gridy = (type & 1) + 3; - pane.add(maptypes[type], c); - } - - JLabel min_zoom_label = new JLabel("Minimum Zoom"); - c.gridx = 4; - c.gridy = 2; - pane.add(min_zoom_label, c); - - min_zoom = new JComboBox(zooms); - min_zoom.setSelectedItem(zooms[10]); - min_zoom.setEditable(false); - c.gridx = 5; - c.gridy = 2; - pane.add(min_zoom, c); - - JLabel max_zoom_label = new JLabel("Maximum Zoom"); - c.gridx = 4; - c.gridy = 3; - pane.add(max_zoom_label, c); - - max_zoom = new JComboBox(zooms); - max_zoom.setSelectedItem(zooms[14]); - max_zoom.setEditable(false); - c.gridx = 5; - c.gridy = 3; - pane.add(max_zoom, c); - - JLabel radius_label = new JLabel("Tile Radius"); - c.gridx = 4; - c.gridy = 4; - pane.add(radius_label, c); - - radius = new JComboBox(radii); - radius.setSelectedItem(radii[4]); - radius.setEditable(true); - c.gridx = 5; - c.gridy = 4; - pane.add(radius, c); - - pack(); - setLocationRelativeTo(owner); - setVisible(true); - } -} diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index 7d3c2a0b..af196105 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -227,7 +227,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener boolean loading; JButton close_button; - JCheckBox[] maptypes = new JCheckBox[AltosUIMap.maptype_terrain - AltosUIMap.maptype_hybrid + 1]; + JCheckBox[] maptypes = new JCheckBox[AltosMap.maptype_terrain - AltosMap.maptype_hybrid + 1]; JComboBox min_zoom; JComboBox max_zoom; @@ -271,7 +271,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener private void do_load() { tiles_loaded = 0; - map.set_zoom(cur_z + AltosUIMapView.default_zoom); + map.set_zoom(cur_z + AltosMap.default_zoom); map.set_maptype(cur_type); map.set_load_params(latitude, longitude, r, this); } @@ -279,7 +279,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener private int next_type(int start) { int next_type; for (next_type = start; - next_type <= AltosUIMap.maptype_terrain && (all_types & (1 << next_type)) == 0; + next_type <= AltosMap.maptype_terrain && (all_types & (1 << next_type)) == 0; next_type++) ; return next_type; @@ -288,7 +288,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener private void next_load() { int next_type = next_type(cur_type + 1); - if (next_type > AltosUIMap.maptype_terrain) { + if (next_type > AltosMap.maptype_terrain) { if (cur_z == max_z) { return; } else { @@ -304,13 +304,13 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener cur_z = min_z; int ntype = 0; all_types = 0; - for (int t = AltosUIMap.maptype_hybrid; t <= AltosUIMap.maptype_terrain; t++) + for (int t = AltosMap.maptype_hybrid; t <= AltosMap.maptype_terrain; t++) if (maptypes[t].isSelected()) { all_types |= (1 << t); ntype++; } if (ntype == 0) { - all_types |= (1 << AltosUIMap.maptype_hybrid); + all_types |= (1 << AltosMap.maptype_hybrid); ntype = 1; } @@ -557,9 +557,9 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener c.gridwidth = 1; - for (int type = AltosUIMap.maptype_hybrid; type <= AltosUIMap.maptype_terrain; type++) { - maptypes[type] = new JCheckBox(AltosUIMap.maptype_labels[type], - type == AltosUIMap.maptype_hybrid); + for (int type = AltosMap.maptype_hybrid; type <= AltosMap.maptype_terrain; type++) { + maptypes[type] = new JCheckBox(AltosMap.maptype_labels[type], + type == AltosMap.maptype_hybrid); c.gridx = 2 + (type >> 1); c.fill = GridBagConstraints.HORIZONTAL; c.gridy = (type & 1) + 3; diff --git a/altosuilib/AltosUIMapRectangle.java b/altosuilib/AltosUIMapRectangle.java deleted file mode 100644 index 008623cb..00000000 --- a/altosuilib/AltosUIMapRectangle.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public class AltosUIMapRectangle { - AltosUILatLon ul, lr; - - public AltosUIMapRectangle(AltosUILatLon a, AltosUILatLon b) { - double ul_lat, ul_lon; - double lr_lat, lr_lon; - - if (a.lat > b.lat) { - ul_lat = a.lat; - lr_lat = b.lat; - } else { - ul_lat = b.lat; - lr_lat = a.lat; - } - if (a.lon < b.lon) { - ul_lon = a.lon; - lr_lon = b.lon; - } else { - ul_lon = b.lon; - lr_lon = a.lon; - } - - ul = new AltosUILatLon(ul_lat, ul_lon); - lr = new AltosUILatLon(lr_lat, lr_lon); - } -} diff --git a/altosuilib/AltosUIMapStore.java b/altosuilib/AltosUIMapStore.java deleted file mode 100644 index ba505a7c..00000000 --- a/altosuilib/AltosUIMapStore.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.io.*; -import java.net.*; -import java.util.*; - -public class AltosUIMapStore { - String url; - File file; - LinkedList listeners = new LinkedList(); - - static final int success = 0; - static final int loading = 1; - static final int failed = 2; - static final int bad_request = 3; - static final int forbidden = 4; - - int status; - - public int status() { - return status; - } - - public synchronized void add_listener(AltosUIMapStoreListener listener) { - if (!listeners.contains(listener)) - listeners.add(listener); - } - - public synchronized void remove_listener(AltosUIMapStoreListener listener) { - listeners.remove(listener); - } - - private synchronized void notify_listeners(int status) { - this.status = status; - for (AltosUIMapStoreListener listener : listeners) - listener.notify_store(this, status); - } - - static Object forbidden_lock = new Object(); - static long forbidden_time; - static boolean forbidden_set; - - private int fetch_url() { - URL u; - - try { - u = new URL(url); - } catch (java.net.MalformedURLException e) { - return bad_request; - } - - byte[] data; - URLConnection uc = null; - try { - uc = u.openConnection(); - String type = uc.getContentType(); - int contentLength = uc.getContentLength(); - if (uc instanceof HttpURLConnection) { - int response = ((HttpURLConnection) uc).getResponseCode(); - switch (response) { - case HttpURLConnection.HTTP_FORBIDDEN: - case HttpURLConnection.HTTP_PAYMENT_REQUIRED: - case HttpURLConnection.HTTP_UNAUTHORIZED: - synchronized (forbidden_lock) { - forbidden_time = System.nanoTime(); - forbidden_set = true; - return forbidden; - } - } - } - InputStream in = new BufferedInputStream(uc.getInputStream()); - int bytesRead = 0; - int offset = 0; - data = new byte[contentLength]; - while (offset < contentLength) { - bytesRead = in.read(data, offset, data.length - offset); - if (bytesRead == -1) - break; - offset += bytesRead; - } - in.close(); - - if (offset != contentLength) - return failed; - - } catch (IOException e) { - return failed; - } - - try { - FileOutputStream out = new FileOutputStream(file); - out.write(data); - out.flush(); - out.close(); - } catch (FileNotFoundException e) { - return bad_request; - } catch (IOException e) { - if (file.exists()) - file.delete(); - return bad_request; - } - return success; - } - - static Object fetch_lock = new Object(); - - static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; - static final long google_maps_ratelimit_ms = 1200; - - class loader implements Runnable { - - public void run() { - if (file.exists()) { - notify_listeners(success); - return; - } - - synchronized(forbidden_lock) { - if (forbidden_set && (System.nanoTime() - forbidden_time) < forbidden_interval) { - notify_listeners(forbidden); - return; - } - } - - int new_status; - - if (!AltosUIVersion.has_google_maps_api_key()) { - synchronized (fetch_lock) { - long startTime = System.nanoTime(); - new_status = fetch_url(); - if (new_status == success) { - long duration_ms = (System.nanoTime() - startTime) / 1000000; - if (duration_ms < google_maps_ratelimit_ms) { - try { - Thread.sleep(google_maps_ratelimit_ms - duration_ms); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - } - } - } else { - new_status = fetch_url(); - } - notify_listeners(new_status); - } - } - - private void load() { - loader l = new loader(); - Thread lt = new Thread(l); - lt.start(); - } - - private AltosUIMapStore (String url, File file) { - this.url = url; - this.file = file; - - if (file.exists()) - status = success; - else { - status = loading; - load(); - } - } - - public boolean equals(AltosUIMapStore other) { - return url.equals(other.url); - } - - static HashMap stores = new HashMap(); - - public static AltosUIMapStore get(String url, File file) { - AltosUIMapStore store; - synchronized(stores) { - if (stores.containsKey(url)) { - store = stores.get(url); - } else { - store = new AltosUIMapStore(url, file); - stores.put(url, store); - } - } - return store; - } - -} diff --git a/altosuilib/AltosUIMapStoreListener.java b/altosuilib/AltosUIMapStoreListener.java deleted file mode 100644 index 5a522387..00000000 --- a/altosuilib/AltosUIMapStoreListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public interface AltosUIMapStoreListener { - abstract void notify_store(AltosUIMapStore store, int status); -} diff --git a/altosuilib/AltosUIMapTile.java b/altosuilib/AltosUIMapTile.java deleted file mode 100644 index 755dbde2..00000000 --- a/altosuilib/AltosUIMapTile.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.image.*; -import javax.swing.*; -import javax.imageio.*; -import java.awt.geom.*; -import java.io.*; -import java.util.*; -import java.awt.RenderingHints.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMapTile { - AltosUIMapTileListener listener; - AltosUILatLon upper_left, center; - int px_size; - int zoom; - int maptype; - AltosUIMapStore store; - AltosUIMapCache cache; - int status; - - private File map_file() { - double lat = center.lat; - double lon = center.lon; - char chlat = lat < 0 ? 'S' : 'N'; - char chlon = lon < 0 ? 'W' : 'E'; - - if (lat < 0) lat = -lat; - if (lon < 0) lon = -lon; - String maptype_string = String.format("%s-", AltosUIMap.maptype_names[maptype]); - String format_string; - if (maptype == AltosUIMap.maptype_hybrid || maptype == AltosUIMap.maptype_satellite || maptype == AltosUIMap.maptype_terrain) - format_string = "jpg"; - else - format_string = "png"; - return new File(AltosUIPreferences.mapdir(), - String.format("map-%c%.6f,%c%.6f-%s%d.%s", - chlat, lat, chlon, lon, maptype_string, zoom, format_string)); - } - - private String map_url() { - String format_string; - if (maptype == AltosUIMap.maptype_hybrid || maptype == AltosUIMap.maptype_satellite || maptype == AltosUIMap.maptype_terrain) - format_string = "jpg"; - else - format_string = "png32"; - - if (AltosUIVersion.has_google_maps_api_key()) - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s&key=%s", - center.lat, center.lon, zoom, px_size, px_size, AltosUIMap.maptype_names[maptype], format_string, AltosUIVersion.google_maps_api_key); - else - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", - center.lat, center.lon, zoom, px_size, px_size, AltosUIMap.maptype_names[maptype], format_string); - } - private Font font = null; - - public void set_font(Font font) { - this.font = font; - } - - int painting_serial; - int painted_serial; - - Image image; - - public void paint_graphics(Graphics2D g2d, AltosUIMapTransform t, int serial) { - if (serial < painted_serial) - return; - - Point2D.Double point_double = t.screen(upper_left); - Point point = new Point((int) (point_double.x + 0.5), - (int) (point_double.y + 0.5)); - - painted_serial = serial; - - if (!g2d.hitClip(point.x, point.y, px_size, px_size)) - return; - - if (image != null) { - g2d.drawImage(image, point.x, point.y, null); - image = null; - } else { - g2d.setColor(Color.GRAY); - g2d.fillRect(point.x, point.y, px_size, px_size); - - if (t.has_location()) { - String message = null; - switch (status) { - case AltosUIMapCache.loading: - message = "Loading..."; - break; - case AltosUIMapCache.bad_request: - message = "Internal error"; - break; - case AltosUIMapCache.failed: - message = "Network error, check connection"; - break; - case AltosUIMapCache.forbidden: - message = "Too many requests, try later"; - break; - } - if (message != null && font != null) { - g2d.setFont(font); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - Rectangle2D bounds = font.getStringBounds(message, g2d.getFontRenderContext()); - - float x = px_size / 2.0f; - float y = px_size / 2.0f; - x = x - (float) bounds.getWidth() / 2.0f; - y = y + (float) bounds.getHeight() / 2.0f; - g2d.setColor(Color.BLACK); - g2d.drawString(message, (float) point_double.x + x, (float) point_double.y + y); - } - } - } - } - - public void set_status(int status) { - this.status = status; - listener.notify_tile(this, status); - } - - public void notify_image(Image image) { - listener.notify_tile(this, status); - } - - public void paint(Graphics g, AltosUIMapTransform t) { - Graphics2D g2d = (Graphics2D) g; - boolean queued = false; - - Point2D.Double point = t.screen(upper_left); - - if (!g.hitClip((int) (point.x + 0.5), (int) (point.y + 0.5), px_size, px_size)) - return; - - ++painting_serial; - - if (image == null && t.has_location()) - image = cache.get(this, store, px_size, px_size); - - paint_graphics(g2d, t, painting_serial); - } - - public int store_status() { - return store.status(); - } - - public void add_store_listener(AltosUIMapStoreListener listener) { - store.add_listener(listener); - } - - public void remove_store_listener(AltosUIMapStoreListener listener) { - store.remove_listener(listener); - } - - public AltosUIMapTile(AltosUIMapTileListener listener, AltosUILatLon upper_left, AltosUILatLon center, int zoom, int maptype, int px_size, Font font) { - this.listener = listener; - this.upper_left = upper_left; - cache = listener.cache(); - - while (center.lon < -180.0) - center.lon += 360.0; - while (center.lon > 180.0) - center.lon -= 360.0; - - this.center = center; - this.zoom = zoom; - this.maptype = maptype; - this.px_size = px_size; - this.font = font; - status = AltosUIMapCache.loading; - store = AltosUIMapStore.get(map_url(), map_file()); - } -} diff --git a/altosuilib/AltosUIMapTileListener.java b/altosuilib/AltosUIMapTileListener.java deleted file mode 100644 index 01e5146b..00000000 --- a/altosuilib/AltosUIMapTileListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public interface AltosUIMapTileListener { - abstract public void notify_tile(AltosUIMapTile tile, int status); - - abstract public AltosUIMapCache cache(); -} diff --git a/altosuilib/AltosUIMapTransform.java b/altosuilib/AltosUIMapTransform.java deleted file mode 100644 index 3b85ca6a..00000000 --- a/altosuilib/AltosUIMapTransform.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMapTransform { - - double scale_x, scale_y; - - double offset_x, offset_y; - - public AltosUILatLon lat_lon (Point2D.Double point) { - double lat, lon; - double rads; - - lon = point.x/scale_x; - rads = 2 * Math.atan(Math.exp(-point.y/scale_y)); - lat = Math.toDegrees(rads - Math.PI/2); - - return new AltosUILatLon(lat,lon); - } - - public Point2D.Double screen_point(Point screen) { - return new Point2D.Double(screen.x + offset_x, screen.y + offset_y); - } - - public AltosUILatLon screen_lat_lon(Point screen) { - return lat_lon(screen_point(screen)); - } - - public Point2D.Double point(AltosUILatLon lat_lon) { - double x, y; - double e; - - x = lat_lon.lon * scale_x; - - e = Math.sin(Math.toRadians(lat_lon.lat)); - e = Math.max(e,-(1-1.0E-15)); - e = Math.min(e, 1-1.0E-15 ); - - y = 0.5*Math.log((1+e)/(1-e))*-scale_y; - - return new Point2D.Double(x, y); - } - - public Point2D.Double screen(Point2D.Double point) { - return new Point2D.Double(point.x - offset_x, point.y - offset_y); - } - - public Point screen(Point point) { - return new Point((int) (point.x - offset_x + 0.5), - (int) (point.y - offset_y + 0.5)); - } - - public Rectangle screen(AltosUIMapRectangle map_rect) { - Point2D.Double ul = screen(map_rect.ul); - Point2D.Double lr = screen(map_rect.lr); - - return new Rectangle((int) ul.x, (int) ul.y, (int) (lr.x - ul.x), (int) (lr.y - ul.y)); - } - - public Point2D.Double screen(AltosUILatLon lat_lon) { - return screen(point(lat_lon)); - } - - private boolean has_location; - - public boolean has_location() { - return has_location; - } - - public AltosUIMapTransform(int width, int height, int zoom, AltosUILatLon centre_lat_lon) { - scale_x = 256/360.0 * Math.pow(2, zoom); - scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); - - Point2D.Double centre_pt = point(centre_lat_lon); - - has_location = (centre_lat_lon.lat != 0 || centre_lat_lon.lon != 0); - offset_x = centre_pt.x - width / 2.0; - offset_y = centre_pt.y - height / 2.0; - } -} diff --git a/altosuilib/AltosUIMapView.java b/altosuilib/AltosUIMapView.java deleted file mode 100644 index 331b0aea..00000000 --- a/altosuilib/AltosUIMapView.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import javax.swing.*; -import java.io.*; -import java.lang.*; -import java.awt.geom.*; -import java.util.*; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_7.*; - -public class AltosUIMapView extends Component implements MouseMotionListener, MouseListener, MouseWheelListener, ComponentListener, AltosUIMapTileListener, AltosUIMapStoreListener { - - AltosUIMapPath path = new AltosUIMapPath(); - - AltosUIMapLine line = new AltosUIMapLine(); - - AltosUIMapCache cache = new AltosUIMapCache(); - - LinkedList marks = new LinkedList(); - - LinkedList zoom_listeners = new LinkedList(); - - boolean have_boost = false; - boolean have_landed = false; - - ConcurrentHashMap tiles = new ConcurrentHashMap(); - - static final int default_zoom = 15; - static final int min_zoom = 3; - static final int max_zoom = 21; - static final int px_size = 512; - - int load_radius; - AltosUILatLon load_centre = null; - AltosUIMapTileListener load_listener; - - int zoom = default_zoom; - int maptype = AltosUIMap.maptype_default; - - long user_input_time; - - /* Milliseconds to wait after user action before auto-scrolling - */ - static final long auto_scroll_delay = 20 * 1000; - - AltosUIMapTransform transform; - AltosUILatLon centre; - - public void set_font() { - line.set_font(AltosUILib.status_font); - for (AltosUIMapTile tile : tiles.values()) - tile.set_font(AltosUILib.value_font); - repaint(); - } - - public void set_units() { - repaint(); - } - - private boolean is_drag_event(MouseEvent e) { - return e.getModifiers() == InputEvent.BUTTON1_MASK; - } - - Point drag_start; - - private void drag(MouseEvent e) { - if (drag_start == null) - return; - - int dx = e.getPoint().x - drag_start.x; - int dy = e.getPoint().y - drag_start.y; - - AltosUILatLon new_centre = transform.screen_lat_lon(new Point(getWidth() / 2 - dx, getHeight() / 2 - dy)); - centre (new_centre.lat, new_centre.lon); - drag_start = e.getPoint(); - } - - private void drag_start(MouseEvent e) { - drag_start = e.getPoint(); - } - - private void notice_user_input() { - user_input_time = System.currentTimeMillis(); - } - - private boolean recent_user_input() { - return (System.currentTimeMillis() - user_input_time) < auto_scroll_delay; - } - - /* MouseMotionListener methods */ - - public void mouseDragged(MouseEvent e) { - notice_user_input(); - if (is_drag_event(e)) - drag(e); - else { - line.dragged(e, transform); - repaint(); - } - } - - public void mouseMoved(MouseEvent e) { - } - - /* MouseListener methods */ - public void mouseClicked(MouseEvent e) { - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - notice_user_input(); - if (is_drag_event(e)) - drag_start(e); - else { - line.pressed(e, transform); - repaint(); - } - } - - public void mouseReleased(MouseEvent e) { - } - - /* MouseWheelListener methods */ - - public void mouseWheelMoved(MouseWheelEvent e) { - int zoom_change = e.getWheelRotation(); - - notice_user_input(); - AltosUILatLon mouse_lat_lon = transform.screen_lat_lon(e.getPoint()); - set_zoom(zoom() - zoom_change); - - Point2D.Double new_mouse = transform.screen(mouse_lat_lon); - - int dx = getWidth()/2 - e.getPoint().x; - int dy = getHeight()/2 - e.getPoint().y; - - AltosUILatLon new_centre = transform.screen_lat_lon(new Point((int) new_mouse.x + dx, (int) new_mouse.y + dy)); - - centre(new_centre.lat, new_centre.lon); - } - - /* ComponentListener methods */ - - public void componentHidden(ComponentEvent e) { - } - - public void componentMoved(ComponentEvent e) { - } - - public void componentResized(ComponentEvent e) { - set_transform(); - } - - public void componentShown(ComponentEvent e) { - set_transform(); - } - - public void repaint(Rectangle r, int pad) { - repaint(r.x - pad, r.y - pad, r.width + pad*2, r.height + pad*2); - } - - public void repaint(AltosUIMapRectangle rect, int pad) { - repaint (transform.screen(rect), pad); - } - - private boolean far_from_centre(AltosUILatLon lat_lon) { - - if (centre == null || transform == null) - return true; - - Point2D.Double screen = transform.screen(lat_lon); - - int width = getWidth(); - int dx = Math.abs ((int) screen.x - width/2); - - if (dx > width / 4) - return true; - - int height = getHeight(); - int dy = Math.abs ((int) screen.y - height/2); - - if (dy > height / 4) - return true; - - return false; - } - - public void show(AltosState state, AltosListenerState listener_state) { - - /* If insufficient gps data, nothing to update - */ - AltosGPS gps = state.gps; - - if (gps == null) - return; - - if (!gps.locked && gps.nsat < 4) - return; - - AltosUIMapRectangle damage = path.add(gps.lat, gps.lon, state.state); - - switch (state.state) { - case AltosLib.ao_flight_boost: - if (!have_boost) { - add_mark(gps.lat, gps.lon, state.state); - have_boost = true; - } - break; - case AltosLib.ao_flight_landed: - if (!have_landed) { - add_mark(gps.lat, gps.lon, state.state); - have_landed = true; - } - break; - } - - if (damage != null) - repaint(damage, AltosUIMapPath.stroke_width); - maybe_centre(gps.lat, gps.lon); - } - - private void set_transform() { - Rectangle bounds = getBounds(); - - transform = new AltosUIMapTransform(bounds.width, bounds.height, zoom, centre); - repaint(); - } - - public boolean set_zoom(int zoom) { - if (min_zoom <= zoom && zoom <= max_zoom && zoom != this.zoom) { - this.zoom = zoom; - tiles.clear(); - set_transform(); - - for (AltosUIMapZoomListener listener : zoom_listeners) - listener.zoom_changed(this.zoom); - - return true; - } - return false; - } - - public void add_zoom_listener(AltosUIMapZoomListener listener) { - if (!zoom_listeners.contains(listener)) - zoom_listeners.add(listener); - } - - public void remove_zoom_listener(AltosUIMapZoomListener listener) { - zoom_listeners.remove(listener); - } - - public void set_load_params(double lat, double lon, int radius, AltosUIMapTileListener listener) { - load_centre = new AltosUILatLon(lat, lon); - load_radius = radius; - load_listener = listener; - centre(lat, lon); - make_tiles(); - for (AltosUIMapTile tile : tiles.values()) { - tile.add_store_listener(this); - if (tile.store_status() != AltosUIMapStore.loading) - listener.notify_tile(tile, tile.store_status()); - } - repaint(); - } - - public boolean all_fetched() { - for (AltosUIMapTile tile : tiles.values()) { - if (tile.store_status() == AltosUIMapStore.loading) - return false; - } - return true; - } - - public boolean set_maptype(int maptype) { - if (maptype != this.maptype) { - this.maptype = maptype; - tiles.clear(); - repaint(); - return true; - } - return false; - } - - public int get_maptype() { - return maptype; - } - - public int zoom() { - return zoom; - } - - public void centre(AltosUILatLon lat_lon) { - centre = lat_lon; - set_transform(); - } - - public void centre(double lat, double lon) { - centre(new AltosUILatLon(lat, lon)); - } - - public void maybe_centre(double lat, double lon) { - AltosUILatLon lat_lon = new AltosUILatLon(lat, lon); - if (centre == null || (!recent_user_input() && far_from_centre(lat_lon))) - centre(lat_lon); - } - - private VolatileImage create_back_buffer() { - return getGraphicsConfiguration().createCompatibleVolatileImage(getWidth(), getHeight()); - } - - private Point floor(Point2D.Double point) { - return new Point ((int) Math.floor(point.x / px_size) * px_size, - (int) Math.floor(point.y / px_size) * px_size); - } - - private Point ceil(Point2D.Double point) { - return new Point ((int) Math.ceil(point.x / px_size) * px_size, - (int) Math.ceil(point.y / px_size) * px_size); - } - - private void make_tiles() { - Point upper_left; - Point lower_right; - - if (load_centre != null) { - Point centre = floor(transform.point(load_centre)); - - upper_left = new Point(centre.x - load_radius * px_size, - centre.y - load_radius * px_size); - lower_right = new Point(centre.x + load_radius * px_size, - centre.y + load_radius * px_size); - } else { - upper_left = floor(transform.screen_point(new Point(0, 0))); - lower_right = floor(transform.screen_point(new Point(getWidth(), getHeight()))); - } - LinkedList to_remove = new LinkedList(); - - for (Point point : tiles.keySet()) { - if (point.x < upper_left.x || lower_right.x < point.x || - point.y < upper_left.y || lower_right.y < point.y) { - to_remove.add(point); - } - } - - for (Point point : to_remove) - tiles.remove(point); - - cache.set_cache_size((getWidth() / px_size + 2) * (getHeight() / px_size + 2)); - for (int y = upper_left.y; y <= lower_right.y; y += px_size) { - for (int x = upper_left.x; x <= lower_right.x; x += px_size) { - Point point = new Point(x, y); - - if (!tiles.containsKey(point)) { - AltosUILatLon ul = transform.lat_lon(new Point2D.Double(x, y)); - AltosUILatLon center = transform.lat_lon(new Point2D.Double(x + px_size/2, y + px_size/2)); - AltosUIMapTile tile = new AltosUIMapTile(this, ul, center, zoom, maptype, - px_size, AltosUILib.value_font); - tiles.put(point, tile); - } - } - } - } - - /* AltosUIMapTileListener methods */ - public synchronized void notify_tile(AltosUIMapTile tile, int status) { - for (Point point : tiles.keySet()) { - if (tile == tiles.get(point)) { - Point screen = transform.screen(point); - repaint(screen.x, screen.y, px_size, px_size); - } - } - } - - public AltosUIMapCache cache() { return cache; } - - /* AltosUIMapStoreListener methods */ - public synchronized void notify_store(AltosUIMapStore store, int status) { - if (load_listener != null) { - for (AltosUIMapTile tile : tiles.values()) - if (store.equals(tile.store)) - load_listener.notify_tile(tile, status); - } - } - - private void do_paint(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - make_tiles(); - - for (AltosUIMapTile tile : tiles.values()) - tile.paint(g2d, transform); - - synchronized(marks) { - for (AltosUIMapMark mark : marks) - mark.paint(g2d, transform); - } - - path.paint(g2d, transform); - - line.paint(g2d, transform); - } - - public void paint(Graphics g) { - } - - public void update(Graphics g) { - paint(g); - } - - public void add_mark(double lat, double lon, int state) { - synchronized(marks) { - marks.add(new AltosUIMapMark(lat, lon, state)); - } - repaint(); - } - - public void clear_marks() { - synchronized(marks) { - marks.clear(); - } - } - - public AltosUIMapView() { - centre(0, 0); - - addComponentListener(this); - addMouseMotionListener(this); - addMouseListener(this); - addMouseWheelListener(this); - set_font(); - } -} diff --git a/altosuilib/AltosUIMapZoomListener.java b/altosuilib/AltosUIMapZoomListener.java deleted file mode 100644 index 6d7f5fa7..00000000 --- a/altosuilib/AltosUIMapZoomListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2014 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public interface AltosUIMapZoomListener { - abstract public void zoom_changed(int zoom); -} diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 6394f537..e9378442 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -55,10 +55,6 @@ public class AltosUIPreferences extends AltosPreferences { public static int position = AltosUILib.position_top_left; - static LinkedList map_cache_listeners; - - public static int map_cache = 9; - public static void init() { AltosPreferences.init(new AltosUIPreferencesBackend()); @@ -75,9 +71,6 @@ public class AltosUIPreferences extends AltosPreferences { position = backend.getInt(positionPreference, AltosUILib.position_top_left); position_listeners = new LinkedList(); - - map_cache = backend.getInt(mapCachePreference, 9); - map_cache_listeners = new LinkedList(); } static { init(); } @@ -225,32 +218,4 @@ public class AltosUIPreferences extends AltosPreferences { return position; } } - - public static void register_map_cache_listener(AltosUIMapCacheListener l) { - synchronized(backend) { - map_cache_listeners.add(l); - } - } - - public static void unregister_map_cache_listener(AltosUIMapCacheListener l) { - synchronized (backend) { - map_cache_listeners.remove(l); - } - } - - public static void set_map_cache(int new_map_cache) { - synchronized(backend) { - map_cache = new_map_cache; - backend.putInt(mapCachePreference, map_cache); - flush_preferences(); - for (AltosUIMapCacheListener l: map_cache_listeners) - l.map_cache_changed(map_cache); - } - } - - public static int map_cache() { - synchronized(backend) { - return map_cache; - } - } } diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 7ec94ba0..71f1c2de 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -58,25 +58,8 @@ altosuilib_JAVA = \ AltosBTDeviceIterator.java \ AltosBTManage.java \ AltosBTKnown.java \ - AltosUIMap.java \ AltosUIMapNew.java \ AltosUIMapPreloadNew.java \ - AltosUIMapView.java \ - AltosUIMapLine.java \ - AltosUIMapMark.java \ - AltosUIMapPath.java \ - AltosUIMapTile.java \ - AltosUIMapCache.java \ - AltosUIMapCacheListener.java \ - AltosUIMapImage.java \ - AltosUIMapTransform.java \ - AltosUIMapRectangle.java \ - AltosUIMapZoomListener.java \ - AltosUIMapTileListener.java \ - AltosUIMapPreload.java \ - AltosUIMapStore.java \ - AltosUIMapStoreListener.java \ - AltosUILatLon.java \ AltosUIFlightTab.java \ AltosUIIndicator.java \ AltosUIUnitsIndicator.java \ diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 0e46a780..3b880b96 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -651,7 +651,6 @@ public class TeleGPS public static void help(int code) { System.out.printf("Usage: altosui [OPTION]... [FILE]...\n"); System.out.printf(" Options:\n"); - System.out.printf(" --fetchmaps \tpre-fetch maps for site map view\n"); System.out.printf(" --replay \t\trelive the glory of past flights \n"); System.out.printf(" --graph \t\tgraph a flight\n"); System.out.printf(" --csv\tgenerate comma separated output for spreadsheets, etc\n"); @@ -676,20 +675,7 @@ public class TeleGPS for (int i = 0; i < args.length; i++) { if (args[i].equals("--help")) help(0); - else if (args[i].equals("--fetchmaps")) { - if (args.length < i + 3) { - help(1); - } else { - try { - double lat = AltosParse.parse_double_locale(args[i+1]); - double lon = AltosParse.parse_double_locale(args[i+2]); - AltosUIMap.prefetch_maps(lat, lon); - } catch (ParseException e) { - System.out.printf("Can't parse number %s\n", e.toString()); - } - i += 2; - } - } else if (args[i].equals("--replay")) + else if (args[i].equals("--replay")) process = process_replay; else if (args[i].equals("--kml")) process = process_kml; diff --git a/telegps/TeleGPSGraphUI.java b/telegps/TeleGPSGraphUI.java index ab094ac9..f9ca9408 100644 --- a/telegps/TeleGPSGraphUI.java +++ b/telegps/TeleGPSGraphUI.java @@ -38,7 +38,7 @@ public class TeleGPSGraphUI extends AltosUIFrame JTabbedPane pane; AltosGraph graph; AltosUIEnable enable; - AltosUIMap map; + AltosUIMapNew map; AltosState state; AltosFlightStats stats; AltosGraphDataSet graphDataSet; @@ -69,7 +69,7 @@ public class TeleGPSGraphUI extends AltosUIFrame graph = new AltosGraph(enable, stats, graphDataSet); statsTable = new AltosFlightStatsTable(stats); - map = new AltosUIMap(); + map = new AltosUIMapNew(); pane.add("Graph", graph.panel); pane.add("Configure Graph", enable); -- cgit v1.2.3 From f822b84d8c25159ff113fef6a419b6e18e87a87a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 01:04:00 -0700 Subject: altosuilib: Get rid of AltosUIVersion.java It's been moved to altoslib/AltosVersion.java Signed-off-by: Keith Packard --- altoslib/AltosVersion.java.in | 2 +- altosuilib/.gitignore | 1 - altosuilib/AltosUIConfigure.java | 5 +++-- altosuilib/AltosUIVersion.java.in | 28 ---------------------------- altosuilib/Makefile.am | 1 - configure.ac | 1 - 6 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 altosuilib/AltosUIVersion.java.in diff --git a/altoslib/AltosVersion.java.in b/altoslib/AltosVersion.java.in index 546d4353..ebba5a00 100644 --- a/altoslib/AltosVersion.java.in +++ b/altoslib/AltosVersion.java.in @@ -22,7 +22,7 @@ public class AltosVersion { public final static String google_maps_api_key = @GOOGLEKEY@; - static boolean has_google_maps_api_key() { + public static boolean has_google_maps_api_key() { return google_maps_api_key != null && google_maps_api_key.length() > 1; } } diff --git a/altosuilib/.gitignore b/altosuilib/.gitignore index 4ad8a77a..943408ec 100644 --- a/altosuilib/.gitignore +++ b/altosuilib/.gitignore @@ -1,4 +1,3 @@ -AltosUIVersion.java bin classaltosuilib.stamp altosuilib*.jar diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 0bd8fb96..75957b33 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -22,6 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; +import org.altusmetrum.altoslib_7.*; class DelegatingRenderer implements ListCellRenderer { @@ -269,8 +270,8 @@ public class AltosUIConfigure row++; pane.add(new JLabel (String.format("AltOS version %s (%smaps key)", - AltosUIVersion.version, - AltosUIVersion.has_google_maps_api_key() ? "" : "no ")), + AltosVersion.version, + AltosVersion.has_google_maps_api_key() ? "" : "no ")), constraints(0, 3)); row++; diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in deleted file mode 100644 index f65b41cd..00000000 --- a/altosuilib/AltosUIVersion.java.in +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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. - */ - -package org.altusmetrum.altosuilib_7; - -public class AltosUIVersion { - public final static String version = "@VERSION@"; - - public final static String google_maps_api_key = @GOOGLEKEY@; - - static boolean has_google_maps_api_key() { - return google_maps_api_key != null && google_maps_api_key.length() > 1; - } -} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 71f1c2de..a00e4a12 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -29,7 +29,6 @@ altosuilib_JAVA = \ AltosUIPreferencesBackend.java \ AltosUIPreferences.java \ AltosUISeries.java \ - AltosUIVersion.java \ AltosUSBDevice.java \ AltosVoice.java \ AltosDisplayThread.java \ diff --git a/configure.ac b/configure.ac index 0564f4f8..d7a14aa8 100644 --- a/configure.ac +++ b/configure.ac @@ -517,7 +517,6 @@ altoslib/Makefile altoslib/AltosVersion.java icon/Makefile altosuilib/Makefile -altosuilib/AltosUIVersion.java altosui/Makefile altosui/Info.plist altosui/altos-windows.nsi -- cgit v1.2.3 From 7975d088a4ac44c0943134fa41d0e3b88f50b98f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 19:47:04 -0700 Subject: altosdroid: Add offline map tab It's not very fancy yet, but it does zoom and pan, and show the path of the rocket with a line. Signed-off-by: Keith Packard --- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 1 + .../org/altusmetrum/AltosDroid/AltosViewPager.java | 3 + .../org/altusmetrum/AltosDroid/TabMapOffline.java | 481 +++++++++++++++++++++ altoslib/AltosMap.java | 2 +- altoslib/AltosMapTile.java | 25 +- altoslib/AltosPointInt.java | 10 + 6 files changed, 514 insertions(+), 8 deletions(-) create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index eff24b10..dd87614b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -444,6 +444,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator(create_tab_view("Descent")), TabDescent.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator(create_tab_view("Landed")), TabLanded.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator(create_tab_view("Map")), TabMap.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("offmap").setIndicator(create_tab_view("OffMap")), TabMapOffline.class, null); // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java index 223ae75a..e8299b09 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java @@ -34,6 +34,9 @@ public class AltosViewPager extends ViewPager { @Override protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { + if (v.getClass().getName().endsWith("MapView")) + return true; + if(v.getClass() != null && v.getClass().getPackage() != null && v.getClass().getPackage().getName() != null && diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java new file mode 100644 index 00000000..42d80ad5 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java @@ -0,0 +1,481 @@ +/* + * Copyright © 2013 Mike Beattie + * + * 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. + */ + +package org.altusmetrum.AltosDroid; + +import java.util.Arrays; +import java.io.*; + +import org.altusmetrum.altoslib_7.*; + +import android.app.Activity; +import android.graphics.*; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.view.*; +import android.widget.*; +import android.location.Location; +import android.content.*; +import android.util.Log; + +public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { + // Debugging + static final String TAG = "AltosDroid"; + static final boolean D = true; + + AltosDroid mAltosDroid; + + AltosMap map; + + Canvas canvas; + Paint paint; + + private boolean pad_set; + + private TextView mDistanceView; + private TextView mBearingView; + private TextView mTargetLatitudeView; + private TextView mTargetLongitudeView; + private TextView mReceiverLatitudeView; + private TextView mReceiverLongitudeView; + + private double mapAccuracy = -1; + + int stroke_width = 20; + + class MapView extends View implements ScaleGestureDetector.OnScaleGestureListener { + + ScaleGestureDetector scale_detector; + boolean scaling; + + protected void onDraw(Canvas view_canvas) { + canvas = view_canvas; + paint = new Paint(Paint.ANTI_ALIAS_FLAG); + paint.setStrokeWidth(stroke_width); + paint.setStrokeCap(Paint.Cap.ROUND); + paint.setStrokeJoin(Paint.Join.ROUND); + map.paint(); + canvas = null; + } + + public boolean onScale(ScaleGestureDetector detector) { + float f = detector.getScaleFactor(); + if (D) Log.d(TAG, String.format("onScale %f\n", f)); + if (f <= 0.8) { + map.set_zoom(map.get_zoom() - 1); + return true; + } + if (f >= 1.2) { + map.set_zoom(map.get_zoom() + 1); + return true; + } + return false; + } + + public boolean onScaleBegin(ScaleGestureDetector detector) { + if (D) Log.d(TAG, String.format("onScaleBegin %f\n", detector.getScaleFactor())); + return true; + } + + public void onScaleEnd(ScaleGestureDetector detector) { + if (D) Log.d(TAG, String.format("onScaleEnd %f\n", detector.getScaleFactor())); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + scale_detector.onTouchEvent(event); + + if (scale_detector.isInProgress()) { + scaling = true; + } + + if (scaling) { + if(D) Log.d(TAG, "scale in progress\n"); + if (event.getAction() == MotionEvent.ACTION_UP) { + if (D) Log.d(TAG, "scale finished\n"); + scaling = false; + } + return true; + } + + if (event.getAction() == MotionEvent.ACTION_DOWN) { + if(D) Log.d(TAG, String.format("down event %g %g\n", event.getX(), event.getY())); + map.touch_start((int) event.getX(), (int) event.getY(), true); + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + if(D) Log.d(TAG, String.format("continue event %g %g\n", event.getX(), event.getY())); + map.touch_continue((int) event.getX(), (int) event.getY(), true); + } + return true; + } + + public MapView(Context context) { + super(context); + scale_detector = new ScaleGestureDetector(this.getContext(), this); + } + } + + class MapFragment extends Fragment { + MapView map_view; + + public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) { + map_view = new MapView(container.getContext()); + return map_view; + } + + public MapFragment() { + } + } + + MapFragment map_fragment; + + /* AltosMapInterface */ + + static final int WHITE = 0xffffffff; + static final int RED = 0xffff0000; + static final int PINK = 0xffff8080; + static final int YELLOW= 0xffffff00; + static final int CYAN = 0xff00ffff; + static final int BLUE = 0xff0000ff; + static final int BLACK = 0xff000000; + + public static final int stateColors[] = { + WHITE, // startup + WHITE, // idle + WHITE, // pad + RED, // boost + PINK, // fast + YELLOW, // coast + CYAN, // drogue + BLUE, // main + BLACK, // landed + BLACK, // invalid + CYAN, // stateless + }; + + class MapPath extends AltosMapPath { + + boolean line_in(AltosPointDouble a, AltosPointDouble b) { + final Rect bounds = canvas.getClipBounds(); + int left = (int) Math.floor (Math.min((float) a.x, (float) b.x) - stroke_width / 2.0f); + int right = (int) Math.ceil(Math.max((float) a.x, (float) b.x) + stroke_width / 2.0f); + int top = (int) Math.floor(Math.min((float) a.y, (float) b.y) - stroke_width / 2.0f); + int bottom = (int) Math.ceil(Math.max((float) a.y, (float) b.y) + stroke_width / 2.0f); + + return left < bounds.right && bounds.left < right && + top < bounds.bottom && bounds.top < bottom; + } + + public void paint(AltosMapTransform t) { + AltosPointDouble prev = null; + int cur_color = paint.getColor(); + + for (AltosMapPathPoint point : points) { + AltosPointDouble cur = t.screen(point.lat_lon); + + if (prev != null && line_in(prev, cur)) { + int color; + if (0 <= point.state && point.state < stateColors.length) + color = stateColors[point.state]; + else + color = stateColors[AltosLib.ao_flight_invalid]; + if (color != cur_color) { + paint.setColor(color); + cur_color = color; + } + canvas.drawLine((float) prev.x, (float) prev.y, (float) cur.x, (float) cur.y, paint); + } + prev = cur; + } + } + + public MapPath() { + stroke_width = TabMapOffline.this.stroke_width; + } + } + + public AltosMapPath new_path() { + return new MapPath(); + } + + class MapLine extends AltosMapLine { + public void paint(AltosMapTransform t) { + } + + public MapLine() { + } + } + + public AltosMapLine new_line() { + return new MapLine(); + } + + class MapImage implements AltosImage { + public Bitmap bitmap; + + public void flush() { + if (bitmap != null) { + bitmap.recycle(); + bitmap = null; + } + } + + public MapImage(File file) { + bitmap = BitmapFactory.decodeFile(file.getPath()); + } + } + + public AltosImage load_image(File file) throws Exception { + return new MapImage(file); + } + + class MapMark extends AltosMapMark { + public void paint(AltosMapTransform t) { + } + + MapMark(double lat, double lon, int state) { + super(lat, lon, state); + } + } + + public AltosMapMark new_mark(double lat, double lon, int state) { + return new MapMark(lat, lon, state); + } + + class MapTile extends AltosMapTile { + public void paint(AltosMapTransform t) { + AltosPointInt pt = new AltosPointInt(t.screen(upper_left)); + + if (canvas.quickReject(pt.x, pt.y, pt.x + px_size, pt.y + px_size, Canvas.EdgeType.AA)) + return; + + AltosImage altos_image = cache.get(this, store, px_size, px_size); + + MapImage map_image = (MapImage) altos_image; + + Bitmap bitmap = null; + + if (map_image != null) + bitmap = map_image.bitmap; + + if (bitmap != null) { + canvas.drawBitmap(bitmap, pt.x, pt.y, paint); + } else { + paint.setColor(0xff808080); + canvas.drawRect(pt.x, pt.y, pt.x + px_size, pt.y + px_size, paint); + if (t.has_location()) { + String message = null; + switch (status) { + case AltosMapTile.loading: + message = "Loading..."; + break; + case AltosMapTile.bad_request: + message = "Internal error"; + break; + case AltosMapTile.failed: + message = "Network error, check connection"; + break; + case AltosMapTile.forbidden: + message = "Too many requests, try later"; + break; + } + if (message != null) { + Rect bounds = new Rect(); + paint.getTextBounds(message, 0, message.length(), bounds); + + int width = bounds.right - bounds.left; + int height = bounds.bottom - bounds.top; + + float x = pt.x + px_size / 2.0f; + float y = pt.y + px_size / 2.0f; + x = x - width / 2.0f; + y = y + height / 2.0f; + paint.setColor(0xff000000); + canvas.drawText(message, 0, message.length(), x, y, paint); + } + } + } + + } + + public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + super(listener, upper_left, center, zoom, maptype, px_size, 2); + } + + } + + public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + return new MapTile(listener, upper_left, center, zoom, maptype, px_size); + } + + public int width() { + if (map_fragment != null && map_fragment.map_view != null) + return map_fragment.map_view.getWidth(); + return 500; + } + + public int height() { + if (map_fragment != null && map_fragment.map_view != null) + return map_fragment.map_view.getHeight(); + return 500; + } + + public void repaint() { + this.getActivity().runOnUiThread(new Runnable() { + public void run() { + if (map_fragment != null && map_fragment.map_view != null) + map_fragment.map_view.invalidate(); + } + }); + } + + public void repaint(AltosRectangle t_damage) { + final AltosRectangle damage = t_damage; + this.getActivity().runOnUiThread(new Runnable() { + public void run() { + if (map_fragment != null && map_fragment.map_view != null) + map_fragment.map_view.invalidate(damage.x, damage.y, damage.x + damage.width, damage.y + damage.height); + } + }); + } + + public void set_zoom_label(String label) { + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.tab_map, container, false); + + map_fragment = new MapFragment(); + map = new AltosMap(this); + mDistanceView = (TextView)v.findViewById(R.id.distance_value); + mBearingView = (TextView)v.findViewById(R.id.bearing_value); + mTargetLatitudeView = (TextView)v.findViewById(R.id.target_lat_value); + mTargetLongitudeView = (TextView)v.findViewById(R.id.target_lon_value); + mReceiverLatitudeView = (TextView)v.findViewById(R.id.receiver_lat_value); + mReceiverLongitudeView = (TextView)v.findViewById(R.id.receiver_lon_value); + return v; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getChildFragmentManager().beginTransaction().add(R.id.map, map_fragment).commit(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + map_fragment = null; + +// Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); +// FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); +// ft.remove(fragment); +// ft.commit(); + } + + private void setupMap() { +/* + mMap = mMapFragment.getMap(); + if (mMap != null) { + mMap.setMyLocationEnabled(true); + mMap.getUiSettings().setTiltGesturesEnabled(false); + mMap.getUiSettings().setZoomControlsEnabled(false); + + mRocketMarker = mMap.addMarker( + // From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/ + new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.rocket)) + .position(new LatLng(0,0)) + .visible(false) + ); + + mPadMarker = mMap.addMarker( + new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.pad)) + .position(new LatLng(0,0)) + .visible(false) + ); + + mPolyline = mMap.addPolyline( + new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0)) + .width(3) + .color(Color.BLUE) + .visible(false) + ); + + mapLoaded = true; + } +*/ + } + + private void center(double lat, double lon, double accuracy) { + if (mapAccuracy < 0 || accuracy < mapAccuracy/10) { + if (map != null) + map.centre(lat, lon); + mapAccuracy = accuracy; + } + } + + public String tab_name() { return "offmap"; } + + public void show(AltosState state, AltosGreatCircle from_receiver, Location receiver) { + if (from_receiver != null) { + mBearingView.setText(String.format("%3.0f°", from_receiver.bearing)); + set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance); + } + + if (state != null) { + map.show(state, null); + if (state.gps != null) { + mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); + mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W")); + if (state.gps.locked && state.gps.nsat >= 4) + center (state.gps.lat, state.gps.lon, 10); + } + } + + if (receiver != null) { + double accuracy; + + if (receiver.hasAccuracy()) + accuracy = receiver.getAccuracy(); + else + accuracy = 1000; + mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S")); + mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W")); + center (receiver.getLatitude(), receiver.getLongitude(), accuracy); + } + + } + + public TabMapOffline() { + } +} diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index b54c66cf..bdb60f0c 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -287,7 +287,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { AltosLatLon ul = transform.lat_lon(new AltosPointDouble(x, y)); AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); AltosMapTile tile = map_interface.new_tile(this, ul, center, zoom, maptype, - AltosMap.px_size); + px_size); tiles.put(point, tile); } } diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index 165f9e6f..ee9206ee 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -26,6 +26,7 @@ public abstract class AltosMapTile implements AltosFontListener { public int px_size; int zoom; int maptype; + int scale; public AltosMapStore store; public AltosMapCache cache; public int status; @@ -51,23 +52,28 @@ public abstract class AltosMapTile implements AltosFontListener { else format_string = "png"; return new File(AltosPreferences.mapdir(), - String.format("map-%c%.6f,%c%.6f-%s%d.%s", - chlat, lat, chlon, lon, maptype_string, zoom, format_string)); + String.format("map-%c%.6f,%c%.6f-%s%d%s.%s", + chlat, lat, chlon, lon, maptype_string, zoom, scale == 1 ? "" : String.format("-%d", scale), format_string)); } private String map_url() { String format_string; + int z = zoom; + if (maptype == AltosMap.maptype_hybrid || maptype == AltosMap.maptype_satellite || maptype == AltosMap.maptype_terrain) format_string = "jpg"; else format_string = "png32"; + for (int s = 1; s < scale; s <<= 1) + z--; + if (AltosVersion.has_google_maps_api_key()) - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s&key=%s", - center.lat, center.lon, zoom, px_size, px_size, AltosMap.maptype_names[maptype], format_string, AltosVersion.google_maps_api_key); + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&scale=%d&sensor=false&maptype=%s&format=%s&key=%s", + center.lat, center.lon, z, px_size/scale, px_size/scale, scale, AltosMap.maptype_names[maptype], format_string, AltosVersion.google_maps_api_key); else - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=%s&format=%s", - center.lat, center.lon, zoom, px_size, px_size, AltosMap.maptype_names[maptype], format_string); + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&scale=%d&sensor=false&maptype=%s&format=%s", + center.lat, center.lon, z, px_size/scale, px_size/scale, AltosMap.maptype_names[maptype], format_string); } public void font_size_changed(int font_size) { @@ -96,7 +102,7 @@ public abstract class AltosMapTile implements AltosFontListener { public abstract void paint(AltosMapTransform t); - public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { this.listener = listener; this.upper_left = upper_left; this.cache = listener.cache(); @@ -110,8 +116,13 @@ public abstract class AltosMapTile implements AltosFontListener { this.zoom = zoom; this.maptype = maptype; this.px_size = px_size; + this.scale = scale; status = AltosMapTile.loading; store = AltosMapStore.get(map_url(), map_file()); } + + public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + this(listener, upper_left, center, zoom, maptype, px_size, 1); + } } diff --git a/altoslib/AltosPointInt.java b/altoslib/AltosPointInt.java index e133ae9c..5d884391 100644 --- a/altoslib/AltosPointInt.java +++ b/altoslib/AltosPointInt.java @@ -28,4 +28,14 @@ public class AltosPointInt { this.x = x; this.y = y; } + + public AltosPointInt(double x, double y) { + this.x = (int) (x + 0.5); + this.y = (int) (y + 0.5); + } + + public AltosPointInt(AltosPointDouble pt_d) { + this.x = (int) (pt_d.x + 0.5); + this.y = (int) (pt_d.y + 0.5); + } } -- cgit v1.2.3 From bca342577740a9d04b8419ecadcff582e77f1e61 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 23:02:43 -0700 Subject: altosdroid: Move pause before reopening bluetooth into connec thread This avoids stalling the UI while waiting for TBT to boot. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 21 +++++++++++++++------ .../altusmetrum/AltosDroid/TelemetryService.java | 18 +++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index e68b1885..d506ff59 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -41,19 +41,19 @@ public class AltosBluetooth extends AltosDroidLink { private ConnectThread connect_thread = null; - private BluetoothAdapter adapter; + private BluetoothDevice device; private BluetoothSocket socket; private InputStream input; private OutputStream output; + private boolean pause; // Constructor - public AltosBluetooth(BluetoothDevice device, Handler handler) { + public AltosBluetooth(BluetoothDevice device, Handler handler, boolean pause) { super(handler); -// set_debug(D); - adapter = BluetoothAdapter.getDefaultAdapter(); + this.device = device; this.handler = handler; + this.pause = pause; - create_socket(device); connect_thread = new ConnectThread(); connect_thread.start(); } @@ -64,6 +64,7 @@ public class AltosBluetooth extends AltosDroidLink { return; } + AltosDebug.check_ui("connected\n"); try { synchronized(this) { if (socket != null) { @@ -141,9 +142,17 @@ public class AltosBluetooth extends AltosDroidLink { if (D) Log.d(TAG, "ConnectThread: BEGIN"); setName("ConnectThread"); + if (pause) { + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + } + } + + create_socket(device); // Always cancel discovery because it will slow down a connection try { - adapter.cancelDiscovery(); + BluetoothAdapter.getDefaultAdapter().cancelDiscovery(); } catch (Exception e) { if (D) Log.d(TAG, String.format("cancelDiscovery exception %s", e.toString())); } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 82c546c5..ed7b75a1 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -341,12 +341,6 @@ public class TelemetryService extends Service implements LocationListener { BluetoothDevice device = bluetooth_adapter.getRemoteDevice(address.address); disconnect(false); - if (pause) { - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - } - } this.address = address; if (D) Log.d(TAG, String.format("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); altos_link = new AltosBluetooth(device, handler); @@ -450,12 +444,14 @@ public class TelemetryService extends Service implements LocationListener { // Move us into the foreground. startForeground(NOTIFICATION, notification); - String action = intent.getAction(); + if (intent != null) { + String action = intent.getAction(); - if (action.equals(AltosDroid.ACTION_BLUETOOTH)) { - DeviceAddress address = AltosDroidPreferences.active_device(); - if (address != null && !address.address.startsWith("USB")) - start_altos_bluetooth(address, false); + if (action.equals(AltosDroid.ACTION_BLUETOOTH)) { + DeviceAddress address = AltosDroidPreferences.active_device(); + if (address != null && !address.address.startsWith("USB")) + start_altos_bluetooth(address, false); + } } // We want this service to continue running until it is explicitly -- cgit v1.2.3 From 2509b664df6a13e6ae9e6753dc9fa0d696a4f6c7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 23:05:11 -0700 Subject: altosdroid: Centralize debug printf code Create AltosDebug to hold the debug code, use it everywhere. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 36 +++++---- .../src/org/altusmetrum/AltosDroid/AltosDebug.java | 62 +++++++++++++++ .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 48 ++++++----- .../org/altusmetrum/AltosDroid/AltosDroidLink.java | 35 ++++---- .../org/altusmetrum/AltosDroid/AltosDroidTab.java | 1 - .../src/org/altusmetrum/AltosDroid/AltosUsb.java | 25 +++--- .../altusmetrum/AltosDroid/DeviceListActivity.java | 8 +- .../org/altusmetrum/AltosDroid/TabMapOffline.java | 18 ++--- .../org/altusmetrum/AltosDroid/TabsAdapter.java | 5 +- .../altusmetrum/AltosDroid/TelemetryLogger.java | 10 +-- .../altusmetrum/AltosDroid/TelemetryReader.java | 14 ++-- .../altusmetrum/AltosDroid/TelemetryService.java | 92 +++++++++++----------- 12 files changed, 192 insertions(+), 162 deletions(-) create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/AltosDebug.java diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index d506ff59..03ae5cb8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -29,16 +29,11 @@ import android.bluetooth.BluetoothSocket; //import android.os.Bundle; import android.os.Handler; //import android.os.Message; -import android.util.Log; import org.altusmetrum.altoslib_7.*; public class AltosBluetooth extends AltosDroidLink { - // Debugging - private static final String TAG = "AltosBluetooth"; - private static final boolean D = true; - private ConnectThread connect_thread = null; private BluetoothDevice device; @@ -60,7 +55,7 @@ public class AltosBluetooth extends AltosDroidLink { void connected() { if (closed()) { - if (D) Log.d(TAG, "connected after closed"); + AltosDebug.debug("connected after closed"); return; } @@ -82,7 +77,7 @@ public class AltosBluetooth extends AltosDroidLink { private void connect_failed() { if (closed()) { - if (D) Log.d(TAG, "connect_failed after closed"); + AltosDebug.debug("connect_failed after closed"); return; } @@ -90,7 +85,7 @@ public class AltosBluetooth extends AltosDroidLink { input = null; output = null; handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED, this).sendToTarget(); - if (D) Log.e(TAG, "ConnectThread: Failed to establish connection"); + AltosDebug.error("ConnectThread: Failed to establish connection"); } void close_device() { @@ -105,7 +100,7 @@ public class AltosBluetooth extends AltosDroidLink { try { tmp_socket.close(); } catch (IOException e) { - if (D) Log.e(TAG, "close_socket failed"); + AltosDebug.error("close_socket failed"); } } } @@ -122,13 +117,14 @@ public class AltosBluetooth extends AltosDroidLink { BluetoothSocket tmp_socket = null; + AltosDebug.check_ui("create_socket\n"); try { tmp_socket = device.createInsecureRfcommSocketToServiceRecord(SPP_UUID); } catch (IOException e) { e.printStackTrace(); } if (socket != null) { - if (D) Log.d(TAG, String.format("Socket already allocated %s", socket.toString())); + AltosDebug.debug("Socket already allocated %s", socket.toString()); close_device(); } synchronized (this) { @@ -139,7 +135,7 @@ public class AltosBluetooth extends AltosDroidLink { private class ConnectThread extends Thread { public void run() { - if (D) Log.d(TAG, "ConnectThread: BEGIN"); + AltosDebug.debug("ConnectThread: BEGIN (pause %b)", pause); setName("ConnectThread"); if (pause) { @@ -154,7 +150,7 @@ public class AltosBluetooth extends AltosDroidLink { try { BluetoothAdapter.getDefaultAdapter().cancelDiscovery(); } catch (Exception e) { - if (D) Log.d(TAG, String.format("cancelDiscovery exception %s", e.toString())); + AltosDebug.debug("cancelDiscovery exception %s", e.toString()); } BluetoothSocket local_socket = null; @@ -170,8 +166,13 @@ public class AltosBluetooth extends AltosDroidLink { // This is a blocking call and will only return on a // successful connection or an exception local_socket.connect(); - } catch (IOException e) { - if (D) Log.d(TAG, String.format("Connect exception %s", e.toString())); + } catch (Exception e) { + AltosDebug.debug("Connect exception %s", e.toString()); + try { + local_socket.close(); + } catch (Exception ce) { + AltosDebug.debug("Close exception %s", ce.toString()); + } local_socket = null; } } @@ -182,15 +183,16 @@ public class AltosBluetooth extends AltosDroidLink { connect_failed(); } - if (D) Log.d(TAG, "ConnectThread: completed"); + AltosDebug.debug("ConnectThread: completed"); } } private synchronized void wait_connected() throws InterruptedException, IOException { + AltosDebug.check_ui("wait_connected\n"); if (input == null && socket != null) { - if (D) Log.d(TAG, "wait_connected..."); + AltosDebug.debug("wait_connected..."); wait(); - if (D) Log.d(TAG, "wait_connected done"); + AltosDebug.debug("wait_connected done"); } if (socket == null) throw new IOException(); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDebug.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDebug.java new file mode 100644 index 00000000..80f1861b --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDebug.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ +package org.altusmetrum.AltosDroid; + +import java.util.Arrays; +import java.io.*; +import java.lang.*; + +import org.altusmetrum.altoslib_7.*; + +import android.app.Activity; +import android.graphics.*; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.view.*; +import android.widget.*; +import android.location.Location; +import android.content.*; +import android.util.Log; +import android.os.Looper; + +public class AltosDebug { + // Debugging + static final String TAG = "AltosDroid"; + public static final boolean D = true; + + static void info(String format, Object ... arguments) { + Log.i(TAG, String.format(format, arguments)); + } + + static void debug(String format, Object ... arguments) { + if (D) + Log.d(TAG, String.format(format, arguments)); + } + + static void error(String format, Object ... arguments) { + Log.e(TAG, String.format(format, arguments)); + } + + static void check_ui(String format, Object ... arguments) { + if (Looper.myLooper() == Looper.getMainLooper()) { + Log.e(TAG, String.format("ON UI THREAD " + format, arguments)); + for (StackTraceElement el : Thread.currentThread().getStackTrace()) + Log.e(TAG, "\t" + el.toString() + "\n"); + } + } +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index dd87614b..65618646 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -42,7 +42,6 @@ import android.content.res.Resources; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.util.DisplayMetrics; -import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -60,9 +59,6 @@ import android.hardware.usb.*; import org.altusmetrum.altoslib_7.*; public class AltosDroid extends FragmentActivity implements AltosUnitsListener { - // Debugging - static final String TAG = "AltosDroid"; - static final boolean D = true; // Actions sent to the telemetry server at startup time @@ -133,17 +129,17 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { switch (msg.what) { case MSG_STATE: - if(D) Log.d(TAG, "MSG_STATE"); + AltosDebug.debug("MSG_STATE"); TelemetryState telemetry_state = (TelemetryState) msg.obj; if (telemetry_state == null) { - Log.d(TAG, "telemetry_state null!"); + AltosDebug.debug("telemetry_state null!"); return; } ad.update_state(telemetry_state); break; case MSG_UPDATE_AGE: - if(D) Log.d(TAG, "MSG_UPDATE_AGE"); + AltosDebug.debug("MSG_UPDATE_AGE"); ad.update_age(); break; } @@ -421,7 +417,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if(D) Log.e(TAG, "+++ ON CREATE +++"); + AltosDebug.debug("+++ ON CREATE +++"); fm = getSupportFragmentManager(); @@ -526,13 +522,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); boolean granted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, true); - if (D) Log.e(TAG, "intent " + intent + " device " + device + " granted " + granted); + AltosDebug.debug("intent %s device %s granted %s", intent, device, granted); if (!granted) device = null; if (device != null) { - if (D) Log.d(TAG, "intent has usb device " + device.toString()); + AltosDebug.debug("intent has usb device " + device.toString()); connectUsb(device); } else { @@ -542,11 +538,11 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { * don't want to loop forever... */ if (granted) { - if (D) Log.d(TAG, "check for a USB device at startup"); + AltosDebug.debug("check for a USB device at startup"); if (check_usb()) return; } - if (D) Log.d(TAG, "Starting by looking for bluetooth devices"); + AltosDebug.debug("Starting by looking for bluetooth devices"); if (ensureBluetooth()) return; finish(); @@ -556,7 +552,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { @Override public void onStart() { super.onStart(); - if(D) Log.e(TAG, "++ ON START ++"); + AltosDebug.debug("++ ON START ++"); noticeIntent(getIntent()); @@ -575,26 +571,26 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); - if(D) Log.d(TAG, "onNewIntent"); + AltosDebug.debug("onNewIntent"); noticeIntent(intent); } @Override public void onResume() { super.onResume(); - if(D) Log.e(TAG, "+ ON RESUME +"); + AltosDebug.debug("+ ON RESUME +"); } @Override public void onPause() { super.onPause(); - if(D) Log.e(TAG, "- ON PAUSE -"); + AltosDebug.debug("- ON PAUSE -"); } @Override public void onStop() { super.onStop(); - if(D) Log.e(TAG, "-- ON STOP --"); + AltosDebug.debug("-- ON STOP --"); doUnbindService(); if (mAltosVoice != null) { @@ -606,14 +602,14 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { @Override public void onDestroy() { super.onDestroy(); - if(D) Log.e(TAG, "--- ON DESTROY ---"); + AltosDebug.debug("--- ON DESTROY ---"); if (mAltosVoice != null) mAltosVoice.stop(); stop_timer(); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if(D) Log.d(TAG, "onActivityResult " + resultCode); + AltosDebug.debug("onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE: // When DeviceListActivity returns with a device to connect to @@ -628,7 +624,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { //setupChat(); } else { // User did not enable Bluetooth or an error occured - Log.e(TAG, "BT not enabled"); + AltosDebug.error("BT not enabled"); stopService(new Intent(AltosDroid.this, TelemetryService.class)); Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show(); finish(); @@ -644,9 +640,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { // Attempt to connect to the device try { mService.send(Message.obtain(null, TelemetryService.MSG_OPEN_USB, device)); - if (D) Log.d(TAG, "Sent OPEN_USB message"); + AltosDebug.debug("Sent OPEN_USB message"); } catch (RemoteException e) { - if (D) Log.e(TAG, "connect device message failed"); + AltosDebug.debug("connect device message failed"); } } } @@ -657,12 +653,12 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { String address = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS); String name = data.getExtras().getString(DeviceListActivity.EXTRA_DEVICE_NAME); - if (D) Log.d(TAG, "Connecting to " + address + " " + name); + AltosDebug.debug("Connecting to " + address + " " + name); DeviceAddress a = new DeviceAddress(address, name); mService.send(Message.obtain(null, TelemetryService.MSG_CONNECT, a)); - if (D) Log.d(TAG, "Sent connecting message"); + AltosDebug.debug("Sent connecting message"); } catch (RemoteException e) { - if (D) Log.e(TAG, "connect device message failed"); + AltosDebug.debug("connect device message failed"); } } @@ -738,7 +734,7 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener { disconnectDevice(); return true; case R.id.quit: - Log.d(TAG, "R.id.quit"); + AltosDebug.debug("R.id.quit"); disconnectDevice(); finish(); return true; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java index 62090774..c7230512 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidLink.java @@ -23,16 +23,11 @@ import java.io.OutputStream; import java.util.UUID; import android.os.Handler; -import android.util.Log; import org.altusmetrum.altoslib_7.*; public abstract class AltosDroidLink extends AltosLink { - // Debugging - private static final String TAG = "AltosDroidLink"; - private static final boolean D = true; - Handler handler; Thread input_thread = null; @@ -70,7 +65,7 @@ public abstract class AltosDroidLink extends AltosLink { // Configure the newly connected device for telemetry print("~\nE 0\n"); set_monitor(false); - if (D) Log.d(TAG, "ConnectThread: connected"); + AltosDebug.debug("ConnectThread: connected"); /* Let TelemetryService know we're connected */ @@ -83,7 +78,7 @@ public abstract class AltosDroidLink extends AltosLink { public void closing() { synchronized(closed_lock) { - if (D) Log.d(TAG, "Marked closing true"); + AltosDebug.debug("Marked closing true"); closing = true; } } @@ -97,14 +92,14 @@ public abstract class AltosDroidLink extends AltosLink { abstract void close_device(); public void close() { - if (D) Log.d(TAG, "close(): begin"); + AltosDebug.debug("close(): begin"); closing(); flush_output(); synchronized (closed_lock) { - if (D) Log.d(TAG, "Marked closed true"); + AltosDebug.debug("Marked closed true"); closed = true; } @@ -113,11 +108,11 @@ public abstract class AltosDroidLink extends AltosLink { synchronized(this) { if (input_thread != null) { - if (D) Log.d(TAG, "close(): stopping input_thread"); + AltosDebug.debug("close(): stopping input_thread"); try { - if (D) Log.d(TAG, "close(): input_thread.interrupt()....."); + AltosDebug.debug("close(): input_thread.interrupt()....."); input_thread.interrupt(); - if (D) Log.d(TAG, "close(): input_thread.join()....."); + AltosDebug.debug("close(): input_thread.join()....."); input_thread.join(); } catch (Exception e) {} input_thread = null; @@ -143,7 +138,7 @@ public abstract class AltosDroidLink extends AltosLink { private void debug_input(byte b) { if (b == '\n') { - Log.d(TAG, " " + new String(debug_chars, 0, debug_off)); + AltosDebug.debug(" " + new String(debug_chars, 0, debug_off)); debug_off = 0; } else { if (debug_off < buffer_size) @@ -153,11 +148,11 @@ public abstract class AltosDroidLink extends AltosLink { private void disconnected() { if (closed()) { - if (D) Log.d(TAG, "disconnected after closed"); + AltosDebug.debug("disconnected after closed"); return; } - if (D) Log.d(TAG, "Sending disconnected message"); + AltosDebug.debug("Sending disconnected message"); handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); } @@ -169,13 +164,13 @@ public abstract class AltosDroidLink extends AltosLink { while (buffer_off == buffer_len) { buffer_len = read(in_buffer, buffer_size); if (buffer_len < 0) { - Log.d(TAG, "ERROR returned from getchar()"); + AltosDebug.debug("ERROR returned from getchar()"); disconnected(); return ERROR; } buffer_off = 0; } - if (D) + if (AltosDebug.D) debug_input(in_buffer[buffer_off]); return in_buffer[buffer_off++]; } @@ -192,7 +187,7 @@ public abstract class AltosDroidLink extends AltosLink { int sent = write(out_buffer, out_buffer_off); if (sent <= 0) { - Log.d(TAG, "flush_output() failed"); + AltosDebug.debug("flush_output() failed"); out_buffer_off = 0; break; } @@ -212,10 +207,10 @@ public abstract class AltosDroidLink extends AltosLink { public void print(String data) { byte[] bytes = data.getBytes(); - if (D) Log.d(TAG, "print(): begin"); + AltosDebug.debug("print(): begin"); for (byte b : bytes) putchar(b); - if (D) Log.d(TAG, "print(): Wrote bytes: '" + data.replace('\n', '\\') + "'"); + AltosDebug.debug("print(): Wrote bytes: '" + data.replace('\n', '\\') + "'"); } public AltosDroidLink(Handler handler) { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index f91ddf58..d33ad05b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -26,7 +26,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentManager; import android.location.Location; -import android.util.Log; import android.widget.TextView; public abstract class AltosDroidTab extends Fragment implements AltosUnitsListener { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java index 4685a824..e559f814 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosUsb.java @@ -27,16 +27,11 @@ import android.content.Context; import android.hardware.usb.*; import android.app.*; import android.os.Handler; -import android.util.Log; import org.altusmetrum.altoslib_7.*; public class AltosUsb extends AltosDroidLink { - // Debugging - private static final String TAG = "AltosUsb"; - private static final boolean D = true; - private Thread input_thread = null; private Handler handler; @@ -91,19 +86,19 @@ public class AltosUsb extends AltosDroidLink { } if (in != null && out != null) { - Log.d(TAG, String.format("\tin %s out %s\n", in.toString(), out.toString())); + AltosDebug.debug("\tin %s out %s\n", in.toString(), out.toString()); manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); if (manager == null) { - Log.d(TAG, "USB_SERVICE failed"); + AltosDebug.debug("USB_SERVICE failed"); return; } connection = manager.openDevice(device); if (connection == null) { - Log.d(TAG, "openDevice failed"); + AltosDebug.debug("openDevice failed"); return; } @@ -167,7 +162,7 @@ public class AltosUsb extends AltosDroidLink { // if (manager.hasPermission(device)) // return true; - Log.d(TAG, "request permission for USB device " + device.toString()); + AltosDebug.debug("request permission for USB device " + device.toString()); manager.requestPermission(device, pi); return false; @@ -183,7 +178,7 @@ public class AltosUsb extends AltosDroidLink { int product = device.getProductId(); if (matchProduct(match_product, device)) { - Log.d(TAG, "found USB device " + device.toString()); + AltosDebug.debug("found USB device " + device.toString()); return device; } } @@ -193,11 +188,11 @@ public class AltosUsb extends AltosDroidLink { private void disconnected() { if (closed()) { - if (D) Log.d(TAG, "disconnected after closed"); + AltosDebug.debug("disconnected after closed"); return; } - if (D) Log.d(TAG, "Sending disconnected message"); + AltosDebug.debug("Sending disconnected message"); handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, this).sendToTarget(); } @@ -210,20 +205,20 @@ public class AltosUsb extends AltosDroidLink { } if (tmp_connection != null) { - if (D) Log.d(TAG, "Closing USB device"); + AltosDebug.debug("Closing USB device"); tmp_connection.close(); } } int read(byte[] buffer, int len) { int ret = connection.bulkTransfer(in, buffer, len, -1); - if (D) Log.d(TAG, String.format("read(%d) = %d\n", len, ret)); + AltosDebug.debug("read(%d) = %d\n", len, ret); return ret; } int write(byte[] buffer, int len) { int ret = connection.bulkTransfer(out, buffer, len, -1); - if (D) Log.d(TAG, String.format("write(%d) = %d\n", len, ret)); + AltosDebug.debug("write(%d) = %d\n", len, ret); return ret; } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java index fd6abe0f..4af117a2 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/DeviceListActivity.java @@ -27,7 +27,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; -import android.util.Log; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; @@ -45,9 +44,6 @@ import android.widget.AdapterView.OnItemClickListener; * Activity in the result Intent. */ public class DeviceListActivity extends Activity { - // Debugging - private static final String TAG = "DeviceListActivity"; - private static final boolean D = true; // Return Intent extra public static final String EXTRA_DEVICE_ADDRESS = "device_address"; @@ -137,7 +133,7 @@ public class DeviceListActivity extends Activity { * Start device discover with the BluetoothAdapter */ private void doDiscovery() { - if (D) Log.d(TAG, "doDiscovery()"); + AltosDebug.debug("doDiscovery()"); // Indicate scanning in the title setProgressBarIndeterminateVisibility(true); @@ -173,7 +169,7 @@ public class DeviceListActivity extends Activity { else name = info; - if (D) Log.d(TAG, String.format("******* selected item '%s'", info)); + AltosDebug.debug("******* selected item '%s'", info); // Create the result Intent and include the MAC address Intent intent = new Intent(); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java index 42d80ad5..ceabe7b4 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java @@ -31,12 +31,8 @@ import android.view.*; import android.widget.*; import android.location.Location; import android.content.*; -import android.util.Log; public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { - // Debugging - static final String TAG = "AltosDroid"; - static final boolean D = true; AltosDroid mAltosDroid; @@ -75,7 +71,7 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { public boolean onScale(ScaleGestureDetector detector) { float f = detector.getScaleFactor(); - if (D) Log.d(TAG, String.format("onScale %f\n", f)); + AltosDebug.debug("onScale %f\n", f); if (f <= 0.8) { map.set_zoom(map.get_zoom() - 1); return true; @@ -88,12 +84,12 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { } public boolean onScaleBegin(ScaleGestureDetector detector) { - if (D) Log.d(TAG, String.format("onScaleBegin %f\n", detector.getScaleFactor())); + AltosDebug.debug("onScaleBegin %f\n", detector.getScaleFactor()); return true; } public void onScaleEnd(ScaleGestureDetector detector) { - if (D) Log.d(TAG, String.format("onScaleEnd %f\n", detector.getScaleFactor())); + AltosDebug.debug("onScaleEnd %f\n", detector.getScaleFactor()); } @Override @@ -105,19 +101,19 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { } if (scaling) { - if(D) Log.d(TAG, "scale in progress\n"); + if(AltosDebug.D) AltosDebug.debug("scale in progress\n"); if (event.getAction() == MotionEvent.ACTION_UP) { - if (D) Log.d(TAG, "scale finished\n"); + AltosDebug.debug("scale finished\n"); scaling = false; } return true; } if (event.getAction() == MotionEvent.ACTION_DOWN) { - if(D) Log.d(TAG, String.format("down event %g %g\n", event.getX(), event.getY())); + AltosDebug.debug("down event %g %g\n", event.getX(), event.getY()); map.touch_start((int) event.getX(), (int) event.getY(), true); } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if(D) Log.d(TAG, String.format("continue event %g %g\n", event.getX(), event.getY())); + AltosDebug.debug("continue event %g %g\n", event.getX(), event.getY()); map.touch_continue((int) event.getX(), (int) event.getY(), true); } return true; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java index 1ac34f9d..b34a25b6 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java @@ -29,7 +29,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TabHost; import android.widget.TabWidget; -import android.util.Log; /** * This is a helper class that implements the management of tabs and all @@ -106,7 +105,7 @@ public class TabsAdapter extends FragmentPagerAdapter @Override public Fragment getItem(int position) { TabInfo info = mTabs.get(position); - Log.d(AltosDroid.TAG, String.format("TabsAdapter.getItem(%d)", position)); + AltosDebug.debug("TabsAdapter.getItem(%d)", position); info.fragment = Fragment.instantiate(mContext, info.clss.getName(), info.args); return info.fragment; } @@ -131,7 +130,7 @@ public class TabsAdapter extends FragmentPagerAdapter if (cur_frag != null) { cur_frag.set_visible(true); } - Log.d(AltosDroid.TAG, String.format("TabsAdapter.onTabChanged(%s) = %d", tabId, position)); + AltosDebug.debug("TabsAdapter.onTabChanged(%s) = %d", tabId, position); mViewPager.setCurrentItem(position); } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java index 0cd9b2c1..7c3c2268 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -7,12 +7,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Environment; -import android.util.Log; public class TelemetryLogger { - private static final String TAG = "TelemetryLogger"; - private static final boolean D = true; - private Context context = null; private AltosLink link = null; private AltosLog logger = null; @@ -33,7 +29,7 @@ public class TelemetryLogger { private void close() { if (logger != null) { - if (D) Log.d(TAG, "Shutting down Telemetry Logging"); + AltosDebug.debug("Shutting down Telemetry Logging"); logger.close(); logger = null; } @@ -43,11 +39,11 @@ public class TelemetryLogger { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { if (logger == null) { - if (D) Log.d(TAG, "Starting up Telemetry Logging"); + AltosDebug.debug("Starting up Telemetry Logging"); logger = new AltosLog(link); } } else { - if (D) Log.d(TAG, "External Storage not present - stopping"); + AltosDebug.debug("External Storage not present - stopping"); close(); } } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index 3f31fa6b..7b29fe44 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -22,7 +22,6 @@ package org.altusmetrum.AltosDroid; import java.text.*; import java.io.*; import java.util.concurrent.*; -import android.util.Log; import android.os.Handler; import org.altusmetrum.altoslib_7.*; @@ -30,9 +29,6 @@ import org.altusmetrum.altoslib_7.*; public class TelemetryReader extends Thread { - private static final String TAG = "TelemetryReader"; - private static final boolean D = true; - int crc_errors; Handler handler; @@ -67,13 +63,13 @@ public class TelemetryReader extends Thread { AltosState state = null; try { - if (D) Log.d(TAG, "starting loop"); + AltosDebug.debug("starting loop"); while (telemQueue != null) { try { state = read(); handler.obtainMessage(TelemetryService.MSG_TELEMETRY, state).sendToTarget(); } catch (ParseException pp) { - Log.e(TAG, String.format("Parse error: %d \"%s\"", pp.getErrorOffset(), pp.getMessage())); + AltosDebug.error("Parse error: %d \"%s\"", pp.getErrorOffset(), pp.getMessage()); } catch (AltosCRCException ce) { ++crc_errors; handler.obtainMessage(TelemetryService.MSG_CRC_ERROR, new Integer(crc_errors)).sendToTarget(); @@ -81,7 +77,7 @@ public class TelemetryReader extends Thread { } } catch (InterruptedException ee) { } catch (IOException ie) { - Log.e(TAG, "IO exception in telemetry reader"); + AltosDebug.error("IO exception in telemetry reader"); handler.obtainMessage(TelemetryService.MSG_DISCONNECTED, link).sendToTarget(); } finally { close(); @@ -89,7 +85,7 @@ public class TelemetryReader extends Thread { } public TelemetryReader (AltosLink in_link, Handler in_handler, AltosState in_state) { - if (D) Log.d(TAG, "connected TelemetryReader create started"); + AltosDebug.debug("connected TelemetryReader create started"); link = in_link; handler = in_handler; @@ -98,6 +94,6 @@ public class TelemetryReader extends Thread { link.add_monitor(telemQueue); link.set_telemetry(AltosLib.ao_telemetry_standard); - if (D) Log.d(TAG, "connected TelemetryReader created"); + AltosDebug.debug("connected TelemetryReader created"); } } diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index ed7b75a1..627f5957 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -39,7 +39,6 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.os.Looper; -import android.util.Log; import android.widget.Toast; import android.location.Location; import android.location.LocationManager; @@ -51,9 +50,6 @@ import org.altusmetrum.altoslib_7.*; public class TelemetryService extends Service implements LocationListener { - private static final String TAG = "TelemetryService"; - private static final boolean D = true; - static final int MSG_REGISTER_CLIENT = 1; static final int MSG_UNREGISTER_CLIENT = 2; static final int MSG_CONNECT = 3; @@ -109,23 +105,23 @@ public class TelemetryService extends Service implements LocationListener { s.remove_client(msg.replyTo); break; case MSG_CONNECT: - if (D) Log.d(TAG, "Connect command received"); + AltosDebug.debug("Connect command received"); DeviceAddress address = (DeviceAddress) msg.obj; AltosDroidPreferences.set_active_device(address); s.start_altos_bluetooth(address, false); break; case MSG_OPEN_USB: - if (D) Log.d(TAG, "Open USB command received"); + AltosDebug.debug("Open USB command received"); UsbDevice device = (UsbDevice) msg.obj; s.start_usb(device); break; case MSG_DISCONNECT: - if (D) Log.d(TAG, "Disconnect command received"); + AltosDebug.debug("Disconnect command received"); s.address = null; s.disconnect(true); break; case MSG_SETFREQUENCY: - if (D) Log.d(TAG, "MSG_SETFREQUENCY"); + AltosDebug.debug("MSG_SETFREQUENCY"); s.telemetry_state.frequency = (Double) msg.obj; if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { try { @@ -138,7 +134,7 @@ public class TelemetryService extends Service implements LocationListener { s.send_to_clients(); break; case MSG_SETBAUD: - if (D) Log.d(TAG, "MSG_SETBAUD"); + AltosDebug.debug("MSG_SETBAUD"); s.telemetry_state.telemetry_rate = (Integer) msg.obj; if (s.telemetry_state.connect == TelemetryState.CONNECT_CONNECTED) { s.altos_link.set_telemetry_rate(s.telemetry_state.telemetry_rate); @@ -151,29 +147,29 @@ public class TelemetryService extends Service implements LocationListener { *Messages from AltosBluetooth */ case MSG_CONNECTED: - Log.d(TAG, "MSG_CONNECTED"); + AltosDebug.debug("MSG_CONNECTED"); bt = (AltosDroidLink) msg.obj; if (bt != s.altos_link) { - if (D) Log.d(TAG, "Stale message"); + AltosDebug.debug("Stale message"); break; } - if (D) Log.d(TAG, "Connected to device"); + AltosDebug.debug("Connected to device"); try { s.connected(); } catch (InterruptedException ie) { } break; case MSG_CONNECT_FAILED: - Log.d(TAG, "MSG_CONNECT_FAILED"); + AltosDebug.debug("MSG_CONNECT_FAILED"); bt = (AltosDroidLink) msg.obj; if (bt != s.altos_link) { - if (D) Log.d(TAG, "Stale message"); + AltosDebug.debug("Stale message"); break; } if (s.address != null) { - if (D) Log.d(TAG, "Connection failed... retrying"); + AltosDebug.debug("Connection failed... retrying"); s.start_altos_bluetooth(s.address, true); } else { s.disconnect(true); @@ -182,15 +178,15 @@ public class TelemetryService extends Service implements LocationListener { case MSG_DISCONNECTED: /* This can be sent by either AltosDroidLink or TelemetryReader */ - Log.d(TAG, "MSG_DISCONNECTED"); + AltosDebug.debug("MSG_DISCONNECTED"); bt = (AltosDroidLink) msg.obj; if (bt != s.altos_link) { - if (D) Log.d(TAG, "Stale message"); + AltosDebug.debug("Stale message"); break; } if (s.address != null) { - if (D) Log.d(TAG, "Connection lost... retrying"); + AltosDebug.debug("Connection lost... retrying"); s.start_altos_bluetooth(s.address, true); } else { s.disconnect(true); @@ -203,16 +199,16 @@ public class TelemetryService extends Service implements LocationListener { case MSG_TELEMETRY: s.telemetry_state.state = (AltosState) msg.obj; if (s.telemetry_state.state != null) { - if (D) Log.d(TAG, "Save state"); + AltosDebug.debug("Save state"); AltosPreferences.set_state(0, s.telemetry_state.state, null); } - if (D) Log.d(TAG, "MSG_TELEMETRY"); + AltosDebug.debug("MSG_TELEMETRY"); s.send_to_clients(); break; case MSG_CRC_ERROR: // forward crc error messages s.telemetry_state.crc_errors = (Integer) msg.obj; - if (D) Log.d(TAG, "MSG_CRC_ERROR"); + AltosDebug.debug("MSG_CRC_ERROR"); s.send_to_clients(); break; default: @@ -225,9 +221,9 @@ public class TelemetryService extends Service implements LocationListener { */ private Message message() { if (telemetry_state == null) - Log.d(TAG, "telemetry_state null!"); + AltosDebug.debug("telemetry_state null!"); if (telemetry_state.state == null) - Log.d(TAG, "telemetry_state.state null!"); + AltosDebug.debug("telemetry_state.state null!"); return Message.obtain(null, AltosDroid.MSG_STATE, telemetry_state); } @@ -236,7 +232,7 @@ public class TelemetryService extends Service implements LocationListener { private void add_client(Messenger client) { clients.add(client); - if (D) Log.d(TAG, "Client bound to service"); + AltosDebug.debug("Client bound to service"); /* On connect, send the current state to the new client */ @@ -246,7 +242,7 @@ public class TelemetryService extends Service implements LocationListener { * go ahead and try to reconnect to the device */ if (address != null && telemetry_state.connect == TelemetryState.CONNECT_DISCONNECTED) { - if (D) Log.d(TAG, "Reconnecting now..."); + AltosDebug.debug("Reconnecting now..."); start_altos_bluetooth(address, false); } } @@ -255,37 +251,37 @@ public class TelemetryService extends Service implements LocationListener { */ private void remove_client(Messenger client) { clients.remove(client); - if (D) Log.d(TAG, "Client unbound from service"); + AltosDebug.debug("Client unbound from service"); /* When the list of clients is empty, stop the service if * we have no current telemetry source */ if (clients.isEmpty() && telemetry_state.connect == TelemetryState.CONNECT_DISCONNECTED) { - if (!D) Log.d(TAG, "No clients, no connection. Stopping\n"); + AltosDebug.debug("No clients, no connection. Stopping\n"); stopSelf(); } } private void send_to_client(Messenger client, Message m) { try { - if (D) Log.d(TAG, String.format("Send message to client %s", client.toString())); + AltosDebug.debug("Send message to client %s", client.toString()); client.send(m); } catch (RemoteException e) { - if (D) Log.e(TAG, String.format("Client %s disappeared", client.toString())); + AltosDebug.error("Client %s disappeared", client.toString()); remove_client(client); } } private void send_to_clients() { Message m = message(); - if (D) Log.d(TAG, String.format("Send message to %d clients", clients.size())); + AltosDebug.debug("Send message to %d clients", clients.size()); for (Messenger client : clients) send_to_client(client, m); } private void disconnect(boolean notify) { - if (D) Log.d(TAG, "disconnect(): begin"); + AltosDebug.debug("disconnect(): begin"); telemetry_state.connect = TelemetryState.CONNECT_DISCONNECTED; telemetry_state.address = null; @@ -294,7 +290,7 @@ public class TelemetryService extends Service implements LocationListener { altos_link.closing(); if (telemetry_reader != null) { - if (D) Log.d(TAG, "disconnect(): stopping TelemetryReader"); + AltosDebug.debug("disconnect(): stopping TelemetryReader"); telemetry_reader.interrupt(); try { telemetry_reader.join(); @@ -303,21 +299,21 @@ public class TelemetryService extends Service implements LocationListener { telemetry_reader = null; } if (telemetry_logger != null) { - if (D) Log.d(TAG, "disconnect(): stopping TelemetryLogger"); + AltosDebug.debug("disconnect(): stopping TelemetryLogger"); telemetry_logger.stop(); telemetry_logger = null; } if (altos_link != null) { - if (D) Log.d(TAG, "disconnect(): stopping AltosDroidLink"); + AltosDebug.debug("disconnect(): stopping AltosDroidLink"); altos_link.close(); altos_link = null; } telemetry_state.config = null; if (notify) { - if (D) Log.d(TAG, "disconnect(): send message to clients"); + AltosDebug.debug("disconnect(): send message to clients"); send_to_clients(); if (clients.isEmpty()) { - if (D) Log.d(TAG, "disconnect(): no clients, terminating"); + AltosDebug.debug("disconnect(): no clients, terminating"); stopSelf(); } } @@ -338,19 +334,21 @@ public class TelemetryService extends Service implements LocationListener { private void start_altos_bluetooth(DeviceAddress address, boolean pause) { // Get the BLuetoothDevice object + AltosDebug.check_ui("start_altos_bluetooth\n"); BluetoothDevice device = bluetooth_adapter.getRemoteDevice(address.address); disconnect(false); this.address = address; - if (D) Log.d(TAG, String.format("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress())); - altos_link = new AltosBluetooth(device, handler); + AltosDebug.debug("start_altos_bluetooth(): Connecting to %s (%s)", device.getName(), device.getAddress()); + altos_link = new AltosBluetooth(device, handler, pause); telemetry_state.connect = TelemetryState.CONNECT_CONNECTING; telemetry_state.address = address; send_to_clients(); } private void connected() throws InterruptedException { - if (D) Log.d(TAG, "connected top"); + AltosDebug.debug("connected top"); + AltosDebug.check_ui("connected\n"); try { if (altos_link == null) throw new InterruptedException("no bluetooth"); @@ -360,9 +358,9 @@ public class TelemetryService extends Service implements LocationListener { } catch (TimeoutException e) { // If this timed out, then we really want to retry it, but // probably safer to just retry the connection from scratch. - if (D) Log.d(TAG, "connected timeout"); + AltosDebug.debug("connected timeout"); if (address != null) { - if (D) Log.d(TAG, "connected timeout, retrying"); + AltosDebug.debug("connected timeout, retrying"); start_altos_bluetooth(address, true); } else { handler.obtainMessage(MSG_CONNECT_FAILED).sendToTarget(); @@ -371,18 +369,18 @@ public class TelemetryService extends Service implements LocationListener { return; } - if (D) Log.d(TAG, "connected bluetooth configured"); + AltosDebug.debug("connected bluetooth configured"); telemetry_state.connect = TelemetryState.CONNECT_CONNECTED; telemetry_state.address = address; telemetry_reader = new TelemetryReader(altos_link, handler, telemetry_state.state); telemetry_reader.start(); - if (D) Log.d(TAG, "connected TelemetryReader started"); + AltosDebug.debug("connected TelemetryReader started"); telemetry_logger = new TelemetryLogger(this, altos_link); - if (D) Log.d(TAG, "Notify UI of connection"); + AltosDebug.debug("Notify UI of connection"); send_to_clients(); } @@ -412,7 +410,7 @@ public class TelemetryService extends Service implements LocationListener { AltosSavedState saved_state = AltosPreferences.state(0); if (saved_state != null) { - if (D) Log.d(TAG, String.format("recovered old state flight %d\n", saved_state.state.flight)); + AltosDebug.debug("recovered old state flight %d\n", saved_state.state.flight); telemetry_state.state = saved_state.state; } @@ -424,7 +422,7 @@ public class TelemetryService extends Service implements LocationListener { @Override public int onStartCommand(Intent intent, int flags, int startId) { - Log.i("TelemetryService", "Received start id " + startId + ": " + intent); + AltosDebug.debug("Received start id %d: %s", startId, intent); CharSequence text = getText(R.string.telemetry_service_started); @@ -483,7 +481,7 @@ public class TelemetryService extends Service implements LocationListener { public void onLocationChanged(Location location) { telemetry_state.location = location; - if (D) Log.d(TAG, "location changed"); + AltosDebug.debug("location changed"); send_to_clients(); } -- cgit v1.2.3 From 103a50db50be55c2293468d273dd94472dd89d94 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 26 May 2015 23:05:49 -0700 Subject: altosdroid: Place icons on screen instead of drawing path This makes drawing a bunch faster, and locating stuff on the screen easier. Signed-off-by: Keith Packard --- .../org/altusmetrum/AltosDroid/TabMapOffline.java | 89 +++++++++++++--------- altoslib/AltosMap.java | 36 ++++++--- 2 files changed, 77 insertions(+), 48 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java index ceabe7b4..6742e606 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java @@ -38,9 +38,18 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { AltosMap map; + AltosLatLon here; + Canvas canvas; Paint paint; + Bitmap pad_bitmap; + int pad_off_x, pad_off_y; + Bitmap rocket_bitmap; + int rocket_off_x, rocket_off_y; + Bitmap here_bitmap; + int here_off_x, here_off_y; + private boolean pad_set; private TextView mDistanceView; @@ -54,11 +63,31 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { int stroke_width = 20; + private void draw_bitmap(AltosLatLon lat_lon, Bitmap bitmap, int off_x, int off_y) { + if (lat_lon != null) { + AltosPointInt pt = new AltosPointInt(map.transform.screen(lat_lon)); + + canvas.drawBitmap(bitmap, pt.x - off_x, pt.y - off_y, paint); + } + } + class MapView extends View implements ScaleGestureDetector.OnScaleGestureListener { ScaleGestureDetector scale_detector; boolean scaling; + private void draw_positions() { + if (map.last_position != null && here != null) { + AltosPointDouble rocket_screen = map.transform.screen(map.last_position); + AltosPointDouble here_screen = map.transform.screen(here); + paint.setColor(0xff8080ff); + canvas.drawLine((float) rocket_screen.x, (float) rocket_screen.y, + (float) here_screen.x, (float) here_screen.y, paint); + } + draw_bitmap(map.last_position, rocket_bitmap, rocket_off_x, rocket_off_y); + draw_bitmap(here, here_bitmap, here_off_x, here_off_y); + } + protected void onDraw(Canvas view_canvas) { canvas = view_canvas; paint = new Paint(Paint.ANTI_ALIAS_FLAG); @@ -66,6 +95,7 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { paint.setStrokeCap(Paint.Cap.ROUND); paint.setStrokeJoin(Paint.Join.ROUND); map.paint(); + draw_positions(); canvas = null; } @@ -205,7 +235,7 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { } public AltosMapPath new_path() { - return new MapPath(); + return null; } class MapLine extends AltosMapLine { @@ -217,7 +247,7 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { } public AltosMapLine new_line() { - return new MapLine(); + return null; } class MapImage implements AltosImage { @@ -241,6 +271,8 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { class MapMark extends AltosMapMark { public void paint(AltosMapTransform t) { + if (state == AltosLib.ao_flight_boost) + draw_bitmap(lat_lon, pad_bitmap, pad_off_x, pad_off_y); } MapMark(double lat, double lon, int state) { @@ -357,6 +389,20 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { super.onAttach(activity); mAltosDroid = (AltosDroid) activity; mAltosDroid.registerTab(this); + pad_bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pad); + /* arrow at the bottom of the launchpad image */ + pad_off_x = pad_bitmap.getWidth() / 2; + pad_off_y = pad_bitmap.getHeight(); + + rocket_bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rocket); + /* arrow at the bottom of the rocket image */ + rocket_off_x = rocket_bitmap.getWidth() / 2; + rocket_off_y = rocket_bitmap.getHeight(); + + here_bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_maps_indicator_current_position); + /* Center of the dot */ + here_off_x = here_bitmap.getWidth() / 2; + here_off_y = here_bitmap.getHeight() / 2; } @Override @@ -400,42 +446,12 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { } private void setupMap() { -/* - mMap = mMapFragment.getMap(); - if (mMap != null) { - mMap.setMyLocationEnabled(true); - mMap.getUiSettings().setTiltGesturesEnabled(false); - mMap.getUiSettings().setZoomControlsEnabled(false); - - mRocketMarker = mMap.addMarker( - // From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/ - new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.rocket)) - .position(new LatLng(0,0)) - .visible(false) - ); - - mPadMarker = mMap.addMarker( - new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.pad)) - .position(new LatLng(0,0)) - .visible(false) - ); - - mPolyline = mMap.addPolyline( - new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0)) - .width(3) - .color(Color.BLUE) - .visible(false) - ); - - mapLoaded = true; - } -*/ } private void center(double lat, double lon, double accuracy) { if (mapAccuracy < 0 || accuracy < mapAccuracy/10) { if (map != null) - map.centre(lat, lon); + map.maybe_centre(lat, lon); mapAccuracy = accuracy; } } @@ -461,13 +477,14 @@ public class TabMapOffline extends AltosDroidTab implements AltosMapInterface { if (receiver != null) { double accuracy; + here = new AltosLatLon(receiver.getLatitude(), receiver.getLongitude()); if (receiver.hasAccuracy()) accuracy = receiver.getAccuracy(); else accuracy = 1000; - mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S")); - mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W")); - center (receiver.getLatitude(), receiver.getLongitude(), accuracy); + mReceiverLatitudeView.setText(AltosDroid.pos(here.lat, "N", "S")); + mReceiverLongitudeView.setText(AltosDroid.pos(here.lon, "E", "W")); + center (here.lat, here.lon, accuracy); } } diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index bdb60f0c..762054a3 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -58,8 +58,9 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { LinkedList marks = new LinkedList(); - AltosMapPath path; - AltosMapLine line; + AltosMapPath path; + AltosMapLine line; + public AltosLatLon last_position; boolean have_boost = false; boolean have_landed = false; @@ -195,8 +196,6 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { if (!gps.locked && gps.nsat < 4) return; - AltosMapRectangle damage = path.add(gps.lat, gps.lon, state.state); - switch (state.state) { case AltosLib.ao_flight_boost: if (!have_boost) { @@ -212,8 +211,15 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { break; } - if (damage != null) - repaint(damage, AltosMapPath.stroke_width); + if (path != null) { + AltosMapRectangle damage = path.add(gps.lat, gps.lon, state.state); + + if (damage != null) + repaint(damage, AltosMapPath.stroke_width); + } + + last_position = new AltosLatLon(gps.lat, gps.lon); + maybe_centre(gps.lat, gps.lon); } @@ -323,9 +329,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { mark.paint(transform); } - path.paint(transform); + if (path != null) + path.paint(transform); - line.paint(transform); + if (line != null) + line.paint(transform); } /* AltosMapTileListener methods */ @@ -368,13 +376,17 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } private void line_start(int x, int y) { - line.pressed(new AltosPointInt(x, y), transform); - repaint(); + if (line != null) { + line.pressed(new AltosPointInt(x, y), transform); + repaint(); + } } private void line(int x, int y) { - line.dragged(new AltosPointInt(x, y), transform); - repaint(); + if (line != null) { + line.dragged(new AltosPointInt(x, y), transform); + repaint(); + } } public void touch_start(int x, int y, boolean is_drag) { -- cgit v1.2.3 From 519d477cb752d9cdba78a4daa32b1f547bf889b4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 15:30:29 -0700 Subject: altoslib: Add AltosLaunchSite bits This asynchronously fetches the list of available launch sites from the standard location and notifies the caller when finished. Signed-off-by: Keith Packard --- altoslib/AltosLaunchSite.java | 57 +++++++++++++++++++++++++++ altoslib/AltosLaunchSiteListener.java | 26 +++++++++++++ altoslib/AltosLaunchSites.java | 73 +++++++++++++++++++++++++++++++++++ altoslib/Makefile.am | 3 ++ 4 files changed, 159 insertions(+) create mode 100644 altoslib/AltosLaunchSite.java create mode 100644 altoslib/AltosLaunchSiteListener.java create mode 100644 altoslib/AltosLaunchSites.java diff --git a/altoslib/AltosLaunchSite.java b/altoslib/AltosLaunchSite.java new file mode 100644 index 00000000..70a4bb58 --- /dev/null +++ b/altoslib/AltosLaunchSite.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_7; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.text.*; +import java.util.concurrent.*; + +public class AltosLaunchSite { + public String name; + public double latitude; + public double longitude; + + public String toString() { + return name; + } + + public AltosLaunchSite(String in_name, double in_latitude, double in_longitude) { + name = in_name; + latitude = in_latitude; + longitude = in_longitude; + } + + public AltosLaunchSite(String line) throws ParseException { + String[] elements = line.split(":"); + + if (elements.length < 3) + throw new ParseException(String.format("Invalid site line %s", line), 0); + + name = elements[0]; + + try { + latitude = AltosParse.parse_double_net(elements[1]); + longitude = AltosParse.parse_double_net(elements[2]); + } catch (ParseException pe) { + throw new ParseException(String.format("Invalid site line %s", line), 0); + } + } +} + diff --git a/altoslib/AltosLaunchSiteListener.java b/altoslib/AltosLaunchSiteListener.java new file mode 100644 index 00000000..21015909 --- /dev/null +++ b/altoslib/AltosLaunchSiteListener.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ +package org.altusmetrum.altoslib_7; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.util.concurrent.*; + +public interface AltosLaunchSiteListener { + public abstract void notify_launch_sites(List sites); +} diff --git a/altoslib/AltosLaunchSites.java b/altoslib/AltosLaunchSites.java new file mode 100644 index 00000000..0922bcea --- /dev/null +++ b/altoslib/AltosLaunchSites.java @@ -0,0 +1,73 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_7; + +import java.io.*; +import java.lang.*; +import java.util.*; +import java.util.concurrent.*; +import java.net.*; +import java.text.*; + +public class AltosLaunchSites extends Thread { + URL url; + LinkedList sites; + AltosLaunchSiteListener listener; + + void notify_complete() { + listener.notify_launch_sites(sites); + } + + void add(AltosLaunchSite site) { + sites.add(site); + } + + void add(String line) { + try { + add(new AltosLaunchSite(line)); + } catch (ParseException pe) { + System.out.printf("parse exception %s\n", pe.toString()); + } + } + + public void run() { + try { + url = new URL(AltosLib.launch_sites_url); + URLConnection uc = url.openConnection(); + + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); + BufferedReader in = new BufferedReader(in_stream); + + for (;;) { + String line = in.readLine(); + if (line == null) + break; + add(line); + } + } catch (Exception e) { + } finally { + notify_complete(); + } + } + + public AltosLaunchSites(AltosLaunchSiteListener listener) { + sites = new LinkedList(); + this.listener = listener; + start(); + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 481c974f..de13c1ec 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -151,6 +151,9 @@ altoslib_JAVA = \ AltosRectangle.java \ AltosFlightDisplay.java \ AltosFontListener.java \ + AltosLaunchSite.java \ + AltosLaunchSiteListener.java \ + AltosLaunchSites.java \ AltosVersion.java JAR=altoslib_$(ALTOSLIB_VERSION).jar -- cgit v1.2.3 From ccba2bb2f193ffd6c3a3d934a46bc06466b4b258 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 15:31:25 -0700 Subject: altosuilib: Use altoslib site list loader Removes the custom version and uses the shared code Signed-off-by: Keith Packard --- altosuilib/AltosUIMapPreloadNew.java | 122 ++++++----------------------------- 1 file changed, 18 insertions(+), 104 deletions(-) diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index af196105..a7d12737 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -118,96 +118,7 @@ class AltosUIMapPos extends Box { } } -class AltosUISite { - String name; - double latitude; - double longitude; - - public String toString() { - return name; - } - - public AltosUISite(String in_name, double in_latitude, double in_longitude) { - name = in_name; - latitude = in_latitude; - longitude = in_longitude; - } - - public AltosUISite(String line) throws ParseException { - String[] elements = line.split(":"); - - if (elements.length < 3) - throw new ParseException(String.format("Invalid site line %s", line), 0); - - name = elements[0]; - - try { - latitude = AltosParse.parse_double_net(elements[1]); - longitude = AltosParse.parse_double_net(elements[2]); - } catch (ParseException pe) { - throw new ParseException(String.format("Invalid site line %s", line), 0); - } - } -} - -class AltosUISites extends Thread { - AltosUIMapPreloadNew preload; - URL url; - LinkedList sites; - - void notify_complete() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - preload.set_sites(); - } - }); - } - - void add(AltosUISite site) { - sites.add(site); - } - - void add(String line) { - try { - add(new AltosUISite(line)); - } catch (ParseException pe) { - System.out.printf("parse exception %s\n", pe.toString()); - } - } - - public void run() { - try { - URLConnection uc = url.openConnection(); - //int length = uc.getContentLength(); - - InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); - BufferedReader in = new BufferedReader(in_stream); - - for (;;) { - String line = in.readLine(); - if (line == null) - break; - add(line); - } - } catch (IOException e) { - } finally { - notify_complete(); - } - } - - public AltosUISites(AltosUIMapPreloadNew in_preload) { - sites = new LinkedList(); - preload = in_preload; - try { - url = new URL(AltosLib.launch_sites_url); - } catch (java.net.MalformedURLException e) { - notify_complete(); - } - start(); - } -} - -public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener { +public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener, AltosLaunchSiteListener { AltosUIFrame owner; AltosUIMapNew map; AltosMapCache cache; @@ -219,9 +130,8 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener int pbar_max; int pbar_cur; - AltosUISites sites; JLabel site_list_label; - JComboBox site_list; + JComboBox site_list; JToggleButton load_button; boolean loading; @@ -357,21 +267,13 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener public AltosMapCache cache() { return cache; } - public void set_sites() { - int i = 1; - for (AltosUISite site : sites.sites) { - site_list.insertItemAt(site, i); - i++; - } - } - public void itemStateChanged(ItemEvent e) { int state = e.getStateChange(); if (state == ItemEvent.SELECTED) { Object o = e.getItem(); - if (o instanceof AltosUISite) { - AltosUISite site = (AltosUISite) o; + if (o instanceof AltosLaunchSite) { + AltosLaunchSite site = (AltosLaunchSite) o; lat.set_value(site.latitude); lon.set_value(site.longitude); } @@ -403,6 +305,18 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener } } + public void notify_launch_sites(final java.util.List sites) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + int i = 1; + for (AltosLaunchSite site : sites) { + site_list.insertItemAt(site, i); + i++; + } + } + }); + } + public AltosUIMapPreloadNew(AltosUIFrame in_owner) { owner = in_owner; @@ -463,10 +377,10 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener pane.add(site_list_label, c); - site_list = new JComboBox(new AltosUISite[] { new AltosUISite("Site List", 0, 0) }); + site_list = new JComboBox(new AltosLaunchSite[] { new AltosLaunchSite("Site List", 0, 0) }); site_list.addItemListener(this); - sites = new AltosUISites(this); + new AltosLaunchSites(this); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; -- cgit v1.2.3 From 756f501593365b80cfa6f7ca871da3291bbde67a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 22:43:53 -0700 Subject: altoslib: Start with map empty Don't load images from 0,0 for no good reason; wait until someone sets a desired lat/lon Signed-off-by: Keith Packard --- altoslib/AltosMap.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index 762054a3..d39c3302 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -150,8 +150,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } public void set_transform() { - transform = new AltosMapTransform(width(), height(), zoom, centre); - repaint(); + if (centre != null) { + transform = new AltosMapTransform(width(), height(), zoom, centre); + repaint(); + } } private void set_zoom_label() { @@ -285,6 +287,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { tiles.remove(point); cache.set_cache_size((width() / AltosMap.px_size + 2) * (height() / AltosMap.px_size + 2)); + for (int y = (int) upper_left.y; y <= lower_right.y; y += AltosMap.px_size) { for (int x = (int) upper_left.x; x <= lower_right.x; x += AltosMap.px_size) { AltosPointInt point = new AltosPointInt(x, y); @@ -319,7 +322,8 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } public void paint() { - make_tiles(); + if (centre != null) + make_tiles(); for (AltosMapTile tile : tiles.values()) tile.paint(transform); @@ -411,6 +415,5 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { line = map_interface.new_line(); path = map_interface.new_path(); set_zoom_label(); - centre(0, 0); } } -- cgit v1.2.3 From ccd557c846eed37328d6799f36e61308bcbb678a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 23:11:58 -0700 Subject: altoslib: Provide toString method for AltosLatLon Makes printing them easier. Signed-off-by: Keith Packard --- altoslib/AltosLatLon.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/altoslib/AltosLatLon.java b/altoslib/AltosLatLon.java index e0fd45e7..dc606ccb 100644 --- a/altoslib/AltosLatLon.java +++ b/altoslib/AltosLatLon.java @@ -27,6 +27,10 @@ public class AltosLatLon { return lat == other.lat && lon == other.lon; } + public String toString() { + return String.format("%f/%f", lat, lon); + } + public AltosLatLon(double lat, double lon) { this.lat = lat; this.lon = lon; -- cgit v1.2.3 From 3b4e6da65158a434905dc652e46c69d2c38cea7f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 23:12:34 -0700 Subject: altoslib: Add map loading helper class This adds the AltosMapLoader class, which iterates over a sequence of zoom levels and formats to get local copies of a desired launch site. Signed-off-by: Keith Packard --- altoslib/AltosMapLoader.java | 143 +++++++++++++++++++++++++++++++++++ altoslib/AltosMapLoaderListener.java | 26 +++++++ altoslib/Makefile.am | 2 + 3 files changed, 171 insertions(+) create mode 100644 altoslib/AltosMapLoader.java create mode 100644 altoslib/AltosMapLoaderListener.java diff --git a/altoslib/AltosMapLoader.java b/altoslib/AltosMapLoader.java new file mode 100644 index 00000000..5db20cf8 --- /dev/null +++ b/altoslib/AltosMapLoader.java @@ -0,0 +1,143 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_7; + +import java.io.*; +import java.util.*; +import java.text.*; +import java.lang.Math; +import java.net.URL; +import java.net.URLConnection; + +public class AltosMapLoader implements AltosMapTileListener { + AltosMapLoaderListener listener; + + double latitude, longitude; + int min_z; + int max_z; + int cur_z; + int all_types; + int cur_type; + int radius; + + int tiles_per_layer; + int tiles_loaded; + int layers_total; + int layers_loaded; + + AltosMap map; + AltosMapCache cache; + + public void do_load() { + map.set_zoom(cur_z + AltosMap.default_zoom); + map.set_maptype(cur_type); + map.set_load_params(latitude, longitude, radius, this); + } + + public int next_type(int start) { + int next_type; + for (next_type = start; + next_type <= AltosMap.maptype_terrain && (all_types & (1 << next_type)) == 0; + next_type++) + ; + return next_type; + } + + public void next_load() { + int next_type = next_type(cur_type + 1); + + if (next_type > AltosMap.maptype_terrain) { + if (cur_z == max_z) { + return; + } else { + cur_z++; + } + next_type = next_type(0); + } + cur_type = next_type; + do_load(); + } + + private void start_load() { + + cur_z = min_z; + int ntype = 0; + + for (int t = AltosMap.maptype_hybrid; t <= AltosMap.maptype_terrain; t++) + if ((all_types & (1 << t)) != 0) + ntype++; + if (ntype == 0) { + all_types = (1 << AltosMap.maptype_hybrid); + ntype = 1; + } + + cur_type = next_type(0); + tiles_per_layer = (radius * 2 + 1) * (radius * 2 + 1); + layers_total = (max_z - min_z + 1) * ntype; + layers_loaded = 0; + tiles_loaded = 0; + + listener.loader_start(layers_total * tiles_per_layer); + do_load(); + } + + public void load(double latitude, double longitude, int min_z, int max_z, int radius, int all_types) { + this.latitude = latitude; + this.longitude = longitude; + this.min_z = min_z; + this.max_z = max_z; + this.radius = radius; + this.all_types = all_types; + start_load(); + } + + public synchronized void notify_tile(AltosMapTile tile, int status) { + boolean do_next = false; + if (status == AltosMapTile.loading) + return; + + if (layers_loaded >= layers_total) + return; + + ++tiles_loaded; + + if (tiles_loaded == tiles_per_layer) { + tiles_loaded = 0; + ++layers_loaded; + if (layers_loaded == layers_total) { + listener.loader_done(layers_total * tiles_per_layer); + return; + } else { + do_next = true; + } + } + listener.loader_notify(layers_loaded * tiles_per_layer + tiles_loaded, + layers_total * tiles_per_layer, tile.store.file.toString()); + if (do_next) + next_load(); + } + + public AltosMapCache cache() { return cache; } + + public AltosMapLoader(AltosMap map, AltosMapCache cache, + AltosMapLoaderListener listener) { + this.map = map; + this.cache = cache; + this.listener = listener; + } +} diff --git a/altoslib/AltosMapLoaderListener.java b/altoslib/AltosMapLoaderListener.java new file mode 100644 index 00000000..79f8b9df --- /dev/null +++ b/altoslib/AltosMapLoaderListener.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2015 Keith Packard + * + * 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. + */ + +package org.altusmetrum.altoslib_7; + +public interface AltosMapLoaderListener { + public abstract void loader_start(int max); + + public abstract void loader_notify(int cur, int max, String name); + + public abstract void loader_done(int max); +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index de13c1ec..a6b178fa 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -154,6 +154,8 @@ altoslib_JAVA = \ AltosLaunchSite.java \ AltosLaunchSiteListener.java \ AltosLaunchSites.java \ + AltosMapLoaderListener.java \ + AltosMapLoader.java \ AltosVersion.java JAR=altoslib_$(ALTOSLIB_VERSION).jar -- cgit v1.2.3 From b49b74847ad55e14d1dbf2872ebbe313147e9fd3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 May 2015 23:14:09 -0700 Subject: altosuilib: Switch to altoslib map loading code Remove the map loading code from the UI bits and use the new altoslib version instead. Signed-off-by: Keith Packard --- altosuilib/AltosUIMapPreloadNew.java | 156 ++++++++++------------------------- 1 file changed, 42 insertions(+), 114 deletions(-) diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index a7d12737..20cb3888 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -118,7 +118,7 @@ class AltosUIMapPos extends Box { } } -public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener, AltosLaunchSiteListener { +public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosLaunchSiteListener, AltosMapLoaderListener { AltosUIFrame owner; AltosUIMapNew map; AltosMapCache cache; @@ -127,8 +127,8 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener AltosUIMapPos lon; JProgressBar pbar; - int pbar_max; - int pbar_cur; + + AltosMapLoader loader; JLabel site_list_label; JComboBox site_list; @@ -149,124 +149,49 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener static final String[] lat_hemi_names = { "N", "S" }; static final String[] lon_hemi_names = { "E", "W" }; - class updatePbar implements Runnable { - String s; - - public updatePbar(String in_s) { - s = in_s; - } - - public void run() { - int n = ++pbar_cur; - - pbar.setMaximum(pbar_max); - pbar.setValue(n); - pbar.setString(s); - } - } - double latitude, longitude; - int min_z; - int max_z; - int cur_z; - int all_types; - int cur_type; - int r; - - int tiles_per_layer; - int tiles_loaded; - int layers_total; - int layers_loaded; - - - private void do_load() { - tiles_loaded = 0; - map.set_zoom(cur_z + AltosMap.default_zoom); - map.set_maptype(cur_type); - map.set_load_params(latitude, longitude, r, this); - } - private int next_type(int start) { - int next_type; - for (next_type = start; - next_type <= AltosMap.maptype_terrain && (all_types & (1 << next_type)) == 0; - next_type++) - ; - return next_type; + /* AltosMapLoaderListener interfaces */ + public void loader_start(final int max) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + pbar.setMaximum(max); + pbar.setValue(0); + pbar.setString(""); + map.clear_marks(); + map.add_mark(latitude, longitude, AltosLib.ao_flight_boost); + } + }); } - private void next_load() { - int next_type = next_type(cur_type + 1); + public void loader_notify(final int cur, final int max, final String name) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + pbar.setValue(cur); + pbar.setString(name); + } + }); + } - if (next_type > AltosMap.maptype_terrain) { - if (cur_z == max_z) { - return; - } else { - cur_z++; - } - next_type = next_type(0); - } - cur_type = next_type; - do_load(); + public void loader_done(int max) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + pbar.setValue(0); + pbar.setString(""); + load_button.setSelected(false); + loading = false; + } + }); } - private void start_load() { - cur_z = min_z; - int ntype = 0; - all_types = 0; + private int all_types() { + int all_types = 0; for (int t = AltosMap.maptype_hybrid; t <= AltosMap.maptype_terrain; t++) - if (maptypes[t].isSelected()) { + if (maptypes[t].isSelected()) all_types |= (1 << t); - ntype++; - } - if (ntype == 0) { - all_types |= (1 << AltosMap.maptype_hybrid); - ntype = 1; - } - - cur_type = next_type(0); - tiles_per_layer = (r * 2 + 1) * (r * 2 + 1); - layers_total = (max_z - min_z + 1) * ntype; - layers_loaded = 0; - pbar_max = layers_total * tiles_per_layer; - pbar_cur = 0; - - map.clear_marks(); - map.add_mark(latitude,longitude, AltosLib.ao_flight_boost); - do_load(); + return all_types; } - /* AltosMapTileListener methods */ - - public synchronized void notify_tile(AltosMapTile tile, int status) { - if (status == AltosMapTile.loading) - return; - - SwingUtilities.invokeLater(new updatePbar(tile.store.file.toString())); - ++tiles_loaded; - if (tiles_loaded == tiles_per_layer) { - ++layers_loaded; - if (layers_loaded == layers_total) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - pbar.setValue(0); - pbar.setString(""); - load_button.setSelected(false); - loading = false; - } - }); - } else { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - next_load(); - } - }); - } - } - } - - public AltosMapCache cache() { return cache; } - public void itemStateChanged(ItemEvent e) { int state = e.getStateChange(); @@ -291,16 +216,17 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener try { latitude = lat.get_value(); longitude = lon.get_value(); - min_z = (Integer) min_zoom.getSelectedItem(); - max_z = (Integer) max_zoom.getSelectedItem(); + int min_z = (Integer) min_zoom.getSelectedItem(); + int max_z = (Integer) max_zoom.getSelectedItem(); if (max_z < min_z) max_z = min_z; - r = (Integer) radius.getSelectedItem(); + int r = (Integer) radius.getSelectedItem(); loading = true; + + loader.load(latitude, longitude, min_z, max_z, r, all_types()); } catch (ParseException pe) { load_button.setSelected(false); } - start_load(); } } } @@ -331,6 +257,8 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener map = new AltosUIMapNew(); cache = new AltosMapCache(map); + loader = new AltosMapLoader(map.map, cache, this); + c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.insets = i; -- cgit v1.2.3 From ff01fb7275973cdbfd976d3b4e638c6235108121 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 28 May 2015 01:00:22 -0700 Subject: altosuilib: Get rid of AltosUIMapNew.set_load_params This isn't needed anywhere. Signed-off-by: Keith Packard --- altosuilib/AltosUIMapNew.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java index 511d8fe6..05f47b53 100644 --- a/altosuilib/AltosUIMapNew.java +++ b/altosuilib/AltosUIMapNew.java @@ -429,10 +429,6 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt JComboBox maptype_combo; - public void set_load_params(double lat, double lon, int radius, AltosMapTileListener listener) { - map.set_load_params(lat, lon, radius, listener); - } - MapView view; public AltosUIMapNew() { -- cgit v1.2.3 From c63617415553d97f9be2f19b94365b53d4480c68 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 28 May 2015 01:00:47 -0700 Subject: altosuilib: Eliminate extra MapCache in AltosUIMapPreloadNew Use the cache from the map. Signed-off-by: Keith Packard --- altosuilib/AltosUIMapPreloadNew.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index 20cb3888..4a5764c8 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -121,7 +121,6 @@ class AltosUIMapPos extends Box { public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosLaunchSiteListener, AltosMapLoaderListener { AltosUIFrame owner; AltosUIMapNew map; - AltosMapCache cache; AltosUIMapPos lat; AltosUIMapPos lon; @@ -255,9 +254,8 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener pane.setLayout(new GridBagLayout()); map = new AltosUIMapNew(); - cache = new AltosMapCache(map); - loader = new AltosMapLoader(map.map, cache, this); + loader = new AltosMapLoader(map.map, this); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; -- cgit v1.2.3 From ba698c2cc48677735046d0881df9c180674e4082 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 28 May 2015 01:01:23 -0700 Subject: altoslib: Pass all map loader params to set_load_params Add zoom and map type to the param list so we don't call set_zoom and set_maptype separately, which only causes lots of extra image loads to get started unnecessarily. Signed-off-by: Keith Packard --- altoslib/AltosMap.java | 10 ++++++++-- altoslib/AltosMapLoader.java | 11 +++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index d39c3302..85f95eef 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -248,7 +248,9 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { public void add_mark(double lat, double lon, int state) { synchronized(marks) { - marks.add(map_interface.new_mark(lat, lon, state)); + AltosMapMark mark = map_interface.new_mark(lat, lon, state); + if (mark != null) + marks.add(mark); } repaint(); } @@ -303,11 +305,15 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } } - public void set_load_params(double lat, double lon, int radius, AltosMapTileListener listener) { + public void set_load_params(int new_zoom, int new_type, double lat, double lon, int radius, AltosMapTileListener listener) { + if (AltosMap.min_zoom <= new_zoom && new_zoom <= AltosMap.max_zoom) + zoom = new_zoom; + maptype = new_type; load_centre = new AltosLatLon(lat, lon); load_radius = radius; load_listener = listener; centre(lat, lon); + tiles.clear(); make_tiles(); for (AltosMapTile tile : tiles.values()) { tile.add_store_listener(this); diff --git a/altoslib/AltosMapLoader.java b/altoslib/AltosMapLoader.java index 5db20cf8..cf7169ba 100644 --- a/altoslib/AltosMapLoader.java +++ b/altoslib/AltosMapLoader.java @@ -41,12 +41,9 @@ public class AltosMapLoader implements AltosMapTileListener { int layers_loaded; AltosMap map; - AltosMapCache cache; public void do_load() { - map.set_zoom(cur_z + AltosMap.default_zoom); - map.set_maptype(cur_type); - map.set_load_params(latitude, longitude, radius, this); + map.set_load_params(cur_z + AltosMap.default_zoom, cur_type, latitude, longitude, radius, this); } public int next_type(int start) { @@ -132,12 +129,10 @@ public class AltosMapLoader implements AltosMapTileListener { next_load(); } - public AltosMapCache cache() { return cache; } + public AltosMapCache cache() { return map.cache(); } - public AltosMapLoader(AltosMap map, AltosMapCache cache, - AltosMapLoaderListener listener) { + public AltosMapLoader(AltosMap map, AltosMapLoaderListener listener) { this.map = map; - this.cache = cache; this.listener = listener; } } -- cgit v1.2.3 From 85013045ca505096064aaf45c312b158d0263d2a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 28 May 2015 01:05:18 -0700 Subject: altosdroid: Add map types and map preloading UIs This adds an ugly dialog to select which maps to preload, and also adds the ability to display other map types. Signed-off-by: Keith Packard --- altosdroid/AndroidManifest.xml | 10 + .../ic_maps_indicator_current_position.png | Bin 0 -> 2079 bytes .../ic_maps_indicator_current_position.png | Bin 0 -> 1205 bytes altosdroid/res/layout/device_list.xml | 16 +- altosdroid/res/layout/map_preload.xml | 129 +++++++++ altosdroid/res/layout/map_type.xml | 47 +++ altosdroid/res/menu/option_menu.xml | 28 +- altosdroid/res/values/strings.xml | 20 ++ .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 24 ++ .../org/altusmetrum/AltosDroid/AltosDroidTab.java | 3 + .../altusmetrum/AltosDroid/MapTypeActivity.java | 84 ++++++ .../altusmetrum/AltosDroid/PreloadMapActivity.java | 322 +++++++++++++++++++++ .../src/org/altusmetrum/AltosDroid/TabMap.java | 13 + .../org/altusmetrum/AltosDroid/TabMapOffline.java | 11 +- .../altusmetrum/AltosDroid/TelemetryService.java | 1 - 15 files changed, 688 insertions(+), 20 deletions(-) create mode 100644 altosdroid/res/drawable-hdpi/ic_maps_indicator_current_position.png create mode 100644 altosdroid/res/drawable-mdpi/ic_maps_indicator_current_position.png create mode 100644 altosdroid/res/layout/map_preload.xml create mode 100644 altosdroid/res/layout/map_type.xml create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/MapTypeActivity.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index 71c6fb12..592373d4 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -72,6 +72,16 @@ android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden" /> + + + + + - diff --git a/altosdroid/res/layout/map_preload.xml b/altosdroid/res/layout/map_preload.xml new file mode 100644 index 00000000..1d1fca32 --- /dev/null +++ b/altosdroid/res/layout/map_preload.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + +