classicsat

Direct numeral entry

Mar 16th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. // 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)
  2.  
  3. // entrymode is set a 0 for 4 digit entry, 1 for 7 digit entry, in either case locations 0+ in that array
  4.  
  5. // the display is a dot matrix LED type, with a library that uses those commands, as well as the cursor, for I
  6. // don't think that display supports one, but my blinking cursor (*) works fine.
  7.  
  8. void directentry(byte entrymode){
  9. byte entryarray[7];// temporary array for numeral entry
  10.  
  11. myDisplay.clear();
  12. myDisplay.home();
  13.  
  14. byte arraysize[2]={4,7};// (mute=time entry 4 digits, mode=date entry 7 digits)
  15. byte array_pointer=0; // zero array pointer
  16.  
  17. while (array_pointer<arraysize[entrymode]){//open while, leave when array_pointer is above arraysize
  18. key=99; //no key received
  19. seccount=0;// timeout counter
  20.  
  21. while (key>90){//open while, leave when key received(below 90)
  22. key=IRrx();// receive key
  23. toggle=!toggle; //toggle for cursor
  24. myDisplay.write(32+(toggle*63)); // write cursor
  25. myDisplay.setCursor(array_pointer);// set position back
  26. seccount++;// increment timeout seconds counter
  27. if (seccount>100){// exit entry if too long.
  28. key=16;// force key to be 16 (EQ on my remote, see below a bit)
  29. }
  30. delay(250);// delay fine here. Slow enough for cursor blink
  31. }// close while key
  32.  
  33. if (key<10){// is numeral key, enter into array, display, increment array pointer
  34. entryarray[array_pointer]=key;
  35. myDisplay.print(key);
  36. array_pointer++;
  37. }
  38.  
  39. if (key==16){// EQ key/timeout, cancel entry
  40. array_pointer=arraysize[entrymode]+1;//make array_pointer big to exit while loop
  41. }
  42.  
  43. }// end while array_pointer loop
  44.  
  45. } // end routine
Advertisement
Add Comment
Please, Sign In to add comment