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
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
uint8_t la[8] PROGMEM ={0x7c,0x44,0x44,0x7c,0x44};
|
||||
uint8_t lb[8] PROGMEM ={0x7c,0x44,0x78,0x44,0x7c};
|
||||
uint8_t lc[8] PROGMEM ={0x7c,0x40,0x40,0x40,0x7c};
|
||||
const uint8_t ld[8] PROGMEM ={0x78,0x44,0x44,0x44,0x78};
|
||||
const uint8_t le[8] PROGMEM ={0x7c,0x40,0x78,0x40,0x7c};
|
||||
const uint8_t lf[8] PROGMEM ={0x7c,0x40,0x70,0x40,0x40};
|
||||
const uint8_t lg[8] PROGMEM ={0x7c,0x40,0x4c,0x44,0x7c};
|
||||
const uint8_t lh[8] PROGMEM ={0x44,0x44,0x7c,0x44,0x44};
|
||||
const uint8_t li[8] PROGMEM ={0x7c,0x10,0x10,0x10,0x7c};
|
||||
const uint8_t lj[8] PROGMEM ={0x0c,0x04,0x04,0x44,0x7c};
|
||||
const uint8_t lk[8] PROGMEM ={0x44,0x48,0x70,0x48,0x44};
|
||||
const uint8_t ll[8] PROGMEM ={0x40,0x40,0x40,0x40,0x7c};
|
||||
const uint8_t lm[8] PROGMEM ={0x44,0x6c,0x54,0x44,0x44};
|
||||
const uint8_t ln[8] PROGMEM ={0x44,0x64,0x54,0x4c,0x44};
|
||||
const uint8_t lo[8] PROGMEM ={0x38,0x44,0x44,0x44,0x38};
|
||||
const uint8_t lp[8] PROGMEM ={0x78,0x44,0x78,0x40,0x40};
|
||||
const uint8_t lq[8] PROGMEM ={0x7c,0x44,0x44,0x7c,0x10};
|
||||
const uint8_t lr[8] PROGMEM ={0x78,0x44,0x78,0x44,0x44};
|
||||
const uint8_t ls[8] PROGMEM ={0x7c,0x40,0x7c,0x04,0x7c};
|
||||
const uint8_t lt[8] PROGMEM ={0x7c,0x10,0x10,0x10,0x10};
|
||||
const uint8_t lu[8] PROGMEM ={0x44,0x44,0x44,0x44,0x7c};
|
||||
const uint8_t lv[8] PROGMEM ={0x44,0x44,0x28,0x28,0x10};
|
||||
const uint8_t lw[8] PROGMEM ={0x44,0x44,0x54,0x54,0x28};
|
||||
const uint8_t lx[8] PROGMEM ={0x44,0x28,0x10,0x28,0x44};
|
||||
const uint8_t ly[8] PROGMEM ={0x44,0x44,0x28,0x10,0x10};
|
||||
const uint8_t lz[8] PROGMEM ={0x7c,0x08,0x10,0x20,0x7c};
|
||||
uint8_t la[8]={0x00,0x7c,0x44,0x44,0x7c,0x44,0x00,0x00};
|
||||
uint8_t lb[8]={0x00,0x7c,0x44,0x78,0x44,0x7c,0x00,0x00};
|
||||
uint8_t lc[8]={0x00,0x7c,0x40,0x40,0x40,0x7c,0x00,0x00};
|
||||
uint8_t ld[8]={0x00,0x78,0x44,0x44,0x44,0x78,0x00,0x00};
|
||||
uint8_t le[8]={0x00,0x7c,0x40,0x78,0x40,0x7c,0x00,0x00};
|
||||
uint8_t lf[8]={0x00,0x7c,0x40,0x70,0x40,0x40,0x00,0x00};
|
||||
uint8_t lg[8]={0x00,0x7c,0x40,0x4c,0x44,0x7c,0x00,0x00};
|
||||
uint8_t lh[8]={0x00,0x44,0x44,0x7c,0x44,0x44,0x00,0x00};
|
||||
uint8_t li[8]={0x00,0x7c,0x10,0x10,0x10,0x7c,0x00,0x00};
|
||||
uint8_t lj[8]={0x00,0x0c,0x04,0x04,0x44,0x7c,0x00,0x00};
|
||||
uint8_t lk[8]={0x00,0x44,0x48,0x70,0x48,0x44,0x00,0x00};
|
||||
uint8_t ll[8]={0x00,0x40,0x40,0x40,0x40,0x7c,0x00,0x00};
|
||||
uint8_t lm[8]={0x00,0x44,0x6c,0x54,0x44,0x44,0x00,0x00};
|
||||
uint8_t ln[8]={0x00,0x44,0x64,0x54,0x4c,0x44,0x00,0x00};
|
||||
uint8_t lo[8]={0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00};
|
||||
uint8_t lp[8]={0x00,0x78,0x44,0x78,0x40,0x40,0x00,0x00};
|
||||
uint8_t lq[8]={0x00,0x7c,0x44,0x44,0x7c,0x10,0x00,0x00};
|
||||
uint8_t lr[8]={0x00,0x78,0x44,0x78,0x44,0x44,0x00,0x00};
|
||||
uint8_t ls[8]={0x00,0x7c,0x40,0x7c,0x04,0x7c,0x00,0x00};
|
||||
uint8_t lt[8]={0x00,0x7c,0x10,0x10,0x10,0x10,0x00,0x00};
|
||||
uint8_t lu[8]={0x00,0x44,0x44,0x44,0x44,0x7c,0x00,0x00};
|
||||
uint8_t lv[8]={0x00,0x44,0x44,0x28,0x28,0x10,0x00,0x00};
|
||||
uint8_t lw[8]={0x00,0x44,0x44,0x54,0x54,0x28,0x00,0x00};
|
||||
uint8_t lx[8]={0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00};
|
||||
uint8_t ly[8]={0x00,0x44,0x44,0x28,0x10,0x10,0x00,0x00};
|
||||
uint8_t lz[8]={0x00,0x7c,0x08,0x10,0x20,0x7c,0x00,0x00};
|
||||
|
||||
//MEMSAVING
|
||||
const uint8_t nze[8] PROGMEM ={0x7c,0x4c,0x54,0x64,0x7c};
|
||||
const uint8_t non[8] PROGMEM ={0x10,0x30,0x10,0x10,0x38};
|
||||
const uint8_t ntw[8] PROGMEM ={0x78,0x04,0x38,0x40,0x7c};
|
||||
const uint8_t nth[8] PROGMEM ={0x7c,0x04,0x38,0x04,0x7c};
|
||||
const uint8_t nfo[8] PROGMEM ={0x40,0x40,0x50,0x7c,0x10};
|
||||
const uint8_t nfi[8] PROGMEM ={0x7c,0x40,0x78,0x04,0x78};
|
||||
const uint8_t nsi[8] PROGMEM ={0x7c,0x40,0x7c,0x44,0x7c};
|
||||
const uint8_t nse[8] PROGMEM ={0x7c,0x04,0x08,0x10,0x10};
|
||||
const uint8_t nei[8] PROGMEM ={0x7c,0x44,0x7c,0x44,0x7c};
|
||||
const uint8_t nni[8] PROGMEM ={0x7c,0x44,0x7c,0x04,0x7c};
|
||||
uint8_t nze[8]={0x00,0x7c,0x4c,0x54,0x64,0x7c,0x00,0x00};
|
||||
uint8_t non[8]={0x00,0x10,0x30,0x10,0x10,0x38,0x00,0x00};
|
||||
uint8_t ntw[8]={0x00,0x78,0x04,0x38,0x40,0x7c,0x00,0x00};
|
||||
uint8_t nth[8]={0x00,0x7c,0x04,0x38,0x04,0x7c,0x00,0x00};
|
||||
uint8_t nfo[8]={0x00,0x40,0x40,0x50,0x7c,0x10,0x00,0x00};
|
||||
uint8_t nfi[8]={0x00,0x7c,0x40,0x78,0x04,0x78,0x00,0x00};
|
||||
uint8_t nsi[8]={0x00,0x7c,0x40,0x7c,0x44,0x7c,0x00,0x00};
|
||||
uint8_t nse[8]={0x00,0x7c,0x04,0x08,0x10,0x10,0x00,0x00};
|
||||
uint8_t nei[8]={0x00,0x7c,0x44,0x7c,0x44,0x7c,0x00,0x00};
|
||||
uint8_t nni[8]={0x00,0x7c,0x44,0x7c,0x04,0x7c,0x00,0x00};
|
||||
|
||||
const uint8_t pqu[8] PROGMEM ={0x78,0x04,0x18,0x00,0x10};
|
||||
const uint8_t ppe[8] PROGMEM ={0x00,0x00,0x00,0x00,0x20};
|
||||
const uint8_t pco[8] PROGMEM ={0x00,0x00,0x00,0x20,0x20};
|
||||
const uint8_t pap[8] PROGMEM ={0x20,0x20,0x00,0x00,0x00};
|
||||
const uint8_t pqt[8] PROGMEM ={0x28,0x28,0x00,0x00,0x00};
|
||||
uint8_t pqu[8]={0x00,0x78,0x04,0x18,0x00,0x10,0x00,0x00};
|
||||
uint8_t ppe[8]={0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00};
|
||||
uint8_t pco[8]={0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00};
|
||||
uint8_t pap[8]={0x20,0x20,0x00,0x00,0x00,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);
|
||||
boolean serial_debug = false;
|
||||
String lineread;
|
||||
|
||||
char signbuffer[18];
|
||||
int signcursor = 0;
|
||||
|
||||
char output[5];
|
||||
|
||||
uint8_t a[1];
|
||||
|
@ -102,8 +106,11 @@ unsigned char security_passphrase_len;
|
|||
|
||||
|
||||
// IP Address for api.twitter.com
|
||||
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[] = {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;
|
||||
|
||||
|
@ -129,6 +136,8 @@ void setup() {
|
|||
|
||||
void loop(){
|
||||
|
||||
|
||||
|
||||
// Check if it's time to get an update
|
||||
if (millis() >= updateTime) {
|
||||
Serial.println("go!");
|
||||
|
@ -137,6 +146,13 @@ void loop(){
|
|||
// 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();
|
||||
|
@ -150,20 +166,18 @@ void load_message(char textmsg[18]) {
|
|||
// 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};
|
||||
|
||||
|
||||
uint8_t* message[18];
|
||||
|
||||
// convert message to led font
|
||||
for(int chr=0;chr<18;chr++){
|
||||
switch(textmsg[chr]) {
|
||||
case 'a':
|
||||
//message[chr] = la;
|
||||
memcpy_P(&(message[chr]), pgm_read_byte(&(la)), 1);
|
||||
message[chr] = la;
|
||||
break;
|
||||
case 'b':
|
||||
//message[chr] = lb;
|
||||
memcpy_P(&(message[chr]), pgm_read_byte(&(lb)), 1);
|
||||
message[chr] = lb;
|
||||
break;
|
||||
/*
|
||||
case 'c':
|
||||
message[chr] = lc;
|
||||
break;
|
||||
|
@ -236,7 +250,6 @@ void load_message(char textmsg[18]) {
|
|||
case 'z':
|
||||
message[chr] = lz;
|
||||
break;
|
||||
//MEMSAVING
|
||||
case '0':
|
||||
message[chr] = nze;
|
||||
break;
|
||||
|
@ -282,13 +295,15 @@ void load_message(char textmsg[18]) {
|
|||
case '"':
|
||||
message[chr] = pqt;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
message[chr] = pcl;
|
||||
break;
|
||||
case ' ':
|
||||
message[chr] = sp;
|
||||
break;
|
||||
default:
|
||||
message[chr] = sp;
|
||||
break;*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +316,7 @@ void load_message(char textmsg[18]) {
|
|||
// for each char in message:
|
||||
for(int chr=0;chr<18;chr++){
|
||||
// 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 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+27] = message[chr][3];
|
||||
i[ofst+36] = message[chr][4];
|
||||
//i[ofst+45] = message[chr][5];
|
||||
//i[ofst+54] = message[chr][6];
|
||||
//i[ofst+63] = message[chr][7];
|
||||
i[ofst+45] = message[chr][5];
|
||||
i[ofst+54] = message[chr][6];
|
||||
i[ofst+63] = message[chr][7];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ser_print(){
|
||||
while (mySerial.available()) {
|
||||
lineread = String(mySerial.read(),HEX);
|
||||
lineread.toCharArray(output,5);
|
||||
|
||||
}
|
||||
// while (mySerial.available()) {
|
||||
// lineread = String(mySerial.read(),HEX);
|
||||
// lineread.toCharArray(output,5);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -403,30 +417,36 @@ void setup_sign_protocol() {
|
|||
// Function to handle data from the server
|
||||
void processData(char* data, int len) {
|
||||
// Do stuff with the data here
|
||||
char buffer[18];
|
||||
|
||||
|
||||
for(int i=0;i<len;i++){
|
||||
if(data[i] == '"'
|
||||
&& data[i+1] == 't'
|
||||
&& data[i+2] == 'e'
|
||||
&& 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]};
|
||||
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++;
|
||||
|
||||
i=i+18;
|
||||
load_message(buffer);
|
||||
send_data();
|
||||
delay(2000);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user