chathura-de-silva / Smart-Medibox

A smart device that reminds the user to take medicine on time.
MIT License
23 stars 7 forks source link

Alarms don't ring after first time! #9

Closed chathura-de-silva closed 5 months ago

chathura-de-silva commented 5 months ago

When any alarm is set for the first time on the device (When the EEPROM has no data) it does ring. But if the same alarm is set again for any other time, it doesn't ring.

Turns out that in the code, the variable alarm_triggered[relavant_alarm] is not being set to false when ever alarm_enabled = true is the issue.

Have to correct the code snippet below by putting the line alarm_triggered[alarm] = false; below and out of the if statement.

   {
            delay(50);
            alarm_minutes[alarm] = temp_minute;
            if (!alarm_enabled)
            {
                alarm_enabled = true;
                save_is_alarm_enabled();
                for (int i = 0; i < n_alarms; i++)
                {
                    alarm_triggered[i] = true;
                }
            }
            alarm_triggered[alarm] = false;

            show_modal_page(alarm_ring, 1000, "Alarm set to " + formatNumber(temp_hour) + ":" + formatNumber(temp_minute), 10);
            save_alarm(alarm);
            break;
        }

Code snippet is inside the function set_alarm(int alarm) inside alarms.cpp.