Fixing stuff to latest version
This commit is contained in:
parent
4bbe270c1d
commit
404e384c08
|
@ -1,59 +1,63 @@
|
||||||
/*
|
/*
|
||||||
* A simple sketch that uses WiServer to serve a web page
|
* A simple sketch that uses WiServer to serve a web page
|
||||||
*/
|
*/
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
uint8_t la[8] PROGMEM ={0x7c,0x44,0x44,0x7c,0x44};
|
uint8_t la[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};
|
||||||
uint8_t lb[8] PROGMEM ={0x7c,0x44,0x78,0x44,0x7c};
|
uint8_t lb[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};
|
||||||
uint8_t lc[8] PROGMEM ={0x7c,0x40,0x40,0x40,0x7c};
|
uint8_t lc[8]={0x00,0x7c,0x40,0x40,0x40,0x7c,0x00,0x00};
|
||||||
const uint8_t ld[8] PROGMEM ={0x78,0x44,0x44,0x44,0x78};
|
uint8_t ld[8]={0x00,0x78,0x44,0x44,0x44,0x78,0x00,0x00};
|
||||||
const uint8_t le[8] PROGMEM ={0x7c,0x40,0x78,0x40,0x7c};
|
uint8_t le[8]={0x00,0x7c,0x40,0x78,0x40,0x7c,0x00,0x00};
|
||||||
const uint8_t lf[8] PROGMEM ={0x7c,0x40,0x70,0x40,0x40};
|
uint8_t lf[8]={0x00,0x7c,0x40,0x70,0x40,0x40,0x00,0x00};
|
||||||
const uint8_t lg[8] PROGMEM ={0x7c,0x40,0x4c,0x44,0x7c};
|
uint8_t lg[8]={0x00,0x7c,0x40,0x4c,0x44,0x7c,0x00,0x00};
|
||||||
const uint8_t lh[8] PROGMEM ={0x44,0x44,0x7c,0x44,0x44};
|
uint8_t lh[8]={0x00,0x44,0x44,0x7c,0x44,0x44,0x00,0x00};
|
||||||
const uint8_t li[8] PROGMEM ={0x7c,0x10,0x10,0x10,0x7c};
|
uint8_t li[8]={0x00,0x7c,0x10,0x10,0x10,0x7c,0x00,0x00};
|
||||||
const uint8_t lj[8] PROGMEM ={0x0c,0x04,0x04,0x44,0x7c};
|
uint8_t lj[8]={0x00,0x0c,0x04,0x04,0x44,0x7c,0x00,0x00};
|
||||||
const uint8_t lk[8] PROGMEM ={0x44,0x48,0x70,0x48,0x44};
|
uint8_t lk[8]={0x00,0x44,0x48,0x70,0x48,0x44,0x00,0x00};
|
||||||
const uint8_t ll[8] PROGMEM ={0x40,0x40,0x40,0x40,0x7c};
|
uint8_t ll[8]={0x00,0x40,0x40,0x40,0x40,0x7c,0x00,0x00};
|
||||||
const uint8_t lm[8] PROGMEM ={0x44,0x6c,0x54,0x44,0x44};
|
uint8_t lm[8]={0x00,0x44,0x6c,0x54,0x44,0x44,0x00,0x00};
|
||||||
const uint8_t ln[8] PROGMEM ={0x44,0x64,0x54,0x4c,0x44};
|
uint8_t ln[8]={0x00,0x44,0x64,0x54,0x4c,0x44,0x00,0x00};
|
||||||
const uint8_t lo[8] PROGMEM ={0x38,0x44,0x44,0x44,0x38};
|
uint8_t lo[8]={0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00};
|
||||||
const uint8_t lp[8] PROGMEM ={0x78,0x44,0x78,0x40,0x40};
|
uint8_t lp[8]={0x00,0x78,0x44,0x78,0x40,0x40,0x00,0x00};
|
||||||
const uint8_t lq[8] PROGMEM ={0x7c,0x44,0x44,0x7c,0x10};
|
uint8_t lq[8]={0x00,0x7c,0x44,0x44,0x7c,0x10,0x00,0x00};
|
||||||
const uint8_t lr[8] PROGMEM ={0x78,0x44,0x78,0x44,0x44};
|
uint8_t lr[8]={0x00,0x78,0x44,0x78,0x44,0x44,0x00,0x00};
|
||||||
const uint8_t ls[8] PROGMEM ={0x7c,0x40,0x7c,0x04,0x7c};
|
uint8_t ls[8]={0x00,0x7c,0x40,0x7c,0x04,0x7c,0x00,0x00};
|
||||||
const uint8_t lt[8] PROGMEM ={0x7c,0x10,0x10,0x10,0x10};
|
uint8_t lt[8]={0x00,0x7c,0x10,0x10,0x10,0x10,0x00,0x00};
|
||||||
const uint8_t lu[8] PROGMEM ={0x44,0x44,0x44,0x44,0x7c};
|
uint8_t lu[8]={0x00,0x44,0x44,0x44,0x44,0x7c,0x00,0x00};
|
||||||
const uint8_t lv[8] PROGMEM ={0x44,0x44,0x28,0x28,0x10};
|
uint8_t lv[8]={0x00,0x44,0x44,0x28,0x28,0x10,0x00,0x00};
|
||||||
const uint8_t lw[8] PROGMEM ={0x44,0x44,0x54,0x54,0x28};
|
uint8_t lw[8]={0x00,0x44,0x44,0x54,0x54,0x28,0x00,0x00};
|
||||||
const uint8_t lx[8] PROGMEM ={0x44,0x28,0x10,0x28,0x44};
|
uint8_t lx[8]={0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00};
|
||||||
const uint8_t ly[8] PROGMEM ={0x44,0x44,0x28,0x10,0x10};
|
uint8_t ly[8]={0x00,0x44,0x44,0x28,0x10,0x10,0x00,0x00};
|
||||||
const uint8_t lz[8] PROGMEM ={0x7c,0x08,0x10,0x20,0x7c};
|
uint8_t lz[8]={0x00,0x7c,0x08,0x10,0x20,0x7c,0x00,0x00};
|
||||||
|
|
||||||
//MEMSAVING
|
uint8_t nze[8]={0x00,0x7c,0x4c,0x54,0x64,0x7c,0x00,0x00};
|
||||||
const uint8_t nze[8] PROGMEM ={0x7c,0x4c,0x54,0x64,0x7c};
|
uint8_t non[8]={0x00,0x10,0x30,0x10,0x10,0x38,0x00,0x00};
|
||||||
const uint8_t non[8] PROGMEM ={0x10,0x30,0x10,0x10,0x38};
|
uint8_t ntw[8]={0x00,0x78,0x04,0x38,0x40,0x7c,0x00,0x00};
|
||||||
const uint8_t ntw[8] PROGMEM ={0x78,0x04,0x38,0x40,0x7c};
|
uint8_t nth[8]={0x00,0x7c,0x04,0x38,0x04,0x7c,0x00,0x00};
|
||||||
const uint8_t nth[8] PROGMEM ={0x7c,0x04,0x38,0x04,0x7c};
|
uint8_t nfo[8]={0x00,0x40,0x40,0x50,0x7c,0x10,0x00,0x00};
|
||||||
const uint8_t nfo[8] PROGMEM ={0x40,0x40,0x50,0x7c,0x10};
|
uint8_t nfi[8]={0x00,0x7c,0x40,0x78,0x04,0x78,0x00,0x00};
|
||||||
const uint8_t nfi[8] PROGMEM ={0x7c,0x40,0x78,0x04,0x78};
|
uint8_t nsi[8]={0x00,0x7c,0x40,0x7c,0x44,0x7c,0x00,0x00};
|
||||||
const uint8_t nsi[8] PROGMEM ={0x7c,0x40,0x7c,0x44,0x7c};
|
uint8_t nse[8]={0x00,0x7c,0x04,0x08,0x10,0x10,0x00,0x00};
|
||||||
const uint8_t nse[8] PROGMEM ={0x7c,0x04,0x08,0x10,0x10};
|
uint8_t nei[8]={0x00,0x7c,0x44,0x7c,0x44,0x7c,0x00,0x00};
|
||||||
const uint8_t nei[8] PROGMEM ={0x7c,0x44,0x7c,0x44,0x7c};
|
uint8_t nni[8]={0x00,0x7c,0x44,0x7c,0x04,0x7c,0x00,0x00};
|
||||||
const uint8_t nni[8] PROGMEM ={0x7c,0x44,0x7c,0x04,0x7c};
|
|
||||||
|
|
||||||
const uint8_t pqu[8] PROGMEM ={0x78,0x04,0x18,0x00,0x10};
|
uint8_t pqu[8]={0x00,0x78,0x04,0x18,0x00,0x10,0x00,0x00};
|
||||||
const uint8_t ppe[8] PROGMEM ={0x00,0x00,0x00,0x00,0x20};
|
uint8_t ppe[8]={0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00};
|
||||||
const uint8_t pco[8] PROGMEM ={0x00,0x00,0x00,0x20,0x20};
|
uint8_t pco[8]={0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00};
|
||||||
const uint8_t pap[8] PROGMEM ={0x20,0x20,0x00,0x00,0x00};
|
uint8_t pap[8]={0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||||
const uint8_t pqt[8] PROGMEM ={0x28,0x28,0x00,0x00,0x00};
|
uint8_t pqt[8]={0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00};
|
||||||
|
uint8_t pcl[8]={0x00,0x00,0x20,0x00,0x20,0x00,0x00,0x00};
|
||||||
|
|
||||||
uint8_t sp[8]={0,0,0,0,0};
|
uint8_t sp[8]={0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
SoftwareSerial mySerial(2, 3, true);
|
SoftwareSerial mySerial(2, 3, true);
|
||||||
boolean serial_debug = false;
|
boolean serial_debug = false;
|
||||||
String lineread;
|
String lineread;
|
||||||
|
|
||||||
|
char signbuffer[18];
|
||||||
|
int signcursor = 0;
|
||||||
|
|
||||||
char output[5];
|
char output[5];
|
||||||
|
|
||||||
uint8_t a[1];
|
uint8_t a[1];
|
||||||
|
@ -102,8 +106,11 @@ unsigned char security_passphrase_len;
|
||||||
|
|
||||||
|
|
||||||
// IP Address for api.twitter.com
|
// IP Address for api.twitter.com
|
||||||
uint8 ip[] = {199,59,150,41};
|
//uint8 ip[] = {199,59,150,41};
|
||||||
GETrequest getTweet(ip, 80, "api.twitter.com", "/1/statuses/user_timeline.json?include_entities=false&include_rts=false&screen_name=heatsynclabs&count=1");
|
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;
|
long updateTime = 0;
|
||||||
|
|
||||||
|
@ -129,6 +136,8 @@ void setup() {
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check if it's time to get an update
|
// Check if it's time to get an update
|
||||||
if (millis() >= updateTime) {
|
if (millis() >= updateTime) {
|
||||||
Serial.println("go!");
|
Serial.println("go!");
|
||||||
|
@ -137,6 +146,13 @@ void loop(){
|
||||||
// Get an update every 30 seconds
|
// Get an update every 30 seconds
|
||||||
updateTime += 1000 * 30;
|
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
|
// Run WiServer
|
||||||
WiServer.server_task();
|
WiServer.server_task();
|
||||||
|
@ -150,20 +166,18 @@ void load_message(char textmsg[18]) {
|
||||||
// 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];
|
||||||
|
|
||||||
// convert message to led font
|
// convert message to led font
|
||||||
for(int chr=0;chr<18;chr++){
|
for(int chr=0;chr<18;chr++){
|
||||||
switch(textmsg[chr]) {
|
switch(textmsg[chr]) {
|
||||||
case 'a':
|
case 'a':
|
||||||
//message[chr] = la;
|
message[chr] = la;
|
||||||
memcpy_P(&(message[chr]), pgm_read_byte(&(la)), 1);
|
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
//message[chr] = lb;
|
message[chr] = lb;
|
||||||
memcpy_P(&(message[chr]), pgm_read_byte(&(lb)), 1);
|
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case 'c':
|
case 'c':
|
||||||
message[chr] = lc;
|
message[chr] = lc;
|
||||||
break;
|
break;
|
||||||
|
@ -236,7 +250,6 @@ void load_message(char textmsg[18]) {
|
||||||
case 'z':
|
case 'z':
|
||||||
message[chr] = lz;
|
message[chr] = lz;
|
||||||
break;
|
break;
|
||||||
//MEMSAVING
|
|
||||||
case '0':
|
case '0':
|
||||||
message[chr] = nze;
|
message[chr] = nze;
|
||||||
break;
|
break;
|
||||||
|
@ -282,13 +295,15 @@ void load_message(char textmsg[18]) {
|
||||||
case '"':
|
case '"':
|
||||||
message[chr] = pqt;
|
message[chr] = pqt;
|
||||||
break;
|
break;
|
||||||
|
case ':':
|
||||||
|
message[chr] = pcl;
|
||||||
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
message[chr] = sp;
|
message[chr] = sp;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
message[chr] = sp;
|
message[chr] = sp;
|
||||||
break;*/
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +316,7 @@ void load_message(char textmsg[18]) {
|
||||||
// for each char in message:
|
// for each char in message:
|
||||||
for(int chr=0;chr<18;chr++){
|
for(int chr=0;chr<18;chr++){
|
||||||
// width is 9 bytes
|
// width is 9 bytes
|
||||||
// each letter occupies 1 byte in width and 5 (frmrly 8) bytes in height (horizontal scanning)
|
// each letter occupies 1 byte in width and 8 bytes in height (horizontal scanning)
|
||||||
// max height is 16 lines
|
// max height is 16 lines
|
||||||
// max offset is 118+72+9+63 = 262
|
// max offset is 118+72+9+63 = 262
|
||||||
|
|
||||||
|
@ -315,20 +330,19 @@ void load_message(char textmsg[18]) {
|
||||||
i[ofst+18] = message[chr][2];
|
i[ofst+18] = message[chr][2];
|
||||||
i[ofst+27] = message[chr][3];
|
i[ofst+27] = message[chr][3];
|
||||||
i[ofst+36] = message[chr][4];
|
i[ofst+36] = message[chr][4];
|
||||||
//i[ofst+45] = message[chr][5];
|
i[ofst+45] = message[chr][5];
|
||||||
//i[ofst+54] = message[chr][6];
|
i[ofst+54] = message[chr][6];
|
||||||
//i[ofst+63] = message[chr][7];
|
i[ofst+63] = message[chr][7];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,30 +417,36 @@ void setup_sign_protocol() {
|
||||||
// Function to handle data from the server
|
// Function to handle data from the server
|
||||||
void processData(char* data, int len) {
|
void processData(char* data, int len) {
|
||||||
// Do stuff with the data here
|
// Do stuff with the data here
|
||||||
char buffer[18];
|
|
||||||
|
|
||||||
for(int i=0;i<len;i++){
|
for(int i=0;i<len;i++){
|
||||||
if(data[i] == '"'
|
Serial.print(data[i]);
|
||||||
&& data[i+1] == 't'
|
if(data[i] == '^' || signcursor > 0) {
|
||||||
&& data[i+2] == 'e'
|
// append to stream if we find a ^ or if we're already appending
|
||||||
&& data[i+3] == 'x'
|
|
||||||
&& data[i+4] == 't'
|
|
||||||
&& data[i+5] == '"'
|
|
||||||
&& data[i+6] == ':'
|
|
||||||
&& data[i+7] == '"'
|
|
||||||
) {
|
|
||||||
i=i+8;
|
|
||||||
while(data[i] != '"' && i < len) {
|
|
||||||
buffer = {data[i],data[i+1],data[i+2],data[i+3],
|
|
||||||
data[i+4],data[i+5],data[i+6],data[i+7],
|
|
||||||
data[i+8],data[i+9],data[i+10],data[i+11],
|
|
||||||
data[i+12],data[i+13],data[i+14],data[i+15],
|
|
||||||
data[i+16],data[i+17]};
|
|
||||||
|
|
||||||
i=i+18;
|
// advance past the ^
|
||||||
load_message(buffer);
|
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();
|
send_data();
|
||||||
delay(2000);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user