commit a2f258d1e78e3fa54e4a2a5586f1d95ed6243cf5 from: Tracey Emery date: Fri Mar 11 22:16:02 2022 UTC update README and rm unneeded code commit - 81efedb6f139d02f9d7bb00a8fb12743af7278b8 commit + a2f258d1e78e3fa54e4a2a5586f1d95ed6243cf5 blob - ce9cb77824a664695df3427037641d5df39dbc6b blob + 44e2a324f8e991a4c959f40ea217bf91e85e2799 --- Morse.cpp +++ Morse.cpp @@ -31,7 +31,6 @@ volatile uint8_t gpio_wpm, dac_wpm; volatile uint8_t gpio_tx_pin, dac_tx_pin; -volatile uint8_t adc_rx_pin; volatile float gpio_unit_t, dac_unit_t; @@ -48,7 +47,7 @@ uint8_t dac_this_index = 0, dac_next_index = 0; uint8_t dac_handle_unit, dac_unit_handled, dac_bit; uint8_t dac_digraph = 0, dac_inited = 0, dac_on = 0; -uint8_t adc_inited, dac_cw_configured = 0; +uint8_t dac_cw_configured = 0; unsigned long gpio_tx_start_millis, gpio_tx_current_millis; unsigned long gpio_handle_unit_millis; @@ -74,10 +73,7 @@ void dac_cw_stop(void); Morse::Morse(uint8_t type, uint8_t the_pin) { - if (type != M_ADC) Morse(type, the_pin, D_WPM); - else - Morse(type, the_pin, 0); } Morse::Morse(uint8_t type, uint8_t the_pin, uint8_t the_wpm) @@ -110,12 +106,6 @@ Morse::Morse(uint8_t type, uint8_t the_pin, uint8_t th dac_inited = 1; } break; - case M_ADC: - if (!adc_inited) { - adc_rx_pin = the_pin; - adc_inited = 1; - } - break; default: exit(1); break; blob - 4b66fe2ad853ecb2fc047a3bcfe236e638cfb572 blob + 9e7979b834eaa1de194a4fd7866e487bc2068b17 --- README.md +++ README.md @@ -1,12 +1,58 @@ -# Morse -Arduino Morse Code Library +# ESP32 Morse Code -To transmit code, setup the class with words per minute and the tx pin. To toggle digraph transmission, enter a backtick before and after your morse. +Arduino ESP32 Morse Code Library -# WIP -This is in a WIP state. +This Morse Code library allows the programmer to generate Morse Code via a GPIO +pin or send audio Morse Code via the on-board DAC. -This shouldn't be used by anybody yet. It is still highly experimental and -subject to large changes. +Usage +----- -I don't pretend to know anything about writing Arduino libraries. This style is OpenBSD style and may not look right in the Arduino IDE, since I don't use it. +Two class instantiation methods are in place: + + Morse(TYPE, PIN/DAC_CHANNEL); + Morse(TYPE, PIN/DAC_CHANNEL, WPM); + +Types available are: + + M_GPIO // GPIO Pin Type + M_DAC // DAC_CHANNEL Type + +It is highly desirable to configure the DAC CW generator by hand: + + dac_cw_config_t dac_cw_config; + + dac_cw_config.en_ch = DAC_CHANNEL_2; + dac_cw_config.scale = DAC_CW_SCALE_2; + dac_cw_config.phase = DAC_CW_PHASE_180; + dac_cw_config.freq = 550; + + morse_dac.dac_cw_configure(&dac_cw_config); + +Pro-sign Morse Code can be generated using backticks: + + String tx = "ab2cd de a2bcd `sos`"; + +To enable the Morse Code, two watchdogs are available: + + morse.gpio_watchdog(); + morse_dac.dac_watchdog(); + +Example +------- + +See the [LED_DAC Example](examples/LED_DAC/LED_DAC.ino) file for more +information. + +Note +---- + +I don't pretend to know anything about writing Arduino libraries. This style is +OpenBSD style and may not look right in the Arduino IDE, since I don't use it. + +Author +------ + +[Tracey Emery](https://github.com/basepr1me/) + +See the [License](LICENSE.md) file for more information. blob - 004080552534a230865d5ec24a47c9b99c84c14b blob + de8a1914f9c039d66e28bf9172970f6cb83b1a33 --- examples/LED_DAC/LED_DAC.ino +++ examples/LED_DAC/LED_DAC.ino @@ -4,7 +4,6 @@ #define LEDP 2 #define GSECS 2000 // seconds between transmittions #define DSECS 4000 -#define DAC_CHANNEL 2 unsigned long current_gpio_millis, start_gpio_millis; unsigned long current_dac_millis, start_dac_millis; @@ -13,7 +12,7 @@ void loop(void); Morse morse(M_GPIO, LEDP); // WPM is auto selected -Morse morse_dac(M_DAC, DAC_CHANNEL, WPM); // use DAC channel 2 +Morse morse_dac(M_DAC, DAC_CHANNEL_2, WPM); // use DAC channel 2 // backticks will toggle digraph sending @@ -27,7 +26,7 @@ setup(void) pinMode(LEDP, OUTPUT); digitalWrite(LEDP, LOW); - // configure our DAC if we want to + // configure our DAC if we want to (this is the prefered method) dac_cw_config_t dac_cw_config; dac_cw_config.en_ch = DAC_CHANNEL_2;