Exemplo n.º 1
0
int main(void) {

  // -------- Inits --------- //
  clock_prescale_set(clock_div_1);                  /* CPU clock 8 MHz */
  initUSART();
  printString("\r\nWelcome to the Servo Sundial.\r\n");
  printString("Type S to set time.\r\n");

  initTimer0_Clock();
  initTimer1_Servo();
  sei();                                   /* set enable interrupt bit */
  LED_DDR |= (1 << LED0);                             /* blinky output */
  LASER_DDR |= (1 << LASER);                    /* enable laser output */

  // ------ Event loop ------ //
  while (1) {

                                                 /* Poll clock routine */
    if (ticks == OVERFLOWS_PER_SECOND) {
      ticks = 0;
      everySecond();
    }

    pollSerial();

  }                                                  /* End event loop */
  return (0);                            /* This line is never reached */
}
Exemplo n.º 2
0
MainWindow::MainWindow( QWidget *parent, P_ImgSrc imgsrc )
    : QMainWindow( parent ), ui( new Ui::MainWindow ), barcodeTimeoutCounter{ 0 }, imageSource{ imgsrc },
      barcodeTimeoutAlarmRaised{ false }, invalidBarcodeCounter{ 0 }
{
    ui->setupUi( this );

    //Setup seconds timer
    connect( &secondsTimer, SIGNAL( timeout() ), this, SLOT( everySecond() ) );
    secondsTimer.start( 1000 );

    //Timer to update glwidget
    connect( &imageDisplayTimer, SIGNAL( timeout() ),
              this, SLOT( updateImageDisplay() ) );
    imageDisplayTimer.start( 33 );

    //Adjust size proportions of splitter
    QList<int> sizes;
    sizes.append( 150 );
    sizes.append( 1 );
    ui->splitter->setSizes( sizes );

    ui->tabWidget->setCurrentIndex( 0 );

    //Load widget states
    loadAlarmCheckboxStates();
    loadBarcodeTimeoutSpinBoxState();

    connect( &imgproc, SIGNAL( foundBarcode( const QString ) ),
             this, SLOT( validateBarcode( const QString )) );

    //Load settings
    barcode_settings.load();
    resetBarcodeTimeoutCounter();
    camera_settings.load();
    general_settings.load();
    on_hsThreshold_valueChanged( general_settings.threshold );
    loadHsThresholdState();
    hole_settings.load();

    //Valid barcodes combo box
    cmbValidBarcodeModel.setStringList( barcode_settings.valid_barcodes );
    ui->cmbValidBarcode->setModel( &cmbValidBarcodeModel );

    //Alarms
    ui->tvAlarms->setModel( &tvAlarmsModel );
    ui->tvAlarms->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
    ui->tvAlarms->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
    ui->tvAlarms->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::ResizeToContents );
    connect( this, SIGNAL( barcode_timeout_alarm() ), &tvAlarmsModel, SLOT( raiseBarcodeTimeoutAlarm() ) );
    connect( this, SIGNAL( invalid_barcode_alarm() ), &tvAlarmsModel, SLOT( raiseInvalidBarcodeTimeoutAlarm() ) );
    connect( &imgproc, SIGNAL( missingHole() ), &tvAlarmsModel, SLOT( raiseMissingHoleAlarm() ) );
    connect( &imgproc, SIGNAL( invalidProfile() ), &tvAlarmsModel, SLOT( raiseInvalidProfileAlarm() ) );
    connect( &imgproc, SIGNAL( noHolesInProfile() ), &tvAlarmsModel, SLOT( raiseNoHolesInProfileAlarm() ) );

    connect( ui->tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( tab_switched( int ) ) );

    //Image source
    imageSource->setProcessFunction( &imgproc );

    //IO
#ifdef USE_IO
    io.setup();
    connect( &tvAlarmsModel, SIGNAL( barcodeRelatedAlarmRaised() ), &io, SLOT( signalBarcodeAlarm() ) );
    connect( &tvAlarmsModel, SIGNAL( holeRelatedAlarmRaised() ), &io, SLOT( signalHoleAlarm() ) );
    connect( &updateIoTimer, SIGNAL( timeout() ), &io, SLOT( update() ) );
    updateIoTimer.start( 100 );
#endif
}