logo elektroda
logo elektroda
X
logo elektroda

Interrupting a While Loop Playing a Song on Boot Alarm When Disarm Signal is Sent

123 12
ADVERTISEMENT
  • #1 21660547
    Joshua Bishop
    Anonymous  
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #3 21660549
    Joshua Bishop
    Anonymous  
  • #4 21660550
    Eduardo Viramontes
    Anonymous  
  • ADVERTISEMENT
  • #5 21660551
    Joshua Bishop
    Anonymous  
  • #6 21660552
    Bob Loy
    Anonymous  
  • #7 21660553
    Bob Loy
    Anonymous  
  • #8 21660554
    Bob Loy
    Anonymous  
  • #9 21660555
    Pieter Kruger
    Anonymous  
  • #10 21660556
    Joshua Bishop
    Anonymous  
  • ADVERTISEMENT
  • #11 21660557
    Joshua Bishop
    Anonymous  
  • #12 21660558
    Ty Wangsness
    Anonymous  
  • #13 21660559
    Bob Loy
    Anonymous  

Topic summary

The discussion addresses the challenge of interrupting a long-running while loop that plays a song as part of a boot alarm system when a disarm signal is received. The original alarm used short repeating cycles with status checks after each cycle, allowing prompt disarm detection. Transitioning to a song playback extended the cycle duration, delaying response to disarm signals. Proposed solutions include inserting multiple for() loops within the song playback to periodically check the disarm status, though this is considered inelegant. Suggestions involve using break statements to exit loops, but these only work at predefined check points. Software interrupts were considered but currently only update status flags without immediate loop interruption. A more robust approach discussed is restructuring the program to use timer interrupts to play individual notes, allowing status checks between notes and immediate song abortion upon disarm. Returning status values from the siren() function to control loop exits was also proposed. Ultimately, the first approach of periodic status checks within the song was implemented for the current project, while the timer interrupt method remains a promising solution for future development. Code formatting tips for forum posts were also shared.
Summary generated by the language model.
ADVERTISEMENT