Exemplo n.º 1
0
void LEDInit(){
  GreenLEDOutput();
  YellowLEDOutput();
  BlueLEDOutput();
  RedLEDOutput();  
  ControlLED(0x0F);

}
Exemplo n.º 2
0
//--------------------------------------------------------------
void OSCCortexApp::draw()
{
    ofSetColor(255);
    vidGrabber.draw(0, 0, 640, 480);
    if (vidGrabber.isFrameNew()) {
        framePix.clear();
        framePix = vidGrabber.getPixelsRef();

        ofSetColor(0);
        ofNoFill();
        float width = 640.0 / 12.0;
        float height = 480.0 / 6.0;

        for (int i = 0; i < 6; i++) {

            for (int j = 0; j < 12; j++) {
                float x = ofMap(j, 0, 12, 0, 640);
                float y = ofMap(i, 0, 6, 0, 480);

                ofRect( x, y, width, height);

                ofVec2f haloCenter(x + width /2, y + height / 2);
                ofCircle(haloCenter, 3);

                ofVec2f ledZero(0,1);

                for (int k = 0; k < 31; k++) {
                    float angle = ofMap(k, 0, 31, 0, 360);
                    ofVec2f dir = ledZero.getRotated(angle);
                    dir.y*=2;
                    dir*=16;
                    ofLine(haloCenter, haloCenter + dir);

                    ControlLED(j, i, k, framePix.getColor((haloCenter.x + dir.x)/2, (haloCenter.y + dir.y)/2), 0.0);
                }


                //            ControlHalo(j, i, framePix.getColor(x/2, y/2), 0.0);
            }
        }

    }
}
Exemplo n.º 3
0
void LEDPatternHandler(uint32_t currentTime){
  static boolean onOff = true,fastIndicator = true,updatePattern;
  static uint8_t patternCount;
  static uint32_t patternTime;
  static uint32_t fastBlinkTime;

  if (displayFSData == true && motorState == HOLD){
    LEDPatternMatrix[GREEN_] = OverRideMatrix[GREEN_];
    LEDPatternMatrix[YELLOW_] = OverRideMatrix[YELLOW_];
    LEDPatternMatrix[BLUE_] = OverRideMatrix[BLUE_];
    LEDPatternMatrix[RED_] = OverRideMatrix[RED_]; 
  }
  else{
    LEDPatternMatrix[GREEN_] = LEDPattern[GREEN_];
    LEDPatternMatrix[YELLOW_] = LEDPattern[YELLOW_];
    LEDPatternMatrix[BLUE_] = LEDPattern[BLUE_];
    LEDPatternMatrix[RED_] = LEDPattern[RED_];
  }

  if (currentTime - patternTime >= PATTERN_TIME){
    patternTime = currentTime;
    if (onOff == true){
      patternCount++;
      ctrlByte = 0xFF;
      for (uint8_t i = 0; i <= 3; i++){
        if (LEDPatternMatrix[i] == 0){
          ctrlByte &= ~(1<<i);
        }
        if (LEDPatternMatrix[i] >= 2 && LEDPatternMatrix[i] < 6){
          if (patternCount % LEDPatternMatrix[i] == 0){
            ctrlByte &= ~(1<<i);
          }
        }
      }
      onOff = false;
    }
    else{
      ctrlByte = 0x00;
      for (uint8_t i = 0; i <= 3; i++){
        if (LEDPatternMatrix[i] == 1){
          ctrlByte |= 1<<i;
        }
      }
      onOff = true;
    }
    updatePattern = true;
  }
  if (currentTime - fastBlinkTime >= PATTERN_TIME_FAST){
    fastBlinkTime = currentTime;
    fastIndicator ^= 1;
    for (uint8_t i = 0; i <= 3; i++){
      if (LEDPatternMatrix[i] == 7){
        if (fastIndicator == true){
          ctrlByte |= 1<<i;
        }
        else{
          ctrlByte &= ~(1<<i);
        }

      }
    }
    updatePattern = true;
  }
  if (updatePattern == true){
    ControlLED(ctrlByte);
    updatePattern = false;
  }

}