Erweiterung des Menüs für die Einstellungen und Speicherung von
Einstellungen im EEprom.
Dieser Commit ist enthalten in:
Ursprung
c815b6c36b
Commit
0ce89c6276
@ -1,2 +1,2 @@
|
|||||||
:080000000032005802000F5508
|
:080000000032005802000C550B
|
||||||
:00000001FF
|
:00000001FF
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
|
* BJ-Keyer
|
||||||
*
|
*
|
||||||
*
|
* 2023-07-29 Tom, DL7BJ
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef BJ-KEYER_H_INCLUDED
|
#ifndef BJ-KEYER_H_INCLUDED
|
||||||
@ -13,7 +14,6 @@
|
|||||||
#define USART_BAUDRATE 9600
|
#define USART_BAUDRATE 9600
|
||||||
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
|
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -42,19 +42,20 @@ const char PRG[] = " BJ-Keyer ";
|
|||||||
const char VER[] = " V1.0 ";
|
const char VER[] = " V1.0 ";
|
||||||
const char Trx1[] = "TRX 1";
|
const char Trx1[] = "TRX 1";
|
||||||
const char Trx2[] = "TRX 2";
|
const char Trx2[] = "TRX 2";
|
||||||
const char Trx[] = "Beide TRX";
|
|
||||||
const char IambicA[] = "Iambic A";
|
const char IambicA[] = "Iambic A";
|
||||||
const char IambicB[] = "Iambic B";
|
const char IambicB[] = "Iambic B";
|
||||||
const char Ratio[] = "Ratio";
|
const char Ratio[] = "Ratio";
|
||||||
const char Reverse[] = "R";
|
const char ReverseRL[] = " L - R °";
|
||||||
|
const char ReverseLR[] = " L ° R -";
|
||||||
const char SideToneOnOff[] = "Mithörton";
|
const char SideToneOnOff[] = "Mithörton";
|
||||||
const char SideToneFreq[] = "Frequenz";
|
const char SideToneFreq[] = "Frequenz";
|
||||||
|
const char RiseTime[] = "Anstieg";
|
||||||
|
const char DebounceTime[] = "Entprl.";
|
||||||
const char Yes[] = "J";
|
const char Yes[] = "J";
|
||||||
const char No[] = "N";
|
const char No[] = "N";
|
||||||
const char Hz[] = "Hz";
|
const char Hz[] = "Hz";
|
||||||
|
|
||||||
// Const strings for VT100
|
// Const strings for VT100 Terminals
|
||||||
const char CLRSCR[] = "\033[2J";
|
const char CLRSCR[] = "\033[2J";
|
||||||
|
|
||||||
#ifndef EEMEM
|
#ifndef EEMEM
|
||||||
@ -68,12 +69,9 @@ const char CLRSCR[] = "\033[2J";
|
|||||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) // clear bit
|
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) // clear bit
|
||||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) // set bit
|
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) // set bit
|
||||||
|
|
||||||
// The length of one dit at 1wpm is 1.2s. The timer resolution
|
|
||||||
// of Timer 1 is set to 64µs, so there are 18750 ticks needed.
|
|
||||||
#define TICKS_PER_WPM 18750
|
|
||||||
|
|
||||||
#define L_WAIT 500 // Frequency for debug LED Timer 0
|
#define L_WAIT 500 // Frequency for debug LED Timer 0
|
||||||
|
|
||||||
|
// Keying states
|
||||||
#define NOTHING 0
|
#define NOTHING 0
|
||||||
#define DIT_DAH_OFF 1
|
#define DIT_DAH_OFF 1
|
||||||
#define DAH_DIT_OFF 2
|
#define DAH_DIT_OFF 2
|
||||||
@ -126,25 +124,20 @@ const char CLRSCR[] = "\033[2J";
|
|||||||
// Menue und Drehencoder
|
// Menue und Drehencoder
|
||||||
#define M_TRX1 1
|
#define M_TRX1 1
|
||||||
#define M_TRX2 2
|
#define M_TRX2 2
|
||||||
#define M_IAMBICA 3
|
#define M_TON 3
|
||||||
#define M_IAMBICB 4
|
#define M_TON_FREQ 4
|
||||||
#define M_REVERSE 5
|
#define M_IAMBICA 5
|
||||||
#define M_RATIO 6
|
#define M_IAMBICB 6
|
||||||
#define M_TON_FREQ 7
|
#define M_REVERSE 7
|
||||||
#define M_TON 8
|
#define M_RATIO 8
|
||||||
#define M_WPMBPM 9
|
#define M_WPMBPM 9
|
||||||
#define M_MAX 9 // maximale Menuepunke
|
#define M_RISETIME 10
|
||||||
|
#define M_DEBOUNCE 11
|
||||||
|
#define M_MAX 11 // maximale Menuepunke
|
||||||
// LCD
|
// LCD
|
||||||
#define CLEARLINE " "
|
#define CLEARLINE " "
|
||||||
|
|
||||||
// Sine wave table for PWM, 256 values
|
// Sinustabelle für PWM mit 64 Werten
|
||||||
//const unsigned char sinewave[] PROGMEM = {
|
|
||||||
// 0x80,0x8d,0x99,0xa5,0xb1,0xbd,0xc8,0xd2,0xdb,0xe3,0xeb,0xf1,0xf6,0xfa,0xfd,0xff, // 16
|
|
||||||
// 0xff,0xfe,0xfc,0xf8,0xf4,0xee,0xe7,0xdf,0xd6,0xcd,0xc2,0xb7,0xab,0x9f,0x93,0x86, // 32
|
|
||||||
// 0x7a,0x6d,0x61,0x55,0x49,0x3e,0x33,0x2a,0x21,0x19,0x12,0x0c,0x08,0x04,0x02,0x01, // 48
|
|
||||||
// 0x01,0x03,0x06,0x0a,0x0f,0x15,0x1d,0x25,0x2e,0x38,0x43,0x4f,0x5b,0x67,0x73,0x80 // 64
|
|
||||||
//};
|
|
||||||
|
|
||||||
const unsigned char sinewave[] PROGMEM = {
|
const unsigned char sinewave[] PROGMEM = {
|
||||||
0x00, 0x01, 0x02, 0x05, 0x0a, 0x0f, 0x15, 0x1d, 0x25, 0x2f, 0x39, 0x43, 0x4f, 0x5a, 0x67, 0x73,
|
0x00, 0x01, 0x02, 0x05, 0x0a, 0x0f, 0x15, 0x1d, 0x25, 0x2f, 0x39, 0x43, 0x4f, 0x5a, 0x67, 0x73,
|
||||||
0x80, 0x8c, 0x98, 0xa5, 0xb0, 0xbc, 0xc6, 0xd0, 0xda, 0xe2, 0xea, 0xf0, 0xf5, 0xfa, 0xfd, 0xfe,
|
0x80, 0x8c, 0x98, 0xa5, 0xb0, 0xbc, 0xc6, 0xd0, 0xda, 0xe2, 0xea, 0xf0, 0xf5, 0xfa, 0xfd, 0xfe,
|
||||||
@ -152,23 +145,10 @@ const unsigned char sinewave[] PROGMEM = {
|
|||||||
0x80, 0x73, 0x67, 0x5a, 0x4f, 0x43, 0x39, 0x2f, 0x25, 0x1d, 0x15, 0x0f, 0x0a, 0x05, 0x02, 0x01
|
0x80, 0x73, 0x67, 0x5a, 0x4f, 0x43, 0x39, 0x2f, 0x25, 0x1d, 0x15, 0x0f, 0x0a, 0x05, 0x02, 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
//const unsigned char sinewave[] PROGMEM = {
|
char sdebug[64];
|
||||||
//0 , 0 , 0 , 1 , 2 , 3 , 5 , 7 , 9 , 12 , 14 , 17 , 21 , 24 , 28 , 32,
|
|
||||||
//36 , 41 , 46 , 51 , 56 , 61 , 66 , 72 , 78 , 83 , 89 , 95 , 101 , 107 , 114 , 120,
|
|
||||||
//127 , 133 , 139 , 145 , 151 , 157 , 163 , 169 , 175 , 181 , 186 , 192 , 197 , 202 , 207 , 212,
|
|
||||||
//216 , 221 , 225 , 228 , 232 , 235 , 238 , 241 , 244 , 246 , 248 , 250 , 251 , 252 , 253 , 253,
|
|
||||||
//253 , 253 , 253 , 252 , 251 , 250 , 248 , 246 , 244 , 241 , 239 , 236 , 232 , 229 , 225 , 221,
|
|
||||||
//216 , 212 , 207 , 202 , 197 , 192 , 187 , 181 , 175 , 169 , 164 , 158 , 151 , 145 , 139 , 133,
|
|
||||||
//127 , 120 , 114 , 108 , 102 , 96 , 90 , 84 , 78 , 72 , 67 , 61 , 56 , 51 , 46 , 41,
|
|
||||||
//37 , 33 , 28 , 25 , 21 , 18 , 15 , 12 , 9 , 7 , 5 , 3 , 2 , 1 , 0 , 0
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t sdebug[64];
|
|
||||||
|
|
||||||
// Sidetone generation
|
// Sidetone generation
|
||||||
double sidetone_f = 600;
|
double FrequencySidetone = 600;
|
||||||
volatile uint8_t icnt;
|
volatile uint8_t icnt;
|
||||||
volatile uint8_t ocr2a;
|
volatile uint8_t ocr2a;
|
||||||
|
|
||||||
@ -178,14 +158,14 @@ uint16_t MenuCtrlTimer = 0; // Wartezeit bis zur Betriebsanzeige nac
|
|||||||
volatile uint16_t ms; // Timer 0 max. 65535ms, all purpose timer variable
|
volatile uint16_t ms; // Timer 0 max. 65535ms, all purpose timer variable
|
||||||
volatile uint16_t mselement; // Timer 0 max. 65535ms, element length of dit or dah
|
volatile uint16_t mselement; // Timer 0 max. 65535ms, element length of dit or dah
|
||||||
|
|
||||||
int8_t wpm = 15; // Geschwindigkeit in wpm
|
int8_t WpM = 12; // Geschwindigkeit in wpm
|
||||||
uint8_t weight = 50; // Gewichtung Punkt-Strich Verhältnis
|
uint8_t Weight = 50; // Gewichtung Punkt-Strich Verhältnis
|
||||||
uint8_t t_element_length;
|
uint8_t t_element_length;
|
||||||
|
|
||||||
struct Merker
|
struct Merker
|
||||||
{
|
{
|
||||||
uint8_t WpMChanged: 1;
|
uint8_t WpMChanged: 1;
|
||||||
uint8_t WriteWpMEEProm: 1;
|
uint8_t WriteWpMEEprom: 1;
|
||||||
} bMerker;
|
} bMerker;
|
||||||
|
|
||||||
struct MenuCtrl
|
struct MenuCtrl
|
||||||
@ -196,10 +176,9 @@ struct MenuCtrl
|
|||||||
uint8_t m_buttonPressedLong: 1;
|
uint8_t m_buttonPressedLong: 1;
|
||||||
uint8_t ClrScr: 1;
|
uint8_t ClrScr: 1;
|
||||||
uint8_t Config: 1;
|
uint8_t Config: 1;
|
||||||
uint8_t WriteEEProm: 1;
|
uint8_t WriteEEprom: 1;
|
||||||
uint8_t Update: 1;
|
uint8_t Update: 1;
|
||||||
uint8_t CurMenue;
|
uint8_t CurMenue;
|
||||||
|
|
||||||
} bMenuCtrl;
|
} bMenuCtrl;
|
||||||
|
|
||||||
// State Machines
|
// State Machines
|
||||||
@ -216,7 +195,6 @@ volatile uint8_t LastSendStatus = MANUAL_SENDING;
|
|||||||
// History
|
// History
|
||||||
uint8_t keyhistory = 0xff;
|
uint8_t keyhistory = 0xff;
|
||||||
|
|
||||||
|
|
||||||
uint8_t KeyTX = 1;
|
uint8_t KeyTX = 1;
|
||||||
|
|
||||||
uint8_t DahBuffer = 0;
|
uint8_t DahBuffer = 0;
|
||||||
@ -227,42 +205,51 @@ uint8_t KeyState = 0;
|
|||||||
uint8_t DitCounter = 0;
|
uint8_t DitCounter = 0;
|
||||||
uint8_t DahCounter = 0;
|
uint8_t DahCounter = 0;
|
||||||
uint8_t CurrentTRX = TRX1;
|
uint8_t CurrentTRX = TRX1;
|
||||||
uint8_t SpeedWpM = 1;
|
uint8_t StateRiseTime = 0;
|
||||||
uint8_t StateRisetime = 0;
|
volatile uint8_t StateRiseTimeCounter = 0;
|
||||||
volatile uint8_t StateRisetimeCounter = 0;
|
|
||||||
|
|
||||||
|
// Variablen in Timer 0
|
||||||
volatile uint16_t l_timer = 0; // counter for LED on
|
volatile uint16_t l_timer = 0; // counter for LED on
|
||||||
volatile uint8_t t_timer = 0; // Frequency of audio output
|
volatile uint8_t t_timer = 0; // Frequency of audio output
|
||||||
volatile uint16_t t_wait = 0; // delayms max. 65535ms
|
volatile uint16_t t_wait = 0; // delayms max. 65535ms
|
||||||
volatile uint8_t t_pwm = 0;
|
volatile uint8_t t_pwm = 0;
|
||||||
volatile uint16_t t_wait_led = 50;
|
volatile uint16_t t_wait_led = 50;
|
||||||
|
volatile uint8_t lastButton = 0; // Wert der letzten Buttonabfrage
|
||||||
|
|
||||||
volatile uint8_t encoder_timer = 0; // 10ms Timer for Encoder
|
// Drehencoder
|
||||||
volatile int8_t encoder_counter = 0; // Vor/Rück Zähler
|
volatile uint8_t EncoderTimer = 0; // 10ms Timer for Encoder
|
||||||
|
volatile int8_t EncoderCounter = 0; // Vor/Rück Zähler
|
||||||
|
volatile int8_t EncoderPos; // Encoderposition für WpM/BpM
|
||||||
|
volatile int8_t EncoderPosConfig; // Encoderposition für Einstellungen
|
||||||
|
|
||||||
|
volatile uint8_t StateStraightKeyPressed = 0; // Merker für StraightKey betätigt
|
||||||
|
volatile uint8_t TimerStraightKeyPressed = 0; // Timervariable für Entprellung
|
||||||
|
|
||||||
// EEPROM
|
// EEPROM
|
||||||
uint8_t dummy = 0x55;
|
uint8_t Dummy = 0x55;
|
||||||
uint8_t ee_dummy EEMEM = 0x55; // Dummy for Address 0
|
uint8_t ee_Dummy EEMEM = 0x55; // Dummy for Address 0
|
||||||
uint8_t ee_wpm EEMEM = 15; // WpM
|
uint8_t ee_WpM EEMEM = 12; // WpM
|
||||||
uint8_t ee_sidetone EEMEM = 0; // Mithörton An (1) oder Aus (0)
|
uint8_t ee_Sidetone EEMEM = 0; // Mithörton An (1) oder Aus (0)
|
||||||
uint16_t ee_sidetone_f EEMEM = 600; // Frequenz des Mithörtons
|
uint16_t ee_FrequencySidetone EEMEM = 600; // Frequenz des Mithörtons
|
||||||
uint8_t ee_iambic EEMEM = 0; // Iambic Mode A oder B
|
uint8_t ee_IambicMode EEMEM = 0; // Iambic Mode A oder B
|
||||||
uint8_t ee_weight EEMEM = 50; // Dah dit Ratio
|
uint8_t ee_Weight EEMEM = 50; // Dah dit Ratio
|
||||||
uint8_t ee_trx EEMEM = 0; // TRX 1 (0), TRX 2 (1), Beide (2)
|
uint8_t ee_TRX EEMEM = 0; // TRX 1 (0), TRX 2 (1), Beide (2)
|
||||||
|
|
||||||
struct Config
|
struct Config
|
||||||
{
|
{
|
||||||
uint8_t trx;
|
uint8_t TRX; // TRX 1 oder 2 oder beide
|
||||||
uint8_t iambic;
|
uint8_t IambicMode; // Iambic A oder Iambic B Mode
|
||||||
uint8_t ratio;
|
uint8_t Ratio; // Punkt/Strich Verhältnis
|
||||||
uint16_t sidetone_f;
|
uint16_t FrequencySidetone; // Frequenz des Mithörtons
|
||||||
uint8_t sidetone;
|
uint8_t SidetoneEnabled; // Mithörton eingeschaltet
|
||||||
uint8_t wpmbpm;
|
uint8_t WpMBpM; // WpM oder BpM Anzeige
|
||||||
uint8_t wpm;
|
uint8_t WpM; // WpM
|
||||||
uint8_t reverse;
|
uint8_t Reverse; // linkes/rechtes Paddle vertauschen
|
||||||
uint8_t weight;
|
uint8_t Weight; // ???
|
||||||
uint8_t Risetime;
|
uint8_t RiseTime; // Anstiegszeit Sinuston
|
||||||
uint8_t RisetimeCounter;
|
uint8_t RiseTimeCounter; // Anzahl Sinusschwingungen für den Anstieg
|
||||||
|
uint8_t DebounceTime; // Entprellzeit für Straight Key Eingang
|
||||||
|
uint8_t WinkeyerEnabled; // Winkeyer2 Emulation
|
||||||
} bConfig;
|
} bConfig;
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
void Init(void);
|
void Init(void);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
@ -7,24 +6,13 @@ int8_t DrehgeberPosition;
|
|||||||
int8_t DrehgeberMax = 127;
|
int8_t DrehgeberMax = 127;
|
||||||
int8_t DrehgeberMin = -127;
|
int8_t DrehgeberMin = -127;
|
||||||
|
|
||||||
#define DDR(x) (*(&x-1))
|
|
||||||
#define Port(x) (*(&x))
|
|
||||||
#define PIN(x) (*(&x-2))
|
|
||||||
|
|
||||||
#define PHASE_A PIN(ENC_A_PORT) & (1<<ENC_A_PIN)
|
|
||||||
#define PHASE_B PIN(ENC_B_PORT) & (1<<ENC_B_PIN)
|
|
||||||
#define BUTTONPRESSED (!(PIN(ENC_T_PORT) & (1<<ENC_T_PIN)))
|
|
||||||
|
|
||||||
#define BUTTON_DEBOUNCETIME_MS 30
|
|
||||||
#define BUTTON_PRESSEDLONG_MS 1000
|
|
||||||
|
|
||||||
volatile int8_t enc_delta;
|
|
||||||
static int8_t last;
|
|
||||||
|
|
||||||
volatile int16_t iButtonPressedCounter = 0;
|
volatile int16_t iButtonPressedCounter = 0;
|
||||||
volatile int16_t iButtonDebounceCycles = 0;
|
volatile int16_t iButtonDebounceCycles = 0;
|
||||||
volatile int16_t iButtonPressedLongCycles = 0;
|
volatile int16_t iButtonPressedLongCycles = 0;
|
||||||
|
|
||||||
|
volatile int8_t enc_delta;
|
||||||
|
static int8_t last;
|
||||||
|
|
||||||
typedef enum EButtonState
|
typedef enum EButtonState
|
||||||
{
|
{
|
||||||
ButtonState_Unpressed,
|
ButtonState_Unpressed,
|
||||||
@ -77,15 +65,18 @@ void EncoderPolling(void)
|
|||||||
if(iButtonPressedCounter >= iButtonDebounceCycles && (! BUTTONPRESSED))
|
if(iButtonPressedCounter >= iButtonDebounceCycles && (! BUTTONPRESSED))
|
||||||
{
|
{
|
||||||
buttonState = ButtonState_Released;
|
buttonState = ButtonState_Released;
|
||||||
if(buttonPressed != ButtonPressed_Long) buttonPressed = ButtonPressed_Short;
|
if(buttonPressed != ButtonPressed_Long)
|
||||||
|
buttonPressed = ButtonPressed_Short;
|
||||||
}
|
}
|
||||||
if(iButtonPressedCounter >= iButtonPressedLongCycles)
|
if(iButtonPressedCounter >= iButtonPressedLongCycles)
|
||||||
{
|
{
|
||||||
|
buttonState = ButtonState_Released;
|
||||||
buttonPressed = ButtonPressed_Long;
|
buttonPressed = ButtonPressed_Long;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonState_Released:
|
case ButtonState_Released:
|
||||||
iButtonPressedCounter = 0;
|
iButtonPressedCounter = 0;
|
||||||
|
if(!BUTTONPRESSED)
|
||||||
buttonState = ButtonState_Unpressed;
|
buttonState = ButtonState_Unpressed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,24 @@
|
|||||||
#define ENC_T_PORT PORTB /**< port for button */
|
#define ENC_T_PORT PORTB /**< port for button */
|
||||||
#define ENC_T_PIN PB2 /**< pin for button */
|
#define ENC_T_PIN PB2 /**< pin for button */
|
||||||
|
|
||||||
|
#define DDR(x) (*(&x-1))
|
||||||
|
#define Port(x) (*(&x))
|
||||||
|
#define PIN(x) (*(&x-2))
|
||||||
|
|
||||||
|
#define PHASE_A PIN(ENC_A_PORT) & (1<<ENC_A_PIN)
|
||||||
|
#define PHASE_B PIN(ENC_B_PORT) & (1<<ENC_B_PIN)
|
||||||
|
#define BUTTONPRESSED (!(PIN(ENC_T_PORT) & (1<<ENC_T_PIN)))
|
||||||
|
|
||||||
|
#define BUTTON_DEBOUNCETIME_MS 30
|
||||||
|
#define BUTTON_PRESSEDLONG_MS 250
|
||||||
|
|
||||||
typedef enum EButtonPressedState
|
typedef enum EButtonPressedState
|
||||||
{
|
{
|
||||||
ButtonPressed_Unpressed,
|
ButtonPressed_Unpressed,
|
||||||
ButtonPressed_Short,
|
ButtonPressed_Short,
|
||||||
ButtonPressed_Long
|
ButtonPressed_Long
|
||||||
|
|
||||||
}tEButtonPressedState;
|
}tEButtonPressedState;
|
||||||
|
|
||||||
// Initialisiert den Encoder und aktiviert den Interrupt + Timer
|
// Initialisiert den Encoder und aktiviert den Interrupt + Timer
|
||||||
void EncoderInit( void );
|
void EncoderInit( void );
|
||||||
// Liest die Position des Encoders aus
|
// Liest die Position des Encoders aus
|
||||||
|
@ -39,37 +39,41 @@ void ResetMilliSeconds(void)
|
|||||||
|
|
||||||
/** \brief EEPROM schreiben
|
/** \brief EEPROM schreiben
|
||||||
*/
|
*/
|
||||||
void WriteEEProm(void)
|
void WriteEEprom(void)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
eeprom_write_byte(&ee_dummy,0x55);
|
eeprom_write_byte(&ee_Dummy,0x55);
|
||||||
eeprom_write_byte(&ee_wpm, bConfig.wpm);
|
eeprom_write_byte(&ee_WpM, bConfig.WpM);
|
||||||
eeprom_write_byte(&ee_iambic, bConfig.iambic);
|
eeprom_write_byte(&ee_IambicMode, bConfig.IambicMode);
|
||||||
eeprom_write_word(&ee_sidetone_f, bConfig.sidetone_f);
|
eeprom_write_word(&ee_FrequencySidetone, bConfig.FrequencySidetone);
|
||||||
eeprom_write_byte(&ee_trx, bConfig.trx);
|
eeprom_write_byte(&ee_TRX, bConfig.TRX);
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadEEProm(void)
|
void ReadEEprom(void)
|
||||||
{
|
{
|
||||||
// wpm = eeprom_read_byte(&ee_wpm);
|
// wpm = eeprom_read_byte(&ee_wpm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteEEProm_WpM(void)
|
void WriteEEpromWpM(void)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
eeprom_write_byte(&ee_wpm, bConfig.wpm);
|
sprintf(sdebug," %i WpM in EEprom schreiben\r\n",bConfig.WpM);
|
||||||
|
SendSerialString(sdebug);
|
||||||
|
eeprom_write_byte(&ee_WpM, bConfig.WpM);
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadEEProm_WpM(void)
|
void ReadEEpromWpM(void)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
bConfig.wpm = eeprom_read_byte(&ee_wpm);
|
bConfig.WpM = eeprom_read_byte(&ee_WpM);
|
||||||
sei();
|
sei();
|
||||||
if(bConfig.wpm > 50) {
|
sprintf(sdebug," %i WpM von EEprom gelesen\r\n",bConfig.WpM);
|
||||||
bConfig.wpm = 15;
|
SendSerialString(sdebug);
|
||||||
WriteEEProm_WpM();
|
if(bConfig.WpM > 50) {
|
||||||
|
bConfig.WpM = 15;
|
||||||
|
WriteEEpromWpM();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +103,8 @@ uint8_t ReadKeyPin(uint8_t pin)
|
|||||||
void SideToneOn(void)
|
void SideToneOn(void)
|
||||||
{
|
{
|
||||||
state_sidetoneoff = 0;
|
state_sidetoneoff = 0;
|
||||||
StateRisetime = bConfig.Risetime;
|
StateRiseTime = bConfig.RiseTime;
|
||||||
StateRisetimeCounter = 0;
|
StateRiseTimeCounter = 0;
|
||||||
icnt = 0;
|
icnt = 0;
|
||||||
sbi(TIMSK1,OCIE1A);
|
sbi(TIMSK1,OCIE1A);
|
||||||
}
|
}
|
||||||
@ -110,8 +114,8 @@ void SideToneOn(void)
|
|||||||
void SideToneOff(void)
|
void SideToneOff(void)
|
||||||
{
|
{
|
||||||
state_sidetoneoff = 1;
|
state_sidetoneoff = 1;
|
||||||
StateRisetime = 0;
|
StateRiseTime = 0;
|
||||||
StateRisetimeCounter = 0;
|
StateRiseTimeCounter = 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
** TXSidetoneKey
|
** TXSidetoneKey
|
||||||
@ -148,10 +152,21 @@ void TXSidetoneKey(uint8_t State, uint8_t SendingType)
|
|||||||
void CheckStraightKey(void)
|
void CheckStraightKey(void)
|
||||||
{
|
{
|
||||||
if(PIND & (1<<STRAIGHT_KEY))
|
if(PIND & (1<<STRAIGHT_KEY))
|
||||||
|
{
|
||||||
TXSidetoneKey(0,MANUAL_SENDING);
|
TXSidetoneKey(0,MANUAL_SENDING);
|
||||||
else
|
StateStraightKeyPressed = 0;
|
||||||
|
} else {
|
||||||
|
if(StateStraightKeyPressed == 0)
|
||||||
|
{
|
||||||
|
StateStraightKeyPressed = 1;
|
||||||
|
TimerStraightKeyPressed = 0;
|
||||||
|
}
|
||||||
|
if(StateStraightKeyPressed == 2)
|
||||||
|
{
|
||||||
TXSidetoneKey(1,MANUAL_SENDING);
|
TXSidetoneKey(1,MANUAL_SENDING);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/** \brief CheckPaddles
|
/** \brief CheckPaddles
|
||||||
* Original code K3NG keyer line 5654
|
* Original code K3NG keyer line 5654
|
||||||
*
|
*
|
||||||
@ -234,10 +249,6 @@ void CheckPaddles(void)
|
|||||||
*/
|
*/
|
||||||
long ServiceStraightKey(void)
|
long ServiceStraightKey(void)
|
||||||
{
|
{
|
||||||
long l;
|
|
||||||
static uint8_t last_straight_key_state = 0;
|
|
||||||
|
|
||||||
return l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,9 +299,9 @@ void SendDit(uint8_t SendingType)
|
|||||||
{
|
{
|
||||||
SendStatus = SENDING_DIT;
|
SendStatus = SENDING_DIT;
|
||||||
TXSidetoneKey(1,SendingType);
|
TXSidetoneKey(1,SendingType);
|
||||||
Loop(1,0,wpm,SendingType);
|
Loop(1,0,WpM,SendingType);
|
||||||
TXSidetoneKey(0,SendingType);
|
TXSidetoneKey(0,SendingType);
|
||||||
Loop(1,0,wpm,SendingType);
|
Loop(1,0,WpM,SendingType);
|
||||||
}
|
}
|
||||||
/** \brief Send a dah
|
/** \brief Send a dah
|
||||||
** A Dah with weight = 50 has the length of 3 Dits.
|
** A Dah with weight = 50 has the length of 3 Dits.
|
||||||
@ -299,9 +310,9 @@ void SendDah(uint8_t SendingType)
|
|||||||
{
|
{
|
||||||
SendStatus = SENDING_DAH;
|
SendStatus = SENDING_DAH;
|
||||||
TXSidetoneKey(1,SendingType);
|
TXSidetoneKey(1,SendingType);
|
||||||
Loop(3,0,wpm,SendingType);
|
Loop(3,0,WpM,SendingType);
|
||||||
TXSidetoneKey(0,SendingType);
|
TXSidetoneKey(0,SendingType);
|
||||||
Loop(1,0,wpm,SendingType);
|
Loop(1,0,WpM,SendingType);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
** Set sidetone frequency
|
** Set sidetone frequency
|
||||||
@ -322,6 +333,7 @@ void Tone(uint16_t f, uint8_t duration)
|
|||||||
SideToneOn();
|
SideToneOn();
|
||||||
delayms(duration);
|
delayms(duration);
|
||||||
SideToneOff();
|
SideToneOff();
|
||||||
|
SetFrequency(bConfig.FrequencySidetone);
|
||||||
}
|
}
|
||||||
void Boop(void)
|
void Boop(void)
|
||||||
{
|
{
|
||||||
@ -392,7 +404,7 @@ void SendChar(unsigned char c)
|
|||||||
// ***TODO Sonderzeichen
|
// ***TODO Sonderzeichen
|
||||||
|
|
||||||
}
|
}
|
||||||
Loop(3,0,wpm,AUTOMATIC);
|
Loop(3,0,WpM,AUTOMATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,9 +24,12 @@ void IntEnable(void);
|
|||||||
|
|
||||||
|
|
||||||
// EEPROM
|
// EEPROM
|
||||||
void WriteEEProm(void);
|
void WriteEEprom(void);
|
||||||
void ReadEEProm(void);
|
void ReadEEprom(void);
|
||||||
void WriteEEProm_WpM(void);
|
void WriteEEpromWpM(void);
|
||||||
void ReadEEProm_WpM(void);
|
void ReadEEpromWpM(void);
|
||||||
|
|
||||||
|
// Serielle Schnittstelle
|
||||||
|
void SendSerialString(char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
229
Source/main.c
229
Source/main.c
@ -18,6 +18,7 @@
|
|||||||
2022-09-02 DL7BJ viele Softwareänderungen, neuer Filter für PWM
|
2022-09-02 DL7BJ viele Softwareänderungen, neuer Filter für PWM
|
||||||
2022-09-11 DL7BJ Encoder, LC-Display, Frontplatine "entsorgt"
|
2022-09-11 DL7BJ Encoder, LC-Display, Frontplatine "entsorgt"
|
||||||
2023-06-28 DL7BJ Port Anpassungen an neue Leiterplatte V1.01
|
2023-06-28 DL7BJ Port Anpassungen an neue Leiterplatte V1.01
|
||||||
|
2023-07-29 DL7BJ Menü für Einstellungen implementiert
|
||||||
|
|
||||||
ATMEGA328(P)
|
ATMEGA328(P)
|
||||||
----------
|
----------
|
||||||
@ -159,7 +160,7 @@ void Init()
|
|||||||
cbi(PORTD,RIGHT_PADDLE);
|
cbi(PORTD,RIGHT_PADDLE);
|
||||||
cbi(PORTD,STRAIGHT_KEY);
|
cbi(PORTD,STRAIGHT_KEY);
|
||||||
|
|
||||||
t_element_length = (uint16_t)1200/bConfig.wpm;
|
t_element_length = (uint16_t)1200/bConfig.WpM;
|
||||||
|
|
||||||
// Pin Change Interrupts Port D - Keys
|
// Pin Change Interrupts Port D - Keys
|
||||||
// PD4 - StraightKey - PCINT20 - Pin Change Interrupt 20
|
// PD4 - StraightKey - PCINT20 - Pin Change Interrupt 20
|
||||||
@ -186,20 +187,22 @@ void Init()
|
|||||||
bMenuCtrl.Update = 1;
|
bMenuCtrl.Update = 1;
|
||||||
bMenuCtrl.Config = 0;
|
bMenuCtrl.Config = 0;
|
||||||
bMenuCtrl.buttonPressed = 0;
|
bMenuCtrl.buttonPressed = 0;
|
||||||
bMenuCtrl.WriteEEProm = 0;
|
bMenuCtrl.WriteEEprom = 0;
|
||||||
bMenuCtrl.buttonPressedLong = 0;
|
bMenuCtrl.buttonPressedLong = 0;
|
||||||
// Initialisierung Konfiguration
|
// Initialisierung Konfiguration
|
||||||
bConfig.iambic = 1;
|
bConfig.IambicMode = 1;
|
||||||
bConfig.sidetone_f = 600;
|
bConfig.FrequencySidetone = 600;
|
||||||
bConfig.sidetone = 1;
|
bConfig.SidetoneEnabled = 1;
|
||||||
bConfig.trx = 0;
|
bConfig.TRX = 0;
|
||||||
bConfig.weight = 50;
|
bConfig.Weight = 50;
|
||||||
bConfig.wpmbpm = 1;
|
bConfig.WpMBpM = 1;
|
||||||
bConfig.wpm = 15;
|
bConfig.WpM = 12;
|
||||||
bConfig.ratio = 30;
|
bConfig.Ratio = 30;
|
||||||
bConfig.reverse = 0;
|
bConfig.Reverse = 0;
|
||||||
bConfig.Risetime = 4;
|
bConfig.RiseTime = 6;
|
||||||
bConfig.RisetimeCounter = 4;
|
bConfig.RiseTimeCounter = 6;
|
||||||
|
bConfig.DebounceTime = 5;
|
||||||
|
bConfig.WinkeyerEnabled = 0;
|
||||||
sei(); // enable all interrupts
|
sei(); // enable all interrupts
|
||||||
}
|
}
|
||||||
/** \brief 16 Bit Timer 1A
|
/** \brief 16 Bit Timer 1A
|
||||||
@ -218,8 +221,8 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
{
|
{
|
||||||
ocr2a = pgm_read_byte_near(sinewave+icnt);
|
ocr2a = pgm_read_byte_near(sinewave+icnt);
|
||||||
icnt++;
|
icnt++;
|
||||||
if(StateRisetime > 0)
|
if(StateRiseTime > 0)
|
||||||
OCR2A = (ocr2a >> StateRisetime);
|
OCR2A = (ocr2a >> StateRiseTime);
|
||||||
else
|
else
|
||||||
OCR2A = ocr2a;
|
OCR2A = ocr2a;
|
||||||
|
|
||||||
@ -228,20 +231,20 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
icnt = 0;
|
icnt = 0;
|
||||||
if(state_sidetoneoff == 0)
|
if(state_sidetoneoff == 0)
|
||||||
{
|
{
|
||||||
if(StateRisetime > 0)
|
if(StateRiseTime > 0)
|
||||||
{
|
{
|
||||||
StateRisetimeCounter++;
|
StateRiseTimeCounter++;
|
||||||
if(StateRisetimeCounter > bConfig.RisetimeCounter)
|
if(StateRiseTimeCounter > bConfig.RiseTimeCounter)
|
||||||
StateRisetime--;
|
StateRiseTime--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(state_sidetoneoff == 1)
|
if(state_sidetoneoff == 1)
|
||||||
{
|
{
|
||||||
if(StateRisetime < bConfig.Risetime)
|
if(StateRiseTime < bConfig.RiseTime)
|
||||||
{
|
{
|
||||||
StateRisetimeCounter++;
|
StateRiseTimeCounter++;
|
||||||
if(StateRisetimeCounter > bConfig.RisetimeCounter)
|
if(StateRiseTimeCounter > bConfig.RiseTimeCounter)
|
||||||
StateRisetime++;
|
StateRiseTime++;
|
||||||
} else {
|
} else {
|
||||||
OCR2A = 0;
|
OCR2A = 0;
|
||||||
cbi(TIMSK1,OCIE1A);
|
cbi(TIMSK1,OCIE1A);
|
||||||
@ -259,41 +262,51 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
*/
|
*/
|
||||||
ISR(TIMER0_COMPA_vect)
|
ISR(TIMER0_COMPA_vect)
|
||||||
{
|
{
|
||||||
ms++;
|
ms++; // allgemeiner Millisekundenzähler
|
||||||
StoreEEprom++;
|
StoreEEprom++; // Zähler für Zeitablauf speichern EEprom
|
||||||
MenuCtrlTimer++;
|
MenuCtrlTimer++; // Zähler für Zeitablauf Einstellungen
|
||||||
|
EncoderTimer++; // Zähler für 5ms Drehencoder Timer
|
||||||
|
|
||||||
mselement++; // element length of dit or dat
|
mselement++; // element length of dit or dat
|
||||||
|
|
||||||
t_wait++;
|
t_wait++;
|
||||||
l_timer++;
|
l_timer++;
|
||||||
encoder_timer++;
|
|
||||||
|
|
||||||
if(l_timer >= L_WAIT){
|
if(l_timer >= L_WAIT)
|
||||||
|
{
|
||||||
l_timer = 0;
|
l_timer = 0;
|
||||||
}
|
}
|
||||||
// Alle 5ms den Drehencoder abfragen
|
// Alle 5ms den Drehencoder abfragen
|
||||||
if(encoder_timer > 5) {
|
if(EncoderTimer > 5)
|
||||||
|
{
|
||||||
|
EncoderTimer = 0;
|
||||||
EncoderPolling();
|
EncoderPolling();
|
||||||
// Schalter vom Drehencoder abfragen
|
// Schalter vom Drehencoder abfragen
|
||||||
if(EncoderGetButtonState() == ButtonPressed_Short)
|
lastButton = EncoderGetButtonState();
|
||||||
|
if(lastButton == ButtonPressed_Short)
|
||||||
{
|
{
|
||||||
bMenuCtrl.buttonPressed = 1;
|
bMenuCtrl.buttonPressed = 1;
|
||||||
SendSerialString("Button pressed short\r\n");
|
SendSerialString("Encoder Button pressed short\r\n");
|
||||||
}
|
}
|
||||||
if(EncoderGetButtonState() == ButtonPressed_Long)
|
if(lastButton == ButtonPressed_Long)
|
||||||
{
|
{
|
||||||
bMenuCtrl.buttonPressedLong = 1;
|
bMenuCtrl.buttonPressedLong = 1;
|
||||||
SendSerialString("Button pressed long\r\n");
|
SendSerialString("Encoder Button pressed long\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Wpm verändert?
|
// WpM verändert? Nach einer Sekunde im EEPROM Speichern
|
||||||
if((StoreEEprom > 1000) && (bMerker.WpMChanged))
|
if((StoreEEprom > 1000) && (bMerker.WpMChanged))
|
||||||
{
|
{
|
||||||
StoreEEprom = 0;
|
bMerker.WriteWpMEEprom = 1;
|
||||||
bMerker.WriteWpMEEProm = 1;
|
|
||||||
bMerker.WpMChanged = 0;
|
bMerker.WpMChanged = 0;
|
||||||
}
|
}
|
||||||
|
// Softwareentprellung für StraightKey
|
||||||
|
TimerStraightKeyPressed++;
|
||||||
|
if(StateStraightKeyPressed == 1)
|
||||||
|
{
|
||||||
|
if(TimerStraightKeyPressed > bConfig.DebounceTime)
|
||||||
|
StateStraightKeyPressed = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Konfiguration nach 3 Sekunden verlassen
|
// Konfiguration nach 3 Sekunden verlassen
|
||||||
// if((MenuCtrlTimer > 3000) && (bMenuCtrl.Config == 1))
|
// if((MenuCtrlTimer > 3000) && (bMenuCtrl.Config == 1))
|
||||||
// {
|
// {
|
||||||
@ -428,7 +441,9 @@ void ConfigMenue(void)
|
|||||||
|
|
||||||
lcd_charMode(NORMAL);
|
lcd_charMode(NORMAL);
|
||||||
lcd_gotoxy(0,0);
|
lcd_gotoxy(0,0);
|
||||||
sprintf(line,"%s - %i","Konfiguration", bMenuCtrl.CurMenue);
|
lcd_puts(CLEARLINE);
|
||||||
|
lcd_gotoxy(0,0);
|
||||||
|
sprintf(line,"%s - %i","Einstellungen", bMenuCtrl.CurMenue);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
lcd_charMode(DOUBLESIZE);
|
lcd_charMode(DOUBLESIZE);
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
@ -437,7 +452,7 @@ void ConfigMenue(void)
|
|||||||
{
|
{
|
||||||
case M_TRX1:
|
case M_TRX1:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if((bConfig.trx == 1) || (bConfig.trx == 0))
|
if((bConfig.TRX == 1) || (bConfig.TRX == 0))
|
||||||
sprintf(line,"[%s]", "TRX 1");
|
sprintf(line,"[%s]", "TRX 1");
|
||||||
else
|
else
|
||||||
sprintf(line," %s ", "TRX 1");
|
sprintf(line," %s ", "TRX 1");
|
||||||
@ -445,7 +460,7 @@ void ConfigMenue(void)
|
|||||||
break;
|
break;
|
||||||
case M_TRX2:
|
case M_TRX2:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if((bConfig.trx == 2) || (bConfig.trx == 0))
|
if((bConfig.TRX == 2) || (bConfig.TRX == 0))
|
||||||
sprintf(line,"[%s]", "TRX 2");
|
sprintf(line,"[%s]", "TRX 2");
|
||||||
else
|
else
|
||||||
sprintf(line," %s ", "TRX 2");
|
sprintf(line," %s ", "TRX 2");
|
||||||
@ -453,47 +468,47 @@ void ConfigMenue(void)
|
|||||||
break;
|
break;
|
||||||
case M_IAMBICA:
|
case M_IAMBICA:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.iambic == 1)
|
if(bConfig.IambicMode == 1)
|
||||||
sprintf(line,"[%s]", "Iambic A");
|
sprintf(line,"[%s]", IambicA);
|
||||||
else
|
else
|
||||||
sprintf(line,"%s", "Iambic A");
|
sprintf(line," %s ", IambicB);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
case M_IAMBICB:
|
case M_IAMBICB:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.iambic == 2)
|
if(bConfig.IambicMode == 2)
|
||||||
sprintf(line,"[%s]", "Iambic B");
|
sprintf(line,"[%s]", IambicB);
|
||||||
else
|
else
|
||||||
sprintf(line,"%s", "Iambic B");
|
sprintf(line," %s ", IambicB);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
case M_REVERSE:
|
case M_REVERSE:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.reverse == 0)
|
if(bConfig.Reverse == 0)
|
||||||
sprintf(line,"%s", "L . R -");
|
sprintf(line,"%s", ReverseLR);
|
||||||
else
|
else
|
||||||
sprintf(line,"%s", "L - R .");
|
sprintf(line,"%s", ReverseRL);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
case M_RATIO:
|
case M_RATIO:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.ratio == 30)
|
if(bConfig.Ratio == 30)
|
||||||
sprintf(line,"%s", "Ratio 3:1");
|
sprintf(line,"%s", "Ratio 3:1");
|
||||||
else
|
else
|
||||||
sprintf(line,"%s %f:1", "Ratio", bConfig.ratio/10);
|
sprintf(line,"%s %i:1", "Ratio", bConfig.Ratio/10);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
case M_TON_FREQ:
|
case M_TON_FREQ:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.sidetone_f == 650)
|
if(bConfig.FrequencySidetone == 650)
|
||||||
sprintf(line,"%s", "Ton 650Hz");
|
sprintf(line,"%s", "Ton 650Hz");
|
||||||
else
|
else
|
||||||
sprintf(line,"%s %uHz", "Ton", bConfig.sidetone_f);
|
sprintf(line,"%s %uHz", "Ton", bConfig.FrequencySidetone);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
case M_TON:
|
case M_TON:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.ratio == 1)
|
if(bConfig.SidetoneEnabled == 1)
|
||||||
sprintf(line,"%s", "Ton an");
|
sprintf(line,"%s", "Ton an");
|
||||||
else
|
else
|
||||||
sprintf(line,"%s", "Ton aus");
|
sprintf(line,"%s", "Ton aus");
|
||||||
@ -501,12 +516,22 @@ void ConfigMenue(void)
|
|||||||
break;
|
break;
|
||||||
case M_WPMBPM:
|
case M_WPMBPM:
|
||||||
lcd_gotoxy(0,3);
|
lcd_gotoxy(0,3);
|
||||||
if(bConfig.wpmbpm == 0)
|
if(bConfig.WpMBpM == 0)
|
||||||
sprintf(line,"%s", "WpM");
|
sprintf(line,"%s", "WpM");
|
||||||
else
|
else
|
||||||
sprintf(line,"%s", "BpM");
|
sprintf(line,"%s", "BpM");
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
break;
|
break;
|
||||||
|
case M_RISETIME:
|
||||||
|
lcd_gotoxy(0,3);
|
||||||
|
sprintf(line,"%s %ims",RiseTime, bConfig.RiseTime);
|
||||||
|
lcd_puts(line);
|
||||||
|
break;
|
||||||
|
case M_DEBOUNCE:
|
||||||
|
lcd_gotoxy(0,3);
|
||||||
|
sprintf(line,"%s %ims",DebounceTime, bConfig.DebounceTime);
|
||||||
|
lcd_puts(line);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
bMenuCtrl.Update = 0;
|
bMenuCtrl.Update = 0;
|
||||||
lcd_charMode(NORMAL);
|
lcd_charMode(NORMAL);
|
||||||
@ -528,29 +553,30 @@ void UpdateDisplay(void)
|
|||||||
{
|
{
|
||||||
lcd_clrscr();
|
lcd_clrscr();
|
||||||
bMenuCtrl.ClrScr = 0;
|
bMenuCtrl.ClrScr = 0;
|
||||||
|
bMenuCtrl.Update = 1;
|
||||||
}
|
}
|
||||||
if(!(bMenuCtrl.Config))
|
if(!(bMenuCtrl.Config))
|
||||||
{
|
{
|
||||||
lcd_charMode(DOUBLESIZE);
|
lcd_charMode(DOUBLESIZE);
|
||||||
lcd_gotoxy(4,3);
|
lcd_gotoxy(4,3);
|
||||||
if(bConfig.wpmbpm)
|
if(bConfig.WpMBpM)
|
||||||
sprintf(line,"%i WpM ",bConfig.wpm);
|
sprintf(line,"%i WpM ",bConfig.WpM);
|
||||||
else
|
else
|
||||||
sprintf(line,"%i BpM ", bConfig.wpm*5);
|
sprintf(line,"%i BpM ", bConfig.WpM*5);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
lcd_charMode(NORMAL);
|
lcd_charMode(NORMAL);
|
||||||
lcd_gotoxy(13,0);
|
lcd_gotoxy(13,0);
|
||||||
if(bConfig.iambic == 1)
|
if(bConfig.IambicMode == 1)
|
||||||
sprintf(line,"%s", IambicA);
|
sprintf(line,"%s", IambicA);
|
||||||
if(bConfig.iambic == 2)
|
if(bConfig.IambicMode == 2)
|
||||||
sprintf(line,"%s", IambicB);
|
sprintf(line,"%s", IambicB);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
lcd_gotoxy(0,0);
|
lcd_gotoxy(0,0);
|
||||||
if(bConfig.trx == 1)
|
if(bConfig.TRX == 1)
|
||||||
sprintf(line, "%s", Trx1);
|
sprintf(line, "%s", Trx1);
|
||||||
if(bConfig.trx == 2)
|
if(bConfig.TRX == 2)
|
||||||
sprintf(line, "%s", Trx2);
|
sprintf(line, "%s", Trx2);
|
||||||
if(bConfig.trx == 0)
|
if(bConfig.TRX == 0)
|
||||||
sprintf(line, "%s %s", Trx1, Trx2);
|
sprintf(line, "%s %s", Trx1, Trx2);
|
||||||
lcd_puts(line);
|
lcd_puts(line);
|
||||||
}
|
}
|
||||||
@ -570,11 +596,16 @@ void Drehencoder(void)
|
|||||||
{
|
{
|
||||||
EncoderMinMax(5,50);
|
EncoderMinMax(5,50);
|
||||||
st = EncoderRead(1);
|
st = EncoderRead(1);
|
||||||
if(bConfig.wpm != st)
|
if(bConfig.WpM != st)
|
||||||
{
|
{
|
||||||
bConfig.wpm = st;
|
bConfig.WpM = st; // neuen Wert in bConfig speichern
|
||||||
bMerker.WpMChanged = 1;
|
bMerker.WpMChanged = 1; // Merker für Timer 0 setzen
|
||||||
bMenuCtrl.Update = 1;
|
bMenuCtrl.Update = 1; // Merker für UpdateDisplay setzen
|
||||||
|
EncoderPos = st; // neuen Werte in EncoderPos speichern
|
||||||
|
WpM = bConfig.WpM; // neuen Wert in WpM übernehmen
|
||||||
|
cli();
|
||||||
|
StoreEEprom = 0; // Timer 0 Variable löschen für Update EEprom
|
||||||
|
sei();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,6 +614,10 @@ void Drehencoder(void)
|
|||||||
bMenuCtrl.Config = 1;
|
bMenuCtrl.Config = 1;
|
||||||
MenuCtrlTimer = 0;
|
MenuCtrlTimer = 0;
|
||||||
bMenuCtrl.buttonPressed = 0;
|
bMenuCtrl.buttonPressed = 0;
|
||||||
|
EncoderPos = EncoderRead(1);
|
||||||
|
bMenuCtrl.CurMenue = EncoderPosConfig;
|
||||||
|
EncoderWrite(EncoderPosConfig);
|
||||||
|
bMenuCtrl.Update = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((bMenuCtrl.buttonPressedLong == 1) && (bMenuCtrl.Config == 1))
|
if((bMenuCtrl.buttonPressedLong == 1) && (bMenuCtrl.Config == 1))
|
||||||
@ -592,8 +627,11 @@ void Drehencoder(void)
|
|||||||
bMenuCtrl.buttonPressedLong = 0;
|
bMenuCtrl.buttonPressedLong = 0;
|
||||||
bMenuCtrl.buttonPressed = 0;
|
bMenuCtrl.buttonPressed = 0;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
|
||||||
MenuCtrlTimer = 0;
|
MenuCtrlTimer = 0;
|
||||||
|
EncoderPosConfig = EncoderRead(1);
|
||||||
|
EncoderWrite(EncoderPos);
|
||||||
|
bMenuCtrl.ClrScr = 1;
|
||||||
|
Beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bMenuCtrl.Config == 1)
|
if(bMenuCtrl.Config == 1)
|
||||||
@ -603,9 +641,9 @@ void Drehencoder(void)
|
|||||||
EncoderMinMax(1,M_MAX);
|
EncoderMinMax(1,M_MAX);
|
||||||
st = EncoderRead(1);
|
st = EncoderRead(1);
|
||||||
sprintf(sdebug,"Encoder %i\r\n",st);
|
sprintf(sdebug,"Encoder %i\r\n",st);
|
||||||
SendSerialString(sdebug);
|
|
||||||
if(last != st)
|
if(last != st)
|
||||||
{
|
{
|
||||||
|
SendSerialString(sdebug);
|
||||||
bMenuCtrl.CurMenue = st;
|
bMenuCtrl.CurMenue = st;
|
||||||
bMenuCtrl.Update = 1;
|
bMenuCtrl.Update = 1;
|
||||||
}
|
}
|
||||||
@ -624,40 +662,45 @@ void Drehencoder(void)
|
|||||||
switch(bMenuCtrl.CurMenue)
|
switch(bMenuCtrl.CurMenue)
|
||||||
{
|
{
|
||||||
case M_TRX1:
|
case M_TRX1:
|
||||||
if(bConfig.trx == 2)
|
if(bConfig.TRX == 2)
|
||||||
bConfig.trx = 0;
|
bConfig.TRX = 0;
|
||||||
else
|
else
|
||||||
bConfig.trx = 1;
|
bConfig.TRX = 1;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
break;
|
break;
|
||||||
case M_TRX2:
|
case M_TRX2:
|
||||||
if(bConfig.trx == 1)
|
if(bConfig.TRX == 1)
|
||||||
bConfig.trx = 0;
|
bConfig.TRX = 0;
|
||||||
else
|
else
|
||||||
bConfig.trx = 2;
|
bConfig.TRX = 2;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
break;
|
break;
|
||||||
case M_IAMBICA:
|
case M_IAMBICA:
|
||||||
bConfig.iambic = 1;
|
bConfig.IambicMode = 1;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
break;
|
break;
|
||||||
case M_IAMBICB:
|
case M_IAMBICB:
|
||||||
bConfig.iambic = 2;
|
bConfig.IambicMode = 2;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
break;
|
break;
|
||||||
case M_REVERSE:
|
case M_REVERSE:
|
||||||
if(bConfig.reverse == 1)
|
if(bConfig.Reverse == 1)
|
||||||
bConfig.reverse = 0;
|
bConfig.Reverse = 0;
|
||||||
else
|
else
|
||||||
bConfig.reverse = 1;
|
bConfig.Reverse = 1;
|
||||||
bMenuCtrl.m_buttonPressed = 0;
|
bMenuCtrl.m_buttonPressed = 0;
|
||||||
|
if(bConfig.Reverse == 1)
|
||||||
|
PaddleMode = PADDLE_REVERSE;
|
||||||
|
else
|
||||||
|
PaddleMode = PADDLE_NORMAL;
|
||||||
|
bMenuCtrl.Update = 1;
|
||||||
break;
|
break;
|
||||||
case M_RATIO:
|
case M_RATIO:
|
||||||
EncoderMinMax(15,30);
|
EncoderMinMax(15,30);
|
||||||
st = EncoderRead(1);
|
st = EncoderRead(1);
|
||||||
bConfig.ratio = st;
|
bConfig.Ratio = st;
|
||||||
if(bConfig.ratio > 30) bConfig.ratio = 30;
|
if(bConfig.Ratio > 30) bConfig.Ratio = 30;
|
||||||
if(bConfig.ratio < 15) bConfig.ratio = 15;
|
if(bConfig.Ratio < 15) bConfig.Ratio = 15;
|
||||||
bMenuCtrl.Update = 1;
|
bMenuCtrl.Update = 1;
|
||||||
break;
|
break;
|
||||||
case M_TON_FREQ:
|
case M_TON_FREQ:
|
||||||
@ -687,21 +730,29 @@ int main(void)
|
|||||||
|
|
||||||
MachineMode = NORMAL;
|
MachineMode = NORMAL;
|
||||||
KeyerMode = IAMBIC_A;
|
KeyerMode = IAMBIC_A;
|
||||||
ReadEEProm_WpM();
|
|
||||||
|
|
||||||
SendSerialString(CLRSCR);
|
SendSerialString(CLRSCR);
|
||||||
SendSerialString("BJ-Keyer V1.00\r\n");
|
SendSerialString("BJ-Keyer V1.00\r\n");
|
||||||
SendSerialString("Ready!\r\n");
|
SendSerialString("Ready!\r\n");
|
||||||
EncoderWrite(bConfig.wpm);
|
|
||||||
|
ReadEEpromWpM();
|
||||||
|
WpM = bConfig.WpM;
|
||||||
|
EncoderPos = bConfig.WpM;
|
||||||
|
EncoderWrite(bConfig.WpM);
|
||||||
|
EncoderPosConfig = 1;
|
||||||
|
|
||||||
SetFrequency(600);
|
SetFrequency(600);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
Drehencoder();
|
Drehencoder();
|
||||||
|
// Wenn Geschwindigkeit verändert und Zeit abgelaufen,
|
||||||
if(bMerker.WriteWpMEEProm)
|
// dann im EEprom speichern und Merker löschen.
|
||||||
WriteEEProm_WpM();
|
if(bMerker.WriteWpMEEprom)
|
||||||
|
{
|
||||||
|
sprintf(" %i WpM in EEprom speichern\r\n", bConfig.WpM);
|
||||||
|
WriteEEpromWpM();
|
||||||
|
bMerker.WriteWpMEEprom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
|
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren