Replace calls to the default Arduino Tone library to toneAC2, saving over 1024 bytes

This commit is contained in:
Reed Nightingale 2020-04-25 22:44:26 -07:00
parent 7a788b6297
commit 2c4448f6a0
3 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#include <Arduino.h>
#include "toneAC2/toneAC2.h"
#include "pin_definitions.h"
#include "settings.h"
#include "tuner.h"
@ -45,7 +45,7 @@ static const unsigned int cwAdcDashTo = 800;
* each time it is called, the cwTimeOut is pushed further into the future
*/
void cwKeydown(){
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq);
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
digitalWrite(PIN_CW_KEY, 1);
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;
@ -56,7 +56,7 @@ void cwKeydown(){
* Pushes the cwTimeout further into the future
*/
void cwKeyUp(){
noTone(PIN_CW_TONE);
noToneAC2();
digitalWrite(PIN_CW_KEY, 0);
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;

View File

@ -1,4 +1,4 @@
#include <Arduino.h>//tone
#include "toneAC2/toneAC2.h"
#include "encoder.h"
#include "morse.h"
@ -86,7 +86,7 @@ void morseLetter(char c, uint16_t dit_duration_ms){
//now we are at the first zero, skip and carry on
mask = mask >> 1;
while(mask){
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq,10000);
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
if (mask & code){
delay(3 * dit_duration_ms);
//Serial.print('-');
@ -96,7 +96,7 @@ void morseLetter(char c, uint16_t dit_duration_ms){
//Serial.print('.');
}
//Serial.print('#');
noTone(PIN_CW_TONE);
noToneAC2();
delay(dit_duration_ms); // space between dots and dashes
mask = mask >> 1;
}
@ -122,8 +122,8 @@ void morseBool(bool val){
if(!globalSettings.morseMenuOn){
return;
}
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq + (val ? RELATIVE_OFFSET_HZ : -RELATIVE_OFFSET_HZ));
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq + (val ? RELATIVE_OFFSET_HZ : -RELATIVE_OFFSET_HZ));
delay(3*globalSettings.cwDitDurationMs);
noTone(PIN_CW_TONE);
noToneAC2();
delay(3*globalSettings.cwDitDurationMs);
}

View File

@ -1,4 +1,4 @@
#include <Arduino.h>
#include "toneAC2/toneAC2.h"
#include "colors.h"
#include "encoder.h"
#include "menu.h"
@ -279,13 +279,13 @@ void ssCwToneValidate(const long int candidate_value_in, long int* validated_val
void ssCwToneChange(const long int new_value, char* buff_out, const size_t buff_out_size)
{
globalSettings.cwSideToneFreq = new_value;
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq);
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
}
void ssCwToneFinalize(const long int final_value)
{
noTone(PIN_CW_TONE);
noToneAC2();
globalSettings.cwSideToneFreq = final_value;
SaveSettingsToEeprom();
}