Cloud and Lightning Code

Do you have a question on how to do something.
Ask in here.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post 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...
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

That does it but then we no longer have random cycling :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

lnevo wrote:That does it but then we no longer have random cycling :)
I thought that's what he wanted. :)
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Cloud and Lightning Code

Post by 89delta »

Cool....you guys rock. Figured i'd take a shot at it Colin that way you're not overloaded...
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Cloud and Lightning Code

Post 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.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post 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 :)
89delta
Posts: 163
Joined: Mon Oct 15, 2012 7:21 pm
Location: Leesburg, GA

Re: Cloud and Lightning Code

Post 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 };
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post 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!
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

I've been working on some upgrades to the lightning engine. Stay tuned!

--Colin
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Update to OP

Improved lightning engine.

New option for increased Mega Lightning.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post 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...
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

Did you see that chalice encrusted on the Megaladon tooth? :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Cloud and Lightning Code

Post by jegillis »

Is there a version of this code for the dimming expansion?
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

No. I'm sure it could be adapted, but I don't have a dimming expansion. :(

--Colin
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Cloud and Lightning Code

Post by lnevo »

I haven't had time yet.. feel free to give it a try and I can certainly help :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post 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.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post 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.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Cloud and Lightning Code

Post by rimai »

I updated the previous post.
I meant to say RANet-Ready Wireless Module and not RANet-Add On.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post by cosmith71 »

Ah, I see. Load the sequence and then trigger when needed. I understand.

--Colin
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Cloud and Lightning Code

Post 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.
Image
TheMikey
Posts: 4
Joined: Wed Sep 25, 2013 9:15 am

Re: Cloud and Lightning Code

Post 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?
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Cloud and Lightning Code

Post 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
TheMikey
Posts: 4
Joined: Wed Sep 25, 2013 9:15 am

Re: Cloud and Lightning Code

Post by TheMikey »

Found it! Thanks!
Post Reply