Page 1 of 1

menus and lights

Posted: Tue Dec 25, 2012 4:40 pm
by rossbryant1956
I am picking apart some code and using the pieces I like. Please explain to me what this does:

Code: Select all

// Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = 0;
  ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
It looks like when a menu toggle is pressed it only turns off lights on the second outlet box. I will have lights on both of my outlet boxes. It obviously goes with this section:

Code: Select all

void DrawCustomMain()
{
  int x,y;
  char text[10];
  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
  pingSerial();

  // Relay Expansion
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph( 5, 5 );
}
I am still brand new at menus, so thanks in advance. BTW I am not using any of my LED\PWM ports at this time so if I don't need that part pls advise. Thx

Re: menus and lights

Posted: Tue Dec 25, 2012 4:48 pm
by rimai
It tells the controller which ports will be used as lights.
If you have lights on both boxes, you need to set the correct bits for each box.

Re: menus and lights

Posted: Tue Dec 25, 2012 5:15 pm
by rossbryant1956
So then if I have lights on both boxes I need:

Code: Select all

// Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = 0;
  ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit;
  ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
This look right? Thx

Re: menus and lights

Posted: Tue Dec 25, 2012 5:19 pm
by rimai
That works, but you can also remove this redundant code, because you are assigning a value to that same variable on the very next line.

Code: Select all

ReefAngel.LightsOnPorts = 0;