Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve sound configurability #201

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions firmware/src/MightyBoard/Motherboard/Command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2043,10 +2043,8 @@ void runCommandSlice() {
LINE_NUMBER_INCR;
if(songId == 0)
Piezo::errorTone(4);
else if (songId == 1 )
Piezo::playTune(TUNE_PRINT_DONE);
else
Piezo::errorTone(2);
Piezo::playTune(songId);
}
#if defined(PSTOP_SUPPORT)
// Helpful at end of print
Expand Down
15 changes: 2 additions & 13 deletions firmware/src/MightyBoard/Motherboard/EepromMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,14 @@ void setCustomColor(uint8_t red, uint8_t green, uint8_t blue) {
sizeof(colors));
}

/**
*
* @param sound desired
* @param dest in eeprom
*/
void eeprom_write_sound(Sound sound, uint16_t dest)
{
eeprom_write_word((uint16_t*)dest, sound.freq);
eeprom_write_word((uint16_t*)dest + 2, sound.durationMs);
}

/**
*
* @param eeprom_base start of buzz effects table
*/
void setDefaultBuzzEffects(uint16_t eeprom_base)
{
Sound blare = {NOTE_B2, 500};
eeprom_write_sound(blare,eeprom_base + buzz_eeprom_offsets::SOUND_ON);
eeprom_write_byte((uint8_t *)(eeprom_base + buzz_eeprom_offsets::SOUND_ON), DEFAULT_BUZZ_ON);
eeprom_write_byte((uint8_t *)(eeprom_base + buzz_eeprom_offsets::HEAT_BUZZ_OFFSET), DEFAULT_BUZZ_HEAT);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions firmware/src/MightyBoard/Motherboard/EepromMap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ enum LEDColors {
LED_DEFAULT_CUSTOM
};

#define DEFAULT_BUZZ_ON 1
#define DEFAULT_BUZZ_HEAT 1

#if BOARD_TYPE == BOARD_TYPE_AZTEEG_X3

Expand Down Expand Up @@ -653,6 +655,9 @@ namespace buzz_eeprom_offsets{
//$type:B $constraints:l,0,1 $tooltip:Check or set to 1 to play bot sounds. Uncheck or set to 0 for no sounds.
const static uint16_t SOUND_ON = 0x00;
//$BEGIN_ENTRY
//$type:B $constraints:l,0,1 $tooltip:Check or set to 1 to always play temperatures reached tune. Uncheck or set to 0 to mute the tune while printing.
const static uint16_t HEAT_BUZZ_OFFSET = 0x02;
//$BEGIN_ENTRY
//$type:B $ignore:True $constraints:l,0,1
const static uint16_t ERROR_BUZZ_OFFSET = 0x04;
//$BEGIN_ENTRY
Expand Down
7 changes: 6 additions & 1 deletion firmware/src/MightyBoard/Motherboard/Motherboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,12 @@ void Motherboard::HeatingAlerts() {
else {
if ( heating_lights_active ) {
heating_lights_active = false;
Piezo::playTune(TUNE_FILAMENT_START);
// Always play tune while not printing, only play during print if HEAT_BUZZ is on or while paused.
if ( eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS + buzz_eeprom_offsets::HEAT_BUZZ_OFFSET,
DEFAULT_BUZZ_HEAT) ||
host::getHostState() == host::HOST_STATE_READY ||
command::pauseState() == PAUSE_STATE_PAUSED )
Piezo::playTune(TUNE_FILAMENT_START);
#ifdef HAS_RGB_LED
RGB_LED::setDefaultColor();
#endif
Expand Down
18 changes: 2 additions & 16 deletions firmware/src/MightyBoard/Motherboard/Piezo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static Timeout piezoTimeout;

void reset(void) {
// Reads the sound setting in from eeprom
soundEnabled = (bool)(eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS + buzz_eeprom_offsets::SOUND_ON,1) != 0);
soundEnabled = (bool)(eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS + buzz_eeprom_offsets::SOUND_ON, DEFAULT_BUZZ_ON) != 0);

//Empty the queue
tones.reset();
Expand Down Expand Up @@ -429,21 +429,7 @@ void playTune(uint8_t tuneid) {
} while (duration != 0 ); //duration == 0 marks the end of the tune
}
else
setTone(NOTE_B2, 500); //Play this is the tuneid doesn't exist
}


// call this sequence on startup
void startUpTone()
{
playTune(TUNE_FILAMENT_START);
}


// call this sequence at the end of prints
void doneTone( )// Ta-da!
{
playTune(TUNE_PRINT_DONE);
errorTone(2); //Play this if the tuneid doesn't exist
}


Expand Down
28 changes: 25 additions & 3 deletions firmware/src/MightyBoard/shared/Menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3852,7 +3852,7 @@ void BotStatsScreen::notifyButtonPressed(ButtonArray::ButtonName button) {

SettingsMenu::SettingsMenu() :
CounterMenu(_BV((uint8_t)ButtonArray::UP) | _BV((uint8_t)ButtonArray::DOWN),
(uint8_t)7
(uint8_t)8 // number of static menu items
#if EXTRUDERS > 1
+ 1
#endif
Expand Down Expand Up @@ -3899,7 +3899,8 @@ void SettingsMenu::resetState() {
#if EXTRUDERS > 1
singleExtruder = 2 != eeprom::getEeprom8(eeprom_offsets::TOOL_COUNT, 1);
#endif
soundOn = 0 != eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS, 1);
soundOn = 0 != eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS + buzz_eeprom_offsets::SOUND_ON, DEFAULT_BUZZ_ON);
soundHeatOn = 0 != eeprom::getEeprom8(eeprom_offsets::BUZZ_SETTINGS + buzz_eeprom_offsets::HEAT_BUZZ_OFFSET, DEFAULT_BUZZ_HEAT);
accelerationOn = 0 != eeprom::getEeprom8(eeprom_offsets::ACCELERATION_SETTINGS + acceleration_eeprom_offsets::ACCELERATION_ACTIVE, 0x01);
overrideGcodeTempOn = 0 != eeprom::getEeprom8(eeprom_offsets::OVERRIDE_GCODE_TEMP, 0);
pauseHeatOn = 0 != eeprom::getEeprom8(eeprom_offsets::HEAT_DURING_PAUSE, DEFAULT_HEAT_DURING_PAUSE);
Expand Down Expand Up @@ -3927,6 +3928,7 @@ void SettingsMenu::resetState() {
}

void SettingsMenu::drawItem(uint8_t index, LiquidCrystalSerial& lcd) {
// When adding items, don't forget to increment the constant in SettingsMenu::SettingsMenu
bool test = false;
const prog_uchar *msg;
uint8_t selection_column = 16;
Expand Down Expand Up @@ -3965,6 +3967,12 @@ void SettingsMenu::drawItem(uint8_t index, LiquidCrystalSerial& lcd) {
}
lind++;

if ( index == lind ) {
msg = SOUND_HEAT_MSG;
test = soundHeatOn;
}
lind++;

if ( index == lind ) {
msg = ACCELERATE_MSG;
test = accelerationOn;
Expand Down Expand Up @@ -4102,6 +4110,11 @@ void SettingsMenu::handleCounterUpdate(uint8_t index, int8_t up) {
}
lind++;

if ( index == lind ) {
soundHeatOn = !soundHeatOn;
}
lind++;

if ( index == lind ) {
accelerationOn = !accelerationOn;
}
Expand Down Expand Up @@ -4207,13 +4220,22 @@ void SettingsMenu::handleSelect(uint8_t index) {
lind++;

if ( index == lind ) {
eeprom_write_byte((uint8_t*)eeprom_offsets::BUZZ_SETTINGS,
eeprom_write_byte((uint8_t*)eeprom_offsets::BUZZ_SETTINGS +
buzz_eeprom_offsets::SOUND_ON,
soundOn ? 1 : 0);
Piezo::reset();
flags = SETTINGS_LINEUPDATE;
}
lind++;

if ( index == lind ) {
eeprom_write_byte((uint8_t*)eeprom_offsets::BUZZ_SETTINGS +
buzz_eeprom_offsets::HEAT_BUZZ_OFFSET,
soundHeatOn ? 1 : 0);
flags = SETTINGS_LINEUPDATE;
}
lind++;

if ( index == lind ) {
eeprom_write_byte((uint8_t*)eeprom_offsets::ACCELERATION_SETTINGS +
acceleration_eeprom_offsets::ACCELERATION_ACTIVE,
Expand Down
1 change: 1 addition & 0 deletions firmware/src/MightyBoard/shared/Menu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ private:
bool singleExtruder;
#endif
bool soundOn;
bool soundHeatOn;
#ifdef HAS_RGB_LED
bool heatingLEDOn;
#ifdef RGB_LED_MENU
Expand Down
3 changes: 2 additions & 1 deletion firmware/src/MightyBoard/shared/locale/Menu.DE.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const PROGMEM prog_uchar RESET_MSG[] = "Einstellungen RESET";
const PROGMEM prog_uchar NOZZLES_MSG[] = "Duesen kalibrieren";
const PROGMEM prog_uchar BOT_STATS_MSG[] = "Bot Statistik";
const PROGMEM prog_uchar TOOL_COUNT_MSG[] = "Duesen";
const PROGMEM prog_uchar SOUND_MSG[] = "Sound";
const PROGMEM prog_uchar SOUND_MSG[] = "Ton";
const PROGMEM prog_uchar SOUND_MSG[] = "Heizungston";
//const PROGMEM prog_uchar LED_HEAT_MSG[] = "Heiz LEDs";
const PROGMEM prog_uchar EXIT_MSG[] = "Exit Menue";
const PROGMEM prog_uchar ACCELERATE_MSG[] = "Beschleunigung";
Expand Down
1 change: 1 addition & 0 deletions firmware/src/MightyBoard/shared/locale/Menu.EN.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const PROGMEM prog_uchar NOZZLES_MSG[] = "Calibrate Nozzles";
const PROGMEM prog_uchar BOT_STATS_MSG[] = "Bot Statistics";
const PROGMEM prog_uchar TOOL_COUNT_MSG[] = "Extruder Count";
const PROGMEM prog_uchar SOUND_MSG[] = "Sound";
const PROGMEM prog_uchar SOUND_HEAT_MSG[] = "Heaters Sound";
//const PROGMEM prog_uchar LED_HEAT_MSG[] = "Heat LEDs";
const PROGMEM prog_uchar EXIT_MSG[] = "Exit Menu";
const PROGMEM prog_uchar ACCELERATE_MSG[] = "Acceleration";
Expand Down
1 change: 1 addition & 0 deletions firmware/src/MightyBoard/shared/locale/Menu.FR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const PROGMEM prog_uchar NOZZLES_MSG[] = "Calibration Buses";
const PROGMEM prog_uchar BOT_STATS_MSG[] = "Bot Statistics";
const PROGMEM prog_uchar TOOL_COUNT_MSG[] = "Nb Tetes:";
const PROGMEM prog_uchar SOUND_MSG[] = "Son";
const PROGMEM prog_uchar SOUND_HEAT_MSG[] = "Son Chauffage";
//const PROGMEM prog_uchar LED_HEAT_MSG[] = "Coul Chauf";
const PROGMEM prog_uchar EXIT_MSG[] = "Sortir du Menu";
const PROGMEM prog_uchar ACCELERATE_MSG[] = "Acceleration";
Expand Down
1 change: 1 addition & 0 deletions firmware/src/MightyBoard/shared/locale/locale.hh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ extern const unsigned char NOZZLES_MSG[];
extern const unsigned char BOT_STATS_MSG[];
extern const unsigned char TOOL_COUNT_MSG[];
extern const unsigned char SOUND_MSG[];
extern const unsigned char SOUND_HEAT_MSG[];
//extern const unsigned char LED_HEAT_MSG[];
extern const unsigned char EXIT_MSG[];
extern const unsigned char ACCELERATE_MSG[];
Expand Down