Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 0:00278ce5259f, committed 2015-08-18
- Comitter:
- acina
- Date:
- Tue Aug 18 15:39:42 2015 +0000
- Commit message:
- Initial Commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accmag.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,101 @@ + + +/* Chip defines */ +#define ACC 0x32 +#define MAG 0x3C + +/* Read */ +#define I2CR 0x01 +/* Write */ +#define I2CW 0x00 +/* Multiple Transfer */ +#define MTRAN 0x80 + +/* accelerometer register defines */ +#define CTRL_REG1_A 0x20 +#define OUT_X_L_A 0x28 +#define OUT_X_H_A 0x29 +#define OUT_Y_L_A 0x2A +#define OUT_Y_H_A 0x2B +#define OUT_Z_L_A 0x2C +#define OUT_Z_H_A 0x2D + +/* magnetometer register defines */ +#define CRB_REG_M 0x01 +#define MR_REG_M 0x02 +#define OUT_X_H_M 0x03 +#define OUT_X_L_M 0x04 +#define OUT_Y_H_M 0x05 +#define OUT_Y_L_M 0x06 +#define OUT_Z_H_M 0x07 +#define OUT_Z_L_M 0x08 + + +/* Activate the accelerometer */ +void startAcc(I2C i2c) +{ + i2c.start(); + i2c.write(ACC | I2CW); + i2c.write(CTRL_REG1_A); + i2c.write(0x37); + i2c.stop(); +} + +/* Activate the magnetometer */ +void startMag(I2C i2c) +{ + i2c.start(); + i2c.write(MAG | I2CW); + i2c.write(CRB_REG_M); + i2c.write(0x20); + i2c.stop(); + i2c.start(); + i2c.write(MAG | I2CW); + i2c.write(MR_REG_M); + i2c.write(0x00); + i2c.stop(); +} + +void readAcc(I2C i2c, char registers[6], int16_t *xacc, int16_t *yacc, int16_t *zacc) +{ + uint8_t DATA[6]; + uint8_t SUB = registers[0]; + uint8_t SAD = ACC; + i2c.start(); + i2c.write(SAD | I2CW); + i2c.write(SUB | MTRAN); + i2c.start(); + i2c.write(SAD | I2CR); + DATA[0] = i2c.read(1); + DATA[1] = i2c.read(1); + DATA[2] = i2c.read(1); + DATA[3] = i2c.read(1); + DATA[4] = i2c.read(1); + DATA[5] = i2c.read(0); + i2c.stop(); + *xacc = DATA[1]*256+DATA[0]; + *yacc = DATA[3]*256+DATA[2]; + *zacc = DATA[5]*256+DATA[4]; +} + +void readMag(I2C i2c, char registers[6], int16_t *xmag, int16_t *ymag, int16_t *zmag) +{ + uint8_t DATA[6]; + uint8_t SUB = registers[0]; + uint8_t SAD = MAG; + i2c.start(); + i2c.write(SAD | I2CW); + i2c.write(SUB | MTRAN); + i2c.start(); + i2c.write(SAD | I2CR); + DATA[0] = i2c.read(1); + DATA[1] = i2c.read(1); + DATA[2] = i2c.read(1); + DATA[3] = i2c.read(1); + DATA[4] = i2c.read(1); + DATA[5] = i2c.read(0); + i2c.stop(); + *xmag = DATA[0]*256+DATA[1]; + *ymag = DATA[2]*256+DATA[3]; + *zmag = DATA[4]*256+DATA[5]; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,75 @@ +#include "mbed.h" +#include "neopixel.h" +#include "neopixel.c" +#include "neopixel_alphabet.h" +#include "neopixel_array.h" +#include "neopixel_digits.h" +#include "neopixel_manip.h" +#include "accmag.h" + +/* Pin defines */ +#define SDA P0_2 +#define SCL P0_0 +#define DOUT P0_3 + +/* Global variables */ +neopixel_strip_t strip; +I2C i2c(SDA,SCL); +Serial debug(USBTX,USBRX); +DigitalOut status(LED1); + +double thetaCalc(int nx, int ny) +{ + double M_PI = 3.14159265358979323846; + double theta; + if (nx >= 0 && ny >= 0) + { + theta = 2*M_PI - atan((double)(nx)/(double)(ny)); + } + else if (nx < 0 && ny >= 0) + { + theta = atan((double)(abs(nx))/(double)(abs(ny))); + } + else if (nx < 0 && ny < 0) + { + theta = M_PI - (M_PI/2 - atan((double)(ny) / (double)(nx))); + } + else + { + theta = M_PI - (atan((double)(nx)/(double)(ny))); + } + return theta; +} + +int main() { + char aregisters[6] = {OUT_X_L_A,OUT_X_H_A,OUT_Y_L_A,OUT_Y_H_A,OUT_Z_L_A,OUT_Z_H_A}; + char mregisters[6] = {OUT_X_H_M,OUT_X_L_M,OUT_Y_H_M,OUT_Y_L_M,OUT_Z_H_M,OUT_Z_L_M}; + uint8_t arr1[8][8][3]; + uint8_t arr2[16][8][3]; + double theta = 0; + int16_t accx, accy, accz, magx, magy, magz; + + neopixel_init(&strip,DOUT,128); + + startAcc(i2c); + + startMag(i2c); + + while(1) { + readAcc(i2c,aregisters,&accx,&accy,&accz); + readMag(i2c,mregisters,&magx,&magy,&magz); + theta = thetaCalc(magx,magz); + rotate_ccw(compass_needle,arr1,3.5,3.5,theta); + if (accz < 0) + { + rotate_ccw(compass_needle,arr1,3.5,3.5,theta); + catArr(arr1,null_flag,arr2); + } + else + { + rotate_cw(compass_needle,arr1,3.5,3.5,theta); + catArr(null_flag,arr1,arr2); + } + showArray2(&strip,arr2,0.1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel.c Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,153 @@ +/* Lava + * + * WS2812B Tricolor LED (neopixel) controller + * + * + * Example code: + + neopixel_strip_t m_strip; + uint8_t dig_pin_num = 6; + uint8_t leds_per_strip = 24; + uint8_t error; + uint8_t led_to_enable = 10; + uint8_t red = 255; + uint8_t green = 0; + uint8_t blue = 159; + + neopixel_init(&m_strip, dig_pin_num, leds_per_strip); + neopixel_clear(&m_strip); + error = neopixel_set_color_and_show(&m_strip, led_to_enable, red, green, blue); + if (error) { + //led_to_enable was not within number leds_per_strip + } + //clear and remove strip + neopixel_clear(&m_strip); + neopixel_destroy(&m_strip); + + + * For use with BLE stack, see information below: + - Include in main.c + #include "ble_radio_notification.h" + - Call (see nrf_soc.h: NRF_RADIO_NOTIFICATION_DISTANCES and NRF_APP_PRIORITIES) + ble_radio_notification_init(NRF_APP_PRIORITY_xxx, + NRF_RADIO_NOTIFICATION_DISTANCE_xxx, + your_radio_callback_handler); + - Create + void your_radio_callback_handler(bool radio_active) + { + if (radio_active == false) + { + neopixel_show(&strip1); + neopixel_show(&strip2); + //...etc + } + } + - Do not use neopixel_set_color_and_show(...) with BLE, instead use uint8_t neopixel_set_color(...); + */ + + +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include "nrf_delay.h" +#include "nrf_gpio.h" +#include "neopixel.h" + +void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds) +{ + strip->leds = (color_t*) malloc(sizeof(color_t) * num_leds); + strip->pin_num = pin_num; + strip->num_leds = num_leds; + nrf_gpio_cfg_output(pin_num); + NRF_GPIO->OUTCLR = (1UL << pin_num); + for (int i = 0; i < num_leds; i++) + { + strip->leds[i].simple.g = 0; + strip->leds[i].simple.r = 0; + strip->leds[i].simple.b = 0; + } +} + +void neopixel_clear(neopixel_strip_t *strip) +{ + for (int i = 0; i < strip->num_leds; i++) + { + strip->leds[i].simple.g = 0; + strip->leds[i].simple.r = 0; + strip->leds[i].simple.b = 0; + } + neopixel_show(strip); +} + +void neopixel_show(neopixel_strip_t *strip) +{ + const uint8_t PIN = strip->pin_num; + NRF_GPIO->OUTCLR = (1UL << PIN); + nrf_delay_us(50); + for (int i = 0; i < strip->num_leds; i++) + { + for (int j = 0; j < 3; j++) + { + if ((strip->leds[i].grb[j] & 128) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 64) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 32) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 16) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 8) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 4) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 2) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + + if ((strip->leds[i].grb[j] & 1) > 0) {NEOPIXEL_SEND_ONE} + else {NEOPIXEL_SEND_ZERO} + } + } +} + +uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue ) +{ + if (index < strip->num_leds) + { + strip->leds[index].simple.r = red; + strip->leds[index].simple.g = green; + strip->leds[index].simple.b = blue; + } + else + return 1; + return 0; +} + +uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue) +{ + if (index < strip->num_leds) + { + strip->leds[index].simple.r = red; + strip->leds[index].simple.g = green; + strip->leds[index].simple.b = blue; + neopixel_show(strip); + } + else + return 1; + return 0; +} + +void neopixel_destroy(neopixel_strip_t *strip) +{ + free(strip->leds); + strip->num_leds = 0; + strip->pin_num = 0; +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,108 @@ + #ifndef NEOPIXEL_H + #define NEOPIXEL_H + + +#include <stdbool.h> +#include <stdint.h> +#include "nrf_delay.h" +#include "nrf_gpio.h" + + +//These defines are timed specific to a series of if statements and will need to be changed +//to compensate for different writing algorithms than the one in neopixel.c +#define NEOPIXEL_SEND_ONE NRF_GPIO->OUTSET = (1UL << PIN); \ + __ASM ( \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + ); \ + NRF_GPIO->OUTCLR = (1UL << PIN); \ + +#define NEOPIXEL_SEND_ZERO NRF_GPIO->OUTSET = (1UL << PIN); \ + __ASM ( \ + " NOP\n\t" \ + ); \ + NRF_GPIO->OUTCLR = (1UL << PIN); \ + __ASM ( \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + " NOP\n\t" \ + ); + +extern void nrf_delay_us(uint32_t volatile number_of_us); +typedef union { + struct { + uint8_t g, r, b; + }simple; + uint8_t grb[3]; +} color_t; + +typedef struct { + uint8_t pin_num; + uint16_t num_leds; + color_t *leds; +} neopixel_strip_t; + +/** + @brief Initialize GPIO and data location + @param[in] pointer to Strip structure + @param[in] pin number for GPIO +*/ +void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds); + +/** + @brief Turn all LEDs off + @param[in] pointer to Strip structure +*/ +void neopixel_clear(neopixel_strip_t *strip); + +/** + @brief Update strip with structure data + @param[in] pointer to Strip structure +*/ +void neopixel_show(neopixel_strip_t *strip); + +/** + @brief Write RGB value to LED structure + @param[in] pointer to Strip structure + @param[in] red value + @param[in] green value + @param[in] blue value + @param[in] LED number (starting at 1) + @retval 0 Successful write + @retval 1 LED number is out of bounds +*/ +uint8_t neopixel_set_color(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue ); + + +/** + @brief Write RGB value to LED structure and update LED + @param[in] pointer to Strip structure + @param[in] red value + @param[in] green value + @param[in] blue value + @param[in] LED number (starting at 1) + @retval 0 Successful write + @retval 1 LED number is out of bounds +*/ +uint8_t neopixel_set_color_and_show(neopixel_strip_t *strip, uint16_t index, uint8_t red, uint8_t green, uint8_t blue); + +/** + @brief Clears structure data + @param[in] pointer to Strip structure +*/ +void neopixel_destroy(neopixel_strip_t *strip); + +#endif +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel_alphabet.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,307 @@ +#ifndef NEOPIXEL_ALPHABET_H +#define NEOPIXEL_ALPHABET_H +#include "mbed.h" + +/* +Template for array literals + +const uint8_t arr[8][8][3] = {\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } \ +}; + +*/ + +const uint8_t A_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t B_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t C_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t D_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t E_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t F_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t G_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t H_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t I_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t J_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t K_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t L_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t M_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t N_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t O_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t P_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Q_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t R_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t S_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t T_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t U_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t V_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t W_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t X_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Y_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Z_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +#endif//NEOPIXEL_ALPHABET_H \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel_array.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,389 @@ +#ifndef NEOPIXEL_ARRAY_H +#define NEOPIXEL_ARRAY_H +#include "mbed.h" + +/* +Template for array literals + +const uint8_t arr[8][8][3] = {\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } ,\ +{ {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} , {000,000,000} } \ +}; + +*/ + +void showArray1(neopixel_strip_t *strip, const uint8_t arr[8][8][3], double scalingFactor) +{ + for (int j=0; j<8; j++) + { + for (int i=0; i<8; i++) + { + neopixel_set_color(strip, i+j*8, arr[j][i][0]*scalingFactor, arr[j][i][1]*scalingFactor, arr[j][i][2]*scalingFactor); + } + } + neopixel_show(strip); +} + +void showArray2(neopixel_strip_t *strip, const uint8_t arr[16][8][3], double scalingFactor) +{ + for (int i=0; i<16; i++) + { + for (int j=0; j<8; j++) + { + neopixel_set_color(strip,j+8*i,arr[i][j][0]*scalingFactor,arr[i][j][1]*scalingFactor,arr[i][j][2]*scalingFactor); + } + } + neopixel_show(strip); +} + +const uint8_t flag_usa[8][8][3] = {\ +{{0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0}} ,\ +{{0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255}} ,\ +{{0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{{0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255}} ,\ +{{255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0}} ,\ +{{255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{{255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{{255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} }\ +}; + + +const uint8_t arrow_up_red[8][8][3] = {\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,0,0} },\ +{{255,0,0} , {255,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {255,0,0} , {255,0,0} },\ +{{255,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {255,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} }\ +}; + + +const uint8_t arrow_right_red[8][8][3] = {\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} },\ +{{255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{{255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} }\ +}; + + +const uint8_t arrow_down_red[8][8][3] = {\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{{255,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {255,0,0} },\ +{{255,0,0} , {255,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {255,0,0} , {255,0,0} },\ +{{0,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} },\ +{{0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} }\ +}; + +const uint8_t arrow_left_red[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{ {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{ {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} },\ +{ {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{ {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} },\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} }\ +}; + +const uint8_t arrow_up_green[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,0,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,255,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,255,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_left_green[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_right_green[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_down_green[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,255,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,255,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,255,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_up_blue[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,255} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_right_blue[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,255} } \ +}; + +const uint8_t arrow_down_blue[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,255} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,0} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t arrow_left_blue[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t flag_japan[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} },\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} }\ +}; + +const uint8_t flag_spain[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {165,42,42} , {165,42,42} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {165,42,42} , {165,42,42} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } \ +}; + +const uint8_t flag_china[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } \ +}; + +const uint8_t flag_greatBritain[8][8][3] = {\ +{ {255,255,255} , {0,0,255} , {0,0,255} , {255,0,0} , {255,0,0} , {0,0,255} , {0,0,255} , {255,255,255} } ,\ +{ {0,0,255} , {255,255,255} , {0,0,255} , {255,0,0} , {255,0,0} , {0,0,255} , {255,255,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,255,255} , {0,0,255} , {0,0,255} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,255,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {255,255,255} , {0,0,255} , {255,0,0} , {255,0,0} , {0,0,255} , {255,255,255} , {0,0,255} } ,\ +{ {255,255,255} , {0,0,255} , {0,0,255} , {255,0,0} , {255,0,0} , {0,0,255} , {0,0,255} , {255,255,255} } \ +}; + +const uint8_t flag_germany[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } \ +}; + +const uint8_t flag_france[8][8][3] = {\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } \ +}; + +const uint8_t flag_belgium[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,255,0} , {255,255,0} , {255,0,0} , {255,0,0} , {255,0,0} } \ +}; + +const uint8_t flag_singapore[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,255,255} , {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t flag_hongKong[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,255,255} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,255,255} , {255,0,0} , {255,255,255} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } \ +}; + +const uint8_t flag_rainbow[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} } ,\ +{ {255,165,0} , {255,165,0} , {255,165,0} , {255,165,0} , {255,165,0} , {255,165,0} , {255,165,0} , {255,165,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} } ,\ +{ {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} , {128,0,128} } \ +}; + +const uint8_t flag_white[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t flag_sweden[8][8][3] = {\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {0,0,255} , {0,0,255} , {0,0,255} } \ +}; + +const uint8_t colorTest[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,0,255} , {0,0,255} , {255,165,0} , {255,165,0} } ,\ +{ {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,0,255} , {0,0,255} , {255,165,0} , {255,165,0} } ,\ +{ {128,0,128} , {128,0,128} , {255,0,255} , {255,0,255} , {0,255,255} , {0,255,255} , {255,255,0} , {255,255,0} } ,\ +{ {128,0,128} , {128,0,128} , {255,0,255} , {255,0,255} , {0,255,255} , {0,255,255} , {255,255,0} , {255,255,0} } ,\ +{ {144,238,144} , {144,238,144} , {165,42,42} , {165,42,42} , {255,105,180} , {255,105,180} , {0,100,0} , {0,100,0} } ,\ +{ {144,238,144} , {144,238,144} , {165,42,42} , {165,42,42} , {255,105,180} , {255,105,180} , {0,100,0} , {0,100,0} } ,\ +{ {173,216,230} , {173,216,230} , {0,0,128} , {0,0,128} , {255,204,203} , {255,204,203} , {139,0,0} , {139,0,0} } ,\ +{ {173,216,230} , {173,216,230} , {0,0,128} , {0,0,128} , {255,204,203} , {255,204,203} , {139,0,0} , {139,0,0} } \ +}; + +const uint8_t scaleTest1[8][8][3] = {\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {255,0,0} , {255,0,0} , {255,0,0} , {255,0,0} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } ,\ +{ {0,0,255} , {0,0,255} , {0,0,255} , {0,0,255} , {255,255,0} , {255,255,0} , {255,255,0} , {255,255,0} } \ +}; + +const uint8_t scaleTest2[8][8][3] = {\ +{ {255,0,0} , {0,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,255} , {255,255,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t half_scale_flag_sweden[8][8][3] = {\ +{ {0,0,255} , {255,255,255} , {255,255,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,255} , {255,255,255} , {255,255,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +}; + +const uint8_t compass_needle[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {255,0,0} , {255,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,255} , {0,0,255} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +const uint8_t null_flag[8][8][3] = {\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } ,\ +{ {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} , {0,0,0} } \ +}; + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel_digits.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,114 @@ +#ifndef NEOPIXEL_DIGITS_H +#define NEOPIXEL_DIGITS_H + +const uint8_t Zero_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t One_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Two_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Three_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Four_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Five_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Six_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Seven_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Eight_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +const uint8_t Nine_gr[8][8][3] = {\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {0,255,0} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {0,255,0} , {255,255,255} , {255,255,255} } ,\ +{ {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} , {255,255,255} } \ +}; + +#endif//NEOPIXEL_DIGETS_H \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/neopixel_manip.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,988 @@ +#ifndef NEOPIXEL_MANIP_H +#define NEOPIXEL_MANIP_H +#include <math.h> +#include <stdarg.h> + +#define SIZE 64 +#define SIDE 8 + +typedef enum _cCode_ + { + wh,bl,re,gr,bu,ye,cy,ma + } cCode; + +void clearArr(uint8_t arr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + arr[i][j][k] = 0; + } + } + } +} + +void clearFlatArr(uint8_t arr[SIDE*SIDE][3]) +{ + for (int n=0; n<SIDE*SIDE; n++) + { + for (int m=0; m<3; m++) + { + arr[n][m] = 0; + } + } +} + +void copyArr(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr[i][j][k]; + } + } + } +} + +void flatten(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIZE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i+SIDE*j][k] = arr[i][j][k]; + } + } + } +} + +void unflatten(const uint8_t arr[SIZE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int n=0; n<SIZE; n++) + { + for (int m=0; m<3; m++) + { + newArr[n%SIDE][n/SIDE][m] = arr[n][m]; + } + } +} + +void rotate_ccw(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], float px, float py, double rad) +{ + double X, Y, oldX, oldY; + int il,ih,jl,jh; + + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + int sum[3] = {0,0,0}; + int count = 0; + X = i - px; + Y = j - py; + oldX = X*cos(rad) - Y*sin(rad); + oldY = X*sin(rad) + Y*cos(rad); + il = floor(oldX+ceil(px)); + ih = ceil(oldX+floor(px)); + jl = floor(oldY+ceil(py)); + jh = ceil(oldY+floor(py)); + if (il < SIDE && il >=0 && jl < SIDE && jl >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jl][k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jl < SIDE && jl >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jl][k]; + } + count ++; + } + if (il < SIDE && il >=0 && jh < SIDE && jh >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jh][k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jh < SIDE && jh >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jh][k]; + } + count ++; + } + for (int k=0; k<3; k++) + { + newArr[i][j][k] = sum[k] / count; + } + } + } +} + +void rotate_cw(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], float px, float py, double rad) +{ + double X, Y, oldX, oldY; + int il,ih,jl,jh; + + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + int sum[3] = {0,0,0}; + int count = 0; + X = i - px; + Y = j - py; + oldX = X*cos(rad) + Y*sin(rad); + oldY = -X*sin(rad) + Y*cos(rad); + il = floor(oldX+ceil(px)); + ih = ceil(oldX+floor(px)); + jl = floor(oldY+ceil(py)); + jh = ceil(oldY+floor(py)); + if (il < SIDE && il >=0 && jl < SIDE && jl >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jl][k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jl < SIDE && jl >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jl][k]; + } + count ++; + } + if (il < SIDE && il >=0 && jh < SIDE && jh >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jh][k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jh < SIDE && jh >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jh][k]; + } + count ++; + } + for (int k=0; k<3; k++) + { + newArr[i][j][k] = sum[k] / count; + } + } + } +} + +void rotate_ccw(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], float px, float py, double rad, cCode colorCode) +{ + double X, Y, oldX, oldY; + int il,ih,jl,jh; + uint8_t colors[3] = {0,0,0}; + switch (colorCode) + { + case wh: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + case bl: + colors[0] = 0; + colors[1] = 0; + colors[2] = 0; + break; + case re: + colors[0] = 255; + colors[1] = 0; + colors[2] = 0; + break; + case gr: + colors[0] = 0; + colors[1] = 255; + colors[2] = 0; + break; + case bu: + colors[0] = 0; + colors[1] = 0; + colors[2] = 255; + break; + case ye: + colors[0] = 255; + colors[1] = 255; + colors[2] = 0; + break; + case cy: + colors[0] = 0; + colors[1] = 255; + colors[2] = 255; + break; + case ma: + colors[0] = 255; + colors[1] = 0; + colors[2] = 255; + break; + default: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + int sum[3] = {0,0,0}; + int count = 0; + X = i - px; + Y = j - py; + oldX = X*cos(rad) - Y*sin(rad); + oldY = X*sin(rad) + Y*cos(rad); + il = floor(oldX+ceil(px)); + ih = ceil(oldX+floor(px)); + jl = floor(oldY+ceil(py)); + jh = ceil(oldY+floor(py)); + if (il < SIDE && il >=0 && jl < SIDE && jl >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jl][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] = colors[k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jl < SIDE && jl >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jl][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] += colors[k]; + } + count ++; + } + if (il < SIDE && il >=0 && jh < SIDE && jh >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jh][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] += colors[k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jh < SIDE && jh >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jh][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] += colors[k]; + } + count ++; + } + for (int k=0; k<3; k++) + { + newArr[i][j][k] = sum[k] / count; + } + } + } +} + +void rotate_cw(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], float px, float py, double rad, cCode colorCode) +{ + double X, Y, oldX, oldY; + int il,ih,jl,jh; + uint8_t colors[3] = {0,0,0}; + switch (colorCode) + { + case wh: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + case bl: + colors[0] = 0; + colors[1] = 0; + colors[2] = 0; + break; + case re: + colors[0] = 255; + colors[1] = 0; + colors[2] = 0; + break; + case gr: + colors[0] = 0; + colors[1] = 255; + colors[2] = 0; + break; + case bu: + colors[0] = 0; + colors[1] = 0; + colors[2] = 255; + break; + case ye: + colors[0] = 255; + colors[1] = 255; + colors[2] = 0; + break; + case cy: + colors[0] = 0; + colors[1] = 255; + colors[2] = 255; + break; + case ma: + colors[0] = 255; + colors[1] = 0; + colors[2] = 255; + break; + default: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + int sum[3] = {0,0,0}; + int count = 0; + X = i - px; + Y = j - py; + oldX = X*cos(rad) + Y*sin(rad); + oldY = -X*sin(rad) + Y*cos(rad); + il = floor(oldX+ceil(px)); + ih = ceil(oldX+floor(px)); + jl = floor(oldY+ceil(py)); + jh = ceil(oldY+floor(py)); + if (il < SIDE && il >=0 && jl < SIDE && jl >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jl][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] = colors[k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jl < SIDE && jl >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jl][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] = colors[k]; + } + count ++; + } + if (il < SIDE && il >=0 && jh < SIDE && jh >=0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[il][jh][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] = colors[k]; + } + count ++; + } + if (ih < SIDE && ih >= 0 && jh < SIDE && jh >= 0) + { + for (int k=0; k<3; k++) + { + sum[k] += arr[ih][jh][k]; + } + count ++; + } + else + { + for (int k=0; k<3; k++) + { + sum[k] = colors[k]; + } + count ++; + } + for (int k=0; k<3; k++) + { + newArr[i][j][k] = sum[k] / count; + } + } + } +} + +void translate_v(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int shift) +{ + int newi; + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = 0; + } + } + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newi = i - shift; + if (newi >= 0 && newi < SIDE) + { + newArr[newi][j][k] = arr[i][j][k]; + } + } + } + } +} + +void translate_h(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int shift) +{ + int newj; + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = 0; + } + } + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newj = j - shift; + if (newj >= 0 && newj < SIDE) + { + newArr[i][newj][k] = arr[i][j][k]; + } + } + } + } +} + +void translate_v(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int shift, cCode colorCode) +{ + int newi; + uint8_t colors[3] = {0,0,0}; + switch (colorCode) + { + case wh: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + case bl: + colors[0] = 0; + colors[1] = 0; + colors[2] = 0; + break; + case re: + colors[0] = 255; + colors[1] = 0; + colors[2] = 0; + break; + case gr: + colors[0] = 0; + colors[1] = 255; + colors[2] = 0; + break; + case bu: + colors[0] = 0; + colors[1] = 0; + colors[2] = 255; + break; + case ye: + colors[0] = 255; + colors[1] = 255; + colors[2] = 0; + break; + case cy: + colors[0] = 0; + colors[1] = 255; + colors[2] = 255; + break; + case ma: + colors[0] = 255; + colors[1] = 0; + colors[2] = 255; + break; + default: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = colors[k]; + } + } + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newi = i - shift; + if (newi >= 0 && newi < SIDE) + { + newArr[newi][j][k] = arr[i][j][k]; + } + } + } + } +} + +void translate_h(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int shift, cCode colorCode) +{ + int newj; + uint8_t colors[3] = {0,0,0}; + switch (colorCode) + { + case wh: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + case bl: + colors[0] = 0; + colors[1] = 0; + colors[2] = 0; + break; + case re: + colors[0] = 255; + colors[1] = 0; + colors[2] = 0; + break; + case gr: + colors[0] = 0; + colors[1] = 255; + colors[2] = 0; + break; + case bu: + colors[0] = 0; + colors[1] = 0; + colors[2] = 255; + break; + case ye: + colors[0] = 255; + colors[1] = 255; + colors[2] = 0; + break; + case cy: + colors[0] = 0; + colors[1] = 255; + colors[2] = 255; + break; + case ma: + colors[0] = 255; + colors[1] = 0; + colors[2] = 255; + break; + default: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = colors[k]; + } + } + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newj = j - shift; + if (newj >= 0 && newj < SIDE) + { + newArr[i][newj][k] = arr[i][j][k]; + } + } + } + } +} +void wrap_v(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], unsigned int shift) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[(i-shift)%SIDE][j][k] = arr[i][j][k]; + } + } + } +} + +void wrap_h(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], unsigned int shift) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr[i][(j+shift)%SIDE][k]; + } + } + } +} + +void catArrOld(const uint8_t arr1[SIDE][SIDE][3], const uint8_t arr2[SIDE][SIDE][3], uint8_t outArr [SIDE][2*SIDE][3]) +{ + for (int i=SIDE-1; i>=0; i--) + { + for (int j=SIDE-1; j>=0; j--) + { + for (int k=0; k<3; k++) + { + outArr[i][j][k] = arr1[i][j][k]; + } + } + for (int j=SIDE*2-1; j>=SIDE; j--) + { + for (int k=0; k<3; k++) + { + outArr[i][j][k] = arr2[i][j-SIDE][k]; + } + } + } +} + +void catArr(const uint8_t arr1[SIDE][SIDE][3], const uint8_t arr2[SIDE][SIDE][3], uint8_t outArr [SIDE*2][SIDE][3]) +{ + for (int i=0; i<16; i++) + { + for (int j=0; j<8; j++) + { + if (i >= 8) + { + for (int k=0; k<3; k++) + { + outArr[i][j][k] = arr2[i-8][j][k]; + } + } + else + { + for (int k=0; k<3; k++) + { + outArr[i][j][k] = arr1[i][j][k]; + } + } + } + } +} + +void splitArrOld(const uint8_t arr[SIDE][SIDE*2][3], uint8_t narr1[SIDE][SIDE][3], uint8_t narr2[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + narr1[i][j][k] = arr[i][j][k]; + } + } + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + narr2[i][j][k] = arr[i][j+8][k]; + } + } + } +} + +void invert(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<SIDE; k++) + { + newArr[i][j][k] = 255 - arr[i][j][k]; + } + } + } +} + +void mirror_v(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<SIDE; k++) + { + newArr[i][j][k] = arr[SIDE - i - 1][j][k]; + } + } + } +} + +void mirror_h(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<SIDE; k++) + { + newArr[i][j][k] = arr[i][SIDE - j - 1][k]; + } + } + } +} + +void transpose(const uint8_t arr[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3]) +{ + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr[j][i][k]; + } + } + } +} + +void unionArr(const uint8_t arr1[SIDE][SIDE][3], const uint8_t arr2[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int ya1, int yb1, int xa1, int xb1, int ya2, int yb2, int xa2, int xb2,cCode colorCode) +{ + Serial debug(USBTX,USBRX); + uint8_t colors[3] = {0,0,0}; + switch (colorCode) + { + case wh: + debug.printf("wh\n\r"); + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + case bl: + debug.printf("bl\n\r"); + colors[0] = 0; + colors[1] = 0; + colors[2] = 0; + break; + case re: + colors[0] = 255; + colors[1] = 0; + colors[2] = 0; + break; + case gr: + colors[0] = 0; + colors[1] = 255; + colors[2] = 0; + break; + case bu: + colors[0] = 0; + colors[1] = 0; + colors[2] = 255; + break; + case ye: + colors[0] = 255; + colors[1] = 255; + colors[2] = 0; + break; + case cy: + colors[0] = 0; + colors[1] = 255; + colors[2] = 255; + break; + case ma: + colors[0] = 255; + colors[1] = 0; + colors[2] = 255; + break; + default: + colors[0] = 255; + colors[1] = 255; + colors[2] = 255; + break; + } + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = colors[k]; + } + } + } + for (int i=xa1; i<xb1; i++) + { + for (int j=ya1; j<yb1; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr1[i][j][k]; + } + } + } + for (int i=xa2; i<xb2; i++) + { + for (int j=ya2; j<yb2; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr2[i][j][k]; + } + } + } +} + +void unionArr(const uint8_t arr1[SIDE][SIDE][3], const uint8_t arr2[SIDE][SIDE][3], uint8_t newArr[SIDE][SIDE][3], int ya1, int yb1, int xa1, int xb1, int ya2, int yb2, int xa2, int xb2) +{ + Serial debug(USBTX,USBRX); + for (int i=0; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = 0; + } + } + } + for (int i=xa1; i<xb1; i++) + { + for (int j=ya1; j<yb1; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr1[i][j][k]; + } + } + } + for (int i=xa2; i<xb2; i++) + { + for (int j=ya2; j<yb2; j++) + { + for (int k=0; k<3; k++) + { + newArr[i][j][k] = arr2[i][j][k]; + } + } + } +} + +void letterShift(const uint8_t arr[SIDE][SIDE][3], uint8_t nArr[SIDE][SIDE][3], int offset, cCode colorCode) +{ + uint8_t larr[SIDE][SIDE][3]; + uint8_t rarr[SIDE][SIDE][3]; + translate_h(arr,rarr,(SIDE/2) + offset,colorCode); + translate_h(arr,larr,-(SIDE/2) + offset,colorCode); + for (int i=0; i<SIDE/2; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + nArr[j][i][k] = larr[j][i+(SIDE/2)][k]; + } + } + } + for (int i=SIDE/2; i<SIDE; i++) + { + for (int j=0; j<SIDE; j++) + { + for (int k=0; k<3; k++) + { + nArr[j][i][k] = rarr[j][i-(SIDE/2)][k]; + } + } + } +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nrf_delay.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,74 @@ +#ifndef _NRF_DELAY_H +#define _NRF_DELAY_H + + #include "nrf.h" + +/* lint --e{438, 522} "Variable not used" "Function lacks side-effects" */ +#if defined ( __CC_ARM ) +static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us) +{ +loop + SUBS R0, R0, #1 + NOP + NOP + NOP + NOP + NOP + NOP + NOP + NOP + NOP + NOP + NOP + NOP + BNE loop + BX LR +} +#elif defined ( __ICCARM__ ) +static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) +{ +__ASM ( +"loop:\n\t" + " SUBS R0, R0, #1\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " NOP\n\t" + " BNE loop\n\t"); +} +#elif defined ( __GNUC__ ) +static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) +{ + do + { + __ASM volatile ( + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + "NOP\n\t" + ); + } while (--number_of_us); +} +#endif + +void nrf_delay_ms(uint32_t volatile number_of_ms); + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nrf_gpio.h Tue Aug 18 15:39:42 2015 +0000 @@ -0,0 +1,379 @@ +#ifndef NRF_GPIO_H__ +#define NRF_GPIO_H__ + +#include "nrf51.h" +#include "nrf51_bitfields.h" + +/** + * @defgroup nrf_gpio GPIO abstraction + * @{ + * @ingroup nrf_drivers + * @brief GPIO pin abstraction and port abstraction for reading and writing byte-wise to GPIO ports. + * + * Here, the GPIO ports are defined as follows: + * - Port 0 -> pin 0-7 + * - Port 1 -> pin 8-15 + * - Port 2 -> pin 16-23 + * - Port 3 -> pin 24-31 + */ + +/** + * @enum nrf_gpio_port_dir_t + * @brief Enumerator used for setting the direction of a GPIO port. + */ +typedef enum +{ + NRF_GPIO_PORT_DIR_OUTPUT, ///< Output + NRF_GPIO_PORT_DIR_INPUT ///< Input +} nrf_gpio_port_dir_t; + +/** + * @enum nrf_gpio_pin_dir_t + * Pin direction definitions. + */ +typedef enum +{ + NRF_GPIO_PIN_DIR_INPUT, ///< Input + NRF_GPIO_PIN_DIR_OUTPUT ///< Output +} nrf_gpio_pin_dir_t; + +/** + * @enum nrf_gpio_port_select_t + * @brief Enumerator used for selecting between port 0 - 3. + */ +typedef enum +{ + NRF_GPIO_PORT_SELECT_PORT0 = 0, ///< Port 0 (GPIO pin 0-7) + NRF_GPIO_PORT_SELECT_PORT1, ///< Port 1 (GPIO pin 8-15) + NRF_GPIO_PORT_SELECT_PORT2, ///< Port 2 (GPIO pin 16-23) + NRF_GPIO_PORT_SELECT_PORT3, ///< Port 3 (GPIO pin 24-31) +} nrf_gpio_port_select_t; + +/** + * @enum nrf_gpio_pin_pull_t + * @brief Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration + */ +typedef enum +{ + NRF_GPIO_PIN_NOPULL = GPIO_PIN_CNF_PULL_Disabled, ///< Pin pullup resistor disabled + NRF_GPIO_PIN_PULLDOWN = GPIO_PIN_CNF_PULL_Pulldown, ///< Pin pulldown resistor enabled + NRF_GPIO_PIN_PULLUP = GPIO_PIN_CNF_PULL_Pullup, ///< Pin pullup resistor enabled +} nrf_gpio_pin_pull_t; + +/** + * @brief Configure GPIO pin range as outputs with normal drive strength. + * This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @note For configuring only one pin as output use @ref nrf_gpio_cfg_output + * Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output. + */ +static __INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + for (; pin_range_start <= pin_range_end; pin_range_start++) + { + NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + } +} + +/** + * @brief Configure GPIO pin range as inputs with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input. + * + * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30) + * + * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high) + * + * @note For configuring only one pin as input use @ref nrf_gpio_cfg_input + * Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable + */ +static __INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + for (; pin_range_start <= pin_range_end; pin_range_start++) + { + NRF_GPIO->PIN_CNF[pin_range_start] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (pull_config << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); + } +} + +/** + * @brief Configure given GPIO pin number as output with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30) + * + * @note Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output. + */ +static __INLINE void nrf_gpio_cfg_output(uint32_t pin_number) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); +} + +/** + * @brief Configure given GPIO pin number as input with given initial value set, hiding inner details. + * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases). + * + * @param pin_number specifies the pin number of gpio pin numbers to be configured (allowed values 0-30) + * + * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high) + * + * @note Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable + */ +static __INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config) +{ + /*lint -e{845} // A zero has been given as right argument to operator '|'" */ + NRF_GPIO->PIN_CNF[pin_number] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (pull_config << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); +} + +/** + * @brief Set the direction for a GPIO pin. + * + * @param pin_number specifies the pin number [0:31] for which to + * set the direction. + * + * @param direction specifies the direction + */ +static __INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction) +{ + if(direction == NRF_GPIO_PIN_DIR_INPUT) + { + NRF_GPIO->PIN_CNF[pin_number] = + (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) + | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) + | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) + | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) + | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos); + } + else + { + NRF_GPIO -> DIRSET = (1UL << pin_number); + } +} + +/** + * @brief Set GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * set. + */ +static __INLINE void nrf_gpio_pin_set(uint32_t pin_number) +{ + NRF_GPIO->OUTSET = (1UL << pin_number); +} + +/** + * @brief Clear GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * clear. + */ +static __INLINE void nrf_gpio_pin_clear(uint32_t pin_number) +{ + NRF_GPIO->OUTCLR = (1UL << pin_number); +} + +/** + * @brief Toggle GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * toggle. + */ +static __INLINE void nrf_gpio_pin_toggle(uint32_t pin_number) +{ + NRF_GPIO->OUT ^= (1UL << pin_number); +} + +/** + * @brief Write value to GPIO pin. + * + * Note that the pin must be configured as an output for this + * function to have any effect. + * + * @param pin_number specifies the pin number [0:31] to + * write. + * + * @param value specifies the value to be written to the pin. + * @arg 0 clears the pin + * @arg >=1 sets the pin. + */ +static __INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value) +{ + if (value == 0) + { + nrf_gpio_pin_clear(pin_number); + } + else + { + nrf_gpio_pin_set(pin_number); + } +} + +/** + * @brief Read the input level of a GPIO pin. + * + * Note that the pin must have input connected for the value + * returned from this function to be valid. + * + * @param pin_number specifies the pin number [0:31] to + * read. + * + * @return + * @retval 0 if the pin input level is low. + * @retval 1 if the pin input level is high. + * @retval > 1 should never occur. + */ +static __INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number) +{ + return ((NRF_GPIO->IN >> pin_number) & 1UL); +} + +/** + * @brief Generic function for writing a single byte of a 32 bit word at a given + * address. + * + * This function should not be called from outside the nrf_gpio + * abstraction layer. + * + * @param word_address is the address of the word to be written. + * + * @param byte_no is the the word byte number (0-3) to be written. + * + * @param value is the value to be written to byte "byte_no" of word + * at address "word_address" + */ +static __INLINE void nrf_gpio_word_byte_write(volatile uint32_t * word_address, uint8_t byte_no, uint8_t value) +{ + *((volatile uint8_t*)(word_address) + byte_no) = value; +} + +/** + * @brief Generic function for reading a single byte of a 32 bit word at a given + * address. + * + * This function should not be called from outside the nrf_gpio + * abstraction layer. + * + * @param word_address is the address of the word to be read. + * + * @param byte_no is the the byte number (0-3) of the word to be read. + * + * @return byte "byte_no" of word at address "word_address". + */ +static __INLINE uint8_t nrf_gpio_word_byte_read(const volatile uint32_t* word_address, uint8_t byte_no) +{ + return (*((const volatile uint8_t*)(word_address) + byte_no)); +} + +/** + * @brief Set the direction of a port. + * + * @param port is the port for which to set the direction. + * + * @param dir direction to be set for this port. + */ +static __INLINE void nrf_gpio_port_dir_set(nrf_gpio_port_select_t port, nrf_gpio_port_dir_t dir) +{ + if (dir == NRF_GPIO_PORT_DIR_OUTPUT) + { + nrf_gpio_word_byte_write(&NRF_GPIO->DIRSET, port, 0xFF); + } + else + { + nrf_gpio_range_cfg_input(port*8, (port+1)*8-1, NRF_GPIO_PIN_NOPULL); + } +} + +/** + * @brief Read GPIO port. + * + * @param port is the port to read. + * + * @return the input value on this port. + */ +static __INLINE uint8_t nrf_gpio_port_read(nrf_gpio_port_select_t port) +{ + return nrf_gpio_word_byte_read(&NRF_GPIO->IN, port); +} + +/** + * @brief Write GPIO port. + * + * @param port is the port to write. + * + * @param value is the value to write to this port. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_write(nrf_gpio_port_select_t port, uint8_t value) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUT, port, value); +} + +/** + * @brief Set individual pins on GPIO port. + * + * @param port is the port for which to set the pins. + * + * @param set_mask is a mask specifying which pins to set. A bit + * set to 1 indicates that the corresponding port pin shall be + * set. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_set(nrf_gpio_port_select_t port, uint8_t set_mask) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUTSET, port, set_mask); +} + +/** + * @brief Clear individual pins on GPIO port. + * + * @param port is the port for which to clear the pins. + * + * @param clr_mask is a mask specifying which pins to clear. A bit + * set to 1 indicates that the corresponding port pin shall be + * cleared. + * + * @sa nrf_gpio_port_dir_set() + */ +static __INLINE void nrf_gpio_port_clear(nrf_gpio_port_select_t port, uint8_t clr_mask) +{ + nrf_gpio_word_byte_write(&NRF_GPIO->OUTCLR, port, clr_mask); +} + +/** @} */ + +#endif +