Go Down

Topic: MatrixDisplay + WiServer = not compatible? (Read 423 times) previous topic - next topic


Mar 05, 2013, 10:47 pm Last Edit: Mar 06, 2013, 01:32 am by Catfang Reason: 1
I have a PC/2/You LED sign that I've wired to a RuggedCircuits Yellowjacket, for the purposes of having a sign that can be updated from any local web browser. The goal is to run a simple webserver on the Yellowjacket that takes REST-like calls to update the LED display. I've been able to successfully run the webserver code, and I've also confirmed that the LED sign works (after moving the two signal pins from 10/11 to 15/16). HOWEVER, as soon as I start to try to use both in the same sketch, the webserver appears to quit working. More specifically, as soon as I add the following line that instantiates the display, the webserver fails to ever connect to my wifi network:
Code: [Select]

// Init Matrix
MatrixDisplay disp(3,16,15, false);

I have two thoughts on the culprit: either I'm running out of memory at runtime, or there is something conflicting between the two libraries.

Anyone have any idea what could be causing the conflict? I never receive any errors, but adding this singlar line of code is enough to cause the Yellowjacket to no longer be able to connect to the wifi network nor respond to web requests (obviously).

My test code:
Code: [Select]

* A simple sketch that uses WiServer to serve a web page
// for the wifi:
#include <EEPROM.h>
#include <TinyREST.h>
#include <WiServer.h>
// for the display:
#include <string.h>
#include "MatrixDisplay.h"
#include "DisplayToolbox.h"
#include "font.h"


// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,20}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"Home"}; // max 32 bytes

unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"password"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------

// Matrix display configuration parameters ----------------------------------------

const int numLines = 6;        // Max number of lines
const int displayTime = 2500;  // Length of time in milliseconds to display each line
const int gapTime = 10;        // Time gap between lines
const int maxLineLength = 100; // Maximum length of a line in characters

String textLines[numLines];     // Array of text lines

int textLength;          // Holds current line length in pixels
int strLength;           // Holds current line length in characters
int currentLine = 0;     // Index of current line

char defaultText[numLines][30] = {{"Awaiting input..."}};

// Character lookup string -- used to map the characters from the keyboard onto the font data array
// (This should probably be moved to program memory in some form in the future)
String charLookup  = " 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*(),-.?></\\|[]_=+:'\"{}";

// Memory test
extern int __bss_end;
extern int *__brkval;

// Macro to make it the initDisplay function a little easier to understand
#define setMaster(dispNum, CSPin) initDisplay(dispNum,CSPin,true)
#define setSlave(dispNum, CSPin) initDisplay(dispNum,CSPin,false)

// Initialize matrix
//MatrixDisplay disp(3,16,15, true);  // <= Uncommenting this line prevents the Yellowjacket from connecting. :(
//DisplayToolbox toolbox(&disp);

// Prepare boundaries
uint8_t X_MAX = 0;
uint8_t Y_MAX = 0;

#define is_printable(c) (!(c&0x80))   

int line = 0;
const unsigned int MAX_INPUT = 100;

// End of matrix display configuration parameters ----------------------------------------

TinyREST rest = TinyREST();
static char cmd_read_string[] = {"string_read"};
static char cmd_write_string[] = {"string_write"};

// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
  return rest.handleURL(URL);

void setup() {
  // Initialize WiServer and have it use the sendMyPage function to serve pages
  rest.addCommand(cmd_read_string, 2, testCallback);
  rest.addCommand(cmd_write_string, 2, testCallback);
  // Enable Serial output and ask WiServer to generate log messages (optional)
  // Enable matrix display
//  for(int i=0; i<numLines; i++){
//    textLines[i] = defaultText[i];
//    Serial.println(defaultText[i]);
//  } 
//  // Fetch display bounds
//  X_MAX = disp.getDisplayCount() * (disp.getDisplayWidth()-1)+3;
//  Y_MAX = disp.getDisplayHeight()-1;
//  // Prepare displays
//  disp.setMaster(0,4);
//  disp.setSlave(1,5);
//  disp.setSlave(2,6);

void loop(){

  // Run WiServer

static int testCallback(TinyREST *srv, char *cmd, int len, char **args, void *blind){
  if (strcmp(cmd, cmd_read_string)==0) {
    //read the string
    WiServer.print("***Pretending to read string!");
    Serial.println("***Pretending to read string!");
  } else if (strcmp(cmd, cmd_write_string)==0) {
    //write the string
    WiServer.print("***Pretending to write string!");
    Serial.println("***Pretending to write string!");
  return RESPONSE_OK;

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131