Advertisement
Guest User

Untitled

a guest
Aug 4th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include "SparkIntervalTimer/SparkIntervalTimer.h"
  2. #include "Adafruit_mfGFX/Adafruit_mfGFX.h"   // Core graphics library
  3. #include "RGBmatrixPanel/RGBmatrixPanel.h" // Hardware-specific library
  4.  
  5. #define CLK D6
  6. #define OE  D7
  7. #define LAT A4
  8. #define A   A0
  9. #define B   A1
  10. #define C   A2
  11. #define D    A3
  12.  
  13. #define MAXLINE 2048
  14.  
  15. TCPServer server = TCPServer(17061);
  16. TCPClient client;
  17.  
  18. String message = "";
  19.  
  20. RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
  21.  
  22. void read_message();
  23.  
  24. void setup() {
  25.       // start listening for clients
  26.       server.begin();
  27.       Serial1.begin(115200);
  28.    
  29.       matrix.begin();
  30.  
  31.  
  32. }
  33.  
  34. void loop() {
  35.       if (client.connected())
  36.       {
  37.         read_message();
  38.         for(int x = 0; x < message.length(); x++)
  39.         {
  40.             Serial1.print(message.charAt(x));
  41.         }
  42.         message = "";
  43.       }
  44.       else
  45.       {
  46.         // if no client is yet connected, check for a new connection
  47.         //client.stop();
  48.         client = server.available();
  49.       }
  50. }
  51.  
  52. void read_message()
  53. {
  54.     while(client.connected())
  55.     {
  56.         if(client.available())
  57.             {
  58.                 char c = client.read();
  59.                 message += c;
  60.             }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement