Es wird vorerst keine Winkeyer Emulation geben, da ich die Funktion
nicht benötige. Der Wert im EEprom wurde zu geschwindigkeitsabhängigem Punkt/Strich Verhältnis geändert. Die Berechnung muss noch in SetRatio() erfolgen. Anzeige auf dem Display geändert, es wird nun das eingestellte Punkt/Strich Verhältnis und der Punkt/Strich Speicherstatus anzeigt. Dokumentation ergänzt.
Dieser Commit ist enthalten in:
		
							Ursprung
							
								
									ffeece7d9e
								
							
						
					
					
						Commit
						74f768a095
					
				@ -15,6 +15,7 @@ const char IambicB[]       = "Iambic B";
 | 
			
		||||
const char Ultimatic[]     = "Ultimat.";
 | 
			
		||||
const char Memory[]        = "Memory";
 | 
			
		||||
const char Ratio[]         = "Ratio";
 | 
			
		||||
const char SpeedRatio[]    = "SpeedRatio";
 | 
			
		||||
const char ReverseRL[]     = " L -   R °";
 | 
			
		||||
const char ReverseLR[]     = " L °   R -";
 | 
			
		||||
const char SideToneOnOff[] = "Mithörton";
 | 
			
		||||
@ -179,8 +180,8 @@ void Drehencoder(void)
 | 
			
		||||
                    bMenuCtrl.SubMenue = 1;
 | 
			
		||||
                    EncoderPosSubConfig = EncoderRead(1);
 | 
			
		||||
                break;
 | 
			
		||||
                case M_WINKEYER:
 | 
			
		||||
                    bConfig.WinkeyerEnabled = (bConfig.WinkeyerEnabled == 1) ? 0 : 1;
 | 
			
		||||
                case M_SPEEDRATIO:
 | 
			
		||||
                    bConfig.SpeedRatioEnabled = (bConfig.SpeedRatioEnabled == 1) ? 0 : 1;
 | 
			
		||||
                    bMenuCtrl.m_buttonPressed = 0;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
@ -247,7 +248,7 @@ void Drehencoder(void)
 | 
			
		||||
void ConfigMenue(void)
 | 
			
		||||
{
 | 
			
		||||
    char line[22];
 | 
			
		||||
 | 
			
		||||
    lcd_clrscr();
 | 
			
		||||
    lcd_charMode(NORMAL);
 | 
			
		||||
    lcd_gotoxy(0,0);
 | 
			
		||||
    lcd_puts(CLEARLINE);
 | 
			
		||||
@ -360,12 +361,12 @@ void ConfigMenue(void)
 | 
			
		||||
            sprintf(line,"%s %ims",DebounceTime, bConfig.DebounceTime);
 | 
			
		||||
            lcd_puts(line);
 | 
			
		||||
        break;
 | 
			
		||||
        case M_WINKEYER:
 | 
			
		||||
        case M_SPEEDRATIO:
 | 
			
		||||
            lcd_gotoxy(0,3);
 | 
			
		||||
            if(bConfig.WinkeyerEnabled)
 | 
			
		||||
                sprintf(line,"[%s]","WinKey");
 | 
			
		||||
            if(bConfig.SpeedRatioEnabled)
 | 
			
		||||
                sprintf(line,"[%s]","va.Ratio");
 | 
			
		||||
            else
 | 
			
		||||
                sprintf(line," %s ","WinKey");
 | 
			
		||||
                sprintf(line," %s ","va.Ratio");
 | 
			
		||||
            lcd_puts(line);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
@ -408,7 +409,7 @@ void UpdateDisplay(void)
 | 
			
		||||
        if(!(bMenuCtrl.Config))
 | 
			
		||||
        {
 | 
			
		||||
            lcd_charMode(DOUBLESIZE);
 | 
			
		||||
            lcd_gotoxy(4,3);
 | 
			
		||||
            lcd_gotoxy(4,2);
 | 
			
		||||
            if(bConfig.WpMBpM == 0)
 | 
			
		||||
                sprintf(line,"%i WpM ",bConfig.WpM);
 | 
			
		||||
            else
 | 
			
		||||
@ -431,11 +432,24 @@ void UpdateDisplay(void)
 | 
			
		||||
            if(bConfig.TRX == 0)
 | 
			
		||||
                sprintf(line, "%s %s", Trx1, Trx2);
 | 
			
		||||
            lcd_puts(line);
 | 
			
		||||
            lcd_gotoxy(0,6);
 | 
			
		||||
            if(bConfig.SpeedRatioEnabled)
 | 
			
		||||
                sprintf(line,"Ratio auto.");
 | 
			
		||||
            else
 | 
			
		||||
                sprintf(line,"Ratio 1:%.1f", (float)bConfig.Ratio/10);
 | 
			
		||||
            lcd_puts(line);
 | 
			
		||||
            lcd_gotoxy(13,6);
 | 
			
		||||
            if(bConfig.Memory)
 | 
			
		||||
                sprintf(line,"MEM ON ");
 | 
			
		||||
            else
 | 
			
		||||
                sprintf(line,"MEM OFF");
 | 
			
		||||
            lcd_puts(line);
 | 
			
		||||
        }
 | 
			
		||||
        if(bMenuCtrl.Config)
 | 
			
		||||
        {
 | 
			
		||||
            ConfigMenue();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    bMenuCtrl.Update = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,3 +1,15 @@
 | 
			
		||||
/** @file   encoder.c
 | 
			
		||||
 *  @date   2014-12-04
 | 
			
		||||
 *  @author Frank Klee
 | 
			
		||||
 *  @brief  Drehencoder Library
 | 
			
		||||
 *
 | 
			
		||||
 *          Basisroutinen zum Abfragen eines Drehencoders mittels Polling.
 | 
			
		||||
 *          Quelle: https://www.mikrocontroller.net/articles/Drehgeber
 | 
			
		||||
 *
 | 
			
		||||
 *  @author Tom, DL7BJ
 | 
			
		||||
 *  @date   2023-03-23
 | 
			
		||||
 *  @brief  Formatierungen und Umbenennungen der Funktionen
 | 
			
		||||
 */
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include "encoder.h"
 | 
			
		||||
@ -37,9 +49,14 @@ void EncoderInit(void)
 | 
			
		||||
    iButtonDebounceCycles = BUTTON_DEBOUNCETIME_MS;
 | 
			
		||||
    iButtonPressedLongCycles = BUTTON_PRESSEDLONG_MS;
 | 
			
		||||
}
 | 
			
		||||
/** \brief EncoderPolling
 | 
			
		||||
 *  Abfrage des Drehencoders und des Tasters
 | 
			
		||||
 *  Wird vom Timer 0 alle 5ms aufgerufen
 | 
			
		||||
/** @fn     void EncoderPolling(void)
 | 
			
		||||
 *  @brief  EncoderPolling
 | 
			
		||||
 *
 | 
			
		||||
 *          Abfrage des Drehencoders und des Tasters
 | 
			
		||||
 *          Wird vom Timer 0 aufgerufen
 | 
			
		||||
 *
 | 
			
		||||
 *  @param  none
 | 
			
		||||
 *  @return none
 | 
			
		||||
*/
 | 
			
		||||
void EncoderPolling(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
#ifndef ENCODER_H_
 | 
			
		||||
#define ENCODER_H_
 | 
			
		||||
 | 
			
		||||
// Art des Drehencoders definieren
 | 
			
		||||
// #define SingleStep
 | 
			
		||||
// #define TwoStep
 | 
			
		||||
@ -21,8 +20,18 @@
 | 
			
		||||
#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 
 | 
			
		||||
/** @brief  Timer für Encoderpolling
 | 
			
		||||
 *
 | 
			
		||||
 *          Wenn der Timer für das Polling vom Drehencoder mit 
 | 
			
		||||
 *          anderen Zeiten als 1ms läuft, dann müssen hier die 
 | 
			
		||||
 *          Werte für Debounce und das lange Drücken des Tasters
 | 
			
		||||
 *          im Encoder angepasset werden. Standardwert ist normal
 | 
			
		||||
 *          1ms, im BJ-Keyer wird 5ms verwendet.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ENCODERTIMER             5
 | 
			
		||||
#define BUTTON_DEBOUNCETIME_MS  30/ENCODERTIMER 
 | 
			
		||||
#define BUTTON_PRESSEDLONG_MS   250/ENCODERTIMER
 | 
			
		||||
 | 
			
		||||
typedef enum EButtonPressedState
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -13,11 +13,11 @@ uint8_t ee_KeyerMode EEMEM = 1;              // Iambic A, Iambic B oder Ultimati
 | 
			
		||||
uint8_t ee_SidetoneEnabled EEMEM = 1;        // Mithörton eingeschaltet
 | 
			
		||||
uint8_t ee_WpMBpM EEMEM = 0;                 // WpM oder BpM Anzeige
 | 
			
		||||
uint8_t ee_Reverse EEMEM = 0;                // linkes/rechtes Paddle vertauschen
 | 
			
		||||
uint8_t ee_WinkeyerEnabled EEMEM = 0;        // Winkeyer Emulation 
 | 
			
		||||
uint8_t ee_SpeedRatioEnabled EEMEM = 0;      // Ratio von der Geschwindigkeit abhängig
 | 
			
		||||
uint8_t ee_Ratio EEMEM = 30;                 // Punkt/Strich Verhältnis 1:3
 | 
			
		||||
uint8_t ee_Memory EEMEM = 0;                 // Punkt/Strich Speicher
 | 
			
		||||
uint16_t ee_SidetoneFreq EEMEM = 600;        // Frequenz des Mithörtons
 | 
			
		||||
uint8_t ee_WpM EEMEM = 12;                   // WpM
 | 
			
		||||
uint8_t ee_WpM EEMEM = 12;                   // Geschwindigkeit WpM
 | 
			
		||||
uint8_t ee_RiseTime EEMEM = 5;               // Anstiegszeit Sinuston
 | 
			
		||||
uint8_t ee_RiseTimeCounter EEMEM = 5;        // Anzahl Sinusschwingungen für den Anstieg
 | 
			
		||||
uint8_t ee_DebounceTime EEMEM = 6;           // Entprellzeit für Straight Key Eingang
 | 
			
		||||
@ -116,7 +116,7 @@ void WriteEEprom(void)
 | 
			
		||||
    eeprom_write_byte(&ee_SidetoneEnabled, bConfig.SidetoneEnabled);
 | 
			
		||||
    eeprom_write_byte(&ee_WpMBpM, bConfig.WpMBpM);
 | 
			
		||||
    eeprom_write_byte(&ee_Reverse, bConfig.Reverse);
 | 
			
		||||
    eeprom_write_byte(&ee_WinkeyerEnabled, bConfig.WinkeyerEnabled);
 | 
			
		||||
    eeprom_write_byte(&ee_SpeedRatioEnabled, bConfig.SpeedRatioEnabled);
 | 
			
		||||
    eeprom_write_byte(&ee_Ratio, bConfig.Ratio);
 | 
			
		||||
    eeprom_write_byte(&ee_Memory, bConfig.Memory);
 | 
			
		||||
    eeprom_write_byte(&ee_RiseTime, bConfig.RiseTime);
 | 
			
		||||
@ -153,7 +153,7 @@ void SetEEprom(void)
 | 
			
		||||
    bConfig.SidetoneEnabled = 1;
 | 
			
		||||
    bConfig.WpMBpM = 1;
 | 
			
		||||
    bConfig.Reverse = 0;
 | 
			
		||||
    bConfig.WinkeyerEnabled = 0;
 | 
			
		||||
    bConfig.SpeedRatioEnabled = 0;
 | 
			
		||||
    bConfig.Ratio = 30;
 | 
			
		||||
    bConfig.Memory = 0;
 | 
			
		||||
    bConfig.RiseTime = 5;
 | 
			
		||||
@ -182,30 +182,13 @@ void ReadEEprom(void)
 | 
			
		||||
    bConfig.SidetoneEnabled = eeprom_read_byte(&ee_SidetoneEnabled);
 | 
			
		||||
    bConfig.WpMBpM = eeprom_read_byte(&ee_WpMBpM);
 | 
			
		||||
    bConfig.Reverse = eeprom_read_byte(&ee_Reverse);
 | 
			
		||||
    bConfig.WinkeyerEnabled = eeprom_read_byte(&ee_WinkeyerEnabled);
 | 
			
		||||
    bConfig.SpeedRatioEnabled = eeprom_read_byte(&ee_SpeedRatioEnabled);
 | 
			
		||||
    bConfig.Ratio = eeprom_read_byte(&ee_Ratio);
 | 
			
		||||
    bConfig.Memory = eeprom_read_byte(&ee_Memory);
 | 
			
		||||
    bConfig.RiseTime = eeprom_read_byte(&ee_RiseTime);
 | 
			
		||||
    bConfig.RiseTimeCounter = eeprom_read_byte(&ee_RiseTimeCounter);
 | 
			
		||||
    bConfig.DebounceTime = eeprom_read_byte(&ee_DebounceTime);
 | 
			
		||||
    IntEnable();
 | 
			
		||||
 | 
			
		||||
    if(bConfig.WpM > 50) {
 | 
			
		||||
        bConfig.WpM = 15;
 | 
			
		||||
        WriteEEpromWpM();
 | 
			
		||||
    }
 | 
			
		||||
    if(bConfig.RiseTime > 10) {
 | 
			
		||||
        bConfig.RiseTime = 10;
 | 
			
		||||
        WriteEEprom();
 | 
			
		||||
    }
 | 
			
		||||
    if(bConfig.RiseTimeCounter > 6) {
 | 
			
		||||
        bConfig.RiseTimeCounter = 6;
 | 
			
		||||
        WriteEEprom();
 | 
			
		||||
    }
 | 
			
		||||
    if(bConfig.DebounceTime > 22) {
 | 
			
		||||
        bConfig.DebounceTime = 25;
 | 
			
		||||
        WriteEEprom();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
/** @brief  Aktuelle Einstellungen über serielle Schnittstelle ausgeben
 | 
			
		||||
 *  @param  none
 | 
			
		||||
@ -231,7 +214,7 @@ void SerialInfo(void)
 | 
			
		||||
    SerialWriteString(sdebug);
 | 
			
		||||
    sprintf(sdebug,"Memory          : %i\r\n", bConfig.Memory);
 | 
			
		||||
    SerialWriteString(sdebug);
 | 
			
		||||
    sprintf(sdebug,"Winkeyer        : %i\r\n", bConfig.WinkeyerEnabled);
 | 
			
		||||
    sprintf(sdebug,"SpeedRatio      : %i\r\n", bConfig.SpeedRatioEnabled);
 | 
			
		||||
    SerialWriteString(sdebug);
 | 
			
		||||
    sprintf(sdebug,"RiseTime        : %i\r\n", bConfig.RiseTime);
 | 
			
		||||
    SerialWriteString(sdebug);
 | 
			
		||||
 | 
			
		||||
@ -112,10 +112,10 @@
 | 
			
		||||
#define M_MEMORY                 8
 | 
			
		||||
#define M_REVERSE                9
 | 
			
		||||
#define M_RATIO                 10
 | 
			
		||||
#define M_WPMBPM                11
 | 
			
		||||
#define M_RISETIME              12
 | 
			
		||||
#define M_DEBOUNCE              13
 | 
			
		||||
#define M_WINKEYER              14
 | 
			
		||||
#define M_SPEEDRATIO            11
 | 
			
		||||
#define M_WPMBPM                12
 | 
			
		||||
#define M_RISETIME              13
 | 
			
		||||
#define M_DEBOUNCE              14
 | 
			
		||||
#define M_MAX                   14          // maximale Menuepunke
 | 
			
		||||
// LCD
 | 
			
		||||
#define CLEARLINE               "                     "
 | 
			
		||||
@ -136,6 +136,7 @@ struct State
 | 
			
		||||
    uint8_t LastSymbolWasDit: 1;        // letztes Symbol war ein Punkt
 | 
			
		||||
    uint8_t DitPressed: 1;              // Dit Hebel betätigt
 | 
			
		||||
    uint8_t DahPressed: 1;              // Dah Hebel betätigt
 | 
			
		||||
    uint8_t Encoder: 1;                 // Drekencoder wurde betätigt
 | 
			
		||||
    uint8_t KeyState:1;                 //
 | 
			
		||||
    uint8_t KeyTX:1;
 | 
			
		||||
};
 | 
			
		||||
@ -161,7 +162,7 @@ struct Config
 | 
			
		||||
    uint8_t SidetoneEnabled: 1;         // Mithörton eingeschaltet
 | 
			
		||||
    uint8_t WpMBpM: 1;                  // WpM oder BpM Anzeige
 | 
			
		||||
    uint8_t Reverse: 1;                 // linkes/rechtes Paddle vertauschen
 | 
			
		||||
    uint8_t WinkeyerEnabled: 1;         // Winkeyer Emulation 
 | 
			
		||||
    uint8_t SpeedRatioEnabled: 1;       // Punkt/Strich Verhältnis Auto
 | 
			
		||||
    uint8_t Ratio;                      // Punkt/Strich Verhältnis 1:3
 | 
			
		||||
    uint8_t Memory:1;                   // Punkt/Strich Speicher
 | 
			
		||||
    uint16_t SidetoneFreq;              // Frequenz des Mithörtons
 | 
			
		||||
 | 
			
		||||
@ -165,6 +165,10 @@ void Init()
 | 
			
		||||
    // sbi(PCMSK2,PCINT18);
 | 
			
		||||
    // sbi(PCMSK2,PCINT19);
 | 
			
		||||
    // sbi(PCMSK2,PCINT20);
 | 
			
		||||
    sbi(PCICR,PCIE0);
 | 
			
		||||
    sbi(PCMSK0,PCINT0);
 | 
			
		||||
    sbi(PCMSK0,PCINT1);
 | 
			
		||||
    sbi(PCMSK0,PCINT2);
 | 
			
		||||
 | 
			
		||||
    // Init serial
 | 
			
		||||
    UBRR0=UBRR_VALUE;   // Set baud rate
 | 
			
		||||
@ -315,14 +319,22 @@ ISR(USART_RX_vect)
 | 
			
		||||
    data = UDR0;
 | 
			
		||||
    SerialWriteChar(data);
 | 
			
		||||
}
 | 
			
		||||
/** @brief  Pin Change Interrupt
 | 
			
		||||
/** @brief  Pin Change Interrupt PORT C
 | 
			
		||||
 *  @param  none
 | 
			
		||||
 *  @return none
 | 
			
		||||
 */
 | 
			
		||||
ISR(PCINT2_vect)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** @brief  Pin Change Interrupt PORT B
 | 
			
		||||
 *  @param  none
 | 
			
		||||
 *  @return none
 | 
			
		||||
 */
 | 
			
		||||
ISR(PCINT0_vect)
 | 
			
		||||
{
 | 
			
		||||
    SerialWriteChar("Encoder\r\n");
 | 
			
		||||
    bState.Encoder = 1;
 | 
			
		||||
}
 | 
			
		||||
/** @brief  Initialisierung bei Reset und Neustart
 | 
			
		||||
 *  @param  none
 | 
			
		||||
 *  @return none
 | 
			
		||||
@ -337,7 +349,7 @@ void ReStart(void)
 | 
			
		||||
    Init();    
 | 
			
		||||
    DisplayVersion();
 | 
			
		||||
    ReadEEprom();
 | 
			
		||||
    WpM = 12; // 12; // 12; // 12; // 12; // 12; // 12; // 12; // 12; // 12; // 12; // 12; // bConfig.WpM;
 | 
			
		||||
    WpM = bConfig.WpM;
 | 
			
		||||
    EncoderPos = bConfig.WpM;
 | 
			
		||||
    EncoderWrite(bConfig.WpM);
 | 
			
		||||
    EncoderPosConfig = 1;
 | 
			
		||||
@ -364,23 +376,20 @@ int main(void)
 | 
			
		||||
    SerialInfo();
 | 
			
		||||
    while(1)
 | 
			
		||||
    {
 | 
			
		||||
        Drehencoder();
 | 
			
		||||
        // Wenn Geschwindigkeit verändert und Zeit abgelaufen,
 | 
			
		||||
        // dann im EEprom speichern und Merker löschen.
 | 
			
		||||
        if(bState.WriteWpMEEprom)
 | 
			
		||||
        {
 | 
			
		||||
            sprintf(sdebug," %i WpM in EEprom speichern\r\n", bConfig.WpM);
 | 
			
		||||
            SerialWriteString(sdebug);
 | 
			
		||||
            WriteEEpromWpM();
 | 
			
		||||
            bState.WriteWpMEEprom = 0;
 | 
			
		||||
        }
 | 
			
		||||
        if(bState.WriteEEprom)
 | 
			
		||||
        {
 | 
			
		||||
            sprintf(sdebug,"Einstellungen in EEprom speichern\r\n");
 | 
			
		||||
            SerialWriteString(sdebug);
 | 
			
		||||
            WriteEEprom();
 | 
			
		||||
            bState.WriteEEprom = 0;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        Drehencoder(); 
 | 
			
		||||
        UpdateDisplay();
 | 
			
		||||
        CheckStraightKey();
 | 
			
		||||
        CheckPaddles();
 | 
			
		||||
 | 
			
		||||
		Laden…
	
	
			
			x
			
			
		
	
		In neuem Issue referenzieren
	
	Einen Benutzer sperren