Replace calls to the default Arduino Tone library to toneAC2, saving over 1024 bytes
This commit is contained in:
parent
7a788b6297
commit
2c4448f6a0
|
@ -1,4 +1,4 @@
|
||||||
#include <Arduino.h>
|
#include "toneAC2/toneAC2.h"
|
||||||
#include "pin_definitions.h"
|
#include "pin_definitions.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "tuner.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
|
* each time it is called, the cwTimeOut is pushed further into the future
|
||||||
*/
|
*/
|
||||||
void cwKeydown(){
|
void cwKeydown(){
|
||||||
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
||||||
digitalWrite(PIN_CW_KEY, 1);
|
digitalWrite(PIN_CW_KEY, 1);
|
||||||
|
|
||||||
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;
|
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;
|
||||||
|
@ -56,7 +56,7 @@ void cwKeydown(){
|
||||||
* Pushes the cwTimeout further into the future
|
* Pushes the cwTimeout further into the future
|
||||||
*/
|
*/
|
||||||
void cwKeyUp(){
|
void cwKeyUp(){
|
||||||
noTone(PIN_CW_TONE);
|
noToneAC2();
|
||||||
digitalWrite(PIN_CW_KEY, 0);
|
digitalWrite(PIN_CW_KEY, 0);
|
||||||
|
|
||||||
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;
|
globalSettings.cwExpirationTimeMs = millis() + globalSettings.cwActiveTimeoutMs;
|
||||||
|
|
10
morse.cpp
10
morse.cpp
|
@ -1,4 +1,4 @@
|
||||||
#include <Arduino.h>//tone
|
#include "toneAC2/toneAC2.h"
|
||||||
|
|
||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
#include "morse.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
|
//now we are at the first zero, skip and carry on
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
while(mask){
|
while(mask){
|
||||||
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq,10000);
|
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
||||||
if (mask & code){
|
if (mask & code){
|
||||||
delay(3 * dit_duration_ms);
|
delay(3 * dit_duration_ms);
|
||||||
//Serial.print('-');
|
//Serial.print('-');
|
||||||
|
@ -96,7 +96,7 @@ void morseLetter(char c, uint16_t dit_duration_ms){
|
||||||
//Serial.print('.');
|
//Serial.print('.');
|
||||||
}
|
}
|
||||||
//Serial.print('#');
|
//Serial.print('#');
|
||||||
noTone(PIN_CW_TONE);
|
noToneAC2();
|
||||||
delay(dit_duration_ms); // space between dots and dashes
|
delay(dit_duration_ms); // space between dots and dashes
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ void morseBool(bool val){
|
||||||
if(!globalSettings.morseMenuOn){
|
if(!globalSettings.morseMenuOn){
|
||||||
return;
|
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);
|
delay(3*globalSettings.cwDitDurationMs);
|
||||||
noTone(PIN_CW_TONE);
|
noToneAC2();
|
||||||
delay(3*globalSettings.cwDitDurationMs);
|
delay(3*globalSettings.cwDitDurationMs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <Arduino.h>
|
#include "toneAC2/toneAC2.h"
|
||||||
#include "colors.h"
|
#include "colors.h"
|
||||||
#include "encoder.h"
|
#include "encoder.h"
|
||||||
#include "menu.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)
|
void ssCwToneChange(const long int new_value, char* buff_out, const size_t buff_out_size)
|
||||||
{
|
{
|
||||||
globalSettings.cwSideToneFreq = new_value;
|
globalSettings.cwSideToneFreq = new_value;
|
||||||
tone(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
toneAC2(PIN_CW_TONE, globalSettings.cwSideToneFreq);
|
||||||
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
|
ltoa(globalSettings.cwSideToneFreq,buff_out,10);
|
||||||
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
strncat_P(buff_out,(const char*)F("Hz"),buff_out_size - strlen(buff_out));
|
||||||
}
|
}
|
||||||
void ssCwToneFinalize(const long int final_value)
|
void ssCwToneFinalize(const long int final_value)
|
||||||
{
|
{
|
||||||
noTone(PIN_CW_TONE);
|
noToneAC2();
|
||||||
globalSettings.cwSideToneFreq = final_value;
|
globalSettings.cwSideToneFreq = final_value;
|
||||||
SaveSettingsToEeprom();
|
SaveSettingsToEeprom();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue