├── Hover ├── keywords.txt ├── Hover.h ├── examples │ ├── HoverDemo │ │ └── HoverDemo.ino │ └── NeoPixelGrid │ │ └── neoPixelGrid.ino └── Hover.cpp ├── README.md └── LICENSE /Hover/keywords.txt: -------------------------------------------------------------------------------- 1 | Hover KEYWORD1 2 | Gesture KEYWORD1 3 | Position KEYWORD1 4 | Touch KEYWORD1 5 | begin KEYWORD2 6 | getStatus KEYWORD2 7 | setRelease KEYWORD2 8 | getPosition KEYWORD2 9 | readPositionData KEYWORD2 10 | readI2CData KEYWORD2 11 | getGesture KEYWORD2 12 | readGestureData KEYWORD2 13 | getTouch KEYWORD2 14 | readTouchData KEYWORD2 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | hover_arduino 2 | ============= 3 | 4 | Arduino Library for Hover (www.hoverlabs.co) 5 | 6 | Hover is a development kit that lets you control your hardware projects in a whole new way. 7 | Wave goodbye to physical buttons. Hover detects hand movements in the air for touch-less interaction. 8 | It also features five touch-sensitive regions for even more options. 9 | Hover uses I2C and 2 digital pins. It is compatible with Arduino, Raspberry Pi and more. 10 | 11 | Written by Emran Mahbub and Jonathan Li for Hover Labs. 12 | BSD license, all text above must be included in any redistribution -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Hover Labs 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of beam_particle nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Hover/Hover.h: -------------------------------------------------------------------------------- 1 | /* =========================================================================== 2 | # This is the library for Hover. 3 | # 4 | # Hover is a development kit that lets you control your hardware projects in a whole new way. 5 | # Wave goodbye to physical buttons. Hover detects hand movements in the air for touch-less interaction. 6 | # It also features five touch-sensitive regions for even more options. 7 | # Hover uses I2C and 2 digital pins. It is compatible with Arduino, Raspberry Pi and more. 8 | # 9 | # Hover can be purchased here: http://www.hoverlabs.co 10 | # 11 | # Written by Emran Mahbub and Jonathan Li for Hover Labs. 12 | # BSD license, all text above must be included in any redistribution 13 | # =========================================================================== 14 | # 15 | # INSTALLATION 16 | # The 3 library files (Hover.cpp, Hover.h and keywords.txt) in the Hover folder should be placed in your Arduino Library folder. 17 | # Run the HoverDemo.ino file from your Arduino IDE. 18 | # 19 | # SUPPORT 20 | # For questions and comments, email us at support@hoverlabs.co 21 | # v3.0 22 | # ===========================================================================*/ 23 | 24 | 25 | #ifndef _Hover_H 26 | #define _Hover_H 27 | 28 | #include "Arduino.h" 29 | 30 | class Gesture { 31 | public: 32 | Gesture (); 33 | Gesture(char * gestureType, uint8_t gestureID, uint8_t gestureValue); 34 | char gestureType[15]; 35 | uint8_t gestureID; 36 | uint8_t gestureValue; 37 | }; 38 | 39 | class Touch { 40 | public: 41 | Touch(); 42 | Touch(char * touchType, uint8_t touchID, uint8_t touchValue); 43 | char touchType[20]; 44 | uint8_t touchID; 45 | uint8_t touchValue; 46 | }; 47 | 48 | class Position { 49 | public: 50 | Position(uint16_t x, uint16_t y, uint16_t z); 51 | uint16_t x, y, z; 52 | }; 53 | 54 | class Hover { 55 | public: 56 | Hover(uint8_t ts, uint8_t rst, uint8_t gestmode, uint8_t touchmode, uint8_t tapmode, uint8_t posmode); 57 | void begin(); 58 | Position getPosition(void); 59 | Gesture getGesture(void); 60 | Touch getTouch(void); 61 | void readI2CData(void); 62 | 63 | private: 64 | boolean _valid; 65 | uint8_t _dat[26], _i2caddr, _ts, _rst, _gestmode, _touchmode, _tapmode, _posmode; 66 | void setRelease(); 67 | boolean getStatus(); 68 | void readPositionData(uint16_t *x, uint16_t *y, uint16_t *z); 69 | void readGestureData(char * gtype, uint8_t * gid, uint8_t * gval); 70 | void readTouchData(char * ttype, uint8_t * tid, uint8_t * tval); 71 | 72 | }; 73 | 74 | 75 | #endif -------------------------------------------------------------------------------- /Hover/examples/HoverDemo/HoverDemo.ino: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************************************************************* 3 | This is an example for Hover. 4 | 5 | Hover is a development kit that lets you control your hardware projects in a whole new way. 6 | Wave goodbye to physical buttons. Hover detects hand movements in the air for touch-less interaction. 7 | It also features five touch-sensitive regions for even more options. 8 | Hover uses I2C and 2 digital pins. It is compatible with Arduino, Raspberry Pi and more. 9 | Hover can be purchased here: http://www.hoverlabs.co 10 | 11 | Written by Emran Mahbub and Jonathan Li for Hover Labs. 12 | BSD license, all text above must be included in any redistribution 13 | =========================================================================== 14 | # HOOKUP GUIDE (For Arduino) 15 | 16 | HOVER ORIGINAL --------------- 17 | # PIN 1 - HOST_V+ ---- 5V Pin or 3v3 Pin depending on what Arduino is running on. 18 | # PIN 2 - RESET ---- Any Digital Pin. This example uses Pin 6. 19 | # PIN 3 - SCL ---- SCL pin 20 | # PIN 4 - SDA ---- SDA pin 21 | # PIN 5 - GND ---- Ground Pin 22 | # PIN 6 - 3V3 ---- 3V3 pin 23 | # PIN 7 - TS ---- Any Digital Pin. This example uses Pin 5. 24 | 25 | HOVER 2.0 -------------------- 26 | # PIN 1 - HOST_V+ ---- 5V Pin or 3v3 Pin depending on what Arduino is running on. 27 | # PIN 2 - 3.3V ---- 3V3 pin 28 | # PIN 3 - GND ---- Ground Pin 29 | # PIN 4 - RESET ---- Any Digital Pin. This example uses Pin 6. 30 | # PIN 5 - TS ---- Any Digital Pin. This example uses Pin 5. 31 | # PIN 6 - LED ---- Optional. Connect to Resistor and LED for debugging. 32 | # PIN 7 - SCL ---- SCL pin 33 | # PIN 8 - SDA ---- SDA pin 34 | 35 | ============================================================================= 36 | # OUTPUT DEFINITION 37 | The following table defines the event map. 38 | 39 | ============================================= 40 | | Gesture Type | Gesture ID | Gesture Value | 41 | ============================================= 42 | | Invalid | 0x00 | 0x00 | 43 | | Right Swipe | 0x01 | 0x01 | 44 | | Left Swipe | 0x01 | 0x02 | 45 | | Up Swipe | 0x01 | 0x03 | 46 | | Down Swipe | 0x01 | 0x04 | 47 | | Airspin | 0x02 | 0x00 to 0xFF | 48 | --------------------------------------------- 49 | 50 | ============================================= 51 | | Touch Type | Touch ID | Touch Value | 52 | ============================================= 53 | | Invalid | 0x00 | 0x00 | 54 | | Touch East | 0x01 | 0x01 | 55 | | Touch West | 0x01 | 0x02 | 56 | | Touch North | 0x01 | 0x03 | 57 | | Touch South | 0x01 | 0x04 | 58 | | Touch Center | 0x01 | 0x05 | 59 | | Tap East | 0x02 | 0x01 | 60 | | Tap West | 0x02 | 0x02 | 61 | | Tap North | 0x02 | 0x03 | 62 | | Tap South | 0x02 | 0x04 | 63 | | Tap Center | 0x02 | 0x05 | 64 | | 2x Tap East | 0x03 | 0x01 | 65 | | 2x Tap West | 0x03 | 0x02 | 66 | | 2x Tap North | 0x03 | 0x03 | 67 | | 2x Tap South | 0x03 | 0x04 | 68 | | 2x Tap Center| 0x03 | 0x05 | 69 | --------------------------------------------- 70 | 71 | ============================================================= 72 | | Position Type| x | y | z | 73 | ============================================================= 74 | | 3D Position | 0 to 100 | 0 to 100 | 0 to 100 | 75 | ------------------------------------------------------------- 76 | # HISTORY 77 | v1.0 - Initial Release 78 | v2.0 - Standardized Output Definition, On Github 79 | v2.1 - Fixed Count Issue, Update Output String with examples 80 | v3.0 - Major library update -- added 3D Position, Touch, Double Tap 81 | v3.1 - Added Airspin Gesture support 82 | 83 | # INSTALLATION 84 | The 3 library files (Hover.cpp, Hover.h and keywords.txt) in the Hover folder should be placed in your Arduino Library folder. 85 | Run the HoverDemo.ino file from your Arduino IDE. 86 | 87 | # SUPPORT 88 | For questions and comments, email us at support@hoverlabs.co 89 | *********************************************************************************************************/ 90 | 91 | #include 92 | #include 93 | 94 | // pin declarations for Hover 95 | int ts = 5; 96 | int reset = 6; 97 | 98 | // Enable or disable different modes. Only gestures and taps are enabled by default. 99 | // Set the following four options to 0x01 if you want to capture every event. Note that the Serial console will be 'spammy'. 100 | #define GESTUREMODE 0x01 //0x00 = disable gestures, 0x01 = enable gestures 101 | #define TOUCHMODE 0x00 //0x00 = disable touch, 0x01 = enable touch 102 | #define TAPMODE 0x01 //0x00 = disable taps, 0x01 = enable taps, 0x02 = single taps only, 0x03 = double taps only 103 | #define POSITIONMODE 0x00 //0x00 = disable position tracking, 0x01 = enable position tracking 104 | 105 | // initialize Hover 106 | Hover hover = Hover(ts, reset, GESTUREMODE, TOUCHMODE, TAPMODE, POSITIONMODE ); 107 | 108 | // used when printing 3D position coordinates. Using a smaller interval will result in a 'spammy' console. Set to update every 150ms by default. 109 | long interval = 150; 110 | long previousMillis = 0; 111 | 112 | void setup() { 113 | Serial.begin(9600); 114 | delay(2000); 115 | Serial.println("Initializing Hover...please wait."); 116 | hover.begin(); 117 | } 118 | 119 | void loop(void) { 120 | 121 | unsigned long currentMillis = millis(); // used for updating 3D position coordinates. Set to update every 150ms by default. 122 | 123 | // read incoming data stream from Hover 124 | hover.readI2CData(); 125 | 126 | // retreive a gesture, touch, or position 127 | Gesture g = hover.getGesture(); 128 | Touch t = hover.getTouch(); 129 | Position p = hover.getPosition(); 130 | 131 | // print Gesture data 132 | if ( g.gestureID != 0){ 133 | Serial.print("Event: "); Serial.print(g.gestureType); Serial.print("\t"); 134 | Serial.print("Gesture ID: "); Serial.print(g.gestureID,HEX); Serial.print("\t"); 135 | Serial.print("Value: "); Serial.print(g.gestureValue,HEX); Serial.println(""); 136 | } 137 | // print Touch data 138 | if ( t.touchID != 0){ 139 | Serial.print("Event: "); Serial.print(t.touchType); Serial.print("\t"); 140 | Serial.print("Touch ID: "); Serial.print(t.touchID,HEX); Serial.print("\t"); 141 | Serial.print("Value: "); Serial.print(t.touchValue,HEX); Serial.println(""); 142 | } 143 | // print 3D Position data (x,y,z coordinates) 144 | if( (currentMillis - previousMillis > interval)) { 145 | 146 | previousMillis = currentMillis; 147 | if ( !(p.x==0 && p.y==0 && p.x==0) ) { 148 | // scale raw position coordinates from (0,65535) to (0, 100). Set to 100 by default. Can be changed to any positive value for the desired granularity. 149 | p.x = map(p.x, 0, 65535, 0, 100); 150 | p.y = map(p.y, 0, 65535, 0, 100); 151 | p.z = map(p.z, 0, 65535, 0, 100); 152 | 153 | Serial.print("(x,y,z): "); Serial.print("\t"); Serial.print("("); 154 | Serial.print(p.x); Serial.print(", "); 155 | Serial.print(p.y); Serial.print(", "); 156 | Serial.print(p.z); Serial.print(")"); Serial.println(""); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Hover/Hover.cpp: -------------------------------------------------------------------------------- 1 | /* =========================================================================== 2 | # This is the library for Hover. 3 | # 4 | # Hover is a development kit that lets you control your hardware projects in a whole new way. 5 | # Wave goodbye to physical buttons. Hover detects hand movements in the air for touch-less interaction. 6 | # It also features five touch-sensitive regions for even more options. 7 | # Hover uses I2C and 2 digital pins. It is compatible with Arduino, Raspberry Pi and more. 8 | # 9 | # Hover can be purchased here: http://www.hoverlabs.co 10 | # 11 | # Written by Emran Mahbub and Jonathan Li for Hover Labs. 12 | # BSD license, all text above must be included in any redistribution 13 | # =========================================================================== 14 | # 15 | # INSTALLATION 16 | # The 3 library files (Hover.cpp, Hover.h and keywords.txt) in the Hover folder should be placed in your Arduino Library folder. 17 | # Run the HoverDemo.ino file from your Arduino IDE. 18 | # 19 | # SUPPORT 20 | # For questions and comments, email us at support@hoverlabs.co 21 | # v3.1 22 | # ===========================================================================*/ 23 | 24 | #include 25 | #include 26 | 27 | #ifdef __AVR__ 28 | #define WIRE Wire 29 | #endif 30 | 31 | Hover::Hover(uint8_t ts, uint8_t rst, uint8_t gestmode, uint8_t touchmode, uint8_t tapmode, uint8_t posmode) { 32 | _i2caddr = 0x42; 33 | _ts = ts; 34 | _rst = rst; 35 | _gestmode = gestmode; 36 | _touchmode = touchmode; 37 | _tapmode = tapmode; 38 | _posmode = posmode; 39 | } 40 | 41 | void Hover::begin() { 42 | WIRE.begin(); 43 | pinMode(_ts, INPUT); 44 | pinMode(_rst, OUTPUT); 45 | digitalWrite(_rst, LOW); 46 | delay(50); 47 | pinMode(_rst, INPUT); 48 | 49 | /*disable autocal for smoother operation*/ 50 | uint8_t autoCal[] = {0x10, 0x00, 0x00, 0xA2, 0x80, 0x00 , 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}; 51 | Wire.beginTransmission(_i2caddr); 52 | Wire.write(autoCal, 16); 53 | Wire.endTransmission(); 54 | 55 | Serial.println("Hover is ready"); 56 | } 57 | 58 | void Hover::setRelease() { 59 | digitalWrite(_ts, HIGH); 60 | pinMode(_ts, INPUT); 61 | } 62 | 63 | boolean Hover::getStatus() { 64 | if (digitalRead(_ts) == 0) { 65 | pinMode(_ts, OUTPUT); 66 | digitalWrite(_ts, LOW); 67 | return 0; 68 | } 69 | return 1; 70 | } 71 | 72 | 73 | void Hover::readI2CData(void) { 74 | if (getStatus() == 0){ 75 | int c = 0; 76 | WIRE.requestFrom((uint8_t)_i2caddr, (uint8_t)26); // request 26 bytes from slave device at 0x42 77 | while(WIRE.available()) // slave may send less than requested 78 | { 79 | _dat[c] = WIRE.read(); // receive a byte as character 80 | c++; 81 | } 82 | setRelease(); 83 | _valid = 1; 84 | delay(6); 85 | } else { 86 | _valid = 0; 87 | } 88 | 89 | } 90 | 91 | Gesture::Gesture(){ 92 | strcpy(gestureType, "none"); 93 | gestureID = 0; 94 | gestureValue = 0; 95 | } 96 | 97 | Gesture::Gesture (char * type, uint8_t id, uint8_t value){ 98 | strcpy(gestureType, type); 99 | gestureID = id; 100 | gestureValue = value; 101 | } 102 | 103 | Gesture Hover::getGesture(void) { 104 | char gtype[15]; 105 | uint8_t gid; 106 | uint8_t gval; 107 | 108 | if (_valid == 1 && _gestmode == 0x01) { 109 | readGestureData(gtype, &gid, &gval); 110 | } else { 111 | strcpy(gtype, "none"); 112 | gid = 0x00; 113 | gval = 0x00; 114 | } 115 | 116 | return Gesture(gtype, gid, gval); 117 | } 118 | 119 | void Hover::readGestureData(char * gtype, uint8_t * gid, uint8_t * gval) { 120 | 121 | switch (_dat[10]){ 122 | case 2: 123 | strcpy(gtype, "Right Swipe"); 124 | *gid = 0x01; 125 | *gval = 0x01; 126 | break; 127 | case 3: 128 | strcpy(gtype, "Left Swipe"); 129 | *gid = 0x01; 130 | *gval = 0x02; 131 | break; 132 | case 4: 133 | strcpy(gtype, "Up Swipe"); 134 | *gid = 0x01; 135 | *gval = 0x03; 136 | break; 137 | case 5: 138 | strcpy(gtype, "Down Swipe"); 139 | *gid = 0x01; 140 | *gval = 0x04; 141 | break; 142 | default: 143 | strcpy(gtype, "None"); 144 | *gid = 0x00; 145 | *gval = 0x00; 146 | break; 147 | } 148 | if (_dat[7] & 0x02){ 149 | strcpy(gtype, "Airspin"); 150 | *gid = 0x02; 151 | *gval = _dat[18]; 152 | } 153 | } 154 | 155 | Touch::Touch(){ 156 | strcpy(touchType, "none"); 157 | touchID = 0; 158 | touchValue = 0; 159 | } 160 | 161 | Touch::Touch (char * type, uint8_t id, uint8_t value){ 162 | strcpy(touchType, type); 163 | touchID = id; 164 | touchValue = value; 165 | } 166 | 167 | Touch Hover::getTouch(void) { 168 | char ttype[20]; 169 | uint8_t tid; 170 | uint8_t tval; 171 | 172 | if (_valid == 1) { 173 | readTouchData(ttype, &tid, &tval); 174 | } else { 175 | strcpy(ttype, "None"); 176 | tid = 0x00; 177 | tval = 0x00; 178 | } 179 | 180 | return Touch(ttype, tid, tval); 181 | } 182 | 183 | void Hover::readTouchData(char * ttype, uint8_t * tid, uint8_t * tval) { 184 | 185 | uint8_t touch, tap, doubleTap; 186 | 187 | touch = (_touchmode==0x01) ? (touch = (_dat[14] & 0x1F)) : (0); 188 | 189 | if (_tapmode!=0x00){ 190 | if (_tapmode == 0x01){ 191 | tap = (((_dat[15] & 0x03) << 3 ) | (_dat[14]>>5)); 192 | doubleTap = ((_dat[15]>>2) & 0x1F); 193 | } else { 194 | tap = (_tapmode==0x02) ? (tap = (((_dat[15] & 0x03) << 3 ) | (_dat[14]>>5))) : (0); 195 | doubleTap = (_tapmode==0x03) ? (doubleTap = ((_dat[15]>>2) & 0x1F)) : (0); 196 | } 197 | } else { 198 | tap = 0; 199 | doubleTap = 0; 200 | } 201 | 202 | 203 | if (doubleTap != 0) { 204 | switch (doubleTap) { 205 | case 1: 206 | strcpy(ttype, "Double Tap South"); 207 | *tid = 0x03; 208 | *tval = 0x04; 209 | break; 210 | case 2: 211 | strcpy(ttype, "Double Tap West"); 212 | *tid = 0x03; 213 | *tval = 0x02; 214 | break; 215 | case 4: 216 | strcpy(ttype, "Double Tap North"); 217 | *tid = 0x03; 218 | *tval = 0x03; 219 | break; 220 | case 8: 221 | strcpy(ttype, "Double Tap East"); 222 | *tid = 0x03; 223 | *tval = 0x01; 224 | break; 225 | case 16: 226 | strcpy(ttype, "Double Tap Center"); 227 | *tid = 0x03; 228 | *tval = 0x05; 229 | break; 230 | default: 231 | strcpy(ttype, "None"); 232 | *tid = 0x00; 233 | *tval = 0x00; 234 | break; 235 | } 236 | 237 | } else if (tap != 0) { 238 | switch (tap){ 239 | case 1: 240 | strcpy(ttype, "Tap South"); 241 | *tid = 0x02; 242 | *tval = 0x04; 243 | break; 244 | case 2: 245 | strcpy(ttype, "Tap West"); 246 | *tid = 0x02; 247 | *tval = 0x02; 248 | break; 249 | case 4: 250 | strcpy(ttype, "Tap North"); 251 | *tid = 0x02; 252 | *tval = 0x03; 253 | break; 254 | case 8: 255 | strcpy(ttype, "Tap East"); 256 | *tid = 0x02; 257 | *tval = 0x01; 258 | break; 259 | case 16: 260 | strcpy(ttype, "Tap Center"); 261 | *tid = 0x02; 262 | *tval = 0x05; 263 | break; 264 | default: 265 | strcpy(ttype, "None"); 266 | *tid = 0x00; 267 | *tval = 0x00; 268 | break; 269 | } 270 | 271 | } else if (touch!=0) { 272 | switch (touch){ 273 | case 1: 274 | strcpy(ttype, "Touch South"); 275 | *tid = 0x01; 276 | *tval = 0x04; 277 | break; 278 | case 2: 279 | strcpy(ttype, "Touch West"); 280 | *tid = 0x01; 281 | *tval = 0x02; 282 | break; 283 | case 4: 284 | strcpy(ttype, "Touch North"); 285 | *tid = 0x01; 286 | *tval = 0x03; 287 | break; 288 | case 8: 289 | strcpy(ttype, "Touch East"); 290 | *tid = 0x01; 291 | *tval = 0x01; 292 | break; 293 | case 16: 294 | strcpy(ttype, "Touch Center"); 295 | *tid = 0x01; 296 | *tval = 0x05; 297 | break; 298 | default: 299 | strcpy(ttype, "None"); 300 | *tid = 0x00; 301 | *tval = 0x00; 302 | break; 303 | } 304 | 305 | } else { 306 | 307 | strcpy(ttype, "None"); 308 | *tid = 0x00; 309 | *tval = 0x00; 310 | 311 | } 312 | 313 | } 314 | 315 | Position::Position (uint16_t x0, uint16_t y0, uint16_t z0) { 316 | x = x0; 317 | y = y0; 318 | z = z0; 319 | } 320 | 321 | Position Hover::getPosition(void) { 322 | 323 | uint16_t x, y, z; 324 | 325 | if (_valid == 1 && _posmode == 0x01) { 326 | 327 | readPositionData(&x, &y, &z); 328 | 329 | } else { 330 | 331 | x = 0; 332 | y = 0; 333 | z = 0; 334 | 335 | } 336 | 337 | return Position(x, y, z); 338 | } 339 | 340 | void Hover::readPositionData(uint16_t *x, uint16_t *y, uint16_t *z) { 341 | 342 | if ((_dat[7] & 0x01) == 1){ 343 | 344 | *x = ((_dat[21] << 8) | _dat[20]); 345 | *y = ((_dat[23] << 8) | _dat[22]); 346 | *z = ((_dat[25] << 8) | _dat[24]); 347 | 348 | } else { 349 | 350 | *x = 0; 351 | *y = 0; 352 | *z = 0; 353 | 354 | } 355 | 356 | } 357 | 358 | 359 | 360 | 361 | 362 | -------------------------------------------------------------------------------- /Hover/examples/NeoPixelGrid/neoPixelGrid.ino: -------------------------------------------------------------------------------- 1 | // NeoPixel Ring simple sketch (c) 2013 Shae Erisson 2 | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library 3 | // Hover example built using the Neopixel Ring as a base. 4 | 5 | #include 6 | #ifdef __AVR__ 7 | #include 8 | #endif 9 | 10 | // How many NeoPixels are attached to the Arduino? 11 | #define NUMPIXELS 64 12 | #define PIN 7 13 | 14 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 15 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 16 | // example for more information on possible values. 17 | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 18 | int delayval = 500; // delay for half a second 19 | 20 | #include 21 | #include 22 | 23 | // pin declarations for Hover 24 | int ts = 5; 25 | int reset = 6; 26 | int circle_count = 999; 27 | 28 | // Enable or disable different modes. Only gestures and taps are enabled by default. 29 | // Set the following four options to 0x01 if you want to capture every event. Note that the Serial console will be 'spammy'. 30 | #define GESTUREMODE 0x01 //0x00 = disable gestures, 0x01 = enable gestures 31 | #define TOUCHMODE 0x00 //0x00 = disable touch, 0x01 = enable touch 32 | #define TAPMODE 0x01 //0x00 = disable taps, 0x01 = enable taps, 0x02 = single taps only, 0x03 = double taps only 33 | #define POSITIONMODE 0x00 //0x00 = disable position tracking, 0x01 = enable position tracking 34 | 35 | // initialize Hover 36 | Hover hover = Hover(ts, reset, GESTUREMODE, TOUCHMODE, TAPMODE, POSITIONMODE); 37 | 38 | // used when printing 3D position coordinates. Using a smaller interval will result in a 'spammy' console. Set to update every 150ms by default. 39 | long interval = 10; 40 | long previousMillis = 0; 41 | int light; 42 | 43 | void setup() { 44 | Serial.begin(9600); 45 | delay(2000); 46 | Serial.println("Initializing Hover...please wait."); 47 | hover.begin(); 48 | pixels.begin(); 49 | } 50 | 51 | void loop() { 52 | 53 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 54 | 55 | unsigned long currentMillis = millis(); // used for updating 3D position coordinates. Set to update every 150ms by default. 56 | 57 | // read incoming data stream from Hover 58 | hover.readI2CData(); 59 | 60 | Gesture g = hover.getGesture(); 61 | Touch t = hover.getTouch(); 62 | Position p = hover.getPosition(); 63 | 64 | 65 | ////////////////////////////////////Touch Example 66 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 67 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 68 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 69 | 70 | 71 | if ( t.touchID == 0x03) { 72 | if (t.touchValue == 0x5) { 73 | for (int i=0; i<8; i++){ 74 | pixels.setPixelColor(0+i, pixels.Color(90,0,90)); 75 | pixels.setPixelColor(56+i, pixels.Color(90,0,90)); 76 | pixels.setPixelColor(7+(i*8), pixels.Color(90,0,90)); 77 | pixels.setPixelColor(0+(i*8), pixels.Color(90,0,90)); 78 | } 79 | pixels.show(); 80 | delay(100); 81 | for (int i=0; i<8; i++){ 82 | pixels.setPixelColor(0+i, 0); 83 | pixels.setPixelColor(56+i, 0); 84 | pixels.setPixelColor(7+(i*8), 0); 85 | pixels.setPixelColor(0+(i*8), 0); 86 | } 87 | pixels.show(); 88 | } 89 | } else if ( t.touchID == 0x2){ 90 | if (t.touchValue == 0x1) { 91 | for (int i = 0; i<8; i++){ 92 | pixels.setPixelColor(24+i, pixels.Color(0,30,10)); 93 | pixels.setPixelColor(32+i, pixels.Color(0,30,10)); 94 | } 95 | pixels.show(); 96 | delay(100); 97 | for (int i = 0; i<8; i++){ 98 | pixels.setPixelColor(24+i, 0); 99 | pixels.setPixelColor(32+i, 0); 100 | delay(12); 101 | pixels.show(); 102 | } 103 | } 104 | else if (t.touchValue == 0x2) { 105 | for (int i = 0; i<8; i++){ 106 | pixels.setPixelColor(24+i, pixels.Color(40,0,00)); 107 | pixels.setPixelColor(32+i, pixels.Color(40,0,00)); 108 | } 109 | pixels.show(); 110 | delay(100); 111 | for (int i = 0; i<8; i++){ 112 | pixels.setPixelColor(31-i, 0); 113 | pixels.setPixelColor(39-i, 0); 114 | delay(12); 115 | pixels.show(); 116 | } 117 | } 118 | else if (t.touchValue == 0x3) { 119 | for (int i = 0; i<8; i++){ 120 | pixels.setPixelColor(3+(i*8), pixels.Color(50,30,0)); 121 | pixels.setPixelColor(4+(i*8), pixels.Color(50,30,0)); 122 | } 123 | pixels.show(); 124 | delay(100); 125 | for (int i = 0; i<8; i++){ 126 | pixels.setPixelColor(59-(i*8), 0); 127 | pixels.setPixelColor(60-(i*8), 0); 128 | delay(12); 129 | pixels.show(); 130 | } 131 | } 132 | else if (t.touchValue == 0x4) { 133 | for (int i = 0; i<8; i++){ 134 | pixels.setPixelColor(3+(i*8), pixels.Color(0,0,30)); 135 | pixels.setPixelColor(4+(i*8), pixels.Color(0,0,30)); 136 | } 137 | pixels.show(); 138 | delay(100); 139 | for (int i = 0; i<8; i++){ 140 | pixels.setPixelColor(3+(i*8), 0); 141 | pixels.setPixelColor(4+(i*8), 0); 142 | delay(12); 143 | pixels.show(); 144 | } 145 | } 146 | else if (t.touchValue == 0x5) { 147 | for (int i = 0; i<4; i++){ 148 | pixels.setPixelColor(0+(i*9), pixels.Color(90,0,90)); 149 | pixels.setPixelColor(7+(i*7), pixels.Color(90,0,90)); 150 | pixels.setPixelColor(63-(i*9), pixels.Color(90,0,90)); 151 | pixels.setPixelColor(56-(i*7), pixels.Color(90,0,90)); 152 | pixels.show(); 153 | delay(60); 154 | } 155 | pixels.show(); 156 | delay(10); 157 | for (int i = 0; i<8; i++){ 158 | pixels.setPixelColor(0+(i*9), 0); 159 | pixels.setPixelColor(7+(i*7), 0); 160 | pixels.setPixelColor(63-(i*9), 0); 161 | pixels.setPixelColor(56-(i*7), 0); 162 | } 163 | pixels.show(); 164 | } 165 | } 166 | 167 | 168 | ////////////////////////////////////Gestures Example 169 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 170 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 171 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 172 | 173 | 174 | int r2 = 0; 175 | int g2 = 0; 176 | int b2 = 10; 177 | int x = 0; 178 | 179 | 180 | 181 | if (g.gestureID == 0x2){ 182 | if (g.gestureValue > 0 && g.gestureValue < 21 && circle_count !=0) { 183 | //print 0 184 | circle_count = 0; 185 | for (int i=0; i<7; i++) { 186 | for (int j=0; j<4; j++){ 187 | pixels.setPixelColor(2+j+(i*8), 0); 188 | } 189 | } 190 | pixels.show(); 191 | for (int i=0; i< 4; i++) { 192 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 193 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 194 | } 195 | for (int i=0; i< 7; i++) { 196 | pixels.setPixelColor(2+(i*8), pixels.Color(5,5,2)); 197 | pixels.setPixelColor(5+(i*8), pixels.Color(5,5,2)); 198 | } 199 | pixels.show(); 200 | } else if (g.gestureValue > 20 && g.gestureValue < 46 && circle_count != 1) { 201 | //print 1 202 | circle_count = 1; 203 | for (int i=0; i<7; i++) { 204 | for (int j=0; j<4; j++){ 205 | pixels.setPixelColor(2+j+(i*8), 0); 206 | } 207 | } 208 | pixels.show(); 209 | for (int i=0; i< 7; i++) { 210 | pixels.setPixelColor(5+(8*i), pixels.Color(5,5,2)); 211 | } 212 | pixels.show(); 213 | } else if (g.gestureValue > 45 && g.gestureValue < 71 && circle_count != 2) { 214 | //print 2 215 | circle_count = 2; 216 | for (int i=0; i<7; i++) { 217 | for (int j=0; j<4; j++){ 218 | pixels.setPixelColor(2+j+(i*8), 0); 219 | } 220 | } 221 | pixels.show(); 222 | for (int i=0; i< 4; i++) { 223 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 224 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 225 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 226 | pixels.setPixelColor(5+(8*i), pixels.Color(5,5,2)); 227 | pixels.setPixelColor(26+(8*i), pixels.Color(5,5,2)); 228 | } 229 | pixels.show(); 230 | } else if (g.gestureValue > 70 && g.gestureValue < 96 && circle_count != 3) { 231 | circle_count = 3; 232 | //print 3 233 | for (int i=0; i<7; i++) { 234 | for (int j=0; j<4; j++){ 235 | pixels.setPixelColor(2+j+(i*8), 0); 236 | } 237 | } 238 | pixels.show(); 239 | for (int i=0; i< 4; i++) { 240 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 241 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 242 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 243 | pixels.setPixelColor(5+(8*i), pixels.Color(5,5,2)); 244 | pixels.setPixelColor(29+(8*i), pixels.Color(5,5,2)); 245 | } 246 | pixels.show(); 247 | } else if (g.gestureValue > 95 && g.gestureValue < 121 && circle_count != 4) { 248 | circle_count = 4; 249 | //print 4 250 | for (int i=0; i<7; i++) { 251 | for (int j=0; j<4; j++){ 252 | pixels.setPixelColor(2+j+(i*8), 0); 253 | } 254 | } 255 | pixels.show(); 256 | for (int i=0; i< 4; i++) { 257 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 258 | pixels.setPixelColor(2+(8*i), pixels.Color(5,5,2)); 259 | pixels.setPixelColor(5+(8*i), pixels.Color(5,5,2)); 260 | pixels.setPixelColor(29+(8*i), pixels.Color(5,5,2)); 261 | } 262 | pixels.show(); 263 | } else if (g.gestureValue > 120 && g.gestureValue < 156 && circle_count != 5) { 264 | circle_count = 5; 265 | //print 5 266 | for (int i=0; i<7; i++) { 267 | for (int j=0; j<4; j++){ 268 | pixels.setPixelColor(2+j+(i*8), 0); 269 | } 270 | } 271 | pixels.show(); 272 | for (int i=0; i< 4; i++) { 273 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 274 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 275 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 276 | pixels.setPixelColor(2+(8*i), pixels.Color(5,5,2)); 277 | pixels.setPixelColor(29+(8*i), pixels.Color(5,5,2)); 278 | } 279 | pixels.show(); 280 | } else if (g.gestureValue > 155 && g.gestureValue < 181 && circle_count != 6) { 281 | circle_count = 6; 282 | //print 6 283 | for (int i=0; i<7; i++) { 284 | for (int j=0; j<4; j++){ 285 | pixels.setPixelColor(2+j+(i*8), 0); 286 | } 287 | } 288 | pixels.show(); 289 | for (int i=0; i< 4; i++) { 290 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 291 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 292 | pixels.setPixelColor(2+(8*i), pixels.Color(5,5,2)); 293 | pixels.setPixelColor(29+(8*i), pixels.Color(5,5,2)); 294 | pixels.setPixelColor(26+(8*i), pixels.Color(5,5,2)); 295 | } 296 | pixels.show(); 297 | } else if (g.gestureValue > 180 && g.gestureValue < 206 && circle_count != 7) { 298 | circle_count = 7; 299 | //print 7 300 | for (int i=0; i<7; i++) { 301 | for (int j=0; j<4; j++){ 302 | pixels.setPixelColor(2+j+(i*8), 0); 303 | } 304 | } 305 | pixels.show(); 306 | for (int i=0; i< 4; i++) { 307 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 308 | pixels.setPixelColor(5+(8*i), pixels.Color(5,5,2)); 309 | pixels.setPixelColor(29+(8*i), pixels.Color(5,5,2)); 310 | } 311 | pixels.show(); 312 | } else if (g.gestureValue > 205 && g.gestureValue < 231 && circle_count != 8) { 313 | circle_count = 8; 314 | //print 8 315 | for (int i=0; i<7; i++) { 316 | for (int j=0; j<4; j++){ 317 | pixels.setPixelColor(2+j+(i*8), 0); 318 | } 319 | } 320 | pixels.show(); 321 | for (int i=0; i< 4; i++) { 322 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 323 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 324 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 325 | } 326 | for (int i=0; i< 7; i++) { 327 | pixels.setPixelColor(2+(i*8), pixels.Color(5,5,2)); 328 | pixels.setPixelColor(5+(i*8), pixels.Color(5,5,2)); 329 | } 330 | pixels.show(); 331 | } else if (g.gestureValue > 230 && g.gestureValue < 256 && circle_count != 9) { 332 | circle_count = 9; 333 | //print 9 334 | for (int i=0; i<7; i++) { 335 | for (int j=0; j<4; j++){ 336 | pixels.setPixelColor(2+j+(i*8), 0); 337 | } 338 | } 339 | pixels.show(); 340 | for (int i=0; i< 4; i++) { 341 | pixels.setPixelColor(2+i, pixels.Color(5,5,2)); 342 | pixels.setPixelColor(26+i, pixels.Color(5,5,2)); 343 | pixels.setPixelColor(50+i, pixels.Color(5,5,2)); 344 | pixels.setPixelColor(2+(i*8), pixels.Color(5,5,2)); 345 | } 346 | for (int i=0; i< 7; i++) { 347 | pixels.setPixelColor(5+(i*8), pixels.Color(5,5,2)); 348 | } 349 | pixels.show(); 350 | } 351 | } 352 | /* 353 | 354 | ////////////////////////////////////Counter 355 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 356 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 357 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 358 | 359 | 360 | if ( g.gestureID != 0){ 361 | if ( g.gestureValue == 0x1){ 362 | for (int i = 0; i<10; i++){ 363 | for (int j = 0; j < 4; j++) { 364 | if (i > 1-j && i < 9-j){ 365 | pixels.setPixelColor(-2+i+(9*j), pixels.Color(0,30,10)); 366 | pixels.setPixelColor(54+i-(7*j), pixels.Color(0,30,10)); 367 | 368 | } else if (i > 8-j){ 369 | pixels.setPixelColor(7+(j*8), pixels.Color(0,30,10)); 370 | pixels.setPixelColor(63-(j*8), pixels.Color(0,30,10)); 371 | } 372 | } 373 | pixels.show(); 374 | delay(i*9); 375 | for (int j = 0; j < 4; j++) { 376 | if (i > 1-j && i < 9-j){ 377 | pixels.setPixelColor(-2+i+(9*j), 0); 378 | pixels.setPixelColor(54+i-(7*j), 0); 379 | } else if (i > 8-j){ 380 | pixels.setPixelColor(7+(j*8), 0); 381 | pixels.setPixelColor(63-(j*8), 0); 382 | } 383 | pixels.show(); 384 | } 385 | } 386 | } else if ( g.gestureValue == 0x2) { 387 | for (int i = 0; i<10; i++){ 388 | for (int j = 0; j < 4; j++) { 389 | if (i > 1-j && i < 9-j){ 390 | pixels.setPixelColor(9-i+(7*j), pixels.Color(40,0,0)); 391 | pixels.setPixelColor(65-i-(9*j), pixels.Color(40,0,0)); 392 | 393 | } else if (i > 8-j){ 394 | pixels.setPixelColor(0+(j*8), pixels.Color(40,0,0)); 395 | pixels.setPixelColor(56-(j*8), pixels.Color(40,0,0)); 396 | } 397 | } 398 | pixels.show(); 399 | delay(i*9); 400 | for (int j = 0; j < 4; j++) { 401 | if (i > 1-j && i < 9-j){ 402 | pixels.setPixelColor(9-i+(7*j), 0); 403 | pixels.setPixelColor(65-i-(9*j), 0); 404 | } else if (i > 8-j){ 405 | pixels.setPixelColor(0+(j*8), 0); 406 | pixels.setPixelColor(56-(j*8), 0); 407 | } 408 | pixels.show(); 409 | } 410 | } 411 | } else if ( g.gestureValue == 0x3) { 412 | for (int i = 0; i<10; i++){ 413 | for (int j = 0; j < 4; j++) { 414 | if (i > 1-j && i < 9-j){ 415 | pixels.setPixelColor(72-(i*8)-(j*7), pixels.Color(50,30,00)); 416 | pixels.setPixelColor(79-(i*8)-(j*9), pixels.Color(50,30,00)); 417 | } else if (i > 8-j){ 418 | pixels.setPixelColor(0+j, pixels.Color(50,30,00)); 419 | pixels.setPixelColor(7-j, pixels.Color(50,30,00)); 420 | } 421 | } 422 | pixels.show(); 423 | delay(i*9); 424 | for (int j = 0; j < 4; j++) { 425 | if (i > 1-j && i < 9-j){ 426 | pixels.setPixelColor(72-(i*8)-(j*7), 0); 427 | pixels.setPixelColor(79-(i*8)-(j*9), 0); 428 | } else if (i > 8-j){ 429 | pixels.setPixelColor(0+j, 0); 430 | pixels.setPixelColor(7-j, 0); 431 | } 432 | pixels.show(); 433 | } 434 | } 435 | } else if ( g.gestureValue == 0x4) { 436 | for (int i = 0; i<10; i++){ 437 | for (int j = 0; j < 4; j++) { 438 | if (i > 1-j && i < 9-j){ 439 | pixels.setPixelColor(-16+(i*8)+(j*9), pixels.Color(0,0,30)); 440 | pixels.setPixelColor(-9+(i*8)+(j*7), pixels.Color(0,0,30)); 441 | } else if (i > 8-j){ 442 | pixels.setPixelColor(56+j, pixels.Color(0,0,30)); 443 | pixels.setPixelColor(63-j, pixels.Color(0,0,30)); 444 | } 445 | } 446 | pixels.show(); 447 | delay(i*9); 448 | for (int j = 0; j < 4; j++) { 449 | if (i > 1-j && i < 9-j){ 450 | pixels.setPixelColor(-16+(i*8)+(j*9), 0); 451 | pixels.setPixelColor(-9+(i*8)+(j*7), 0); 452 | } else if (i > 8-j){ 453 | pixels.setPixelColor(56+j, 0); 454 | pixels.setPixelColor(63-j, 0); 455 | } 456 | pixels.show(); 457 | } 458 | } 459 | } 460 | } 461 | 462 | */ 463 | /* 464 | 465 | 466 | 467 | ////////////////////////////////////Position Example 468 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 469 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 470 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 471 | 472 | if( (currentMillis - previousMillis > interval)) { 473 | 474 | previousMillis = currentMillis; 475 | if ( !(p.x==0 && p.y==0 && p.x==0) ) { 476 | 477 | // scale raw position coordinates from (0,65535) to (0, 100). Set to 100 by default. Can be changed to any positive value for the desired granularity. 478 | p.x = map(p.x, 0, 65535, 0, 7); 479 | p.y = map(p.y, 0, 65535, 0, 7); 480 | p.z = map(p.z, 0, 65535, 0, 7); 481 | 482 | light = (64+(p.x))-(8*(p.y)); 483 | Serial.println(light); 484 | 485 | int r = 0; 486 | int g = 0; 487 | int b = 10; 488 | int a = 4; 489 | 490 | for (int i = 0; i<64; i++){ 491 | pixels.setPixelColor(i, pixels.Color(r+(p.z*a),g,b)); 492 | } 493 | //3 colors 494 | //1 - 2x2 square. The point we use as center is top right. 495 | //2 - Surrounding flower petals. 2 on each side of 2x2 square. 496 | //3 - The rest. 497 | 498 | pixels.setPixelColor(light, pixels.Color(r+(p.z*a),g,b+40)); 499 | pixels.setPixelColor(light+8, pixels.Color(r+(p.z*a),g,b+40)); 500 | pixels.setPixelColor(light-8, pixels.Color(r+(p.z*a),g,b+80)); 501 | pixels.setPixelColor(light+16, pixels.Color(r+(p.z*a),g,b+80)); 502 | 503 | //make sure we don't go over the edge 504 | if (light % 8 != 7){ 505 | pixels.setPixelColor(light+1, pixels.Color(r+(p.z*a),g,b+40)); 506 | pixels.setPixelColor(light+9, pixels.Color(r+(p.z*a),g,b+40)); 507 | 508 | pixels.setPixelColor(light-7, pixels.Color(r+(p.z*a),g,b+80)); 509 | pixels.setPixelColor(light+17, pixels.Color(r+(p.z*a),g,b+80)); 510 | } 511 | if (light % 8 != 7 && light % 8 != 6){ 512 | pixels.setPixelColor(light+2, pixels.Color(r+(p.z*a),g,b+80)); 513 | pixels.setPixelColor(light+10, pixels.Color(r+(p.z*a),g,b+80)); 514 | } 515 | if (light % 8 != 0){ 516 | pixels.setPixelColor(light-1, pixels.Color(r+(p.z*a),g,b+80)); 517 | pixels.setPixelColor(light+7, pixels.Color(r+(p.z*a),g,b+80)); 518 | } 519 | 520 | pixels.show(); 521 | } 522 | } 523 | */ 524 | } 525 | 526 | 527 | /* for(int i=0;i