Skip to content

Commit

Permalink
Merge pull request #1001 from phaethon/active-devel
Browse files Browse the repository at this point in the history
Entering characters using paddle in iambic mode
  • Loading branch information
df8oe authored Aug 17, 2017
2 parents 398e732 + 0ed24a8 commit d7f4f46
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 10 deletions.
12 changes: 6 additions & 6 deletions mchf-eclipse/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="111743357592321234" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1435794056738905230" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="177772813756081672" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1372283831538266564" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -27,7 +27,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="126911469821072498" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1474558212332860462" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -38,7 +38,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="175670720889180520" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1406400670025555236" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -49,7 +49,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="79220502755665618" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1390366696367146638" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -60,7 +60,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="160498481196857800" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1367636514431600004" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
59 changes: 55 additions & 4 deletions mchf-eclipse/drivers/audio/cw/cw_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "softdds.h"
#include "cw_gen.h"
#include "cat_driver.h"
#include "ui_driver.h"


// States
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -82,6 +84,9 @@ typedef struct PaddleState

ulong ultim;

ulong cw_char;
ulong space_timer;

} PaddleState;

// Public paddle state
Expand All @@ -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,
Expand Down Expand Up @@ -236,13 +244,15 @@ 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;

// we add the correction value to both dit and dah and subtract from pause. dah gets less change proportionally because of this
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()
Expand Down Expand Up @@ -277,6 +287,9 @@ void CwGen_Init(void)
default:
break;
}

ps.cw_char = 0;
ps.space_timer = 0;
}

/**
Expand Down Expand Up @@ -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<CW_CHAR_CODES; i++) {
if (cw_char_codes[i] == c) {
UiDriver_TextMsgPutChar(cw_char_chars[i]);
return;
}
}
UiDriver_TextMsgPutChar('*');
}

static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong blockSize)
{
uint32_t retval = false;
Expand All @@ -526,6 +549,13 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
}
else
{
if (ps.port_state & CW_END_PROC) {
CwGen_AddChar(ps.cw_char);
ps.cw_char = 0;
ps.port_state &= ~CW_END_PROC;
ps.space_timer = ps.space_time;
}

if(ps.break_timer == 0)
{
ts.tx_stop_req = true;
Expand All @@ -534,6 +564,13 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
{
ps.break_timer--;
}

if(ps.space_timer)
{
ps.space_timer--;
} else {
CwGen_AddChar(0);
}
retval = false;
}
}
Expand All @@ -552,6 +589,7 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
ps.port_state |= CW_DIT_PROC;
ps.key_timer = ps.dit_time;
ps.cw_state = CW_KEY_DOWN;
ps.cw_char = ps.cw_char * 4 + 2;
}
else
{
Expand All @@ -565,11 +603,13 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
if (ps.port_state & CW_DAH_L)
{
ps.key_timer = ps.dah_time;
ps.cw_char = ps.cw_char * 4 + 3;
ps.cw_state = CW_KEY_DOWN;
}
else
{
ps.cw_state = CW_IDLE;

CwGen_SetBreakTime();
}
rerunStateMachine = true;
Expand Down Expand Up @@ -627,6 +667,14 @@ static bool CwGen_ProcessIambic(float32_t *i_buffer,float32_t *q_buffer,ulong bl
ps.key_timer--;
if(ps.key_timer == 0)
{
if(ps.cw_char > 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)
Expand All @@ -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();
}
}
Expand Down
1 change: 1 addition & 0 deletions mchf-eclipse/drivers/ui/ui_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7f4f46

Please sign in to comment.