![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code to work with NeoPixels
main.cpp@4:64ecb3b6d1c7, 2015-04-24 (annotated)
- Committer:
- ivanyohuno
- Date:
- Fri Apr 24 11:36:37 2015 +0000
- Revision:
- 4:64ecb3b6d1c7
- Parent:
- 3:81ab43d7e3a2
Using 2 spis with 2 strips of 8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ivanyohuno | 0:c350fa2f0c19 | 1 | #include "mbed.h" |
ivanyohuno | 0:c350fa2f0c19 | 2 | #include <string.h> |
ivanyohuno | 0:c350fa2f0c19 | 3 | #include <stdio.h> |
ivanyohuno | 0:c350fa2f0c19 | 4 | #include "NeoStrip.h" |
ivanyohuno | 0:c350fa2f0c19 | 5 | |
ivanyohuno | 0:c350fa2f0c19 | 6 | /* |
ivanyohuno | 0:c350fa2f0c19 | 7 | neopixel_spi v03 |
ivanyohuno | 0:c350fa2f0c19 | 8 | Created By: Ivan Yohuno |
ivanyohuno | 0:c350fa2f0c19 | 9 | SSID: 200717683 |
ivanyohuno | 0:c350fa2f0c19 | 10 | |
ivanyohuno | 0:c350fa2f0c19 | 11 | Notes: |
ivanyohuno | 0:c350fa2f0c19 | 12 | -Code to be run on WS2812 neopixel LEDs, can run with a single pixel or a strip of max 8 leds connected together |
ivanyohuno | 0:c350fa2f0c19 | 13 | -Single LED can be connected to power source of 5V but if connected to 5V logic will need to be shifted up from 3.3V to 5V |
ivanyohuno | 0:c350fa2f0c19 | 14 | |
ivanyohuno | 0:c350fa2f0c19 | 15 | Features: |
ivanyohuno | 0:c350fa2f0c19 | 16 | -SetRGBPixel // sets colour of one RGB Pixel (the first pixel connected), generally used for testing. Colour is a mix of 3 8 bit values of red, green and blue |
ivanyohuno | 0:c350fa2f0c19 | 17 | -SetRGBStrip // sets colour of RGB strip of 8 |
ivanyohuno | 0:c350fa2f0c19 | 18 | -setRGBStrips //sets colours of 4 RGB strips of 8 |
ivanyohuno | 0:c350fa2f0c19 | 19 | colours 2D 4x3 matrix: |
ivanyohuno | 0:c350fa2f0c19 | 20 | {{room 1 strip red, room 1 strip green, room 1 strip blue}, |
ivanyohuno | 0:c350fa2f0c19 | 21 | {room 2 strip red, room 2 strip green, room 3 strip blue}, |
ivanyohuno | 0:c350fa2f0c19 | 22 | {room 3 strip red, room 3 strip green, room 3 strip blue} |
ivanyohuno | 0:c350fa2f0c19 | 23 | } |
ivanyohuno | 0:c350fa2f0c19 | 24 | -SetRGBPixels // sets an RGB strip of 8 to individual colours using a 2D 8x3 matrix |
ivanyohuno | 0:c350fa2f0c19 | 25 | colours 2D 8x3 matrix: |
ivanyohuno | 0:c350fa2f0c19 | 26 | {{1st pixel red, 1st pixel blue, 1st pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 27 | {2nd pixel red, 2nd pixel blue, 2nd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 28 | {3rd pixel red, 3rd pixel blue, 3rd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 29 | {4th pixel red, 4th pixel blue, 4th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 30 | {5th pixel red, 5th pixel blue, 5th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 31 | {6th pixel red, 6th pixel blue, 6th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 32 | {7th pixel red, 7th pixel blue, 7th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 33 | {8th pixel red, 8th pixel blue, 8th pixel green} |
ivanyohuno | 0:c350fa2f0c19 | 34 | } |
ivanyohuno | 0:c350fa2f0c19 | 35 | -setRGBAll // sets 4 RGB strips of 8 to individual colours using a 3D 8x4x3 matrix |
ivanyohuno | 0:c350fa2f0c19 | 36 | colours 2D 8x4x3 matrix: |
ivanyohuno | 0:c350fa2f0c19 | 37 | {room1{1st pixel red, 1st pixel blue, 1st pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 38 | {2nd pixel red, 2nd pixel blue, 2nd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 39 | {3rd pixel red, 3rd pixel blue, 3rd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 40 | {4th pixel red, 4th pixel blue, 4th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 41 | {5th pixel red, 5th pixel blue, 5th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 42 | {6th pixel red, 6th pixel blue, 6th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 43 | {7th pixel red, 7th pixel blue, 7th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 44 | {8th pixel red, 8th pixel blue, 8th pixel green} |
ivanyohuno | 0:c350fa2f0c19 | 45 | room2{1st pixel red, 1st pixel blue, 1st pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 46 | {2nd pixel red, 2nd pixel blue, 2nd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 47 | {3rd pixel red, 3rd pixel blue, 3rd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 48 | {4th pixel red, 4th pixel blue, 4th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 49 | {5th pixel red, 5th pixel blue, 5th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 50 | {6th pixel red, 6th pixel blue, 6th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 51 | {7th pixel red, 7th pixel blue, 7th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 52 | {8th pixel red, 8th pixel blue, 8th pixel green} |
ivanyohuno | 0:c350fa2f0c19 | 53 | room3{1st pixel red, 1st pixel blue, 1st pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 54 | {2nd pixel red, 2nd pixel blue, 2nd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 55 | {3rd pixel red, 3rd pixel blue, 3rd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 56 | {4th pixel red, 4th pixel blue, 4th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 57 | {5th pixel red, 5th pixel blue, 5th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 58 | {6th pixel red, 6th pixel blue, 6th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 59 | {7th pixel red, 7th pixel blue, 7th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 60 | {8th pixel red, 8th pixel blue, 8th pixel green} |
ivanyohuno | 0:c350fa2f0c19 | 61 | room4{1st pixel red, 1st pixel blue, 1st pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 62 | {2nd pixel red, 2nd pixel blue, 2nd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 63 | {3rd pixel red, 3rd pixel blue, 3rd pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 64 | {4th pixel red, 4th pixel blue, 4th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 65 | {5th pixel red, 5th pixel blue, 5th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 66 | {6th pixel red, 6th pixel blue, 6th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 67 | {7th pixel red, 7th pixel blue, 7th pixel green}, |
ivanyohuno | 0:c350fa2f0c19 | 68 | {8th pixel red, 8th pixel blue, 8th pixel green} |
ivanyohuno | 0:c350fa2f0c19 | 69 | } |
ivanyohuno | 0:c350fa2f0c19 | 70 | |
ivanyohuno | 0:c350fa2f0c19 | 71 | */ |
ivanyohuno | 0:c350fa2f0c19 | 72 | |
ivanyohuno | 0:c350fa2f0c19 | 73 | //function declarations |
ivanyohuno | 4:64ecb3b6d1c7 | 74 | //void setRGBPixel(int r, int g, int b); //sets colour of one RGB Pixel |
ivanyohuno | 4:64ecb3b6d1c7 | 75 | void setRGBStrip1(int r, int g, int b); //sets colour of a strip of 8 RGB Pixels on pin 5 |
ivanyohuno | 4:64ecb3b6d1c7 | 76 | void setRGBStrip2(int r, int g, int b); //sets colour of a strip of 8 RGB Pixels on pin 11 |
ivanyohuno | 4:64ecb3b6d1c7 | 77 | void setRGBPixels1(int colours[8][3]); //sets sequence of colours for a strip of 8 RGB Pixels on pin 5 |
ivanyohuno | 4:64ecb3b6d1c7 | 78 | void setRGBPixels2(int colours[8][3]); //sets sequence of colours for a strip of 8 RGB Pixels on pin 11 |
ivanyohuno | 4:64ecb3b6d1c7 | 79 | //void setRGBFloor1(int colours[2][8][3]); //sets a sequence of colours for 2 strips of 8 RGB Pixels on pin 5 |
ivanyohuno | 4:64ecb3b6d1c7 | 80 | //void setRGBFloor2(int colours[2][8][3]); //sets a sequence of colours for 2 strips of 8 RGB Pixels on pin 11 |
ivanyohuno | 1:42b43fa7362f | 81 | |
ivanyohuno | 1:42b43fa7362f | 82 | |
ivanyohuno | 0:c350fa2f0c19 | 83 | void spi_init(); //initializes SPI pin at correct bit length and bit rate |
ivanyohuno | 0:c350fa2f0c19 | 84 | int * decimalToBinary(int n); //converts a decimal value between 0 and 255 to an 8 bit binary array of 0xF00 (0) and 0xFF0 (1) |
ivanyohuno | 0:c350fa2f0c19 | 85 | |
ivanyohuno | 0:c350fa2f0c19 | 86 | //initialize pins |
ivanyohuno | 0:c350fa2f0c19 | 87 | DigitalOut volt(p16); //pin for LV voltage |
ivanyohuno | 2:35fd99de07b3 | 88 | SPI spi(p5, p6, p7);//pin for SPI communication - p5 MOSI p5 MISO p6 SCLK |
ivanyohuno | 1:42b43fa7362f | 89 | SPI spi2(p11, p12, p13);//pin for SPI communication - p5 MOSI p5 MISO p6 SCLK |
ivanyohuno | 0:c350fa2f0c19 | 90 | NeoStrip strip(p5,8); |
ivanyohuno | 0:c350fa2f0c19 | 91 | |
ivanyohuno | 0:c350fa2f0c19 | 92 | int main() { |
ivanyohuno | 0:c350fa2f0c19 | 93 | volt = 1; |
ivanyohuno | 0:c350fa2f0c19 | 94 | //use either function |
ivanyohuno | 0:c350fa2f0c19 | 95 | } |
ivanyohuno | 0:c350fa2f0c19 | 96 | |
ivanyohuno | 4:64ecb3b6d1c7 | 97 | void setRGBStrip1(int r, int g, int b){ |
ivanyohuno | 0:c350fa2f0c19 | 98 | int r_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 99 | int g_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 100 | int b_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 101 | memcpy(r_array, decimalToBinary(r), sizeof(r_array)); |
ivanyohuno | 0:c350fa2f0c19 | 102 | memcpy(g_array, decimalToBinary(g), sizeof(g_array)); |
ivanyohuno | 0:c350fa2f0c19 | 103 | memcpy(b_array, decimalToBinary(b), sizeof(b_array)); |
ivanyohuno | 0:c350fa2f0c19 | 104 | |
ivanyohuno | 0:c350fa2f0c19 | 105 | //send commands to LED Driver |
ivanyohuno | 0:c350fa2f0c19 | 106 | //initialize SPI |
ivanyohuno | 0:c350fa2f0c19 | 107 | spi_init(); |
ivanyohuno | 0:c350fa2f0c19 | 108 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 109 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 110 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 111 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 112 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 113 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 114 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 115 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 116 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 117 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 118 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 119 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 120 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 121 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 122 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 123 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 124 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 125 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 126 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 127 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 128 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 129 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 130 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 131 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 132 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 133 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 134 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 135 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 136 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 137 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 138 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 139 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 140 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 141 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 142 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 143 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 144 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 145 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 146 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 147 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 148 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 149 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 150 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 151 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 152 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 153 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 154 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 155 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 156 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 157 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 158 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 159 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 160 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 161 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 162 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 163 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 164 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 165 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 166 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 167 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 168 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 169 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 170 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 171 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 172 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 173 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 174 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 175 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 176 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 177 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 178 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 179 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 180 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 181 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 182 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 183 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 184 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 185 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 186 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 187 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 188 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 189 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 190 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 191 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 192 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 193 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 194 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 195 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 196 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 197 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 198 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 199 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 200 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 201 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 202 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 203 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 204 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 205 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 206 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 207 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 208 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 209 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 210 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 211 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 212 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 213 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 214 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 215 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 216 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 217 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 218 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 219 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 220 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 221 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 222 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 223 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 224 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 225 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 226 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 227 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 228 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 229 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 230 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 231 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 232 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 233 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 234 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 235 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 236 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 237 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 238 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 239 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 240 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 241 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 242 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 243 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 244 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 245 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 246 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 247 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 248 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 249 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 250 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 251 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 252 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 253 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 254 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 255 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 256 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 257 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 258 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 259 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 260 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 261 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 262 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 263 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 264 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 265 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 266 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 267 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 268 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 269 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 270 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 271 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 272 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 273 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 274 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 275 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 276 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 277 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 278 | |
ivanyohuno | 0:c350fa2f0c19 | 279 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 280 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 281 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 282 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 283 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 284 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 285 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 286 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 287 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 288 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 289 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 290 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 291 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 292 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 293 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 294 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 295 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 296 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 297 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 298 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 299 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 300 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 301 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 302 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 303 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 304 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 305 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 306 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 307 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 308 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 309 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 310 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 311 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 312 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 313 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 314 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 315 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 316 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 317 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 318 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 319 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 320 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 321 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 322 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 323 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 324 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 325 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 326 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 327 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 328 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 329 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 330 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 331 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 332 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 2:35fd99de07b3 | 333 | |
ivanyohuno | 0:c350fa2f0c19 | 334 | //wait for latch |
ivanyohuno | 0:c350fa2f0c19 | 335 | wait_us(60); |
ivanyohuno | 0:c350fa2f0c19 | 336 | } |
ivanyohuno | 4:64ecb3b6d1c7 | 337 | |
ivanyohuno | 4:64ecb3b6d1c7 | 338 | void setRGBStrip2(int r, int g, int b){ |
ivanyohuno | 4:64ecb3b6d1c7 | 339 | int r_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 340 | int g_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 341 | int b_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 342 | memcpy(r_array, decimalToBinary(r), sizeof(r_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 343 | memcpy(g_array, decimalToBinary(g), sizeof(g_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 344 | memcpy(b_array, decimalToBinary(b), sizeof(b_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 345 | |
ivanyohuno | 4:64ecb3b6d1c7 | 346 | //send commands to LED Driver |
ivanyohuno | 4:64ecb3b6d1c7 | 347 | //initialize spi |
ivanyohuno | 4:64ecb3b6d1c7 | 348 | spi_init(); |
ivanyohuno | 4:64ecb3b6d1c7 | 349 | //LED0 |
ivanyohuno | 4:64ecb3b6d1c7 | 350 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 351 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 352 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 353 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 354 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 355 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 356 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 357 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 358 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 359 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 360 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 361 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 362 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 363 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 364 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 365 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 366 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 367 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 368 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 369 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 370 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 371 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 372 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 373 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 374 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 375 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 376 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 377 | //LED1 |
ivanyohuno | 4:64ecb3b6d1c7 | 378 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 379 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 380 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 381 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 382 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 383 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 384 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 385 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 386 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 387 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 388 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 389 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 390 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 391 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 392 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 393 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 394 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 395 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 396 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 397 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 398 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 399 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 400 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 401 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 402 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 403 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 404 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 405 | //LED2 |
ivanyohuno | 4:64ecb3b6d1c7 | 406 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 407 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 408 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 409 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 410 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 411 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 412 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 413 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 414 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 415 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 416 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 417 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 418 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 419 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 420 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 421 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 422 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 423 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 424 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 425 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 426 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 427 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 428 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 429 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 430 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 431 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 432 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 433 | //LED3 |
ivanyohuno | 4:64ecb3b6d1c7 | 434 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 435 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 436 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 437 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 438 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 439 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 440 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 441 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 442 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 443 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 444 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 445 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 446 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 447 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 448 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 449 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 450 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 451 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 452 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 453 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 454 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 455 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 456 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 457 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 458 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 459 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 460 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 461 | //LED4 |
ivanyohuno | 4:64ecb3b6d1c7 | 462 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 463 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 464 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 465 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 466 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 467 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 468 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 469 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 470 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 471 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 472 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 473 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 474 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 475 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 476 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 477 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 478 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 479 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 480 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 481 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 482 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 483 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 484 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 485 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 486 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 487 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 488 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 489 | //LED5 |
ivanyohuno | 4:64ecb3b6d1c7 | 490 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 491 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 492 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 493 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 494 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 495 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 496 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 497 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 498 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 499 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 500 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 501 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 502 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 503 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 504 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 505 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 506 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 507 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 508 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 509 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 510 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 511 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 512 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 513 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 514 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 515 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 516 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 517 | //LED6 |
ivanyohuno | 4:64ecb3b6d1c7 | 518 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 519 | |
ivanyohuno | 4:64ecb3b6d1c7 | 520 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 521 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 522 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 523 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 524 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 525 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 526 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 527 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 528 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 529 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 530 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 531 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 532 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 533 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 534 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 535 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 536 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 537 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 538 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 539 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 540 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 541 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 542 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 543 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 544 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 545 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 546 | //LED7 |
ivanyohuno | 4:64ecb3b6d1c7 | 547 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 548 | spi2.write(g_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 549 | spi2.write(g_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 550 | spi2.write(g_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 551 | spi2.write(g_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 552 | spi2.write(g_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 553 | spi2.write(g_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 554 | spi2.write(g_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 555 | spi2.write(g_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 556 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 557 | spi2.write(r_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 558 | spi2.write(r_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 559 | spi2.write(r_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 560 | spi2.write(r_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 561 | spi2.write(r_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 562 | spi2.write(r_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 563 | spi2.write(r_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 564 | spi2.write(r_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 565 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 566 | spi2.write(b_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 567 | spi2.write(b_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 568 | spi2.write(b_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 569 | spi2.write(b_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 570 | spi2.write(b_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 571 | spi2.write(b_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 572 | spi2.write(b_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 573 | spi2.write(b_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 574 | |
ivanyohuno | 4:64ecb3b6d1c7 | 575 | //wait for latch |
ivanyohuno | 4:64ecb3b6d1c7 | 576 | wait_us(60); |
ivanyohuno | 4:64ecb3b6d1c7 | 577 | } |
ivanyohuno | 4:64ecb3b6d1c7 | 578 | |
ivanyohuno | 0:c350fa2f0c19 | 579 | |
ivanyohuno | 0:c350fa2f0c19 | 580 | |
ivanyohuno | 0:c350fa2f0c19 | 581 | void setRGBPixel(int r, int g, int b){ |
ivanyohuno | 0:c350fa2f0c19 | 582 | //translate int values to array of 0xF00 (0) and 0xFF0 (1) binary |
ivanyohuno | 0:c350fa2f0c19 | 583 | int r_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 584 | int g_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 585 | int b_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 586 | memcpy(r_array, decimalToBinary(r), sizeof(r_array)); |
ivanyohuno | 0:c350fa2f0c19 | 587 | memcpy(g_array, decimalToBinary(g), sizeof(g_array)); |
ivanyohuno | 0:c350fa2f0c19 | 588 | memcpy(b_array, decimalToBinary(b), sizeof(b_array)); |
ivanyohuno | 0:c350fa2f0c19 | 589 | |
ivanyohuno | 0:c350fa2f0c19 | 590 | //send commands to LED Driver |
ivanyohuno | 0:c350fa2f0c19 | 591 | //initialize SPI |
ivanyohuno | 0:c350fa2f0c19 | 592 | spi_init(); |
ivanyohuno | 0:c350fa2f0c19 | 593 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 594 | spi.write(g_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 595 | spi.write(g_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 596 | spi.write(g_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 597 | spi.write(g_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 598 | spi.write(g_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 599 | spi.write(g_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 600 | spi.write(g_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 601 | spi.write(g_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 602 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 603 | spi.write(r_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 604 | spi.write(r_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 605 | spi.write(r_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 606 | spi.write(r_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 607 | spi.write(r_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 608 | spi.write(r_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 609 | spi.write(r_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 610 | spi.write(r_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 611 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 612 | spi.write(b_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 613 | spi.write(b_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 614 | spi.write(b_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 615 | spi.write(b_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 616 | spi.write(b_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 617 | spi.write(b_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 618 | spi.write(b_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 619 | spi.write(b_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 620 | //wait for latch |
ivanyohuno | 0:c350fa2f0c19 | 621 | wait_us(60); |
ivanyohuno | 0:c350fa2f0c19 | 622 | } |
ivanyohuno | 0:c350fa2f0c19 | 623 | |
ivanyohuno | 4:64ecb3b6d1c7 | 624 | void setRGBPixels1(int colours[8][3]){ |
ivanyohuno | 0:c350fa2f0c19 | 625 | //translate int values to array of 0xF00 (0) and 0xFF0 (1) binary |
ivanyohuno | 0:c350fa2f0c19 | 626 | int r0_array[8]; //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 627 | int g0_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 628 | int b0_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 629 | memcpy(r0_array, decimalToBinary(colours[0][0]), sizeof(r0_array)); |
ivanyohuno | 0:c350fa2f0c19 | 630 | memcpy(g0_array, decimalToBinary(colours[0][1]), sizeof(g0_array)); |
ivanyohuno | 0:c350fa2f0c19 | 631 | memcpy(b0_array, decimalToBinary(colours[0][2]), sizeof(b0_array)); |
ivanyohuno | 0:c350fa2f0c19 | 632 | int r1_array[8]; //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 633 | int g1_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 634 | int b1_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 635 | memcpy(r1_array, decimalToBinary(colours[1][0]), sizeof(r1_array)); |
ivanyohuno | 0:c350fa2f0c19 | 636 | memcpy(g1_array, decimalToBinary(colours[1][1]), sizeof(g1_array)); |
ivanyohuno | 0:c350fa2f0c19 | 637 | memcpy(b1_array, decimalToBinary(colours[1][2]), sizeof(b1_array)); |
ivanyohuno | 0:c350fa2f0c19 | 638 | int r2_array[8]; //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 639 | int g2_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 640 | int b2_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 641 | memcpy(r2_array, decimalToBinary(colours[2][0]), sizeof(r2_array)); |
ivanyohuno | 0:c350fa2f0c19 | 642 | memcpy(g2_array, decimalToBinary(colours[2][1]), sizeof(g2_array)); |
ivanyohuno | 0:c350fa2f0c19 | 643 | memcpy(b2_array, decimalToBinary(colours[2][2]), sizeof(b2_array)); |
ivanyohuno | 0:c350fa2f0c19 | 644 | int r3_array[8]; //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 645 | int g3_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 646 | int b3_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 647 | memcpy(r3_array, decimalToBinary(colours[3][0]), sizeof(r3_array)); |
ivanyohuno | 0:c350fa2f0c19 | 648 | memcpy(g3_array, decimalToBinary(colours[3][1]), sizeof(g3_array)); |
ivanyohuno | 0:c350fa2f0c19 | 649 | memcpy(b3_array, decimalToBinary(colours[3][2]), sizeof(b3_array)); |
ivanyohuno | 0:c350fa2f0c19 | 650 | int r4_array[8]; //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 651 | int g4_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 652 | int b4_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 653 | memcpy(r4_array, decimalToBinary(colours[4][0]), sizeof(r4_array)); |
ivanyohuno | 0:c350fa2f0c19 | 654 | memcpy(g4_array, decimalToBinary(colours[4][1]), sizeof(g4_array)); |
ivanyohuno | 0:c350fa2f0c19 | 655 | memcpy(b4_array, decimalToBinary(colours[4][2]), sizeof(b4_array)); |
ivanyohuno | 0:c350fa2f0c19 | 656 | int r5_array[8]; //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 657 | int g5_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 658 | int b5_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 659 | memcpy(r5_array, decimalToBinary(colours[5][0]), sizeof(r5_array)); |
ivanyohuno | 0:c350fa2f0c19 | 660 | memcpy(g5_array, decimalToBinary(colours[5][1]), sizeof(g5_array)); |
ivanyohuno | 0:c350fa2f0c19 | 661 | memcpy(b5_array, decimalToBinary(colours[5][2]), sizeof(b5_array)); |
ivanyohuno | 0:c350fa2f0c19 | 662 | int r6_array[8]; //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 663 | int g6_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 664 | int b6_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 665 | memcpy(r6_array, decimalToBinary(colours[6][0]), sizeof(r6_array)); |
ivanyohuno | 0:c350fa2f0c19 | 666 | memcpy(g6_array, decimalToBinary(colours[6][1]), sizeof(g6_array)); |
ivanyohuno | 0:c350fa2f0c19 | 667 | memcpy(b6_array, decimalToBinary(colours[6][2]), sizeof(b6_array)); |
ivanyohuno | 0:c350fa2f0c19 | 668 | int r7_array[8]; //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 669 | int g7_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 670 | int b7_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 671 | memcpy(r7_array, decimalToBinary(colours[7][0]), sizeof(r7_array)); |
ivanyohuno | 0:c350fa2f0c19 | 672 | memcpy(g7_array, decimalToBinary(colours[7][1]), sizeof(g7_array)); |
ivanyohuno | 0:c350fa2f0c19 | 673 | memcpy(b7_array, decimalToBinary(colours[7][2]), sizeof(b7_array)); |
ivanyohuno | 0:c350fa2f0c19 | 674 | |
ivanyohuno | 0:c350fa2f0c19 | 675 | //send commands to LED Driver |
ivanyohuno | 0:c350fa2f0c19 | 676 | //initialize SPI |
ivanyohuno | 0:c350fa2f0c19 | 677 | spi_init(); |
ivanyohuno | 0:c350fa2f0c19 | 678 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 679 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 680 | spi.write(g0_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 681 | spi.write(g0_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 682 | spi.write(g0_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 683 | spi.write(g0_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 684 | spi.write(g0_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 685 | spi.write(g0_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 686 | spi.write(g0_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 687 | spi.write(g0_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 688 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 689 | spi.write(r0_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 690 | spi.write(r0_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 691 | spi.write(r0_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 692 | spi.write(r0_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 693 | spi.write(r0_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 694 | spi.write(r0_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 695 | spi.write(r0_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 696 | spi.write(r0_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 697 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 698 | spi.write(b0_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 699 | spi.write(b0_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 700 | spi.write(b0_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 701 | spi.write(b0_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 702 | spi.write(b0_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 703 | spi.write(b0_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 704 | spi.write(b0_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 705 | spi.write(b0_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 706 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 707 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 708 | spi.write(g1_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 709 | spi.write(g1_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 710 | spi.write(g1_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 711 | spi.write(g1_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 712 | spi.write(g1_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 713 | spi.write(g1_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 714 | spi.write(g1_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 715 | spi.write(g1_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 716 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 717 | spi.write(r1_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 718 | spi.write(r1_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 719 | spi.write(r1_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 720 | spi.write(r1_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 721 | spi.write(r1_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 722 | spi.write(r1_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 723 | spi.write(r1_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 724 | spi.write(r1_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 725 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 726 | spi.write(b1_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 727 | spi.write(b1_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 728 | spi.write(b1_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 729 | spi.write(b1_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 730 | spi.write(b1_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 731 | spi.write(b1_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 732 | spi.write(b1_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 733 | spi.write(b1_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 734 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 735 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 736 | spi.write(g2_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 737 | spi.write(g2_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 738 | spi.write(g2_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 739 | spi.write(g2_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 740 | spi.write(g2_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 741 | spi.write(g2_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 742 | spi.write(g2_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 743 | spi.write(g2_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 744 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 745 | spi.write(r2_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 746 | spi.write(r2_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 747 | spi.write(r2_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 748 | spi.write(r2_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 749 | spi.write(r2_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 750 | spi.write(r2_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 751 | spi.write(r2_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 752 | spi.write(r2_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 753 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 754 | spi.write(b2_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 755 | spi.write(b2_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 756 | spi.write(b2_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 757 | spi.write(b2_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 758 | spi.write(b2_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 759 | spi.write(b2_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 760 | spi.write(b2_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 761 | spi.write(b2_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 762 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 763 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 764 | spi.write(g3_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 765 | spi.write(g3_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 766 | spi.write(g3_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 767 | spi.write(g3_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 768 | spi.write(g3_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 769 | spi.write(g3_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 770 | spi.write(g3_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 771 | spi.write(g3_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 772 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 773 | spi.write(r3_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 774 | spi.write(r3_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 775 | spi.write(r3_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 776 | spi.write(r3_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 777 | spi.write(r3_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 778 | spi.write(r3_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 779 | spi.write(r3_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 780 | spi.write(r3_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 781 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 782 | spi.write(b3_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 783 | spi.write(b3_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 784 | spi.write(b3_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 785 | spi.write(b3_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 786 | spi.write(b3_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 787 | spi.write(b3_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 788 | spi.write(b3_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 789 | spi.write(b3_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 790 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 791 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 792 | spi.write(g4_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 793 | spi.write(g4_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 794 | spi.write(g4_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 795 | spi.write(g4_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 796 | spi.write(g4_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 797 | spi.write(g4_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 798 | spi.write(g4_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 799 | spi.write(g4_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 800 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 801 | spi.write(r4_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 802 | spi.write(r4_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 803 | spi.write(r4_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 804 | spi.write(r4_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 805 | spi.write(r4_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 806 | spi.write(r4_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 807 | spi.write(r4_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 808 | spi.write(r4_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 809 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 810 | spi.write(b4_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 811 | spi.write(b4_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 812 | spi.write(b4_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 813 | spi.write(b4_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 814 | spi.write(b4_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 815 | spi.write(b4_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 816 | spi.write(b4_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 817 | spi.write(b4_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 818 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 819 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 820 | spi.write(g5_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 821 | spi.write(g5_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 822 | spi.write(g5_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 823 | spi.write(g5_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 824 | spi.write(g5_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 825 | spi.write(g5_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 826 | spi.write(g5_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 827 | spi.write(g5_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 828 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 829 | spi.write(r5_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 830 | spi.write(r5_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 831 | spi.write(r5_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 832 | spi.write(r5_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 833 | spi.write(r5_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 834 | spi.write(r5_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 835 | spi.write(r5_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 836 | spi.write(r5_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 837 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 838 | spi.write(b5_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 839 | spi.write(b5_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 840 | spi.write(b5_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 841 | spi.write(b5_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 842 | spi.write(b5_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 843 | spi.write(b5_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 844 | spi.write(b5_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 845 | spi.write(b5_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 846 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 847 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 848 | spi.write(g6_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 849 | spi.write(g6_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 850 | spi.write(g6_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 851 | spi.write(g6_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 852 | spi.write(g6_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 853 | spi.write(g6_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 854 | spi.write(g6_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 855 | spi.write(g6_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 856 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 857 | spi.write(r6_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 858 | spi.write(r6_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 859 | spi.write(r6_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 860 | spi.write(r6_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 861 | spi.write(r6_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 862 | spi.write(r6_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 863 | spi.write(r6_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 864 | spi.write(r6_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 865 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 866 | spi.write(b6_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 867 | spi.write(b6_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 868 | spi.write(b6_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 869 | spi.write(b6_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 870 | spi.write(b6_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 871 | spi.write(b6_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 872 | spi.write(b6_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 873 | spi.write(b6_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 874 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 875 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 876 | spi.write(g7_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 877 | spi.write(g7_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 878 | spi.write(g7_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 879 | spi.write(g7_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 880 | spi.write(g7_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 881 | spi.write(g7_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 882 | spi.write(g7_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 883 | spi.write(g7_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 884 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 885 | spi.write(r7_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 886 | spi.write(r7_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 887 | spi.write(r7_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 888 | spi.write(r7_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 889 | spi.write(r7_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 890 | spi.write(r7_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 891 | spi.write(r7_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 892 | spi.write(r7_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 893 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 894 | spi.write(b7_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 895 | spi.write(b7_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 896 | spi.write(b7_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 897 | spi.write(b7_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 898 | spi.write(b7_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 899 | spi.write(b7_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 900 | spi.write(b7_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 901 | spi.write(b7_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 902 | //wait for latch |
ivanyohuno | 0:c350fa2f0c19 | 903 | wait_us(60); |
ivanyohuno | 0:c350fa2f0c19 | 904 | } |
ivanyohuno | 0:c350fa2f0c19 | 905 | |
ivanyohuno | 4:64ecb3b6d1c7 | 906 | void setRGBPixels2(int colours[8][3]){ |
ivanyohuno | 4:64ecb3b6d1c7 | 907 | //translate int values to array of 0xF00 (0) and 0xFF0 (1) binary |
ivanyohuno | 4:64ecb3b6d1c7 | 908 | int r0_array[8]; //LED0 |
ivanyohuno | 4:64ecb3b6d1c7 | 909 | int g0_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 910 | int b0_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 911 | memcpy(r0_array, decimalToBinary(colours[0][0]), sizeof(r0_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 912 | memcpy(g0_array, decimalToBinary(colours[0][1]), sizeof(g0_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 913 | memcpy(b0_array, decimalToBinary(colours[0][2]), sizeof(b0_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 914 | int r1_array[8]; //LED1 |
ivanyohuno | 4:64ecb3b6d1c7 | 915 | int g1_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 916 | int b1_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 917 | memcpy(r1_array, decimalToBinary(colours[1][0]), sizeof(r1_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 918 | memcpy(g1_array, decimalToBinary(colours[1][1]), sizeof(g1_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 919 | memcpy(b1_array, decimalToBinary(colours[1][2]), sizeof(b1_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 920 | int r2_array[8]; //LED2 |
ivanyohuno | 4:64ecb3b6d1c7 | 921 | int g2_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 922 | int b2_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 923 | memcpy(r2_array, decimalToBinary(colours[2][0]), sizeof(r2_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 924 | memcpy(g2_array, decimalToBinary(colours[2][1]), sizeof(g2_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 925 | memcpy(b2_array, decimalToBinary(colours[2][2]), sizeof(b2_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 926 | int r3_array[8]; //LED3 |
ivanyohuno | 4:64ecb3b6d1c7 | 927 | int g3_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 928 | int b3_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 929 | memcpy(r3_array, decimalToBinary(colours[3][0]), sizeof(r3_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 930 | memcpy(g3_array, decimalToBinary(colours[3][1]), sizeof(g3_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 931 | memcpy(b3_array, decimalToBinary(colours[3][2]), sizeof(b3_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 932 | int r4_array[8]; //LED4 |
ivanyohuno | 4:64ecb3b6d1c7 | 933 | int g4_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 934 | int b4_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 935 | memcpy(r4_array, decimalToBinary(colours[4][0]), sizeof(r4_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 936 | memcpy(g4_array, decimalToBinary(colours[4][1]), sizeof(g4_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 937 | memcpy(b4_array, decimalToBinary(colours[4][2]), sizeof(b4_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 938 | int r5_array[8]; //LED5 |
ivanyohuno | 4:64ecb3b6d1c7 | 939 | int g5_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 940 | int b5_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 941 | memcpy(r5_array, decimalToBinary(colours[5][0]), sizeof(r5_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 942 | memcpy(g5_array, decimalToBinary(colours[5][1]), sizeof(g5_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 943 | memcpy(b5_array, decimalToBinary(colours[5][2]), sizeof(b5_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 944 | int r6_array[8]; //LED6 |
ivanyohuno | 4:64ecb3b6d1c7 | 945 | int g6_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 946 | int b6_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 947 | memcpy(r6_array, decimalToBinary(colours[6][0]), sizeof(r6_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 948 | memcpy(g6_array, decimalToBinary(colours[6][1]), sizeof(g6_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 949 | memcpy(b6_array, decimalToBinary(colours[6][2]), sizeof(b6_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 950 | int r7_array[8]; //LED7 |
ivanyohuno | 4:64ecb3b6d1c7 | 951 | int g7_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 952 | int b7_array[8]; |
ivanyohuno | 4:64ecb3b6d1c7 | 953 | memcpy(r7_array, decimalToBinary(colours[7][0]), sizeof(r7_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 954 | memcpy(g7_array, decimalToBinary(colours[7][1]), sizeof(g7_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 955 | memcpy(b7_array, decimalToBinary(colours[7][2]), sizeof(b7_array)); |
ivanyohuno | 4:64ecb3b6d1c7 | 956 | |
ivanyohuno | 4:64ecb3b6d1c7 | 957 | //send commands to LED Driver |
ivanyohuno | 4:64ecb3b6d1c7 | 958 | //initialize SPI |
ivanyohuno | 4:64ecb3b6d1c7 | 959 | spi_init(); |
ivanyohuno | 4:64ecb3b6d1c7 | 960 | //LED0 |
ivanyohuno | 4:64ecb3b6d1c7 | 961 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 962 | spi2.write(g0_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 963 | spi2.write(g0_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 964 | spi2.write(g0_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 965 | spi2.write(g0_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 966 | spi2.write(g0_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 967 | spi2.write(g0_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 968 | spi2.write(g0_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 969 | spi2.write(g0_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 970 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 971 | spi2.write(r0_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 972 | spi2.write(r0_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 973 | spi2.write(r0_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 974 | spi2.write(r0_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 975 | spi2.write(r0_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 976 | spi2.write(r0_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 977 | spi2.write(r0_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 978 | spi2.write(r0_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 979 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 980 | spi2.write(b0_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 981 | spi2.write(b0_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 982 | spi2.write(b0_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 983 | spi2.write(b0_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 984 | spi2.write(b0_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 985 | spi2.write(b0_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 986 | spi2.write(b0_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 987 | spi2.write(b0_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 988 | //LED1 |
ivanyohuno | 4:64ecb3b6d1c7 | 989 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 990 | spi2.write(g1_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 991 | spi2.write(g1_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 992 | spi2.write(g1_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 993 | spi2.write(g1_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 994 | spi2.write(g1_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 995 | spi2.write(g1_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 996 | spi2.write(g1_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 997 | spi2.write(g1_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 998 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 999 | spi2.write(r1_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1000 | spi2.write(r1_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1001 | spi2.write(r1_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1002 | spi2.write(r1_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1003 | spi2.write(r1_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1004 | spi2.write(r1_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1005 | spi2.write(r1_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1006 | spi2.write(r1_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1007 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1008 | spi2.write(b1_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1009 | spi2.write(b1_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1010 | spi2.write(b1_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1011 | spi2.write(b1_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1012 | spi2.write(b1_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1013 | spi2.write(b1_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1014 | spi2.write(b1_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1015 | spi2.write(b1_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1016 | //LED2 |
ivanyohuno | 4:64ecb3b6d1c7 | 1017 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1018 | spi2.write(g2_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1019 | spi2.write(g2_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1020 | spi2.write(g2_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1021 | spi2.write(g2_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1022 | spi2.write(g2_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1023 | spi2.write(g2_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1024 | spi2.write(g2_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1025 | spi2.write(g2_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1026 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1027 | spi2.write(r2_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1028 | spi2.write(r2_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1029 | spi2.write(r2_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1030 | spi2.write(r2_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1031 | spi2.write(r2_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1032 | spi2.write(r2_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1033 | spi2.write(r2_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1034 | spi2.write(r2_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1035 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1036 | spi2.write(b2_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1037 | spi2.write(b2_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1038 | spi2.write(b2_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1039 | spi2.write(b2_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1040 | spi2.write(b2_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1041 | spi2.write(b2_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1042 | spi2.write(b2_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1043 | spi2.write(b2_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1044 | //LED3 |
ivanyohuno | 4:64ecb3b6d1c7 | 1045 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1046 | spi2.write(g3_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1047 | spi2.write(g3_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1048 | spi2.write(g3_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1049 | spi2.write(g3_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1050 | spi2.write(g3_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1051 | spi2.write(g3_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1052 | spi2.write(g3_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1053 | spi2.write(g3_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1054 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1055 | spi2.write(r3_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1056 | spi2.write(r3_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1057 | spi2.write(r3_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1058 | spi2.write(r3_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1059 | spi2.write(r3_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1060 | spi2.write(r3_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1061 | spi2.write(r3_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1062 | spi2.write(r3_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1063 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1064 | spi2.write(b3_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1065 | spi2.write(b3_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1066 | spi2.write(b3_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1067 | spi2.write(b3_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1068 | spi2.write(b3_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1069 | spi2.write(b3_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1070 | spi2.write(b3_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1071 | spi2.write(b3_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1072 | //LED4 |
ivanyohuno | 4:64ecb3b6d1c7 | 1073 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1074 | spi2.write(g4_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1075 | spi2.write(g4_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1076 | spi2.write(g4_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1077 | spi2.write(g4_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1078 | spi2.write(g4_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1079 | spi2.write(g4_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1080 | spi2.write(g4_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1081 | spi2.write(g4_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1082 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1083 | spi2.write(r4_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1084 | spi2.write(r4_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1085 | spi2.write(r4_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1086 | spi2.write(r4_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1087 | spi2.write(r4_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1088 | spi2.write(r4_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1089 | spi2.write(r4_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1090 | spi2.write(r4_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1091 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1092 | spi2.write(b4_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1093 | spi2.write(b4_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1094 | spi2.write(b4_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1095 | spi2.write(b4_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1096 | spi2.write(b4_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1097 | spi2.write(b4_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1098 | spi2.write(b4_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1099 | spi2.write(b4_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1100 | //LED5 |
ivanyohuno | 4:64ecb3b6d1c7 | 1101 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1102 | spi2.write(g5_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1103 | spi2.write(g5_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1104 | spi2.write(g5_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1105 | spi2.write(g5_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1106 | spi2.write(g5_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1107 | spi2.write(g5_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1108 | spi2.write(g5_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1109 | spi2.write(g5_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1110 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1111 | spi2.write(r5_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1112 | spi2.write(r5_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1113 | spi2.write(r5_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1114 | spi2.write(r5_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1115 | spi2.write(r5_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1116 | spi2.write(r5_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1117 | spi2.write(r5_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1118 | spi2.write(r5_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1119 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1120 | spi2.write(b5_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1121 | spi2.write(b5_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1122 | spi2.write(b5_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1123 | spi2.write(b5_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1124 | spi2.write(b5_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1125 | spi2.write(b5_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1126 | spi2.write(b5_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1127 | spi2.write(b5_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1128 | //LED6 |
ivanyohuno | 4:64ecb3b6d1c7 | 1129 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1130 | spi2.write(g6_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1131 | spi2.write(g6_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1132 | spi2.write(g6_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1133 | spi2.write(g6_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1134 | spi2.write(g6_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1135 | spi2.write(g6_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1136 | spi2.write(g6_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1137 | spi2.write(g6_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1138 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1139 | spi2.write(r6_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1140 | spi2.write(r6_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1141 | spi2.write(r6_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1142 | spi2.write(r6_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1143 | spi2.write(r6_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1144 | spi2.write(r6_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1145 | spi2.write(r6_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1146 | spi2.write(r6_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1147 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1148 | spi2.write(b6_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1149 | spi2.write(b6_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1150 | spi2.write(b6_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1151 | spi2.write(b6_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1152 | spi2.write(b6_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1153 | spi2.write(b6_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1154 | spi2.write(b6_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1155 | spi2.write(b6_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1156 | //LED7 |
ivanyohuno | 4:64ecb3b6d1c7 | 1157 | //set green bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1158 | spi2.write(g7_array[7]); //set g7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1159 | spi2.write(g7_array[6]); //set g6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1160 | spi2.write(g7_array[5]); //set g5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1161 | spi2.write(g7_array[4]); //set g4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1162 | spi2.write(g7_array[3]); //set g3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1163 | spi2.write(g7_array[2]); //set g2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1164 | spi2.write(g7_array[1]); //set g1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1165 | spi2.write(g7_array[0]);//set g0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1166 | //set red bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1167 | spi2.write(r7_array[7]);//set r7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1168 | spi2.write(r7_array[6]); //set r6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1169 | spi2.write(r7_array[5]); //set r5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1170 | spi2.write(r7_array[4]); //set r4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1171 | spi2.write(r7_array[3]); //set r3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1172 | spi2.write(r7_array[2]); //set r2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1173 | spi2.write(r7_array[1]); //set r1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1174 | spi2.write(r7_array[0]); //set r0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1175 | //set blue bits |
ivanyohuno | 4:64ecb3b6d1c7 | 1176 | spi2.write(b7_array[7]); //set b7 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1177 | spi2.write(b7_array[6]); //set b6 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1178 | spi2.write(b7_array[5]); //set b5 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1179 | spi2.write(b7_array[4]); //set b4 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1180 | spi2.write(b7_array[3]); //set b3 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1181 | spi2.write(b7_array[2]); //set b2 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1182 | spi2.write(b7_array[1]); //set b1 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1183 | spi2.write(b7_array[0]); //set b0 bit |
ivanyohuno | 4:64ecb3b6d1c7 | 1184 | //wait for latch |
ivanyohuno | 4:64ecb3b6d1c7 | 1185 | wait_us(60); |
ivanyohuno | 4:64ecb3b6d1c7 | 1186 | } |
ivanyohuno | 4:64ecb3b6d1c7 | 1187 | /* |
ivanyohuno | 2:35fd99de07b3 | 1188 | void setRGBFloor_1(int room1[8][3], int room2[8][3]){ |
ivanyohuno | 0:c350fa2f0c19 | 1189 | //translate int values to array of 0xF00 (0) and 0xFF0 (1) binary |
ivanyohuno | 0:c350fa2f0c19 | 1190 | //room1 |
ivanyohuno | 0:c350fa2f0c19 | 1191 | int r00_array[8]; //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 1192 | int g00_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1193 | int b00_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1194 | memcpy(r00_array, decimalToBinary(room1[0][0]), sizeof(r00_array)); |
ivanyohuno | 1:42b43fa7362f | 1195 | memcpy(g00_array, decimalToBinary(room1[0][1]), sizeof(g00_array)); |
ivanyohuno | 1:42b43fa7362f | 1196 | memcpy(b00_array, decimalToBinary(room1[0][2]), sizeof(b00_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1197 | int r01_array[8]; //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 1198 | int g01_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1199 | int b01_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1200 | memcpy(r01_array, decimalToBinary(room1[1][0]), sizeof(r01_array)); |
ivanyohuno | 1:42b43fa7362f | 1201 | memcpy(g01_array, decimalToBinary(room1[1][1]), sizeof(g01_array)); |
ivanyohuno | 1:42b43fa7362f | 1202 | memcpy(b01_array, decimalToBinary(room1[1][2]), sizeof(b01_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1203 | int r02_array[8]; //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 1204 | int g02_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1205 | int b02_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1206 | memcpy(r02_array, decimalToBinary(room1[2][0]), sizeof(r02_array)); |
ivanyohuno | 1:42b43fa7362f | 1207 | memcpy(g02_array, decimalToBinary(room1[2][1]), sizeof(g02_array)); |
ivanyohuno | 1:42b43fa7362f | 1208 | memcpy(b02_array, decimalToBinary(room1[2][2]), sizeof(b02_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1209 | int r03_array[8]; //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 1210 | int g03_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1211 | int b03_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1212 | memcpy(r03_array, decimalToBinary(room1[3][0]), sizeof(r03_array)); |
ivanyohuno | 1:42b43fa7362f | 1213 | memcpy(g03_array, decimalToBinary(room1[3][1]), sizeof(g03_array)); |
ivanyohuno | 1:42b43fa7362f | 1214 | memcpy(b03_array, decimalToBinary(room1[3][2]), sizeof(b03_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1215 | int r04_array[8]; //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 1216 | int g04_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1217 | int b04_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1218 | memcpy(r04_array, decimalToBinary(room1[4][0]), sizeof(r04_array)); |
ivanyohuno | 1:42b43fa7362f | 1219 | memcpy(g04_array, decimalToBinary(room1[4][1]), sizeof(g04_array)); |
ivanyohuno | 1:42b43fa7362f | 1220 | memcpy(b04_array, decimalToBinary(room1[4][2]), sizeof(b04_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1221 | int r05_array[8]; //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 1222 | int g05_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1223 | int b05_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1224 | memcpy(r05_array, decimalToBinary(room1[5][0]), sizeof(r05_array)); |
ivanyohuno | 1:42b43fa7362f | 1225 | memcpy(g05_array, decimalToBinary(room1[5][1]), sizeof(g05_array)); |
ivanyohuno | 1:42b43fa7362f | 1226 | memcpy(b05_array, decimalToBinary(room1[5][2]), sizeof(b05_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1227 | int r06_array[8]; //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 1228 | int g06_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1229 | int b06_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1230 | memcpy(r06_array, decimalToBinary(room1[6][0]), sizeof(r06_array)); |
ivanyohuno | 1:42b43fa7362f | 1231 | memcpy(g06_array, decimalToBinary(room1[6][1]), sizeof(g06_array)); |
ivanyohuno | 1:42b43fa7362f | 1232 | memcpy(b06_array, decimalToBinary(room1[6][2]), sizeof(b06_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1233 | int r07_array[8]; //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 1234 | int g07_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1235 | int b07_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1236 | memcpy(r07_array, decimalToBinary(room1[7][0]), sizeof(r07_array)); |
ivanyohuno | 1:42b43fa7362f | 1237 | memcpy(g07_array, decimalToBinary(room1[7][1]), sizeof(g07_array)); |
ivanyohuno | 1:42b43fa7362f | 1238 | memcpy(b07_array, decimalToBinary(room1[7][2]), sizeof(b07_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1239 | |
ivanyohuno | 0:c350fa2f0c19 | 1240 | //room2 |
ivanyohuno | 0:c350fa2f0c19 | 1241 | int r10_array[8]; //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 1242 | int g10_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1243 | int b10_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1244 | memcpy(r10_array, decimalToBinary(room2[0][0]), sizeof(r10_array)); |
ivanyohuno | 1:42b43fa7362f | 1245 | memcpy(g10_array, decimalToBinary(room2[0][1]), sizeof(g10_array)); |
ivanyohuno | 1:42b43fa7362f | 1246 | memcpy(b10_array, decimalToBinary(room2[0][2]), sizeof(b10_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1247 | int r11_array[8]; //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 1248 | int g11_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1249 | int b11_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1250 | memcpy(r11_array, decimalToBinary(room2[1][0]), sizeof(r11_array)); |
ivanyohuno | 1:42b43fa7362f | 1251 | memcpy(g11_array, decimalToBinary(room2[1][1]), sizeof(g11_array)); |
ivanyohuno | 1:42b43fa7362f | 1252 | memcpy(b11_array, decimalToBinary(room2[1][2]), sizeof(b11_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1253 | int r12_array[8]; //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 1254 | int g12_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1255 | int b12_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1256 | memcpy(r12_array, decimalToBinary(room2[2][0]), sizeof(r12_array)); |
ivanyohuno | 1:42b43fa7362f | 1257 | memcpy(g12_array, decimalToBinary(room2[2][1]), sizeof(g12_array)); |
ivanyohuno | 1:42b43fa7362f | 1258 | memcpy(b12_array, decimalToBinary(room2[2][2]), sizeof(b12_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1259 | int r13_array[8]; //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 1260 | int g13_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1261 | int b13_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1262 | memcpy(r13_array, decimalToBinary(room2[3][0]), sizeof(r13_array)); |
ivanyohuno | 1:42b43fa7362f | 1263 | memcpy(g13_array, decimalToBinary(room2[3][1]), sizeof(g13_array)); |
ivanyohuno | 1:42b43fa7362f | 1264 | memcpy(b13_array, decimalToBinary(room2[3][2]), sizeof(b13_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1265 | int r14_array[8]; //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 1266 | int g14_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1267 | int b14_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1268 | memcpy(r14_array, decimalToBinary(room2[4][0]), sizeof(r14_array)); |
ivanyohuno | 1:42b43fa7362f | 1269 | memcpy(g14_array, decimalToBinary(room2[4][1]), sizeof(g14_array)); |
ivanyohuno | 1:42b43fa7362f | 1270 | memcpy(b14_array, decimalToBinary(room2[4][2]), sizeof(b14_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1271 | int r15_array[8]; //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 1272 | int g15_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1273 | int b15_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1274 | memcpy(r15_array, decimalToBinary(room2[5][0]), sizeof(r15_array)); |
ivanyohuno | 1:42b43fa7362f | 1275 | memcpy(g15_array, decimalToBinary(room2[5][1]), sizeof(g15_array)); |
ivanyohuno | 1:42b43fa7362f | 1276 | memcpy(b15_array, decimalToBinary(room2[5][2]), sizeof(b15_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1277 | int r16_array[8]; //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 1278 | int g16_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1279 | int b16_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1280 | memcpy(r16_array, decimalToBinary(room2[6][0]), sizeof(r16_array)); |
ivanyohuno | 1:42b43fa7362f | 1281 | memcpy(g16_array, decimalToBinary(room2[6][1]), sizeof(g16_array)); |
ivanyohuno | 1:42b43fa7362f | 1282 | memcpy(b16_array, decimalToBinary(room2[6][2]), sizeof(b16_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1283 | int r17_array[8]; //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 1284 | int g17_array[8]; |
ivanyohuno | 0:c350fa2f0c19 | 1285 | int b17_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1286 | memcpy(r17_array, decimalToBinary(room2[7][0]), sizeof(r17_array)); |
ivanyohuno | 1:42b43fa7362f | 1287 | memcpy(g17_array, decimalToBinary(room2[7][1]), sizeof(g17_array)); |
ivanyohuno | 1:42b43fa7362f | 1288 | memcpy(b17_array, decimalToBinary(room2[7][2]), sizeof(b17_array)); |
ivanyohuno | 0:c350fa2f0c19 | 1289 | |
ivanyohuno | 0:c350fa2f0c19 | 1290 | //send commands to LED Driver |
ivanyohuno | 0:c350fa2f0c19 | 1291 | //initialize SPI |
ivanyohuno | 0:c350fa2f0c19 | 1292 | spi_init(); |
ivanyohuno | 0:c350fa2f0c19 | 1293 | //room1 |
ivanyohuno | 0:c350fa2f0c19 | 1294 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 1295 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1296 | spi.write(g00_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1297 | spi.write(g00_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1298 | spi.write(g00_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1299 | spi.write(g00_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1300 | spi.write(g00_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1301 | spi.write(g00_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1302 | spi.write(g00_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1303 | spi.write(g00_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1304 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1305 | spi.write(r00_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1306 | spi.write(r00_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1307 | spi.write(r00_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1308 | spi.write(r00_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1309 | spi.write(r00_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1310 | spi.write(r00_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1311 | spi.write(r00_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1312 | spi.write(r00_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1313 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1314 | spi.write(b00_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1315 | spi.write(b00_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1316 | spi.write(b00_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1317 | spi.write(b00_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1318 | spi.write(b00_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1319 | spi.write(b00_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1320 | spi.write(b00_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1321 | spi.write(b00_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1322 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 1323 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1324 | spi.write(g01_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1325 | spi.write(g01_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1326 | spi.write(g01_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1327 | spi.write(g01_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1328 | spi.write(g01_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1329 | spi.write(g01_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1330 | spi.write(g01_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1331 | spi.write(g01_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1332 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1333 | spi.write(r01_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1334 | spi.write(r01_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1335 | spi.write(r01_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1336 | spi.write(r01_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1337 | spi.write(r01_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1338 | spi.write(r01_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1339 | spi.write(r01_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1340 | spi.write(r01_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1341 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1342 | spi.write(b01_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1343 | spi.write(b01_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1344 | spi.write(b01_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1345 | spi.write(b01_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1346 | spi.write(b01_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1347 | spi.write(b01_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1348 | spi.write(b01_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1349 | spi.write(b01_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1350 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 1351 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1352 | spi.write(g02_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1353 | spi.write(g02_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1354 | spi.write(g02_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1355 | spi.write(g02_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1356 | spi.write(g02_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1357 | spi.write(g02_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1358 | spi.write(g02_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1359 | spi.write(g02_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1360 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1361 | spi.write(r02_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1362 | spi.write(r02_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1363 | spi.write(r02_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1364 | spi.write(r02_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1365 | spi.write(r02_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1366 | spi.write(r02_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1367 | spi.write(r02_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1368 | spi.write(r02_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1369 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1370 | spi.write(b02_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1371 | spi.write(b02_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1372 | spi.write(b02_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1373 | spi.write(b02_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1374 | spi.write(b02_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1375 | spi.write(b02_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1376 | spi.write(b02_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1377 | spi.write(b02_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1378 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 1379 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1380 | spi.write(g03_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1381 | spi.write(g03_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1382 | spi.write(g03_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1383 | spi.write(g03_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1384 | spi.write(g03_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1385 | spi.write(g03_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1386 | spi.write(g03_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1387 | spi.write(g03_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1388 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1389 | spi.write(r03_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1390 | spi.write(r03_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1391 | spi.write(r03_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1392 | spi.write(r03_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1393 | spi.write(r03_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1394 | spi.write(r03_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1395 | spi.write(r03_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1396 | spi.write(r03_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1397 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1398 | spi.write(b03_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1399 | spi.write(b03_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1400 | spi.write(b03_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1401 | spi.write(b03_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1402 | spi.write(b03_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1403 | spi.write(b03_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1404 | spi.write(b03_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1405 | spi.write(b03_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1406 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 1407 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1408 | spi.write(g04_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1409 | spi.write(g04_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1410 | spi.write(g04_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1411 | spi.write(g04_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1412 | spi.write(g04_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1413 | spi.write(g04_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1414 | spi.write(g04_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1415 | spi.write(g04_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1416 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1417 | spi.write(r04_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1418 | spi.write(r04_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1419 | spi.write(r04_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1420 | spi.write(r04_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1421 | spi.write(r04_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1422 | spi.write(r04_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1423 | spi.write(r04_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1424 | spi.write(r04_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1425 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1426 | spi.write(b04_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1427 | spi.write(b04_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1428 | spi.write(b04_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1429 | spi.write(b04_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1430 | spi.write(b04_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1431 | spi.write(b04_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1432 | spi.write(b04_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1433 | spi.write(b04_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1434 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 1435 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1436 | spi.write(g05_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1437 | spi.write(g05_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1438 | spi.write(g05_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1439 | spi.write(g05_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1440 | spi.write(g05_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1441 | spi.write(g05_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1442 | spi.write(g05_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1443 | spi.write(g05_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1444 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1445 | spi.write(r05_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1446 | spi.write(r05_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1447 | spi.write(r05_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1448 | spi.write(r05_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1449 | spi.write(r05_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1450 | spi.write(r05_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1451 | spi.write(r05_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1452 | spi.write(r05_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1453 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1454 | spi.write(b05_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1455 | spi.write(b05_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1456 | spi.write(b05_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1457 | spi.write(b05_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1458 | spi.write(b05_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1459 | spi.write(b05_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1460 | spi.write(b05_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1461 | spi.write(b05_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1462 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 1463 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1464 | spi.write(g06_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1465 | spi.write(g06_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1466 | spi.write(g06_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1467 | spi.write(g06_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1468 | spi.write(g06_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1469 | spi.write(g06_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1470 | spi.write(g06_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1471 | spi.write(g06_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1472 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1473 | spi.write(r06_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1474 | spi.write(r06_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1475 | spi.write(r06_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1476 | spi.write(r06_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1477 | spi.write(r06_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1478 | spi.write(r06_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1479 | spi.write(r06_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1480 | spi.write(r06_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1481 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1482 | spi.write(b06_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1483 | spi.write(b06_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1484 | spi.write(b06_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1485 | spi.write(b06_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1486 | spi.write(b06_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1487 | spi.write(b06_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1488 | spi.write(b06_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1489 | spi.write(b06_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1490 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 1491 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1492 | spi.write(g07_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1493 | spi.write(g07_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1494 | spi.write(g07_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1495 | spi.write(g07_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1496 | spi.write(g07_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1497 | spi.write(g07_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1498 | spi.write(g07_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1499 | spi.write(g07_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1500 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1501 | spi.write(r07_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1502 | spi.write(r07_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1503 | spi.write(r07_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1504 | spi.write(r07_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1505 | spi.write(r07_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1506 | spi.write(r07_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1507 | spi.write(r07_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1508 | spi.write(r07_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1509 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1510 | spi.write(b07_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1511 | spi.write(b07_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1512 | spi.write(b07_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1513 | spi.write(b07_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1514 | spi.write(b07_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1515 | spi.write(b07_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1516 | spi.write(b07_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1517 | spi.write(b07_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1518 | //room2 |
ivanyohuno | 0:c350fa2f0c19 | 1519 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 1520 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1521 | spi.write(g10_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1522 | spi.write(g10_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1523 | spi.write(g10_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1524 | spi.write(g10_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1525 | spi.write(g10_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1526 | spi.write(g10_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1527 | spi.write(g10_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1528 | spi.write(g10_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1529 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1530 | spi.write(r10_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1531 | spi.write(r10_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1532 | spi.write(r10_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1533 | spi.write(r10_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1534 | spi.write(r10_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1535 | spi.write(r10_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1536 | spi.write(r10_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1537 | spi.write(r10_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1538 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1539 | spi.write(b10_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1540 | spi.write(b10_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1541 | spi.write(b10_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1542 | spi.write(b10_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1543 | spi.write(b10_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1544 | spi.write(b10_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1545 | spi.write(b10_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1546 | spi.write(b10_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1547 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 1548 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1549 | spi.write(g11_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1550 | spi.write(g11_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1551 | spi.write(g11_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1552 | spi.write(g11_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1553 | spi.write(g11_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1554 | spi.write(g11_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1555 | spi.write(g11_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1556 | spi.write(g11_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1557 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1558 | spi.write(r11_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1559 | spi.write(r11_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1560 | spi.write(r11_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1561 | spi.write(r11_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1562 | spi.write(r11_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1563 | spi.write(r11_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1564 | spi.write(r11_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1565 | spi.write(r11_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1566 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1567 | spi.write(b11_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1568 | spi.write(b11_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1569 | spi.write(b11_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1570 | spi.write(b11_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1571 | spi.write(b11_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1572 | spi.write(b11_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1573 | spi.write(b11_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1574 | spi.write(b11_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1575 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 1576 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1577 | spi.write(g12_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1578 | spi.write(g12_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1579 | spi.write(g12_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1580 | spi.write(g12_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1581 | spi.write(g12_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1582 | spi.write(g12_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1583 | spi.write(g12_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1584 | spi.write(g12_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1585 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1586 | spi.write(r12_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1587 | spi.write(r12_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1588 | spi.write(r12_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1589 | spi.write(r12_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1590 | spi.write(r12_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1591 | spi.write(r12_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1592 | spi.write(r12_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1593 | spi.write(r12_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1594 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1595 | spi.write(b12_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1596 | spi.write(b12_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1597 | spi.write(b12_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1598 | spi.write(b12_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1599 | spi.write(b12_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1600 | spi.write(b12_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1601 | spi.write(b12_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1602 | spi.write(b12_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1603 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 1604 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1605 | spi.write(g13_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1606 | spi.write(g13_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1607 | spi.write(g13_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1608 | spi.write(g13_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1609 | spi.write(g13_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1610 | spi.write(g13_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1611 | spi.write(g13_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1612 | spi.write(g13_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1613 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1614 | spi.write(r13_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1615 | spi.write(r13_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1616 | spi.write(r13_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1617 | spi.write(r13_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1618 | spi.write(r13_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1619 | spi.write(r13_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1620 | spi.write(r13_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1621 | spi.write(r13_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1622 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1623 | spi.write(b13_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1624 | spi.write(b13_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1625 | spi.write(b13_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1626 | spi.write(b13_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1627 | spi.write(b13_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1628 | spi.write(b13_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1629 | spi.write(b13_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1630 | spi.write(b13_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1631 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 1632 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1633 | spi.write(g14_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1634 | spi.write(g14_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1635 | spi.write(g14_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1636 | spi.write(g14_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1637 | spi.write(g14_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1638 | spi.write(g14_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1639 | spi.write(g14_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1640 | spi.write(g14_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1641 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1642 | spi.write(r14_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1643 | spi.write(r14_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1644 | spi.write(r14_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1645 | spi.write(r14_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1646 | spi.write(r14_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1647 | spi.write(r14_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1648 | spi.write(r14_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1649 | spi.write(r14_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1650 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1651 | spi.write(b14_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1652 | spi.write(b14_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1653 | spi.write(b14_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1654 | spi.write(b14_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1655 | spi.write(b14_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1656 | spi.write(b14_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1657 | spi.write(b14_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1658 | spi.write(b14_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1659 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 1660 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1661 | spi.write(g15_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1662 | spi.write(g15_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1663 | spi.write(g15_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1664 | spi.write(g15_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1665 | spi.write(g15_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1666 | spi.write(g15_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1667 | spi.write(g15_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1668 | spi.write(g15_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1669 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1670 | spi.write(r15_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1671 | spi.write(r15_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1672 | spi.write(r15_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1673 | spi.write(r15_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1674 | spi.write(r15_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1675 | spi.write(r15_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1676 | spi.write(r15_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1677 | spi.write(r15_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1678 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1679 | spi.write(b15_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1680 | spi.write(b15_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1681 | spi.write(b15_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1682 | spi.write(b15_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1683 | spi.write(b15_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1684 | spi.write(b15_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1685 | spi.write(b15_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1686 | spi.write(b15_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1687 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 1688 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1689 | spi.write(g16_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1690 | spi.write(g16_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1691 | spi.write(g16_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1692 | spi.write(g16_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1693 | spi.write(g16_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1694 | spi.write(g16_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1695 | spi.write(g16_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1696 | spi.write(g16_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1697 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1698 | spi.write(r16_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1699 | spi.write(r16_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1700 | spi.write(r16_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1701 | spi.write(r16_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1702 | spi.write(r16_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1703 | spi.write(r16_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1704 | spi.write(r16_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1705 | spi.write(r16_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1706 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1707 | spi.write(b16_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1708 | spi.write(b16_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1709 | spi.write(b16_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1710 | spi.write(b16_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1711 | spi.write(b16_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1712 | spi.write(b16_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1713 | spi.write(b16_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1714 | spi.write(b16_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1715 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 1716 | //set green bits |
ivanyohuno | 0:c350fa2f0c19 | 1717 | spi.write(g17_array[7]); //set g7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1718 | spi.write(g17_array[6]); //set g6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1719 | spi.write(g17_array[5]); //set g5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1720 | spi.write(g17_array[4]); //set g4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1721 | spi.write(g17_array[3]); //set g3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1722 | spi.write(g17_array[2]); //set g2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1723 | spi.write(g17_array[1]); //set g1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1724 | spi.write(g17_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1725 | //set red bits |
ivanyohuno | 0:c350fa2f0c19 | 1726 | spi.write(r17_array[7]);//set r7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1727 | spi.write(r17_array[6]); //set r6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1728 | spi.write(r17_array[5]); //set r5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1729 | spi.write(r17_array[4]); //set r4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1730 | spi.write(r17_array[3]); //set r3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1731 | spi.write(r17_array[2]); //set r2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1732 | spi.write(r17_array[1]); //set r1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1733 | spi.write(r17_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1734 | //set blue bits |
ivanyohuno | 0:c350fa2f0c19 | 1735 | spi.write(b17_array[7]); //set b7 bit |
ivanyohuno | 0:c350fa2f0c19 | 1736 | spi.write(b17_array[6]); //set b6 bit |
ivanyohuno | 0:c350fa2f0c19 | 1737 | spi.write(b17_array[5]); //set b5 bit |
ivanyohuno | 0:c350fa2f0c19 | 1738 | spi.write(b17_array[4]); //set b4 bit |
ivanyohuno | 0:c350fa2f0c19 | 1739 | spi.write(b17_array[3]); //set b3 bit |
ivanyohuno | 0:c350fa2f0c19 | 1740 | spi.write(b17_array[2]); //set b2 bit |
ivanyohuno | 0:c350fa2f0c19 | 1741 | spi.write(b17_array[1]); //set b1 bit |
ivanyohuno | 0:c350fa2f0c19 | 1742 | spi.write(b17_array[0]); //set b0 bit |
ivanyohuno | 1:42b43fa7362f | 1743 | |
ivanyohuno | 1:42b43fa7362f | 1744 | //wait for latch |
ivanyohuno | 1:42b43fa7362f | 1745 | wait_us(60); |
ivanyohuno | 1:42b43fa7362f | 1746 | } |
ivanyohuno | 1:42b43fa7362f | 1747 | |
ivanyohuno | 1:42b43fa7362f | 1748 | void setRGBFloor_2(int room3[8][3], int room4[8][3]){ |
ivanyohuno | 1:42b43fa7362f | 1749 | //translate int values to array of 0xF00 (0) and 0xFF0 (1) binary |
ivanyohuno | 2:35fd99de07b3 | 1750 | //room3 |
ivanyohuno | 1:42b43fa7362f | 1751 | int r00_array[8]; //LED0 |
ivanyohuno | 1:42b43fa7362f | 1752 | int g00_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1753 | int b00_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1754 | memcpy(r00_array, decimalToBinary(room3[0][0]), sizeof(r00_array)); |
ivanyohuno | 1:42b43fa7362f | 1755 | memcpy(g00_array, decimalToBinary(room3[0][1]), sizeof(g00_array)); |
ivanyohuno | 1:42b43fa7362f | 1756 | memcpy(b00_array, decimalToBinary(room3[0][2]), sizeof(b00_array)); |
ivanyohuno | 1:42b43fa7362f | 1757 | int r01_array[8]; //LED1 |
ivanyohuno | 1:42b43fa7362f | 1758 | int g01_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1759 | int b01_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1760 | memcpy(r01_array, decimalToBinary(room3[1][0]), sizeof(r01_array)); |
ivanyohuno | 1:42b43fa7362f | 1761 | memcpy(g01_array, decimalToBinary(room3[1][1]), sizeof(g01_array)); |
ivanyohuno | 1:42b43fa7362f | 1762 | memcpy(b01_array, decimalToBinary(room3[1][2]), sizeof(b01_array)); |
ivanyohuno | 1:42b43fa7362f | 1763 | int r02_array[8]; //LED2 |
ivanyohuno | 1:42b43fa7362f | 1764 | int g02_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1765 | int b02_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1766 | memcpy(r02_array, decimalToBinary(room3[2][0]), sizeof(r02_array)); |
ivanyohuno | 1:42b43fa7362f | 1767 | memcpy(g02_array, decimalToBinary(room3[2][1]), sizeof(g02_array)); |
ivanyohuno | 1:42b43fa7362f | 1768 | memcpy(b02_array, decimalToBinary(room3[2][2]), sizeof(b02_array)); |
ivanyohuno | 1:42b43fa7362f | 1769 | int r03_array[8]; //LED3 |
ivanyohuno | 1:42b43fa7362f | 1770 | int g03_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1771 | int b03_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1772 | memcpy(r03_array, decimalToBinary(room3[3][0]), sizeof(r03_array)); |
ivanyohuno | 1:42b43fa7362f | 1773 | memcpy(g03_array, decimalToBinary(room3[3][1]), sizeof(g03_array)); |
ivanyohuno | 1:42b43fa7362f | 1774 | memcpy(b03_array, decimalToBinary(room3[3][2]), sizeof(b03_array)); |
ivanyohuno | 1:42b43fa7362f | 1775 | int r04_array[8]; //LED4 |
ivanyohuno | 1:42b43fa7362f | 1776 | int g04_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1777 | int b04_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1778 | memcpy(r04_array, decimalToBinary(room3[4][0]), sizeof(r04_array)); |
ivanyohuno | 1:42b43fa7362f | 1779 | memcpy(g04_array, decimalToBinary(room3[4][1]), sizeof(g04_array)); |
ivanyohuno | 1:42b43fa7362f | 1780 | memcpy(b04_array, decimalToBinary(room3[4][2]), sizeof(b04_array)); |
ivanyohuno | 1:42b43fa7362f | 1781 | int r05_array[8]; //LED5 |
ivanyohuno | 1:42b43fa7362f | 1782 | int g05_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1783 | int b05_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1784 | memcpy(r05_array, decimalToBinary(room3[5][0]), sizeof(r05_array)); |
ivanyohuno | 1:42b43fa7362f | 1785 | memcpy(g05_array, decimalToBinary(room3[5][1]), sizeof(g05_array)); |
ivanyohuno | 1:42b43fa7362f | 1786 | memcpy(b05_array, decimalToBinary(room3[5][2]), sizeof(b05_array)); |
ivanyohuno | 1:42b43fa7362f | 1787 | int r06_array[8]; //LED6 |
ivanyohuno | 1:42b43fa7362f | 1788 | int g06_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1789 | int b06_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1790 | memcpy(r06_array, decimalToBinary(room3[6][0]), sizeof(r06_array)); |
ivanyohuno | 1:42b43fa7362f | 1791 | memcpy(g06_array, decimalToBinary(room3[6][1]), sizeof(g06_array)); |
ivanyohuno | 1:42b43fa7362f | 1792 | memcpy(b06_array, decimalToBinary(room3[6][2]), sizeof(b06_array)); |
ivanyohuno | 1:42b43fa7362f | 1793 | int r07_array[8]; //LED7 |
ivanyohuno | 1:42b43fa7362f | 1794 | int g07_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1795 | int b07_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1796 | memcpy(r07_array, decimalToBinary(room3[7][0]), sizeof(r07_array)); |
ivanyohuno | 1:42b43fa7362f | 1797 | memcpy(g07_array, decimalToBinary(room3[7][1]), sizeof(g07_array)); |
ivanyohuno | 1:42b43fa7362f | 1798 | memcpy(b07_array, decimalToBinary(room3[7][2]), sizeof(b07_array)); |
ivanyohuno | 1:42b43fa7362f | 1799 | |
ivanyohuno | 1:42b43fa7362f | 1800 | //room4 |
ivanyohuno | 1:42b43fa7362f | 1801 | int r10_array[8]; //LED0 |
ivanyohuno | 1:42b43fa7362f | 1802 | int g10_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1803 | int b10_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1804 | memcpy(r10_array, decimalToBinary(room4[0][0]), sizeof(r10_array)); |
ivanyohuno | 1:42b43fa7362f | 1805 | memcpy(g10_array, decimalToBinary(room4[0][1]), sizeof(g10_array)); |
ivanyohuno | 1:42b43fa7362f | 1806 | memcpy(b10_array, decimalToBinary(room4[0][2]), sizeof(b10_array)); |
ivanyohuno | 1:42b43fa7362f | 1807 | int r11_array[8]; //LED1 |
ivanyohuno | 1:42b43fa7362f | 1808 | int g11_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1809 | int b11_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1810 | memcpy(r11_array, decimalToBinary(room4[1][0]), sizeof(r11_array)); |
ivanyohuno | 1:42b43fa7362f | 1811 | memcpy(g11_array, decimalToBinary(room4[1][1]), sizeof(g11_array)); |
ivanyohuno | 1:42b43fa7362f | 1812 | memcpy(b11_array, decimalToBinary(room4[1][2]), sizeof(b11_array)); |
ivanyohuno | 1:42b43fa7362f | 1813 | int r12_array[8]; //LED2 |
ivanyohuno | 1:42b43fa7362f | 1814 | int g12_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1815 | int b12_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1816 | memcpy(r12_array, decimalToBinary(room4[2][0]), sizeof(r12_array)); |
ivanyohuno | 1:42b43fa7362f | 1817 | memcpy(g12_array, decimalToBinary(room4[2][1]), sizeof(g12_array)); |
ivanyohuno | 1:42b43fa7362f | 1818 | memcpy(b12_array, decimalToBinary(room4[2][2]), sizeof(b12_array)); |
ivanyohuno | 1:42b43fa7362f | 1819 | int r13_array[8]; //LED3 |
ivanyohuno | 1:42b43fa7362f | 1820 | int g13_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1821 | int b13_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1822 | memcpy(r13_array, decimalToBinary(room4[3][0]), sizeof(r13_array)); |
ivanyohuno | 1:42b43fa7362f | 1823 | memcpy(g13_array, decimalToBinary(room4[3][1]), sizeof(g13_array)); |
ivanyohuno | 1:42b43fa7362f | 1824 | memcpy(b13_array, decimalToBinary(room4[3][2]), sizeof(b13_array)); |
ivanyohuno | 1:42b43fa7362f | 1825 | int r14_array[8]; //LED4 |
ivanyohuno | 1:42b43fa7362f | 1826 | int g14_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1827 | int b14_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1828 | memcpy(r14_array, decimalToBinary(room4[4][0]), sizeof(r14_array)); |
ivanyohuno | 1:42b43fa7362f | 1829 | memcpy(g14_array, decimalToBinary(room4[4][1]), sizeof(g14_array)); |
ivanyohuno | 1:42b43fa7362f | 1830 | memcpy(b14_array, decimalToBinary(room4[4][2]), sizeof(b14_array)); |
ivanyohuno | 1:42b43fa7362f | 1831 | int r15_array[8]; //LED5 |
ivanyohuno | 1:42b43fa7362f | 1832 | int g15_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1833 | int b15_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1834 | memcpy(r15_array, decimalToBinary(room4[5][0]), sizeof(r15_array)); |
ivanyohuno | 1:42b43fa7362f | 1835 | memcpy(g15_array, decimalToBinary(room4[5][1]), sizeof(g15_array)); |
ivanyohuno | 1:42b43fa7362f | 1836 | memcpy(b15_array, decimalToBinary(room4[5][2]), sizeof(b15_array)); |
ivanyohuno | 1:42b43fa7362f | 1837 | int r16_array[8]; //LED6 |
ivanyohuno | 1:42b43fa7362f | 1838 | int g16_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1839 | int b16_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1840 | memcpy(r16_array, decimalToBinary(room4[6][0]), sizeof(r16_array)); |
ivanyohuno | 1:42b43fa7362f | 1841 | memcpy(g16_array, decimalToBinary(room4[6][1]), sizeof(g16_array)); |
ivanyohuno | 1:42b43fa7362f | 1842 | memcpy(b16_array, decimalToBinary(room4[6][2]), sizeof(b16_array)); |
ivanyohuno | 1:42b43fa7362f | 1843 | int r17_array[8]; //LED7 |
ivanyohuno | 1:42b43fa7362f | 1844 | int g17_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1845 | int b17_array[8]; |
ivanyohuno | 1:42b43fa7362f | 1846 | memcpy(r17_array, decimalToBinary(room4[7][0]), sizeof(r17_array)); |
ivanyohuno | 1:42b43fa7362f | 1847 | memcpy(g17_array, decimalToBinary(room4[7][1]), sizeof(g17_array)); |
ivanyohuno | 1:42b43fa7362f | 1848 | memcpy(b17_array, decimalToBinary(room4[7][2]), sizeof(b17_array)); |
ivanyohuno | 1:42b43fa7362f | 1849 | |
ivanyohuno | 1:42b43fa7362f | 1850 | //send commands to LED Driver |
ivanyohuno | 1:42b43fa7362f | 1851 | //initialize SPI |
ivanyohuno | 1:42b43fa7362f | 1852 | spi_init(); |
ivanyohuno | 0:c350fa2f0c19 | 1853 | //room3 |
ivanyohuno | 0:c350fa2f0c19 | 1854 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 1855 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1856 | spi2.write(g00_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1857 | spi2.write(g00_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1858 | spi2.write(g00_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1859 | spi2.write(g00_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 1860 | spi2.write(g00_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 1861 | spi2.write(g00_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 1862 | spi2.write(g00_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 1863 | spi2.write(g00_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1864 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 1865 | spi2.write(r00_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 1866 | spi2.write(r00_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 1867 | spi2.write(r00_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 1868 | spi2.write(r00_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 1869 | spi2.write(r00_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 1870 | spi2.write(r00_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 1871 | spi2.write(r00_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 1872 | spi2.write(r00_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1873 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 1874 | spi2.write(b00_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 1875 | spi2.write(b00_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 1876 | spi2.write(b00_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 1877 | spi2.write(b00_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 1878 | spi2.write(b00_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 1879 | spi2.write(b00_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 1880 | spi2.write(b00_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 1881 | spi2.write(b00_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1882 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 1883 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1884 | spi2.write(g01_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1885 | spi2.write(g01_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1886 | spi2.write(g01_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1887 | spi2.write(g01_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 1888 | spi2.write(g01_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 1889 | spi2.write(g01_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 1890 | spi2.write(g01_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 1891 | spi2.write(g01_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1892 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 1893 | spi2.write(r01_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 1894 | spi2.write(r01_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 1895 | spi2.write(r01_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 1896 | spi2.write(r01_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 1897 | spi2.write(r01_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 1898 | spi2.write(r01_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 1899 | spi2.write(r01_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 1900 | spi2.write(r01_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1901 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 1902 | spi2.write(b01_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 1903 | spi2.write(b01_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 1904 | spi2.write(b01_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 1905 | spi2.write(b01_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 1906 | spi2.write(b01_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 1907 | spi2.write(b01_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 1908 | spi2.write(b01_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 1909 | spi2.write(b01_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1910 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 1911 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1912 | spi2.write(g02_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1913 | spi2.write(g02_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1914 | spi2.write(g02_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1915 | spi2.write(g02_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 1916 | spi2.write(g02_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 1917 | spi2.write(g02_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 1918 | spi2.write(g02_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 1919 | spi2.write(g02_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1920 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 1921 | spi2.write(r02_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 1922 | spi2.write(r02_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 1923 | spi2.write(r02_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 1924 | spi2.write(r02_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 1925 | spi2.write(r02_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 1926 | spi2.write(r02_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 1927 | spi2.write(r02_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 1928 | spi2.write(r02_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1929 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 1930 | spi2.write(b02_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 1931 | spi2.write(b02_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 1932 | spi2.write(b02_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 1933 | spi2.write(b02_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 1934 | spi2.write(b02_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 1935 | spi2.write(b02_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 1936 | spi2.write(b02_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 1937 | spi2.write(b02_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1938 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 1939 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1940 | spi2.write(g03_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1941 | spi2.write(g03_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1942 | spi2.write(g03_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1943 | spi2.write(g03_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 1944 | spi2.write(g03_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 1945 | spi2.write(g03_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 1946 | spi2.write(g03_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 1947 | spi2.write(g03_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1948 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 1949 | spi2.write(r03_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 1950 | spi2.write(r03_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 1951 | spi2.write(r03_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 1952 | spi2.write(r03_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 1953 | spi2.write(r03_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 1954 | spi2.write(r03_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 1955 | spi2.write(r03_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 1956 | spi2.write(r03_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1957 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 1958 | spi2.write(b03_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 1959 | spi2.write(b03_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 1960 | spi2.write(b03_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 1961 | spi2.write(b03_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 1962 | spi2.write(b03_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 1963 | spi2.write(b03_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 1964 | spi2.write(b03_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 1965 | spi2.write(b03_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1966 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 1967 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1968 | spi2.write(g04_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1969 | spi2.write(g04_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1970 | spi2.write(g04_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1971 | spi2.write(g04_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 1972 | spi2.write(g04_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 1973 | spi2.write(g04_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 1974 | spi2.write(g04_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 1975 | spi2.write(g04_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1976 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 1977 | spi2.write(r04_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 1978 | spi2.write(r04_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 1979 | spi2.write(r04_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 1980 | spi2.write(r04_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 1981 | spi2.write(r04_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 1982 | spi2.write(r04_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 1983 | spi2.write(r04_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 1984 | spi2.write(r04_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1985 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 1986 | spi2.write(b04_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 1987 | spi2.write(b04_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 1988 | spi2.write(b04_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 1989 | spi2.write(b04_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 1990 | spi2.write(b04_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 1991 | spi2.write(b04_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 1992 | spi2.write(b04_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 1993 | spi2.write(b04_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 1994 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 1995 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 1996 | spi2.write(g05_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 1997 | spi2.write(g05_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 1998 | spi2.write(g05_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 1999 | spi2.write(g05_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2000 | spi2.write(g05_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2001 | spi2.write(g05_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2002 | spi2.write(g05_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2003 | spi2.write(g05_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2004 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2005 | spi2.write(r05_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2006 | spi2.write(r05_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2007 | spi2.write(r05_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2008 | spi2.write(r05_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2009 | spi2.write(r05_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2010 | spi2.write(r05_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2011 | spi2.write(r05_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2012 | spi2.write(r05_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2013 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2014 | spi2.write(b05_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2015 | spi2.write(b05_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2016 | spi2.write(b05_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2017 | spi2.write(b05_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2018 | spi2.write(b05_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2019 | spi2.write(b05_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2020 | spi2.write(b05_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2021 | spi2.write(b05_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2022 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 2023 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2024 | spi2.write(g06_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2025 | spi2.write(g06_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2026 | spi2.write(g06_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2027 | spi2.write(g06_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2028 | spi2.write(g06_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2029 | spi2.write(g06_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2030 | spi2.write(g06_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2031 | spi2.write(g06_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2032 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2033 | spi2.write(r06_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2034 | spi2.write(r06_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2035 | spi2.write(r06_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2036 | spi2.write(r06_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2037 | spi2.write(r06_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2038 | spi2.write(r06_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2039 | spi2.write(r06_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2040 | spi2.write(r06_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2041 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2042 | spi2.write(b06_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2043 | spi2.write(b06_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2044 | spi2.write(b06_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2045 | spi2.write(b06_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2046 | spi2.write(b06_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2047 | spi2.write(b06_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2048 | spi2.write(b06_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2049 | spi2.write(b06_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2050 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 2051 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2052 | spi2.write(g07_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2053 | spi2.write(g07_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2054 | spi2.write(g07_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2055 | spi2.write(g07_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2056 | spi2.write(g07_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2057 | spi2.write(g07_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2058 | spi2.write(g07_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2059 | spi2.write(g07_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2060 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2061 | spi2.write(r07_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2062 | spi2.write(r07_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2063 | spi2.write(r07_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2064 | spi2.write(r07_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2065 | spi2.write(r07_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2066 | spi2.write(r07_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2067 | spi2.write(r07_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2068 | spi2.write(r07_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2069 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2070 | spi2.write(b07_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2071 | spi2.write(b07_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2072 | spi2.write(b07_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2073 | spi2.write(b07_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2074 | spi2.write(b07_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2075 | spi2.write(b07_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2076 | spi2.write(b07_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2077 | spi2.write(b07_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2078 | //room4 |
ivanyohuno | 0:c350fa2f0c19 | 2079 | //LED0 |
ivanyohuno | 0:c350fa2f0c19 | 2080 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2081 | spi2.write(g10_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2082 | spi2.write(g10_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2083 | spi2.write(g10_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2084 | spi2.write(g10_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2085 | spi2.write(g10_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2086 | spi2.write(g10_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2087 | spi2.write(g10_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2088 | spi2.write(g10_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2089 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2090 | spi2.write(r10_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2091 | spi2.write(r10_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2092 | spi2.write(r10_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2093 | spi2.write(r10_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2094 | spi2.write(r10_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2095 | spi2.write(r10_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2096 | spi2.write(r10_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2097 | spi2.write(r10_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2098 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2099 | spi2.write(b10_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2100 | spi2.write(b10_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2101 | spi2.write(b10_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2102 | spi2.write(b10_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2103 | spi2.write(b10_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2104 | spi2.write(b10_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2105 | spi2.write(b10_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2106 | spi2.write(b10_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2107 | //LED1 |
ivanyohuno | 0:c350fa2f0c19 | 2108 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2109 | spi2.write(g11_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2110 | spi2.write(g11_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2111 | spi2.write(g11_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2112 | spi2.write(g11_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2113 | spi2.write(g11_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2114 | spi2.write(g11_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2115 | spi2.write(g11_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2116 | spi2.write(g11_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2117 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2118 | spi2.write(r11_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2119 | spi2.write(r11_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2120 | spi2.write(r11_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2121 | spi2.write(r11_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2122 | spi2.write(r11_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2123 | spi2.write(r11_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2124 | spi2.write(r11_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2125 | spi2.write(r11_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2126 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2127 | spi2.write(b11_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2128 | spi2.write(b11_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2129 | spi2.write(b11_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2130 | spi2.write(b11_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2131 | spi2.write(b11_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2132 | spi2.write(b11_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2133 | spi2.write(b11_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2134 | spi2.write(b11_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2135 | //LED2 |
ivanyohuno | 0:c350fa2f0c19 | 2136 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2137 | spi2.write(g12_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2138 | spi2.write(g12_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2139 | spi2.write(g12_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2140 | spi2.write(g12_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2141 | spi2.write(g12_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2142 | spi2.write(g12_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2143 | spi2.write(g12_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2144 | spi2.write(g12_array[0]);//set g0 bit |
ivanyohuno | 2:35fd99de07b3 | 2145 | //s2et red bits |
ivanyohuno | 2:35fd99de07b3 | 2146 | spi2.write(r12_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2147 | spi2.write(r12_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2148 | spi2.write(r12_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2149 | spi2.write(r12_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2150 | spi2.write(r12_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2151 | spi2.write(r12_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2152 | spi2.write(r12_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2153 | spi2.write(r12_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2154 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2155 | spi2.write(b12_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2156 | spi2.write(b12_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2157 | spi2.write(b12_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2158 | spi2.write(b12_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2159 | spi2.write(b12_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2160 | spi2.write(b12_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2161 | spi2.write(b12_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2162 | spi2.write(b12_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2163 | //LED3 |
ivanyohuno | 0:c350fa2f0c19 | 2164 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2165 | spi2.write(g13_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2166 | spi2.write(g13_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2167 | spi2.write(g13_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2168 | spi2.write(g13_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2169 | spi2.write(g13_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2170 | spi2.write(g13_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2171 | spi2.write(g13_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2172 | spi2.write(g13_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2173 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2174 | spi2.write(r13_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2175 | spi2.write(r13_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2176 | spi2.write(r13_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2177 | spi2.write(r13_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2178 | spi2.write(r13_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2179 | spi2.write(r13_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2180 | spi2.write(r13_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2181 | spi2.write(r13_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2182 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2183 | spi2.write(b13_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2184 | spi2.write(b13_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2185 | spi2.write(b13_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2186 | spi2.write(b13_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2187 | spi2.write(b13_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2188 | spi2.write(b13_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2189 | spi2.write(b13_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2190 | spi2.write(b13_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2191 | //LED4 |
ivanyohuno | 0:c350fa2f0c19 | 2192 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2193 | spi2.write(g14_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2194 | spi2.write(g14_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2195 | spi2.write(g14_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2196 | spi2.write(g14_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2197 | spi2.write(g14_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2198 | spi2.write(g14_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2199 | spi2.write(g14_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2200 | spi2.write(g14_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2201 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2202 | spi2.write(r14_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2203 | spi2.write(r14_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2204 | spi2.write(r14_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2205 | spi2.write(r14_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2206 | spi2.write(r14_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2207 | spi2.write(r14_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2208 | spi2.write(r14_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2209 | spi2.write(r14_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2210 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2211 | spi2.write(b14_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2212 | spi2.write(b14_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2213 | spi2.write(b14_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2214 | spi2.write(b14_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2215 | spi2.write(b14_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2216 | spi2.write(b14_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2217 | spi2.write(b14_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2218 | spi2.write(b14_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2219 | //LED5 |
ivanyohuno | 0:c350fa2f0c19 | 2220 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2221 | spi2.write(g15_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2222 | spi2.write(g15_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2223 | spi2.write(g15_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2224 | spi2.write(g15_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2225 | spi2.write(g15_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2226 | spi2.write(g15_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2227 | spi2.write(g15_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2228 | spi2.write(g15_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2229 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2230 | spi2.write(r15_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2231 | spi2.write(r15_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2232 | spi2.write(r15_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2233 | spi2.write(r15_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2234 | spi2.write(r15_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2235 | spi2.write(r15_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2236 | spi2.write(r15_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2237 | spi2.write(r15_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2238 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2239 | spi2.write(b15_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2240 | spi2.write(b15_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2241 | spi2.write(b15_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2242 | spi2.write(b15_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2243 | spi2.write(b15_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2244 | spi2.write(b15_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2245 | spi2.write(b15_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2246 | spi2.write(b15_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2247 | //LED6 |
ivanyohuno | 0:c350fa2f0c19 | 2248 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2249 | spi2.write(g16_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2250 | spi2.write(g16_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2251 | spi2.write(g16_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2252 | spi2.write(g16_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2253 | spi2.write(g16_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2254 | spi2.write(g16_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2255 | spi2.write(g16_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2256 | spi2.write(g16_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2257 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2258 | spi2.write(r16_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2259 | spi2.write(r16_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2260 | spi2.write(r16_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2261 | spi2.write(r16_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2262 | spi2.write(r16_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2263 | spi2.write(r16_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2264 | spi2.write(r16_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2265 | spi2.write(r16_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2266 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2267 | spi2.write(b16_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2268 | spi2.write(b16_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2269 | spi2.write(b16_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2270 | spi2.write(b16_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2271 | spi2.write(b16_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2272 | spi2.write(b16_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2273 | spi2.write(b16_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2274 | spi2.write(b16_array[0]); //set b0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2275 | //LED7 |
ivanyohuno | 0:c350fa2f0c19 | 2276 | //set green bits |
ivanyohuno | 2:35fd99de07b3 | 2277 | spi2.write(g17_array[7]); //set g7 bit |
ivanyohuno | 2:35fd99de07b3 | 2278 | spi2.write(g17_array[6]); //set g6 bit |
ivanyohuno | 2:35fd99de07b3 | 2279 | spi2.write(g17_array[5]); //set g5 bit |
ivanyohuno | 2:35fd99de07b3 | 2280 | spi2.write(g17_array[4]); //set g4 bit |
ivanyohuno | 2:35fd99de07b3 | 2281 | spi2.write(g17_array[3]); //set g3 bit |
ivanyohuno | 2:35fd99de07b3 | 2282 | spi2.write(g17_array[2]); //set g2 bit |
ivanyohuno | 2:35fd99de07b3 | 2283 | spi2.write(g17_array[1]); //set g1 bit |
ivanyohuno | 2:35fd99de07b3 | 2284 | spi2.write(g17_array[0]);//set g0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2285 | //set red bits |
ivanyohuno | 2:35fd99de07b3 | 2286 | spi2.write(r17_array[7]);//set r7 bit |
ivanyohuno | 2:35fd99de07b3 | 2287 | spi2.write(r17_array[6]); //set r6 bit |
ivanyohuno | 2:35fd99de07b3 | 2288 | spi2.write(r17_array[5]); //set r5 bit |
ivanyohuno | 2:35fd99de07b3 | 2289 | spi2.write(r17_array[4]); //set r4 bit |
ivanyohuno | 2:35fd99de07b3 | 2290 | spi2.write(r17_array[3]); //set r3 bit |
ivanyohuno | 2:35fd99de07b3 | 2291 | spi2.write(r17_array[2]); //set r2 bit |
ivanyohuno | 2:35fd99de07b3 | 2292 | spi2.write(r17_array[1]); //set r1 bit |
ivanyohuno | 2:35fd99de07b3 | 2293 | spi2.write(r17_array[0]); //set r0 bit |
ivanyohuno | 0:c350fa2f0c19 | 2294 | //set blue bits |
ivanyohuno | 2:35fd99de07b3 | 2295 | spi2.write(b17_array[7]); //set b7 bit |
ivanyohuno | 2:35fd99de07b3 | 2296 | spi2.write(b17_array[6]); //set b6 bit |
ivanyohuno | 2:35fd99de07b3 | 2297 | spi2.write(b17_array[5]); //set b5 bit |
ivanyohuno | 2:35fd99de07b3 | 2298 | spi2.write(b17_array[4]); //set b4 bit |
ivanyohuno | 2:35fd99de07b3 | 2299 | spi2.write(b17_array[3]); //set b3 bit |
ivanyohuno | 2:35fd99de07b3 | 2300 | spi2.write(b17_array[2]); //set b2 bit |
ivanyohuno | 2:35fd99de07b3 | 2301 | spi2.write(b17_array[1]); //set b1 bit |
ivanyohuno | 2:35fd99de07b3 | 2302 | spi2.write(b17_array[0]); //set b0 bit |
ivanyohuno | 1:42b43fa7362f | 2303 | |
ivanyohuno | 0:c350fa2f0c19 | 2304 | //wait for latch |
ivanyohuno | 0:c350fa2f0c19 | 2305 | wait_us(60); |
ivanyohuno | 0:c350fa2f0c19 | 2306 | } |
ivanyohuno | 4:64ecb3b6d1c7 | 2307 | */ |
ivanyohuno | 0:c350fa2f0c19 | 2308 | int * decimalToBinary(int n) // converts decimal value to 8 bit array of 1's (0xFF0) and 0's (0xF00) |
ivanyohuno | 0:c350fa2f0c19 | 2309 | { |
ivanyohuno | 0:c350fa2f0c19 | 2310 | int reminder; |
ivanyohuno | 0:c350fa2f0c19 | 2311 | int i=0; |
ivanyohuno | 0:c350fa2f0c19 | 2312 | int static binary[8]; //initialize to 00000000 |
ivanyohuno | 0:c350fa2f0c19 | 2313 | while (n!=0) |
ivanyohuno | 0:c350fa2f0c19 | 2314 | { |
ivanyohuno | 0:c350fa2f0c19 | 2315 | reminder=n%2; |
ivanyohuno | 0:c350fa2f0c19 | 2316 | if(reminder == 1){ |
ivanyohuno | 0:c350fa2f0c19 | 2317 | binary[i] = 0xFF0; |
ivanyohuno | 0:c350fa2f0c19 | 2318 | } |
ivanyohuno | 0:c350fa2f0c19 | 2319 | if(reminder == 0){ |
ivanyohuno | 0:c350fa2f0c19 | 2320 | binary[i] = 0xF00; |
ivanyohuno | 0:c350fa2f0c19 | 2321 | } |
ivanyohuno | 0:c350fa2f0c19 | 2322 | n = n/2; |
ivanyohuno | 0:c350fa2f0c19 | 2323 | i++; |
ivanyohuno | 0:c350fa2f0c19 | 2324 | } |
ivanyohuno | 0:c350fa2f0c19 | 2325 | //sets the remainder of the digits to 0xF00 if n reaches 0 before i = 7 |
ivanyohuno | 0:c350fa2f0c19 | 2326 | for(;i<8;i++){ |
ivanyohuno | 0:c350fa2f0c19 | 2327 | binary[i] = 0xF00; |
ivanyohuno | 0:c350fa2f0c19 | 2328 | } |
ivanyohuno | 0:c350fa2f0c19 | 2329 | return binary; |
ivanyohuno | 0:c350fa2f0c19 | 2330 | } |
ivanyohuno | 0:c350fa2f0c19 | 2331 | |
ivanyohuno | 0:c350fa2f0c19 | 2332 | void spi_init(){ //initializes spi port to send 0 bit length |
ivanyohuno | 2:35fd99de07b3 | 2333 | spi.format(14, 0); //set spi at 14 bits/byte with clock phase and clock polarity at mode 0 |
ivanyohuno | 2:35fd99de07b3 | 2334 | spi.frequency(10600000); //set frequency of spi clock at 96/9 - 10.6MHz 94.3 ns bit time length |
ivanyohuno | 1:42b43fa7362f | 2335 | spi2.format(14, 0); //set spi at 14 bits/byte with clock phase and clock polarity at mode 0 |
ivanyohuno | 1:42b43fa7362f | 2336 | spi2.frequency(10600000); //set frequency of spi clock at 96/9 - 10.6MHz 94.3 ns bit time length |
ivanyohuno | 1:42b43fa7362f | 2337 | |
ivanyohuno | 0:c350fa2f0c19 | 2338 | } |
ivanyohuno | 0:c350fa2f0c19 | 2339 |