commit 8211b9cb69a48d026b6d75f215674bf035e974a1 from: Tracey Emery date: Mon Dec 13 22:21:28 2021 UTC add volume ... i think. this should affect amplitude. i'll know more on scope. commit - b12256f6688bf8dc65df430bac6fe40e1d188353 commit + 8211b9cb69a48d026b6d75f215674bf035e974a1 blob - 08f628fcb8a927850ac0f5c05918a77a04a3b658 blob + 7b541463b15b7555948c083750fed9bd743bc2bc --- Morse.cpp +++ Morse.cpp @@ -25,8 +25,9 @@ #define D_WPM 15 +#define MAX_RAD 127.5 + #define UNIT_T(x) (60.0 / (50.0 * (float)x)) * 1000.0 -#define SINE_W(x) (sin(x) * 127.5 + 127.5) volatile uint8_t gpio_wpm, dac_wpm; @@ -50,7 +51,7 @@ uint8_t dac_digraph = 0, dac_inited = 0, dac_on = 0 uint8_t adc_inited; -float dac_i = 0.0, dac_max = 6.283; +float dac_i = 0.0, dac_max = 6.283, volume; unsigned long gpio_tx_start_millis, gpio_tx_current_millis; unsigned long gpio_handle_unit_millis; @@ -282,10 +283,11 @@ Morse::dac_watchdog(void) if (dac_inited) { dac_handle_chars(); if (dac_on) { - dac_i += .125; + dac_i += .02; if (dac_i >= dac_max) dac_i = 0.0; - dacWrite(dac_tx_pin, SINE_W(dac_i)); + volume = (MAX_RAD * (dac_volume / 100.0)); + dacWrite(dac_tx_pin, sin(dac_i) * volume + volume); } } } blob - 363392aff0252a5265a2352d94626d3c695f0421 blob + 2c689220dd6e95ff05605aff350c671df17848b2 --- Morse.h +++ Morse.h @@ -24,6 +24,8 @@ Morse { // we've no rx code yet public: + float dac_volume = 100; + Morse(uint8_t type, uint8_t the_pin); Morse(uint8_t type, uint8_t the_pin, uint8_t the_wpm);