Aliexpressなどで販売されている64x32のフルカラードットマトリクスLED2枚とNucleo F401REを利用して、 E233系の駅停車時、路線名表示ありのLED側面行先表示を再現するプログラムです。 3秒間隔、3段階切替で、路線名、種別、行先、次停車駅を個別に指定することが可能です。

Dependencies:   SDFileSystem mbed

Committer:
chirashi
Date:
Tue Nov 11 09:56:45 2014 +0000
Revision:
9:ab87b0e361aa
Parent:
8:9d22c9910917
Child:
10:4d9cf202a845
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RRacer 0:1f58ecec51d6 1 /*
RRacer 0:1f58ecec51d6 2 The goal of this program is to show the basic connections and workings of Adafruits 32x16 RGB LED matrix board (http://www.adafruit.com/products/420),
RRacer 0:1f58ecec51d6 3 also sold on other places, for instance http://www.ebay.com/itm/PH6-RGB-Full-Color-LED-16-32-Dot-Matrix-Display-Module-/310303408628?pt=LH_DefaultDomain_0&hash=item483f8641f4 (no
RRacer 0:1f58ecec51d6 4 affiliation with either of them).
RRacer 0:1f58ecec51d6 5 This program is not intended to be highly optimized or a guideline in C programming in any way (more of the opposite actually).
RRacer 1:dd0dcd303d6d 6 To have more than 7 colors on this thing, you need to implement software PWM of some sort. I have obviously not done that, but if YOU do, please let me know!
RRacer 1:dd0dcd303d6d 7 Adafruit have a wicked demo program for an arduino - www.youtube.com/watch?v=lY-flFEfsHo
RRacer 0:1f58ecec51d6 8 There are probably lots of ways to make this perform better, perhaps by using Neal Hormans port of the Adafruit_GFX library (http://mbed.org/users/nkhorman/code/Adafruit_GFX/).
RRacer 0:1f58ecec51d6 9 No error checking or out-of-bounds checking is done. Use at your own peril.
RRacer 0:1f58ecec51d6 10 For more detailed information on the driver chip, see http://www.bjtopspace.com/ziliao/CYT62726.pdf
RRacer 0:1f58ecec51d6 11 Although the chips on my board says jx15020, I've been informed that they are equvivalent to the CYT62726, and so far it's a match.
RRacer 0:1f58ecec51d6 12 Feel free to use all or parts of this work.
RRacer 0:1f58ecec51d6 13 If you choose to do so, I would appreciate a small mentioning in the scrolling opening credits ;)
RRacer 0:1f58ecec51d6 14
RRacer 0:1f58ecec51d6 15 Best regards,
RRacer 0:1f58ecec51d6 16 Hugo Harming
RRacer 0:1f58ecec51d6 17 upgraded@hotmail.com
RRacer 0:1f58ecec51d6 18 */
RRacer 0:1f58ecec51d6 19
RRacer 0:1f58ecec51d6 20 #include "mbed.h"
RRacer 0:1f58ecec51d6 21 #define LOW 0
RRacer 0:1f58ecec51d6 22 #define HIGH 1
RRacer 0:1f58ecec51d6 23
chirashi 6:e6cb4a476422 24 #define R_Debug1 0
chirashi 6:e6cb4a476422 25 #define R_Debug2 0
chirashi 6:e6cb4a476422 26 #define R_Debug3 0
chirashi 6:e6cb4a476422 27 #define R_Debug4 0
chirashi 6:e6cb4a476422 28
chirashi 6:e6cb4a476422 29 #define G_Debug1 0
chirashi 6:e6cb4a476422 30 #define G_Debug2 0
chirashi 6:e6cb4a476422 31 #define G_Debug3 0
chirashi 6:e6cb4a476422 32 #define G_Debug4 0
chirashi 6:e6cb4a476422 33
chirashi 6:e6cb4a476422 34 #define B_Debug1 0
chirashi 6:e6cb4a476422 35 #define B_Debug2 0
chirashi 6:e6cb4a476422 36 #define B_Debug3 0
chirashi 6:e6cb4a476422 37 #define B_Debug4 0
chirashi 6:e6cb4a476422 38
chirashi 6:e6cb4a476422 39
chirashi 9:ab87b0e361aa 40 #define LED_Width 64
chirashi 9:ab87b0e361aa 41 #define LED_Height 8
chirashi 6:e6cb4a476422 42
chirashi 9:ab87b0e361aa 43 BusOut ABC(D8,D9,D10,D14); // Row address.
chirashi 2:c1a9a2a0885d 44 DigitalOut CLK(D11); // Data clock - rising edge
chirashi 2:c1a9a2a0885d 45 DigitalOut LAT(D12); // Data latch - active low (pulse up after data load)
chirashi 2:c1a9a2a0885d 46 DigitalOut OE(D13); // Output enable - active low (hold high during data load, bring low after LAT pulse)
chirashi 2:c1a9a2a0885d 47 DigitalOut R1(D2); // RED Serial in for upper half
chirashi 2:c1a9a2a0885d 48 DigitalOut R2(D3); // RED Serial in for lower half
chirashi 2:c1a9a2a0885d 49 DigitalOut G1(D4); // GREEN Serial in for upper half
chirashi 2:c1a9a2a0885d 50 DigitalOut G2(D5); // GREEN Serial in for lower half
chirashi 2:c1a9a2a0885d 51 DigitalOut B1(D6); // BLUE Serial in for upper half
chirashi 2:c1a9a2a0885d 52 DigitalOut B2(D7); // BLUE Serial in for lower half
RRacer 0:1f58ecec51d6 53
chirashi 8:9d22c9910917 54 Ticker ChangeTimer;
chirashi 8:9d22c9910917 55 int ChangeCount = 0;
chirashi 8:9d22c9910917 56
RRacer 0:1f58ecec51d6 57 unsigned char gm[32][6]; // Buffer with 32x6 bytes. Graphics memory if you like.
RRacer 0:1f58ecec51d6 58 unsigned long CT; // Counter for demo code
RRacer 0:1f58ecec51d6 59
chirashi 7:79dfe71beb88 60 int LEDBuffer [32][128] = {
chirashi 9:ab87b0e361aa 61 {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 62 {10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 63 {10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 64 {10,10,10,10,10,10,0,0,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,10,10,0,10,10,10,10,0,0,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 65 {10,10,10,10,0,0,0,0,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,10,10,0,0,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 66 {10,10,0,0,0,0,10,10,0,0,10,0,0,10,10,10,10,10,10,10,10,10,10,0,0,10,10,0,10,10,10,10,0,0,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,0,0,0,10,10,10,0,0,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 67 {10,10,10,10,10,10,10,10,10,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,10,10,0,0,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,0,0,0,10,10,10,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,0,0,10,10,10,0,0,10,10,10,0,0,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 68 {10,10,10,10,10,10,10,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,0,0,10,10,0,10,10,10,10,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,0,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 69 {10,10,10,10,0,0,0,0,0,10,10,0,0,0,0,0,10,10,10,10,10,10,10,0,0,10,10,0,10,10,10,10,0,0,10,0,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,0,0,10,10,10,0,0,10,10,10,0,0,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 70 {10,10,0,0,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,10,10,10,10,0,0,0,0,0,0,0,0,10,0,0,10,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 71 {10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,10,0,0,10,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,0,0,10,0,0,0,0,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 72 {10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,0,10,0,10,0,10,0,0,10,10,0,0,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 73 {10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,0,10,0,10,0,10,0,10,0,10,0,0,10,10,0,0,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,7,7,7,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 74 {10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,0,10,0,10,0,10,0,10,0,10,0,0,10,10,10,0,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,7,7,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 75 {10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10,10,10,0,10,0,10,10,10,10,10,0,10,0,10,10,10,10,0,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,7,7,7,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 76 {10,10,10,10,10,0,0,10,10,10,10,10,10,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,10,0,10,10,10,10,10,10,0,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
chirashi 9:ab87b0e361aa 77
chirashi 8:9d22c9910917 78 };
chirashi 6:e6cb4a476422 79
chirashi 8:9d22c9910917 80 int LEDBuffer2[32][128] = {
chirashi 9:ab87b0e361aa 81 {8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,7,7,0,0,0,8,8,8,8,8,8,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,8,8,8,8,8,8,8,0,0,0,0,0,7,7,0,0,0,0,7,7,0,0,0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0}
chirashi 8:9d22c9910917 97
chirashi 8:9d22c9910917 98
chirashi 8:9d22c9910917 99 };
chirashi 8:9d22c9910917 100
chirashi 8:9d22c9910917 101 int LEDBuffer3[32][128] = {
chirashi 9:ab87b0e361aa 102 {11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,7,7,0,0,0,0,0,7,7,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 103 {11,11,11,11,0,11,11,11,0,11,0,11,11,11,11,11,11,11,11,0,11,11,11,11,11,11,0,0,11,11,11,11,11,11,11,0,11,11,11,11,11,0,11,11,11,11,11,11,0,0,0,0,0,0,0,7,7,0,0,7,7,0,7,7,11,11,11,11,11,11,11,0,11,11,11,11,11,11,0,0,0,0,0,11,0,0,0,0,11,11,11,11,11,11,11,11,0,11,11,11,11,11,11,11,11,0,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 104 {11,11,11,0,7,0,11,0,7,0,7,0,11,11,11,11,11,11,0,7,0,11,0,0,0,0,7,7,0,11,11,11,11,11,0,7,0,11,11,0,0,7,0,0,11,11,11,11,0,0,0,0,0,0,0,7,7,0,0,7,7,7,0,7,11,11,11,11,11,11,0,7,0,0,0,11,11,0,7,7,7,7,7,0,7,7,7,7,0,11,11,0,7,0,0,0,7,0,0,0,11,0,0,0,0,7,0,0,0,0,11,11,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 105 {11,11,0,0,7,0,11,7,7,7,7,7,0,11,11,11,11,11,11,0,7,0,7,7,7,7,0,0,11,11,11,11,11,0,7,0,0,11,0,7,7,7,7,7,0,11,11,11,0,0,0,0,0,0,0,7,7,0,0,0,7,7,0,7,11,11,11,11,11,0,7,7,7,7,7,0,11,0,7,0,7,0,0,0,7,0,0,7,0,11,11,0,7,7,7,7,7,7,7,7,0,7,7,7,7,7,7,7,7,7,0,11,0,0,4,0,0,0,0,0,4,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 106 {11,0,7,7,7,7,0,0,7,0,7,0,0,11,11,11,11,11,0,11,0,0,7,0,0,0,0,0,0,11,11,11,0,7,0,0,7,0,0,7,0,0,0,7,0,11,11,11,0,0,0,0,0,7,7,7,7,7,7,0,7,7,0,7,11,11,11,11,0,7,0,0,0,7,0,11,11,0,7,7,7,7,7,0,7,0,0,7,0,11,11,0,7,0,0,0,0,0,0,0,11,0,0,0,0,7,0,0,0,0,11,11,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0},
chirashi 9:ab87b0e361aa 107 {11,11,0,0,7,0,7,7,7,7,7,7,7,0,11,11,11,0,7,0,11,0,7,7,7,7,7,7,7,0,11,11,11,0,7,0,7,0,0,7,7,7,7,7,0,11,11,11,0,0,0,0,0,7,7,7,7,7,7,0,0,0,7,7,11,11,0,0,7,7,0,0,7,0,11,11,11,0,7,0,7,0,0,0,7,0,0,7,0,11,0,7,0,0,7,7,7,7,7,0,11,0,7,7,7,7,7,7,7,0,11,11,0,0,0,0,4,0,0,0,4,4,4,4,4,4,4,0},
chirashi 9:ab87b0e361aa 108 {11,11,0,7,7,0,0,0,0,7,0,0,0,11,11,11,11,11,0,7,0,0,7,0,0,0,7,0,0,11,11,11,11,11,0,7,0,0,0,7,0,0,0,7,0,11,11,11,0,0,0,0,0,0,0,7,7,0,0,0,0,0,7,7,11,0,7,7,0,0,7,7,0,11,11,11,11,0,7,7,7,7,7,0,7,0,0,7,0,11,0,7,0,0,7,0,0,0,7,0,11,0,7,0,0,7,0,0,7,0,11,11,0,0,0,0,0,0,0,4,0,0,4,0,0,0,4,0},
chirashi 9:ab87b0e361aa 109 {11,11,0,7,7,7,0,7,7,7,7,7,0,11,11,11,11,11,11,0,11,0,7,0,11,0,7,0,11,11,11,11,11,0,7,0,0,7,0,7,7,7,7,7,0,11,11,11,0,0,0,0,0,0,7,7,7,7,0,7,7,7,7,7,11,11,0,0,0,0,7,0,7,0,0,11,11,0,7,0,7,0,0,0,7,7,7,7,0,0,7,7,0,0,7,7,7,7,7,0,11,0,7,7,7,7,7,7,7,0,11,11,0,0,0,0,0,0,0,4,0,0,4,0,0,4,0,0},
chirashi 9:ab87b0e361aa 110 {11,0,7,0,7,0,0,7,0,7,0,7,0,11,11,11,11,11,11,0,11,0,7,0,0,0,7,0,0,11,11,11,0,7,7,7,7,7,0,0,0,7,0,0,0,11,11,11,0,0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,11,11,0,0,7,7,0,11,0,7,7,0,0,0,7,7,7,7,7,0,7,0,7,0,0,7,0,7,0,7,7,7,7,7,7,7,0,0,7,0,0,7,0,0,7,0,11,11,0,0,0,0,4,0,4,0,0,0,4,0,4,0,0,0},
chirashi 9:ab87b0e361aa 111 {11,0,7,0,7,0,0,7,7,7,7,7,0,11,11,11,11,11,0,7,0,7,7,7,7,7,7,7,7,0,11,11,11,0,0,7,0,0,7,7,0,7,7,0,7,0,11,11,0,0,0,0,0,0,7,7,7,0,7,0,0,7,7,0,11,0,7,7,0,0,0,0,0,0,0,7,7,0,0,0,7,0,7,0,7,0,7,0,11,0,0,7,0,7,0,0,0,0,0,7,0,0,7,7,7,7,7,7,7,0,11,11,0,0,0,0,4,0,0,0,0,0,4,0,0,0,0,0},
chirashi 9:ab87b0e361aa 112 {11,11,0,0,7,11,0,7,0,7,0,7,0,11,11,11,11,11,0,7,0,0,0,0,0,0,0,0,0,11,11,11,0,7,0,7,7,0,0,7,0,7,7,7,0,11,11,11,0,0,0,0,0,7,7,7,7,0,0,0,7,7,0,0,11,11,0,0,7,7,7,7,7,7,7,0,0,11,0,7,7,0,7,0,7,0,7,0,11,11,0,7,0,0,7,7,7,7,7,0,11,0,0,0,0,7,0,0,0,0,11,11,0,0,0,4,0,0,0,0,0,4,0,4,0,0,0,0},
chirashi 9:ab87b0e361aa 113 {11,11,11,0,7,11,0,7,7,7,7,7,0,11,11,11,11,11,0,7,0,11,0,7,0,0,7,0,11,11,11,11,0,7,0,7,7,0,0,7,0,7,0,7,0,11,11,11,0,0,0,0,0,7,0,7,7,0,0,7,7,7,7,0,11,11,11,0,7,0,0,0,0,0,7,0,11,0,7,7,0,0,7,0,7,0,0,7,0,11,0,7,0,11,0,0,7,0,0,11,0,7,7,7,7,7,7,7,7,7,0,11,0,0,0,4,0,0,0,0,0,4,0,4,0,0,0,0},
chirashi 9:ab87b0e361aa 114 {11,11,11,0,7,0,0,0,7,0,7,0,0,11,11,11,11,0,7,0,11,0,7,0,11,11,0,7,0,11,11,11,0,7,0,7,0,0,7,0,0,7,0,0,7,0,11,11,0,0,0,0,0,0,0,7,7,0,0,0,0,0,7,7,11,11,11,0,7,0,0,0,0,0,7,0,0,7,7,0,0,0,7,0,7,0,0,7,0,11,0,7,0,11,0,0,7,0,11,11,11,0,0,0,0,7,0,0,0,0,11,11,0,0,4,0,0,0,0,0,4,0,0,0,4,0,0,0},
chirashi 9:ab87b0e361aa 115 {11,11,11,0,7,0,7,7,0,11,0,7,7,0,11,11,11,0,7,0,0,7,0,11,11,11,11,0,7,0,11,11,11,0,0,7,0,11,0,7,7,0,11,11,0,11,11,11,0,0,0,0,0,0,0,7,7,0,0,0,0,0,7,7,11,11,11,0,7,7,7,7,7,7,7,0,0,7,0,0,7,7,0,7,0,11,11,0,7,0,0,7,0,0,7,7,0,11,11,11,11,11,11,11,0,7,0,11,11,11,11,11,0,0,4,0,0,0,0,4,0,0,0,0,0,4,0,0},
chirashi 9:ab87b0e361aa 116 {11,11,11,11,0,11,0,0,11,11,11,0,0,11,11,11,11,11,0,11,11,0,11,11,11,11,11,11,0,11,11,11,11,11,11,0,11,11,11,0,0,11,11,11,11,11,11,11,0,0,0,0,0,0,0,7,7,0,0,0,7,7,7,0,11,11,11,11,0,0,0,0,0,0,0,11,11,0,11,11,0,0,11,0,11,11,11,11,0,11,11,0,11,11,0,0,11,11,11,11,11,11,11,11,11,0,11,11,11,11,11,11,0,0,0,0,0,4,4,0,0,0,0,0,0,0,4,0},
chirashi 9:ab87b0e361aa 117 {11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,7,7,0,7,7,7,7,0,0,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
chirashi 8:9d22c9910917 118
chirashi 8:9d22c9910917 119 };
chirashi 8:9d22c9910917 120
chirashi 9:ab87b0e361aa 121 //10 Yellow(Nambu Local)
chirashi 9:ab87b0e361aa 122 //11 Green (Yokohama Line)
chirashi 9:ab87b0e361aa 123 bool R1Data1[32]={0,1,0,0,1,0,1,1,0,1,1,1};
chirashi 9:ab87b0e361aa 124 bool R1Data2[32]={0,1,0,0,1,0,1,1,0,1,1,0};
chirashi 9:ab87b0e361aa 125 bool R1Data3[32]={0,1,0,0,1,0,1,1,0,1,1,0};
chirashi 9:ab87b0e361aa 126 bool R1Data4[32]={0,1,0,0,1,0,1,1,0,1,0,0};
chirashi 4:245f17936b1a 127
chirashi 9:ab87b0e361aa 128 bool G1Data1[32]={0,0,1,0,1,1,0,1,1,0,1,1};
chirashi 9:ab87b0e361aa 129 bool G1Data2[32]={0,0,1,0,1,1,0,1,1,0,1,1};
chirashi 9:ab87b0e361aa 130 bool G1Data3[32]={0,0,1,0,1,1,0,1,0,0,0,0};
chirashi 9:ab87b0e361aa 131 bool G1Data4[32]={0,0,1,0,1,1,0,1,0,0,0,0};
chirashi 7:79dfe71beb88 132
chirashi 9:ab87b0e361aa 133 bool B1Data1[32]={0,0,0,1,0,1,1,1,1,1,0,0};
chirashi 9:ab87b0e361aa 134 bool B1Data2[32]={0,0,0,1,0,1,1,1,1,0,0,0};
chirashi 9:ab87b0e361aa 135 bool B1Data3[32]={0,0,0,1,0,1,1,1,1,0,0,0};
chirashi 9:ab87b0e361aa 136 bool B1Data4[32]={0,0,0,1,0,1,1,1,1,0,0,0};
chirashi 7:79dfe71beb88 137
chirashi 7:79dfe71beb88 138
chirashi 7:79dfe71beb88 139
chirashi 7:79dfe71beb88 140
RRacer 0:1f58ecec51d6 141
RRacer 0:1f58ecec51d6 142 void Init()
RRacer 0:1f58ecec51d6 143 {
RRacer 0:1f58ecec51d6 144 // Set up things to a known state
RRacer 0:1f58ecec51d6 145 CLK = LOW;
RRacer 0:1f58ecec51d6 146 LAT = LOW;
RRacer 0:1f58ecec51d6 147 OE = HIGH; //display off
RRacer 0:1f58ecec51d6 148 ABC = 0;
RRacer 0:1f58ecec51d6 149 CT=0;
chirashi 7:79dfe71beb88 150
RRacer 0:1f58ecec51d6 151 }
RRacer 0:1f58ecec51d6 152
RRacer 0:1f58ecec51d6 153
RRacer 0:1f58ecec51d6 154
chirashi 8:9d22c9910917 155 void WrRow(unsigned char Row, int Buffer[32][128])
RRacer 0:1f58ecec51d6 156 {
RRacer 0:1f58ecec51d6 157 // Write specified row (and row+8) to display. Valid input: 0 to 7.
chirashi 2:c1a9a2a0885d 158 ABC = 7-Row; // Set row address
chirashi 6:e6cb4a476422 159 for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
chirashi 5:532937f20397 160
chirashi 8:9d22c9910917 161 if (Buffer [(7-Row)][col] == 0){
chirashi 6:e6cb4a476422 162 R1 = R_Debug1;
chirashi 6:e6cb4a476422 163 G1 = G_Debug1;
chirashi 6:e6cb4a476422 164 B1 = B_Debug1;
chirashi 7:79dfe71beb88 165 }else {
chirashi 8:9d22c9910917 166 //R1 = R1Data1[(LEDBuffer [(7-Row)][col])];
chirashi 8:9d22c9910917 167 //G1 = G1Data1[(LEDBuffer [(7-Row)][col])];
chirashi 8:9d22c9910917 168 //B1 = B1Data1[(LEDBuffer [(7-Row)][col])];
chirashi 8:9d22c9910917 169 R1 = R1Data1[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 170 G1 = G1Data1[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 171 B1 = B1Data1[(Buffer [(7-Row)][col])];
chirashi 4:245f17936b1a 172 }
chirashi 7:79dfe71beb88 173
chirashi 8:9d22c9910917 174 if (Buffer [(15-Row)][col] == 0){
chirashi 6:e6cb4a476422 175 R2 = R_Debug1;
chirashi 6:e6cb4a476422 176 G2 = G_Debug1;
chirashi 6:e6cb4a476422 177 B2 = B_Debug1;
chirashi 7:79dfe71beb88 178 }else {
chirashi 8:9d22c9910917 179 R2 = R1Data1[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 180 G2 = G1Data1[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 181 B2 = B1Data1[(Buffer [(15-Row)][col])];
chirashi 7:79dfe71beb88 182 }
chirashi 4:245f17936b1a 183
chirashi 4:245f17936b1a 184 CLK = HIGH; // tick (clock bit in)
chirashi 4:245f17936b1a 185 CLK = LOW; // tock
chirashi 4:245f17936b1a 186 }
chirashi 4:245f17936b1a 187 LAT = HIGH; // Latch entire row
chirashi 4:245f17936b1a 188 LAT = LOW;
chirashi 4:245f17936b1a 189 }
chirashi 4:245f17936b1a 190
chirashi 8:9d22c9910917 191 void WrRow2(unsigned char Row,int Buffer[32][128])
chirashi 4:245f17936b1a 192 {
chirashi 4:245f17936b1a 193 // Write specified row (and row+8) to display. Valid input: 0 to 7.
chirashi 4:245f17936b1a 194 ABC = 7-Row; // Set row address
chirashi 6:e6cb4a476422 195 for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
chirashi 5:532937f20397 196
chirashi 8:9d22c9910917 197 if (Buffer [(7-Row)][col] == 0){
chirashi 6:e6cb4a476422 198 R1 = R_Debug2;
chirashi 6:e6cb4a476422 199 G1 = G_Debug2;
chirashi 6:e6cb4a476422 200 B1 = B_Debug2;
chirashi 5:532937f20397 201 }else{
chirashi 8:9d22c9910917 202 R1 = R1Data2[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 203 G1 = G1Data2[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 204 B1 = B1Data2[(Buffer [(7-Row)][col])];
chirashi 5:532937f20397 205 }
chirashi 5:532937f20397 206
chirashi 8:9d22c9910917 207 if (Buffer [(15-Row)][col] == 0){
chirashi 6:e6cb4a476422 208 R2 = R_Debug2;
chirashi 6:e6cb4a476422 209 G2 = G_Debug2;
chirashi 6:e6cb4a476422 210 B2 = B_Debug2;
chirashi 6:e6cb4a476422 211 }else{
chirashi 8:9d22c9910917 212 R2 = R1Data2[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 213 G2 = G1Data2[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 214 B2 = B1Data2[(Buffer [(15-Row)][col])];
chirashi 7:79dfe71beb88 215 }
chirashi 5:532937f20397 216
chirashi 5:532937f20397 217 CLK = HIGH; // tick (clock bit in)
chirashi 5:532937f20397 218 CLK = LOW; // tock
chirashi 5:532937f20397 219 }
chirashi 5:532937f20397 220 LAT = HIGH; // Latch entire row
chirashi 5:532937f20397 221 LAT = LOW;
chirashi 5:532937f20397 222 }
chirashi 5:532937f20397 223
chirashi 8:9d22c9910917 224 void WrRow3(unsigned char Row,int Buffer[32][128])
chirashi 5:532937f20397 225 {
chirashi 5:532937f20397 226 // Write specified row (and row+8) to display. Valid input: 0 to 7.
chirashi 5:532937f20397 227 ABC = 7-Row; // Set row address
chirashi 6:e6cb4a476422 228 for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
chirashi 5:532937f20397 229
chirashi 8:9d22c9910917 230 if (Buffer [(7-Row)][col] == 0){
chirashi 6:e6cb4a476422 231 R1 = R_Debug3;
chirashi 6:e6cb4a476422 232 G1 = G_Debug3;
chirashi 6:e6cb4a476422 233 B1 = B_Debug3;
chirashi 5:532937f20397 234 }else{
chirashi 8:9d22c9910917 235 R1 = R1Data3[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 236 G1 = G1Data3[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 237 B1 = B1Data3[(Buffer [(7-Row)][col])];
chirashi 5:532937f20397 238 }
chirashi 5:532937f20397 239
chirashi 8:9d22c9910917 240 if (Buffer [(15-Row)][col] == 0){
chirashi 6:e6cb4a476422 241 R2 = R_Debug3;
chirashi 6:e6cb4a476422 242 G2 = G_Debug3;
chirashi 6:e6cb4a476422 243 B2 = B_Debug3;
chirashi 5:532937f20397 244 }else{
chirashi 8:9d22c9910917 245 R2 = R1Data3[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 246 G2 = G1Data3[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 247 B2 = B1Data3[(Buffer [(15-Row)][col])];
chirashi 7:79dfe71beb88 248 }
chirashi 5:532937f20397 249
chirashi 5:532937f20397 250 CLK = HIGH; // tick (clock bit in)
chirashi 5:532937f20397 251 CLK = LOW; // tock
chirashi 5:532937f20397 252 }
chirashi 5:532937f20397 253 LAT = HIGH; // Latch entire row
chirashi 5:532937f20397 254 LAT = LOW;
chirashi 5:532937f20397 255 }
chirashi 5:532937f20397 256
chirashi 8:9d22c9910917 257 void WrRow4(unsigned char Row,int Buffer[32][128])
chirashi 5:532937f20397 258 {
chirashi 5:532937f20397 259 // Write specified row (and row+8) to display. Valid input: 0 to 7.
chirashi 5:532937f20397 260 ABC = 7-Row; // Set row address
chirashi 6:e6cb4a476422 261 for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
chirashi 5:532937f20397 262
chirashi 8:9d22c9910917 263 if (Buffer [(7-Row)][col] == 0){
chirashi 6:e6cb4a476422 264 R1 = R_Debug4;
chirashi 6:e6cb4a476422 265 G1 = G_Debug4;
chirashi 6:e6cb4a476422 266 B1 = B_Debug4;
chirashi 5:532937f20397 267 }else{
chirashi 8:9d22c9910917 268 R1 = R1Data4[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 269 G1 = G1Data4[(Buffer [(7-Row)][col])];
chirashi 8:9d22c9910917 270 B1 = B1Data4[(Buffer [(7-Row)][col])];
chirashi 5:532937f20397 271 }
chirashi 5:532937f20397 272
chirashi 8:9d22c9910917 273 if (Buffer [(15-Row)][col] == 0){
chirashi 6:e6cb4a476422 274 R2 = R_Debug4;
chirashi 6:e6cb4a476422 275 G2 = G_Debug4;
chirashi 6:e6cb4a476422 276 B2 = B_Debug4;
chirashi 6:e6cb4a476422 277 }else if (LEDBuffer [(15-Row)][col] == 1){
chirashi 8:9d22c9910917 278 R2 = R1Data4[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 279 G2 = G1Data4[(Buffer [(15-Row)][col])];
chirashi 8:9d22c9910917 280 B2 = B1Data4[(Buffer [(15-Row)][col])];
chirashi 7:79dfe71beb88 281 }
chirashi 5:532937f20397 282
chirashi 5:532937f20397 283 CLK = HIGH; // tick (clock bit in)
chirashi 5:532937f20397 284 CLK = LOW; // tock
chirashi 5:532937f20397 285 }
chirashi 5:532937f20397 286 LAT = HIGH; // Latch entire row
chirashi 5:532937f20397 287 LAT = LOW;
chirashi 5:532937f20397 288 }
chirashi 5:532937f20397 289
chirashi 4:245f17936b1a 290
chirashi 3:6dbbc0130e96 291 void WrRowOFF(unsigned char Row)
chirashi 3:6dbbc0130e96 292 {
chirashi 3:6dbbc0130e96 293 // Write specified row (and row+8) to display. Valid input: 0 to 7.
chirashi 3:6dbbc0130e96 294 ABC = 7-Row; // Set row address
chirashi 6:e6cb4a476422 295 for(int col=0; col<LED_Width; col++) { // To daisychain more displays, I guess you would have to increase this counter to n*32 columns. Might mirror though.
chirashi 3:6dbbc0130e96 296 R1 = 0; // Red bit, upper half
chirashi 3:6dbbc0130e96 297 G1 = 0; // Green bit, upper half
chirashi 3:6dbbc0130e96 298 B1 = 0; // Blue bit, upper half
chirashi 3:6dbbc0130e96 299 R2 = 0; // Red bit, lower half
chirashi 3:6dbbc0130e96 300 G2 = 0; // Green bit, lower half
chirashi 3:6dbbc0130e96 301 B2 = 0; // Blue bit, lower half
chirashi 3:6dbbc0130e96 302 CLK = HIGH; // tick (clock bit in)
chirashi 3:6dbbc0130e96 303 CLK = LOW; // tock
chirashi 3:6dbbc0130e96 304 }
chirashi 3:6dbbc0130e96 305 LAT = HIGH; // Latch entire row
chirashi 3:6dbbc0130e96 306 LAT = LOW;
chirashi 3:6dbbc0130e96 307 }
chirashi 3:6dbbc0130e96 308
RRacer 0:1f58ecec51d6 309 void Pset(unsigned char x,unsigned char y, unsigned char c)
RRacer 0:1f58ecec51d6 310 {
RRacer 0:1f58ecec51d6 311 // Set pixel (x,y) to color c
RRacer 0:1f58ecec51d6 312 // Manipulates graphics memory, so you won't see any change til you Paint() it.
RRacer 0:1f58ecec51d6 313 unsigned char ud,l,r0,g0,b0;
RRacer 0:1f58ecec51d6 314 ud=(y & 8)>>3; // 0 = upper half, 1 = lower half
RRacer 0:1f58ecec51d6 315 l=y & 7; // Extract row in upper/lower half
RRacer 0:1f58ecec51d6 316 r0=(c & 4) >>2; // Extract red bit from color
RRacer 0:1f58ecec51d6 317 g0=(c & 2) >>1; // Extract green bit from color
RRacer 0:1f58ecec51d6 318 b0=(c & 1); // Extract blue bit from color
RRacer 0:1f58ecec51d6 319 // *******Removes current bit ******* *Adds bit**
RRacer 0:1f58ecec51d6 320 gm[x][0+3*ud]=(gm[x][0+3*ud] & (255-(1<<(7-l))))+(r0<<(7-l)); // Red byte
RRacer 0:1f58ecec51d6 321 gm[x][1+3*ud]=(gm[x][1+3*ud] & (255-(1<<(7-l))))+(g0<<(7-l)); // Green byte
RRacer 0:1f58ecec51d6 322 gm[x][2+3*ud]=(gm[x][2+3*ud] & (255-(1<<(7-l))))+(b0<<(7-l)); // Blue byte
RRacer 0:1f58ecec51d6 323 }
RRacer 0:1f58ecec51d6 324
chirashi 8:9d22c9910917 325 void Paint(int Buffer2[32][128])
RRacer 0:1f58ecec51d6 326 {
RRacer 0:1f58ecec51d6 327 // Write graphics memory to display
chirashi 5:532937f20397 328 //1
chirashi 9:ab87b0e361aa 329 for(int Row=0; Row<LED_Height; Row++) {
RRacer 0:1f58ecec51d6 330 OE = HIGH; // Disable output
chirashi 8:9d22c9910917 331 WrRow(Row,Buffer2);
chirashi 5:532937f20397 332 //wait_us(10);
chirashi 5:532937f20397 333 OE = LOW; // Enable output
chirashi 5:532937f20397 334
chirashi 6:e6cb4a476422 335 wait_us(10); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
chirashi 5:532937f20397 336 }
chirashi 5:532937f20397 337 //2
chirashi 9:ab87b0e361aa 338 for(int Row=0; Row<LED_Height; Row++) {
chirashi 5:532937f20397 339 OE = HIGH; // Disable output
chirashi 5:532937f20397 340 //WrRow(Row);
chirashi 8:9d22c9910917 341 WrRow2(Row,Buffer2);
chirashi 5:532937f20397 342 //wait_us(10);
chirashi 5:532937f20397 343 OE = LOW; // Enable output
chirashi 5:532937f20397 344
chirashi 6:e6cb4a476422 345 wait_us(10); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
chirashi 5:532937f20397 346 }
chirashi 5:532937f20397 347 //3
chirashi 9:ab87b0e361aa 348 for(int Row=0; Row<LED_Height; Row++) {
chirashi 5:532937f20397 349 OE = HIGH; // Disable output
chirashi 8:9d22c9910917 350 WrRow3(Row,Buffer2);
chirashi 5:532937f20397 351 //wait_us(10);
chirashi 5:532937f20397 352 OE = LOW; // Enable output
chirashi 5:532937f20397 353
chirashi 6:e6cb4a476422 354 wait_us(10); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
chirashi 5:532937f20397 355 }
chirashi 5:532937f20397 356 //4
chirashi 9:ab87b0e361aa 357 for(int Row=0; Row<LED_Height; Row++) {
chirashi 5:532937f20397 358 OE = HIGH; // Disable output
chirashi 8:9d22c9910917 359 WrRow4(Row,Buffer2);
chirashi 5:532937f20397 360 //wait_us(10);
RRacer 0:1f58ecec51d6 361 OE = LOW; // Enable output
chirashi 4:245f17936b1a 362
chirashi 6:e6cb4a476422 363 wait_us(10); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
chirashi 5:532937f20397 364 }
chirashi 7:79dfe71beb88 365
chirashi 5:532937f20397 366
chirashi 4:245f17936b1a 367 }
chirashi 4:245f17936b1a 368
RRacer 0:1f58ecec51d6 369
chirashi 3:6dbbc0130e96 370
chirashi 3:6dbbc0130e96 371 void PaintOFF()
chirashi 3:6dbbc0130e96 372 {
chirashi 3:6dbbc0130e96 373 // Write graphics memory to display
chirashi 3:6dbbc0130e96 374 for(int Row=0; Row<8; Row++) {
chirashi 3:6dbbc0130e96 375 OE = HIGH; // Disable output
chirashi 3:6dbbc0130e96 376 WrRowOFF(Row);
chirashi 3:6dbbc0130e96 377 OE = LOW; // Enable output
chirashi 4:245f17936b1a 378 wait_us(50); // Wasting some time. Use for whatever else. Probably better with a ticker for the display refresh.
chirashi 3:6dbbc0130e96 379 }
chirashi 3:6dbbc0130e96 380 }
chirashi 3:6dbbc0130e96 381
chirashi 8:9d22c9910917 382 void TimerTick(){
chirashi 8:9d22c9910917 383 if (ChangeCount == 0){
chirashi 8:9d22c9910917 384
chirashi 8:9d22c9910917 385
chirashi 8:9d22c9910917 386
chirashi 8:9d22c9910917 387
chirashi 8:9d22c9910917 388 ChangeCount = ChangeCount + 1;
chirashi 8:9d22c9910917 389 }else if(ChangeCount == 1 ){
chirashi 8:9d22c9910917 390
chirashi 8:9d22c9910917 391
chirashi 8:9d22c9910917 392 ChangeCount = ChangeCount + 1;
chirashi 8:9d22c9910917 393 //ChangeCount = 0;
chirashi 8:9d22c9910917 394 }else if(ChangeCount == 2){
chirashi 8:9d22c9910917 395
chirashi 8:9d22c9910917 396 ChangeCount = 0;
chirashi 8:9d22c9910917 397 }else{
chirashi 8:9d22c9910917 398
chirashi 8:9d22c9910917 399
chirashi 8:9d22c9910917 400 }
chirashi 8:9d22c9910917 401
chirashi 8:9d22c9910917 402
chirashi 8:9d22c9910917 403 }
chirashi 3:6dbbc0130e96 404
RRacer 0:1f58ecec51d6 405 int main()
RRacer 0:1f58ecec51d6 406 {
RRacer 0:1f58ecec51d6 407 Init(); // Set things up
chirashi 8:9d22c9910917 408 ChangeTimer.attach(&TimerTick,5);
chirashi 8:9d22c9910917 409
RRacer 0:1f58ecec51d6 410 while(1) { // Messy demo loop following...
RRacer 0:1f58ecec51d6 411 CT++;
chirashi 8:9d22c9910917 412 if (ChangeCount == 0){
chirashi 8:9d22c9910917 413 Paint(LEDBuffer);
chirashi 8:9d22c9910917 414 }else if(ChangeCount == 1){
chirashi 8:9d22c9910917 415 Paint(LEDBuffer2);
chirashi 8:9d22c9910917 416 }else if(ChangeCount == 2){
chirashi 8:9d22c9910917 417 Paint(LEDBuffer3);
chirashi 8:9d22c9910917 418 }
chirashi 4:245f17936b1a 419
chirashi 4:245f17936b1a 420 //if((CT<=2560)||(CT>=2880 && CT<=4160)) {
chirashi 4:245f17936b1a 421 // Paint(); // Refresh display
chirashi 4:245f17936b1a 422 // if((CT % 20)==0) ShiftRight(); // After every 20 refresh, do a ShiftRight
chirashi 4:245f17936b1a 423 //}
chirashi 3:6dbbc0130e96 424
chirashi 4:245f17936b1a 425 //if(CT==2560) {
chirashi 4:245f17936b1a 426 // for(int c=0; c<8; c++) {
chirashi 4:245f17936b1a 427 // for(int x=c; x<(31-c); x++) {// Top side
chirashi 4:245f17936b1a 428 // Pset(x,c,c);
chirashi 4:245f17936b1a 429 // Paint(); // Display refresh time sets loop duration.
chirashi 4:245f17936b1a 430 // }
chirashi 4:245f17936b1a 431 // for(int y=c; y<(15-c); y++) {// Right side
chirashi 4:245f17936b1a 432 // Pset(31-c,y,c);
chirashi 4:245f17936b1a 433 // Paint();
chirashi 4:245f17936b1a 434 // }
chirashi 4:245f17936b1a 435 // for(int x=(31-c); x>=c; x--) {// Bottom side
chirashi 4:245f17936b1a 436 // Pset(x,(15-c),c);
chirashi 4:245f17936b1a 437 // Paint();
chirashi 4:245f17936b1a 438 // }
chirashi 4:245f17936b1a 439 // for(int y=(15-c); y>=c; y--) { // Left side
chirashi 4:245f17936b1a 440 // Pset(c,y,c);
chirashi 4:245f17936b1a 441 // Paint();
chirashi 4:245f17936b1a 442 // }
chirashi 4:245f17936b1a 443 // }
chirashi 4:245f17936b1a 444 //}
chirashi 3:6dbbc0130e96 445
RRacer 0:1f58ecec51d6 446 if(CT>4160) {
chirashi 4:245f17936b1a 447 //MkPattern(); // Restore original priceless artwork
RRacer 0:1f58ecec51d6 448 CT=0; // Start all over.
RRacer 0:1f58ecec51d6 449 }
chirashi 3:6dbbc0130e96 450
chirashi 4:245f17936b1a 451 //PaintOFF();
chirashi 6:e6cb4a476422 452 //wait_us(10);
RRacer 0:1f58ecec51d6 453 }
chirashi 3:6dbbc0130e96 454
RRacer 0:1f58ecec51d6 455 }