diff --git a/mchf-eclipse/.settings/language.settings.xml b/mchf-eclipse/.settings/language.settings.xml
index b1404a835..76ae75aaa 100644
--- a/mchf-eclipse/.settings/language.settings.xml
+++ b/mchf-eclipse/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
@@ -27,7 +27,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -49,7 +49,7 @@
-
+
@@ -60,7 +60,7 @@
-
+
diff --git a/mchf-eclipse/drivers/audio/cw/cw_gen.c b/mchf-eclipse/drivers/audio/cw/cw_gen.c
index 4a6b70fcc..36f17c365 100644
--- a/mchf-eclipse/drivers/audio/cw/cw_gen.c
+++ b/mchf-eclipse/drivers/audio/cw/cw_gen.c
@@ -40,6 +40,7 @@
#include "softdds.h"
#include "cw_gen.h"
#include "cat_driver.h"
+#include "ui_driver.h"
// States
@@ -54,14 +55,14 @@
#define CW_DIT_L 0x01
#define CW_DAH_L 0x02
#define CW_DIT_PROC 0x04
+#define CW_END_PROC 0x10
#define CW_IAMBIC_A 0x00
#define CW_IAMBIC_B 0x10
#define CW_SMOOTH_LEN 2 // with sm_table size of 128 ~5.3ms for edges, ~ 9 steps of 0.6 ms
#define CW_SMOOTH_STEPS 9 // 1 step = 0.6ms; 13 for 8ms, 9 for 5.4 ms, for internal keyer
-//
-//
+
typedef struct PaddleState
{
// State machine and port states
@@ -72,6 +73,7 @@ typedef struct PaddleState
int32_t dit_time;
int32_t dah_time;
int32_t pause_time;
+ int32_t space_time;
// Timers
ulong key_timer;
@@ -82,6 +84,9 @@ typedef struct PaddleState
ulong ultim;
+ ulong cw_char;
+ ulong space_timer;
+
} PaddleState;
// Public paddle state
@@ -91,9 +96,12 @@ static bool CwGen_ProcessStraightKey(float32_t *i_buffer,float32_t *q_buffer,u
static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong size);
static void CwGen_TestFirstPaddle();
+#define CW_CHAR_CODES 47
+const int cw_char_codes[] = {0, 2, 3, 10, 11, 14, 15, 42, 43, 46, 47, 58, 59, 62, 63, 170, 171, 174, 186, 190, 191, 234, 235, 238, 239, 250, 251, 682, 683, 687, 703, 767, 938, 939, 942, 1002, 1018, 1022, 1023, 2810, 2990, 3003, 3054, 3070, 3755, 4015, 4074};
+const char cw_char_chars[] = {' ', 'E', 'T', 'I', 'A', 'N', 'M', 'S', 'U', 'R', 'W', 'D', 'K', 'G', 'O', 'H', 'V', 'F', 'L', 'P', 'J', 'B', 'X', 'C', 'Y', 'Z', 'Q', '5', '4', '3', '2', '1', '6', '=', '/', '7', '8', '9', '0', '?', '"', '.', '@', '\'', '-', ',', ':'};
+
// Blackman-Harris function to keep CW signal bandwidth narrow
#define CW_SMOOTH_TBL_SIZE 128
-
static const float sm_table[CW_SMOOTH_TBL_SIZE] =
{
0.0,
@@ -236,6 +244,7 @@ void CwGen_SetSpeed()
int32_t dit_time = 180000/ts.cw_keyer_speed + CW_SMOOTH_STEPS*100; // +9 = 6ms * 1/1500 = 0,006*1500
int32_t dah_time = 3*180000/ts.cw_keyer_speed + CW_SMOOTH_STEPS*100; // +9 = 6ms * 1/1500 = 0,006*1500
int32_t pause_time = 180000/ts.cw_keyer_speed - CW_SMOOTH_STEPS*100; // -9 = -6ms * 1/1500 = -0,006*1500
+ int32_t space_time = 6*180000/ts.cw_keyer_speed;
int32_t weight_corr = ((int32_t)ts.cw_keyer_weight-100) * dit_time/100;
@@ -243,6 +252,7 @@ void CwGen_SetSpeed()
ps.dit_time = (dit_time + weight_corr)/100;
ps.dah_time = (dah_time + weight_corr)/100;
ps.pause_time = (pause_time - weight_corr)/100;
+ ps.space_time = space_time / 100;
}
static void CwGen_SetBreakTime()
@@ -277,6 +287,9 @@ void CwGen_Init(void)
default:
break;
}
+
+ ps.cw_char = 0;
+ ps.space_timer = 0;
}
/**
@@ -501,6 +514,16 @@ static bool CwGen_ProcessStraightKey(float32_t *i_buffer,float32_t *q_buffer,ulo
return retval;
}
+void CwGen_AddChar(ulong c) {
+ for (int i = 0; i 5000) {
+ CwGen_AddChar(-1);
+ ps.cw_char = 0;
+ ps.port_state &= ~CW_END_PROC;
+ } else {
+ ps.port_state |= CW_END_PROC;
+ }
+
if (ts.cw_keyer_mode == CW_MODE_IAM_A || ts.cw_keyer_mode == CW_KEYER_MODE_IAM_B)
{
if (ps.port_state & CW_DIT_PROC)
@@ -648,12 +696,15 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
if((ps.port_state & CW_DAH_L) && ps.ultim == 0)
{
ps.port_state &= ~(CW_DIT_L + CW_DIT_PROC);
- ps.cw_state = CW_DAH_CHECK;
+ ps.cw_state |= CW_END_PROC;
}
else
{
ps.port_state &= ~(CW_DAH_L);
ps.cw_state = CW_IDLE;
+ ps.space_timer = ps.space_time;
+ CwGen_AddChar(ps.cw_char);
+ ps.cw_char = 0;
CwGen_SetBreakTime();
}
}
diff --git a/mchf-eclipse/drivers/ui/ui_driver.c b/mchf-eclipse/drivers/ui/ui_driver.c
index 5d9f48340..eaaa0ea73 100644
--- a/mchf-eclipse/drivers/ui/ui_driver.c
+++ b/mchf-eclipse/drivers/ui/ui_driver.c
@@ -6005,6 +6005,7 @@ void UiDriver_MainHandler()
{
UiDriver_DisplayVoltage();
}
+
if (pwmt.undervoltage_detected == true) {
if (UiDriver_TimerExpireAndRewind(SCTimer_LEDBLINK, now, 64)) {
MchfBoard_GreenLed(LED_STATE_TOGGLE);