Jump to content

Tiva C Alarm Library Overlapping Data

Recommended Posts

I am attempting to construct a simple library for creating alarm objects, basically just the days of the week, an hour, and a minute packaged together in an object for easy management.


I have attached a zip of the library, (feel free to use any code that might be useful!) but I am having an issue where toggling the days of the week alters the values of the integer hour and minute values. The days of the week are stored as an array of seven booleans, but I don't think that I am making a fencepost error somewhere...


I tried the various days of the week, and figured out that days 0-3 (Sun-Wed) alter the hour value, while days 4-6 (Thur-Sat) alter the minute value. Based on that, and the way that the numbers change (roughly multiples of 8) I think that the array of booleans is being written right over the top of the integer values in memory (or vice versa).


Am I configuring something in my library wrong, or instantiating the object incorrectly, maybe?


I have also attached a zip of some code demonstrating the problem by printing the values through serial.


MTAlarm.zip Zipped Library Code


problem_demo.zip Zipped demo code (Note: toggling commands are commented out, so out of the box it should function roughly as anticipated.)


Thanks in advance!



Link to post
Share on other sites

I'm more familiar with C than C++, but I would feel better if this line


  boolean _wdays[];


looked more like this:


  boolean _wdays[7];


And even then, I'd be tempted to use bit flags inside a simple 'char weekdays'
with an enum to define the symbolic names.
Please ignore me if C++ correctly allocates enough space for the array.
PS: also, your MTAlarm.ino has a spurious MTButton() declaration instead of MTAlarm().  Don't know if that matters.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...