Go Down

Topic: Need help to finish the code (Read 3816 times) previous topic - next topic

wvmarle

After building the test set, to make it work: probably an hour or two. To make it work well, a day or two.

There appear to be issues with the buttons handling as well, I can't yet figure out how that's supposed to work. I'll anyway do my best to work with the existing wiring for that, should be able to make that work.

So there are four buttons: hour, minute, alarm and a general on/off. It seems that any press on hour/minute buttons will change the time, that doesn't sound like a good idea. So my suggestion:
- long press (1 second or so) the on/off button goes in to time setting mode.
- hour button advances the hour, rolling over at 23 back to 0.
- pressing the minute button switches to minute setting; then pressing the button advances the minute, rolling over at 59 back to 0.
- pressing the hour button goes back to hour setting, etc.
- pressing the on/off button sets the time.

Same for the alarm button: long press goes into alarm setting mode.

Have the hour resp. minute LEDs flash as they are being set, so you know what you're doing (just no way to indicate whether you set alarm or time).

One alarm can be set (store in EEPROM to remember this over power cycles); rings for some time (how long?) until the alarm button is pressed.

Any way to entirely disable the alarm? Any way to indicate that the alarm is active or not?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

After building the test set, to make it work: probably an hour or two. To make it work well, a day or two.

There appear to be issues with the buttons handling as well, I can't yet figure out how that's supposed to work. I'll anyway do my best to work with the existing wiring for that, should be able to make that work.

So there are four buttons: hour, minute, alarm and a general on/off. It seems that any press on hour/minute buttons will change the time, that doesn't sound like a good idea. So my suggestion:
- long press (1 second or so) the on/off button goes in to time setting mode.
- hour button advances the hour, rolling over at 23 back to 0.
- pressing the minute button switches to minute setting; then pressing the button advances the minute, rolling over at 59 back to 0.
- pressing the hour button goes back to hour setting, etc.
- pressing the on/off button sets the time.

Same for the alarm button: long press goes into alarm setting mode.

Have the hour resp. minute LEDs flash as they are being set, so you know what you're doing (just no way to indicate whether you set alarm or time).

One alarm can be set (store in EEPROM to remember this over power cycles); rings for some time (how long?) until the alarm button is pressed.

Any way to entirely disable the alarm? Any way to indicate that the alarm is active or not?
Hi. How are you?

Your stuff is on its way. I posted them today. I appreciate your help. Please keep it up. I will send you another special gift (surpize) when I see that the code is complete.

Just some update. Please read my comments below. I have tried to answer as many remarks as I can.

Regarding the weird issue on pin 1 (Rx) that you mentioned in your recent message, no I didn't have any issues with with that old code of mine. Everything was working as intended. May be you mean the initial flickering when arduino is first powered on, which I think is due to bootloader starting. But that is like a one time thing and then it gets to work and functions as intended. But probably you are referring to a different issue.

Regarding your latest comments on the forum, Yes, please do. I like all the new ideas which you mentioned in there, such as flashing when the clock or alarm is in setting mode and goes solid when it is back to normal mode. That sounds like a perfect idea.

He basically implemented everything so that, you click the buttonAlarm (acts like mode changing button) and then you are in alarm mode and you can activate alarm by pushing hour/minute buttons simultaneously (which turns on alarm clock) and you can set alarm time. Once alarm time is set, click buttonAlarm (which acts like mode change button) again, go to Clock mode and set the clock time, if needed. Simple as that.

In the old code, you would change between clock and alarm menus by simply pressing the buttonAlarm button as many times as needed to toggle back and forth between clock and alarm menus. And activate and deactivate alarm (only in alarm mode) by simulataneous press of hour/minute buttons. I hope it makes sense now. But if you have a better idea than this, please implement it. Thanks.

Please check this link:This was the original version of the code which I worked off from to make that old code of mine. The comments are in russian. It must have been written by a russian programmer. I found it online. But I think you will understand even without the comment.

I like your way of setting things a lot better. Although I was confused by some of your suggestions. Can you explain in more detail. I like the idea of flashing when in setting mode. Please implement the ideas which you mentioned in your recent reply. I was a little bit confused with long press suggestion.


Here is what my project looks like:




I am using 2 transistor setup for constant current supply. The right transistor is the main transistor through which the main current passes and lights up the LED. Both of the transistors in my case are 2N2222. When the current rises, some of the current is diverted to the base of the left transistor which in turn takes away some current from the base of the right transistor thus creating a feedback loop.

Cheers.

arduinoware

Also, forgot to mention, the general On/Off button, I was using that as a means of turning on and off the lights. But I think you are planning another use for that?

Just curious.

Cheers.

wvmarle

I know that LED circuit. A simple constant-current circuit.

For the testing I've set it up with simple LEDs, no transistors, just straight from the pin. The Rx needed its own resistor and is now happy. Clock is running after I got the order right, so that's progress.

Your buttons, are they active low (pull-up resistor) or active high (pull-down resistor)?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

I know that LED circuit. A simple constant-current circuit.

For the testing I've set it up with simple LEDs, no transistors, just straight from the pin. The Rx needed its own resistor and is now happy. Clock is running after I got the order right, so that's progress.

Your buttons, are they active low (pull-up resistor) or active high (pull-down resistor)?
Hi. My buttons are with pull-up resistor, so I think they are active LOW.

Cheers

wvmarle

Hereby.

Buttons set to INPUT_PULLUP so you don't need external resistors; if you have those in place you can change that to INPUT.

Note the #ifdef tags: that's to allow it to work without RTC.

Tested as much as possible; I do see some odd behaviour with the long press detection. Doesn't seem to be a serious issue. Let me know if there are any issues - hope your son likes the present.


Clock behaviour:

When powerd on, flash all LEDs and buzz the buzzer, play special effects, then go into normal clock display mode.
Alarms are switched OFF.

You're in clock mode.

Press alarmOnOff button long: switch on/off alarms.
  When switching on: play effect that first switches on the LEDS row by row, then flashes two times short and one time long.
  When switching off: play effect that first switches off the LEDs row by row, then flashes one time short.
 
Long press hour and minute buttons together: go into alarm set mode.
  Press the hour button to advance the alarm hour by one.
  Press the minute button to advance the alarm minute by one.
  Press AlarmOnOff button: switch to set clock mode (LEDs flash three times).

  Press the hour button to advance the clock hour by one.
  Press the minute button to advance the clock minute by one.
  Press AlarmOnOff button: switch to set alarm mode (LEDs flash once).

  Press LightsOnOff button (in either set alarm mode or set clock mode): store the alarm and clock time and go back to clock mode (LEDs flash long one time).
 
Long press the OnOff button:
  Switch on/off the display.
  Display on: clock, hourly special effects and alarms show.
  Display off: only the alarm lights show.

When an alarm is playing:
  Press alarmOnOff button short to snooze the alarm, it will play again after 5 minutes.
  If alarm is playing for 20 minutes, it will switch off by itself.
  Press alarmOnOff button long to stop the alarm (it will play again 24 hours later).
 
When any effect is playing:
  press alarmOnOff button short to stop this.
 
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

#21
Jan 12, 2018, 03:17 pm Last Edit: Jan 12, 2018, 03:32 pm by arduinoware
Hereby.

Buttons set to INPUT_PULLUP so you don't need external resistors; if you have those in place you can change that to INPUT.

Note the #ifdef tags: that's to allow it to work without RTC.

Tested as much as possible; I do see some odd behaviour with the long press detection. Doesn't seem to be a serious issue. Let me know if there are any issues - hope your son likes the present.


Clock behaviour:

When powerd on, flash all LEDs and buzz the buzzer, play special effects, then go into normal clock display mode.
Alarms are switched OFF.

You're in clock mode.

Press alarmOnOff button long: switch on/off alarms.
  When switching on: play effect that first switches on the LEDS row by row, then flashes two times short and one time long.
  When switching off: play effect that first switches off the LEDs row by row, then flashes one time short.
 
Long press hour and minute buttons together: go into alarm set mode.
  Press the hour button to advance the alarm hour by one.
  Press the minute button to advance the alarm minute by one.
  Press AlarmOnOff button: switch to set clock mode (LEDs flash three times).

  Press the hour button to advance the clock hour by one.
  Press the minute button to advance the clock minute by one.
  Press AlarmOnOff button: switch to set alarm mode (LEDs flash once).

  Press LightsOnOff button (in either set alarm mode or set clock mode): store the alarm and clock time and go back to clock mode (LEDs flash long one time).
 
Long press the OnOff button:
  Switch on/off the display.
  Display on: clock, hourly special effects and alarms show.
  Display off: only the alarm lights show.

When an alarm is playing:
  Press alarmOnOff button short to snooze the alarm, it will play again after 5 minutes.
  If alarm is playing for 20 minutes, it will switch off by itself.
  Press alarmOnOff button long to stop the alarm (it will play again 24 hours later).
 
When any effect is playing:
  press alarmOnOff button short to stop this.
 
Just tried to do the testing. But nothing works. I power up the clock and I see some flashing and then, all the lights turn off  and stay off no matter what I do. And the hour/minute buttons beep with every press but no LEDs light up. And if I keep pressing the hour or minute buttons, a continous, non ending beeeeeeep starts  unless I press another button. Something must be wrong I think.

By the way, I think there was also a slight misunderstanding of one of my requests.

1.

Right now, I can't be sure, because I am unable to test. But when you said, "flashing" in time setting mode, I thought you were referring to flashing of time shown with LEDs (if you know what I mean) as you are setting time, not just a couple of flashes before you start setting time. Do you think you can do that? That is why I wanted to have that in both modes. I was referring to the flashing of the actual time, as you are setting it.

2.
Also, I don't want the specialEffects to play when the clock is first powered on.

3. Besides, it might be a little late to mention, but still, my on/off button is not a push button, it is a normal button. 1 click on, another click off. Changing the wiring, really isn't an option for me. I have glued some of the components and it would get quite ugly If I move things around.

Please help. Because right now, nothing works.

Thanks.

wvmarle

3. Besides, it might be a little late to mention, but still, my on/off button is not a push button, it is a normal button. 1 click on, another click off. Changing the wiring, really isn't an option for me. I have glued some of the components and it would get quite ugly If I move things around.
That's good to know, as it does throw off other things (I was using it to do other things thinking it was a push button).

It may very well be the cause of you not seeing anything: when lights off, you don't get the animations and you don't get to see the lights when selecting things.

Which reminds me: I should switch that whole function off when lights are off, or you're starting to press buttons blindly! So first switch lights on, after that you can set alarm and time.

If lights ON, is that pin HIGH or LOW?

And how to do alarm on/off? (with that I mean whether it should do the alarm at all - not the snooze/stop alarm after the alarm went off already).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

#23
Jan 12, 2018, 05:11 pm Last Edit: Jan 12, 2018, 05:23 pm by arduinoware
That's good to know, as it does throw off other things (I was using it to do other things thinking it was a push button).

It may very well be the cause of you not seeing anything: when lights off, you don't get the animations and you don't get to see the lights when selecting things.

Which reminds me: I should switch that whole function off when lights are off, or you're starting to press buttons blindly! So first switch lights on, after that you can set alarm and time.

If lights ON, is that pin HIGH or LOW?

And how to do alarm on/off? (with that I mean whether it should do the alarm at all - not the snooze/stop alarm after the alarm went off already).
That is a good question. :) I mean, about pin being HIGH or LOW. All I know is that it is a normal button with a pull-up resistor. not a pushbutton. i mean, the on/off button. and Analog Read <1000, is pressed condition.

Yes, please make the change, so that the user doesn't press buttons blindly if lights are off.

Ok. I was able to get some functioning out of the clock. I tried to immitate a push button effect with my normal button (on/off button). That button is really the cause of some of the issues.

Still got issues though:

1. Can you please do something about my normal button (On/Off). Changing it to a push button is really not an option. Like I said, glue is all over the place. I really don't know how to go about it. I suppose, you could program the lights to go on and off with a normal button like this, but then how are you going to implement the storing of clock setting which previously was bound to on/off longpress??

2. I was somehow able to get to setting mode, I like how the minutes flash if you're setting minutes and hours flash if you are setting hours. But can you make it flash a tiny bit faster? Only a tiny bit? or is that some kind of a standard value?

3. Also, I noticed that if you press and hold minute or hour buttons in the setting mode, you can't advance through hours or minutes faster. So, the only option to advance is single presses. Can you fix that?

4. Long press issues. Some long press issues are present. Would be nice if you could clear that. it gets annoying to be honest.

Additionally, what kind of special effect have you programmed to play at power up? I was a bit confused about that. Originally, I had just programmed a solid on for 400ms and straight away to show clock. or have you tried to implement the same special effects that plays every hour to be at power up?

Thank you so much.

I realize that is a lot of requests. But you get it complete, and I will make sure you receive a very very special gift from me. The other things are already well on their way. :)

But please, don't reduce any functionality of the clock. I have 1 normal button and 3 push buttons, there must be some way to combine the presses. Hour/min and buttonAlarm buttons are push buttons, and On/Off is a normal button. Please see what you can do. If it is an absolute must, I will have to bring in another button. But I want to avoid it by all means.

So, I think just use the On/Off normal button states for lights on/off. And the remaining functionality we have to find a way to implement somehow.

Cheers.

wvmarle

That is a good question. :) I mean, about pin being HIGH or LOW. All I know is that it is a normal button with a pull-up resistor. not a pushbutton. i mean, the on/off button. and Analog Read <1000, is pressed condition.
Pressed / low reading means lights off, right?

It just means I have to treat this one separate from the push buttons. That's no problem, a small change really. The main part is knowing how it behaves!

Quote
3. Also, I noticed that if you press and hold minute or hour buttons in the setting mode, you can't advance through hours or minutes faster. So, the only option to advance is single presses. Can you fix that?
Really have to think about how to do this - considering it's clashing with the normal long press handling.

Quote
Additionally, what kind of special effect have you programmed to play at power up? I was a bit confused about that. Originally, I had just programmed a solid on for 400ms and straight away to show clock. or have you tried to implement the same special effects that plays every hour to be at power up?
That's exactly what the current behaviour should be.

If you power it up just before the hour, or if your RTC is somehow set to exactly an hour, it of course will play this at startup as it's the time for it.

For the blinking and so I'll just add some #define statements at the top of the sketch so you can tinker and set it to your liking.

Wouter.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

#25
Jan 12, 2018, 05:34 pm Last Edit: Jan 12, 2018, 05:39 pm by arduinoware
Pressed / low reading means lights off, right?
onoffbutton < 1000, (analog read) means light on. with my current setup.

For the blinking and so I'll just add some #define statements at the top of the sketch so you can tinker and set it to your liking.
which blink tinkering do you mean?

Also, please see my previous post above. Can you please fix them all? Also, please remember the shut everything down thing if lights are off. so that not to press blindly. And please don't reduce functionality of the clock. I like how you'd set up things.

Cheers.

wvmarle

Clock behaviour:

When powerd on, flash all LEDs and buzz the buzzer, play special effects, then go into normal clock display mode.
Alarms are switched OFF.

You're in clock mode.

Press alarmOnOff button long: switch on/off alarms.
  When switching on: play effect that first switches on the LEDS row by row, then flashes two times short and one time long.
  When switching off: play effect that first switches off the LEDs row by row, then flashes one time short.
 
Long press hour and minute buttons together: go into alarm set mode.
  Press the hour button to advance the alarm hour by one.
  Press the minute button to advance the alarm minute by one.
  Press AlarmOnOff button: switch to set clock mode (LEDs flash once).

  Press the hour button to advance the clock hour by one.
  Press the minute button to advance the clock minute by one.
  Press AlarmOnOff button: save and switch to clock mode (LEDs flash once).
 

When an alarm is playing:
  Press alarmOnOff button short to snooze the alarm, it will play again after 5 minutes.
  If alarm is playing for 20 minutes, it will switch off by itself.
  Press alarmOnOff button long to stop the alarm (it will play again 24 hours later).
 
When any effect is playing:
  press alarmOnOff button short to stop this.
 
 
The On/Off switch:
  Switch on/off the display.
  On: clock, hourly special effects and alarms show.
  Off: only the alarm lights show; hour and minute buttons are disabled.


It seems the alarm time is not stored in EEPROM as I want it to do - have to look into what I did wrong there. But not now. Enough for tonight :)


To change the long press time and speed of blinking, change the values in these #define values at the top of the sketch:

Code: [Select]

#define BLINK_FREQUENCY 800    // in milliseconds, how fast the LEDs blink when setting hour/minute.
#define LONG_PRESS_TIME 500    // How long before a long press is detecetd, in milliseconds.
#define DEBOUNCE_DELAY 50      // How long to wait for debounce - and how long to play the buzzer for when the button is pressed.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

#27
Jan 12, 2018, 10:27 pm Last Edit: Jan 12, 2018, 10:30 pm by arduinoware
Clock behaviour:

When powerd on, flash all LEDs and buzz the buzzer, play special effects, then go into normal clock display mode.
Alarms are switched OFF.

You're in clock mode.

Press alarmOnOff button long: switch on/off alarms.
  When switching on: play effect that first switches on the LEDS row by row, then flashes two times short and one time long.
  When switching off: play effect that first switches off the LEDs row by row, then flashes one time short.
 
Long press hour and minute buttons together: go into alarm set mode.
  Press the hour button to advance the alarm hour by one.
  Press the minute button to advance the alarm minute by one.
  Press AlarmOnOff button: switch to set clock mode (LEDs flash once).

  Press the hour button to advance the clock hour by one.
  Press the minute button to advance the clock minute by one.
  Press AlarmOnOff button: save and switch to clock mode (LEDs flash once).
 

When an alarm is playing:
  Press alarmOnOff button short to snooze the alarm, it will play again after 5 minutes.
  If alarm is playing for 20 minutes, it will switch off by itself.
  Press alarmOnOff button long to stop the alarm (it will play again 24 hours later).
 
When any effect is playing:
  press alarmOnOff button short to stop this.
 
 
The On/Off switch:
  Switch on/off the display.
  On: clock, hourly special effects and alarms show.
  Off: only the alarm lights show; hour and minute buttons are disabled.


It seems the alarm time is not stored in EEPROM as I want it to do - have to look into what I did wrong there. But not now. Enough for tonight :)
Thanks. It is starting to look good. Good job!
Also, check my PM for the 1st paragraph.

Please see if you can change these: (test results and some changes required)

1. Please pay attention closely to this one. When the alarm is switched ON, effect plays that first switches on the LEDS row by row, then it flashes two times short and one time long. That is fine. No changes for switching alarm ON. But when alarm is switched OFF, I want to reverse the effects. So, it does a short flash first, then the rows switch off.

2. Please read carefully. When you click hour/minute buttons together, all LEDs blink twice indicating that you are entering alarm time setting mode. That is fine. But leds also blink the 2nd time, if you move on from alarm setting to clock setting mode which I don't want to happen. I only want them to blink first time, when you are entering alarm setting mode and for transition between alarm setting mode and clock setting mode may be just switch off all leds for 50ms. And moving from clock setting to normal display, no changes please.

3. A minor issue with something not being universal accross setting mode. When you first LongPress hour/minute and go to Alarm Setting mode, nothing is flashing, you have to press hour or minute button again to select hours or minutes to start flashing. But if you go to clock setting mode, minutes are immediately flashing. Can you make it so that, in alarm setting mode, it also starts with minutes flashing. just so that, it is universally the same.

4. 1. Alarm is not playing melody fully and the sound has become slightly different, like bogged or slowed down a little bit.) Please check if you can.

Just some background information about the alarm sound and lighting effects. But it may not even be relevant. Only for information: (since the alarm sound is concerned): The original Mario Theme sketch that I have used to create my alarm sound and lighting effects, did not have the
Code: [Select]

long halfway = numCycles / 1.1;

 

in

Code: [Select]

void buzz(int targetPin, long frequency, long length) {

 
section. I had added that because it was suggested by someone to make the LEDs light up with correct timing and better follow the music beats. Because, in the original sketch, there was not enough time for the LEDs to go off and on again. So they were flickering. So, the final code for the "buzz" section looked like this and allowed correct light up timing of LEDs:

Code: [Select]

void buzz(int targetPin, long frequency, long length) {

  long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
  //// 1 second's worth of microseconds, divided by the frequency, then split in half since
  //// there are two phases to each cycle
  long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
  //// multiply frequency, which is really cycles per second, by the number of seconds to
  //// get the total number of cycles to produce
  long halfway = numCycles / 1.1;
  for (long i = 0; i < numCycles; i++) { // for the calculated length of time...
    digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(delayValue); // wait for the calculated delay value
    digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(delayValue); // wait again or the calculated delay value
    if (i < halfway) {
      for (int i = 0; i <= 13; i++) {
        if (i == 9) continue;
        digitalWrite(i, HIGH);
      }
    } else {
      for (int i = 0; i <= 13; i++) {
        if (i == 9) continue;
        digitalWrite(i, LOW);
      }
    }
  }
}

 

The old "buzz code" code was this:

Code: [Select]

void buzz(int targetPin, long frequency, long length) {
  for (int i = 0; i <= 13; i++) {
    if (i != 9) {
      digitalWrite(i, HIGH);
    }
  }
  long delayValue = 1000000 / frequency / 2; // calculate the delay value between transitions
  //// 1 second's worth of microseconds, divided by the frequency, then split in half since
  //// there are two phases to each cycle
  long numCycles = frequency * length / 1000; // calculate the number of cycles for proper timing
  //// multiply frequency, which is really cycles per second, by the number of seconds to
  //// get the total number of cycles to produce
  for (long i = 0; i < numCycles; i++) { // for the calculated length of time...
    digitalWrite(targetPin, HIGH); // write the buzzer pin high to push out the diaphram
    delayMicroseconds(delayValue); // wait for the calculated delay value
    digitalWrite(targetPin, LOW); // write the buzzer pin low to pull back the diaphram
    delayMicroseconds(delayValue); // wait again or the calculated delay value
  }
  for (int i = 0; i <= 13; i++) {
    if (i != 9) {
      digitalWrite(i, LOW);
    }
  }
}


Just so you know, in case it is relevant. But this whole thing probably is not the reason because in my old setup, the alarm sounded fine. Probably, something else has changed.

wvmarle

Yes, something changed: during the playing the buttons are checked (so it reacts to the alarm button to stop the sounds).

4. It's doing this during the tone playing; as it uses the slow digitalRead() functions - taking 4-5 us each plus loop overhead - coming to close to 20 us to read three buttons - this may indeed affect the music. A 2 kHz tone makes for 2,000 reads a second (buttons are checked once every wave), that's 40,000 us extra, 20 ms, or a 2% stretch.

You may try to tinker a bit with the delay times in the buzz function (I don't have a buzzer so I can't hear any sounds - using an LED in its place to see when it triggers). If that doesn't work I have to go down and dirty and replace the digitalRead() functions with the much faster direct reads (should be able to read three buttons and return to music playing in 1-2 us). I was afraid of this happening, hoped it was no problem.

All analog pins, should be same register. One read for the three of them, quick if/then to see if any are activated, if none, straight back to the music. 10-20 clock cycles or so. Should be no problem for your music - this 2 kHz tone would add 20,000-40,000 clock cycles, for 1.25-2.5 ms total, about 0.2% stretch of the tone.

1, 2. Animations are set up in the special effects section. This I designed to make as easy as possible to amend. At the moment it has indeed the same when going into alarm set mode and when switching from alarm to clock.  I have to change one variable and re-enable one of the effects blocks. Easy to change things here.
I'll add a bit in the manual on how to make changes, so you can play with this. It's basically a set of LED patterns and times to show it, in addition using ledsOn() and ledsOff() as convenience functions for all on and off.

3. I noticed myself as well. Have to fix that, should be an easy one as well. Just setting the correct flag. The intended behaviour is that the first press on hour changes to hour setting, the second and subsequent presses make the change. Same for switching to minute setting.
Apparently the first of the two is not set when you enter alarm set mode.

If there are more issues let me know. Can try and fix them all in one go :-)
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

arduinoware

#29
Jan 13, 2018, 07:47 am Last Edit: Jan 13, 2018, 09:42 am by arduinoware
Yes, something changed: during the playing the buttons are checked (so it reacts to the alarm button to stop the sounds).

4. It's doing this during the tone playing; as it uses the slow digitalRead() functions - taking 4-5 us each plus loop overhead - coming to close to 20 us to read three buttons - this may indeed affect the music. A 2 kHz tone makes for 2,000 reads a second (buttons are checked once every wave), that's 40,000 us extra, 20 ms, or a 2% stretch.

You may try to tinker a bit with the delay times in the buzz function (I don't have a buzzer so I can't hear any sounds - using an LED in its place to see when it triggers). If that doesn't work I have to go down and dirty and replace the digitalRead() functions with the much faster direct reads (should be able to read three buttons and return to music playing in 1-2 us). I was afraid of this happening, hoped it was no problem.

All analog pins, should be same register. One read for the three of them, quick if/then to see if any are activated, if none, straight back to the music. 10-20 clock cycles or so. Should be no problem for your music - this 2 kHz tone would add 20,000-40,000 clock cycles, for 1.25-2.5 ms total, about 0.2% stretch of the tone.

1, 2. Animations are set up in the special effects section. This I designed to make as easy as possible to amend. At the moment it has indeed the same when going into alarm set mode and when switching from alarm to clock.  I have to change one variable and re-enable one of the effects blocks. Easy to change things here.
I'll add a bit in the manual on how to make changes, so you can play with this. It's basically a set of LED patterns and times to show it, in addition using ledsOn() and ledsOff() as convenience functions for all on and off.

3. I noticed myself as well. Have to fix that, should be an easy one as well. Just setting the correct flag. The intended behaviour is that the first press on hour changes to hour setting, the second and subsequent presses make the change. Same for switching to minute setting.
Apparently the first of the two is not set when you enter alarm set mode.

If there are more issues let me know. Can try and fix them all in one go :-)
Thanks man! I have summerized all the things I would like changed. So you can do it at one go.

I like the fact that you are making effects easy to change. But I am really afraid to touch the code. It takes me a full day of staring at code to just change a few things. And that is on a good day :)

About notes 1 and 2:

So please, please remember to reverse/change the effects that I asked in request number "1" and "2" in my previous post. That will really save me a lot of torturing myself.

About note 3:

You said that the intended behaviour is that the first press on hour changes to hour setting, the second and subsequent presses make the change. So, according to this: is anything supposed to flash when you first enter either of the setting modes or not? I am confused. Because when you enter alarm setting mode, it does NOT flash immediately.  Everything is solid at first. But in clock setting mode it does flash minutes initially. Minutes are flashing immediately. But I kind of liked the immediate flashing of minutes when you enter both setting modes. Gives you something to start with. Is that how it was intended to work.

Note 4: please remember the fast scrolling/hour and minute advancing thing.

Note: 5. Can you make the "hourly special effects" a bit more interesting? The one that plays every hour. I feel the current one is a bit boring. I am really afraid to touch it myself. I go OCD about checking and checking the code. Takes me a full day. Only if you have time or desire left from the other issues.

Note 6: In addition to my comments above, I'm thinking to be honest this Mario soundtrack for alarm and alarm lighting is more trouble than it is worth. Besides I didn't like it anyway.

Please, whatever it takes, replace the alarm music with another music with no lights or buzzes. Something that fits the purpose of alarm and piezo buzzer. May be something classical. Besides, removing the buzz and alarm lights should take care of some of the issues.

I would try to look for another music myself but I really wouldn't know what I am looking at. One that can be implemented into the current project, so that snooze and stop alarm buttons will work as intended.

But please remember to remove all related logic. Because once alarm buzz and lights are gone:

1. There will be no interference between hourly special effects and alarm lights; so hourly special effects can run every hour without interference. And priority logic of special effects can be removed. (which skips special effects if alarm lights are on)

2. The only thing that showed with on/off button  in off position (all functions off) was the alarm lights. That condition I believe, can be removed also. Since alarm lights are being ditched too.

Go Up