Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // IRrx() is a function that returns a byte 0 to 20, 0 to 9 for numeral keys, 10 to 20 for others, 16 being the key I am // using for cancel (Pause)
- // entrymode is set a 0 for 4 digit entry, 1 for 7 digit entry, in either case locations 0+ in that array
- // the display is a dot matrix LED type, with a library that uses those commands, as well as the cursor, for I
- // don't think that display supports one, but my blinking cursor (*) works fine.
- void directentry(byte entrymode){
- byte entryarray[7];// temporary array for numeral entry
- myDisplay.clear();
- myDisplay.home();
- byte arraysize[2]={4,7};// (mute=time entry 4 digits, mode=date entry 7 digits)
- byte array_pointer=0; // zero array pointer
- while (array_pointer<arraysize[entrymode]){//open while, leave when array_pointer is above arraysize
- key=99; //no key received
- seccount=0;// timeout counter
- while (key>90){//open while, leave when key received(below 90)
- key=IRrx();// receive key
- toggle=!toggle; //toggle for cursor
- myDisplay.write(32+(toggle*63)); // write cursor
- myDisplay.setCursor(array_pointer);// set position back
- seccount++;// increment timeout seconds counter
- if (seccount>100){// exit entry if too long.
- key=16;// force key to be 16 (EQ on my remote, see below a bit)
- }
- delay(250);// delay fine here. Slow enough for cursor blink
- }// close while key
- if (key<10){// is numeral key, enter into array, display, increment array pointer
- entryarray[array_pointer]=key;
- myDisplay.print(key);
- array_pointer++;
- }
- if (key==16){// EQ key/timeout, cancel entry
- array_pointer=arraysize[entrymode]+1;//make array_pointer big to exit while loop
- }
- }// end while array_pointer loop
- } // end routine
Advertisement
Add Comment
Please, Sign In to add comment