Esempio n. 1
0
int main(void)
{
  uint8_t offset = 0;
  uint8_t direction = 1;
  CLKPR = 0x80, CLKPR = 0;
  initPins();
  while (1) {
    fakeline(); fakeline(); fakeline(); fakeline(); fakeline();
    fakeline(); fakeline(); fakeline(); fakeline(); fakeline();
    fakeline(); fakeline(); fakeline(); fakeline(); fakeline();
    //fakeline(); fakeline(); fakeline(); fakeline(); fakeline();
    unsigned char i = 0;
    for (i = 0; i < 240; i++) {
      PORTF = 0;
      if (direction) {
	if (++offset > 7) {
	  direction = 0;
	}
      } else {
	if (--offset <= 1) {
	  direction = 1;
	}
      }
      //offset = 0;
      usleep(11+offset);
      //_delay_us(11);
      // 16 bytes = 32 us
      patternline(16, (uint16_t)imagedata, 10 - offset/2);
      usleep(20-offset);
      //_delay_us(20);
      PORTB = _BV(0);
    }
  }
}
Esempio n. 2
0
void Demultiplexer::dataChanged()
{
	if ( hasProperty("numInput") && dataInt("numInput") != -1 )
	{
		int addressSize = int( std::ceil( std::log( (double)dataInt("numInput") ) / std::log(2.0) ) );
		property("numInput")->setValue(-1);
		
		if ( addressSize < 1 )
			addressSize = 1;
		else if ( addressSize > 8 )
			addressSize = 8;
		
		// This function will get called again when we set the value of numInput
		property("addressSize")->setValue(addressSize);
		return;
	}
	
	if ( hasProperty("numInput") )
	{
		m_variantData["numInput"]->deleteLater();
		m_variantData.remove("numInput");
	}
	
	initPins( unsigned(dataInt("addressSize")) );
}
Esempio n. 3
0
void BinaryCounter::dataChanged()
{
	initPins( dataInt("bitcount") );
	
	b_triggerHigh = dataString("trig") == "Rising";
	setDisplayText( ">", b_triggerHigh ? "^>" : "_>" );
}
Esempio n. 4
0
void MatrixDisplay::dataChanged() {
    QColor color = dataColor("color");
    m_r = double(color.red())   / 0x100;
    m_g = double(color.green()) / 0x100;
    m_b = double(color.blue())  / 0x100;

    int numRows = dataInt("0-rows");
    int numCols = dataInt("1-cols");

    bool ledsChanged = (numRows != int(m_numRows)) || (numCols != int(m_numCols));

    if (ledsChanged) { 
        for (unsigned i = 0; i < m_numCols; i++)
            for (unsigned j = 0; j < m_numRows; j++)  // must remove elements before re-organizing storage. 
                removeElement(&(m_LEDs[i][j].m_pDiode), (i == (m_numCols - 1)) && (j == (m_numRows - 1))); 

        initPins(numRows, numCols);
        }

    bool rowCathode = dataString("diode-configuration") == "Row Cathode";

    if ((rowCathode != m_bRowCathode) || ledsChanged) {
        m_bRowCathode = rowCathode;

        for (unsigned i = 0; i < m_numCols; i++) {
            for (unsigned j = 0; j < m_numRows; j++) {

                if (rowCathode) {
                    setup2pinElement(m_LEDs[i][j].m_pDiode, m_pColNodes[i]->pin(), m_pRowNodes[j]->pin());
                } else setup2pinElement(m_LEDs[i][j].m_pDiode, m_pRowNodes[j]->pin(), m_pColNodes[i]->pin());
            }
        }
    }
}
Esempio n. 5
0
/* Disable the UART */
void UARTdisable()
{
    /* Float pins */
    initPins(0);

    /* DeInit */
    USART_DeInit(H1UART);
}
	IRSensor::IRSensor(int pin, int minRange, int maxRange):
		DATA_PIN(pin),
		MIN_RANGE(minRange),
		MAX_RANGE(maxRange)
	{
		initPins();
		calibrationData = new int[1];
		defaultCalibration();
	}
Esempio n. 7
0
void RAM::dataChanged() {
    m_wordSize = dataInt("wordSize");
    m_addressSize = dataInt("addressSize");

    int newSize = int(m_wordSize * std::pow(2., m_addressSize));
    m_data.resize(newSize);

    initPins();
}
	Motor::Motor(int fwdPin, int bwdPin, int pwmPin, int fwdEncoderPin, int bwdEncoderPin):
		fwdPin(fwdPin),
		bwdPin(bwdPin),
		pwmPin(pwmPin)
#ifdef __MK20DX256__ // Teensy Compile
		, encoder(Encoder(fwdEncoderPin, bwdEncoderPin))
#endif
	{
		initPins();
	}
Esempio n. 9
0
void ADDAC::propertyChanged(Property& theProperty, QVariant newValue, QVariant oldValue)
{
    if(theProperty.name() == "range"){
        m_range = newValue.toDouble();
    }
    if(theProperty.name() == "numBits"){
        initPins();
    }
    Q_UNUSED(oldValue);
}
Esempio n. 10
0
void ResistorDIP::dataChanged()
{
	initPins();
	const double resistance = dataDouble("resistance");
	for ( int i=0; i<m_resistorCount; ++i )
		m_resistance[i]->setResistance(resistance);
	
	const QString display = QString::number( resistance / getMultiplier(resistance), 'g', 3 ) + getNumberMag(resistance) + QChar(0x3a9);
	addDisplayText( "res", QRect( offsetX(), offsetY()-16, 32, 12 ), display );
}
Esempio n. 11
0
void wcycle_init ()
{
	initPins ();
	initClocks ();
	initFlash ();
	initUART ();
	initPWM ();
	initDHT ();

	wcycle_pwm_ctl (readFlash());
}
Esempio n. 12
0
void init()
{
  cli();
  initPins();
  initClock();
  initBuffer();
  initSerial();
  recvMode = RM_DATA;
  set_sleep_mode( SLEEP_MODE_IDLE );
  sei();
}
Esempio n. 13
0
//Set constructor 
spi0::spi0(unsigned long _pclk,int _dataLength,int _clkDiv)
{
	pclk=_pclk;
	clock=pclk/_clkDiv;			//save for clock
	dataLength=_dataLength;	
	clkDiv=_clkDiv;
	initPins();		//initialse pins
	setClockDiv(clkDiv);		//initialise clock
	S0SPCR=(0xF00&(dataLength<<8))|(1<<5)|(0<<4)|(0<<3)|(1<<2);	//initialse control register
	S0SPDR=0;
}
Esempio n. 14
0
/* Enable and config the UART port */
int UARTenable(unsigned int baudrate, int parity)
{
    if (IS_USART_BAUDRATE(baudrate)) {
        USART_InitTypeDef USART_InitStructure;
        USART_StructInit(&USART_InitStructure);

        USART_InitStructure.USART_BaudRate = baudrate;
        USART_InitStructure.USART_StopBits = USART_StopBits_1;
        /* always use 8-bit data */
        switch (parity) {
        case UARTParity_No:
            /* 8 bits and no parity bit */
            USART_InitStructure.USART_WordLength = USART_WordLength_8b;
            USART_InitStructure.USART_Parity = USART_Parity_No;
            break;
        case UARTParity_Even:
            /* 8 bits and a parity bit */
            USART_InitStructure.USART_WordLength = USART_WordLength_9b;
            USART_InitStructure.USART_Parity = USART_Parity_Even;
            break;
        case UARTParity_Odd:
            /* 8 bits and a parity bit */
            USART_InitStructure.USART_WordLength = USART_WordLength_9b;
            USART_InitStructure.USART_Parity = USART_Parity_Odd;
            break;
        default:
            return UARTRetBadParity;
        }

        USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
        USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

        /* Configure USART */
        USART_DeInit(H1UART);
        USART_Init(H1UART, &USART_InitStructure);

        /* Get interrupts on Recieve Not Empty, enable TXE as needed later */
        USART_ITConfig(H1UART, USART_IT_RXNE, ENABLE);

        /* Go */
        USART_Cmd(H1UART, ENABLE);

        /* wait for tx ready */
        while(USART_GetFlagStatus(H1UART, USART_FLAG_TC) == RESET);

        /* Set up pins */
        initPins(1);

        return UARTRetOK;
    }
    else {
        return UARTRetBadSpeed;
    }
}
void LandBoards_MyMenu::begin(void)
{
	mcp.begin();   	// use default address 0	
#if defined(ARDUINO_ARCH_AVR)
	TWBR = 12;    			// go to 400 KHz I2C speed mode
#elif defined(ARDUINO_ARCH_STM32F1)
	Wire.setClock(400000);	// 400KHz speed
#else
  #error “This library only supports boards with an AVR or SAM processor.”
#endif
	initPins();
}
Esempio n. 16
0
void ECKeyPad::dataChanged() {
    initPins(dataInt("numCols"));

    bool useToggle = dataBool("useToggles");
    bool bounce = dataBool("bounce");
    int bouncePeriod_ms = int(dataDouble("bounce_period") * 1e3);

    for (unsigned i = 0; i < 4; i++) {
        for (unsigned j = 0; j < m_numCols; j++) {
            button(buttonID(i, j))->setToggle(useToggle);
            m_switch[i][j]->setBounce(bounce, bouncePeriod_ms);
        }
    }
}
Esempio n. 17
0
File: main.c Progetto: OfnyaHoo/EV15
int main(int argc, char** argv) {
    ConfigureOscillator();
    initPins();
    TRISBbits.TRISB4=0;
    LATBbits.LATB4=0;
    initUARTS();
    INTCON2bits.GIE=1;
    while(1)
    {
       // LATBbits.LATB4=!LATBbits.LATB4;
        delay(1000);
    }
    
    return (EXIT_SUCCESS);
}
Esempio n. 18
0
void LEDBarGraphDisplay::dataChanged() {
	DiodeSettings ds;
	QColor color = dataColor("color");

	ds.I_S = dataDouble("I_S");
	ds.V_B = dataDouble("V_B");
	ds.N = dataDouble("N");

	initPins();

	// Update each diode in array with new diode setting as they are acting individually.

	for (unsigned i = 0; i < m_numRows; i++) {
		m_LEDParts[i]->setDiodeSettings(ds);
		m_LEDParts[i]->setColor(color);
	}
}
Esempio n. 19
0
int main()
{
    //Clock init  M=43, N1,2 = 2 == 39.61MIPS
    PLLFBD = 43;
    CLKDIVbits.PLLPOST = 0; // N1 = 2
    CLKDIVbits.PLLPRE = 0; // N2 = 2
    OSCTUN = 0;
    RCONbits.SWDTEN = 0;

    __builtin_write_OSCCONH(0x01); // Initiate Clock Switch to Primary (3?)

    __builtin_write_OSCCONL(0x01); // Start clock switching

    while (OSCCONbits.COSC != 0b001); // Wait for Clock switch to occur

    while (OSCCONbits.LOCK != 1) {
    };
    //End of clock init.
    
    initPins();
    
    Uart2Init(115200L, InterruptRoutine);

//    Uart2PrintChar('S');
    while (!SD_IN);
    
    // initialize the file system, open the file, read the file and send in chunks
    FSInit();

    FSFILE * openFile = FSfopen("send.txt", FS_READ);

    char toSend[512];
    int n;
    while (n = FSfread(toSend, 1, 512, openFile)) {
        Uart2SendBytes(toSend, n);
    }
    FSfclose(openFile);

    // turn on amber LED
    TRISAbits.TRISA4 = 0;
    LATAbits.LATA4 = 1;
    
    while (1);
}
Esempio n. 20
0
void initAll(void)
{
   ledTable[0]=1;
   ledTable[1]=2;
   ledTable[2]=3;
   ledTable[3]=4;
   ledTable[4]=0;
   ledTable[5]=5;
   ledTable[6]=6;
   ledTable[7]=7;
   ES_Timer_Init(ES_Timer_RATE_1MS);
   printf("init started\r\n");
   //dont change the order of initializers     
   initPins();  
   initSCI();
   initCheckers();
   ES_Timer_Init(ES_Timer_RATE_1MS);
   //sendData[0]=0x13;
   //sendData[1]=0x14;
   //sendMessage(sendData, 2, 0x21,0x80);
}
Esempio n. 21
0
MyMenu::MyMenu(void)
{
	mcp.begin();      // use default address 0
	initPins();
	return;
}
Stepper_Shift::Stepper_Shift(uint8_t dpin0, uint8_t dpin1, uint8_t dpin2, uint8_t rclk, uint8_t srclk){
  numBoards = 3;
  alloc(6);
  initPins(dpin0, dpin1, dpin2, rclk, srclk);
}
Stepper_Shift::Stepper_Shift(uint8_t dpin0, uint8_t rclk, uint8_t srclk){
  numBoards = 1;
  alloc(9);  //allocates 9 bytes to store motor commands (only requires 5 bits per motor, but I'm unsure how to manipulate a byte array 5 bits at a time at this point)
  initPins(dpin0, rclk, srclk);
}
Esempio n. 24
0
void init() {
    initPins();
    //timer1_isr_init();
    os_timer_setfn(&micros_overflow_timer, (os_timer_func_t*) &micros_overflow_tick, 0);
    os_timer_arm(&micros_overflow_timer, 60000, REPEAT);
}
Esempio n. 25
0
void MOTORS_init() {
	initTimer();
	initPWM();
	initPins();
}
/**
* Program pooling a directory, and doing a scheduling.
**/
int main (int argc, char** argv)
{

	initPins();
	adc_init();
	lcd_init();
	
	/** The status does not exist at the launch of the schduler prgram*/
	clearFile();
	int pid=readPid();	
	stopIfPidExists(pid);
	writePid();
	
	SetChrMode();
	int nbSecond;
	int remainingSeconds;
	uchar intensity;
	uchar tmpintensity;
    int i;
	int valueInFile;
	time_t whenItsComplete ;
	char timestr[7];
	
	pinMode (RELAY_IN, OUTPUT);
	// Permanent loop checking file.
	int cycle=0;
	
	
	while(1){
		valueInFile=getCoundownValue();
		#ifndef PROD
		printf("pause:%d,valueInFile:%d\n",pauseSt,valueInFile);
		#endif
	
		if(valueInFile>=0){
			nbSecond=valueInFile;
		// The countdown
			whenItsComplete = time(NULL)+nbSecond;
			remainingSeconds=whenItsComplete-time(NULL);
		}
		else{remainingSeconds=-1;}
		#ifndef PROD
		printf("nbsecond:%d\n",nbSecond);
		#endif
	
	
		do {
	
	   /**
	   * Do a regular reset of the LCD
	   **/
		if(cycle%500==0){
		 lcd_init();
		}
		else if(cycle%60==0){
			resetLcd();
		}
		/**
		* Write the remaining seconds
		**/
		if(cycle%60==0){
		 writeRemaining(remainingSeconds);
		}
		

		/**
		* Increment only if not in pause (Cycle increments will be at the end of the cycle loop.
		**/	

		
		updateStandbyStatus();
		cycle++;

		
		
		if(remainingSeconds>-1){
		if(pauseSt==IS_RUNNING){
				remainingSeconds=whenItsComplete-time(NULL);
		}else{
			    whenItsComplete=remainingSeconds+time(NULL);
		}


				openRelay();
				if(lastImmobileState==0||(time(NULL)-lastImmobileState)<NBSECONDBEFORECREENSHUTDOWN){
				digitalWrite (TRANSISTOR, LOW);
				}
				else{
				digitalWrite (TRANSISTOR, HIGH);
				}
				int seconds=remainingSeconds%60;
				int hours=remainingSeconds/3600;
				int minutes=remainingSeconds/60%60;
			
				sprintf(timestr,"%02d:%02d:%02d",hours,minutes,seconds);
					
				goHome();
				lcd_text(timestr);
				#ifndef PROD
				printf("%s\n",timestr);
				#endif
				sleep(1);
		}
			/**
			* Block measuring intensity
			*/
			if(cycle%20==0){
				intensity=get_ADC_Result();
				#ifndef PROD
				printf("Intensite: %d\n",intensity);
				#endif
			}
			#ifndef PROD
			printf("Remaining seconds %d,cycle=%d\n",remainingSeconds,cycle);
			#endif

	} while ( remainingSeconds>0&& !isFilePresent());
	
		#ifndef PROD
	//	printf("Sortie boucle décompte\n");
		#endif
			
		/**
		* Every 10 ccyle there is a full reset of the screen. Otherwise it is  light reset.
		**/
	
		if(cycle%100==0){
			lcd_init();
		}
		nbSecond=0;
		/**
		*
		**/
		if(valueInFile==NO_FILE){
			goHome();
			closeRelay();
			digitalWrite (TRANSISTOR, HIGH);
			lcd_text("Expire    " );
			#ifndef PROD
			printf("Expire\n");
			#endif
		}
			else if(valueInFile==TV_ON){
			goHome();
			openRelay();
			digitalWrite (TRANSISTOR, LOW);
			lcd_text("Tele on      " );
			}
		else if(valueInFile==TV_OFF){
			goHome();
			digitalWrite (TRANSISTOR, HIGH);
			closeRelay();
			lcd_text("Tele off      " );
		}
		sleep(3);
	}
}
Esempio n. 27
0
void enableMotors() {
	initPins();
	steppersOn = true;
	digitalWrite(2, false);
}
Esempio n. 28
0
OLED::OLED()
{
	initPins();
	initOLED();
}
Esempio n. 29
0
OPA::OPA(OPA_ADDRESSES address) :
	address(address),
	error(OPA_ERROR_NONE)
{
	initPins();
}
Esempio n. 30
0
OPA::OPA() :
	address(OPA_ADDRESS_0),
	error(OPA_ERROR_NONE)
{
	initPins();
}