void TestSimulationController::testCase1( ) {
  InputButton *btn1 = new InputButton( );
  InputButton *btn2 = new InputButton( );
  And *andItem = new And( );
  Led *led = new Led( );
  QNEConnection *conn = new QNEConnection( );
  QNEConnection *conn2 = new QNEConnection( );
  QNEConnection *conn3 = new QNEConnection( );
  editor->getScene( )->addItem( led );
  editor->getScene( )->addItem( andItem );
  editor->getScene( )->addItem( btn1 );
  editor->getScene( )->addItem( btn2 );
  editor->getScene( )->addItem( conn );
  editor->getScene( )->addItem( conn2 );
  editor->getScene( )->addItem( conn3 );
  conn->setPort1( btn1->output( ) );
  conn->setPort2( andItem->input( 0 ) );
  conn2->setPort1( btn2->output( ) );
  conn2->setPort2( andItem->input( 1 ) );
  conn3->setPort1( andItem->output( ) );
  conn3->setPort2( led->input( ) );
  QVector< GraphicElement* > elms( SimulationController::sortElements( editor->getScene( )->getElements( ) ) );
  QVERIFY( elms.at( 0 ) == btn1 || elms.at( 1 ) == btn1 );
  QVERIFY( elms.at( 0 ) == btn2 || elms.at( 1 ) == btn2 );
  QVERIFY( elms.at( 2 ) == andItem );
  QVERIFY( elms.at( 3 ) == led );
}
Beispiel #2
0
QList<QVector3D> ControlPlan2D::controlLed(const QString & valeur,Cube cubeMotif,int NumeroPlan,QList<QVector3D>  liste_vecteur3D,Ui::MainWindow *ui,QPushButton* buttons[90]){
        QString strlig=valeur[0];
        QString strcol=valeur[1];
        int lig=strlig.toInt(0,10);
        int col=strcol.toInt(0,10);
        Led l;
        l=cubeMotif.getList1()->value(NumeroPlan).getLed(lig,col);
        l.modifierEtat();
        Plan p1=cubeMotif.getList1()->value(NumeroPlan);
        p1.updatePlan(l,lig,col);
        cubeMotif.updateCube(p1,NumeroPlan);
        QVector3D v;
        v=QVector3D(abs(8-col),NumeroPlan,abs(8-lig));
        liste_vecteur3D.append(v);
        QString s ;
        s=QString::number(liste_vecteur3D.size());
        qDebug()<<"la taille de la liste est "+s;
        ui->widget->setListPoints(liste_vecteur3D);
        if(cubeMotif.getList1()->value(NumeroPlan).getLed(lig,col).getEtat()==1){
            liste_vecteur3D.append(v);
           ui->widget->setListPoints(liste_vecteur3D);
        }
        else {
            liste_vecteur3D.removeAll(v);
            ui->widget->setListPoints(liste_vecteur3D);
        }
        afficheLed(buttons,lig,col,l.getEtat());
        return liste_vecteur3D;
}
void
initLeds()
{
  redLed.off();
  greenLed.off();
  redLed.quicklyMakeBlinkSeveralTimes(3);
}
Beispiel #4
0
int handleStatus(String status) {
  if (status == "BOOKED") {
    fadeRate = 2000;
    led.fadeOnce(colors[1], blue, 2000);
    colors[0] = blue;
    colors[1] = blueSoft;
    return 1;
  } else if (status == "VACANT") {
    fadeRate = 2000;
    led.fadeOnce(colors[1], green, 2000);
    colors[0] = green;
    colors[1] = greenSoft;
    return 1;
  } else if (status == "FIVE_MINUTE_WARNING") {
    fadeRate = 1500;
    led.fadeOnce(colors[1], orange, 2000);
    colors[0] = orange;
    colors[1] = orangeRed;
    return 1;
  } else if (status == "ONE_MINUTE_WARNING") {
    fadeRate = 500;
    colors[0] = red;
    colors[1] = orange;
    return 1;
  }

  return 0;
}
void VideoBasedTracker::drawLedCircleOnStatusImage(Led const &led,
        bool filled,
        cv::Vec3b color) {
    cv::circle(m_statusImage, led.getLocation(),
               led.getMeasurement().diameter / 2., cv::Scalar(color),
               filled ? -1 : 1);
}
void Wrapper::ledSet(WbDeviceTag tag, int state) {
  Device *device = DeviceManager::instance()->findDeviceFromTag(tag);
  Led *led = dynamic_cast<Led *>(device);
  if (led) {
    led->setLedRequested();
    led->setState(state);
  }
}
void rt_thread_entry_led_test(void* parameter)
{
	Led led;
	led.init();
	while(1)
	{
		led.toggle();
		
		rt_thread_delay(RT_TICK_PER_SECOND/5);
	}
}
Beispiel #8
0
void LedTests::addTimeAxis() {
    iAnimation->addTimeAxis(0, 100, 100, kPriorityLow, false);

    Led* led = new Led(iAnimation,
                       *iAnimation,
                       1,
                       Position(0,0),
                       NULL);

    led->addTimeAxis();

    QVERIFY(led->timeAxis() != NULL);
}
// Setup function
void setup()
{
  // connection to the salve computer in the garage
  Serial1.begin(9600);

  // register Particle variables
  Particle.variable("rssi", rssi);
  Particle.variable("temperature", temperature);
  Particle.variable("humidity", humidity);

  // register Particle functions
  Particle.function("Door", funcDoor);
  Particle.function("Restart", funcRestart);

  // connect to the blynk server
  //Blynk.begin("7cb12eb10dee49f98c61d3e7b34f7433");

  //while (Blynk.connect() == false) {
    // Wait until connected
  //}

  debug("STEJ Garage Control");
  debug(String::format("Built: %s %s",__DATE__, __TIME__));

  closeLed.setMax(brightness);
  openLed.setMax(brightness);

  openButton.attach(bePressed, onOpenPressed);
  closeButton.attach(bePressed, onClosePressed);

  screen.begin(0x73, true);
  screen.setBrightness((brightness / 100.0) * 15);
  screen.clearText();

  screen << "Now is the time for a very long message to see if it works!";

  //lcd.clear();

  // Adds newline to every command
  cmd.printLfCr();

  cmd.attach(GC_DoorStatus, &onDoorStatus);
  cmd.attach(GC_Temperature, &onTemperature);

  cmd.sendCmd(GC_Acknowledge, F("Garage Control Master Started!"));

  onFiveSeconds(); fiveSecondTimer.start();
  fiveMinuteTimer.start();
  onThirtySeconds(); thirtySecondTimer.start();
}
void breathe(Led & led)
{
  if( !led.isRunning() )
  {
    if( led.isOn() )
    {
      led.fadeOff(breathe);
    }
    else
    {
      led.fadeOn(breathe);
    }
  }
}
bool Chirp::overlaps(Led led) {
	float maxMoveDistance = lastSeen * Config::getRobotSpeed();
	float maxRotation = lastSeen * Config::getRobotRotation();
	float distance = util::distance(position, led.getPoint());

	switch(led.getType()) {
	case Led::RED:
		return distance + maxMoveDistance < Config::getRobotDiameter();
	case Led::BLUE:
		return distance + maxMoveDistance < Config::getRobotDiameter() / 2 + Config::getCameraLedSize();
	case Led::GREEN:
		return distance + maxMoveDistance < (1/2.0 + 1.0/4.0)  * Config::getRobotDiameter();
	}
}
bool Chirp::closeTo(Led led) {
	float maxMoveDistance = lastSeen * Config::getRobotSpeed();
	float maxRotation = lastSeen * Config::getRobotRotation();
	float distance = util::distance(position, led.getPoint());

	switch(led.getType()) {
	case Led::RED:
		return distance < maxMoveDistance;
	case Led::BLUE:
		return distance < maxMoveDistance + Config::getRobotDiameter() / 2;
	case Led::GREEN:
		// TODO: function currently assumes the robot is rotated towards the green light, use maxRotation to gain increased precision
		return distance < maxMoveDistance + Config::getRobotDiameter() / 4;
	}

}
Beispiel #13
0
			/// Must be called at least every ms
			void
			run()
			{
				led->run();
				
				if (timer.isExpired() && (isBlinking || state == FIRST_BREAK || state == SECOND_BREAK))
				{
					switch (state)
					{
						case FIRST_FLASH:
							led->on(onFade);
							
							timer.restart(on1);
							state = FIRST_BREAK;
							break;
							
						case FIRST_BREAK:
							led->off(offFade);
							
							timer.restart(pause1);
							state = SECOND_FLASH;
							break;
							
						case SECOND_FLASH:
							led->on(onFade);
							
							if (isCounting && !--counter) {
								isBlinking = false;
								isCounting = false;
							}
							
							timer.restart(on2);
							state = SECOND_BREAK;
							break;
							
						case SECOND_BREAK:
							led->off(offFade);
							
							timer.restart(pause2);
							
						default:
							state = FIRST_FLASH;
							break;
					}
				}
			}
Beispiel #14
0
void draw(const uint8_t *frame, uint8_t numRow, uint8_t x, uint8_t y) {
  uint8_t newFrame[numRow];
  for(uint8_t i = 0; i < numRow; i++) {
    newFrame[i] = frame[i] >> x;
  }
  for(uint8_t j = 0; j < numRow; j++) {
    lc.setRow(0, j + y, newFrame[j]);
  }
}
Beispiel #15
0
void LedTests::setTimeAxisCurrentValue() {
    Led* led = new Led(iAnimation,
                       *iAnimation,
                       1,
                       Position(0,0),
                       NULL);

    iAnimation->addTimeAxis(0, 10, 100, kPriorityLow, false);
    ColourValue* frameValue = new ColourValue(led, QColor(Qt::blue));

    for(int i = 0; i < 10; i++) {
        iAnimation->timeAxis()->setCurrentFrame(i);

        led->setTimeAxisCurrentValue(*frameValue);

        QCOMPARE(led->currentColour(), QColor(Qt::blue));
    }
}
void Wrapper::stopActuators() {
  // reset all the requests

  for (int i=0; i<5; i++) {
    Led *led = DeviceManager::instance()->led(i);
    led->resetLedRequested();
  }

  vector<Device *>::const_iterator it;
  const vector<Device *> &devices = DeviceManager::instance()->devices();
  for (it=devices.begin() ; it < devices.end(); it++) {
    Sensor *s = dynamic_cast<Sensor *>(*it);
    if (s)
      s->resetSensorRequested();
  }

  // send the packet
  robotStep(0);
}
// Loop function
void loop()
{
  // process serial commands
  cmd.feedinSerialData();

  // read buttons
  openButton.run();
  closeButton.run();

  // update led matrix
  screen.run(mpScrollLeft, 100);

  // update leds
  closeLed.display();
  openLed.display();

  // update blynk
  //Blynk.run();
}
Beispiel #18
0
void LedTests::constructor() {
    QFETCH(Position, position);
    QFETCH(int, number);
    QFETCH(QString, error);

    try {
        Led* led = new Led(iAnimation,
                      *iAnimation,
                      number,
                      position,
                      NULL);

        QCOMPARE(led->position(), position);
        QCOMPARE(led->number(), number);

    } catch(IllegalArgumentException& e){
        QCOMPARE(e.errorMessage(), error);

        return;
    }
}
Beispiel #19
0
			/// Must be called at least every ms
			void
			run()
			{
				led->run();
				
				if (!led->isFading() && (isPulsing || !pulseDirection))
				{
					if (pulseDirection) {
						led->on(halfPeriod);
						
						if (isCounting && !--counter) {
							isPulsing = false;
							isCounting = false;
						}
					}
					else {
						led->off(halfPeriod);
					}
					pulseDirection = !pulseDirection;
				}
			}
Beispiel #20
0
int main(int argc, char** argv){

//Definir estados Leds:
LedRed.LedOff(); //OK
LedGreen.LedOff(); //OK
//Asignar interrupciones a teclas
Tecla1.teclaInterrupcion(); //OK
Tecla3.teclaInterrupcion(); //OK

//Configurar interrupciones:
INTCONSET= _INTCON_MVEC_MASK; //CONFIGURE INTERRUPT CONTROLLLER FOR MULTIVECTOR
__asm__ volatile("ei"); //ENABLE INTERRUPTS

//Main program:
while(1){        
        
        if(Tecla1.pulsada()== 1){
            LedRed.LedOn();
        }
        //PULSAR TECLA 2(RB12) -> APAGAR LOS DOS
        if(Tecla2.pulsada_ahora() == 1){ //DOESNT WORKS
            LedGreen.LedOn();
        }
        
        //PULSAR TECLA 3(RB14) -> ENCENDER LED ROJO(RB4) //OK
        if(Tecla3.pulsada()== 1){
            LedRed.LedOff();
            LedGreen.LedOff();
        }
}
    return 0;
}
void AxisDetailsWidget::addLed(int row, int column) {
    Led* led = iAnimation.ledAt(Position(row, column));

    if(led == NULL) {
        throw IllegalArgumentException("AnimationDetailsWidget::addLed : NULL led");
    }

    if(!iLedDetails.contains(led->number())) {
        int count = iLedDetails.count();
        qDebug("add new led, %d, %d", row, column);

        QLabel* ledNumberLabel = new QLabel(this);
        ledNumberLabel->setMaximumWidth(LED_LABEL_WIDTH);
        ledNumberLabel->setMinimumWidth(LED_LABEL_WIDTH);

        FrameListWidget* framesListWidget = new FrameListWidget(this, axisData(*led), *this);//, count);
        QToolButton* closeButton = new QToolButton(this);
        closeButton->setObjectName(QString::fromUtf8("detailsClose"));
        closeButton->setIcon(QIcon(":/images/delete.png"));

        iGridLayout->addWidget(closeButton, count, 0);
        iGridLayout->addWidget(ledNumberLabel, count, 1);
        iGridLayout->addWidget(framesListWidget, count, 2);
       // iGridLayout->setColumnStretch(1, 1);
       // iGridLayout->addWidget(new QWidget(), count, 3);
       // iGridLayout->setColumnStretch(3, 2);

        iLedDetails.insert(led->number(), new LedDetails(*this,
                                                         *led,
                                                         *ledNumberLabel,
                                                         *framesListWidget,
                                                         *closeButton));

        iCloseAll->setEnabled(true);
        iScrollAreaWidgetContents->setShowCurrentFrameLine(true);

        doResize();
        layout()->invalidate();
    }
}
Beispiel #22
0
void LedTests::colourChanged() {
    QFETCH(int, currentFrame);

    Led* led = new Led(iAnimation,
                       *iAnimation,
                       1,
                       Position(0,0),
                       NULL);

    QSignalSpy updatedSpy(led, SIGNAL(updated()));

    iAnimation->addTimeAxis(0, 10, 100, kPriorityLow, false);
    iAnimation->timeAxis()->setCurrentFrame(currentFrame);

    QCOMPARE(updatedSpy.count(), 1);

    for(int i = 0; i < 10; i++) {
        led->colourChanged(i);

        QCOMPARE(updatedSpy.count(), (i >= currentFrame) ? 2 : 1);
    }
}
void onDoorStatus()
{
  debug("onDoorStatus()");

  door_status = (DS) cmd.readInt32Arg();
  cmd.sendCmd(GC_Acknowledge, F("door"));

  if( ((door_command == DC_OPEN_DOOR)  && (door_status == DS_Open  )) ||  // door is now open
      ((door_command == DC_CLOSE_DOOR) && (door_status == DS_Closed)) ||  // door is now closed
       (door_command == DC_NONE)                                       )
  {
    door_command = DC_NONE;

    movementWatchdog.stop();

    switch( door_status )
    {
      case DS_Open:
        openLed.on();
        closeLed.off();
        break;

      case DS_Closed:
        closeLed.on();
        openLed.off();
        break;
    }
  }
  else
  {
    switch( door_command )
    {
      case DC_OPEN_DOOR:
        breathe(openLed);
        closeLed.off();
        break;
      
      case DC_CLOSE_DOOR:
        breathe(closeLed);
        openLed.off();
        break;
    }
  }

  updateDisplay();

  Particle.publish(F("Door"), toString(door_status), PRIVATE);

  //lcdPrint(0, toString(door_status));
  //lcdPrint(1, toString(door_command));
}
Beispiel #24
0
void LedTests::copyConstructor() {
    QFETCH(Position, position);
    QFETCH(int, number);

    Led* led = new Led(iAnimation,
                  *iAnimation,
                  number,
                  position,
                  NULL);

    Led* copyLed = new Led(*led);

    QCOMPARE(copyLed->position(), led->position());
    QCOMPARE(copyLed->number(), led->number());

    // TODO add axis tests
}
Beispiel #25
0
void LedTests::addValueAxis() {
    QFETCH(int, numValueAxes);
    QFETCH(bool, addTimeAxis);
    QFETCH(int, currentFrameNum);

    Led* led = new Led(iAnimation,
                       *iAnimation,
                       1,
                       Position(0,0),
                       NULL);

    /*if(addTimeAxis) {
        led->addTimeAxis();
    }*/



    if(addTimeAxis) {
        iAnimation->addTimeAxis(0, 100, 100, kPriorityLow, false);
        //iAnimation->timeAxis()->setCurrentFrame(currentFrameNum);
    }

    for(int i = 0; i < numValueAxes; i++) {
        iAnimation->addValueAxis(-10, 10, 0, kPriorityLow, false);
    }

    for(int i = 0; i < numValueAxes; i++) {
        //led->addValueAxis(i);

        QCOMPARE(led->axisAt(i).axis().lowValue(), iAnimation->axisAt(i).lowValue());
        QCOMPARE(led->axisAt(i).axis().highValue(), iAnimation->axisAt(i).highValue());
        QCOMPARE(led->axisAt(i).axis().zeroValue(), iAnimation->axisAt(i).zeroValue());
        QCOMPARE(led->axisAt(i).axis().priority(), iAnimation->axisAt(i).priority());
        QCOMPARE(led->axisAt(i).axis().isOpaque(), iAnimation->axisAt(i).isOpaque());

        if(addTimeAxis) {
            ValueAxisData& axis = led->axisAt(i);

            QCOMPARE(static_cast<const LinkedValue&>(axis.frameAt(axis.axis().zeroValue()).value()).colour(),
                    static_cast<const ColourValue&>(led->timeAxis()->currentFrame().value()).colour());
        }
    }
}
Beispiel #26
0
void draw(const uint8_t *frame, uint8_t numRow) {
  for(uint8_t i = 0; i < numRow; i++) {
      lc.setRow(0, i, frame[i]);
  }
}
/**
 * Start of loop related code:
 *      LED signaling
 */
void
processStartOfLoop()
{
  greenLed.quicklyMakeBlinkSeveralTimes(3);
}
Beispiel #28
0
void loop() {
  led.fade(colors, 2, fadeRate);
}
Beispiel #29
0
void StatusXMLDocumentHandler::startTag(QString tagName, QHash<QString, QString> attributes)
{
    setStatus(false);
    bool tmp = true;
    if(tagName == "DisplayStatus")
    {
    }
    if(checkData(attributeList.value(tagName), attributes))
    {
        if(tagName == "StatusText")
        {
            int p;
            float f;


            if(validateAttribute(attributes.value("name_text_id"), _int, &p, &tmp))
                statusData.setNameTextId(p);

            if(attributes.contains("value"))
            {
                if(validateAttribute(attributes.value("value"), _float, &f, &tmp))
                    statusData.setValue(f);

                if(validateAttribute(attributes.value("unit_text_id"), _int, &p, &tmp))
                    statusData.setUnitTextId(p);

                if(validateAttribute(attributes.value("precision"), _int, &p, &tmp))
                    statusData.setPrecision(p);
            }
        }
        else if(tagName == "Led")
        {
            int p;
            QString s;

            Led led;
            if(validateAttribute(attributes.value("id"), _int, &p, &tmp))
            {
                if(!leds.contains(p))
                {
                    led.setId(p);
//                    leds.insert(p,led);

//                    status.addLed(led);
                }
                else
                {
//                    led = leds.value(p);
                }
            }


            if(validateAttribute(attributes.value("color"), _string, &s, &tmp))
            {
//                if(ledData)
                    led.setColor(s);
            }

            if(validateAttribute(attributes.value("blink"), _int, &p, &tmp))
            {
//                if(ledData)
                    led.setBlink(p);
            }

        }
    }
    else
    {
        error("Not all mandatory attributes are validated");
    }
    setStatus(tmp);
}
Beispiel #30
0
void Init() {
  lc.shutdown(0,false);  // Wake up displays
  lc.setIntensity(0,0);  // Set intensity levels
  lc.clearDisplay(0);  // Clear Displays
}