Programm for decoding radio-signals sent by a ETH-Window-Shutter-Contact, received with a RFM12B-module
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
Go to the documentation of this file.
00001 #include "mbed.h" 00002 00003 #include "TextLCD.h" 00004 00005 #include "eth_comfort.h" 00006 #include "rfm.h" 00007 #include "rfm12b.h" 00008 00009 /*! 00010 * \file main.cpp 00011 * \brief Show the messages from ETH-Radio-Shutters on serial port and lcd 00012 * \author Karl Zweimüller 00013 */ 00014 00015 TextLCD lcd(p30, p29, p28, p27, p26, p25, TextLCD::LCD16x2); // rs, e, d0-d3 00016 00017 eth_comfort eth_comf(p11, p12, p13, p14, p18, LED4); // mosi, miso, sclk, cs, rxdata, rxled 00018 00019 Serial pc(USBTX, USBRX); // tx, rx 00020 00021 // mbed LEDs 00022 /* 00023 DigitalOut led1(LED1); 00024 DigitalOut led2(LED2); 00025 DigitalOut led3(LED3); 00026 DigitalOut led4(LED4); 00027 */ 00028 00029 //--------------------------------------------------------------------- 00030 // 00031 //--------------------------------------------------------------------- 00032 00033 int main() { 00034 00035 eth_message message; 00036 00037 pc.baud(115200); 00038 00039 pc.printf("\n\rConnected to mbed\n\r"); 00040 lcd.printf("Hello!\n"); 00041 00042 do { 00043 // anything new? 00044 if (eth_comf.readable()) { 00045 // read the new message and display 00046 message = eth_comf.getMessage(); 00047 pc.printf("\n\rCounter: %02X\n\r",message.cnt); 00048 pc.printf( " Dev-ID: %06X\n\r",message.adr); 00049 pc.printf( " cmd: %0X\n\r",message.cmd); 00050 //pc.printf( "cmd&0x80: %0X\n\r",message.cmd&0x80); 00051 // why doesn't work the following?????????????? 00052 //pc.printf( "Battery: "); 00053 //if (message.cmd&0x80 == 0x00) pc.printf("GOOD\n\r"); else pc.printf("WEAK\n\r"); 00054 00055 pc.printf( "Window : %s\n\r\n\r", (message.cmd&0x01 != 0x00) ? "OPEN" : "CLOSE"); 00056 lcd.cls(); 00057 lcd.printf("#:%02X ID: %06X\n",message.cnt,message.adr); 00058 lcd.printf("Window : %s\n", (message.cmd&0x01 != 0x00) ? "OPEN" : "CLOSE"); 00059 pc.printf("\n\r"); 00060 } 00061 } while (1==1); 00062 00063 } 00064 00065
Generated on Thu Jul 14 2022 01:29:01 by
1.7.2