Exemplo n.º 1
0
int defineCharacter(int ascii, int *data) {
  int baseAddress = (ascii * 8) + 64;
  lcd.commandWrite(baseAddress);
  for (int i = 0; i < 8; i++)
    lcd.print(data[i]);
  return ascii;
}
Exemplo n.º 2
0
/*
 * We'll have the WiServer call this function whenever a resource needs to be sent
 * @param URL null-terminated URL of the resource to send
 */
boolean sendPage(char* URL) {
  Serial.println(URL);
  // Request for the main page (checked last because other URL's also start with '/')
  if (strcmp(URL, "/") == 0) {
    WiServer.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
    WiServer.print("<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-gb\" xml:lang=\"en-gb\">");
    WiServer.print("<head>");
    WiServer.print("</head><body>"); 
    WiServer.print("<script src=\"http://download.milesburton.com/Arduino/WiServer/htmlScript.js\" type=\"text/javascript\"></script>");
    WiServer.print("</body></html>");
    return true;   
  }
  else{
    // Consider a URL to be a request to output to a URL
    // Each forward slash represents a new line (4 lines max)
    
    int j = 1; // Start at char 1 of the URL (ignore the first /)
    lcd.clear(); // Clear LCD
    Serial.println("Writing to LCD");
    
    int len = strlen(URL);
    // Loop through each line
    for(int i=1;i<5;i++)
    {
      Serial.print("Writing to line");
      Serial.print(i);
      Serial.print('\n');


      lcd.cursorTo(i,0); // Move to line
      
      // Read next page of URL
      
      for(j=j;j<len;j++)
      {
        if(((j+2)<=len) && URL[j]=='%' && URL[j+1]=='2' && URL[j+2]=='0')
        {
          lcd.print(' ');
          j+=2;
          continue;
        }  
        
         
        if(URL[j]=='/')
        {
          j++;
          break; // If the current char is a /, break out read for the next line
        }
        lcd.print(URL[j]); // Write out char in URL to LCD
        Serial.print(URL[j]); // Send to Serial also
      }
       Serial.print('\n'); // Write a new line for easy reading
    }
    
    Serial.println("...Waiting for next command...");
    return true; // Return 200 to page
  }
}
Exemplo n.º 3
0
void loop() {  
  val = analogRead(potPin);
  
  if (val != valOld)
    {
       lcd.cursorTo(1, 10); 
       sprintf(buffer,"%4d",val);
       lcd.printIn(buffer);
    }
      valOld= val;
  
   /***** sending the dmx signal *****/
  // sending the break (the break can be between 88us and 1sec)
  digitalWrite(sig, LOW);

  delay(val);

  // sending the start byte
  shiftDmxOut(sig, 0);

  for (int count = 1; count <= 512; count++)
  {
    shiftDmxOut(sig, value[count]);
  }
  /***** sending the dmx signal end *****/

  value[1] += valueadd[1];
  if ((value[1] <= 0) || (value[1] >= 250))
  {
    valueadd[1] *= -1;
  }
 
 
 value[2] += valueadd[2];
  if ((value[2] <= 0) || (value[2] >= 250))
  {
    valueadd[2] *= -1;
  }

 
 value[3] += valueadd[3];
  if ((value[3] <= 0) || (value[3] >= 250))
  {
    valueadd[3] *= -1;
  }
   
 
 value[4] += valueadd[4];
  if ((value[4] <= 0) || (value[4] >= 250))
  {
    valueadd[4] *= -1;
  }
  
}
Exemplo n.º 4
0
void setup() { 
  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat
  pinMode(sig, OUTPUT);
  lcd.init();
  //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
  //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)
       lcd.clear();
       val = analogRead(potPin);
       sprintf(buffer,"%4d",val);
       lcd.printIn("Poti:");
       lcd.cursorTo(1, 10); 
       lcd.printIn(buffer);
}
Exemplo n.º 5
0
void logoScreen() {

  int copywrite[] = { 128,159,145,149,151,149,145,159 };  // (c) symbol  
  defineCharacter(1, copywrite);

  // screen one.
  lcd.clear();
  moveToChar(1,0);
  lcd.printIn("PerLCD v1.0");
  moveToChar(2,0);
  lcd.print(1); lcd.printIn(" kevin montuori");
  delay(2000);
  lcd.clear();
}
Exemplo n.º 6
0
// do something...
void dispatchCommand() {
  int commandNumber = atoi(commandBuffer);
  if (DEBUG) {
    Serial.print("command buffer is: "); Serial.println(commandBuffer);
    Serial.println("accumulated data:"); Serial.println(dataBuffer);
  }

  int dataAsInt;
  switch (commandNumber) {
  case CLEAR:
    clearLineHistory();
    lcd.clear();
    break;
  case ROW_ONE_TEXT:
    writeLine(1, dataBuffer);
    break;
  case ROW_TWO_TEXT:
    writeLine(2, dataBuffer);
    break;
  case PLACE_STRING:
    writeString(dataBuffer);
    break;
  case WRITE_ASCII:
    writeAscii(dataBuffer);
    break;
  case SCROLL_LEFT:
    dataAsInt = atoi(dataBuffer);
    dataAsInt > 0 ? dataAsInt : DEFAULT_SCROLL_DELAY;
    lcd.leftScroll(LINE_SIZE, 
		   dataAsInt > 0 ? dataAsInt : DEFAULT_SCROLL_DELAY);
    lcd.clear();		// should i or not?
    break;
  case SCROLL_UP:
    writeLine(1, lineHistory[2]);
    writeLine(2, dataBuffer);
    break;
  case MAKE_CHAR:
    recvCharData();
    break;
  case SET_GAUGE:
    setGauge();
    break;
  case SEND_CMD:
    lcd.commandWrite(atoi(dataBuffer));
    break;
  case PRINT:
    lcd.print(atoi(dataBuffer));
    break;
  case RESET:
    clearLineHistory();
    resetGauges();
    lcd.clear();
    break;
  default: 
    lcd.clear();
    lcd.printIn("Undef'd Command");
  }
}
Exemplo n.º 7
0
void writeString(char *data) {
  char *tokens[MAX_DATA_SIZE];
  int toks = tokenizeData(tokens);
  if (toks == 3) {
    moveToChar(atoi(tokens[0]), atoi(tokens[1]));
    lcd.printIn(tokens[2]);
  }
}
Exemplo n.º 8
0
// initializer.
void setup() {
  lcd.init();
  for (int i = 1; i > sizeof(analoguePins); i++) // setup the pins.
    pinMode(analoguePins[i], OUTPUT);
  logoScreen();			// blatent self-promotion.
  clearLineHistory();
  memset(blankLine, SPACE, (LINE_SIZE - 1));
  Serial.begin(SERIAL_SPEED);
}
Exemplo n.º 9
0
void setup() {
  // Init the WiServer with our sendPage function that we defined above
  Serial.begin(9200);
  Serial.println("Loading..");
  
  // Output some bits and peices to screen
  lcd.init();
  lcd.clear();
  lcd.cursorTo(1,0);
  lcd.printIn("Wireless LCD Shield");
  lcd.cursorTo(2,0);
  lcd.printIn("MilesBurton.com 2009");
  lcd.cursorTo(3,0);
  lcd.printIn("Powered by WiShield");
  lcd.cursorTo(4,0);
  lcd.printIn("Loading...");
  
  // Initalise and connect Wifi
  WiServer.init(sendPage);  

  // Confirm we're finished loading
  Serial.println("Finished loading...");
  // Update the LCD
  lcd.cursorTo(4,0); 
  lcd.printIn("Ready...");
}
Exemplo n.º 10
0
void printDebugChar(char someChar) {
  moveToChar(2, 15);
  lcd.print(someChar);
}
Exemplo n.º 11
0
void writeCharAt(int row, int col, char character) {
  moveToChar(row, col);
  lcd.print(character);
}
Exemplo n.º 12
0
// slightly faster than lcd.cursorTo (particularly on the second line
// of a two line display).
void moveToChar(int row, int col) {
  int address = DDRAM_OFFSET + ((row - 1) * ROW_MULTIPLIER) + col;
  lcd.commandWrite(address);
}
Exemplo n.º 13
0
// writes msg to required line
void lcd_print(byte line, char *msg)
{
  byte i;
  lcd.cursorTo(line + 1, 0);
  lcd.printIn(msg);
}
Exemplo n.º 14
0
void lcd_init()
{
  lcd.init();
  lcd.clear();
}