SHARE
TWEET

Untitled

a guest Oct 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct blinkPattern {
  2.     unsigned char[6] out = {0};
  3.     unsigned char length;
  4.     } blinkPattern;
  5.    
  6. blinkPattern P1;
  7. blinkPattern P2;
  8. blinkPattern P3;
  9. blinkPattern P4;
  10.  
  11. P1.length = 2;
  12. P2.length = 2;
  13. P3.length = 8;
  14. P4.length = 5;
  15.  
  16. P1.out[0] = 0b11110000;
  17. P1.out[1] = 0b00001111;
  18.  
  19. P2.out[0] = 0b10101010;
  20. P2.out[1] = 0b01010101;
  21.  
  22. P3.out[0] = 0b10000000;
  23. P3.out[1] = 0b01000000;
  24. P3.out[2] = 0b00100000;
  25. P3.out[3] = 0b00010000;
  26. P3.out[4] = 0b00001000;
  27. P3.out[5] = 0b00000100;
  28. P3.out[6] = 0b00000010;
  29. P3.out[7] = 0b00000001;
  30.  
  31. P4.out[0] = 0b00011000;
  32. P4.out[1] = 0b00100100;
  33. P4.out[2] = 0b01000010;
  34. P4.out[3] = 0b10000001;
  35. P4.out[4] = 0b00000000;
  36.  
  37.  
  38.  
  39.  
  40.  
  41. unsigned char patternPeriod = 1;
  42. unsigned char patternOut_1 = 0x00;
  43. unsigned char patternOut_2 = 0x00;
  44. unsigned char patternOut_3 = 0x00;
  45. unsigned char patternOut_4 = 0x00;
  46.  
  47. unsigned char patternRequest = 0x00;
  48.  
  49.  
  50. enum SMState_Pattern_1 {
  51.     PatternLoop1
  52. };
  53. enum SMState_Pattern_2 {
  54.     PatternLoop2
  55. };
  56. enum SMState_Pattern_3 {
  57.     PatternLoop3
  58. };
  59. enum SMState_Pattern_4 {
  60.     PatternLoop4
  61. };
  62.  
  63.  
  64.  
  65. unsigned char encodePatternRequest(unsigned char keypadInput, unsigned char currentPatternRequest) {
  66.     switch keypadInput {
  67.         case 'A':
  68.             return (currentPatternRequest & 0x0F) | 0x10;
  69.             break;
  70.         case 'B':
  71.             return (currentPatternRequest & 0x0F) | 0x20;
  72.             break;
  73.         case 'C':
  74.             return (currentPatternRequest & 0x0F) | 0x30;
  75.             break;
  76.         case 'D':
  77.             return (currentPatternRequest & 0x0F) | 0x40;
  78.             break;
  79.  
  80.         case '1':
  81.             return (currentPatternRequest & 0x0F) | 0x01;
  82.             break;
  83.         case '2':
  84.             return (currentPatternRequest & 0x0F) | 0x02;
  85.             break;
  86.         case '3':
  87.             return (currentPatternRequest & 0x0F) | 0x03;
  88.             break;
  89.         case '4':
  90.             return (currentPatternRequest & 0x0F) | 0x04;
  91.             break;
  92.         case '5':
  93.             return (currentPatternRequest & 0x0F) | 0x05;
  94.             break;
  95.         case '6':
  96.             return (currentPatternRequest & 0x0F) | 0x06;
  97.             break;
  98.        
  99.  
  100.         default:
  101.             return 0;
  102.             break;
  103.     }
  104. }
  105.  
  106. int SMTick_pattern_1 (int state) {
  107.     static unsigned char patternIter; // Auto init to zero
  108.     patternIter = ++patternIter >=
  109.  
  110.     switch state {
  111.         case PatternLoop1:
  112.             patternOut_1
  113.     }
  114.  
  115.  
  116.  
  117.  
  118. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top