Closed MrCarlos closed 12 years ago
Your issue report doesn't appear to describe a problem with the G35Arduino library. Are you describing an issue in this library that needs to be fixed or improved? If you're having trouble with your XBee hardware or the programming of it, there are likely to be good sources of information or support elsewhere for that commercial product. If you are describing a problem with this library, please reopen this issue and be more specific.
Incidentally, you shouldn't have to modify the G35Arduino library to switch programs remotely. See Ticon2011 for an example of a sketch that controls switching without library modifications. The reason this is important is that your changes will be overwritten as library improvements come in.
Hi Mike,
Thanks for the reply. I don't have a problem with the g35 libraries. I was just looking for some friendly advice. I didn't see a forum on github setup for that specific purpose.
The example you provided in ticon2011 was helpful, but my main problem is that I don't know how to reliably monitor the serial port for an incoming character in such a way that it doesn't slow down the entire light program.
Best,
Carlos
On May 7, 2012, at 7:03 AM, Mike Tsao reply@reply.github.com wrote:
Your issue report doesn't appear to describe a problem with the G35Arduino library. Are you describing an issue in this library that needs to be fixed or improved? If you're having trouble with your XBee hardware or the programming of it, there are likely to be good sources of information or support elsewhere for that commercial product. If you are describing a problem with this library, please reopen this issue and be more specific.
Incidentally, you shouldn't have to modify the G35Arduino library to switch programs remotely. See Ticon2011 for an example of a sketch that controls switching without library modifications. The reason this is important is that your changes will be overwritten as library improvements come in.
Reply to this email directly or view it on GitHub: https://github.com/sowbug/G35Arduino/issues/12#issuecomment-5550630
avrfreaks.net is a good forum for general microcontroller-related programming questions. You're more likely to find people who know about the hardware you're using. I know nothing about XBee, so I can't help.
Generally, the Arduino serial library isn't going to be compatible with speed-critical code. It's very slow, and it seems to be pretty liberal with its use of interrupts, which will upset the timing of the light signals.
Hi,
I'm new to all this so if I posting this in the wrong section I apologize. I have been working on adding xbee communication to allow remote program changing. I have it working pretty much as a hack as I'm not a a programmer. I'm sort of at the end of my knowledge base and I just don't know what to do next to get it to work exactly how I want it.
My main problem is I had to use some delays to read the serial input from the Xbee. Those delays slowed the light programs down too much. I reduced the two delays to 5ms, the light programs are slightly slower than the stock code but they still look good, but now I have to push the key many times before the program picks up my key input. Not ideal. Maybe someone can help me learn the right way execute this idea?
Long term I want to also add a menu to select any program and jump right into it and add the ability to increase or decrease the program run times via xbee connection.
I modified the ProgramRunner.h
/* G35: An Arduino library for GE Color Effects G-35 holiday lights. Copyright © 2011 The G35 Authors. Use, modification, and distribution are subject to the BSD license as described in the accompanying LICENSE file.
By Mike Tsao <github.com/sowbug>.
See README for complete attributions. */
ifndef INCLUDE_G35_PROGRAM_RUNNER_H
define INCLUDE_G35_PROGRAM_RUNNER_H
include
//setup for xbee communication
include
SoftwareSerial mySerial = SoftwareSerial(2, 3); int incomingByte; char chrValue;
// ProgramRunner manages a collection of LightPrograms. // // It gives the current program a slice of time to run, decides when it's // time to switch to the next program, and asks the program_creator callback // to give it the next program when it's time. In Arduino terms, it's what // you want to call in your loop() method. // // switch_program() is public because the application might sometimes want // to change programs more frequently, for example if you've implemented // a remote control receiver. class ProgramRunner { public: ProgramRunner(LightProgram* (*program_creator)(uint8_t program_index), uint8_t program_count, uint16_t program_duration_seconds) : programcount(program_count), program_durationseconds(program_duration_seconds), programindex(programcount - 1), next_switchmillis(0), programcreator(programcreator), program(NULL) {}
void loop() {
//get data from incoming xbee communcation incomingByte = (mySerial.read()); chrValue = incomingByte;
// check xbee for in coming character
delay(5); if (incomingByte >= 0 && incomingByte <= 254) { Serial.print(chrValue); mySerial.println(chrValue); Serial.println(" was received "); }
// if it's an H (ASCII 72) turn ON the LED and goto switch program:
if (incomingByte == 'H') { digitalWrite(8, HIGH); //for debugging mySerial.print("Switching to "); delay(5); switch_program(); }
}
void switch_program() {
}
private: uint8_t programcount; uint16_t program_durationseconds; uint8_t programindex; uint32_t next_switchmillis; uint32_t next_domillis; LightProgram* (_programcreator)(uint8_t programindex); LightProgram program_; };
endif // INCLUDE_G35_PROGRAM_RUNNER_H