コード例 #1
0
unsigned long KaKuTransmitter::getTelegram(char address, unsigned short device, boolean on) {
	unsigned short trits[12];

	address-=65;
	device-=1;

	for (unsigned short i=0; i<4; i++) {
		// Trits 0-3 contain address (2^4 = 16 addresses)
		trits[i]=(address & 1)?2:0;
		address>>=1;

		// Trits 4-8 contain device (2^4 = 16 addresses)
		trits[i+4]=(device & 1)?2:0;
		device>>=1;
	}

	// Trits 8-10 seem to be fixed
	trits[8]=0;
	trits[9]=2;
	trits[10]=2;

	// Switch on or off
	trits[11]=(on?2:0);

	return encodeTelegram(trits);
}
コード例 #2
0
unsigned long ElroTransmitter::getTelegram(unsigned short systemCode, char device, bool on) {
	unsigned short trits[12];

	// The remote controls use only a subset of devices, where the
	// device number always has just a single 1 bit (e.g., 'A' is 1,
	// 'B' is 2, 'C' is 4, etc.). This requires just a single one of
	// the ABCDE switches on the receivers to be on. However, the
	// receivers support full 5-bit addressing, which you can also
	// use with this function if you just pass a number between 0-31
	// instead of a letter.
	if (device >= 'A' && device <= 'E')
		device = 1 << (device - 'A');

	for (unsigned short i=0; i<5; i++) {
		//trits 0-4 contain address (2^5=32 addresses)
		trits[i]=(systemCode & 1)?0:2;
		systemCode>>=1;

		// trits 5-9 contain device (2^5=32 devices)
		trits[i+5]=(device & 1)?0:2;
		device>>=1;

	}

	//switch on or off
	trits[10]=(on?0:2);
	trits[11]=(!on?0:2);

	return encodeTelegram(trits);
}
コード例 #3
0
unsigned long BlokkerTransmitter::getTelegram(unsigned short device, boolean on) {
	unsigned short trits[12]={0};

	device--;

	for (unsigned short i=1; i<4; i++) {
		// Trits 1-3 contain device
		trits[i]=(device & 1)?0:1;
		device>>=1;
	}

	// Switch on or off
	trits[8]=(on?1:0);

	return encodeTelegram(trits);
}
コード例 #4
0
unsigned long ElroTransmitter::getTelegram(unsigned short systemCode, char device, boolean on) {
	unsigned short trits[12];

	device-=65;

	for (unsigned short i=0; i<5; i++) {
		//trits 0-4 contain address (2^5=32 addresses)
		trits[i]=(systemCode & 1)?0:2;
		systemCode>>=1;

		//trits 5-9 contain device. Only one trit has value 0, others have 2 (float)!
		trits[i+5]=(i==device?0:2);
	}

	//switch on or off
	trits[10]=(on?0:2);
	trits[11]=(!on?0:2);

	return encodeTelegram(trits);
}
コード例 #5
0
unsigned long KaKuTransmitter::getTelegram(char address, unsigned short group, unsigned short device, boolean on) {
	unsigned short trits[12], i;

	address-=65;
	group-=1;
	device-=1;

	// Address. M3E Pin A0-A3
	for (i=0; i<4; i++) {
		// Trits 0-3 contain address (2^4 = 16 addresses)
		trits[i]=(address & 1)?2:0;
		address>>=1;
	}

	// Device. M3E Pin A4-A5
	for (; i<6; i++) {
		trits[i]=(device & 1)?2:0;
		device>>=1;
	}

	// Group. M3E Pin A6-A7
	for (; i<8; i++) {
		trits[i]=(group & 1)?2:0;
		group>>=1;
	}

	// Trits 8-10 are be fixed. M3E Pin A8/D0-A10/D2
	trits[8]=0;
	trits[9]=2;
	trits[10]=2;

	// Switch on or off, M3E Pin A11/D3
	trits[11]=(on?2:0);

	return encodeTelegram(trits);
}
コード例 #6
0
void RemoteTransmitter::sendTelegram(unsigned short trits[]) {
	sendTelegram(encodeTelegram(trits),_pin);
}