Advertisement
arter97

Untitled

Jul 3rd, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 17.25 KB | None | 0 0
  1. // based on an orginal sketch by Arduino forum member "danigom"
  2. // http://forum.arduino.cc/index.php?action=profile;u=188950
  3.  
  4. #include <avr/pgmspace.h>
  5. #include <LedControl.h>
  6.  
  7. const int numDevices = 4;      // number of MAX7219s used
  8. const long scrollDelay = 50;   // adjust scrolling speed
  9.  
  10. unsigned long bufferLong [16] = {0};
  11.  
  12. LedControl lc = LedControl(5,7,6,numDevices);
  13.  
  14. const unsigned char scrollText[] PROGMEM ={
  15.     "a!Byfyrdse!/\0"};
  16.  
  17. void setup(){
  18.     for (int x=0; x<numDevices; x++){
  19.         lc.shutdown(x,false);       //The MAX72XX is in power-saving mode on startup
  20.         lc.setIntensity(x,1);       // Set the brightness to default value
  21.         lc.clearDisplay(x);         // and clear the display
  22.     }
  23. }
  24.  
  25. void loop(){
  26.     scrollMessage(scrollText);
  27.     // scrollFont();
  28. }
  29.  
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31.  
  32. int trim_matrix(const unsigned char* font) {
  33.     int i;
  34.     int j;
  35.     const unsigned char product = 1;
  36.     int ret = 0;
  37.     unsigned char temp;
  38.     for (i = 0; i < 8; i++) {
  39.         temp = font[i];
  40.         for (j = 0; j < 8; j++) {
  41.         if ((product & temp) == 1) {
  42.             if (ret < (8 - j)) { // 8-j == length
  43.                ret = 8 - j;
  44.             }
  45.             break;
  46.         }
  47.         temp = temp >> 1;
  48.         }
  49.     }
  50.  
  51.     return ret;
  52. }
  53.  
  54. const unsigned char font5x7[] PROGMEM = {      //Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
  55.     B00000000,  //Space (Char 0x20)
  56.     B00000000,
  57.     B00000000,
  58.     B00000000,
  59.     B00000000,
  60.     B00000000,
  61.     B00000000,
  62.     B00000000,
  63.  
  64.     B10000000,  //!
  65.     B10000000,
  66.     B10000000,
  67.     B10000000,
  68.     B00000000,
  69.     B00000000,
  70.     B10000000,
  71.     B00000000,
  72.  
  73.     B10100000,  //"
  74.     B10100000,
  75.     B10100000,
  76.     B00000000,
  77.     B00000000,
  78.     B00000000,
  79.     B00000000,
  80.     B00000000,
  81.  
  82.     B01010000,  //#
  83.     B01010000,
  84.     B11111000,
  85.     B01010000,
  86.     B11111000,
  87.     B01010000,
  88.     B01010000,
  89.     B00000000,
  90.  
  91.     B00100000,  //$
  92.     B01111000,
  93.     B10100000,
  94.     B01110000,
  95.     B00101000,
  96.     B11110000,
  97.     B00100000,
  98.     B00000000,
  99.  
  100.     B11000000,  //%
  101.     B11001000,
  102.     B00010000,
  103.     B00100000,
  104.     B01000000,
  105.     B10011000,
  106.     B00011000,
  107.     B00000000,
  108.  
  109.     B01100000,  //&
  110.     B10010000,
  111.     B10100000,
  112.     B01000000,
  113.     B10101000,
  114.     B10010000,
  115.     B01101000,
  116.     B00000000,
  117.  
  118.     B11000000,  //'
  119.     B01000000,
  120.     B10000000,
  121.     B00000000,
  122.     B00000000,
  123.     B00000000,
  124.     B00000000,
  125.     B00000000,
  126.  
  127.     B00100000,  //(
  128.     B01000000,
  129.     B10000000,
  130.     B10000000,
  131.     B10000000,
  132.     B01000000,
  133.     B00100000,
  134.     B00000000,
  135.  
  136.     B10000000,  //)
  137.     B01000000,
  138.     B00100000,
  139.     B00100000,
  140.     B00100000,
  141.     B01000000,
  142.     B10000000,
  143.     B00000000,
  144.  
  145.     B00000000,  //*
  146.     B00100000,
  147.     B10101000,
  148.     B01110000,
  149.     B10101000,
  150.     B00100000,
  151.     B00000000,
  152.     B00000000,
  153.  
  154.     B00000000,  //+
  155.     B00100000,
  156.     B00100000,
  157.     B11111000,
  158.     B00100000,
  159.     B00100000,
  160.     B00000000,
  161.     B00000000,
  162.  
  163.     B00000000,  //,
  164.     B00000000,
  165.     B00000000,
  166.     B00000000,
  167.     B11000000,
  168.     B01000000,
  169.     B10000000,
  170.     B00000000,
  171.  
  172.     B00000000,  //-
  173.     B00000000,
  174.     B11111000,
  175.     B00000000,
  176.     B00000000,
  177.     B00000000,
  178.     B00000000,
  179.     B00000000,
  180.  
  181.     B00000000,  //.
  182.     B00000000,
  183.     B00000000,
  184.     B00000000,
  185.     B00000000,
  186.     B11000000,
  187.     B11000000,
  188.     B00000000,
  189.  
  190.     B00000000,  ///
  191.     B00001000,
  192.     B00010000,
  193.     B00100000,
  194.     B01000000,
  195.     B10000000,
  196.     B00000000,
  197.     B00000000,
  198.  
  199.     B01110000,  //0
  200.     B10001000,
  201.     B10011000,
  202.     B10101000,
  203.     B11001000,
  204.     B10001000,
  205.     B01110000,
  206.     B00000000,
  207.  
  208.     B01000000,  //1
  209.     B11000000,
  210.     B01000000,
  211.     B01000000,
  212.     B01000000,
  213.     B01000000,
  214.     B11100000,
  215.     B00000000,
  216.  
  217.     B01110000,  //2
  218.     B10001000,
  219.     B00001000,
  220.     B00010000,
  221.     B00100000,
  222.     B01000000,
  223.     B11111000,
  224.     B00000000,
  225.  
  226.     B11111000,  //3
  227.     B00010000,
  228.     B00100000,
  229.     B00010000,
  230.     B00001000,
  231.     B10001000,
  232.     B01110000,
  233.     B00000000,
  234.  
  235.     B00010000,  //4
  236.     B00110000,
  237.     B01010000,
  238.     B10010000,
  239.     B11111000,
  240.     B00010000,
  241.     B00010000,
  242.     B00000000,
  243.  
  244.     B11111000,  //5
  245.     B10000000,
  246.     B11110000,
  247.     B00001000,
  248.     B00001000,
  249.     B10001000,
  250.     B01110000,
  251.     B00000000,
  252.  
  253.     B00110000,  //6
  254.     B01000000,
  255.     B10000000,
  256.     B11110000,
  257.     B10001000,
  258.     B10001000,
  259.     B01110000,
  260.     B00000000,
  261.  
  262.     B11111000,  //7
  263.     B10001000,
  264.     B00001000,
  265.     B00010000,
  266.     B00100000,
  267.     B00100000,
  268.     B00100000,
  269.     B00000000,
  270.  
  271.     B01110000,  //8
  272.     B10001000,
  273.     B10001000,
  274.     B01110000,
  275.     B10001000,
  276.     B10001000,
  277.     B01110000,
  278.     B00000000,
  279.  
  280.     B01110000,  //9
  281.     B10001000,
  282.     B10001000,
  283.     B01111000,
  284.     B00001000,
  285.     B00010000,
  286.     B01100000,
  287.     B00000000,
  288.  
  289.     B00000000,  //:
  290.     B11000000,
  291.     B11000000,
  292.     B00000000,
  293.     B11000000,
  294.     B11000000,
  295.     B00000000,
  296.     B00000000,
  297.  
  298.     B00000000,  //;
  299.     B11000000,
  300.     B11000000,
  301.     B00000000,
  302.     B11000000,
  303.     B01000000,
  304.     B10000000,
  305.     B00000000,
  306.  
  307.     B00010000,  //<
  308.     B00100000,
  309.     B01000000,
  310.     B10000000,
  311.     B01000000,
  312.     B00100000,
  313.     B00010000,
  314.     B00000000,
  315.  
  316.     B00000000,  //=
  317.     B00000000,
  318.     B11111000,
  319.     B00000000,
  320.     B11111000,
  321.     B00000000,
  322.     B00000000,
  323.     B00000000,
  324.  
  325.     B10000000,  //>
  326.     B01000000,
  327.     B00100000,
  328.     B00010000,
  329.     B00100000,
  330.     B01000000,
  331.     B10000000,
  332.     B00000000,
  333.  
  334.     B01110000,  //?
  335.     B10001000,
  336.     B00001000,
  337.     B00010000,
  338.     B00100000,
  339.     B00000000,
  340.     B00100000,
  341.     B00000000,
  342.  
  343.     B01110000,  //@
  344.     B10001000,
  345.     B00001000,
  346.     B01101000,
  347.     B10101000,
  348.     B10101000,
  349.     B01110000,
  350.     B00000000,
  351.    
  352.     B01110000,  //A
  353.     B10001000,
  354.     B10001000,
  355.     B10001000,
  356.     B11111000,
  357.     B10001000,
  358.     B10001000,
  359.     B00000000,
  360.  
  361.     B11110000,  //B
  362.     B10001000,
  363.     B10001000,
  364.     B11110000,
  365.     B10001000,
  366.     B10001000,
  367.     B11110000,
  368.     B00000000,
  369.  
  370.     B01110000,  //C
  371.     B10001000,
  372.     B10000000,
  373.     B10000000,
  374.     B10000000,
  375.     B10001000,
  376.     B01110000,
  377.     B00000000,
  378.  
  379.     B11100000,  //D
  380.     B10010000,
  381.     B10001000,
  382.     B10001000,
  383.     B10001000,
  384.     B10010000,
  385.     B11100000,
  386.     B00000000,
  387.  
  388.     B11111000,  //E
  389.     B10000000,
  390.     B10000000,
  391.     B11110000,
  392.     B10000000,
  393.     B10000000,
  394.     B11111000,
  395.     B00000000,
  396.  
  397.     B11111000,  //F
  398.     B10000000,
  399.     B10000000,
  400.     B11110000,
  401.     B10000000,
  402.     B10000000,
  403.     B10000000,
  404.     B00000000,
  405.  
  406.     B01110000,  //G
  407.     B10001000,
  408.     B10000000,
  409.     B10111000,
  410.     B10001000,
  411.     B10001000,
  412.     B01111000,
  413.     B00000000,
  414.  
  415.     B10001000,  //H
  416.     B10001000,
  417.     B10001000,
  418.     B11111000,
  419.     B10001000,
  420.     B10001000,
  421.     B10001000,
  422.     B00000000,
  423.  
  424.     B11100000,  //I
  425.     B01000000,
  426.     B01000000,
  427.     B01000000,
  428.     B01000000,
  429.     B01000000,
  430.     B11100000,
  431.     B00000000,
  432.  
  433.     B00111000,  //J
  434.     B00010000,
  435.     B00010000,
  436.     B00010000,
  437.     B00010000,
  438.     B10010000,
  439.     B01100000,
  440.     B00000000,
  441.  
  442.     B10001000,  //K
  443.     B10010000,
  444.     B10100000,
  445.     B11000000,
  446.     B10100000,
  447.     B10010000,
  448.     B10001000,
  449.     B00000000,
  450.  
  451.     B10000000,  //L
  452.     B10000000,
  453.     B10000000,
  454.     B10000000,
  455.     B10000000,
  456.     B10000000,
  457.     B11111000,
  458.     B00000000,
  459.  
  460.     B10001000,  //M
  461.     B11011000,
  462.     B10101000,
  463.     B10101000,
  464.     B10001000,
  465.     B10001000,
  466.     B10001000,
  467.     B00000000,
  468.  
  469.     B10001000,  //N
  470.     B10001000,
  471.     B11001000,
  472.     B10101000,
  473.     B10011000,
  474.     B10001000,
  475.     B10001000,
  476.     B00000000,
  477.  
  478.     B01110000,  //O
  479.     B10001000,
  480.     B10001000,
  481.     B10001000,
  482.     B10001000,
  483.     B10001000,
  484.     B01110000,
  485.     B00000000,
  486.  
  487.     B11110000,  //P
  488.     B10001000,
  489.     B10001000,
  490.     B11110000,
  491.     B10000000,
  492.     B10000000,
  493.     B10000000,
  494.     B00000000,
  495.  
  496.     B01110000,  //Q
  497.     B10001000,
  498.     B10001000,
  499.     B10001000,
  500.     B10101000,
  501.     B10010000,
  502.     B01101000,
  503.     B00000000,
  504.  
  505.     B11110000,  //R
  506.     B10001000,
  507.     B10001000,
  508.     B11110000,
  509.     B10100000,
  510.     B10010000,
  511.     B10001000,
  512.     B00000000,
  513.  
  514.     B01111000,  //S
  515.     B10000000,
  516.     B10000000,
  517.     B01110000,
  518.     B00001000,
  519.     B00001000,
  520.     B11110000,
  521.     B00000000,
  522.  
  523.     B11111000,  //T
  524.     B00100000,
  525.     B00100000,
  526.     B00100000,
  527.     B00100000,
  528.     B00100000,
  529.     B00100000,
  530.     B00000000,
  531.  
  532.     B10001000,  //U
  533.     B10001000,
  534.     B10001000,
  535.     B10001000,
  536.     B10001000,
  537.     B10001000,
  538.     B01110000,
  539.     B00000000,
  540.  
  541.     B10001000,  //V
  542.     B10001000,
  543.     B10001000,
  544.     B10001000,
  545.     B10001000,
  546.     B01010000,
  547.     B00100000,
  548.     B00000000,
  549.  
  550.     B10001000,  //W
  551.     B10001000,
  552.     B10001000,
  553.     B10101000,
  554.     B10101000,
  555.     B10101000,
  556.     B01010000,
  557.     B00000000,
  558.  
  559.     B10001000,  //X
  560.     B10001000,
  561.     B01010000,
  562.     B00100000,
  563.     B01010000,
  564.     B10001000,
  565.     B10001000,
  566.     B00000000,
  567.  
  568.     B10001000,  //Y
  569.     B10001000,
  570.     B10001000,
  571.     B01010000,
  572.     B00100000,
  573.     B00100000,
  574.     B00100000,
  575.     B00000000,
  576.  
  577.     B11111000,  //Z
  578.     B00001000,
  579.     B00010000,
  580.     B00100000,
  581.     B01000000,
  582.     B10000000,
  583.     B11111000,
  584.     B00000000,
  585.  
  586.     B11100000,  //[
  587.     B10000000,
  588.     B10000000,
  589.     B10000000,
  590.     B10000000,
  591.     B10000000,
  592.     B11100000,
  593.     B00000000,
  594.  
  595.     B00000000,  //(Backward Slash)
  596.     B10000000,
  597.     B01000000,
  598.     B00100000,
  599.     B00010000,
  600.     B00001000,
  601.     B00000000,
  602.     B00000000,
  603.  
  604.     B11100000,  //]
  605.     B00100000,
  606.     B00100000,
  607.     B00100000,
  608.     B00100000,
  609.     B00100000,
  610.     B11100000,
  611.     B00000000,
  612.  
  613.     B00100000,  //^
  614.     B01010000,
  615.     B10001000,
  616.     B00000000,
  617.     B00000000,
  618.     B00000000,
  619.     B00000000,
  620.     B00000000,
  621.  
  622.     B00000000,  //_
  623.     B00000000,
  624.     B00000000,
  625.     B00000000,
  626.     B00000000,
  627.     B00000000,
  628.     B11111000,
  629.     B00000000,
  630.  
  631.     B10000000,  //`
  632.     B01000000,
  633.     B00100000,
  634.     B00000000,
  635.     B00000000,
  636.     B00000000,
  637.     B00000000,
  638.     B00000000,
  639.  
  640.     B00000000,  //a
  641.     B00000000,
  642.     B01110000,
  643.     B00001000,
  644.     B01111000,
  645.     B10001000,
  646.     B01111000,
  647.     B00000000,
  648.  
  649.     B10000000,  //b
  650.     B10000000,
  651.     B10110000,
  652.     B11001000,
  653.     B10001000,
  654.     B10001000,
  655.     B11110000,
  656.     B00000000,
  657.  
  658.     B00000000,  //c
  659.     B00000000,
  660.     B01110000,
  661.     B10001000,
  662.     B10000000,
  663.     B10001000,
  664.     B01110000,
  665.     B00000000,
  666.  
  667.     B00001000,  //d
  668.     B00001000,
  669.     B01101000,
  670.     B10011000,
  671.     B10001000,
  672.     B10001000,
  673.     B01111000,
  674.     B00000000,
  675.  
  676.     B00000000,  //e
  677.     B00000000,
  678.     B01110000,
  679.     B10001000,
  680.     B11111000,
  681.     B10000000,
  682.     B01110000,
  683.     B00000000,
  684.  
  685.     B00110000,  //f
  686.     B01001000,
  687.     B01000000,
  688.     B11100000,
  689.     B01000000,
  690.     B01000000,
  691.     B01000000,
  692.     B00000000,
  693.  
  694.     B00000000,  //g
  695.     B01111000,
  696.     B10001000,
  697.     B10001000,
  698.     B01111000,
  699.     B00001000,
  700.     B01110000,
  701.     B00000000,
  702.  
  703.     B10000000,  //h
  704.     B10000000,
  705.     B10110000,
  706.     B11001000,
  707.     B10001000,
  708.     B10001000,
  709.     B10001000,
  710.     B00000000,
  711.  
  712.     B01000000,  //i
  713.     B00000000,
  714.     B11000000,
  715.     B01000000,
  716.     B01000000,
  717.     B01000000,
  718.     B11100000,
  719.     B00000000,
  720.  
  721.     B00010000,  //j
  722.     B00000000,
  723.     B00110000,
  724.     B00010000,
  725.     B00010000,
  726.     B10010000,
  727.     B01100000,
  728.     B00000000,
  729.  
  730.     B10000000,  //k
  731.     B10000000,
  732.     B10010000,
  733.     B10100000,
  734.     B11000000,
  735.     B10100000,
  736.     B10010000,
  737.     B00000000,
  738.  
  739.     B11000000,  //l
  740.     B01000000,
  741.     B01000000,
  742.     B01000000,
  743.     B01000000,
  744.     B01000000,
  745.     B11100000,
  746.     B00000000,
  747.  
  748.     B00000000,  //m
  749.     B00000000,
  750.     B11010000,
  751.     B10101000,
  752.     B10101000,
  753.     B10001000,
  754.     B10001000,
  755.     B00000000,
  756.  
  757.     B00000000,  //n
  758.     B00000000,
  759.     B10110000,
  760.     B11001000,
  761.     B10001000,
  762.     B10001000,
  763.     B10001000,
  764.     B00000000,
  765.  
  766.     B00000000,  //o
  767.     B00000000,
  768.     B01110000,
  769.     B10001000,
  770.     B10001000,
  771.     B10001000,
  772.     B01110000,
  773.     B00000000,
  774.  
  775.     B00000000,  //p
  776.     B00000000,
  777.     B11110000,
  778.     B10001000,
  779.     B11110000,
  780.     B10000000,
  781.     B10000000,
  782.     B00000000,
  783.  
  784.     B00000000,  //q
  785.     B00000000,
  786.     B01101000,
  787.     B10011000,
  788.     B01111000,
  789.     B00001000,
  790.     B00001000,
  791.     B00000000,
  792.  
  793.     B00000000,  //r
  794.     B00000000,
  795.     B10110000,
  796.     B11001000,
  797.     B10000000,
  798.     B10000000,
  799.     B10000000,
  800.     B00000000,
  801.  
  802.     B00000000,  //s
  803.     B00000000,
  804.     B01110000,
  805.     B10000000,
  806.     B01110000,
  807.     B00001000,
  808.     B11110000,
  809.     B00000000,
  810.  
  811.     B01000000,  //t
  812.     B01000000,
  813.     B11100000,
  814.     B01000000,
  815.     B01000000,
  816.     B01001000,
  817.     B00110000,
  818.     B00000000,
  819.  
  820.     B00000000,  //u
  821.     B00000000,
  822.     B10001000,
  823.     B10001000,
  824.     B10001000,
  825.     B10011000,
  826.     B01101000,
  827.     B00000000,
  828.  
  829.     B00000000,  //v
  830.     B00000000,
  831.     B10001000,
  832.     B10001000,
  833.     B10001000,
  834.     B01010000,
  835.     B00100000,
  836.     B00000000,
  837.  
  838.     B00000000,  //w
  839.     B00000000,
  840.     B10001000,
  841.     B10101000,
  842.     B10101000,
  843.     B10101000,
  844.     B01010000,
  845.     B00000000,
  846.  
  847.     B00000000,  //x
  848.     B00000000,
  849.     B10001000,
  850.     B01010000,
  851.     B00100000,
  852.     B01010000,
  853.     B10001000,
  854.     B00000000,
  855.  
  856.     B00000000,  //y
  857.     B00000000,
  858.     B10001000,
  859.     B10001000,
  860.     B01111000,
  861.     B00001000,
  862.     B01110000,
  863.     B00000000,
  864.  
  865.     B00000000,  //z
  866.     B00000000,
  867.     B11111000,
  868.     B00010000,
  869.     B00100000,
  870.     B01000000,
  871.     B11111000,
  872.     B00000000,
  873.  
  874.     B00100000,  //{
  875.     B01000000,
  876.     B01000000,
  877.     B10000000,
  878.     B01000000,
  879.     B01000000,
  880.     B00100000,
  881.     B00000000,
  882.  
  883.     B10000000,  //|
  884.     B10000000,
  885.     B10000000,
  886.     B10000000,
  887.     B10000000,
  888.     B10000000,
  889.     B10000000,
  890.     B00000000,
  891.  
  892.     B10000000,  //}
  893.     B01000000,
  894.     B01000000,
  895.     B00100000,
  896.     B01000000,
  897.     B01000000,
  898.     B10000000,
  899.     B00000000,
  900.  
  901.     B00000000,  //~
  902.     B00000000,
  903.     B00000000,
  904.     B01101000,
  905.     B10010000,
  906.     B00000000,
  907.     B00000000,
  908.     B00000000,
  909.  
  910.     B01100000,  // (Char 0x7F)
  911.     B10010000,
  912.     B10010000,
  913.     B01100000,
  914.     B00000000,
  915.     B00000000,
  916.     B00000000,
  917.     B00000000
  918. };
  919.  
  920. void scrollFont() {
  921.     for (int counter=0x20;counter<0x80;counter++){
  922.         loadBufferLong(counter);
  923.         delay(500);
  924.     }
  925. }
  926.  
  927. // Scroll Message
  928. void scrollMessage(const unsigned char * messageString) {
  929.     int counter = 0;
  930.     int myChar=0;
  931.     do {
  932.         // read back a char
  933.         myChar =  pgm_read_byte_near(messageString + counter);
  934.         if (myChar != 0){
  935.             loadBufferLong(myChar);
  936.         }
  937.         counter++;
  938.     }
  939.     while (myChar != 0);
  940. }
  941. // Load character into scroll buffer
  942. void loadBufferLong(int ascii){
  943.     if (ascii >= 0x20 && ascii <=0x7f){
  944.         for (int a=0;a<8;a++){                      // Loop 7 times for a 5x7 font
  945.             unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a);     // Index into character table to get row data
  946.             unsigned long x = bufferLong [a*2];     // Load current scroll buffer
  947.             x = x | c;                              // OR the new character onto end of current
  948.             bufferLong [a*2] = x;                   // Store in buffer
  949.         }
  950.         //byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 9) + 8);     // Index into character table for kerning data
  951.         int count = trim_matrix(font5x7 + ((ascii - 0x20) * 8));
  952.         //byte count = 6;
  953.         for (int x=0; x<count;x++){
  954.             rotateBufferLong();
  955.             printBufferLong();
  956.             delay(scrollDelay);
  957.         }
  958.     }
  959. }
  960. // Rotate the buffer
  961. void rotateBufferLong(){
  962.     for (int a=0;a<8;a++){                      // Loop 7 times for a 5x7 font
  963.         unsigned long x = bufferLong [a*2];     // Get low buffer entry
  964.         byte b = bitRead(x,31);                 // Copy high order bit that gets lost in rotation
  965.         x = x<<1;                               // Rotate left one bit
  966.         bufferLong [a*2] = x;                   // Store new low buffer
  967.         x = bufferLong [a*2+1];                 // Get high buffer entry
  968.         x = x<<1;                               // Rotate left one bit
  969.         bitWrite(x,0,b);                        // Store saved bit
  970.         bufferLong [a*2+1] = x;                 // Store new high buffer
  971.     }
  972. }  
  973. // Display Buffer on LED matrix
  974. void printBufferLong(){
  975.   for (int a=0;a<8;a++){                    // Loop 7 times for a 5x7 font
  976.     unsigned long x = bufferLong [a*2+1];   // Get high buffer entry
  977.     byte y = x;                             // Mask off first character
  978.     lc.setRow(3,a,y);                       // Send row to relevent MAX7219 chip
  979.     x = bufferLong [a*2];                   // Get low buffer entry
  980.     y = (x>>24);                            // Mask off second character
  981.     lc.setRow(2,a,y);                       // Send row to relevent MAX7219 chip
  982.     y = (x>>16);                            // Mask off third character
  983.     lc.setRow(1,a,y);                       // Send row to relevent MAX7219 chip
  984.     y = (x>>8);                             // Mask off forth character
  985.     lc.setRow(0,a,y);                       // Send row to relevent MAX7219 chip
  986.   }
  987. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement