Advertisement
SoapSuds

Untitled

May 4th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. int verbose = 1;
  2. int debug = 0;
  3.  
  4. /* Define the uart we are reading from (In this case Serial1)*/
  5. Stream* uart1;
  6.  
  7. //Start up the Bitdex operations
  8. void setup(){
  9.   //Open Arduino Serials port for USB
  10.   Serial.begin(9600);
  11.  
  12.   //Open the Serial1 TX/RX lines
  13.   Serial1.begin(9600);
  14.  
  15.   //Print string
  16.   printString("Booting up....", 1, 0);
  17.  
  18.   //Start up WiFly -- Boot wifi componenet
  19.   printString("Initalizing WiFi", 0, 1);
  20.  
  21.   printString("Wifi Handshake | Success", 1, 0);
  22.  
  23.  
  24.   delay(1000);
  25.   printString("Entering command mode", 0, 1);
  26.   Serial1.println("$$$");
  27.  
  28. }
  29.  
  30.  
  31. void loop(){
  32.  
  33.   if(Serial1.available()){
  34.     Serial.println(Serial1.read());
  35.   }
  36. }
  37.  
  38.  
  39.  
  40. /* WiFly Functions */
  41. void setUart(Stream* uart){
  42.  
  43. }
  44.  
  45.  
  46.  
  47. /* Help full functions */
  48. void printString(String string_to_print, int verbose_required, int debug_required){
  49.   int printHappened = 0;
  50.  
  51.   //Is verbose or debug required to print this string?
  52.   if((verbose_required == 1 && verbose == 1) || debug_required == 1 && debug == 1){
  53.     //Print string
  54.     Serial.print(string_to_print);
  55.     printHappened = 1;
  56.    
  57.   }
  58.  
  59.   if(verbose_required == 0 && debug_required == 0 && printHappened == 0){
  60.     //Print string
  61.     Serial.print(string_to_print);
  62.     printHappened = 1;
  63.    
  64.   }
  65.  
  66.   if(printHappened){
  67.     //Make a new line to keep the terminal tidy
  68.     Serial.print("\n");
  69.   }
  70.    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement