7 #pragma GCC diagnostic push 8 #pragma GCC diagnostic ignored "-Wall" 9 #pragma GCC diagnostic ignored "-Wextra" 14 #define EBOARD_VERSION "3.1m" 15 #define VALUE_TO_STRING(x) #x 19 #define PREPROCESS_DEBUG 1 22 #define VALUE(x) VALUE_TO_STRING(x) 24 #ifndef PREPROCESS_DEBUG 26 #define PREPROCESS_DEBUG 0 28 #define PPERFORM_PRAGMA(str) _Pragma(#str) 30 #if PREPROCESS_DEBUG == 1 31 #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str)) 33 #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str)) 35 #define DEBUG_MSG(str) ; 36 #define MACRO_MSG(mac,str) ; 38 DEBUG_MSG(
"If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
40 DEBUG_MSG(
"You are using eBoard-header v3.1m written by EagleoutIce");
482 #ifndef EBOARD_HEADER_GUARD 483 #define EBOARD_HEADER_GUARD 486 DEBUG_MSG(
"Documentation macro SET => Full doc features enabled");
491 #define EBOARD_I2C 0x1 496 #define EBOARD_LCD 0x1 500 #define EBOARD_SHIFT_REGISTER 0x1 504 #define EBOARD_BLUETOOTH 0x1 512 #define __AVR_ATmega2560__ 516 #define __AVR_ATmega328P__ 520 #define EBOARD_NEO 0x1 532 #include <avr/pgmspace.h> 539 #ifndef EBOARD_GUESSPATH 540 DEBUG_MSG(
"You are using Guesspath! Necessary libraries for eBoard will be included automatically");
544 #define EBOARD_GUESSPATH 0x1 546 DEBUG_MSG(
"You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
549 #if defined(ARDUINO) //general platform-check [No tab] 554 #define main eVirtual_main //main has a different meaning^^ 556 #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D 562 #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__)) 563 #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!" 566 #if defined(__AVR_ATmega2560__) 567 DEBUG_MSG(
"Building for Arduino Mega with ATmega2560");
571 #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS 573 DEBUG_MSG(
"Building for Arduino Uno or Nano with ATmega328P");
574 #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS 578 #include <avr/interrupt.h> 580 #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0 581 DEBUG_MSG(
"You enabled I²C feature"s);
588 #define TWI_FREQ 100000L 591 # ifndef TWI_BUFFER_LENGTH 592 #define TWI_BUFFER_LENGTH 32 603 #include <avr/interrupt.h> 604 #include <compat/twi.h> 607 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 611 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 614 #include "pins_arduino.h" 616 static volatile uint8_t twi_state;
617 static volatile uint8_t twi_slarw;
618 static volatile uint8_t twi_sendStop;
619 static volatile uint8_t twi_inRepStart;
621 static void (*twi_onSlaveTransmit)(void);
622 static void (*twi_onSlaveReceive)(uint8_t*, int);
624 static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
625 static volatile uint8_t twi_masterBufferIndex;
626 static volatile uint8_t twi_masterBufferLength;
628 static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
629 static volatile uint8_t twi_txBufferIndex;
630 static volatile uint8_t twi_txBufferLength;
632 static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
633 static volatile uint8_t twi_rxBufferIndex;
635 static volatile uint8_t twi_error;
637 void twi_init(
void) {
638 twi_state = TWI_READY;
640 twi_inRepStart =
false;
642 digitalWrite(SDA, 1);
643 digitalWrite(SCL, 1);
647 TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
649 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
652 inline void twi_setAddress(uint8_t address) {
656 uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) {
659 if(TWI_BUFFER_LENGTH < length)
return 0;
661 while(TWI_READY != twi_state)
continue;
664 twi_sendStop = sendStop;
668 twi_masterBufferIndex = 0;
669 twi_masterBufferLength = length-1;
671 twi_slarw |= address << 1;
673 if (
true == twi_inRepStart) {
674 twi_inRepStart =
false;
676 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
679 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
681 while(TWI_MRX == twi_state)
continue;
683 if (twi_masterBufferIndex < length)
684 length = twi_masterBufferIndex;
686 for(i = 0; i < length; ++i) data[i] = twi_masterBuffer[i];
691 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) {
694 if(TWI_BUFFER_LENGTH < length)
return 1;
696 while(TWI_READY != twi_state)
continue;
699 twi_sendStop = sendStop;
702 twi_masterBufferIndex = 0;
703 twi_masterBufferLength = length;
705 for(i = 0; i < length; ++i) twi_masterBuffer[i] = data[i];
707 twi_slarw = TW_WRITE;
708 twi_slarw |= address << 1;
710 if (
true == twi_inRepStart) {
711 twi_inRepStart =
false;
713 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
716 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
718 while(wait && (TWI_MTX == twi_state))
continue;
720 if (twi_error == 0xFF)
return 0;
721 else if (twi_error == TW_MT_SLA_NACK)
return 2;
722 else if (twi_error == TW_MT_DATA_NACK)
return 3;
726 uint8_t twi_transmit(
const uint8_t* data, uint8_t length) {
729 if(TWI_BUFFER_LENGTH < length)
return 1;
731 if(TWI_STX != twi_state)
return 2;
733 twi_txBufferLength = length;
734 for(i = 0; i < length; ++i) twi_txBuffer[i] = data[i];
739 void twi_attachSlaveRxEvent(
void (*
function)(uint8_t*,
int) ) {
740 twi_onSlaveReceive =
function;
743 void twi_attachSlaveTxEvent(
void (*
function)(
void) ) {
744 twi_onSlaveTransmit =
function;
747 void twi_reply(uint8_t ack) {
749 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
751 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
756 void twi_stop(
void) {
757 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
759 while(TWCR & _BV(TWSTO))
continue;
761 twi_state = TWI_READY;
764 void twi_releaseBus(
void){
765 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
766 twi_state = TWI_READY;
779 if(twi_masterBufferIndex < twi_masterBufferLength){
780 TWDR = twi_masterBuffer[twi_masterBufferIndex++];
783 if (twi_sendStop) twi_stop();
785 twi_inRepStart =
true;
786 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
787 twi_state = TWI_READY;
792 twi_error = TW_MT_SLA_NACK;
795 case TW_MT_DATA_NACK:
796 twi_error = TW_MT_DATA_NACK;
800 twi_error = TW_MT_ARB_LOST;
804 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
806 if(twi_masterBufferIndex < twi_masterBufferLength) twi_reply(1);
809 case TW_MR_DATA_NACK:
810 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
811 if (twi_sendStop) twi_stop();
813 twi_inRepStart =
true;
814 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
815 twi_state = TWI_READY;
822 case TW_SR_GCALL_ACK:
823 case TW_SR_ARB_LOST_SLA_ACK:
824 case TW_SR_ARB_LOST_GCALL_ACK:
826 twi_rxBufferIndex = 0;
830 case TW_SR_GCALL_DATA_ACK:
831 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
832 twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
838 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH) twi_rxBuffer[twi_rxBufferIndex] =
'\0';
840 twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
841 twi_rxBufferIndex = 0;
844 case TW_SR_DATA_NACK:
845 case TW_SR_GCALL_DATA_NACK:
849 case TW_ST_ARB_LOST_SLA_ACK:
851 twi_txBufferIndex = 0;
852 twi_txBufferLength = 0;
853 twi_onSlaveTransmit();
854 if(0 == twi_txBufferLength){
855 twi_txBufferLength = 1;
856 twi_txBuffer[0] = 0x00;
859 TWDR = twi_txBuffer[twi_txBufferIndex++];
860 if(twi_txBufferIndex < twi_txBufferLength) twi_reply(1);
863 case TW_ST_DATA_NACK:
864 case TW_ST_LAST_DATA:
866 twi_state = TWI_READY;
872 twi_error = TW_BUS_ERROR;
879 #include <inttypes.h> 882 #define BUFFER_LENGTH 32 945 void begin(uint8_t address);
951 inline void begin(
int address);
992 inline uint8_t
requestFrom(uint8_t address, uint8_t quantity);
1000 uint8_t
requestFrom(uint8_t address , uint8_t quantity, uint8_t sendStop);
1008 inline uint8_t
requestFrom(
int address,
int quantity);
1017 inline uint8_t
requestFrom(
int address,
int quantity,
int sendStop);
1026 virtual size_t write(uint8_t data);
1034 virtual size_t write(
const uint8_t *data,
size_t quantity);
1045 virtual int read(
void);
1051 virtual int peek(
void);
1058 void onReceive(
void (*
function)(
int) );
1065 void onRequest(
void (*
function)(
void) );
1079 #include <inttypes.h> 1110 twi_setAddress(address);
1117 begin((uint8_t)address);
1124 uint8_t
read = twi_readFrom(address,
rxBuffer, quantity, sendStop);
1132 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1136 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1140 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
1176 twi_transmit(&data, 1);
1183 for(
size_t i = 0; i < quantity; ++i) {
1187 twi_transmit(data, quantity);
1226 for(uint8_t i = 0; i < numBytes; ++i) {
1256 DEBUG_MSG(
"You disabled I²C");
1261 #ifndef EBOARD_USE_SPI 1262 #define EBOARD_USE_SPI 0x1 1264 #if EBOARD_USE_SPI > 0x0 1265 DEBUG_MSG(
"You enabled SPI");
1267 #define _SPI_H_INCLUDED 1271 #define SPI_CLOCK_DIV4 0x00 1272 #define SPI_CLOCK_DIV16 0x01 1274 #define SPI_CLOCK_DIV64 0x02 1276 #define SPI_CLOCK_DIV128 0x03 1278 #define SPI_CLOCK_DIV2 0x04 1280 #define SPI_CLOCK_DIV8 0x05 1282 #define SPI_CLOCK_DIV32 0x06 1286 #define SPI_MODE0 0x00 1287 #define SPI_MODE1 0x04 1289 #define SPI_MODE2 0x08 1291 #define SPI_MODE3 0x0C 1295 #define SPI_MODE_MASK 0x0C 1296 #define SPI_CLOCK_MASK 0x03 1298 #define SPI_2XCLOCK_MASK 0x01 1320 inline static byte
transfer(byte _data);
1332 static void begin(
void);
1336 inline static void end(
void);
1357 while (!(SPSR & _BV(SPIF)));
1366 digitalWrite(SS, HIGH);
1367 pinMode(SS, OUTPUT);
1370 pinMode(SCK, OUTPUT);
1371 pinMode(MOSI, OUTPUT);
1377 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
1378 else SPCR &= ~(_BV(DORD));
1392 DEBUG_MSG(
"You disabled SPI");
1395 #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0) 1396 #include <avr/pgmspace.h> 1397 DEBUG_MSG(
"You enabled LCD");
1411 DEBUG_MSG(
"You defined IGNORE_SIZE: byte will be used");
1414 DEBUG_MSG(
"You did not define IGNORE_SIZE: int will be used");
1421 #ifndef EBOARD_DEBUG_MODE 1422 #define EBOARD_DEBUG_MODE 0x1 1425 #if EBOARD_DEBUG_MODE > 0x0 1436 #define EBOARD_NANO 0x0 1439 #if EBOARD_NANO > 0x0 || defined(DOC) 1440 #ifndef EBOARD_NANO_STEER 1444 #define EBOARD_NANO_STEER 12 1446 #ifndef EBOARD_NANO_MAIN 1450 #define EBOARD_NANO_MAIN 13 1452 MACRO_MSG(
EBOARD_NANO,
"Using Arduino NANO environment [e.g. remove SoccerBoard]");
1453 #if PREPROCESS_DEBUG > 0x1 1454 #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR") 1455 #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR") 1458 MACRO_MSG(
EBOARD_NANO,
"Using Arduino UNO/MEGA environment");
1464 #ifndef EBOARD_CHECK_PINS 1465 #define EBOARD_CHECK_PINS 0x1 1468 #if EBOARD_CHECK_PINS > 0x0 1474 #ifndef EBOARD_SHIFT_REGISTER 1478 #define EBOARD_SHIFT_REGISTER 0x0 1481 #if EBOARD_SHIFT_REGISTER > 0x0 1490 #ifndef EBOARD_CHECK_PINS_PWM 1491 #define EBOARD_CHECK_PINS_PWM 0x1 1494 #if EBOARD_CHECK_PINS_PWM > 0x0 1503 #ifndef EBOARD_DEBUG_SPEED 1504 #define EBOARD_DEBUG_SPEED 9600 1506 #if PREPROCESS_DEBUG > 0x0 1507 #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED)) 1514 #ifndef EBOARD_SPI_SERVO_MAX 1515 #define EBOARD_SPI_SERVO_MAX 2 1517 #if PREPROCESS_DEBUG > 0x0 1518 #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX)) 1523 #ifndef EBOARD_USE_UTILITY 1524 #define EBOARD_USE_UTILITY 0x1 1526 #if EBOARD_USE_UTILITY > 0x0 1535 #define EBOARD_COPY_AND_PASTE 0x1 1539 #ifndef EBOARD_PWM_SPE 1540 #define EBOARD_PWM_SPE 1 1542 #if PREPROCESS_DEBUG > 0x0 1543 #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s") 1550 #define EBOARD_I2C 0x0 //disabled by default 1553 #ifndef EBOARD_BLUETOOTH 1557 #define EBOARD_BLUETOOTH 0x0 1560 #if EBOARD_BLUETOOTH > 0x0 1569 #ifndef EBOARD_CLAMP 1570 #define EBOARD_CLAMP 0x1 1572 #if EBOARD_CLAMP > 0x0 1573 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [0;1023]");
1575 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [-300;300]");
1582 #define EBOARD_NEO 0x0 1584 #if EBOARD_NEO > 0x0 1585 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support enabled");
1587 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support disabled");
1593 #ifndef EBOARD_USE_RESET 1594 #define EBOARD_USE_RESET 0x1 1597 #if EBOARD_USE_RESET > 0x0 1598 #include <avr/wdt.h> 1607 #ifndef PIN_BLUETOOTH_STATE 1608 #if defined(__AVR_ATmega2560__) 1609 #define PIN_BLUETOOTH_STATE 0x13 // 19 1611 #define PIN_BLUETOOTH_STATE 0x2 1618 #ifndef PIN_BLUETOOTH_RX 1619 #if defined(__AVR_ATmega2560__) 1620 #define PIN_BLUETOOTH_RX 0x13 // 19 1622 #define PIN_BLUETOOTH_RX 0x2 1629 #ifndef PIN_BLUETOOTH_TX 1630 #if defined(__AVR_ATmega2560__) 1631 #define PIN_BLUETOOTH_TX 0x12 // 18 1633 #define PIN_BLUETOOTH_TX 0x3 1640 #ifndef PIN_MOTOR_DIR 1641 #define PIN_MOTOR_DIR 0x4 1647 #ifndef PIN_MOTOR_SPE 1648 #define PIN_MOTOR_SPE 0x5 1654 #ifndef PIN_SHIFT_CLK 1655 #define PIN_SHIFT_CLK 0x6 1660 #ifndef PIN_SHIFT_DAT 1661 #define PIN_SHIFT_DAT 0x7 1666 #ifndef PIN_SHIFT_LAT 1667 #define PIN_SHIFT_LAT 0x8 1680 #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__) 1681 #if EBOARD_GUESSPATH > 0x0 1684 #define _SS_MAX_RX_BUFF 64 // RX buffer size 1686 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 1761 void setTX(uint8_t transmitPin);
1766 void setRX(uint8_t receivePin);
1771 static inline void tunedDelay(uint16_t delay);
1781 SoftwareSerial(uint8_t receivePin, uint8_t transmitPin,
bool inverse_logic =
false);
1803 void begin(
long speed);
1810 inline void end(
void);
1832 virtual size_t write(uint8_t byte);
1837 virtual int read(
void);
1846 virtual void flush(
void);
1873 #if EBOARD_DEBUG_MODE > 0x0 1875 #define _DEBUG_PIN1 11 1876 #define _DEBUG_PIN2 13 1878 typedef struct _DELAY_TABLE {
1880 unsigned short rx_delay_centering;
1881 unsigned short rx_delay_intrabit;
1882 unsigned short rx_delay_stopbit;
1883 unsigned short tx_delay;
1885 #if F_CPU == 16000000 1887 static const DELAY_TABLE PROGMEM table[] = {
1889 { 115200, 1, 17, 17, 12, },
1890 { 57600, 10, 37, 37, 33, },
1891 { 38400, 25, 57, 57, 54, },
1892 { 31250, 31, 70, 70, 68, },
1893 { 28800, 34, 77, 77, 74, },
1894 { 19200, 54, 117, 117, 114, },
1895 { 14400, 74, 156, 156, 153, },
1896 { 9600, 114, 236, 236, 233, },
1897 { 4800, 233, 474, 474, 471, },
1898 { 2400, 471, 950, 950, 947, },
1899 { 1200, 947, 1902, 1902, 1899, },
1900 { 600, 1902, 3804, 3804, 3800, },
1901 { 300, 3804, 7617, 7617, 7614, },
1904 const int XMIT_START_ADJUSTMENT = 5;
1906 #elif F_CPU == 8000000 1908 static const DELAY_TABLE table[] PROGMEM = {
1910 { 115200, 1, 5, 5, 3, },
1911 { 57600, 1, 15, 15, 13, },
1912 { 38400, 2, 25, 26, 23, },
1913 { 31250, 7, 32, 33, 29, },
1914 { 28800, 11, 35, 35, 32, },
1915 { 19200, 20, 55, 55, 52, },
1916 { 14400, 30, 75, 75, 72, },
1917 { 9600, 50, 114, 114, 112, },
1918 { 4800, 110, 233, 233, 230, },
1919 { 2400, 229, 472, 472, 469, },
1920 { 1200, 467, 948, 948, 945, },
1921 { 600, 948, 1895, 1895, 1890, },
1922 { 300, 1895, 3805, 3805, 3802, },
1925 const int XMIT_START_ADJUSTMENT = 4;
1927 #elif F_CPU == 20000000 1929 static const DELAY_TABLE PROGMEM table[] = {
1931 { 115200, 3, 21, 21, 18, },
1932 { 57600, 20, 43, 43, 41, },
1933 { 38400, 37, 73, 73, 70, },
1934 { 31250, 45, 89, 89, 88, },
1935 { 28800, 46, 98, 98, 95, },
1936 { 19200, 71, 148, 148, 145, },
1937 { 14400, 96, 197, 197, 194, },
1938 { 9600, 146, 297, 297, 294, },
1939 { 4800, 296, 595, 595, 592, },
1940 { 2400, 592, 1189, 1189, 1186, },
1941 { 1200, 1187, 2379, 2379, 2376, },
1942 { 600, 2379, 4759, 4759, 4755, },
1943 { 300, 4759, 9523, 9523, 9520, },
1946 const int XMIT_START_ADJUSTMENT = 6;
1949 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors 1956 #if EBOARD_DEBUG_MODE > 0x0 1957 inline void DebugPulse(uint8_t pin, uint8_t count) {
1959 volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
1961 uint8_t val = *pport;
1964 *pport = val | digitalPinToBitMask(pin);
1973 asm volatile(
"sbiw %0, 0x01 \n\t" 1975 "cpi %A0, 0xFF \n\t" 1978 :
"+r" (delay),
"+a" (tmp)
1987 uint8_t oldSREG = SREG;
2000 #if GCC_VERSION < 40302 2018 #if EBOARD_DEBUG_MODE > 0x0 2019 DebugPulse(_DEBUG_PIN2, 1);
2022 for (uint8_t i=0x1; i; i <<= 1)
2025 #if EBOARD_DEBUG_MODE > 0x0 2026 DebugPulse(_DEBUG_PIN2, 1);
2037 #if EBOARD_DEBUG_MODE > 0x0 2038 DebugPulse(_DEBUG_PIN2, 1);
2048 #if EBOARD_DEBUG_MODE > 0x0 2049 #if _DEBUG // for scope: pulse pin as overflow indictator 2050 DebugPulse(_DEBUG_PIN1, 1);
2057 #if GCC_VERSION < 40302 2072 if (pin_state == LOW)
2088 #if defined(PCINT0_vect) 2094 #if defined(PCINT1_vect) 2100 #if defined(PCINT2_vect) 2106 #if defined(PCINT3_vect) 2113 _rx_delay_centering(0),
2114 _rx_delay_intrabit(0),
2115 _rx_delay_stopbit(0),
2117 _buffer_overflow(false),
2118 _inverse_logic(inverse_logic) {
2128 pinMode(tx, OUTPUT);
2129 digitalWrite(tx, HIGH);
2131 uint8_t port = digitalPinToPort(tx);
2138 digitalWrite(rx, HIGH);
2141 uint8_t port = digitalPinToPort(rx);
2148 for (
unsigned i=0; i<
sizeof(table)/
sizeof(table[0]); ++i) {
2149 long baud = pgm_read_dword(&table[i].baud);
2150 if (baud == speed) {
2154 _tx_delay = pgm_read_word(&table[i].tx_delay);
2168 pinMode(_DEBUG_PIN1, OUTPUT);
2169 pinMode(_DEBUG_PIN2, OUTPUT);
2206 uint8_t oldSREG = SREG;
2213 for (byte mask = 0x01; mask; mask <<= 1) {
2225 for (byte mask = 0x01; mask; mask <<= 1) {
2246 uint8_t oldSREG = SREG;
2271 #if EBOARD_DEBUG_MODE > 0x0 2275 #define __ASSERT_USE_STDERR 2294 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp);
2296 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp){
2297 Serial.print(
"Error with: "); Serial.print(__func);
2298 Serial.print(
" in "); Serial.print(__file);
2299 Serial.print(
" >>");
2300 Serial.println(__sexp);
2301 if(strcmp(__func,
"checkIdx")==0){
2302 Serial.println(
" This happens if an out of bounds exception");
2303 Serial.println(
" has occured. Following pins shouldn't be used:");
2306 Serial.println(
" : Used for Bluetooth communication");
2307 Serial.print(
" D");Serial.print(
PIN_MOTOR_DIR);Serial.print(
"&");
2309 Serial.println(
" : Used for main motor control");
2310 #if EBOARD_USE_SPI > 0x0 2311 Serial.print(
" D10-13");
2312 Serial.println(
": Used for smart-servo-shield");
2314 }
else if (strcmp(__func,
"readPin")==0){
2315 Serial.println(
"You've tried to access an analogPin that isn't present on the board you're currently working on!");
2332 #if EBOARD_DEBUG_MODE > 0x0 2333 assert(idx>=0x0 && idx <
PIN_MAX);
2339 #if EBOARD_COPY_AND_PASTE > 0x0 2340 #if EBOARD_CHECK_PINS_PWM > 0x0 2351 for (count = 0; x; count++)
2358 #if EBOARD_CHECK_PINS > 0x0 2364 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2366 #elif defined(__AVR_ATmega2560__) 2372 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2374 #elif defined(__AVR_ATmega2560__) 2391 return (mode == OUTPUT)? ((
pin_out & (1<<idx))>0x0):((
pin_in & (1<<idx))>0x0);
2404 #if EBOARD_CHECK_PINS > 0x0 2420 #if EBOARD_BLUETOOTH > 0x0 2429 inline char readVal(
char oF =
'.');
2442 template <
typename T>
2443 inline void writeVal(
const T& val);
2459 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2465 inline char readVal(
char oF) {
2466 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2467 return ((Serial1.available())?(Serial1.read()):(oF));
2472 template<
typename T>
2473 inline void writeVal(
const T& val){
2474 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2481 #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE 2490 #if EBOARD_SHIFT_REGISTER > 0x0 2538 val = min(val,0xFF); val = max(0x0,val);
2543 extern void rept_task(
void);
2544 DEBUG_MSG(
"You defined REPT_TASK: you have to define rept_task(void)!");
2546 DEBUG_MSG(
"You did not define REPT_TASK: rept_task(void) will not have any effect");
2563 #if EBOARD_SHIFT_REGISTER > 0x0 2570 #if EBOARD_CHECK_PINS > 0x0 2574 #if EBOARD_COPY_AND_PASTE > 0x0 2577 pinMode(idx,OUTPUT);
2579 digitalWrite(idx,val);
2595 #if EBOARD_CHECK_PINS > 0x0 2597 #if defined (__AVR_ATmega2560__) 2598 else if (idx<0||idx>0xF){
2600 else if (idx<0||idx>0x7){
2602 #if EBOARD_DEBUG_MODE > 0x0 2609 #if EBOARD_COPY_AND_PASTE > 0x0 2614 return((dig)? digitalRead(idx) : analogRead(idx));
2618 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0) 2624 #if defined(__AVR_ATmega2560__) 2625 ServoCds55(
int CS=53);
2627 ServoCds55(
int CS=10);
2630 void WritePos(
int ID,
int Pos);
2631 void write(
int ID,
int Pos);
2632 inline void setVelocity(
int velocity);
2633 inline void setPoslimit(
int posLimit);
2634 void rotate(
int ID,
int velocity);
2635 void SetServoLimit(
int ID,
int upperLimit);
2636 void SetMotormode(
int ID,
int velocity);
2637 void SetID(
int ID,
int newID);
2639 byte sendWait (
const byte what);
2642 int upperLimit_temp;
2645 ServoCds55::ServoCds55 (
int CS):cs(CS) {
2646 velocity_temp = 150;
2647 upperLimit_temp = 300;
2650 void ServoCds55::begin() {
2652 digitalWrite(cs,HIGH);
2657 byte ServoCds55::sendWait (
const byte what) {
2659 delayMicroseconds (20);
2663 void ServoCds55::setVelocity(
int velocity){
2664 velocity_temp = velocity;
2667 void ServoCds55::setPoslimit(
int posLimit){
2668 upperLimit_temp = posLimit;
2671 void ServoCds55::write(
int ID,
int Pos){
2672 SetServoLimit(ID,upperLimit_temp);
2676 void ServoCds55::rotate(
int ID,
int velocity){
2677 SetServoLimit(ID,0);
2679 SetMotormode(ID,velocity);
2682 void ServoCds55::WritePos(
int ID,
int Pos){
2683 int PosB = (Pos>>8 & 0xff);
2684 int PosS = (Pos & 0xff);
2685 int velocityB = (velocity_temp>>8 & 0xff);
2686 int velocityS = (velocity_temp & 0xff);
2687 digitalWrite(cs, LOW);
2688 sendWait (
'p'); sendWait (ID);
2689 sendWait (PosB); sendWait (PosS);
2690 sendWait (velocityB); sendWait (velocityS);
2691 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2692 digitalWrite(cs, HIGH);
2696 void ServoCds55::SetServoLimit(
int ID,
int upperLimit_temp){
2697 int upperLimitB = (upperLimit_temp>>8 & 0xff);
2698 int upperLimitS = (upperLimit_temp & 0xff);
2699 digitalWrite(cs, LOW);
2700 sendWait (
's'); sendWait (ID);
2701 sendWait (upperLimitB); sendWait (upperLimitS);
2702 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2703 digitalWrite(cs, HIGH);
2707 void ServoCds55::SetMotormode(
int ID,
int velocity){
2708 int velocityB = (velocity>>8 & 0xff);
2709 int velocityS = (velocity & 0xff);
2710 digitalWrite(cs, LOW);
2711 sendWait (
'm'); sendWait (ID);
2712 sendWait (velocityB); sendWait (velocityS);
2713 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2714 digitalWrite(cs, HIGH);
2718 void ServoCds55::SetID(
int ID,
int newID){
2719 digitalWrite(cs, LOW);
2720 sendWait (
'i'); sendWait (ID);
2722 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2723 digitalWrite(cs, HIGH);
2727 void ServoCds55::Reset(
int ID){
2728 digitalWrite(cs, LOW);
2729 sendWait (
'r'); sendWait (ID);
2730 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2731 digitalWrite(cs, HIGH);
2740 #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0 2773 #if EBOARD_USE_UTILITY > 0x0 or defined(__AVR_ATmega2560__) //won't shrink space... just speed things up 2782 inline void led(
int idx,
bool state);
2790 inline void ledOn(
int idx);
2798 inline void ledOff(
int idx);
2813 #if EBOARD_USE_UTILITY > 0x0 2829 inline void motor(uint8_t
id,int16_t val);
2872 inline void sleep(uint16_t t);
2878 inline void msleep(uint16_t t);
2896 inline void reset(
void);
2901 #if defined(__AVR_ATmega2560__) 2907 #elif EBOARD_USE_UTILITY > 0x0 2915 #if EBOARD_USE_UTILITY > 0x0 2922 else if(
id>0&&
id<3&&(val>-0 && val < 1024)) {
_servoHandler.write((
id-1),(val *600/1023 - 300));}
2927 #if EBOARD_USE_RESET > 0x0 2928 wdt_enable(WDTO_15MS);
2944 #define DIGITAL_IN 0x0 2945 #define DIGITAL_IN_INV 0x1 2947 #define DIGITAL_IN_PULLUP 0x2 2949 #define DIGITAL_IN_PULLUP_INV 0x3 2951 #define DIGITAL_OUT 0x4 2953 #define DIGITAL_OUT_INV 0x5 2955 #define DIGITAL_OUT_LOW 0x6 2957 #define DIGITAL_OUT_HIGH 0x7 2959 #define ANALOG_IN_8_BIT 0x8 2961 #define ANALOG_IN_10_BIT 0x9 2963 #define ANALOG_IN_MEAN_8_BIT 0xA 2965 #define ANALOG_IN_MEAN_10_BIT 0xB 2967 #define COUNTER_8_BIT 0xC 2969 #define COUNTER_16_BIT 0xD 2971 #define COUNTER_RISE_8_BIT 0xE 2973 #define COUNTER_RISE_16_BIT 0xF 2975 #define PWM_SLOW 0x8 2977 #define PWM_FAST 0x9 2979 #define FREQ_LOW 0xA 2981 #define FREQ_HIGH 0xB 2983 #define COUNTER_B_DIR 0xC 2985 #define COUNTER_B_DIR_PULLUP 0xD 2987 #define COUNTER_MEAN_8_BIT 0xE 2989 #define COUNTER_MEAN_16_BIT 0xF 3022 #if EBOARD_USE_UTILITY > 0x0 3023 inline void read(
void);
3034 inline void write(
void);
3046 this->
A=0x0;this->
B=0x0;this->
C=0x0;
3048 #if EBOARD_USE_UTILITY > 0x0 3102 #if EBOARD_USE_UTILITY > 0x0 3139 inline void ledOff(
void);
3141 inline void ledOn(
void);
3203 #if EBOARD_USE_UTILITY > 0x0 3216 #if EBOARD_CLAMP > 0x0 3217 if(pos>1023 || speed > 1023)
return;
3219 speed = speed*600/1023 - 300;
3220 pos = pos *600/1023 - 300;
3223 if(pos>300 || speed > 300)
return;
3264 #if EBOARD_USE_UTILITY > 0x0 3274 inline void action(
void);
3292 #if EBOARD_USE_UTILITY > 0x0 3317 #if EBOARD_BLUETOOTH > 0x0 3363 inline void write(
const char*
const val);
3381 #if EBOARD_I2C > 0x0 3427 for (byte i = 1; (i < 255 && !
STOP); i++) {
3431 if(count < ret_len) ret[count] = i;
3469 #if EBOARD_LCD > 0x0 3472 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
3473 {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
3474 {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
3475 {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
3476 {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
3477 {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
3478 {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
3479 {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
3480 {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
3481 {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
3482 {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
3483 {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
3484 {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
3485 {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
3486 {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
3487 {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
3488 {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
3489 {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
3490 {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
3491 {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
3492 {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
3493 {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
3494 {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
3495 {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
3496 {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
3497 {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
3498 {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
3499 {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
3500 {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
3501 {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
3502 {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
3503 {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
3504 {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
3505 {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
3506 {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
3507 {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
3508 {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
3509 {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
3510 {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
3511 {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
3512 {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
3513 {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
3514 {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
3515 {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
3516 {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
3517 {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
3518 {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
3519 {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
3520 {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
3521 {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
3522 {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
3523 {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
3524 {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
3525 {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
3526 {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
3527 {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
3528 {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
3529 {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
3530 {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
3531 {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
3532 {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
3533 {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
3534 {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
3535 {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
3536 {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
3537 {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
3538 {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
3539 {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
3540 {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
3541 {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
3542 {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
3543 {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
3544 {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
3545 {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
3546 {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
3547 {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
3548 {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
3549 {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
3550 {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
3551 {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
3552 {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
3553 {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
3554 {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
3555 {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
3556 {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
3557 {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
3558 {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
3559 {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
3560 {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
3561 {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
3562 {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
3563 {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
3564 {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
3565 {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
3566 {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
3567 {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
3832 #define LCD_COMMAND_MODE 0x80 3833 #define LCD_DATA_MODE 0x40 3835 #define LCD_COMMAND_DISPLAY_OFF 0xAE 3837 #define LCD_COMMAND_DISPLAY_ON 0xAF 3839 #define LCD_COMMAND_BLACK_BACKGROUND 0xA6 3841 #define LCD_COMMAND_WHITE_BACKGROUND 0xA7 3843 #define LCD_COMMAND_SET_BRIGHTNESS 0x81 3845 #define LCD_PAGE_ADDRESSING 0x02 3847 #define LCD_HORIZONTAL_ADDRESSING 0x00 3851 #define LCD_COMMAND_CHARGE_PUMP_SETTING 0x8d 3852 #define LCD_COMMAND_CHARGE_PUMP_ENABLE 0x14 3856 #define LCD_WIDTH 128 3860 #define LCD_HEIGHT 64 3905 #if EBOARD_NANO == 0 3943 inline bool clear(
void);
3949 inline void print(
const char* data);
3955 inline void print(
int data);
4000 inline bool reset(
void);
4015 inline bool init(
void);
4025 inline void drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY);
4047 inline bool setCursor(byte posX = 0x0, byte posY = 0x0);
4115 #if EBOARD_NANO == 0x0 4130 return this->
init();
4134 for(byte i = 0; i < 8; i++){
4138 for (byte j = 0; j < 128; j++)
4158 if(data[i] < 32 || data[i] > 127){ i++;
continue;}
4159 for (byte j = 0; j < 8; j++){
4166 char buffer[11] =
"";
4167 itoa(data,buffer,10);
4168 this->
print(line,col,buffer);
4177 return this->
clear();
4194 return this->
clear();
4197 inline void LCD::drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY){
4201 for(
int i = 0x0; i < (hiX * 8 * hiY); i++){
4202 this->
s1Dat(pgm_read_byte(&bitmap[i]));
4203 if(++col == (hiX * 8)) {
4216 this->
s2Cmd((0x00 + (8 *posX & 0x0F)),(0x10 + ((8 * posX >> 4) & 0x0F)));
4217 this->
pX = posX; this->
pY = posY;
4218 return this->
s1Cmd(0xB0 + posY);
4223 this->
s2Cmd(0x81,val);
4254 #if EBOARD_NEO > 0x0 4259 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 4260 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 4262 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 4264 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 4266 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 4268 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 4274 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 4275 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 4277 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 4279 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 4281 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 4283 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 4285 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 4287 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 4289 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 4291 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 4293 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 4295 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 4297 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 4299 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 4301 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 4303 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 4305 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 4307 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 4309 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 4311 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 4313 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 4315 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 4317 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 4319 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 4324 #define EBOARD_NEO_800KHZ 0x0000 4325 #define EBOARD_NEO_400KHZ 0x0100 4406 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
4415 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4459 uint8_t
sine8(uint8_t x)
const;
4465 uint8_t
gamma8(uint8_t x)
const;
4470 inline int8_t
getPin(
void);
4482 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
4490 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4523 #ifdef __AVR__ //not needed (rem?) 4524 volatile uint8_t *
port;
4536 begun(false), brightness(0),
pixels(NULL), endTime(0) {
4546 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
4552 if(
pin >= 0) pinMode(
pin, INPUT);
4557 pinMode(
pin, OUTPUT);
4558 digitalWrite(
pin, LOW);
4590 #if defined(ESP8266) 4592 extern "C" void ICACHE_RAM_ATTR espShow(
4593 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4594 #elif defined(ESP32) 4595 extern "C" void espShow(
4596 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4613 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 4616 volatile uint8_t n1, n2 = 0;
4619 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4620 if(
port == &PORTD) {
4626 if(b & 0x80) n1 = hi;
4631 "out %[port] , %[hi]" "\n\t" 4632 "mov %[n2] , %[lo]" "\n\t" 4633 "out %[port] , %[n1]" "\n\t" 4635 "sbrc %[byte] , 6" "\n\t" 4636 "mov %[n2] , %[hi]" "\n\t" 4637 "out %[port] , %[lo]" "\n\t" 4640 "out %[port] , %[hi]" "\n\t" 4641 "mov %[n1] , %[lo]" "\n\t" 4642 "out %[port] , %[n2]" "\n\t" 4644 "sbrc %[byte] , 5" "\n\t" 4645 "mov %[n1] , %[hi]" "\n\t" 4646 "out %[port] , %[lo]" "\n\t" 4649 "out %[port] , %[hi]" "\n\t" 4650 "mov %[n2] , %[lo]" "\n\t" 4651 "out %[port] , %[n1]" "\n\t" 4653 "sbrc %[byte] , 4" "\n\t" 4654 "mov %[n2] , %[hi]" "\n\t" 4655 "out %[port] , %[lo]" "\n\t" 4658 "out %[port] , %[hi]" "\n\t" 4659 "mov %[n1] , %[lo]" "\n\t" 4660 "out %[port] , %[n2]" "\n\t" 4662 "sbrc %[byte] , 3" "\n\t" 4663 "mov %[n1] , %[hi]" "\n\t" 4664 "out %[port] , %[lo]" "\n\t" 4667 "out %[port] , %[hi]" "\n\t" 4668 "mov %[n2] , %[lo]" "\n\t" 4669 "out %[port] , %[n1]" "\n\t" 4671 "sbrc %[byte] , 2" "\n\t" 4672 "mov %[n2] , %[hi]" "\n\t" 4673 "out %[port] , %[lo]" "\n\t" 4676 "out %[port] , %[hi]" "\n\t" 4677 "mov %[n1] , %[lo]" "\n\t" 4678 "out %[port] , %[n2]" "\n\t" 4680 "sbrc %[byte] , 1" "\n\t" 4681 "mov %[n1] , %[hi]" "\n\t" 4682 "out %[port] , %[lo]" "\n\t" 4685 "out %[port] , %[hi]" "\n\t" 4686 "mov %[n2] , %[lo]" "\n\t" 4687 "out %[port] , %[n1]" "\n\t" 4689 "sbrc %[byte] , 0" "\n\t" 4690 "mov %[n2] , %[hi]" "\n\t" 4691 "out %[port] , %[lo]" "\n\t" 4692 "sbiw %[count], 1" "\n\t" 4694 "out %[port] , %[hi]" "\n\t" 4695 "mov %[n1] , %[lo]" "\n\t" 4696 "out %[port] , %[n2]" "\n\t" 4697 "ld %[byte] , %a[ptr]+" "\n\t" 4698 "sbrc %[byte] , 7" "\n\t" 4699 "mov %[n1] , %[hi]" "\n\t" 4700 "out %[port] , %[lo]" "\n\t" 4706 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
4711 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4716 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4717 if(
port == &PORTB) {
4718 #endif // defined(PORTD/C/F) 4722 if(b & 0x80) n1 = hi;
4726 "out %[port] , %[hi]" "\n\t" 4727 "mov %[n2] , %[lo]" "\n\t" 4728 "out %[port] , %[n1]" "\n\t" 4730 "sbrc %[byte] , 6" "\n\t" 4731 "mov %[n2] , %[hi]" "\n\t" 4732 "out %[port] , %[lo]" "\n\t" 4734 "out %[port] , %[hi]" "\n\t" 4735 "mov %[n1] , %[lo]" "\n\t" 4736 "out %[port] , %[n2]" "\n\t" 4738 "sbrc %[byte] , 5" "\n\t" 4739 "mov %[n1] , %[hi]" "\n\t" 4740 "out %[port] , %[lo]" "\n\t" 4742 "out %[port] , %[hi]" "\n\t" 4743 "mov %[n2] , %[lo]" "\n\t" 4744 "out %[port] , %[n1]" "\n\t" 4746 "sbrc %[byte] , 4" "\n\t" 4747 "mov %[n2] , %[hi]" "\n\t" 4748 "out %[port] , %[lo]" "\n\t" 4750 "out %[port] , %[hi]" "\n\t" 4751 "mov %[n1] , %[lo]" "\n\t" 4752 "out %[port] , %[n2]" "\n\t" 4754 "sbrc %[byte] , 3" "\n\t" 4755 "mov %[n1] , %[hi]" "\n\t" 4756 "out %[port] , %[lo]" "\n\t" 4758 "out %[port] , %[hi]" "\n\t" 4759 "mov %[n2] , %[lo]" "\n\t" 4760 "out %[port] , %[n1]" "\n\t" 4762 "sbrc %[byte] , 2" "\n\t" 4763 "mov %[n2] , %[hi]" "\n\t" 4764 "out %[port] , %[lo]" "\n\t" 4766 "out %[port] , %[hi]" "\n\t" 4767 "mov %[n1] , %[lo]" "\n\t" 4768 "out %[port] , %[n2]" "\n\t" 4770 "sbrc %[byte] , 1" "\n\t" 4771 "mov %[n1] , %[hi]" "\n\t" 4772 "out %[port] , %[lo]" "\n\t" 4774 "out %[port] , %[hi]" "\n\t" 4775 "mov %[n2] , %[lo]" "\n\t" 4776 "out %[port] , %[n1]" "\n\t" 4778 "sbrc %[byte] , 0" "\n\t" 4779 "mov %[n2] , %[hi]" "\n\t" 4780 "out %[port] , %[lo]" "\n\t" 4781 "sbiw %[count], 1" "\n\t" 4782 "out %[port] , %[hi]" "\n\t" 4783 "mov %[n1] , %[lo]" "\n\t" 4784 "out %[port] , %[n2]" "\n\t" 4785 "ld %[byte] , %a[ptr]+" "\n\t" 4786 "sbrc %[byte] , 7" "\n\t" 4787 "mov %[n1] , %[hi]" "\n\t" 4788 "out %[port] , %[lo]" "\n\t" 4790 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4791 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4794 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4797 #if defined(PORTC) || defined(PORTF) 4803 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4804 if(
port == &PORTC) {
4810 if(b & 0x80) n1 = hi;
4814 "out %[port] , %[hi]" "\n\t" 4815 "mov %[n2] , %[lo]" "\n\t" 4816 "out %[port] , %[n1]" "\n\t" 4818 "sbrc %[byte] , 6" "\n\t" 4819 "mov %[n2] , %[hi]" "\n\t" 4820 "out %[port] , %[lo]" "\n\t" 4822 "out %[port] , %[hi]" "\n\t" 4823 "mov %[n1] , %[lo]" "\n\t" 4824 "out %[port] , %[n2]" "\n\t" 4826 "sbrc %[byte] , 5" "\n\t" 4827 "mov %[n1] , %[hi]" "\n\t" 4828 "out %[port] , %[lo]" "\n\t" 4830 "out %[port] , %[hi]" "\n\t" 4831 "mov %[n2] , %[lo]" "\n\t" 4832 "out %[port] , %[n1]" "\n\t" 4834 "sbrc %[byte] , 4" "\n\t" 4835 "mov %[n2] , %[hi]" "\n\t" 4836 "out %[port] , %[lo]" "\n\t" 4838 "out %[port] , %[hi]" "\n\t" 4839 "mov %[n1] , %[lo]" "\n\t" 4840 "out %[port] , %[n2]" "\n\t" 4842 "sbrc %[byte] , 3" "\n\t" 4843 "mov %[n1] , %[hi]" "\n\t" 4844 "out %[port] , %[lo]" "\n\t" 4846 "out %[port] , %[hi]" "\n\t" 4847 "mov %[n2] , %[lo]" "\n\t" 4848 "out %[port] , %[n1]" "\n\t" 4850 "sbrc %[byte] , 2" "\n\t" 4851 "mov %[n2] , %[hi]" "\n\t" 4852 "out %[port] , %[lo]" "\n\t" 4854 "out %[port] , %[hi]" "\n\t" 4855 "mov %[n1] , %[lo]" "\n\t" 4856 "out %[port] , %[n2]" "\n\t" 4858 "sbrc %[byte] , 1" "\n\t" 4859 "mov %[n1] , %[hi]" "\n\t" 4860 "out %[port] , %[lo]" "\n\t" 4862 "out %[port] , %[hi]" "\n\t" 4863 "mov %[n2] , %[lo]" "\n\t" 4864 "out %[port] , %[n1]" "\n\t" 4866 "sbrc %[byte] , 0" "\n\t" 4867 "mov %[n2] , %[hi]" "\n\t" 4868 "out %[port] , %[lo]" "\n\t" 4869 "sbiw %[count], 1" "\n\t" 4870 "out %[port] , %[hi]" "\n\t" 4871 "mov %[n1] , %[lo]" "\n\t" 4872 "out %[port] , %[n2]" "\n\t" 4873 "ld %[byte] , %a[ptr]+" "\n\t" 4874 "sbrc %[byte] , 7" "\n\t" 4875 "mov %[n1] , %[hi]" "\n\t" 4876 "out %[port] , %[lo]" "\n\t" 4878 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4879 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4882 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4891 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 4892 if(
port == &PORTF) {
4893 #endif // defined(PORTD/B/C) 4898 if(b & 0x80) n1 = hi;
4902 "out %[port] , %[hi]" "\n\t" 4903 "mov %[n2] , %[lo]" "\n\t" 4904 "out %[port] , %[n1]" "\n\t" 4906 "sbrc %[byte] , 6" "\n\t" 4907 "mov %[n2] , %[hi]" "\n\t" 4908 "out %[port] , %[lo]" "\n\t" 4910 "out %[port] , %[hi]" "\n\t" 4911 "mov %[n1] , %[lo]" "\n\t" 4912 "out %[port] , %[n2]" "\n\t" 4914 "sbrc %[byte] , 5" "\n\t" 4915 "mov %[n1] , %[hi]" "\n\t" 4916 "out %[port] , %[lo]" "\n\t" 4918 "out %[port] , %[hi]" "\n\t" 4919 "mov %[n2] , %[lo]" "\n\t" 4920 "out %[port] , %[n1]" "\n\t" 4922 "sbrc %[byte] , 4" "\n\t" 4923 "mov %[n2] , %[hi]" "\n\t" 4924 "out %[port] , %[lo]" "\n\t" 4926 "out %[port] , %[hi]" "\n\t" 4927 "mov %[n1] , %[lo]" "\n\t" 4928 "out %[port] , %[n2]" "\n\t" 4930 "sbrc %[byte] , 3" "\n\t" 4931 "mov %[n1] , %[hi]" "\n\t" 4932 "out %[port] , %[lo]" "\n\t" 4934 "out %[port] , %[hi]" "\n\t" 4935 "mov %[n2] , %[lo]" "\n\t" 4936 "out %[port] , %[n1]" "\n\t" 4938 "sbrc %[byte] , 2" "\n\t" 4939 "mov %[n2] , %[hi]" "\n\t" 4940 "out %[port] , %[lo]" "\n\t" 4942 "out %[port] , %[hi]" "\n\t" 4943 "mov %[n1] , %[lo]" "\n\t" 4944 "out %[port] , %[n2]" "\n\t" 4946 "sbrc %[byte] , 1" "\n\t" 4947 "mov %[n1] , %[hi]" "\n\t" 4948 "out %[port] , %[lo]" "\n\t" 4950 "out %[port] , %[hi]" "\n\t" 4951 "mov %[n2] , %[lo]" "\n\t" 4952 "out %[port] , %[n1]" "\n\t" 4954 "sbrc %[byte] , 0" "\n\t" 4955 "mov %[n2] , %[hi]" "\n\t" 4956 "out %[port] , %[lo]" "\n\t" 4957 "sbiw %[count], 1" "\n\t" 4958 "out %[port] , %[hi]" "\n\t" 4959 "mov %[n1] , %[lo]" "\n\t" 4960 "out %[port] , %[n2]" "\n\t" 4961 "ld %[byte] , %a[ptr]+" "\n\t" 4962 "sbrc %[byte] , 7" "\n\t" 4963 "mov %[n1] , %[hi]" "\n\t" 4964 "out %[port] , %[lo]" "\n\t" 4966 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4967 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4970 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 4972 #endif // defined(PORTD/B/C) 4973 #endif // defined(PORTF) 4976 volatile uint8_t next, bit;
4985 "st %a[port], %[hi]" "\n\t" 4986 "sbrc %[byte] , 7" "\n\t" 4987 "mov %[next], %[hi]" "\n\t" 4988 "st %a[port], %[next]" "\n\t" 4989 "mov %[next] , %[lo]" "\n\t" 4991 "breq nextbyte20" "\n\t" 4992 "rol %[byte]" "\n\t" 4993 "st %a[port], %[lo]" "\n\t" 4997 "rjmp head20" "\n\t" 4998 "nextbyte20:" "\n\t" 4999 "st %a[port], %[lo]" "\n\t" 5001 "ldi %[bit] , 8" "\n\t" 5002 "ld %[byte] , %a[ptr]+" "\n\t" 5003 "sbiw %[count], 1" "\n\t" 5014 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 5016 volatile uint8_t next;
5021 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5022 if(
port == &PORTD) {
5028 if(b & 0x80) next = hi;
5031 "out %[port], %[hi]" "\n\t" 5032 "rcall bitTimeD" "\n\t" 5033 "out %[port], %[hi]" "\n\t" 5034 "rcall bitTimeD" "\n\t" 5035 "out %[port], %[hi]" "\n\t" 5036 "rcall bitTimeD" "\n\t" 5037 "out %[port], %[hi]" "\n\t" 5038 "rcall bitTimeD" "\n\t" 5039 "out %[port], %[hi]" "\n\t" 5040 "rcall bitTimeD" "\n\t" 5041 "out %[port], %[hi]" "\n\t" 5042 "rcall bitTimeD" "\n\t" 5043 "out %[port], %[hi]" "\n\t" 5044 "rcall bitTimeD" "\n\t" 5046 "out %[port] , %[hi]" "\n\t" 5048 "ld %[byte] , %a[ptr]+" "\n\t" 5049 "out %[port] , %[next]" "\n\t" 5050 "mov %[next] , %[lo]" "\n\t" 5051 "sbrc %[byte] , 7" "\n\t" 5052 "mov %[next] , %[hi]" "\n\t" 5054 "out %[port] , %[lo]" "\n\t" 5055 "sbiw %[count], 1" "\n\t" 5059 "out %[port], %[next]" "\n\t" 5060 "mov %[next], %[lo]" "\n\t" 5061 "rol %[byte]" "\n\t" 5062 "sbrc %[byte], 7" "\n\t" 5063 "mov %[next], %[hi]" "\n\t" 5065 "out %[port], %[lo]" "\n\t" 5071 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
5076 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5082 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5083 if(
port == &PORTB) {
5089 if(b & 0x80) next = hi;
5093 "out %[port], %[hi]" "\n\t" 5094 "rcall bitTimeB" "\n\t" 5095 "out %[port], %[hi]" "\n\t" 5096 "rcall bitTimeB" "\n\t" 5097 "out %[port], %[hi]" "\n\t" 5098 "rcall bitTimeB" "\n\t" 5099 "out %[port], %[hi]" "\n\t" 5100 "rcall bitTimeB" "\n\t" 5101 "out %[port], %[hi]" "\n\t" 5102 "rcall bitTimeB" "\n\t" 5103 "out %[port], %[hi]" "\n\t" 5104 "rcall bitTimeB" "\n\t" 5105 "out %[port], %[hi]" "\n\t" 5106 "rcall bitTimeB" "\n\t" 5107 "out %[port] , %[hi]" "\n\t" 5109 "ld %[byte] , %a[ptr]+" "\n\t" 5110 "out %[port] , %[next]" "\n\t" 5111 "mov %[next] , %[lo]" "\n\t" 5112 "sbrc %[byte] , 7" "\n\t" 5113 "mov %[next] , %[hi]" "\n\t" 5115 "out %[port] , %[lo]" "\n\t" 5116 "sbiw %[count], 1" "\n\t" 5120 "out %[port], %[next]" "\n\t" 5121 "mov %[next], %[lo]" "\n\t" 5122 "rol %[byte]" "\n\t" 5123 "sbrc %[byte], 7" "\n\t" 5124 "mov %[next], %[hi]" "\n\t" 5126 "out %[port], %[lo]" "\n\t" 5129 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5130 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5133 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5136 #if defined(PORTC) || defined(PORTF) 5142 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5143 if(
port == &PORTC) {
5149 if(b & 0x80) next = hi;
5153 "out %[port], %[hi]" "\n\t" 5154 "rcall bitTimeC" "\n\t" 5155 "out %[port], %[hi]" "\n\t" 5156 "rcall bitTimeC" "\n\t" 5157 "out %[port], %[hi]" "\n\t" 5158 "rcall bitTimeC" "\n\t" 5159 "out %[port], %[hi]" "\n\t" 5160 "rcall bitTimeC" "\n\t" 5161 "out %[port], %[hi]" "\n\t" 5162 "rcall bitTimeC" "\n\t" 5163 "out %[port], %[hi]" "\n\t" 5164 "rcall bitTimeC" "\n\t" 5165 "out %[port], %[hi]" "\n\t" 5166 "rcall bitTimeC" "\n\t" 5167 "out %[port] , %[hi]" "\n\t" 5169 "ld %[byte] , %a[ptr]+" "\n\t" 5170 "out %[port] , %[next]" "\n\t" 5171 "mov %[next] , %[lo]" "\n\t" 5172 "sbrc %[byte] , 7" "\n\t" 5173 "mov %[next] , %[hi]" "\n\t" 5175 "out %[port] , %[lo]" "\n\t" 5176 "sbiw %[count], 1" "\n\t" 5180 "out %[port], %[next]" "\n\t" 5181 "mov %[next], %[lo]" "\n\t" 5182 "rol %[byte]" "\n\t" 5183 "sbrc %[byte], 7" "\n\t" 5184 "mov %[next], %[hi]" "\n\t" 5186 "out %[port], %[lo]" "\n\t" 5189 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5190 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5193 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5202 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5203 if(
port == &PORTF) {
5209 if(b & 0x80) next = hi;
5213 "out %[port], %[hi]" "\n\t" 5214 "rcall bitTimeC" "\n\t" 5215 "out %[port], %[hi]" "\n\t" 5216 "rcall bitTimeC" "\n\t" 5217 "out %[port], %[hi]" "\n\t" 5218 "rcall bitTimeC" "\n\t" 5219 "out %[port], %[hi]" "\n\t" 5220 "rcall bitTimeC" "\n\t" 5221 "out %[port], %[hi]" "\n\t" 5222 "rcall bitTimeC" "\n\t" 5223 "out %[port], %[hi]" "\n\t" 5224 "rcall bitTimeC" "\n\t" 5225 "out %[port], %[hi]" "\n\t" 5226 "rcall bitTimeC" "\n\t" 5227 "out %[port] , %[hi]" "\n\t" 5229 "ld %[byte] , %a[ptr]+" "\n\t" 5230 "out %[port] , %[next]" "\n\t" 5231 "mov %[next] , %[lo]" "\n\t" 5232 "sbrc %[byte] , 7" "\n\t" 5233 "mov %[next] , %[hi]" "\n\t" 5235 "out %[port] , %[lo]" "\n\t" 5236 "sbiw %[count], 1" "\n\t" 5240 "out %[port], %[next]" "\n\t" 5241 "mov %[next], %[lo]" "\n\t" 5242 "rol %[byte]" "\n\t" 5243 "sbrc %[byte], 7" "\n\t" 5244 "mov %[next], %[hi]" "\n\t" 5246 "out %[port], %[lo]" "\n\t" 5249 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5250 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5253 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5258 volatile uint8_t next, bit;
5267 "st %a[port], %[hi]" "\n\t" 5268 "sbrc %[byte] , 7" "\n\t" 5269 "mov %[next], %[hi]" "\n\t" 5271 "st %a[port], %[next]" "\n\t" 5276 "st %a[port], %[lo]" "\n\t" 5279 "breq nextbyte30" "\n\t" 5280 "rol %[byte]" "\n\t" 5284 "rjmp head30" "\n\t" 5285 "nextbyte30:" "\n\t" 5287 "ldi %[bit] , 8" "\n\t" 5288 "ld %[byte] , %a[ptr]+" "\n\t" 5289 "sbiw %[count], 1" "\n\t" 5300 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 5302 volatile uint8_t next, bit;
5311 "st %a[port], %[hi]" "\n\t" 5312 "sbrc %[byte], 7" "\n\t" 5313 "mov %[next], %[hi]" "\n\t" 5315 "st %a[port], %[next]" "\n\t" 5316 "mov %[next] , %[lo]" "\n\t" 5317 "breq nextbyte20" "\n\t" 5318 "rol %[byte]" "\n\t" 5321 "st %a[port], %[lo]" "\n\t" 5324 "rjmp head20" "\n\t" 5325 "nextbyte20:" "\n\t" 5326 "ldi %[bit] , 8" "\n\t" 5327 "ld %[byte] , %a[ptr]+" "\n\t" 5328 "st %a[port], %[lo]" "\n\t" 5330 "sbiw %[count], 1" "\n\t" 5342 volatile uint8_t next, bit;
5351 "st %a[port], %[hi]" "\n\t" 5352 "sbrc %[byte] , 7" "\n\t" 5353 "mov %[next] , %[hi]" "\n\t" 5356 "st %a[port], %[next]" "\n\t" 5362 "st %a[port], %[lo]" "\n\t" 5364 "mov %[next] , %[lo]" "\n\t" 5366 "breq nextbyte40" "\n\t" 5367 "rol %[byte]" "\n\t" 5374 "rjmp head40" "\n\t" 5375 "nextbyte40:" "\n\t" 5376 "ldi %[bit] , 8" "\n\t" 5377 "ld %[byte] , %a[ptr]+" "\n\t" 5379 "st %a[port], %[lo]" "\n\t" 5381 "sbiw %[count], 1" "\n\t" 5393 #error "CPU SPEED NOT SUPPORTED" 5395 #elif defined(__arm__) 5398 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 5399 #define CYCLES_800_T0H (F_CPU / 4000000) 5400 #define CYCLES_800_T1H (F_CPU / 1250000) 5401 #define CYCLES_800 (F_CPU / 800000) 5402 #define CYCLES_400_T0H (F_CPU / 2000000) 5403 #define CYCLES_400_T1H (F_CPU / 833333) 5404 #define CYCLES_400 (F_CPU / 400000) 5408 volatile uint8_t *
set = portSetRegister(
pin),
5409 *clr = portClearRegister(
pin);
5412 ARM_DEMCR |= ARM_DEMCR_TRCENA;
5413 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
5416 cyc = ARM_DWT_CYCCNT + CYCLES_800;
5419 for(mask = 0x80; mask; mask >>= 1) {
5420 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5421 cyc = ARM_DWT_CYCCNT;
5424 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
5426 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
5431 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5433 cyc = ARM_DWT_CYCCNT + CYCLES_400;
5436 for(mask = 0x80; mask; mask >>= 1) {
5437 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5438 cyc = ARM_DWT_CYCCNT;
5441 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
5443 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
5448 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5451 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 5453 #elif defined(ESP8266) || defined(ESP32) 5457 #elif defined(__ARDUINO_ARC__) 5461 #define NOPx7 { __builtin_arc_nop(); \ 5462 __builtin_arc_nop(); __builtin_arc_nop(); \ 5463 __builtin_arc_nop(); __builtin_arc_nop(); \ 5464 __builtin_arc_nop(); __builtin_arc_nop(); } 5466 PinDescription *pindesc = &g_APinDescription[
pin];
5468 register uint8_t *p =
pixels;
5469 register uint32_t currByte = (uint32_t) (*p);
5470 register uint32_t currBit = 0x80 & currByte;
5471 register uint32_t bitCounter = 0;
5472 register uint32_t first = 1;
5474 if (pindesc->ulGPIOType == SS_GPIO) {
5475 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
5476 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
5477 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5478 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5488 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
5495 __builtin_arc_nop();
5498 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
5502 if(bitCounter >= 8) {
5504 currByte = (uint32_t) (*++p);
5507 currBit = 0x80 & currByte;
5510 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
5511 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
5512 uint32_t reg_val = MMIO_REG_VAL(reg);
5513 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5514 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5522 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
5526 __builtin_arc_nop();
5532 MMIO_REG_VAL(reg) = reg_bit_low;
5536 if(bitCounter >= 8) {
5538 currByte = (uint32_t) (*++p);
5541 currBit = 0x80 & currByte;
5547 #error Architecture not supported 5560 digitalWrite(p, LOW);
5563 port = portOutputRegister(digitalPinToPort(p));
5564 pinMask = digitalPinToBitMask(p);
5569 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
5591 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5616 r = (uint8_t)(c >> 16),
5617 g = (uint8_t)(c >> 8),
5628 uint8_t w = (uint8_t)(c >> 24);
5638 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5641 uint32_t
NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5642 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5658 return ((uint32_t)p[
aOffset[0]] << 16) |
5659 ((uint32_t)p[
aOffset[1]] << 8) |
5670 return ((uint32_t)p[
aOffset[3]] << 24) |
5671 ((uint32_t)p[
aOffset[0]] << 16) |
5672 ((uint32_t)p[
aOffset[1]] << 8) |
5689 uint8_t newBrightness = b + 1;
5695 if(oldBrightness == 0) scale = 0;
5696 else if(b == 255) scale = 65535 / oldBrightness;
5697 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
5698 for(uint16_t i=0; i<
numBytes; i++) {
5700 *ptr++ = (c * scale) >> 8;
5714 static const uint8_t PROGMEM _sineTable[256] = {
5715 128,131,134,137,140,143,146,149,152,155,158,162,165,167,170,173,
5716 176,179,182,185,188,190,193,196,198,201,203,206,208,211,213,215,
5717 218,220,222,224,226,228,230,232,234,235,237,238,240,241,243,244,
5718 245,246,248,249,250,250,251,252,253,253,254,254,254,255,255,255,
5719 255,255,255,255,254,254,254,253,253,252,251,250,250,249,248,246,
5720 245,244,243,241,240,238,237,235,234,232,230,228,226,224,222,220,
5721 218,215,213,211,208,206,203,201,198,196,193,190,188,185,182,179,
5722 176,173,170,167,165,162,158,155,152,149,146,143,140,137,134,131,
5723 128,124,121,118,115,112,109,106,103,100, 97, 93, 90, 88, 85, 82,
5724 79, 76, 73, 70, 67, 65, 62, 59, 57, 54, 52, 49, 47, 44, 42, 40,
5725 37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
5726 10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0,
5727 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
5728 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
5729 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
5730 79, 82, 85, 88, 90, 93, 97,100,103,106,109,112,115,118,121,124};
5732 static const uint8_t PROGMEM _gammaTable[256] = {
5733 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5734 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
5735 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
5736 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7,
5737 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
5738 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20,
5739 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29,
5740 30, 31, 31, 32, 33, 34, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42,
5741 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
5742 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 75,
5743 76, 77, 78, 80, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96,
5744 97, 99,100,102,103,105,106,108,109,111,112,114,115,117,119,120,
5745 122,124,125,127,129,130,132,134,136,137,139,141,143,145,146,148,
5746 150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,
5747 182,184,186,188,191,193,195,197,199,202,204,206,209,211,213,215,
5748 218,220,223,225,227,230,232,235,237,240,242,245,247,250,252,255};
5751 return pgm_read_byte(&_sineTable[x]);
5755 return pgm_read_byte(&_gammaTable[x]);
6126 #if EBOARD_NANO > 0x0 || defined(DOC) 6128 #if EBOARD_GUESSPATH > 0x0 6133 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
6134 #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 6135 #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 6136 #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 6137 #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 6139 #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 6140 #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 6142 #define INVALID_SERVO 255 // flag indicating an invalid servo index 6145 uint8_t isActive :1 ;
6150 volatile unsigned int ticks;
6156 uint8_t attach(
int pin);
6157 uint8_t attach(
int pin,
int min,
int max);
6159 void write(
int value);
6160 void writeMicroseconds(
int value);
6162 int readMicroseconds();
6163 inline bool attached();
6169 #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 6170 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds 6173 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 6177 static servo_t servos[MAX_SERVOS];
6178 static volatile int8_t Channel[_Nbr_16timers ];
6180 uint8_t ServoCount = 0;
6183 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo 6184 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer 6185 #define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel 6186 #define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel 6188 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo 6189 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo 6191 static inline void handle_interrupts(timer16_Sequence_t timer,
volatile uint16_t *TCNTn,
volatile uint16_t* OCRnA)
6193 if( Channel[timer] < 0 )
6196 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive ==
true )
6197 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW);
6201 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
6202 *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
6203 if(SERVO(timer,Channel[timer]).Pin.isActive ==
true)
6204 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH);
6208 if( ((
unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )
6209 *OCRnA = (
unsigned int)usToTicks(REFRESH_INTERVAL);
6211 *OCRnA = *TCNTn + 4;
6212 Channel[timer] = -1;
6216 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform 6218 #if defined(_useTimer1) 6219 SIGNAL (TIMER1_COMPA_vect)
6221 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6224 #elif defined WIRING 6226 #if defined(_useTimer1) 6227 void Timer1Service()
6229 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6234 static void initISR(timer16_Sequence_t timer) {
6235 if(timer == _timer1) {
6239 TIFR1 |= _BV(OCF1A);
6240 TIMSK1 |= _BV(OCIE1A) ;
6242 timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
6247 static void finISR(timer16_Sequence_t timer) {
6248 #if defined WIRING // Wiring 6249 if(timer == _timer1) {
6250 TIMSK &= ~_BV(OCIE1A) ;
6251 timerDetach(TIMER1OUTCOMPAREA_INT);
6253 else if(timer == _timer3) {
6254 ETIMSK &= ~_BV(OCIE3A);
6255 timerDetach(TIMER3OUTCOMPAREA_INT);
6263 static boolean isTimerActive(timer16_Sequence_t timer) {
6265 for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
6266 if(SERVO(timer,channel).Pin.isActive ==
true)
6273 if( ServoCount < MAX_SERVOS) {
6274 this->servoIndex = ServoCount++;
6275 servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);
6278 this->servoIndex = INVALID_SERVO ;
6281 uint8_t Servo::attach(
int pin) {
6282 return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
6285 uint8_t Servo::attach(
int pin,
int min,
int max) {
6286 if(this->servoIndex < MAX_SERVOS ) {
6287 pinMode( pin, OUTPUT) ;
6288 servos[this->servoIndex].Pin.nbr = pin;
6290 this->min = (MIN_PULSE_WIDTH - min)/4;
6291 this->max = (MAX_PULSE_WIDTH - max)/4;
6293 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6294 if(isTimerActive(timer) ==
false)
6296 servos[this->servoIndex].Pin.isActive =
true;
6298 return this->servoIndex ;
6301 void Servo::detach() {
6302 servos[this->servoIndex].Pin.isActive =
false;
6303 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6304 if(isTimerActive(timer) ==
false) {
6309 void Servo::write(
int value) {
6310 if(value < MIN_PULSE_WIDTH)
6312 if(value < 0) value = 0;
6313 if(value > 180) value = 180;
6314 value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
6316 this->writeMicroseconds(value);
6319 void Servo::writeMicroseconds(
int value) {
6321 byte channel = this->servoIndex;
6322 if( (channel < MAX_SERVOS) )
6324 if( value < SERVO_MIN() )
6325 value = SERVO_MIN();
6326 else if( value > SERVO_MAX() )
6327 value = SERVO_MAX();
6329 value = value - TRIM_DURATION;
6330 value = usToTicks(value);
6332 uint8_t oldSREG = SREG;
6334 servos[channel].ticks = value;
6339 inline int Servo::read()
6341 return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
6344 int Servo::readMicroseconds() {
6345 unsigned int pulsewidth;
6346 if( this->servoIndex != INVALID_SERVO )
6347 pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ;
6354 inline bool Servo::attached() {
6355 return servos[this->servoIndex].Pin.isActive ;
6361 #if EBOARD_COPY_AND_PASTE > 0x0 6371 #if EBOARD_NANO > 0x0 6372 Servo mainMotor,steerMotor;
6384 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
6400 #if EBOARD_DEBUG_MODE > 0x0 6405 TIMSK2 &= ~(1<<TOIE2);
6406 TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
6407 TCCR2B &= ~(1<<WGM22);
6409 TIMSK2 &= ~(1<<OCIE2A);
6410 TCCR2B |= (1<<CS22);
6411 TCCR2B &= ~((1<<CS21) | (1<<CS20));
6412 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
6413 TIMSK2 |= (1<<TOIE2);
6415 #if EBOARD_BLUETOOTH > 0x0 6416 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 6419 Serial1.begin(38400);
6425 #if EBOARD_I2C > 0x0 6428 #if EBOARD_SHIFT_REGISTER > 0x0 6434 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0) 6437 #if EBOARD_NANO > 0x0 6440 #if EBOARD_DEBUG_MODE > 0x0 6441 Serial.println(
"Initializing main driving motor (3s)");
6443 mainMotor.write(90);
6445 #if EBOARD_DEBUG_MODE > 0x0 6446 Serial.println(
"Initializing of main driving motor completed");
6449 #if EBOARD_DEBUG_MODE > 0x0 6451 Serial.println(
"fin");
6457 #if EBOARD_NANO > 0x0 6458 mainMotor.write(90);
6461 #if EBOARD_NANO == 0x0 6476 #if EBOARD_NANO > 0x0 || defined(DOC) 6492 if(spe < 0 || spe > 180)
return;
6493 mainMotor.write(spe);
6496 if(ang < 0 || ang > 180)
return;
6497 steerMotor.write(ang);
6503 #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process 6505 #pragma GCC diagnostic pop int actPos
stores the actual pos or move-to pos of the AX12Servo
uint16_t _rx_delay_intrabit
the rx startbit delay
uint8_t * pixels
stores the pixels
void onRequest(void(*function)(void))
this will set the user_onRequest method
volatile uint8_t * port
the used port register
virtual size_t write(uint8_t data)
this will write a single unsigned 8-bit value to address
void recv(void)
private receive routine called each time interrupt handler gets triggered
SoccerBoard(void)
The constructor.
void setTX(uint8_t transmitPin)
sets a specific pin to be 'the chosen one' as a txPin
int8_t pin
stores the pin -1 if the pin wasn't set
optVAL_t C
storing value for C-pin [MOTOR SPE]
void begin(long speed)
the start function to setup delay_values etc.
AX12Servo * connected[2]
stores the pointers to the registerd AX12Servo
const unsigned char * buf[11]
to enable 'smooth' access (:
uint8_t _transmitBitMask
the pin mask to address the tx pin
[COPY&PASTE] This is the SoccerBoard ghost struct :D
static void(* user_onReceive)(int numBytes)
twi slave [Rx]receive-event user def handler
uint8_t aOffset[4]
stores the offsets in rgbw format
static volatile uint8_t _receive_buffer_head
current location in rxBuffer
[COPY&PASTE] This is the AX12Servo ghost struct :D
static void detachInterrupt(void)
disables the interrupt feature
void write(void)
this will write values stored in B and C
static uint8_t rxBufferIndex
this defines the rxBuffer Index - current position in rxBuffer array
bool canShow(void)
this will determine if the next show is available [last show finished]
void storePosition(int pos, int speed=0x3FF)
This saves the Servo Position.
int actSpe
stores the actual 'would use speed' of the AX12Servo
optVAL_t getPosition(void)
This "kind of" returns the Servo-Position.
virtual size_t write(uint8_t byte)
writes a specific value to the tx register
optVAL_t B
storing value for B-pin [MOTOR DIR]
void setID(optVAL_t newID)
change the AX-12 Servo this object should speak to
uint8_t getBrightness(void) const
returns the current set brightness
[SPI] This is used to avoid path resolving issues and defines the common known Arduino SPI interface ...
uint16_t numLEDs
stores the amount of LEDs
I2CInOut(SoccerBoard &, optVAL_t, optVAL_t, optVAL_t, optVAL_t)
The constructor.
void button(int)
š§ I prevent errors!
bool isListening(void)
checks if this object is the listening object
~NeoPixel(void)
the destructor [calling free on pixel and freeing input pin]
static uint8_t txBufferIndex
this defines the txBuffer Index - current position in txBuffer array
static void onRequestService(void)
twi slave [Tx]transmitting-event handler
uint16_t _rx_delay_stopbit
the rx stopbit dely
char channel(optVAL_t)
will return the next char received by the module. A 64 byte Serial buffer is included! ...
This is used to avoid path resolving issues and defines the common known Arduino Wire-Interface    ...
int peek(void)
reads the actual pointed rxBuffer element without dropping it
void led(int idx, bool state)
[MEGA] Control the OnBoard LED
uint8_t rx_pin_read(void)
simple routine to read the rxPin by registers
bool begun
true if NeoPixel::begin has been called
static uint8_t transmitting
'boolean' value. Set to 1 if transmitting => in master write mode
RB14Scan(void)
The constructor.
void s2Cmd(optVAL_t o, optVAL_t t)
this function will execute two cmd sends without starting and without ending the transmission ...
void ledOff(int idx)
[MEGA] Deactivate the OnBoard LED
uint8_t gamma8(uint8_t x) const
acces to the gamma-correction-8-bit table ;D
void ledMeter(int)
[MEGA] Activate the OnBoard LED
void powerOn(optVAL_t id)
Set the state of a certain D-pin to HIGH.
void changeModes(optVAL_t, optVAL_t, optVAL_t)
š§ I prevent errors!
static void end(void)
this will end the SPI connection
int8_t getPin(void)
this will return the set data pin
void reset(void)
Resets the Soccerboard if EBOARD_USE_RESET is set to true.
bool listen(void)
sets the SoftwareSerial object to be the listening one gaining control over the buffers etc...
bool reset(void)
clears the screen
bool isMoving(void)
Use this if you wan't to have a nice way of writing false.
void sleep(uint16_t t)
Say goodnight!
void setTorque(uint16_t)
š§ I prevent errors!
void changeMode(bool newMode=true)
enable or disable the display
NeoPixel pixels
the NeoPixel-object we use
void ledOn(void)
Noone needs the AX-12 Servo LED^^.
static uint8_t rxBufferLength
this defines the length of rxBuffer
static uint8_t txAddress
this defines the txAddress the transmitting Dta
int storedPos
stores the position the Servo should go to DynamixelBoard::action()
bool init(void)
initializes the Display called by:
void tx_pin_write(uint8_t pin_state)
writes a bool value on the txPin by registers
static uint8_t txBuffer[]
this defines the txBuffer used to enable delayed read
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b)
sets the rgb color of a specific pixel
void changeAddress(optVAL_t)
š§ I prevent errors!
this namespace contains all the Don't use manually classes ;)
static void attachInterrupt(void)
enables the interrupt feature
SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
the constructor for the SoftwareSerial object
virtual void flush(void)
resets the position in buffer and the buffer itself if the object is listening
static char _receive_buffer[64]
the buffer for rxBuffer
static void begin(void)
this will setup everything for SPI connection
optVAL_t id
stores the id of the AX12Servo obejct
void msleep(uint16_t t)
Say goodnight!
byte pX
the addressing mode (page/horizontal)
DynamixelBoard(SoccerBoard &)
The constructor.
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
virtual int read(void)
this will read a single byte from rxBuffer and increment the Index
void clear(void)
this will reset all set pixels [won't call NeoPixel::show()]
bool setCursor(byte posX=0x0, byte posY=0x0)
set the position of the cursor
uint8_t * getPixels(void) const
this will give you access to the pixels
~SoftwareSerial(void)
the destructor of the SoftwareSerial object
LCD(SoccerBoard &soccerBoard, optVAL_t id=0x3C)
The constructor.
void waitForButton(int)
š§ I prevent errors!
void motorsOff(void)
As requested this is the shortcut to disable the main motor.
int raw(optVAL_t)
this will check for connection status [will return true if pin not connected]
bool overflow(void)
returns the current overflow flag and disables it
static void setDataMode(uint8_t mode)
this will set the Data transfer mode
void updateType(uint16_t t)
this changes the type of communication between arduino and LED stripe
virtual int available(void)
checks if there is data to read available
NeoPixel(void)
the empty constructor
[COPY&PASTE] [BLUETOOTH] This is the RB14Scan ghost struct :D
uint8_t requestFrom(uint8_t address, uint8_t quantity)
this will read a specific quantity of bytes from a specific address
void changeBackground(bool newBackground=false)
changes the background of the display
static void onReceiveService(uint8_t *inBytes, int numBytes)
twi slave [Rx]receive-event handler
void begin()
begin the TwoWire communcation without any data set
optVAL_t ID
ID of the Display.
void motor(uint8_t id, int16_t val)
As requested this is the ultimate shortcut ;)
uint8_t sine8(uint8_t x) const
acces to the sine-8-bit table ;D
bool digital(optVAL_t id)
Reads a digital value from a pin.
static void handle_interrupt(void)
used to handle interrupts on active listening object
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
[COPY&PASTE] This is the DynamixelBoard ghost struct :D
TwoWire()
The constructor of the TwoWire class.
volatile uint8_t * _transmitPortRegister
the register the reveice pin is located on
static void setClockDivider(uint8_t rate)
this will change the clock devider the
void write(const char *const val)
this will write a constant string to the output
void beginTransmission(uint8_t address)
this will start a new transmission to a specific address => master mode
void power(optVAL_t id, bool state)
Set the state of a certain D-pin.
void s1Dat(optVAL_t o)
this function will execute one dat send without starting and without ending the transmission ...
uint32_t endTime
stores the last call time of show for NeoPixel::canShow()
void changeId(optVAL_t)
š§ I prevent errors!
uint16_t _tx_delay
the (generic) tx delay
DynamixelBoard * _conBoard
virtual int peek(void)
this will read a single byte from rxBuffer without increment the Index
void setBrightness(uint8_t val)
changes the brightness for all further acceses via NeoPixel::setPixelColor()
void setSpeed(optVAL_t)
š§ I prevent errors!
void lightOn(void)
enable the backlight
[COPY&PASTE] This is the I2CInOut ghost struct :D
void lightOff(void)
disable the backlight
void setRX(uint8_t receivePin)
sets a specific pin to be 'the chosen one' as a rxPin
bool clear(void)
clears the LCD
bool s1Cmd(optVAL_t o)
this function will execute one cmd send without starting and without ending the transmission ...
void onReceive(void(*function)(int))
this will set the user_onReceive method
uint8_t brightness
stores the brightness
uint8_t pinMask
the used pinMask
void ledsOff(void)
[MEGA] Deactivate the OnBoard LED
static uint8_t txBufferLength
this defines the length of txBuffer
static byte transfer(byte _data)
this will send a single bite via the SPI connection
void setPositionMode(void)
set the AX-12 Servo to positionMode
static void setBitOrder(uint8_t bitOrder)
this will set the BitOrder
void end(void)
ends communcation on the rx pin
void action(void)
will force every AX12Servo to drive to AX12Servo::storedPos with AX12Servo::storedSpeed ...
static SoftwareSerial * active_object
the active SoftwareSerial object to operate on
bool changeBrightness(byte val=0x64)
changes the brightness of the display
void read(void)
š§ I prevent errors!
optVAL_t analog(optVAL_t id)
Reads an analog value from a pin.
void ledOn(int idx)
[MEGA] Activate the OnBoard LED
AX12Servo(void)
The constructor.
void ledOn(optVAL_t)
š§ I prevent errors!
bool changeID(optVAL_t newID=0x3C)
changes the address of the LCD display talked to
void setPosition(int pos, int speed=0x3FF)
This moves the Servo to the new position.
uint16_t _inverse_logic
determining if all pin reads etc whould be inverted (e.g. no pullup on rx);
DynamixelBoard dBoard(board)
the dBoard object
bool is800KHz
determines the speed the communcation is working on
uint16_t _rx_delay_centering
the rx center delay
static volatile uint8_t _receive_buffer_tail
size of rxBuffer
uint8_t endTransmission(void)
this will end the transmission and send the STOP-sequence
void print(const char *data)
prints a string to the display
void setSpeedMode(void)
set the AX-12 Servo NOT to speedMode
virtual int available(void)
this will return the amount of rxBuffer left
uint8_t _receivePin
the id of the receive pin
void drawBitmap(const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY)
draws a bitmap representet as an array of bytes
void ledOff(void)
Noone needs the AX-12 Servo LED^^.
void powerOff(optVAL_t id)
Set the state of a certain D-pin to LOW.
uint16_t _buffer_overflow
determining if an _buffer_overflow occured
static void(* user_onRequest)(void)
twi slave [Tx]transmitting-event user def handler
uint8_t _receiveBitMask
the pin mask to directly read from register (Rx)
virtual int read(void)
reads the actual pointed rxBuffer top element
static uint8_t rxBuffer[]
this defines the rxBuffer used to enable delayed read
volatile uint8_t * _receivePortRegister
the register the reveice pin is located 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 changeMotorID(optVAL_t)
š§ I prevent errors!
void show(void)
this will reveal the setPixels [via NeoPixel::setPixelColor() etc...]
uint16_t numPixels(void) const
returns the size of the LED stripe
void ledOff(optVAL_t)
š§ I prevent errors!
static void tunedDelay(uint16_t delay)
apply a specific delay to achieve higher precision
[I2C] [LCD] This is used to add support for OLED displays connected to the 'SoccerBoard' ...
void changeMotorID(optVAL_t newID)
change the AX-12 Servo this object should speak to
optVAL_t A
storing value for A-pin (š§ I prevent errors!)
This is used to avoid path resolving issues and defines the common known Arduino SoftwareSerial inter...