1 #ifndef EAGLE_EBOARD_HELPLIB_NEOPIXEL 2 #define EAGLE_EBOARD_HELPLIB_NEOPIXEL 8 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 9 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 11 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 13 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 15 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 17 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 23 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 24 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 26 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 28 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 30 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 32 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 34 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 36 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 38 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 40 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 42 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 44 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 46 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 48 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 50 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 52 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 54 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 56 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 58 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 60 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 62 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 64 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 66 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 68 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 73 #define EBOARD_NEO_800KHZ 0x0000 74 #define EBOARD_NEO_400KHZ 0x0100 155 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
164 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
207 inline int8_t
getPin(
void);
219 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
227 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
260 #ifdef __AVR__ //not needed (rem?) 261 volatile uint8_t *port;
286 begun(false), brightness(0),
pixels(NULL), endTime(0) {
293 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
299 if(
pin >= 0) pinMode(
pin, INPUT);
304 pinMode(
pin, OUTPUT);
305 digitalWrite(
pin, LOW);
339 extern "C" void ICACHE_RAM_ATTR espShow(
340 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
342 extern "C" void espShow(
343 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
360 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 363 volatile uint8_t n1, n2 = 0;
366 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 370 hi = PORTD | pinMask;
371 lo = PORTD & ~pinMask;
373 if(b & 0x80) n1 = hi;
378 "out %[port] , %[hi]" "\n\t" 379 "mov %[n2] , %[lo]" "\n\t" 380 "out %[port] , %[n1]" "\n\t" 382 "sbrc %[byte] , 6" "\n\t" 383 "mov %[n2] , %[hi]" "\n\t" 384 "out %[port] , %[lo]" "\n\t" 387 "out %[port] , %[hi]" "\n\t" 388 "mov %[n1] , %[lo]" "\n\t" 389 "out %[port] , %[n2]" "\n\t" 391 "sbrc %[byte] , 5" "\n\t" 392 "mov %[n1] , %[hi]" "\n\t" 393 "out %[port] , %[lo]" "\n\t" 396 "out %[port] , %[hi]" "\n\t" 397 "mov %[n2] , %[lo]" "\n\t" 398 "out %[port] , %[n1]" "\n\t" 400 "sbrc %[byte] , 4" "\n\t" 401 "mov %[n2] , %[hi]" "\n\t" 402 "out %[port] , %[lo]" "\n\t" 405 "out %[port] , %[hi]" "\n\t" 406 "mov %[n1] , %[lo]" "\n\t" 407 "out %[port] , %[n2]" "\n\t" 409 "sbrc %[byte] , 3" "\n\t" 410 "mov %[n1] , %[hi]" "\n\t" 411 "out %[port] , %[lo]" "\n\t" 414 "out %[port] , %[hi]" "\n\t" 415 "mov %[n2] , %[lo]" "\n\t" 416 "out %[port] , %[n1]" "\n\t" 418 "sbrc %[byte] , 2" "\n\t" 419 "mov %[n2] , %[hi]" "\n\t" 420 "out %[port] , %[lo]" "\n\t" 423 "out %[port] , %[hi]" "\n\t" 424 "mov %[n1] , %[lo]" "\n\t" 425 "out %[port] , %[n2]" "\n\t" 427 "sbrc %[byte] , 1" "\n\t" 428 "mov %[n1] , %[hi]" "\n\t" 429 "out %[port] , %[lo]" "\n\t" 432 "out %[port] , %[hi]" "\n\t" 433 "mov %[n2] , %[lo]" "\n\t" 434 "out %[port] , %[n1]" "\n\t" 436 "sbrc %[byte] , 0" "\n\t" 437 "mov %[n2] , %[hi]" "\n\t" 438 "out %[port] , %[lo]" "\n\t" 439 "sbiw %[count], 1" "\n\t" 441 "out %[port] , %[hi]" "\n\t" 442 "mov %[n1] , %[lo]" "\n\t" 443 "out %[port] , %[n2]" "\n\t" 444 "ld %[byte] , %a[ptr]+" "\n\t" 445 "sbrc %[byte] , 7" "\n\t" 446 "mov %[n1] , %[hi]" "\n\t" 447 "out %[port] , %[lo]" "\n\t" 453 : [port]
"I" (_SFR_IO_ADDR(PORTD)),
458 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 463 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 465 #endif // defined(PORTD/C/F) 466 hi = PORTB | pinMask;
467 lo = PORTB & ~pinMask;
469 if(b & 0x80) n1 = hi;
473 "out %[port] , %[hi]" "\n\t" 474 "mov %[n2] , %[lo]" "\n\t" 475 "out %[port] , %[n1]" "\n\t" 477 "sbrc %[byte] , 6" "\n\t" 478 "mov %[n2] , %[hi]" "\n\t" 479 "out %[port] , %[lo]" "\n\t" 481 "out %[port] , %[hi]" "\n\t" 482 "mov %[n1] , %[lo]" "\n\t" 483 "out %[port] , %[n2]" "\n\t" 485 "sbrc %[byte] , 5" "\n\t" 486 "mov %[n1] , %[hi]" "\n\t" 487 "out %[port] , %[lo]" "\n\t" 489 "out %[port] , %[hi]" "\n\t" 490 "mov %[n2] , %[lo]" "\n\t" 491 "out %[port] , %[n1]" "\n\t" 493 "sbrc %[byte] , 4" "\n\t" 494 "mov %[n2] , %[hi]" "\n\t" 495 "out %[port] , %[lo]" "\n\t" 497 "out %[port] , %[hi]" "\n\t" 498 "mov %[n1] , %[lo]" "\n\t" 499 "out %[port] , %[n2]" "\n\t" 501 "sbrc %[byte] , 3" "\n\t" 502 "mov %[n1] , %[hi]" "\n\t" 503 "out %[port] , %[lo]" "\n\t" 505 "out %[port] , %[hi]" "\n\t" 506 "mov %[n2] , %[lo]" "\n\t" 507 "out %[port] , %[n1]" "\n\t" 509 "sbrc %[byte] , 2" "\n\t" 510 "mov %[n2] , %[hi]" "\n\t" 511 "out %[port] , %[lo]" "\n\t" 513 "out %[port] , %[hi]" "\n\t" 514 "mov %[n1] , %[lo]" "\n\t" 515 "out %[port] , %[n2]" "\n\t" 517 "sbrc %[byte] , 1" "\n\t" 518 "mov %[n1] , %[hi]" "\n\t" 519 "out %[port] , %[lo]" "\n\t" 521 "out %[port] , %[hi]" "\n\t" 522 "mov %[n2] , %[lo]" "\n\t" 523 "out %[port] , %[n1]" "\n\t" 525 "sbrc %[byte] , 0" "\n\t" 526 "mov %[n2] , %[hi]" "\n\t" 527 "out %[port] , %[lo]" "\n\t" 528 "sbiw %[count], 1" "\n\t" 529 "out %[port] , %[hi]" "\n\t" 530 "mov %[n1] , %[lo]" "\n\t" 531 "out %[port] , %[n2]" "\n\t" 532 "ld %[byte] , %a[ptr]+" "\n\t" 533 "sbrc %[byte] , 7" "\n\t" 534 "mov %[n1] , %[hi]" "\n\t" 535 "out %[port] , %[lo]" "\n\t" 537 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
538 : [port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
541 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 544 #if defined(PORTC) || defined(PORTF) 550 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 554 hi = PORTC | pinMask;
555 lo = PORTC & ~pinMask;
557 if(b & 0x80) n1 = hi;
561 "out %[port] , %[hi]" "\n\t" 562 "mov %[n2] , %[lo]" "\n\t" 563 "out %[port] , %[n1]" "\n\t" 565 "sbrc %[byte] , 6" "\n\t" 566 "mov %[n2] , %[hi]" "\n\t" 567 "out %[port] , %[lo]" "\n\t" 569 "out %[port] , %[hi]" "\n\t" 570 "mov %[n1] , %[lo]" "\n\t" 571 "out %[port] , %[n2]" "\n\t" 573 "sbrc %[byte] , 5" "\n\t" 574 "mov %[n1] , %[hi]" "\n\t" 575 "out %[port] , %[lo]" "\n\t" 577 "out %[port] , %[hi]" "\n\t" 578 "mov %[n2] , %[lo]" "\n\t" 579 "out %[port] , %[n1]" "\n\t" 581 "sbrc %[byte] , 4" "\n\t" 582 "mov %[n2] , %[hi]" "\n\t" 583 "out %[port] , %[lo]" "\n\t" 585 "out %[port] , %[hi]" "\n\t" 586 "mov %[n1] , %[lo]" "\n\t" 587 "out %[port] , %[n2]" "\n\t" 589 "sbrc %[byte] , 3" "\n\t" 590 "mov %[n1] , %[hi]" "\n\t" 591 "out %[port] , %[lo]" "\n\t" 593 "out %[port] , %[hi]" "\n\t" 594 "mov %[n2] , %[lo]" "\n\t" 595 "out %[port] , %[n1]" "\n\t" 597 "sbrc %[byte] , 2" "\n\t" 598 "mov %[n2] , %[hi]" "\n\t" 599 "out %[port] , %[lo]" "\n\t" 601 "out %[port] , %[hi]" "\n\t" 602 "mov %[n1] , %[lo]" "\n\t" 603 "out %[port] , %[n2]" "\n\t" 605 "sbrc %[byte] , 1" "\n\t" 606 "mov %[n1] , %[hi]" "\n\t" 607 "out %[port] , %[lo]" "\n\t" 609 "out %[port] , %[hi]" "\n\t" 610 "mov %[n2] , %[lo]" "\n\t" 611 "out %[port] , %[n1]" "\n\t" 613 "sbrc %[byte] , 0" "\n\t" 614 "mov %[n2] , %[hi]" "\n\t" 615 "out %[port] , %[lo]" "\n\t" 616 "sbiw %[count], 1" "\n\t" 617 "out %[port] , %[hi]" "\n\t" 618 "mov %[n1] , %[lo]" "\n\t" 619 "out %[port] , %[n2]" "\n\t" 620 "ld %[byte] , %a[ptr]+" "\n\t" 621 "sbrc %[byte] , 7" "\n\t" 622 "mov %[n1] , %[hi]" "\n\t" 623 "out %[port] , %[lo]" "\n\t" 625 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
626 : [port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
629 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 638 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 640 #endif // defined(PORTD/B/C) 642 hi = PORTF | pinMask;
643 lo = PORTF & ~pinMask;
645 if(b & 0x80) n1 = hi;
649 "out %[port] , %[hi]" "\n\t" 650 "mov %[n2] , %[lo]" "\n\t" 651 "out %[port] , %[n1]" "\n\t" 653 "sbrc %[byte] , 6" "\n\t" 654 "mov %[n2] , %[hi]" "\n\t" 655 "out %[port] , %[lo]" "\n\t" 657 "out %[port] , %[hi]" "\n\t" 658 "mov %[n1] , %[lo]" "\n\t" 659 "out %[port] , %[n2]" "\n\t" 661 "sbrc %[byte] , 5" "\n\t" 662 "mov %[n1] , %[hi]" "\n\t" 663 "out %[port] , %[lo]" "\n\t" 665 "out %[port] , %[hi]" "\n\t" 666 "mov %[n2] , %[lo]" "\n\t" 667 "out %[port] , %[n1]" "\n\t" 669 "sbrc %[byte] , 4" "\n\t" 670 "mov %[n2] , %[hi]" "\n\t" 671 "out %[port] , %[lo]" "\n\t" 673 "out %[port] , %[hi]" "\n\t" 674 "mov %[n1] , %[lo]" "\n\t" 675 "out %[port] , %[n2]" "\n\t" 677 "sbrc %[byte] , 3" "\n\t" 678 "mov %[n1] , %[hi]" "\n\t" 679 "out %[port] , %[lo]" "\n\t" 681 "out %[port] , %[hi]" "\n\t" 682 "mov %[n2] , %[lo]" "\n\t" 683 "out %[port] , %[n1]" "\n\t" 685 "sbrc %[byte] , 2" "\n\t" 686 "mov %[n2] , %[hi]" "\n\t" 687 "out %[port] , %[lo]" "\n\t" 689 "out %[port] , %[hi]" "\n\t" 690 "mov %[n1] , %[lo]" "\n\t" 691 "out %[port] , %[n2]" "\n\t" 693 "sbrc %[byte] , 1" "\n\t" 694 "mov %[n1] , %[hi]" "\n\t" 695 "out %[port] , %[lo]" "\n\t" 697 "out %[port] , %[hi]" "\n\t" 698 "mov %[n2] , %[lo]" "\n\t" 699 "out %[port] , %[n1]" "\n\t" 701 "sbrc %[byte] , 0" "\n\t" 702 "mov %[n2] , %[hi]" "\n\t" 703 "out %[port] , %[lo]" "\n\t" 704 "sbiw %[count], 1" "\n\t" 705 "out %[port] , %[hi]" "\n\t" 706 "mov %[n1] , %[lo]" "\n\t" 707 "out %[port] , %[n2]" "\n\t" 708 "ld %[byte] , %a[ptr]+" "\n\t" 709 "sbrc %[byte] , 7" "\n\t" 710 "mov %[n1] , %[hi]" "\n\t" 711 "out %[port] , %[lo]" "\n\t" 713 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
714 : [port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
717 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 719 #endif // defined(PORTD/B/C) 720 #endif // defined(PORTF) 723 volatile uint8_t next, bit;
725 hi = *port | pinMask;
726 lo = *port & ~pinMask;
732 "st %a[port], %[hi]" "\n\t" 733 "sbrc %[byte] , 7" "\n\t" 734 "mov %[next], %[hi]" "\n\t" 735 "st %a[port], %[next]" "\n\t" 736 "mov %[next] , %[lo]" "\n\t" 738 "breq nextbyte20" "\n\t" 740 "st %a[port], %[lo]" "\n\t" 746 "st %a[port], %[lo]" "\n\t" 748 "ldi %[bit] , 8" "\n\t" 749 "ld %[byte] , %a[ptr]+" "\n\t" 750 "sbiw %[count], 1" "\n\t" 752 : [port]
"+e" (port),
761 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 763 volatile uint8_t next;
768 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 772 hi = PORTD | pinMask;
773 lo = PORTD & ~pinMask;
775 if(b & 0x80) next = hi;
778 "out %[port], %[hi]" "\n\t" 779 "rcall bitTimeD" "\n\t" 780 "out %[port], %[hi]" "\n\t" 781 "rcall bitTimeD" "\n\t" 782 "out %[port], %[hi]" "\n\t" 783 "rcall bitTimeD" "\n\t" 784 "out %[port], %[hi]" "\n\t" 785 "rcall bitTimeD" "\n\t" 786 "out %[port], %[hi]" "\n\t" 787 "rcall bitTimeD" "\n\t" 788 "out %[port], %[hi]" "\n\t" 789 "rcall bitTimeD" "\n\t" 790 "out %[port], %[hi]" "\n\t" 791 "rcall bitTimeD" "\n\t" 793 "out %[port] , %[hi]" "\n\t" 795 "ld %[byte] , %a[ptr]+" "\n\t" 796 "out %[port] , %[next]" "\n\t" 797 "mov %[next] , %[lo]" "\n\t" 798 "sbrc %[byte] , 7" "\n\t" 799 "mov %[next] , %[hi]" "\n\t" 801 "out %[port] , %[lo]" "\n\t" 802 "sbiw %[count], 1" "\n\t" 806 "out %[port], %[next]" "\n\t" 807 "mov %[next], %[lo]" "\n\t" 809 "sbrc %[byte], 7" "\n\t" 810 "mov %[next], %[hi]" "\n\t" 812 "out %[port], %[lo]" "\n\t" 818 : [port]
"I" (_SFR_IO_ADDR(PORTD)),
823 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 829 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 833 hi = PORTB | pinMask;
834 lo = PORTB & ~pinMask;
836 if(b & 0x80) next = hi;
840 "out %[port], %[hi]" "\n\t" 841 "rcall bitTimeB" "\n\t" 842 "out %[port], %[hi]" "\n\t" 843 "rcall bitTimeB" "\n\t" 844 "out %[port], %[hi]" "\n\t" 845 "rcall bitTimeB" "\n\t" 846 "out %[port], %[hi]" "\n\t" 847 "rcall bitTimeB" "\n\t" 848 "out %[port], %[hi]" "\n\t" 849 "rcall bitTimeB" "\n\t" 850 "out %[port], %[hi]" "\n\t" 851 "rcall bitTimeB" "\n\t" 852 "out %[port], %[hi]" "\n\t" 853 "rcall bitTimeB" "\n\t" 854 "out %[port] , %[hi]" "\n\t" 856 "ld %[byte] , %a[ptr]+" "\n\t" 857 "out %[port] , %[next]" "\n\t" 858 "mov %[next] , %[lo]" "\n\t" 859 "sbrc %[byte] , 7" "\n\t" 860 "mov %[next] , %[hi]" "\n\t" 862 "out %[port] , %[lo]" "\n\t" 863 "sbiw %[count], 1" "\n\t" 867 "out %[port], %[next]" "\n\t" 868 "mov %[next], %[lo]" "\n\t" 870 "sbrc %[byte], 7" "\n\t" 871 "mov %[next], %[hi]" "\n\t" 873 "out %[port], %[lo]" "\n\t" 876 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
877 : [port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
880 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 883 #if defined(PORTC) || defined(PORTF) 889 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 893 hi = PORTC | pinMask;
894 lo = PORTC & ~pinMask;
896 if(b & 0x80) next = hi;
900 "out %[port], %[hi]" "\n\t" 901 "rcall bitTimeC" "\n\t" 902 "out %[port], %[hi]" "\n\t" 903 "rcall bitTimeC" "\n\t" 904 "out %[port], %[hi]" "\n\t" 905 "rcall bitTimeC" "\n\t" 906 "out %[port], %[hi]" "\n\t" 907 "rcall bitTimeC" "\n\t" 908 "out %[port], %[hi]" "\n\t" 909 "rcall bitTimeC" "\n\t" 910 "out %[port], %[hi]" "\n\t" 911 "rcall bitTimeC" "\n\t" 912 "out %[port], %[hi]" "\n\t" 913 "rcall bitTimeC" "\n\t" 914 "out %[port] , %[hi]" "\n\t" 916 "ld %[byte] , %a[ptr]+" "\n\t" 917 "out %[port] , %[next]" "\n\t" 918 "mov %[next] , %[lo]" "\n\t" 919 "sbrc %[byte] , 7" "\n\t" 920 "mov %[next] , %[hi]" "\n\t" 922 "out %[port] , %[lo]" "\n\t" 923 "sbiw %[count], 1" "\n\t" 927 "out %[port], %[next]" "\n\t" 928 "mov %[next], %[lo]" "\n\t" 930 "sbrc %[byte], 7" "\n\t" 931 "mov %[next], %[hi]" "\n\t" 933 "out %[port], %[lo]" "\n\t" 936 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
937 : [port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
940 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 949 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 953 hi = PORTF | pinMask;
954 lo = PORTF & ~pinMask;
956 if(b & 0x80) next = hi;
960 "out %[port], %[hi]" "\n\t" 961 "rcall bitTimeC" "\n\t" 962 "out %[port], %[hi]" "\n\t" 963 "rcall bitTimeC" "\n\t" 964 "out %[port], %[hi]" "\n\t" 965 "rcall bitTimeC" "\n\t" 966 "out %[port], %[hi]" "\n\t" 967 "rcall bitTimeC" "\n\t" 968 "out %[port], %[hi]" "\n\t" 969 "rcall bitTimeC" "\n\t" 970 "out %[port], %[hi]" "\n\t" 971 "rcall bitTimeC" "\n\t" 972 "out %[port], %[hi]" "\n\t" 973 "rcall bitTimeC" "\n\t" 974 "out %[port] , %[hi]" "\n\t" 976 "ld %[byte] , %a[ptr]+" "\n\t" 977 "out %[port] , %[next]" "\n\t" 978 "mov %[next] , %[lo]" "\n\t" 979 "sbrc %[byte] , 7" "\n\t" 980 "mov %[next] , %[hi]" "\n\t" 982 "out %[port] , %[lo]" "\n\t" 983 "sbiw %[count], 1" "\n\t" 987 "out %[port], %[next]" "\n\t" 988 "mov %[next], %[lo]" "\n\t" 990 "sbrc %[byte], 7" "\n\t" 991 "mov %[next], %[hi]" "\n\t" 993 "out %[port], %[lo]" "\n\t" 996 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
997 : [port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
1000 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 1005 volatile uint8_t next, bit;
1007 hi = *port | pinMask;
1008 lo = *port & ~pinMask;
1014 "st %a[port], %[hi]" "\n\t" 1015 "sbrc %[byte] , 7" "\n\t" 1016 "mov %[next], %[hi]" "\n\t" 1018 "st %a[port], %[next]" "\n\t" 1023 "st %a[port], %[lo]" "\n\t" 1026 "breq nextbyte30" "\n\t" 1027 "rol %[byte]" "\n\t" 1031 "rjmp head30" "\n\t" 1032 "nextbyte30:" "\n\t" 1034 "ldi %[bit] , 8" "\n\t" 1035 "ld %[byte] , %a[ptr]+" "\n\t" 1036 "sbiw %[count], 1" "\n\t" 1038 : [port]
"+e" (port),
1047 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 1049 volatile uint8_t next, bit;
1051 hi = *port | pinMask;
1052 lo = *port & ~pinMask;
1058 "st %a[port], %[hi]" "\n\t" 1059 "sbrc %[byte], 7" "\n\t" 1060 "mov %[next], %[hi]" "\n\t" 1062 "st %a[port], %[next]" "\n\t" 1063 "mov %[next] , %[lo]" "\n\t" 1064 "breq nextbyte20" "\n\t" 1065 "rol %[byte]" "\n\t" 1068 "st %a[port], %[lo]" "\n\t" 1071 "rjmp head20" "\n\t" 1072 "nextbyte20:" "\n\t" 1073 "ldi %[bit] , 8" "\n\t" 1074 "ld %[byte] , %a[ptr]+" "\n\t" 1075 "st %a[port], %[lo]" "\n\t" 1077 "sbiw %[count], 1" "\n\t" 1079 : [port]
"+e" (port),
1089 volatile uint8_t next, bit;
1091 hi = *port | pinMask;
1092 lo = *port & ~pinMask;
1098 "st %a[port], %[hi]" "\n\t" 1099 "sbrc %[byte] , 7" "\n\t" 1100 "mov %[next] , %[hi]" "\n\t" 1103 "st %a[port], %[next]" "\n\t" 1109 "st %a[port], %[lo]" "\n\t" 1111 "mov %[next] , %[lo]" "\n\t" 1113 "breq nextbyte40" "\n\t" 1114 "rol %[byte]" "\n\t" 1121 "rjmp head40" "\n\t" 1122 "nextbyte40:" "\n\t" 1123 "ldi %[bit] , 8" "\n\t" 1124 "ld %[byte] , %a[ptr]+" "\n\t" 1126 "st %a[port], %[lo]" "\n\t" 1128 "sbiw %[count], 1" "\n\t" 1130 : [port]
"+e" (port),
1140 #error "CPU SPEED NOT SUPPORTED" 1142 #elif defined(__arm__) 1145 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 1146 #define CYCLES_800_T0H (F_CPU / 4000000) 1147 #define CYCLES_800_T1H (F_CPU / 1250000) 1148 #define CYCLES_800 (F_CPU / 800000) 1149 #define CYCLES_400_T0H (F_CPU / 2000000) 1150 #define CYCLES_400_T1H (F_CPU / 833333) 1151 #define CYCLES_400 (F_CPU / 400000) 1155 volatile uint8_t *
set = portSetRegister(
pin),
1156 *clr = portClearRegister(
pin);
1159 ARM_DEMCR |= ARM_DEMCR_TRCENA;
1160 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
1163 cyc = ARM_DWT_CYCCNT + CYCLES_800;
1166 for(mask = 0x80; mask; mask >>= 1) {
1167 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
1168 cyc = ARM_DWT_CYCCNT;
1171 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
1173 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
1178 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
1180 cyc = ARM_DWT_CYCCNT + CYCLES_400;
1183 for(mask = 0x80; mask; mask >>= 1) {
1184 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
1185 cyc = ARM_DWT_CYCCNT;
1188 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
1190 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
1195 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
1198 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 1200 #elif defined(ESP8266) || defined(ESP32) 1204 #elif defined(__ARDUINO_ARC__) 1208 #define NOPx7 { __builtin_arc_nop(); \ 1209 __builtin_arc_nop(); __builtin_arc_nop(); \ 1210 __builtin_arc_nop(); __builtin_arc_nop(); \ 1211 __builtin_arc_nop(); __builtin_arc_nop(); } 1213 PinDescription *pindesc = &g_APinDescription[
pin];
1214 register uint32_t loop = 8 *
numBytes;
1215 register uint8_t *p =
pixels;
1216 register uint32_t currByte = (uint32_t) (*p);
1217 register uint32_t currBit = 0x80 & currByte;
1218 register uint32_t bitCounter = 0;
1219 register uint32_t first = 1;
1221 if (pindesc->ulGPIOType == SS_GPIO) {
1222 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
1223 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
1224 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
1225 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
1235 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
1242 __builtin_arc_nop();
1245 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
1249 if(bitCounter >= 8) {
1251 currByte = (uint32_t) (*++p);
1254 currBit = 0x80 & currByte;
1257 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
1258 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
1259 uint32_t reg_val = MMIO_REG_VAL(reg);
1260 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
1261 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
1269 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
1273 __builtin_arc_nop();
1279 MMIO_REG_VAL(reg) = reg_bit_low;
1283 if(bitCounter >= 8) {
1285 currByte = (uint32_t) (*++p);
1288 currBit = 0x80 & currByte;
1294 #error Architecture not supported 1307 digitalWrite(p, LOW);
1310 port = portOutputRegister(digitalPinToPort(p));
1311 pinMask = digitalPinToBitMask(p);
1316 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
1338 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
1363 r = (uint8_t)(c >> 16),
1364 g = (uint8_t)(c >> 8),
1375 uint8_t w = (uint8_t)(c >> 24);
1385 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
1388 uint32_t
NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
1389 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
1405 return ((uint32_t)p[
aOffset[0]] << 16) |
1406 ((uint32_t)p[
aOffset[1]] << 8) |
1417 return ((uint32_t)p[
aOffset[3]] << 24) |
1418 ((uint32_t)p[
aOffset[0]] << 16) |
1419 ((uint32_t)p[
aOffset[1]] << 8) |
1429 uint8_t newBrightness = b + 1;
1435 if(oldBrightness == 0) scale = 0;
1436 else if(b == 255) scale = 65535 / oldBrightness;
1437 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
1438 for(uint16_t i=0; i<
numBytes; i++) {
1440 *ptr++ = (c * scale) >> 8;
uint8_t * pixels
stores the pixels
int8_t pin
stores the pin -1 if the pin wasn't set
uint8_t aOffset[4]
stores the offsets in rgbw format
bool canShow(void)
this will determine if the next show is available [last show finished]
uint8_t getBrightness(void) const
returns the current set brightness
uint16_t numLEDs
stores the amount of LEDs
~NeoPixel(void)
the destructor [calling free on pixel and freeing input pin]
bool begun
true if NeoPixel::begin has been called
int8_t getPin(void)
this will return the set data pin
NeoPixel pixels
the NeoPixel-object we use
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b)
sets the rgb color of a specific pixel
void updateLength(uint16_t n)
this changes the length of the connected LED stripe
uint16_t numBytes
stores the byte size [pixels] used internally
static uint32_t Color(uint8_t r, uint8_t g, uint8_t b)
returns a color value that can be used with NeoPixel::setPixelColor()
void setPin(uint8_t p)
sets pin for communication
void clear(void)
this will reset all set pixels [won't call NeoPixel::show()]
uint8_t * getPixels(void) const
this will give you access to the pixels
void updateType(uint16_t t)
this changes the type of communication between arduino and LED stripe
NeoPixel(void)
the empty constructor
uint32_t endTime
stores the last call time of show for NeoPixel::canShow()
void setBrightness(uint8_t val)
changes the brightness for all further acceses via NeoPixel::setPixelColor()
uint8_t brightness
stores the brightness
#define EBOARD_NEO_800KHZ
bool is800KHz
determines the speed the communcation is working on
void begin(void)
this has to be called to start the communcation (you should call NeoPixel::setPin() before) ...
[NEO] this allows you to access Adafruit LED-stripes
uint32_t getPixelColor(uint16_t n) const
returns the color of a specific pixel
void show(void)
this will reveal the setPixels [via NeoPixel::setPixelColor() etc...]
uint16_t numPixels(void) const
returns the size of the LED stripe