示例#1
0
void LCD12864::Duplicate(bool x) {
if (x == true)
setPins(0,0,0,0,1,1,1,1,1,1); // Draw
else
setPins(0,0,0,0,1,1,1,1,1,0); // Draw

}
示例#2
0
void LCD12864::RenderScreenBuffer(uint8_t screen) {

for (int k = 0; k < 32; k++) {
VectorConverter(k+128); // Starting Y Position
setPins(0,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); // SET DDRAM Y
setPins(0,0,1,0,0,0,0,0,0,0); // SET DDRAM X at start again


if (screen == 2) {
for (int i = 0; i < 16; i++) {
setPins(1,0,0,0,0,0,0,0,0,0); // draw remaining pixels =D

}
}

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

// Check if a pixel exists
for (int j = 0; j < 8; j++) {
int res = ScreenBuffer[i][k] & checkAND[j];

if (res > 0) { // Looks like we found a 1
temp[j] = 1;
}
else
temp[j] = 0;
} // end j
setPins(1,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); // draw remaining pixels =D
} // end i


} // end k

}
示例#3
0
void main()
{
 
    WDTCTL = WDTPW|WDTHOLD; //Stop watchdog timer
    if (CALBC1_1MHZ==0xFF)					// If calibration constant erased
    {											
      while(1);                               // do not load, trap CPU!!	
    }
    char p[24];
    setPins();
    clock_set();
    TimerA_UART_init();
    ADC10CTL0 |= ADC10ON;//ADC setup
    ADC10CTL1 |= INCH_0|ADC10SSEL_1|CONSEQ_1;  // set channel, ad source ACLK, sequence of channels
    ADC10AE0  |= BIT0;//|BIT1;
    ADC10CTL0 |= ENC|ADC10SC; //|ADC10IE;
    __enable_interrupt();
    for (;;)
    {
        // Wait for incoming character
        __bis_SR_register(LPM0_bits);
        //temp = (temp*35)/100; 
        itoa(temp,p,10);
        TimerA_UART_print(p);
        TimerA_UART_print("\r\n");
        //set_led(temp);
    }
}
示例#4
0
RGBLED::RGBLED(int rPin, int gPin, int bPin,
               int rVal, int gVal, int bVal, float fadeSpeed) :
  rPin(rPin), gPin(gPin), bPin(bPin), color(rVal, gVal, bVal),
  fadePerc(fadeSpeed), currFade(0)
{
  setPins();
}
示例#5
0
文件: main.c 项目: jifalops/tm4c
void onMusicStop(void) {
    // turn off LEDs
    setPins(io, 0);
    playing = FALSE;
    noteCount = 0;
    beatCount = 0;
}
示例#6
0
void PerimeterControl::setup(){
  Console.println(F("PerimeterControl::setup"));
  // perimeter
  pinMode(pinPerimeterRight, INPUT);    
  pinMode(pinPerimeterLeft, INPUT);          
  setPins(pinPerimeterLeft, pinPerimeterRight);
}
示例#7
0
int
main(int argc, char **argv)
{
	static int      read, mask;
	int             pins;
	int             c;
	int             option_index = 0;
	char           *serial = NULL;
	static struct option long_options[] = {
		{"mask", required_argument, 0, 'm'},
		{"serial", required_argument, 0, 's'},
		{"read", no_argument, 0, 'r'},
		{"list", no_argument, 0, 'l'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}	/* This is a filler for -1 */
	};
	if (argc == 1) {
		helpMessage();
		return 1;
	}
	while ((c = getopt_long(argc, argv, "m:rhls:", long_options, &option_index)) != -1) {
		switch (c) {
		case 'l':
			listRelays();
			return 1;
			break;
		case 'r':
			read = 1;
			break;
		case 'm':
			mask = 1;
			pins = atoi(optarg);
			break;
		case 's':
			serial = optarg;
			break;
		case 'h':
			helpMessage();
			return 0;
			break;
		default:
			helpMessage();
			return 1;
			break;
		}
	}
	if (read || mask) {
		initBoard(serial);
	}
	if (mask) {
		setPins(pins);
	}
	if (read) {
		return readPins();
	}
	exit(0);
	return (0);
}
示例#8
0
void DinoSerial::process(int cmd, char *message) {
  switch(cmd) {
    case 0:  setPins(message);            break;
    case 1:  begin(message);              break;
    case 2:  softSerial.print(message);   break;
    case 3:  softSerial.println(message); break;
    default:                              break;
  }
}
示例#9
0
 void DigitalPin::setState(bool newState) {
     if(getDirection() == OUT) {
         if (newState) {
             setPins(config.port, config.pins);
         } else {
             clearPins(config.port, config.pins);
         }
         state = newState;
     } else {
         // No error handling here because all feasible output methods use this very function.
     }
 }
示例#10
0
void StepperMotor::fullStep(byte reverse){
  switch(_state){
     case 0:
     case 1:{
        setPins(HIGH,HIGH,LOW,LOW,reverse);
        break;
     }
     case 2:
     case 3:{
       setPins(LOW,HIGH,HIGH,LOW,reverse);
       break;
     }
     case 4:
     case 5:{
       setPins(LOW,LOW,HIGH,HIGH,reverse);
       break;
     }
     case 6:
     case 7:{
       setPins(HIGH,LOW,LOW,HIGH,reverse);
       break;       
     }
  }
}
示例#11
0
int main(int argc, char **argv) {

  signal(SIGALRM, handle);
  declareTermiosCrap();
  wiringPiSetup();
  setPins(pinRed, pinGreen, pinBlue, pinWhite);
  setSwitches();
  blinkLights(pinRed, pinGreen, pinBlue, pinWhite);
  repeatColors();
  verify();
  

	tcsetattr(0, TCSANOW, &initial_settings);
	return 0;
}
int FriendtrackerUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 38)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 38;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QStringList*>(_v) = onlinePpIds(); break;
        case 1: *reinterpret_cast< QStringList*>(_v) = pins(); break;
        case 2: *reinterpret_cast< bb::cascades::GroupDataModel**>(_v) = friendListModel(); break;
        case 3: *reinterpret_cast< bool*>(_v) = getInitial(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOnlinePpIds(*reinterpret_cast< QStringList*>(_v)); break;
        case 1: setPins(*reinterpret_cast< QStringList*>(_v)); break;
        case 3: setInitial(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#13
0
void initBoard(char *serial) {
	//Init FTDI communication
	ftdi_init(&ftdic);
	if (0) {
		//Open
			ret = ftdi_usb_open(&ftdic, 0x0403, 0x6001);
	} else {
		//Open via serial number, to be implemented later.
			ret = ftdi_usb_open_desc(&ftdic, 0x0403, 0x6001, NULL, serial);
	}
	ret = ftdi_read_pins(&ftdic, bits);
	//Board has just been plugged in or power lost
		if (bits[0] == 0xFF) {
		//Prevents 0xFF from flipping all switches on
			//ftdi_enable_bitbang(&ftdic, 0xF0);
			ftdi_set_bitmode(&ftdic, 0xF0, BITMODE_BITBANG);	
			setPins(0);
		}
	ftdi_set_bitmode(&ftdic, 0xFF, BITMODE_BITBANG);
	//ftdi_enable_bitbang(&ftdic, 0xFF);
}
示例#14
0
void LCD12864::Draw(bool t, uint8_t x, uint8_t y) {
if (t == true) // Graphic Select
  setPins(0,0,0,0,1,1,0,1,1,0); // 8BIT Mode-4 ext gfx mode
else { // Text select, are all these really necessary? I really don't know

x += 128;
y += 128;
  // 5FH
// setPins(0,0,0,1,0,1,1,1,1,1);
  // 34H
  setPins(0,0,0,0,1,1,0,1,0,0);
//30H
setPins(0,0,0,0,1,1,0,0,0,0);

//01h
setPins(0,0,0,0,0,0,0,0,0,1);

//06h
setPins(0,0,0,0,0,0,0,1,1,0);

//0ch
setPins(0,0,0,0,0,0,1,1,0,0);

VectorConverter(y); // lets get the binary from the dec
setPins(0,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); // SET DDRAM Y
VectorConverter(x); // lets get the binary from the dec
setPins(0,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); // SET DDRAM X

/*
//Move Y
setPins(0,0,1,0,0,0,0,0,0,0);
//Move X
setPins(0,0,1,0,0,0,0,1,0,0);
*/
}

}
示例#15
0
RHSoftwareSPI::RHSoftwareSPI(Frequency frequency, BitOrder bitOrder, DataMode dataMode)
    :
    RHGenericSPI(frequency, bitOrder, dataMode)
{
    setPins(12, 11, 13);
}
示例#16
0
RGBFade::RGBFade(int red, int grn, int blue){
  setPins(red, grn, blue);
}
示例#17
0
void Shifty::setPins(int dataPin, int clockPin, int latchPin) {
  setPins(dataPin, clockPin, latchPin, -1);
}
/**
* use to select the interface mode...
* when adding slave PCM1808s with an existing master,
* conserve pins by hardwiring MD1 and MD2, or connecting multiple
* PCM1808s to the same bus
*/
void Alislahish_PCM1808::selectMode(InterfaceModes mode){
	_mode = mode;
	setPins();
}
示例#19
0
void TemperatureSensor::init(sensorModule m, SensorPins& p) {
	/* Each temperature sensor has a maximum of two channels. The first channel
	 * is always Temperature. The second channel may or may not be used. For
	 * DHT11/22 devices, the second channel is humidity.
	 */
	setModule(m);
	setPins(p);

	// Configure Sensor Parameters
	setStaleAge_ms(10000);	// timeout of the value if not update for 10 seconds.

	// Channel 1 is always defined like this
	setCalEnable(TEMP_CAL_INDEX_TEMP_SLOPE, true);
	setCalName(TEMP_CAL_INDEX_TEMP_SLOPE, "Temperature Gain");
	setCalEnable(TEMP_CAL_INDEX_TEMP_OFFSET, true);
	setCalName(TEMP_CAL_INDEX_TEMP_OFFSET, "Temperature Offset");
	setValueEnable(TEMP_VALUE_INDEX_TEMPERATURE, true);
	setValueName(TEMP_VALUE_INDEX_TEMPERATURE, "temp");
	setType(TEMP_VALUE_INDEX_TEMPERATURE, valueType::temperature);
	setUOM(TEMP_VALUE_INDEX_TEMPERATURE, uomType::celsius);

	// Channel 2 defaults -- assume not used
	setCalEnable(TEMP_CAL_INDEX_HUMIDITY_SLOPE, false);
	setCalName(TEMP_CAL_INDEX_HUMIDITY_SLOPE, "not used");
	setCalEnable(TEMP_CAL_INDEX_HUMIDITY_OFFSET, false);
	setCalName(TEMP_CAL_INDEX_HUMIDITY_OFFSET, "not used");
	setValueEnable(TEMP_VALUE_INDEX_HUMIDITY, false);
	setValueName(TEMP_VALUE_INDEX_HUMIDITY, "not used");
	setType(TEMP_VALUE_INDEX_HUMIDITY, valueType::undefined);
	setUOM(TEMP_VALUE_INDEX_HUMIDITY, uomType::undefined);

	if (m == sensorModule::dht11 || m == sensorModule::dht22 || m == sensorModule::htu21d_si7102) {
		setCalEnable(TEMP_CAL_INDEX_HUMIDITY_SLOPE, true);
		setCalName(TEMP_CAL_INDEX_HUMIDITY_SLOPE, "Humidity Gain");
		setCalEnable(TEMP_CAL_INDEX_HUMIDITY_OFFSET, true);
		setCalName(TEMP_CAL_INDEX_HUMIDITY_OFFSET, "Humidity Offset");
		setValueEnable(TEMP_VALUE_INDEX_HUMIDITY, true);
		setValueName(TEMP_VALUE_INDEX_HUMIDITY, "rH%");
		setType(TEMP_VALUE_INDEX_HUMIDITY, valueType::humidity);
		setUOM(TEMP_VALUE_INDEX_HUMIDITY, uomType::rh);
	}

	// The pins used to interact with the sensor
	digital_pin = static_cast<uint8_t>(p.digital);
	sda_pin = static_cast<uint8_t>(p.sda);
	scl_pin = static_cast<uint8_t>(p.scl);

	// Create and initialize the sensor objects
	//lint -e{788} Many modules are intentionally omitted from the switch. Don't complain about it.
	switch (m) {
		case sensorModule::dht11:
			dht = new DHT(digital_pin, DHT11);
			dht->begin();
			setWaitTimeBetweenAcquireSetupMS(2000);
			setWaitTimeAfterAcquireSetupMS(250);
			setWaitTimeAfterAcquire1MS(250);
			break;
		case sensorModule::dht22:
			dht = new DHT(digital_pin, DHT22);
			dht->begin();
			setWaitTimeBetweenAcquireSetupMS(2000);
			setWaitTimeAfterAcquireSetupMS(250);
			setWaitTimeAfterAcquire1MS(250);
			break;
		case sensorModule::ds18b20:
			ow = new OneWire(digital_pin);	// specify pin on creation
			dallas = new DallasTemperature(ow);
			setWaitTimeBetweenAcquireSetupMS(2000);
			setWaitTimeAfterAcquireSetupMS(0);
			setWaitTimeAfterAcquire1MS(800);
			// do the begin later since it takes a while
			break;
		case sensorModule::htu21d_si7102:
			htu21d = new HTU21D();
//			htu21d->begin(callbackfunction);
			htu21d->begin();
			setWaitTimeBetweenAcquireSetupMS(2000);
			setWaitTimeAfterAcquireSetupMS(0);
			setWaitTimeAfterAcquire1MS(0);
			break;
		default:
			break;  // none of these sensors are supported by this module
	}
}
示例#20
0
//
// Constructor
//
SoftI2CMaster::SoftI2CMaster(uint8_t sdaPin, uint8_t sclPin) 
{
    setPins(sdaPin, sclPin, true);
    i2c_init();
}
示例#21
0
SoftI2CMaster::SoftI2CMaster(uint8_t sdaPin, uint8_t sclPin, uint8_t pullups)
{
    setPins(sdaPin, sclPin, pullups);
    i2c_init();
}
/**
* use to choose the audio data output format
*/
void Alislahish_PCM1808::selectFormat(AudioInterfaceFormats format){
	_format = format;
	setPins();

} 
示例#23
0
void TMRpcm::play(char* filename, unsigned long seekPoint){

  if(speakerPin != lastSpeakPin){
	  #if !defined (MODE2)
	  	setPin();
	  #else
	    setPins();
	  #endif
	  lastSpeakPin=speakerPin;
   }
  stopPlayback();
  if(!wavInfo(filename)){
  	#if defined (debug)
  		Serial.println("WAV ERROR");
  	#endif
  return;
  }//verify its a valid wav file


  		if(seekPoint > 0){ seekPoint = (SAMPLE_RATE*seekPoint) + fPosition();
  		seek(seekPoint); //skip the header info

  }
	playing = 1; bitClear(optionByte,7); //paused = 0;

	if(SAMPLE_RATE > 45050 ){ SAMPLE_RATE = 24000;
	#if defined (debug)
  	  	Serial.print("SAMPLE RATE TOO HIGH: ");
  	  	Serial.println(SAMPLE_RATE);
  	#endif
  	}

#if !defined (USE_TIMER2)
    //if(qual)
    if(bitRead(optionByte,6)){resolution = 10 * (800000/SAMPLE_RATE);}
    else{ resolution = 10 * (1600000/SAMPLE_RATE);
	}
#else
	resolution = 255;
	if(SAMPLE_RATE < 9000){
		*TCCRnB[tt] &= ~_BV(CS20);
		*TCCRnB[tt] |= _BV(CS21);
	}else{
		*TCCRnB[tt] &= ~_BV(CS21);
		*TCCRnB[tt] |= _BV(CS20);
	}
#endif
    byte tmp = (sFile.read() + sFile.peek()) / 2;

	#if defined(rampMega)
    if(bitRead(optionByte,5)){

			*OCRnA[tt] = 0; *OCRnB[tt] = resolution;
			timerSt();
			for(unsigned int i=0; i < resolution; i++){

				*OCRnB[tt] = constrain(resolution-i,0,resolution);

			//if(bitRead(*TCCRnB[tt],0)){
			//	for(int i=0; i<10; i++){
			//		while(*TCNT[tt] < resolution-50){}
			//	}
			//}else{
				delayMicroseconds(150);
			//}
			}

	}
	bitClear(optionByte,5);
	#endif

	//rampUp = 0;
	unsigned int mod;
	if(volMod > 0){ mod = *OCRnA[tt] >> volMod; }else{ mod = *OCRnA[tt] << (volMod*-1); }
示例#24
0
RGBLED::RGBLED(int rPin, int gPin, int bPin, RGBColor c, float fadeSpeed) :
  rPin(rPin), gPin(gPin), bPin(bPin), color(c),
  fadePerc(fadeSpeed), currFade(0)
{
  setPins();
}
示例#25
0
void LCD12864::Initialise(void) {
this->checkAND[7]= B00000001;
this->checkAND[6]   = B00000010;
this->checkAND[5] = B00000100;
this->checkAND[4]  = B00001000;
this->checkAND[3]  = B00010000;
this->checkAND[2]  = B00100000;
this->checkAND[1]  = B01000000;
this->checkAND[0]  = B10000000;


   pinMode(CSEL1, OUTPUT);    
//   pinMode(this->CSEL2, OUTPUT);    
   pinMode(RS, OUTPUT);     
   pinMode(RW, OUTPUT);    
   pinMode(EN, OUTPUT);     
   pinMode(D0, OUTPUT);      
   pinMode(D1, OUTPUT);    
   pinMode(D2, OUTPUT);   
   pinMode(D3, OUTPUT);      
   pinMode(D4, OUTPUT);      
   pinMode(D5, OUTPUT);      
   pinMode(D6, OUTPUT);      
   pinMode(D7, OUTPUT);      

delayns();
selectCS1();
delayns();



  // 5FH
 setPins(0,0,0,1,0,1,1,1,1,1);
  // 34H
  setPins(0,0,0,0,1,1,0,1,0,0);
//30H
setPins(0,0,0,0,1,1,0,0,0,0);

//01h
setPins(0,0,0,0,0,0,0,0,0,1);

//06h
setPins(0,0,0,0,0,0,0,1,1,0);

//0ch
setPins(0,0,0,0,0,0,1,1,0,0);

//try for gfx
setPins(0,0,1,0,1,1,1,1,1,1);



delayns();
delayns();


 setPins(0,0,0,0,1,1,0,1,0,0); // 8BIT Mode-4 ext gfx mode
setPins(0,0,0,0,0,0,0,0,1,0); // Vertical scroll
//  setPins(0,0,1,0,0,0,0,0,0,0); // SET 0,0

delayns();
delayns();


setPins(0,0,1,0,0,0,0,0,0,0); // SET DDRAM Y
setPins(0,0,1,0,0,0,0,0,0,0); // SET DDRAM X

// Clear the Screen



for (int j = 128; j <= 160; j++) {
for (int i = 0; i <= 256; i+=8) {
  setPins(1,0,0,0,0,0,0,0,0,0);
}

VectorConverter(j); // lets get the binary from the dec
setPins(0,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); // SET DDRAM Y
setPins(0,0,1,0,0,0,0,0,0,0); // SET DDRAM X


}

this->currentXpos = 0; // Starting coordinate lEFT of screen
this->currentYpos = 128; // // Starting coordinate TOP of screen



}
//en is enable, in1 and in2 are the two sides of the H-Bridge
Type1_Motor::Type1_Motor(uint8_t en, uint8_t in1, uint8_t in2) {
	setPins(en, in1, in2);
}
//en is enable, in1 and in2 are the two sides of the H-Bridge
Type2_Motor::Type2_Motor(unsigned char in1, unsigned char in2) {
	setPins(in1, in2);
}
示例#28
0
void LCD12864::Render(void) {
  setPins(0,0,0,0,1,1,0,1,1,0); // 8BIT Mode-4 ext gfx mode
}