Karl Zweimüller
/
eth_comfort_test
Programm for decoding radio-signals sent by a ETH-Window-Shutter-Contact, received with a RFM12B-module
main.cpp@1:fc72e0bdb693, 2011-04-07 (annotated)
- Committer:
- charly
- Date:
- Thu Apr 07 19:54:09 2011 +0000
- Revision:
- 1:fc72e0bdb693
- Parent:
- 0:96794c9fc5a3
Reorganized and created classes for RFM12B and ETH-Comfort
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charly | 0:96794c9fc5a3 | 1 | #include "mbed.h" |
charly | 0:96794c9fc5a3 | 2 | |
charly | 0:96794c9fc5a3 | 3 | #include "TextLCD.h" |
charly | 0:96794c9fc5a3 | 4 | |
charly | 0:96794c9fc5a3 | 5 | #include "eth_comfort.h" |
charly | 0:96794c9fc5a3 | 6 | #include "rfm.h" |
charly | 0:96794c9fc5a3 | 7 | #include "rfm12b.h" |
charly | 0:96794c9fc5a3 | 8 | |
charly | 1:fc72e0bdb693 | 9 | /*! |
charly | 1:fc72e0bdb693 | 10 | * \file main.cpp |
charly | 1:fc72e0bdb693 | 11 | * \brief Show the messages from ETH-Radio-Shutters on serial port and lcd |
charly | 1:fc72e0bdb693 | 12 | * \author Karl Zweimüller |
charly | 1:fc72e0bdb693 | 13 | */ |
charly | 0:96794c9fc5a3 | 14 | |
charly | 1:fc72e0bdb693 | 15 | TextLCD lcd(p30, p29, p28, p27, p26, p25, TextLCD::LCD16x2); // rs, e, d0-d3 |
charly | 1:fc72e0bdb693 | 16 | |
charly | 1:fc72e0bdb693 | 17 | eth_comfort eth_comf(p11, p12, p13, p14, p18, LED4); // mosi, miso, sclk, cs, rxdata, rxled |
charly | 0:96794c9fc5a3 | 18 | |
charly | 0:96794c9fc5a3 | 19 | Serial pc(USBTX, USBRX); // tx, rx |
charly | 0:96794c9fc5a3 | 20 | |
charly | 0:96794c9fc5a3 | 21 | // mbed LEDs |
charly | 1:fc72e0bdb693 | 22 | /* |
charly | 0:96794c9fc5a3 | 23 | DigitalOut led1(LED1); |
charly | 0:96794c9fc5a3 | 24 | DigitalOut led2(LED2); |
charly | 0:96794c9fc5a3 | 25 | DigitalOut led3(LED3); |
charly | 0:96794c9fc5a3 | 26 | DigitalOut led4(LED4); |
charly | 1:fc72e0bdb693 | 27 | */ |
charly | 0:96794c9fc5a3 | 28 | |
charly | 0:96794c9fc5a3 | 29 | //--------------------------------------------------------------------- |
charly | 0:96794c9fc5a3 | 30 | // |
charly | 0:96794c9fc5a3 | 31 | //--------------------------------------------------------------------- |
charly | 0:96794c9fc5a3 | 32 | |
charly | 1:fc72e0bdb693 | 33 | int main() { |
charly | 1:fc72e0bdb693 | 34 | |
charly | 1:fc72e0bdb693 | 35 | eth_message message; |
charly | 0:96794c9fc5a3 | 36 | |
charly | 1:fc72e0bdb693 | 37 | pc.baud(115200); |
charly | 0:96794c9fc5a3 | 38 | |
charly | 1:fc72e0bdb693 | 39 | pc.printf("\n\rConnected to mbed\n\r"); |
charly | 1:fc72e0bdb693 | 40 | lcd.printf("Hello!\n"); |
charly | 0:96794c9fc5a3 | 41 | |
charly | 1:fc72e0bdb693 | 42 | do { |
charly | 1:fc72e0bdb693 | 43 | // anything new? |
charly | 1:fc72e0bdb693 | 44 | if (eth_comf.readable()) { |
charly | 1:fc72e0bdb693 | 45 | // read the new message and display |
charly | 1:fc72e0bdb693 | 46 | message = eth_comf.getMessage(); |
charly | 1:fc72e0bdb693 | 47 | pc.printf("\n\rCounter: %02X\n\r",message.cnt); |
charly | 1:fc72e0bdb693 | 48 | pc.printf( " Dev-ID: %06X\n\r",message.adr); |
charly | 1:fc72e0bdb693 | 49 | pc.printf( " cmd: %0X\n\r",message.cmd); |
charly | 1:fc72e0bdb693 | 50 | //pc.printf( "cmd&0x80: %0X\n\r",message.cmd&0x80); |
charly | 1:fc72e0bdb693 | 51 | // why doesn't work the following?????????????? |
charly | 1:fc72e0bdb693 | 52 | //pc.printf( "Battery: "); |
charly | 1:fc72e0bdb693 | 53 | //if (message.cmd&0x80 == 0x00) pc.printf("GOOD\n\r"); else pc.printf("WEAK\n\r"); |
charly | 0:96794c9fc5a3 | 54 | |
charly | 1:fc72e0bdb693 | 55 | pc.printf( "Window : %s\n\r\n\r", (message.cmd&0x01 != 0x00) ? "OPEN" : "CLOSE"); |
charly | 1:fc72e0bdb693 | 56 | lcd.cls(); |
charly | 1:fc72e0bdb693 | 57 | lcd.printf("#:%02X ID: %06X\n",message.cnt,message.adr); |
charly | 1:fc72e0bdb693 | 58 | lcd.printf("Window : %s\n", (message.cmd&0x01 != 0x00) ? "OPEN" : "CLOSE"); |
charly | 1:fc72e0bdb693 | 59 | pc.printf("\n\r"); |
charly | 1:fc72e0bdb693 | 60 | } |
charly | 1:fc72e0bdb693 | 61 | } while (1==1); |
charly | 0:96794c9fc5a3 | 62 | |
charly | 0:96794c9fc5a3 | 63 | } |
charly | 0:96794c9fc5a3 | 64 | |
charly | 0:96794c9fc5a3 | 65 |