Compare commits

..

2 Commits

Author SHA1 Message Date
3da8001c4c Renaming sketch 2016-06-16 09:44:01 -07:00
6db5cf4a80 Ripping out all the wifi stuff 2016-06-16 09:41:43 -07:00

View File

@ -60,111 +60,45 @@ int signcursor = 0;
char output[5]; char output[5];
uint8_t a[1]; // Protocol crap
uint8_t b[13]; uint8_t a[1] = {0x1};
uint8_t c[1]; uint8_t b[13] = {0x6,0x7,0xD4,0x9,0x5,0x1B,0xE8,0x8,0x17,0x37,0x1B,0xE8,0xE4};
uint8_t d[1]; uint8_t c[1] = {0x0};
uint8_t e[1]; uint8_t d[1] = {0xA};
uint8_t f[1]; uint8_t e[1] = {0x1A};
uint8_t g[12]; uint8_t f[1] = {0x1};
uint8_t h[1]; uint8_t g[12] = {0x6,0x7,0xD4,0x9,0x5,0x1B,0xE8,0x8,0x17,0x38,0x0,0x9C};
uint8_t i[262]; uint8_t h[1] = {0x18};
uint8_t j[24]; // Set all LEDs on
uint8_t i[262] = {0x1B,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xD4,0x9,0x1B,0xE8,0x7,0xD4,0xA,0x1B,0xE8,0x0,0x0,0x0,0x17,0x3B,0x3B,0x7F,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x10,0x62,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x64,0x0,0x0,0x30,0x30,0x30,0x30,0x33,0x30,0x30,0x33,0x30,0x30,0x5C,0x42,0x30,0x30,0x5C,0x70,0x0,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x1,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x0,0x0,0x70,0x2E,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0,0x10,0x0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
#include <WiServer.h> // Protocol crap
uint8_t j[24] = {0x19,0x44,0x49,0x53,0x50,0x0,0x0,0x0,0x48,0x0,0x10,0x1,0x0,0x0,0x0,0x0,0x0,0x28,0x0,0x0,0x50,0x0,0x0,0x58};
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,100}; // 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 = {"heatsynclabs"}; // max 32 bytes
unsigned char security_type = 2; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"yourpasswordhere"}; // 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 ----------------------------------------
// IP Address for api.twitter.com
//uint8 ip[] = {199,59,150,41};
uint8 ip[] = {50,56,124,136};
//GETrequest getTweet(ip, 80, "api.twitter.com", "/1/statuses/user_timeline.json?include_entities=false&include_rts=false&screen_name=heatsynclabs&count=1");
GETrequest getTweet(ip, 80, "tweet.zyphon.com", "/cgi-bin/signage.rb");
long updateTime = 0;
void setup() { void setup() {
// Enable Serial output and ask WiServer to generate log messages (optional) // Enable Serial output and ask WiServer to generate log messages (optional)
Serial.begin(57600); Serial.begin(57600);
Serial.println("wifi");
// Initialize WiServer and have it use the sendMyPage function to serve pages
WiServer.init(NULL);
WiServer.enableVerboseMode(true);
getTweet.setReturnFunc(processData);
updateTime = millis();
Serial.println("ser"); Serial.println("ser");
// set the data rate for the SoftwareSerial port // set the data rate for the SoftwareSerial port
mySerial.begin(9600); mySerial.begin(9600);
mySerial.println("hi"); mySerial.println("hi");
//setup_sign_protocol(); send_data(); // this should send the new program to the sign
Serial.println("dun"); Serial.println("dun");
} }
void loop(){ void loop(){
// do nothing
// you can do something like this if you want but you should put a delay in the loop so it's not constant:
// load_message("foo bar");
// Check if it's time to get an update // send_data();
if (millis() >= updateTime) {
Serial.println("go!");
getTweet.submit();
// Get an update every 30 seconds
updateTime += 1000 * 30;
}
else{
// Check if it's time to clear the screen (20 secs before update)
if (millis() >= updateTime-1000*20) {
load_message(" ");
send_data();
}
}
// Run WiServer
WiServer.server_task();
delay(10);
} }
void load_message(char textmsg[18]) { void load_message(char textmsg[18]) {
// max size is 262 bytes with 118 bytes of header, leaving 144 bytes for 16x72 (1152 pixels) // max size is 262 bytes with 118 bytes of header, leaving 144 bytes for 16x72 (1152 pixels)
// this is the 118 byte header // this is the 118 byte header
i = {0x1B,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xD4,0x9,0x1B,0xE8,0x7,0xD4,0xA,0x1B,0xE8,0x0,0x0,0x0,0x17,0x3B,0x3B,0x7F,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x10,0x62,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x64,0x0,0x0,0x30,0x30,0x30,0x30,0x33,0x30,0x30,0x33,0x30,0x30,0x5C,0x42,0x30,0x30,0x5C,0x70,0x0,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x1,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x0,0x0,0x70,0x2E,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0,0x10,0x0}; //i = {0x1B,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xD4,0x9,0x1B,0xE8,0x7,0xD4,0xA,0x1B,0xE8,0x0,0x0,0x0,0x17,0x3B,0x3B,0x7F,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x10,0x62,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x64,0x0,0x0,0x30,0x30,0x30,0x30,0x33,0x30,0x30,0x33,0x30,0x30,0x5C,0x42,0x30,0x30,0x5C,0x70,0x0,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x1,0x70,0x30,0x30,0x33,0x30,0x30,0x33,0x0,0x0,0x70,0x2E,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x0,0x10,0x0};
uint8_t* message[18]; uint8_t* message[18];
@ -339,11 +273,10 @@ void load_message(char textmsg[18]) {
} }
void ser_print(){ void ser_print(){
// while (mySerial.available()) { while (mySerial.available()) {
// lineread = String(mySerial.read(),HEX); lineread = String(mySerial.read(),HEX);
// lineread.toCharArray(output,5); lineread.toCharArray(output,5);
// } }
} }
void array_sw(uint8_t data[], int datasize) { void array_sw(uint8_t data[], int datasize) {
@ -396,59 +329,4 @@ void send_data() {
ser_print(); ser_print();
} }
void setup_sign_protocol() {
// Protocol crap
a = {0x1};
b = {0x6,0x7,0xD4,0x9,0x5,0x1B,0xE8,0x8,0x17,0x37,0x1B,0xE8,0xE4};
c = {0x0};
d = {0xA};
e = {0x1A};
f = {0x1};
g = {0x6,0x7,0xD4,0x9,0x5,0x1B,0xE8,0x8,0x17,0x38,0x0,0x9C};
h = {0x18};
// Set all LEDs on
i = {0x1B,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0xD4,0x9,0x1B,0xE8,0x7,0xD4,0xA,0x1B,0xE8,0x0,0x0,0x0,0x17,0x3B,0x3B,0x7F,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0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0x0,0x0,0x0,0x0,0x0,0x28,0x0,0x0,0x50,0x0,0x0,0x58};
}
// Function to handle data from the server
void processData(char* data, int len) {
// Do stuff with the data here
for(int i=0;i<len;i++){
Serial.print(data[i]);
if(data[i] == '^' || signcursor > 0) {
// append to stream if we find a ^ or if we're already appending
// advance past the ^
if(data[i] == '^') {
i=i+1;
}
while(data[i] != '$' && i < len) {
signbuffer[signcursor] = data[i];
signcursor++;
i++;
if(data[i] == '$' || signcursor > 17 || i > len) {
// fill in any remaining letters in the buffer
for(int j=signcursor;j<18;j++){
signbuffer[j]='\0';
}
// send to the screen
signcursor = 0;
Serial.print("> sending:");
Serial.println(signbuffer);
load_message(signbuffer);
send_data();
}
}
}
}
}