Page 3 of 4

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:16 pm
by lnevo
Yeah, this line is what sets the mode based on what's in the array...

Code: Select all

if (chooseLightning) { lightningMode=LightningModes[random(100)%sizeof(LightningModes)]; chooseLightning=false; } 
We'll have to do some logic here to set it to what's in InternalMemory... and how do you revert back to the random selections? We could do something like the PWM overrides, where if it's 255 we go back to our regularly scheduled program and if it's not then we hard code to that mode...

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:17 pm
by cosmith71
89delta wrote:Ok So I figured it out how to use the internal memory locations I think. Just not the actual location so am not sure just yet if it will mess with another setting.

But in Globals add:

#define Mem_B_StormMode 112

Then in checkcloud() find

static byte lightningMode=0; and replace with
static byte lightningMode=InternalMemory.read(Mem_B_StormMode);

Will be testing this right now.
Don't do this:
static byte lightningMode=0; and replace with
static byte lightningMode=InternalMemory.read(Mem_B_StormMode);
Instead, take this line out:

Code: Select all

if (chooseLightning) { lightningMode=LightningModes[random(100)%sizeof(LightningModes)]; chooseLightning=false; } 
and replace with this:

Code: Select all

lightningMode=InteralMemory.read(Mem_B_StormMode);
I think that should do it.

--Colin

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:19 pm
by lnevo
That does it but then we no longer have random cycling :)

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:21 pm
by cosmith71
lnevo wrote:That does it but then we no longer have random cycling :)
I thought that's what he wanted. :)

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:21 pm
by 89delta
Cool....you guys rock. Figured i'd take a shot at it Colin that way you're not overloaded...

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:26 pm
by 89delta
cosmith71 wrote:
lnevo wrote:That does it but then we no longer have random cycling :)
I thought that's what he wanted. :)
Oh don't get me wrong guys. Love the random part of it. But enjoying re-learning the code structure on how it all works and trying different things out. Besides the random part wouldn't work with slower drivers unless we can "over-ride" it by being able to select just the "Slow" Mode for the ELN's or other drivers. As the Fast and Mega modes work fine with the LDD's and the CAT4101's i've got laying around.

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:27 pm
by cosmith71
No problem!

Lee, how is it done with the DC pumps? Isn't there a way to cycle through them with memory control? I'm not up on them...

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 1:47 pm
by lnevo
Yes, but we should strive to maintain a single code base :) I'm trying to avoid multiple versions.

With the DCPumps we have a variable UseMemory that we set when we want to use Memory or Override.

We can keep the line in there, but I recommend if Memory is 255 then go with the Array. If it's set than go with the mode that's set.

89, thats the nice thing about the array though, if you have slow drivers, just put Slow :) Random is useless (for now) with the slow drivers, until someone comes up with a second "slow" method :)

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 2:11 pm
by 89delta
lnevo wrote:Yes, but we should strive to maintain a single code base :) I'm trying to avoid multiple versions.

With the DCPumps we have a variable UseMemory that we set when we want to use Memory or Override.

We can keep the line in there, but I recommend if Memory is 255 then go with the Array. If it's set than go with the mode that's set.

89, thats the nice thing about the array though, if you have slow drivers, just put Slow :) Random is useless (for now) with the slow drivers, until someone comes up with a second "slow" method :)
True Lee....But I was kinda of thinking along your wanting to turn this into another class and just being able to have the end user select which one to use. Nevermind....am having a brain fart. I get what you're saying now. After you get this into another class we just add the coding for it into our INO:

byte LightningModes[] = { Slow }; or
byte LightningModes[] = { Slow, Fast, Mega };

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 2:55 pm
by lnevo
Yeah when we get to that point we can do something like we do for dcpump. I like how all this is proceeding. Ideas are great, keep em coming!

Re: Cloud and Lightning Code

Posted: Thu Aug 07, 2014 3:58 pm
by cosmith71
I've been working on some upgrades to the lightning engine. Stay tuned!

--Colin

Re: Cloud and Lightning Code

Posted: Fri Aug 08, 2014 9:09 am
by cosmith71
Update to OP

Improved lightning engine.

New option for increased Mega Lightning.

--Colin

Re: Cloud and Lightning Code

Posted: Fri Aug 08, 2014 9:24 am
by lnevo
Cool, but by making the rate a define, we can't modify it on the fly through mem or variable changing. So, let's get away from using #defines for this... :) At some point I'll be making them all properties of the Cloud class.

My recommendation though would be to make it a separate mode... so Mega1 Mega2. This way we maintain one variable to choose which mode we want. Very cool updates though, keep em coming...

Re: Cloud and Lightning Code

Posted: Fri Aug 08, 2014 9:59 am
by cosmith71
lnevo wrote:Cool, but by making the rate a define, we can't modify it on the fly through mem or variable changing. So, let's get away from using #defines for this... :) At some point I'll be making them all properties of the Cloud class.

My recommendation though would be to make it a separate mode... so Mega1 Mega2. This way we maintain one variable to choose which mode we want. Very cool updates though, keep em coming...
Done. Went with Mega and Mega2, since Mega1 looks like Megal. :mrgreen:

--Colin

Re: Cloud and Lightning Code

Posted: Fri Aug 08, 2014 1:20 pm
by lnevo
Did you see that chalice encrusted on the Megaladon tooth? :)

Re: Cloud and Lightning Code

Posted: Fri Aug 15, 2014 10:17 am
by cosmith71
New mode:

Calm

No lightning at all. Good for putting into a random sequence so there isn't lightning every time there is a cloud. OP updated.

--Colin

Re: Cloud and Lightning Code

Posted: Sat Aug 30, 2014 4:17 pm
by jegillis
Is there a version of this code for the dimming expansion?

Re: Cloud and Lightning Code

Posted: Sat Aug 30, 2014 4:19 pm
by cosmith71
No. I'm sure it could be adapted, but I don't have a dimming expansion. :(

--Colin

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 7:04 am
by cosmith71
RANet dimming expansion on the way! :D

Lee, have you done any work on putting this into a library? If not, I may start as a learning experience.

--Colin

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 8:23 am
by lnevo
I haven't had time yet.. feel free to give it a try and I can certainly help :)

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 8:37 am
by cosmith71
Awesome! I've always thought that the best way to learn something was to do it. I'm sure I'll have questions.

--Colin

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 9:00 am
by rimai
The lightning will have to be incorporated in the slave side. The cloud should be fine.
The RANet bandwidth is not fast enough.
It sends data every 100ms.

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 9:27 am
by cosmith71
rimai wrote:The lightning will have to be incorporated in the slave side. The cloud should be fine.
The RANet bandwidth is not fast enough.
It sends data every 100ms.
Slave side? Esplain please.

--Colin

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 9:34 am
by rimai
Every RANet-Ready Wireless Module has a microcontroller in it to receive and process the wireless data.
The current firmware can only process data for relays and dimming channels.
We will need to create a firmware that can accept commands, so you can trigger remotely.
For example, a command to trigger the lightning effect on the dimming module.
You are not the only one that will want this.
The person using the dimmable LED driver wants this too.
I just need to find some time to put something together, but I'd like to release the next libs first.
The RANet requires some changes on the core libraries released from Arduino, specifically the SoftwareSerial library and I'd like to have at least the base communication working and released before we start adding functionality to it.
We have been getting some help from Sacohen, lnevo, AlanM, binder and others to see if any other minor bug is found.
Hopefully, we get a release soon.

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 9:36 am
by rimai
I updated the previous post.
I meant to say RANet-Ready Wireless Module and not RANet-Add On.

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 9:54 am
by cosmith71
Ah, I see. Load the sequence and then trigger when needed. I understand.

--Colin

Re: Cloud and Lightning Code

Posted: Thu Sep 04, 2014 10:37 am
by jegillis
And I thought that just coding this for the dimming expansion would work. I don't know how to code much of anything but would be happy to test anything you come up with.

Re: Cloud and Lightning Code

Posted: Fri Sep 05, 2014 7:40 am
by TheMikey
I feel like a bit of an idiot, but I can't seem to find this line:

byte LightningModes[] = { Slow, Fast, Mega };

To even start this programming. Is there an updated full code I need to find somewhere before attempting to customize this?

Re: Cloud and Lightning Code

Posted: Fri Sep 05, 2014 7:44 am
by cosmith71
The updated code is in the first post.

Do a search for this:

Code: Select all

 byte LightningModes[] = { Mega, Mega, Mega2, Calm, Calm };
And change it to your liking.

--Colin

Re: Cloud and Lightning Code

Posted: Fri Sep 05, 2014 8:04 am
by TheMikey
Found it! Thanks!