aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/spec.md14
-rw-r--r--src/common/Core/fsm.c87
-rw-r--r--src/simulator/src/GPIO/usart.c2
-rw-r--r--src/simulator/src/Gui/gui.c17
4 files changed, 85 insertions, 35 deletions
diff --git a/doc/spec.md b/doc/spec.md
index 1731d4e..39ca742 100644
--- a/doc/spec.md
+++ b/doc/spec.md
@@ -42,7 +42,19 @@ Avec hysterèse:
##Toutes les heures paires :
-Le relais, seulement s'il n'y a pas de QSO en cours, (sinon il attend la fin du QSO), dès qu’il a la possibilité, il prend la main sur toutes autres activités possible, (modulation off, et 1750Hz) puis il TX :
+Le relais, seulement s'il n'y a pas de QSO en cours, (sinon il attend la fin du QSO), dès qu’il a la possibilité, il prend la main sur toutes autres activités possible, (modulation off, et 1750Hz) puis il TX une balise.
+
+A partir d'octobre 2020:
+
+*HB9G JN36BK U 13V5 1650 AH + T 12 73*
+
+Tendance: + - ou = selon l'évolution de la capacité en Ah. T par pas de 1 degré C. *73* si éolienne dans le vent, *SK*
+si repliée.
+
+En QRP, *HB9G U 12V5 1010 AH 73*
+
+
+Jusqu'en octobre 2020:
*HB9G JN36BK 1628 M U 13V5* (un pas de 0,5V est suffisant) puis la tendance à la charge ou décharge ou égale (representés par +/-/=), *T* (température) par pas de 2 degrés, puis *73* si la queue de l’éolienne est dans le vent, ou *SK* si elle est repliée.
diff --git a/src/common/Core/fsm.c b/src/common/Core/fsm.c
index 0cf2d7d..7d3e6ca 100644
--- a/src/common/Core/fsm.c
+++ b/src/common/Core/fsm.c
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2019 Matthias P. Braendli, Maximilien Cuony
+ * Copyright (c) 2020 Matthias P. Braendli, Maximilien Cuony
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,6 +30,7 @@
#include "Core/stats.h"
#include "GPIO/usart.h"
#include "GPIO/temperature.h"
+#include "GPIO/batterycharge.h"
#include "GPIO/analog.h"
static struct fsm_input_signals_t fsm_in;
@@ -43,9 +44,9 @@ static sstv_fsm_state_t sstv_state;
// in ms using the timestamp_now() function
static uint64_t timestamp_state[_NUM_FSM_STATES];
-static int last_supply_voltage_decivolts = 0;
+static int last_battery_capacity_ah = 0;
-#define BALISE_MESSAGE_LEN 64
+#define BALISE_MESSAGE_LEN 75
static char balise_message[BALISE_MESSAGE_LEN];
static int balise_message_empty(void)
@@ -486,41 +487,50 @@ void fsm_update() {
// The backslash is the SK digraph
}
- char supply_trend = '=';
- // = means same voltage as previous
- // + means higher
- // - means lower
- if (last_supply_voltage_decivolts < supply_decivolts) {
- supply_trend = '+';
- }
- else if (last_supply_voltage_decivolts > supply_decivolts) {
- supply_trend = '-';
- }
-
if (balise_message_empty()) {
- if (temperature_valid()) {
- snprintf(balise_message, BALISE_MESSAGE_LEN-1,
- CW_PREDELAY "HB9G JN36BK 1628M U %dV%01d %c T %d %s" CW_POSTDELAY,
- supply_decivolts / 10,
- supply_decivolts % 10,
- supply_trend,
- (int)(round_float_to_half_steps(temperature_get())),
- eol_info);
+ const uint32_t capacity_bat_mah = batterycharge_retrieve_last_capacity();
+ const int capacity_bat_ah = capacity_bat_mah / 1000;
+
+ char supply_trend = '=';
+ if (capacity_bat_ah) {
+ // = means same battery capacity as previous
+ // + means higher
+ // - means lower
+ if (last_battery_capacity_ah < capacity_bat_ah) {
+ supply_trend = '+';
+ }
+ else if (last_battery_capacity_ah > capacity_bat_ah) {
+ supply_trend = '-';
+ }
+
+ last_battery_capacity_ah = capacity_bat_ah;
}
- else {
- snprintf(balise_message, BALISE_MESSAGE_LEN-1,
- CW_PREDELAY "HB9G JN36BK 1628M U %dV%01d %c %s" CW_POSTDELAY,
+
+ size_t len = 0;
+
+ len += snprintf(balise_message + len, BALISE_MESSAGE_LEN-len-1,
+ CW_PREDELAY "HB9G JN36BK U %dV%01d ",
supply_decivolts / 10,
- supply_decivolts % 10,
- supply_trend,
- eol_info);
+ supply_decivolts % 10);
+
+ if (capacity_bat_ah != 0) {
+ len += snprintf(balise_message + len, BALISE_MESSAGE_LEN-len-1,
+ " %d AH %c ", capacity_bat_ah, supply_trend);
}
+
+ if (temperature_valid()) {
+ len += snprintf(balise_message + len, BALISE_MESSAGE_LEN-len-1,
+ " T %d ",
+ (int)(round_float_to_half_steps(temperature_get())));
+ }
+
+ snprintf(balise_message + len, BALISE_MESSAGE_LEN-len-1,
+ "%s" CW_POSTDELAY,
+ eol_info);
}
fsm_out.msg = balise_message;
- last_supply_voltage_decivolts = supply_decivolts;
-
fsm_out.cw_psk_trigger = 1;
}
@@ -611,10 +621,21 @@ void fsm_update() {
// The backslash is the SK digraph
}
- snprintf(balise_message, BALISE_MESSAGE_LEN-1,
- CW_PREDELAY "HB9G U %dV%01d %s" CW_POSTDELAY,
+ size_t len = 0;
+ len += snprintf(balise_message+len, BALISE_MESSAGE_LEN-len-1,
+ CW_PREDELAY "HB9G U %dV%01d ",
supply_decivolts / 10,
- supply_decivolts % 10,
+ supply_decivolts % 10);
+
+ const uint32_t capacity_bat_mah = batterycharge_retrieve_last_capacity();
+ const int capacity_bat_ah = capacity_bat_mah / 1000;
+ if (capacity_bat_ah != 0) {
+ len += snprintf(balise_message + len, BALISE_MESSAGE_LEN-len-1,
+ " %d AH ", capacity_bat_ah);
+ }
+
+ len += snprintf(balise_message+len, BALISE_MESSAGE_LEN-len-1,
+ "%s" CW_POSTDELAY,
eol_info);
fsm_out.msg = balise_message;
diff --git a/src/simulator/src/GPIO/usart.c b/src/simulator/src/GPIO/usart.c
index 6e62b6d..eb2c976 100644
--- a/src/simulator/src/GPIO/usart.c
+++ b/src/simulator/src/GPIO/usart.c
@@ -87,4 +87,6 @@ void gui_usart_send(char * string) {
string++;
}
+ usart_process_char('\r');
+ usart_process_char('\n');
}
diff --git a/src/simulator/src/Gui/gui.c b/src/simulator/src/Gui/gui.c
index 498fd9a..3dab969 100644
--- a/src/simulator/src/Gui/gui.c
+++ b/src/simulator/src/Gui/gui.c
@@ -38,6 +38,7 @@
#include <limits.h>
#include "gui.h"
+#include "Core/common.h"
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_STANDARD_IO
@@ -176,9 +177,11 @@ int gui_last_fsm_states_timestamps[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/**
- * Voltage
+ * Voltage and battery cap
**/
float gui_measured_voltage = 14.0f;
+int gui_measured_capacity = 1630; // Ah
+int gui_measured_capacity_last = 1630; // Ah
/**
@@ -799,6 +802,18 @@ void main_gui() {
nk_label_colored(ctx, "Voltage", NK_TEXT_LEFT, c);
nk_property_float(ctx, "V", 0.0f, &gui_measured_voltage, 24.0f, 0.5f, 0.5f);
+ nk_layout_row_dynamic(ctx, 25, 2);
+ nk_label_colored(ctx, "Capacity", NK_TEXT_LEFT, c);
+ nk_property_int(ctx, "Ah", 0, &gui_measured_capacity, 1650, 10, 0.1f);
+
+ if (gui_measured_capacity != gui_measured_capacity_last) {
+ uart_send_txt_len = snprintf(uart_send_txt, sizeof(uart_send_txt), "CAPA,%ld,%d", timestamp_now()/1000, gui_measured_capacity * 1000);
+
+ uart_send_txt[uart_send_txt_len] = '\0';
+ gui_usart_send(uart_send_txt);
+
+ gui_measured_capacity_last = gui_measured_capacity;
+ }
if (gui_in_tone_1750) {
c = color_on;