aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-12 18:54:14 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-12 18:54:14 +0200
commite20f8816f48aa80a82b241ef73e2d9ab92833f87 (patch)
tree60cfd4d9fa7e3f3525df8ad98ddaa9cf65fe2825 /src/common
parent6f95a22ce25839825c79d4529317984bd3e1b870 (diff)
downloadglutte-o-matic-e20f8816f48aa80a82b241ef73e2d9ab92833f87.tar.gz
glutte-o-matic-e20f8816f48aa80a82b241ef73e2d9ab92833f87.tar.bz2
glutte-o-matic-e20f8816f48aa80a82b241ef73e2d9ab92833f87.zip
Fix analog supply voltage readout
Diffstat (limited to 'src/common')
-rw-r--r--src/common/includes/Core/fsm.h1
-rw-r--r--src/common/includes/GPIO/analog.h5
-rw-r--r--src/common/sourcelist.txt1
-rw-r--r--src/common/src/Core/main.c14
-rw-r--r--src/common/src/GPIO/usart.c11
5 files changed, 25 insertions, 7 deletions
diff --git a/src/common/includes/Core/fsm.h b/src/common/includes/Core/fsm.h
index 75f1f46..94698b4 100644
--- a/src/common/includes/Core/fsm.h
+++ b/src/common/includes/Core/fsm.h
@@ -74,7 +74,6 @@ struct fsm_input_signals_t {
// All signals the FSM has to control
struct fsm_output_signals_t {
/* Signals to the repeater electronics */
- int qrp; // Place the repeater in QRP mode // TODO move out of FSM
int tx_on; // Enable TX circuitry
int modulation; // Enable repeater RX to TX modulation
diff --git a/src/common/includes/GPIO/analog.h b/src/common/includes/GPIO/analog.h
index 99404f6..54dfb5d 100644
--- a/src/common/includes/GPIO/analog.h
+++ b/src/common/includes/GPIO/analog.h
@@ -30,3 +30,8 @@ void analog_init(void);
* Returns 0.0f in case of error */
float analog_measure_12v(void);
+/* Keep an average of measurements, and decide if the repeater should enter
+ * QRP. Returns 1 if low power must be activated
+ */
+int analog_supply_too_low(void);
+
diff --git a/src/common/sourcelist.txt b/src/common/sourcelist.txt
index 0abc086..eada47f 100644
--- a/src/common/sourcelist.txt
+++ b/src/common/sourcelist.txt
@@ -1,3 +1,4 @@
+src/GPIO/analog.c
src/GPIO/usart.c
src/GPIO/temperature.c
src/GPS/gps.c
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index a30a3f6..22aca74 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -188,6 +188,7 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters)
usart_debug_puts("Init done.\r\n");
+ int last_qrp = 0;
while(1) {
int i = 0;
vTaskDelay(pdMS_TO_TICKS(1000));
@@ -201,6 +202,14 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters)
leds_turn_off(LED_GREEN);
}
+ const int qrp = analog_supply_too_low();
+ if (qrp != last_qrp) {
+ usart_debug("QRP should be %d\r\n", qrp);
+ last_qrp = qrp;
+
+ pio_set_qrp(qrp);
+ }
+
const float supply_voltage = analog_measure_12v();
usart_debug("12V monitor %dmV\r\n", (int32_t)(supply_voltage * 1000.0f));
}
@@ -232,10 +241,10 @@ static void detect_button_press(void __attribute__ ((unused))*pvParameters)
usart_debug_puts("Bouton bleu\r\n");
if (temperature_valid()) {
-
float temp = temperature_get();
+ int temp_decidegrees = temp * 10.0f;
- usart_debug("Temperature %f\r\n", temp);
+ usart_debug("Temperature %d.%01d\r\n", temp_decidegrees / 10, temp_decidegrees % 10);
} else {
usart_debug_puts("No temp\r\n");
@@ -434,7 +443,6 @@ static void exercise_fsm(void __attribute__ ((unused))*pvParameters)
pio_set_tx(fsm_out.tx_on);
pio_set_mod_off(!fsm_out.modulation);
- pio_set_qrp(fsm_out.qrp); // TODO move out of FSM
// Add message to CW generator only on rising edge of trigger
if (fsm_out.cw_psk31_trigger && !cw_last_trigger) {
diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c
index ee7e96d..ee7ad9f 100644
--- a/src/common/src/GPIO/usart.c
+++ b/src/common/src/GPIO/usart.c
@@ -28,6 +28,7 @@
#include <inttypes.h>
#include "Core/common.h"
#include "GPIO/usart.h"
+#include "GPIO/analog.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
@@ -128,11 +129,15 @@ static void usart_clear_nmea_buffer(void) {
void usart_process_char(char c) {
if (c == 'h') {
- usart_debug_puts("help: no commands supported yet!\r\n");
- } else {
+ usart_debug_puts("help: commands: [v]oltage.\r\n");
+ }
+ else if (c == 'v') {
+ const float supply_voltage = analog_measure_12v();
+ usart_debug("12V monitor %dmV\r\n", (int32_t)(supply_voltage * 1000.0f));
+ }
+ else {
usart_debug("Unknown command %c\r\n", c);
}
-
}
void usart_gps_process_char(char c) {