Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
x10rf.cpp
00001 #include "x10rf.h" 00002 00003 x10rf::x10rf(PinName pin) : pin(pin) 00004 {} 00005 00006 // -------------------------------------- Fonctions X10 --------------------------------- 00007 // Envoi entête: 00008 void x10rf::x10_sendpreamble(void) 00009 { 00010 pin = 0; // X10PIN à 0. 00011 wait_ms(40) ; 00012 pin = 1; // X10PIN à 1. 00013 wait_ms(9) ; 00014 pin = 0; // X10PIN à 0. 00015 wait_us(4500) ; 00016 } 00017 00018 // -------------------------------------------------------------------------------------- 00019 // Envoi bit: 00020 void x10rf::x10_sendbit(void) 00021 { 00022 pin = 1; // X10PIN à 1. 00023 wait_us(560) ; 00024 pin = 0; // X10PIN à 0. 00025 wait_us(560) ; 00026 } 00027 00028 // ----------------------- 00029 // Envoi d'un octet X10 RF 00030 void x10rf::x10_sendoctet(char X10octet) 00031 { 00032 char nobit, valbit; 00033 for (nobit=0; nobit<=7; nobit++) { 00034 valbit=X10octet & 0x80; 00035 X10octet=(X10octet << 1); 00036 00037 x10_sendbit(); // On envoi un bit 00038 if ( valbit ) { // Si bit à 1 pause + longue. 00039 wait_us(1200) ; 00040 } 00041 } 00042 } 00043 00044 // Envoie trame X10, House Code / Unit Code / Action (ON/OFF/DIM/BRIGHT) 00045 void x10rf::x10_sendcmd(char House, char Unit, char Action) 00046 { 00047 char hc, uc ; 00048 00049 hc = house_code[House - 0x41] ; // Lit code correspondant dans tableau house_code. 00050 00051 if(Unit>8) { 00052 hc |= 0x04 ; 00053 Unit-=8; 00054 } 00055 00056 uc = unit_code[Unit-1] ; // Lit code correspondant dans tableau unit_code. 00057 00058 if (Action==OFF) 00059 uc |= 0x20 ; 00060 else if(Action==BRIGHT) 00061 uc=0x88; 00062 else if(Action==DIM) 00063 uc=0x98; 00064 00065 // Envoie commande X10 hc/uc. 00066 x10_sendpreamble() ; 00067 x10_sendoctet(hc) ; // house code 00068 x10_sendoctet(~hc) ; // ~house code 00069 x10_sendoctet(uc) ; // unit code 00070 x10_sendoctet(~uc) ; // ~unit code 00071 x10_sendbit() ; 00072 }
Generated on Sat Jul 16 2022 20:03:45 by
1.7.2