Advertisement
KRITSADA

ATX2 & Wireless-X GLCD Rx DEMO

Oct 14th, 2016
1,611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <ATX2.h>
  2.  
  3. void setup()
  4. {
  5.   XIOinit();
  6.   glcdClear();
  7.   glcdMode(1);
  8.   setTextSize(2);
  9.   setTextColor(GLCD_SKY);
  10.   glcd(1, 0, "Connect      ");
  11.   setTextColor(GLCD_GREEN);
  12.   glcd(2, 0, "Wireless-X");
  13.   glcd(3, 0, "  Receiver     ");
  14.   setTextColor(GLCD_WHITE);
  15.   glcd(4, 0, "to (2) RxD1  ");
  16.   setTextColor(GLCD_ORANGE);
  17.   glcd(5, 0, "and push (OK)");
  18.   while (!sw_OK());
  19.   glcdClear();
  20.   setTextSize(2);
  21.   Serial1.begin(9600);
  22. }
  23.  
  24. void loop()
  25. {
  26.   int RxByte;
  27.   while (1)
  28.   {
  29.     RxByte = 0;
  30.     while (Serial1.available() > 0)
  31.       RxByte = Serial1.read();
  32.     setTextColor(GLCD_WHITE);
  33.     glcd(1, 2, "%b", ((RxByte & 0x80) != 0));
  34.     glcd(2, 0, "%b", ((RxByte & 0x40) != 0));
  35.     glcd(2, 4, "%b", ((RxByte & 0x20) != 0));
  36.     glcd(3, 2, "%b", ((RxByte & 0x10) != 0));
  37.  
  38.     glcd(1, 10, "%b", ((RxByte & 0x08) != 0));
  39.     glcd(2, 8, "%b", ((RxByte & 0x04) != 0));
  40.     glcd(2, 12, "%b", ((RxByte & 0x02) != 0));
  41.     glcd(3, 10, "%b", ((RxByte & 0x01) != 0));
  42.  
  43.     setTextColor(GLCD_YELLOW);
  44.     glcd(5, 0, "DATA:%b%b%b%b%b%b%b%b",
  45.          ((RxByte & 0x80) != 0), ((RxByte & 0x40) != 0),
  46.          ((RxByte & 0x20) != 0), ((RxByte & 0x10) != 0),
  47.          ((RxByte & 0x08) != 0), ((RxByte & 0x04) != 0),
  48.          ((RxByte & 0x02) != 0), ((RxByte & 0x01) != 0)
  49.         );
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement