/* mem 1186 7/24/15 without wire<> default for 10 switches to A2 input steps to change to remote remote via wired A4-A5 1. line18 #include between pro-mini and A4-A5 2. line1090 in setup() 2 lines 'begin + recive' turn on only one readSW() 3. around line 1040 readSW() pick #1 block out #2 ~~~~~~~~~~~~~~~ see very bottom for instructions for different models */ // #include //uses mini pro for ir siginal directly into micro //////////////////////////////////////////////////////////////////////////// #include //use eeprom for user input #include #define ledWidth 56 //Q change for # of leds 56,64,72,80 common #define stillWidth 50 //Q change for width 65=13chr (chr*5) #define darkOne 1 //Q change for brightness low #define darkTwo 100 //Q change for brightness med #define darkThree 254 //Q change for brightness hi byte scrollSpeed = 20; //Q speed set #define defaultspeed 20 //Q speed set #define SWdelay 250 //Q sets switch delay + blinks screen /////////////////////////////////////////////////////////////////// //mmmmmmmmmmmmmmmmmmmmmm mod 5 and up ver8.1 and up pin-outs mmmmmmmmmmmmm #define clockPinrow 9 // row is single 595 to ground #define dataPinrow 10 #define latchrcPin 11 //latch row + col shared byte clockPin=12; #define coldataPin 13 #define keyclockPin 3 #define keylatchPin 4 #define keydataPin 2 #define britePwm 5 //pwm PIN led supply volt #define RTCclock 6 //rtc pins #define RTCdataIO 7 //rtc pins #define RTCrst 8 //rtc pins ///////// end mod 5 + up pin-outs //////////////// //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //mmmmmmmmmmmmmmm turn on/off irSig in readSW() for NO remote mmmmmmmmmmmmQ //mmmmmmmmmmmmmm mod 5+ key pad + in-line keys + remote mmmmmmmmmmmm #define SWmenu 192 // -10 ss +10 #define SWup 36 // x ? up x ? #define SWrt 72 // lf ent rt #define SWenter 40 // exit dn menu #define SWdn 160 // ------------------------- #define SWlf 24 // 18 34 66 #define SWexit 144 // 20 36 68 #define SWss 34 // 24 40 72 #define SW49 18 // -10 144 160 192 #define SW51 66 // +10 #define SWblnkl 20 // not used, need deff #define SWblnkr 68 // not used, need deff //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ////////////// end keypad selection ////////////////////// //// function loop switches //// byte whileMenu = 0; byte whileEdit = 0; byte whileUser = 0; byte newDay=1; //once daily update rtc (no need to update every rtc read byte edc; //used in seconds display int refreshTime=0; //for rtc refresh unsigned long timeOut=0; //60,000 = 1min (240,000 4min) 1k=1sec byte displayCount=0; int irSig = 0; //i2c line int bank1 = 1023; //analogread for in-line switches byte toporder=0; //up display mode byte bottomorder=0; //up display mode byte oldDstart=1; byte Dstart=0; //starts up with msg change (order++) byte Dline=0; //up display mode int Dcount=0; //count passes byte Dsubcount=0; //up display mode int Dcountto=400; //up display mode byte skip = 0; byte Mskip = 0; byte dark = 254; //pwm pin6 drives mosffet, brightness int eeInfo = 0; //eeprom info int d = 0; //eeprom write and read int dd = 1; //eeprom read to msg int x = 0; byte Five = 0; byte fiveShift = 0; byte col = 0; byte colShift = 0; byte blank = 0; //to blink cursor byte Speed = 0; //max count 256 int same = 0; int inXX = 0; // must go negetive int nextLetter = 0; //0-330+ byte allmessShift = 0; //0-7 byte messShift = 0; //0-7 byte oldStop = 0; int stopStart = 20; //set speed of scrolling 257 in pause //// array stored in program storage (32k) not in dynamic (2k) //// //// markers are 63,95,127 const int letter[] PROGMEM = {31,27,17,17,27, 31,16,11,11,16, //0-star, 5-A 31,0,10,10,17, 31,0,14,14,14, 31,0,14,14,17, //10-B, 15-C, 20-D 31,0,10,10,10, 31,0,11,11,11, 31,17,14,10,8, //25-E, 30-F, 35-G 31,0,27,27,0, 31,14,0,0,14, 31,28,30,30,0, //40-H, 45-I, 50-J 31,0,27,21,14, 31,0,30,30,30, 31,0,19,19,0, //55-K, 60-L, 65-M 31,0,23,27,0, 31,0,14,14,0, 31,0,11,11,3, //70-N, 75-O, 80-P 31,0,14,12,0, 31,0,11,11,20, 31,22,10,10,13, //85-Q, 90-R, 95-S 31,15,0,0,15, 31,01,30,30,1, 31,7,27,29,0, //100-T, 105-U, 110-V 31,1,24,24,1, 31,4,27,27,4, 31,7,24,24,7, //115-W, 120-X, 125-Y 31,12,10,10,6, //130-Z 31,17,14,14,17, 31,14,0,0,30, 31,8,10,10,22, //135-0, 140-1, 145-2 31,14,10,10,0, 31,3,27,27,0, 31,2,10,10,13, //150-3, 155-4, 160-5 31,16,10,10,12, 31,14,13,11,7, 31,17,10,10,17, //165-6, 170-7, 175-8 31,23,11,10,17, //180-9 31,0,95,31,31, // 185-vert line 63,30,26,30,30, 30,30,30,30,30, //190-eom, 195-underscore 31,15,23,27,29, 31,29,27,23,15, //200-\ slash L 205-/ slash R 31,15,15,95,31, 15,15,15,15,15, //210-quote 215-overscore 31,15,95,31,31, 31,25,25,25,31, //220-apost 225- = equ 2,10,0,10,8, 31,30,95,31,31, //230-doll 235-period pt 31,21,95,31,31, 31,27,27,95,31, //240-colen cln 245- - dsh 31,31,31,95,31, 31,15,8,11,3, //250-space 255-qus ? 31,2,95,31,31, 31,0,14,95,31, //260 xpl ! 265-left squ 31,31,14,0,31, 27,21,10,27,27, //270-rite squ 275-left arrow < 27,27,10,21,27, 27,23,0,23,27, //280-rite arrow 285-up arrow 27,29,0,29,27, 31,27,17,95,27, //290-down arrow 295-plus + 0,0,0,31,31, 31,31,0,0,0, //300-lite left 305-lite rite 3,3,3,3,3, 24,24,24,24,24, //310-lite up 315-lite down 0,0,0,0,0, 31,27,23,14,95, //320-lite all 325-% percent 31,21,21,95,31, 31,31,17,31,95, //330-pmrtc 335-sec1 31,29,27,23,95, 31,27,27,27,95, //340-sec2/ 345-sec3- 31,23,27,29,95, 31,21,95,31,31, //350-sec4\ 355-amrtc 31,30,28,24,16, 31,16,24,28,30, //360-rt triangle 365-lf tri 31,15,7,3,1, 31,1,3,7,15, //370-rtop tri 375-ltop tri 30,28,24,28,30, 15,7,3,7,15, //380-btm tri 385-top tri 31,31,31,95,31, }; ///390 space at end, allways change letterEnd #define letterEnd 390 //390 used for last access position of letter[] //in extensive patterns bump to higher limit. //need to change eemsgIn() to match #define st 0 //star * #define A 5 //letters are all caps #define B 10 //define uses NO memory #define C 15 #define D 20 #define E 25 #define F 30 #define G 35 #define H 40 #define I 45 #define J 50 #define K 55 #define L 60 #define M 65 #define N 70 #define O 75 #define P 80 #define Q 85 #define R 90 #define S 95 #define T 100 #define U 105 #define V 110 #define W 115 #define X 120 #define Y 125 #define Z 130 #define zer 135 #define one 140 #define two 145 #define thr 150 #define fou 155 #define fiv 160 #define six 165 #define sev 170 #define eig 175 #define nin 180 #define eom 190 //end of message ( MARKER starts with 63,30,26,30,30) #define und 195 //underscore _ #define slL 200 //slash left #define slR 205 //slash right / #define qt 210 //quote (either side) " #define ovr 215 //overscore ( MARKER must not change) #define pt 235 //peroid . #define cln 240 //colen : #define dsh 245 //dash - #define ss 250 //space ( MARKER must not change) #define qus 255 //question mark ? #define plu 295 //plus + #define pmrtc 330 //PM colen with dot #define amrtc 355 //AM colen only ////////////////////// clock setup and variables ///////////// #define Wmin 130 //register address #define Whour 132 //hour + am/pm + 12/24 //register 132=hour bit7 H = 12h, bit5 H = pm #define Wday 134 #define Wmonth 136 #define Wwday 138 #define Wyear 140 #define twelve24 128 //128=12h, 0=24h mode byte openReg = 128; //128,0 new rtc needs to be turned on byte writeData = 0; //run this to writeRTC() function //144,171 sets charger to 2diode+8k byte nowTmin=0; //0-5 byte nowmin=0; //0-9 00-59 byte nowThour=0; //0-1 byte nowhour=0; //0-9 1-12 byte nowAP=0; //0=am, am=blank 1=pm, pm=dot byte nowTday=0; //0-3 byte nowday=0; //0-9 1-31 byte nowTmonth=0; //0-1 byte nowmonth=0; //0-9 1-12 byte nowwday=0; //1-7 1=monday 7=sunday byte nowTyear=0; //0-9 byte nowyear=0; //0-9 00-99 byte conVert=0; byte x1=0; //display info byte x2=0; //clockSet() display info byte x3=0; //display info byte x4=0; //order unconvert byte xinfo=0; //global generic info byte poss=0; //possition of cursur byte dataBurst[64]; byte dataconvert[]={nowThour,nowhour,nowTmin,nowmin,nowTmonth, nowmonth,nowTday,nowday,nowTyear,nowyear }; byte dataorder[]={1,2,4,5,}; //from ttime[] byte dataorder2[]={1,2,4,5,9,10,}; //from ddate[] int ttime[]={ss,nowThour,nowhour,cln,nowTmin,nowmin,nowAP,F,R,I,ss,eom }; int ddate[]={ss,nowTmonth,nowmonth,slR,nowTday,nowday, slR,two,zer,nowTyear,nowyear,ss,eom }; int xorder=0; //goes negitave byte xxorder=0; byte order[]={0,1,2,3,4,5,6,7,8,9,}; //changes by 'set order' byte disp1[] = { M,S,G,ss,ss,ss,ss,ss,ss,ss, M,E,N,U,ss,S,E,T,U,P, //0-9 10-19 E,D,I,T,ss,M,S,G,ss,ss, S,E,T,ss,O,R,D,E,R,ss, //20-29 30-39 S,E,T,ss,B,R,I,G,H,T, E,R,A,S,E,ss,A,L,L,ss, //40-49 50-59 S,E,T,ss,M,I,N,U,T,E, S,E,T,ss,H,O,U,R,ss,ss, //60-69 70-79 S,E,T,ss,W,K,ss,D,A,Y, S,E,T,ss,M,O,N,T,H,ss, //80-89 90-99 S,E,T,ss,D,A,Y,ss,ss,ss, S,E,T,ss,Y,E,A,R,ss,ss, //100-109 110-119 S,E,T,ss,S,P,E,E,D,ss, S,E,T,ss,M,O,D,E,ss,ss, //120-129 130-139 ss,ss,E,M,P,T,Y,ss,ss,ss, }; //140-149 int disp1End=140; //sets end for skips through display int ms1[45]; int ms2[45]; int ms3[45]; int ms4[45]; int ms5[45]; int ms6[45]; int ms7[45]; int ms8[45]; int eSpace[]= { 0,46, 48,93, 95,140, 142,187, 189,234, 236,281, 283,328, 330,375, }; // ms1 ms2 ms3 ms4 ms5 ms6 ms7 ms8 byte allcenter[]={ 42, 54, 44, 44, 44, 44, 44, 44, 44, 44, }; int* allmess[] = {ttime,ddate,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8, }; //************************************************************** ////////////////////// FUNCTIONS ////////////////////////////** //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm void scanWritestill() { //need 'same' as start for x, else x=anything for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; digitalWrite(coldataPin, HIGH); digitalWrite(clockPin, LOW); digitalWrite(coldataPin, HIGH); digitalWrite(clockPin, HIGH); digitalWrite(coldataPin, LOW); digitalWrite(clockPin, LOW); } //col=0 end if (col>=stillWidth) { x=9; } //blank spaces to end of led digitalWrite(clockPin, LOW); digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(disp1[x]+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm void scanWrite1() { digitalWrite(coldataPin, HIGH); digitalWrite(clockPin, LOW); digitalWrite(coldataPin, HIGH); digitalWrite(clockPin, HIGH); digitalWrite(coldataPin, LOW); digitalWrite(clockPin, LOW); } //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm void scanWrite2() { digitalWrite(clockPin, LOW); digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); } //^^^^^^^^^^^^^^^^^^ end scan for led screen ^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //////// FORMATT EEPROM, ALL ZERO (star), AND INDEX MSG /////////////////// void eeformat() { for (int i=0; i<=400; i++) { EEPROM.write(i,0); } //filled 0-400 with zeros (star) EEPROM.write(2,one); EEPROM.write(9,eom); EEPROM.write(49,two); EEPROM.write(56,eom); EEPROM.write(96,thr); EEPROM.write(103,eom); //put msg number in each msg (spot) EEPROM.write(143,fou); EEPROM.write(150,eom); EEPROM.write(190,fiv); EEPROM.write(197,eom); EEPROM.write(237,six); EEPROM.write(244,eom); EEPROM.write(284,sev); EEPROM.write(291,eom); EEPROM.write(331,eig); EEPROM.write(338,eom); EEPROM.write(399,11); //marker for new ic to be filled, eemsgIn(); } //^^^^^^^^^^^ END OF EEPROM ERACE ^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ///////// eemsgIn() eeprom info to msg at startup ms1,ms2,ms3... ////////// /////// and saved paramaters, speed,order,mode // 399 marker for new ic to be filled with stars // 412 marker 400 to 410 spot for order[] // 414 marker 415 storage spot for speed, Speed= 0=100 // 416 marker 417 storage spot for mode, Mskip= 0-255 // 418 marker 419 storage spot for dark, dark= 0-255 // marker new is 0, turned on is 11 (eleven) void eemsgIn() { x=allmessShift; //just a screen save of last allmessShift allmessShift=2; //start on msg 1 d=0; dd=0; if (EEPROM.read(414)==11) { stopStart=EEPROM.read(415); } //scroll speed if (EEPROM.read(416)==11) { Mskip=EEPROM.read(417); } //display mode if (EEPROM.read(418)==11) { dark=EEPROM.read(419); } //brightness if (EEPROM.read(412)==11) { for (int i=400; i<=409; i++) //order[] { order[d]=EEPROM.read(i); d++; } } int eindex=0; int eeInfo=0; int dd=0; while (eindex <= 373) { eeInfo=EEPROM.read(eindex); switch(eeInfo) { case 0: eeInfo=0; break; //no case needed if 0 (zero) case 4: eeInfo=260; break; case 9: eeInfo=265; break; case 14: eeInfo=270; break; case 19: eeInfo=275; break; case 24: eeInfo=280; break; case 29: eeInfo=285; break; case 34: eeInfo=290; break; case 39: eeInfo=295; break; case 44: eeInfo=300; break; case 49: eeInfo=305; break; case 54: eeInfo=310; break; case 59: eeInfo=315; break; case 64: eeInfo=320; break; case 69: eeInfo=325; break; case 74: eeInfo=330; break; case 79: eeInfo=335; break; case 84: eeInfo=340; break; case 89: eeInfo=345; break; case 94: eeInfo=350; break; case 99: eeInfo=355; break; case 104: eeInfo=360; break; case 109: eeInfo=365; break; case 114: eeInfo=370; break; case 119: eeInfo=375; break; case 124: eeInfo=380; break; case 129: eeInfo=385; break; case 134: eeInfo=390; break; case 139: eeInfo=395; break; case 144: eeInfo=400; break; } allmess[allmessShift][dd] = eeInfo; dd++; eindex++; if (eindex==45) { allmessShift++; dd=0; eindex=47; } //reset for ms 2 if (eindex==92) { allmessShift++; dd=0; eindex=94; } //ms3 if (eindex==139) { allmessShift++; dd=0; eindex=141; } //ms4 if (eindex==186) { allmessShift++; dd=0; eindex=188; } //ms5 if (eindex==233) { allmessShift++; dd=0; eindex=235; } //ms6 if (eindex==280) { allmessShift++; dd=0; eindex=282; } //ms7 if (eindex==327) { allmessShift++; dd=0; eindex=329; } //ms8 } //end WHILE loop allmessShift=x; //now that msg full, exstract allcenter[] int goo=0; x=2; byte i=1; while(goo==0) { if(allmess[x][i]==eom) { allcenter[x]=(i*5)-2; x++; i=0; if (x==10) goo=1; } i++; } }//end eein // cheated. need to store full int (2 bytes) into eeprom 1 byte. // then remove 1 byte at a time and then combine into int inside msg. // // instead I store a byte. The 'letter[]' array only logs X5, 5,10,15,20... // so when storing a msg the byte is 5,10,15,20... // ex. 'happy'= 40,5,80,80,125 (all x5) // any byte over 255 is stored x-256 because the '0' is counted. // so storing 280 as a byte the computer stores 24 // having x5 in letter[] means that 24 will never be repeated // sence only x5 are valid. // // this is where I cheated and use case to match the letter[] index // to the stored byte. // speed is not important and this is a small database to store. // this keeps the memory half by using byte instead int. // // if > 255 case converts to byte up to 400. if 'chr set' goes past // 400 need to add more case. //^^^^^^^^^^^ end of eemsgIn ^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ///////// eeStore() STORE MSG TO EEPROM + AUTO eom /////// void eeStore() { allmess[allmessShift][inXX]=eom; //eom=63 (index spot 190 in letter[] ) d=(allmessShift*2)-4; dd=0; byte oneMore=0; byte ddd=0; if (d>=2) { ddd=1; } //file skips somewhere, stupid fix, eSpace[] 0-49 bad for (int i=eSpace[d]-ddd; i<=eSpace[d+1]; i++) { EEPROM.write(i,allmess[allmessShift][dd]); dd++; if (oneMore==1) { oneMore=0; break; } if (allmess[allmessShift][dd]==eom) { oneMore=1; } //count at eom } //1 more loop to write allcenter[allmessShift]=(dd-1)*5; //centers display in jump mode } //^^^^^^^^^^^ END OF eeStore ^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //////////// amPM() set am/pm, + 12/24 function ///////////////// void amPM() { xinfo=A; if (displayCount!=70) { return; } //not == (!=) while (whileMenu==1) { blank++; if(blank>=60) { blank=0; } if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); if (xinfo==A) { xinfo=0; } else xinfo=32; openReg=132; writeData=x1+x2+xinfo+twelve24; writeRTC(); whileMenu=0; } if (readSW()==SWup && xinfo==A) { delay(SWdelay); xinfo=P; } if (readSW()==SWup && xinfo==P) { delay(SWdelay); xinfo=A; } for (int col=0; col<=ledWidth; col++) { if (col==0) { x=ss; } if (col==5) { x=xinfo; } if (blank>=50 && col==5) { x=ss; } if (col==10) { x=M; } if (col==15 && xinfo==P) { x=pmrtc; } if (col==15 && xinfo==A) { x=amrtc; } if (col==20) { x=A; } if (col==25) { x=M; } if (col==30) { x=slR; } if (col==35) { x=P; } if (col==40) { x=M; } if (col>=45) { x=ss; } digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; scanWrite1(); } scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+x+Five)); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } } //^^^^^^^^^^^^^ end amPM() ^^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm /////////// clockSet() function ////////////////////// void clockSet() { whileMenu=1; timeOut=millis(); x1=zer; x2=zer; poss=1; blank=0; //starts clock openReg = 144; writeData=171; writeRTC(); //on batt charger 2diodes + 8k openReg = 128; writeData = 0; writeRTC(); //turns on clock crystal if (nowhour==zer && nowThour==zer) { openReg = 132; writeData = 177; writeRTC(); } //sets to 12h mode (0 for 24h) // 177=12h mode, pm, +32=PM, +128=12h mode, +16=10hr, 0-9, // 11:00 PM = 32+128+16+1=177 while (whileMenu==1) { blank++; if(blank>=60) { blank=0; } switch(displayCount) { case 60: openReg=130; break; //min case 70: openReg=132; break; //hour case 80: openReg=138; break; //week day case 90: openReg=136; break; //month case 100: openReg=134; break; //day case 110: openReg=140; break; //year } if (displayCount==70 || displayCount==90) { //hour 1-12 or month 1-12 poss=3; if (x1==zer && x2==zer) { x1=one; } //starts screen with '1' if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); if (displayCount==70) { newDay=1; unConvert(); amPM(); whileMenu=0; } if (displayCount==90) { newDay=1; unConvert(); writeData=x1+x2; writeRTC(); whileMenu=0; } } if (readSW()==SWup) { delay(SWdelay); x1+=5; if (x1==nin+5 && x2==zer) { x1=zer; x2=one; } if (x1==thr && x2==one) { x1=one; x2=zer; } } } if (displayCount==100) { //day 1-31 poss=3; if (x1==zer && x2==zer) { x1=one; } if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); newDay=1; unConvert(); writeData=x1+x2; writeRTC(); whileMenu=0; } if (readSW()==SWup) { delay(SWdelay); x1+=5; if (x1==nin+5 && x2==zer) { x1=zer; x2=one; } if (x1==nin+5 && x2==one) { x1=zer; x2=two; } if (x1==nin+5 && x2==two) { x1=zer; x2=thr; } if (x1==two && x2==thr) { x1=one; x2=zer; } } } if (displayCount==80) { //mon,tue,wed,thr,fri,sat,sun 1-7 if (x1==zer && x2==zer) { x1=one; } //starts screen with '1' x2=ss; poss=3; if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); newDay=1; unConvert(); writeData=x1; writeRTC(); whileMenu=0; } if (readSW()==SWup) { delay(SWdelay); x1+=5; if (x1==sev+5) { x1=one; } } if (readSW()==SWdn) { delay(SWdelay); x1-=5; if (x1==one-5) { x1=sev; } } } if (poss==1) { //right digit possition ox if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); newDay=1; unConvert(); writeData=x1+x2; writeRTC(); whileMenu=0; } if (readSW()==SWlf || readSW()==SWrt) { delay(SWdelay); poss=0; } if (readSW()==SWup) { delay(SWdelay); x1+=5; if (x1==nin+5) { x1=zer; } } if (readSW()==SWdn) { delay(SWdelay); x1-=5; if (x1==zer-5) { x1=nin; } } } if (poss==0) { //left digit possition xo if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWenter) { delay(SWdelay); newDay=1; unConvert(); writeData=x1+x2; writeRTC(); whileMenu=0; } if (readSW()==SWlf || readSW()==SWrt) { delay(SWdelay); poss=1; } if (readSW()==SWup) { delay(SWdelay); x2+=5; if (x2==fiv+5) { x2=zer; } } if (readSW()==SWdn) { delay(SWdelay); x2-=5; if (x2==zer-5) { x2=fiv; } } } for (int col=0; col<=ledWidth; col++) { if (col==0) { x=ss; } if (col==5) { x=x2; } if (blank>=50 && col==5 && poss==0) { x=ss; } if (col==10) { x=x1; } if (blank>=50 && col==10 && poss==1) { x=ss; } if (blank>=50 && col==10 && poss==3) {x=ss;} if (col==15) { x=ss; } if (col==20) { x=disp1[displayCount+4]; } if (col>=25) { x=disp1[displayCount+5]; } if (col>=30) { x=disp1[displayCount+6]; } if (col>=35) { x=disp1[displayCount+7]; } if (col>=40) { x=ss; } digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; scanWrite1(); } scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+x+Five)); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } } //^^^^^^^^^^^^^ end of clockSet() ^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ////////// convert to letter[] for led //////////////// void convertRTC() { if (nowAP==1) { ttime[3]=pmrtc; } //big colen =PM colen=AM else { ttime[3]=amrtc; } switch (nowwday) { case 1: ttime[7]=M; ttime[8]=O; ttime[9]=N; break; //mon case 2: ttime[7]=T; ttime[8]=U; ttime[9]=E; break; //tue case 3: ttime[7]=W; ttime[8]=E; ttime[9]=D; break; //wed case 4: ttime[7]=T; ttime[8]=H; ttime[9]=R; break; //thr case 5: ttime[7]=F; ttime[8]=R; ttime[9]=I; break; //fri case 6: ttime[7]=S; ttime[8]=A; ttime[9]=T; break; //sat case 7: ttime[7]=S; ttime[8]=U; ttime[9]=N; break; } //end switch for (byte gg=0; gg<=9; gg++) { conVert=dataconvert[gg]; switch (conVert) { case 0: conVert=135; break; //0 case 1: conVert=140; break; //1 case 2: conVert=145; break; //2 case 3: conVert=150; break; //3 case 4: conVert=155; break; //4 case 5: conVert=160; break; //5 case 6: conVert=165; break; //6 case 7: conVert=170; break; //7 case 8: conVert=175; break; //8 case 9: conVert=180; break; } //9 end switch if (gg<=3) { ttime[dataorder[gg]]=conVert; } else ddate[dataorder2[gg-4]]=conVert; } if (ttime[1]==135) { ttime[1]=ss; } //removes '0' 04:22= 4:22 if (ddate[1]==135) { ddate[1]=ss; } //removes '0' 06/16= 6/16/2015 } //^^^^^^^^^^^^^^ end convertRTC() ^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ////////// unConvert() letter[] back to dec ///////// void unConvert() { switch (x1) { case 135: x1=0; break; case 140: x1=1; break; case 145: x1=2; break; case 150: x1=3; break; case 155: x1=4; break; case 160: x1=5; break; case 165: x1=6; break; case 170: x1=7; break; case 175: x1=8; break; case 180: x1=9; break; } //end switch x1 switch (x2) { case 135: x2=0; break; case 140: x2=16; break; case 145: x2=32; break; case 150: x2=48; break; case 155: x2=64; break; case 160: x2=80; break; //higest numb 5 ex 57 min, no60 case 165: x2=96; break; case 170: x2=112; break; case 175: x2=128; break; case 180: x2=144; break; } //end switch x2 } //end unconvert //^^^^^^^^^^^^^^^ end unConvert ^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //////////////// write to RTC //////////////////// void writeRTC() { pinMode(RTCdataIO,OUTPUT); // transmitt to rtc digitalWrite(RTCrst,HIGH); delayMicroseconds( 4); //new, turn on 128/0 digitalWrite(RTCclock,LOW); delayMicroseconds( 1); //130-min, 132-hour, 134-day shiftOut(RTCdataIO,RTCclock,LSBFIRST,openReg); //byte or registers to open digitalWrite(RTCclock,LOW); delayMicroseconds( 1); //136-month,138-w day,140-year shiftOut(RTCdataIO,RTCclock,LSBFIRST,writeData); //byte to write delayMicroseconds( 1); // hour #7 bit =1 to stay in 12/not 24 digitalWrite(RTCrst,LOW); } //^^^^^^^^^^^^^^^ end writeRTC ^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ////////////// readRTC() //////////// void readRTC() { pinMode(RTCdataIO,OUTPUT); // transmitt to rtc digitalWrite(RTCrst,HIGH); delayMicroseconds( 4); digitalWrite(RTCclock,LOW); delayMicroseconds( 1); shiftOut(RTCdataIO,RTCclock,LSBFIRST,0XBF); //BF hex for burst mode digitalWrite(RTCclock,LOW); delayMicroseconds( 1); pinMode(RTCdataIO,INPUT); byte fullread; if (newDay==1) fullread=55; else fullread=20; for( byte i = 0; i <= fullread; i++) { //0-55 (56) burst dataBurst[i]=digitalRead(RTCdataIO); // bit info inside databurst array ////65 if (i>=8 && i<=11) { bitWrite(dataconvert[3], i-8, dataBurst[i]); } //nowmin if (i>=12 && i<=14) { bitWrite(dataconvert[2], i-12, dataBurst[i]); } //nowTmin if (i>=16 && i<=19) {bitWrite(dataconvert[1], i-16, dataBurst[i]); } //hour if (i==20) {bitWrite(dataconvert[0], 0, dataBurst[i]); } //nowThour if (newDay==1) { if (i==21) {bitWrite(nowAP, 0, dataBurst[i]); } //am=0, pm=1 if (i>=24 && i<=27) {bitWrite(dataconvert[7], i-24, dataBurst[i]); } //day if (i>=28 && i<=30) {bitWrite(dataconvert[6], i-28, dataBurst[i]); } //Tday if (i>=32 && i<=35) {bitWrite(dataconvert[5], i-32, dataBurst[i]); } //month if (i==36) {bitWrite(dataconvert[4], 0, dataBurst[i]); } //Tmonth if (i>=40 && i<=43) {bitWrite(nowwday, i-40, dataBurst[i]); } //monday=1 if (i>=48 && i<=51) {bitWrite(dataconvert[9], i-48, dataBurst[i]); } //year if (i>=52 && i<=55) {bitWrite(dataconvert[8], i-52, dataBurst[i]); } //Tyear } digitalWrite( RTCclock, HIGH); delayMicroseconds( 1); digitalWrite( RTCclock, LOW); delayMicroseconds( 1); } digitalWrite(RTCrst, LOW); newDay=0; } //^^^^^^^^^^^^^^^^^^ end readRTC ^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm /////////// set order /////////////////////////// void whileorder() { byte order2[]={T,D,one,two,thr,fou,fiv,six,sev,eig,S,ss, //0-11, x = changes T,D,one,two,thr,fou,fiv,six,sev,eig,S, }; //same = 12-22 x=0; timeOut=millis(); whileMenu=1; //x=index in order2[] dd=0; blank=0; same=12; //same=var name called from index of order2[] //dd=cursor left or right place while (whileMenu==1) { blank++; if (blank>=60) { blank=0; } if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWup) { delay(SWdelay); same++; if (dd==0 && same==22 || same>=23) { same=12; } } //no stop fst coll if (readSW()==SWdn) { delay(SWdelay); same--; if (dd==0 && same==11) { same=21; } if (dd!=0 && same<=11) { same=22; } } //letter dwn if (readSW()==SWlf) { delay(SWdelay); dd--; blank=0; if (dd<0) { dd=9; } } //display left if (readSW()==SWrt) { delay(SWdelay); dd++; blank=0; if (dd>=10) { dd=0; } } //display rite if (readSW()==SWenter) { delay(SWdelay); order2[dd]=order2[same]; dd++; blank=0; if (dd>=10) { dd=0; } } if (readSW()==SWmenu) { delay(550); for (int i=0; i<=9; i++) { x4=order2[i]; switch (x4) { case 100: x4=0; break; //T=0 in allmess[] time case 20: x4=1; break; //D=1 in allmess[] date case 140: x4=2; break; //msg 1 case 145: x4=3; break; //msg 2 case 150: x4=4; break; //3 case 155: x4=5; break; //4 case 160: x4=6; break; //5 case 165: x4=7; break; //6 case 170: x4=8; break; //7 case 175: x4=9; break; } // 8 end switch x4 order[i]=x4; EEPROM.write(400+i,x4); } //end for EEPROM.write(412,11); //stored marker switch was 0 now 11 xorder=0; whileMenu=0; } //END MENU for (int col=0; col<=ledWidth; col++) { if (col==0) { x=0; } if (col==5) { x=1; } if (col==10) { x=2; } //this sets up screen display if (col==15) { x=3; } if (col==20) { x=4; } if (col==25) { x=5; } //x is the index position inside order2 array if (col==30) { x=6; } if (col==35) { x=7; } if (col==40) { x=8; } if (col==45) { x=9; } if (col>=50) { x=11; } //blanks remaining screen. if (col==((dd*5)) && blank>=50) { x=11; } //creates blinking cursor if (col==((dd*5)) && blank<=50 ) { x=same; } digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; scanWrite1(); } scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(order2[x]+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; } //x++ } } } //^^^^^^^^^^^^^^^^^ end whileorder ^^^^^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //////////////// whilebright() /////////////////////////// void whilebright() { whileMenu=1; timeOut=millis(); byte anything=one; while (whileMenu==1) { analogWrite(britePwm, dark); if (readSW()==SWexit || readSW()==SWenter || timeOut+240000<=millis()) { whileMenu=0; EEPROM.write(418,11); EEPROM.write(419,dark); } if (readSW()==SWup) { delay(300); skip++; if (skip>=3) skip=0; } if (skip==0) { dark=darkOne; anything=L; } if (skip==1) { dark=darkTwo; anything=M; } if (skip==2) { dark=darkThree; anything=H; } x=0; byte disp1[]={ss,B,R,I,G,H,T,ss,anything,ss}; for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; scanWrite1(); } if (col>=stillWidth) { x=0; } //blank spaces to end of led scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(disp1[x]+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } } //^^^^^^^^^^^^^^^^^^^^^^ end whilebright() ^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm /////////// dMode function display mode set ///////////////////// void dMode() { whileMenu=1; timeOut=millis(); Mskip=0; while (whileMenu==1) { if (readSW()==SWexit || readSW()==SWenter || timeOut+240000<=millis()) { whileMenu=0; } //will finish while loop if (readSW()==SWup) { delay(300); Mskip++; stopStart=20; if (Mskip>=3) Mskip=0; } if (readSW()==SWenter && Mskip>=1) { delay(2000); } if (Mskip==0) { x1=L; x2=F; x3=T; } if (Mskip==1) { x1=U; x2=slR; x3=D; } if (Mskip==2) { x1=J; x2=M; x3=P; } x=0; byte disp1[]={ss,x1,x2,x3,ss,S,C,R,L,ss,ss, }; for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; scanWrite1(); } if (col>=stillWidth) { x=0; } //blank spaces to end of led scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(disp1[x]+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } EEPROM.write(416,11); EEPROM.write(417,Mskip); } ///////////// end dMode function ///////// //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm /////////// userMenu function keys on displayCount x 10 ///////////// void userMenu() { while (whileMenu==1) { dark=darkThree; analogWrite(britePwm, dark); x=displayCount; //use disp1[] array scanWritestill(); if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; break; } if (readSW()==SWup) { delay(SWdelay); displayCount+=10; if (displayCount>disp1End) { displayCount=20; } } if (readSW()==SWdn) { delay(SWdelay); displayCount-=10; if (displayCount<20) { displayCount=disp1End; } } if (readSW()==SWenter && displayCount==20) { delay(SWdelay); whileMenu=0; whileEdit=1; allmessShift=2; } //msg edit if (readSW()==SWenter && displayCount==30) //order edit function { delay(SWdelay); whileMenu=0; whileorder(); fiveShift=0; colShift=0;} if (readSW()==SWenter && displayCount==40) { delay(SWdelay); whileMenu=0; whilebright(); } if (readSW()==SWenter && displayCount==50) { delay(SWdelay); whileMenu=0; eeformat(); } //erace all msg function if (readSW()==SWenter && (displayCount>=60 && displayCount<=110)) { delay(SWdelay); whileMenu=0; clockSet(); } //set clock if (readSW()==SWenter && displayCount==120) { delay(SWdelay); whileMenu=0; speedSet(); stopStart=scrollSpeed; } if (readSW()==SWenter && displayCount==130) { delay(SWdelay); whileMenu=0; dMode(); } //set display mode, left-up-blink if (readSW()==SWenter && displayCount==140) { delay(SWdelay); whileMenu=0; myScreen(); fiveShift=0; colShift=0; } } ///////////////////// USER EDIT SELECT MSG NUMBER TO EDIT /////////////////// while (whileEdit==1) { if (readSW()==SWexit || timeOut+240000<=millis()) { eemsgIn(); whileEdit=0; break; } if (readSW()==SWenter) { delay(SWdelay); whileEdit=0; whileUser=1; } if (readSW()==SWup) { delay(SWdelay); allmessShift++; x=0; colShift=0; if (allmessShift>=10) { allmessShift=2; } } //Q CFM * if (readSW()==SWdn) { delay(SWdelay); allmessShift--; x=0; colShift=0; if (allmessShift<=1) { allmessShift=9; } } //Q CFM * x=0; switch (allmessShift) { case 2: disp1[4]=one; break; case 3: disp1[4]=two; break; case 4: disp1[4]=thr; break; case 5: disp1[4]=fou; break; case 6: disp1[4]=fiv; break; case 7: disp1[4]=six; break; case 8: disp1[4]=sev; break; case 9: disp1[4]=eig; break; } if (x>=7) { x=0; } //makes screen 7 chr wide scanWritestill(); } ///////////////////////// USER INPUT LETTERS ///////////////////// //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm same=5; //starts with A in cursor while (whileUser==1) { if (readSW()==SWup) { same+=5; delay(SWdelay); //in SW letter up if (same==eom) { same+=5; } //skips eom key if (same==letterEnd+5) { same=0; } } if (readSW()==SWdn) { same-=5; delay(SWdelay); //in SW letter dwn if (same==eom) { same-=5; } //skips eom key if (same<0) { same=letterEnd; } } if (readSW()==SWss) { delay(SWdelay); same=letterEnd; } //to letter[] last place if (readSW()==SW49) { delay(SWdelay); same-=50; if (same<0) { same=letterEnd; } } if (readSW()==SW51) { delay(SWdelay); same+=50; if (same>letterEnd) { same=0; } } if (readSW()==SWlf && inXX<=43) { delay(SWdelay); inXX++; } //shift left <45 if (readSW()==SWrt) { delay(SWdelay); inXX-- ; if (inXX<=0) { inXX=0; }} if (readSW()==SWenter) { delay(SWdelay); allmess[allmessShift][inXX]=same; inXX++; if (inXX>=45) { inXX--; } } //no edit past 45 if (readSW()==SWmenu) { delay(SWdelay); eeStore(); eemsgIn(); whileUser=0; } if (readSW()==SWexit || timeOut+240000<=millis()) { eemsgIn(); whileUser=0; } for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { Five=0; nextLetter=ss; scanWrite1(); } scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(nextLetter+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; } if (col==1 && inXX>4) { Five=0; nextLetter=allmess[allmessShift][-5+inXX]; } if (col==6 && inXX>3) { Five=0; nextLetter=allmess[allmessShift][-4+inXX]; } if (col==11 && inXX>2) { Five=0; nextLetter= allmess[allmessShift][-3+inXX]; } if (col==16 && inXX>1) { Five=0; nextLetter= allmess[allmessShift][-2+inXX]; } if (col==21 && inXX>0) { Five=0; nextLetter= allmess[allmessShift][-1+inXX]; } if (col==26) { blank++; Five=0; nextLetter=same; } if (col==26 && blank>=65) { if (blank>=70) { blank=0; }; Five=0; nextLetter=und; } if (col==31) { Five=0; nextLetter=allmess[allmessShift][1+inXX]; } if (col==36) { Five=0; nextLetter=allmess[allmessShift][2+inXX]; } if (col==41) { Five=0; nextLetter=allmess[allmessShift][3+inXX]; } if (col>=46) { Five=0; nextLetter=allmess[allmessShift][4+inXX]; } if (col>=51) { Five=0; nextLetter=allmess[allmessShift][5+inXX]; } } } same=0; Five=0; inXX=0; //reset } //^^^^^^^^^^^^ END OF INPUT LETTERS ^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //////////////// speedSet() scroll speed //////// void speedSet() { whileMenu=1; timeOut=millis(); x2=two; x1=zer; scrollSpeed=20; while (whileMenu==1) { if (readSW()==SWexit || timeOut+240000<=millis()) { scrollSpeed=defaultspeed; whileMenu=0; } if (readSW()==SWenter) { whileMenu=0; EEPROM.write(414,11); EEPROM.write(415,scrollSpeed); } if (readSW()==SWup) { delay(SWdelay); scrollSpeed++; x1+=5; } if (readSW()==SWdn) { delay(SWdelay); scrollSpeed--; x1-=5; } if (scrollSpeed>0 && scrollSpeed<10) { x2=zer; } if (scrollSpeed>9 && scrollSpeed<20) { x2=one; } if (scrollSpeed>19 && scrollSpeed<30) { x2=two; } if (scrollSpeed>29 && scrollSpeed<40) { x2=thr; } if (scrollSpeed>=40) { scrollSpeed=1; x2=zer; x1=one;} if (scrollSpeed<=0) { scrollSpeed=39; x2=thr; x1=nin;} if (x1>nin) { x1=zer; } if (x1=stillWidth) { x=0; } //blank spaces to end of led scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+(disp1[x]+Five))); digitalWrite(latchrcPin, HIGH); Five++; if (Five==5) { Five=0; x++; } } } } //^^^^^^^^^^^^^^^^ end speedSet() ^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm /////////// myScreen() user created screens ////// void myScreen() { whileMenu=1; timeOut=millis(); fiveShift=0; colShift=0; x=0; Five=0; nextLetter=0; } /* while (whileMenu==1) { if (readSW()==SWexit || timeOut+240000<=millis()) { whileMenu=0; } if (readSW()==SWss && stopStart<100) { delay(SWdelay); stopStart=32000; } if (readSW()==SWss && stopStart>100) { delay(SWdelay); stopStart=scrollSpeed; } if (readSW()==SWlf) { delay(150); colShift++; } if (readSW()==SWrt) { delay(150); colShift--; } for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { Speed++; Five=fiveShift; x=colShift; nextLetter= pgm_read_word_near(help+colShift)+fiveShift; scanWrite1(); } scanWrite2(); shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+nextLetter)); digitalWrite(latchrcPin, HIGH); //latch both row and col Five++; nextLetter++; if (Five==5) { Five=0; x++; nextLetter= pgm_read_word_near(help+x); } if (col==0 && pgm_read_word_near(letter+nextLetter)==63) { x=0; nextLetter=pgm_read_word_near(help+x); colShift=-0; fiveShift=0; xorder++; } //eol reset if (pgm_read_word_near(letter+nextLetter)==63) { x=0; nextLetter=pgm_read_word_near(help+x); } //eom reset if (Speed==stopStart) { Speed=0; fiveShift++; // (27)scroll speed if (fiveShift>=5) { fiveShift=0; colShift++; } } } } } */ //^^^^^^^^^^^^^ end myScreen() ^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ////////////////// readSW() 1 of 2 kinds pick only ONE /////////////// ////////////////////// begin switches # 1 /////////////////////////////////// /////(1) readsw with ir remote by data link (A4 A5) //// ---- turn off-on receiveEvent() under setup + #include wire // byte readSW(void) { byte data; data=irSig; timeOut=millis(); return(data); } // void receiveEvent(int nothing) { irSig = Wire.read(); } //////////////////////// end switches # 1 ///////////////////////////////// //****************************************************************************** ////(2) readsw for analog switches (if 8sw add 2 resistors to =10sw) ///////// ////////////////////// begin switches # 2 ////////////////////////////////////// // /* byte readSW(void) { byte data; data=0; bank1 = analogRead(A2); if (bank1>=960) { data=0; return(data); } //no sw pushed else { delayMicroseconds(50); bank1=analogRead(A2); } // Serial.println(bank1); switch(bank1) { //5v usb case 0 ... 10: data=144; break; //exit 0-5 case 110 ... 135: data=192; break; //menu 118-122 case 217 ... 245: data=34; break; //pau-ss 228-229 case 320 ... 350: data=40; break; //enter 334-335 case 422 ... 450: data=160; break; //down 434-436 case 520 ... 550: data=36; break; //up 534-535 case 615 ... 650: data=24; break; //left 631-630 case 710 ... 745: data=72; break; //rite 728-725 case 805 ... 840: data=18; break; //-10 825-821 case 900 ... 940: data=66; break; //+10 924-917 } timeOut=millis(); bank1=1023; return(data); } // */ /////////// end switches # 2 ////////////////// //////////////////////////////////////////////////////////////// //**************************************************************** /////////////// END readSW() ///////////////////// //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //^^^^^^^^^^^^^^^ END of FUNCTIONS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH //...................................................................... //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void setup() { ///////////////////// runs one time only ///////// // Serial.begin(9600); // Serial.println(irSig); ///// ---- turn off-on for ir remote --- next 2 lines // Wire.begin(4); //I2C Bus as Slave,Device4, mini pro,ir remote // Wire.onReceive(receiveEvent); // register event ////// ---- end ir remote on-off if (EEPROM.read(399)!=11) { eeformat(); } //empty new micro gets loaded eemsgIn(); //loads msg from stored in eeprom analogWrite(britePwm, dark); //darkens screen pwm always on pinMode(britePwm, OUTPUT); //LED transistor bias pinMode(latchrcPin, OUTPUT); //shared latch row + coll pinMode(clockPin, OUTPUT); pinMode(coldataPin, OUTPUT); // columns pinMode(clockPinrow, OUTPUT); pinMode(dataPinrow, OUTPUT); // rows pinMode(RTCclock,OUTPUT); pinMode(RTCdataIO,OUTPUT); pinMode(RTCrst,OUTPUT); digitalWrite(RTCclock,LOW); digitalWrite(RTCdataIO,LOW); digitalWrite(RTCrst,LOW); pinMode(keylatchPin, OUTPUT); pinMode(keyclockPin, OUTPUT); pinMode(keydataPin, INPUT); digitalWrite(keylatchPin, LOW); //dosent care digitalWrite(keyclockPin, LOW); //dosent care just for reset } //end setup //^^^^^^^^^^^^^^ END of setup ^^^^^^^^^^^^^^^^ //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm //zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz //uuuuuuuuuuuuuuuuuuuuuuuuUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU //HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH void loop() { //call temperature to another mini, direct spi to NRF too slow // delay(11); //test for ping, causes flashing refreshTime++; //about 1.2sec refresh rtc if(refreshTime>=120) { refreshTime=0; readRTC(); convertRTC(); edc=0; ttime[6]=335; if (ttime[2]==two && ttime[4]==zer && ttime[5]==zer) { newDay=1; } } if(refreshTime==30 || refreshTime==60 || refreshTime==90 ) { edc+=5; ttime[6]=335+edc; } //spinn clock display // Serial.println(readSW()); // delay(200); ////////////////// SIX button enter for functions //////////// ///////// ss,rt,lf,up,dn,menu //////////// switch(readSW()) { case 0: break; //no switch pushed no need to continu to read case case SWss: delay(SWdelay); //pause or space or up/down if (Mskip==0) { //normal scroll mode if (stopStart<32) { oldStop=stopStart; stopStart=257; } //byte stopstart never> 256 else { stopStart=oldStop; } } //normal display pause //next else=screen in u/d mode if (Mskip==1) { delay(SWdelay); Dstart++; if (Dstart==2) { oldDstart=1; } else { oldDstart=2; Dstart=1; } } //pause = display rolls up or down break; case SWrt: delay(150); scrollSpeed+=2; ////slower if (scrollSpeed>=30) { scrollSpeed=29; } stopStart=scrollSpeed; EEPROM.write(414,11); EEPROM.write(415,stopStart); break; case SWlf: delay(150); scrollSpeed-=2; ////faster if (scrollSpeed<=3) { scrollSpeed=3; } stopStart=scrollSpeed; EEPROM.write(414,11); EEPROM.write(415,stopStart); break; case SWup: delay(SWdelay); xorder++; if (order[xorder]==S || xorder>9) { xorder=0; } x=0; colShift=0; fiveShift=0; allmessShift=order[xorder]; break; case SWdn: delay(SWdelay); xorder--; if (xorder<0) { xorder=9; } //xorder goes '-' must be 'int' if (order[xorder]==S) { xorder--; } x=0; colShift=0; fiveShift=0; allmessShift=order[xorder]; break; case SW49: if (Mskip==1) { delay(SWdelay); Dcountto+=200; //scroll speed in up mode if(Dcountto>=1851) { Dcountto=1850; } } break; case SW51: if (Mskip==1) { delay(SWdelay); Dcountto-=200; if(Dcountto<=0) { Dcountto=50; } } break; case SWmenu: displayCount=10; whileMenu=1; userMenu(); break; } //end readsw() //////////// end readSW() function //////////////////// ////////////////// LED DISPLAY SCREEN /////////////////// //// left scroll mode skip=0 normal mode //////////////////////////// if (Mskip==0) { //col= zero this section, made 'for col loop' shorter Speed++; nextLetter=allmess[allmessShift][colShift]+fiveShift; if (pgm_read_word_near(letter+nextLetter)==95 ) { fiveShift=0; colShift++; nextLetter=allmess[allmessShift][colShift]+fiveShift; } //95 marker for space <5 if ( pgm_read_word_near(letter+nextLetter)==63) { fiveShift=0; colShift=0; xorder++; if (order[xorder]==S || xorder>9) { xorder=0; } allmessShift=order[xorder]; nextLetter=allmess[allmessShift][colShift]+fiveShift; } //eol end of line reset Five=fiveShift; x=colShift; xxorder=xorder; messShift=allmessShift; //sends out first pulse, 'for loop' pushes pulse to end digitalWrite(latchrcPin, LOW); PORTB=B00110000; // dat+clock hi delayMicroseconds(5); PORTB=B00000000; // dat+clock low for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col>0) { PORTB=B00010000; delayMicroseconds(5); PORTB=B00000000; } shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+nextLetter)); PORTB=B00001000; //latch both row and col Five++; nextLetter++; //Five=counter nextLetter++=fiveShift if (Five>=5) { Five=0; x++; nextLetter=allmess[messShift][x]; } //makes 5 to end x++=colShift if (pgm_read_word_near(letter+nextLetter)==95 ) //95 marker for adjusting width <5 { Five=0; x++; nextLetter=allmess[messShift][x]; } if (pgm_read_word_near(letter+nextLetter)==63) { x=0; Five=0; xxorder++; if (order[xxorder]==S || xxorder>9) { xxorder=0; } messShift=order[xxorder]; nextLetter=allmess[messShift][x]; } //eom if (Speed==stopStart) { Speed=0; fiveShift++; if (fiveShift>=5) { fiveShift=0; colShift++; } } } //col loop end } //Mskip=0 left scroll end ///////// display up scroll mode ////////////// // mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ///// //pause = try for up then down, movement if (Mskip==1) { byte bsl=0; byte bsr=0; byte bsup=0; byte eolBlank=0; for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if (col==0) { nextLetter=allmess[allmessShift][colShift]+fiveShift; Speed++; eolBlank=0; Five=fiveShift; x=colShift; xxorder=xorder; messShift=allmessShift; digitalWrite(coldataPin, HIGH); digitalWrite(clockPin, HIGH); digitalWrite(coldataPin, LOW); digitalWrite(clockPin, LOW); } //col=0 end else { digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); } switch (Dline) { case 0: //normal scan in center shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+nextLetter)); break; case 1: //bit shift right shiftOut(dataPinrow, clockPinrow, LSBFIRST, (pgm_read_word_near(letter+nextLetter)>>bsr)+bsup); break; case 2: //bit shift left shiftOut(dataPinrow, clockPinrow, LSBFIRST, (pgm_read_word_near(letter+nextLetter)<=(ledWidth-allcenter[allmessShift])/2.5) { Five++; nextLetter++; } //center if (Five>=5) { Five=0; x++; nextLetter=allmess[messShift][x]; } //makes 5 to end if (pgm_read_word_near(letter+nextLetter)==95 ) //95 marker for adjusting width <5 { Five=0; x++; nextLetter=allmess[messShift][x]; } if (pgm_read_word_near(letter+nextLetter)==63) { eolBlank=1; } //switches eolBlank on if (eolBlank==1) { nextLetter=ss; } //if eom(63) blanks(ss) remainder of screen if (Dstart==0) { //normal display msg change if ( Speed==stopStart*8 ) { Speed=0; bottomorder=xorder; xorder++; Dstart=oldDstart; if (order[xorder]==S || xorder>9) { xorder=0; } x=0; colShift=0; fiveShift=0; allmessShift=order[xorder]; toporder=xorder; } } //end dstart=0 if (Dstart==1) { oldDstart=1; Dcount++; if (Dcount>=Dcountto) { Dcount=0; Dsubcount++; } switch (Dsubcount) { case 0: Dline=1; bsr=1; bsup=16; allmessShift=order[bottomorder]; break; case 1: Dline=1; bsr=2; bsup=24; allmessShift=order[bottomorder]; break; case 2: Dline=1; bsr=3; bsup=28; allmessShift=order[bottomorder]; break; case 3: Dline=2; bsl=4; bsup=15; allmessShift=order[toporder]; break; case 4: Dline=2; bsl=3; bsup=7; allmessShift=order[toporder]; break; case 5: Dline=2; bsl=2; bsup=3; allmessShift=order[toporder]; break; case 6: Dline=2; bsl=1; bsup=1; allmessShift=order[toporder]; break; case 7: Dline=0; Dstart=0; Dcount=0; Speed=0; Dsubcount=0; allmessShift=order[toporder]; break; } //end switch } //end dstart = 1 if (Dstart==2) { oldDstart=2; Dcount++; if (Dcount>=Dcountto) { Dcount=0; Dsubcount++; } switch (Dsubcount) { case 0: Dline=2; bsl=1; bsup=1; allmessShift=order[bottomorder]; break; case 1: Dline=2; bsl=2; bsup=3; allmessShift=order[bottomorder]; break; case 2: Dline=2; bsl=3; bsup=7; allmessShift=order[bottomorder]; break; case 3: Dline=1; bsr=4; bsup=30; allmessShift=order[toporder]; break; case 4: Dline=1; bsr=3; bsup=28; allmessShift=order[toporder]; break; case 5: Dline=1; bsr=2; bsup=24; allmessShift=order[toporder]; break; case 6: Dline=1; bsr=1; bsup=16; allmessShift=order[toporder]; break; case 7: Dline=0; Dstart=0; Dcount=0; Speed=0; Dsubcount=0; allmessShift=order[toporder]; break; } //end switch } //end dstart = 2 } //for col end } //Mskip=1 up scroll mode end ///////// display jump scroll mode ////////////// // mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm ///// if (Mskip==2) { byte eolBlank=0; for (int col=0; col<=ledWidth; col++) { digitalWrite(latchrcPin, LOW); if(col==ledWidth) Speed++; //shift at end of display if (col==0) { nextLetter=allmess[allmessShift][colShift]+fiveShift; Five=fiveShift; x=colShift; xxorder=xorder; messShift=allmessShift; PORTB=B00110000; delayMicroseconds(5); PORTB=B00000000; //pulse out } //col=0 end else{ PORTB=B00010000; delayMicroseconds(5); PORTB=B00000000; } shiftOut(dataPinrow, clockPinrow, LSBFIRST, pgm_read_word_near(letter+nextLetter)); PORTB=B00001000; //latch both row and col if (col>=(ledWidth-allcenter[allmessShift])/2.5) { Five++; nextLetter++; } //center if (Five>=5) { Five=0; x++; nextLetter=allmess[messShift][x]; } //makes 5 to end if (pgm_read_word_near(letter+nextLetter)==95 ) //95 marker for adjusting width <5 { Five=0; x++; nextLetter=allmess[messShift][x]; } if (pgm_read_word_near(letter+nextLetter)==63) { eolBlank=1; } //switches eolBlank on if (eolBlank==1) { nextLetter=ss; } //eol(63) blanks(ss) remainder of screen if ( Speed==stopStart*10 ) { Speed=0; xorder++; if (order[xorder]==S || xorder>9) { xorder=0; } x=0; colShift=0; fiveShift=0; allmessShift=order[xorder]; } } //for col end } //Mskip=2 end } //void loop end THE END END END END /* block out sections for: pin-outs --------- two types: mod 1 and mod 5+ use mod 5 switches/remotes/keypad: keypad or in-line switches ------- three types in-line,early key,5+ keypad readSW() --- has some changes depending on three type of input switches. uses analog or digital cd4014, and input direct from pro mini ir siginals. mini uses 'irSig' as reading variable. this one line is in readSW(). Ir siginals can happen any time, if in a loop the siginals wont read. I use a seperate mini with Ir code loop. I got the code off line. Then connect the two micros and have them talk. I got the cheep remotes from china and paid about 3-4 dollars in a combined order. I first tried shiftout to a cd4014 then read the 4014 on the other mini. this works very well and saves #include wire. (about 2k) all my latest modles use 10 switches + 10 1k resistors. I have a pull-up resistor on pin A2 51k. anything around 40-80k is good but you will have to 'serial monitor' the new window values for each switch. The 'EMPTY' was a help screen but it didnt help so I am working on a user screen and graphic creation. i forget what this next section is for bitshift for my display= >>1 +16 <<1 +1 >>2 +24 <<2 +3 >>3 +28 <<3 +7 >>4 +30 <<4 +15 my 5 line display, next numbers off screen (dont care) (pgm_read_word_near(letter+nextLetter)>>2) +24 ); */