6 #ifndef EBOARD_HEADER_GUARD 7 #define EBOARD_HEADER_GUARD 8 #pragma GCC diagnostic push 9 #pragma GCC diagnostic ignored "-Wall" 10 #pragma GCC diagnostic ignored "-Wextra" 15 #define EBOARD_VERSION "3.1m" 16 #define VALUE_TO_STRING(x) #x 20 #define PREPROCESS_DEBUG 1 23 #define VALUE(x) VALUE_TO_STRING(x) 25 #ifndef PREPROCESS_DEBUG 27 #define PREPROCESS_DEBUG 0 29 #define PPERFORM_PRAGMA(str) _Pragma(#str) 31 #if PREPROCESS_DEBUG == 1 32 #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str)) 34 #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str)) 36 #define DEBUG_MSG(str) ; 37 #define MACRO_MSG(mac,str) ; 39 DEBUG_MSG(
"If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
41 DEBUG_MSG(
"You are using eBoard-header v3.1m written by EagleoutIce");
512 DEBUG_MSG(
"Documentation macro SET => Full doc features enabled");
517 #define EBOARD_I2C 0x1 522 #define EBOARD_LCD 0x1 526 #define EBOARD_SHIFT_REGISTER 0x1 530 #define EBOARD_BLUETOOTH 0x1 538 #define __AVR_ATmega2560__ 542 #define __AVR_ATmega328P__ 546 #define EBOARD_NEO 0x1 564 return int((__builtin_sin((val/128.0*PI))+1)*127.5+0.5);
572 return int(pow((val)/255.0,2.6)*255.0+0.5);
575 #include <avr/pgmspace.h> 582 #ifndef EBOARD_GUESSPATH 583 DEBUG_MSG(
"You are using Guesspath! Necessary libraries for eBoard will be included automatically");
587 #define EBOARD_GUESSPATH 0x1 589 DEBUG_MSG(
"You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
592 #if defined(ARDUINO) //general platform-check [No tab] 597 #define main eVirtual_main //main has a different meaning^^ 599 #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D 605 #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__)) 606 #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!" 609 #if defined(__AVR_ATmega2560__) 610 DEBUG_MSG(
"Building for Arduino Mega with ATmega2560");
614 #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS 616 DEBUG_MSG(
"Building for Arduino Uno or Nano with ATmega328P");
617 #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS 621 #include <avr/interrupt.h> 623 #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0 624 DEBUG_MSG(
"You enabled I²C featurea");
631 #define TWI_FREQ 100000L 634 # ifndef TWI_BUFFER_LENGTH 635 #define TWI_BUFFER_LENGTH 32 646 #include <avr/interrupt.h> 647 #include <compat/twi.h> 650 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 654 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 657 #include "pins_arduino.h" 659 static volatile uint8_t twi_state;
660 static volatile uint8_t twi_slarw;
661 static volatile uint8_t twi_sendStop;
662 static volatile uint8_t twi_inRepStart;
664 static void (*twi_onSlaveTransmit)(void);
665 static void (*twi_onSlaveReceive)(uint8_t*, int);
667 static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
668 static volatile uint8_t twi_masterBufferIndex;
669 static volatile uint8_t twi_masterBufferLength;
671 static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
672 static volatile uint8_t twi_txBufferIndex;
673 static volatile uint8_t twi_txBufferLength;
675 static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
676 static volatile uint8_t twi_rxBufferIndex;
678 static volatile uint8_t twi_error;
680 void twi_init(
void) {
681 twi_state = TWI_READY;
683 twi_inRepStart =
false;
685 digitalWrite(SDA, 1);
686 digitalWrite(SCL, 1);
690 TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
692 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
695 inline void twi_setAddress(uint8_t address) {
699 uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) {
702 if(TWI_BUFFER_LENGTH < length)
return 0;
704 while(TWI_READY != twi_state)
continue;
707 twi_sendStop = sendStop;
711 twi_masterBufferIndex = 0;
712 twi_masterBufferLength = length-1;
714 twi_slarw |= address << 1;
716 if (
true == twi_inRepStart) {
717 twi_inRepStart =
false;
719 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
722 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
724 while(TWI_MRX == twi_state)
continue;
726 if (twi_masterBufferIndex < length)
727 length = twi_masterBufferIndex;
729 for(i = 0; i < length; ++i) data[i] = twi_masterBuffer[i];
734 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) {
737 if(TWI_BUFFER_LENGTH < length)
return 1;
739 while(TWI_READY != twi_state)
continue;
742 twi_sendStop = sendStop;
745 twi_masterBufferIndex = 0;
746 twi_masterBufferLength = length;
748 for(i = 0; i < length; ++i) twi_masterBuffer[i] = data[i];
750 twi_slarw = TW_WRITE;
751 twi_slarw |= address << 1;
753 if (
true == twi_inRepStart) {
754 twi_inRepStart =
false;
756 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
759 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
761 while(wait && (TWI_MTX == twi_state))
continue;
763 if (twi_error == 0xFF)
return 0;
764 else if (twi_error == TW_MT_SLA_NACK)
return 2;
765 else if (twi_error == TW_MT_DATA_NACK)
return 3;
769 uint8_t twi_transmit(
const uint8_t* data, uint8_t length) {
772 if(TWI_BUFFER_LENGTH < length)
return 1;
774 if(TWI_STX != twi_state)
return 2;
776 twi_txBufferLength = length;
777 for(i = 0; i < length; ++i) twi_txBuffer[i] = data[i];
782 void twi_attachSlaveRxEvent(
void (*
function)(uint8_t*,
int) ) {
783 twi_onSlaveReceive =
function;
786 void twi_attachSlaveTxEvent(
void (*
function)(
void) ) {
787 twi_onSlaveTransmit =
function;
790 void twi_reply(uint8_t ack) {
792 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
794 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
799 void twi_stop(
void) {
800 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
802 while(TWCR & _BV(TWSTO))
continue;
804 twi_state = TWI_READY;
807 void twi_releaseBus(
void){
808 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
809 twi_state = TWI_READY;
822 if(twi_masterBufferIndex < twi_masterBufferLength){
823 TWDR = twi_masterBuffer[twi_masterBufferIndex++];
826 if (twi_sendStop) twi_stop();
828 twi_inRepStart =
true;
829 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
830 twi_state = TWI_READY;
835 twi_error = TW_MT_SLA_NACK;
838 case TW_MT_DATA_NACK:
839 twi_error = TW_MT_DATA_NACK;
843 twi_error = TW_MT_ARB_LOST;
847 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
849 if(twi_masterBufferIndex < twi_masterBufferLength) twi_reply(1);
852 case TW_MR_DATA_NACK:
853 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
854 if (twi_sendStop) twi_stop();
856 twi_inRepStart =
true;
857 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
858 twi_state = TWI_READY;
865 case TW_SR_GCALL_ACK:
866 case TW_SR_ARB_LOST_SLA_ACK:
867 case TW_SR_ARB_LOST_GCALL_ACK:
869 twi_rxBufferIndex = 0;
873 case TW_SR_GCALL_DATA_ACK:
874 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
875 twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
881 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH) twi_rxBuffer[twi_rxBufferIndex] =
'\0';
883 twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
884 twi_rxBufferIndex = 0;
887 case TW_SR_DATA_NACK:
888 case TW_SR_GCALL_DATA_NACK:
892 case TW_ST_ARB_LOST_SLA_ACK:
894 twi_txBufferIndex = 0;
895 twi_txBufferLength = 0;
896 twi_onSlaveTransmit();
897 if(0 == twi_txBufferLength){
898 twi_txBufferLength = 1;
899 twi_txBuffer[0] = 0x00;
902 TWDR = twi_txBuffer[twi_txBufferIndex++];
903 if(twi_txBufferIndex < twi_txBufferLength) twi_reply(1);
906 case TW_ST_DATA_NACK:
907 case TW_ST_LAST_DATA:
909 twi_state = TWI_READY;
915 twi_error = TW_BUS_ERROR;
922 #include <inttypes.h> 925 #define BUFFER_LENGTH 32 988 void begin(uint8_t address);
994 inline void begin(
int address);
1035 inline uint8_t
requestFrom(uint8_t address, uint8_t quantity);
1043 uint8_t
requestFrom(uint8_t address , uint8_t quantity, uint8_t sendStop);
1051 inline uint8_t
requestFrom(
int address,
int quantity);
1060 inline uint8_t
requestFrom(
int address,
int quantity,
int sendStop);
1069 virtual size_t write(uint8_t data);
1077 virtual size_t write(
const uint8_t *data,
size_t quantity);
1088 virtual int read(
void);
1094 virtual int peek(
void);
1101 void onReceive(
void (*
function)(
int) );
1108 void onRequest(
void (*
function)(
void) );
1122 #include <inttypes.h> 1153 twi_setAddress(address);
1160 begin((uint8_t)address);
1167 uint8_t
read = twi_readFrom(address,
rxBuffer, quantity, sendStop);
1175 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1179 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1183 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
1219 twi_transmit(&data, 1);
1226 for(
size_t i = 0; i < quantity; ++i) {
1230 twi_transmit(data, quantity);
1269 for(uint8_t i = 0; i < numBytes; ++i) {
1299 DEBUG_MSG(
"You disabled I²C");
1304 #ifndef EBOARD_USE_SPI 1305 #define EBOARD_USE_SPI 0x1 1307 #if EBOARD_USE_SPI > 0x0 1308 DEBUG_MSG(
"You enabled SPI");
1310 #define _SPI_H_INCLUDED 1314 #define SPI_CLOCK_DIV4 0x00 1315 #define SPI_CLOCK_DIV16 0x01 1317 #define SPI_CLOCK_DIV64 0x02 1319 #define SPI_CLOCK_DIV128 0x03 1321 #define SPI_CLOCK_DIV2 0x04 1323 #define SPI_CLOCK_DIV8 0x05 1325 #define SPI_CLOCK_DIV32 0x06 1329 #define SPI_MODE0 0x00 1330 #define SPI_MODE1 0x04 1332 #define SPI_MODE2 0x08 1334 #define SPI_MODE3 0x0C 1338 #define SPI_MODE_MASK 0x0C 1339 #define SPI_CLOCK_MASK 0x03 1341 #define SPI_2XCLOCK_MASK 0x01 1363 inline static byte
transfer(byte _data);
1375 static void begin(
void);
1379 inline static void end(
void);
1400 while (!(SPSR & _BV(SPIF)));
1409 digitalWrite(SS, HIGH);
1410 pinMode(SS, OUTPUT);
1413 pinMode(SCK, OUTPUT);
1414 pinMode(MOSI, OUTPUT);
1420 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
1421 else SPCR &= ~(_BV(DORD));
1435 DEBUG_MSG(
"You disabled SPI");
1438 #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0) 1439 #include <avr/pgmspace.h> 1440 DEBUG_MSG(
"You enabled LCD");
1454 DEBUG_MSG(
"You defined IGNORE_SIZE: byte will be used");
1457 DEBUG_MSG(
"You did not define IGNORE_SIZE: int will be used");
1464 #ifndef EBOARD_DEBUG_MODE 1465 #define EBOARD_DEBUG_MODE 0x1 1468 #if EBOARD_DEBUG_MODE > 0x0 1479 #define EBOARD_NANO 0x0 1482 #if EBOARD_NANO > 0x0 || defined(DOC) 1483 #ifndef EBOARD_NANO_STEER 1487 #define EBOARD_NANO_STEER 12 1489 #ifndef EBOARD_NANO_MAIN 1493 #define EBOARD_NANO_MAIN 13 1495 MACRO_MSG(
EBOARD_NANO,
"Using Arduino NANO environment [e.g. remove SoccerBoard]");
1496 #if PREPROCESS_DEBUG > 0x1 1497 #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR") 1498 #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR") 1501 MACRO_MSG(
EBOARD_NANO,
"Using Arduino UNO/MEGA environment");
1507 #ifndef EBOARD_CHECK_PINS 1508 #define EBOARD_CHECK_PINS 0x1 1511 #if EBOARD_CHECK_PINS > 0x0 1517 #ifndef EBOARD_SHIFT_REGISTER 1521 #define EBOARD_SHIFT_REGISTER 0x0 1524 #if EBOARD_SHIFT_REGISTER > 0x0 1533 #ifndef EBOARD_CHECK_PINS_PWM 1534 #define EBOARD_CHECK_PINS_PWM 0x1 1537 #if EBOARD_CHECK_PINS_PWM > 0x0 1546 #ifndef EBOARD_DEBUG_SPEED 1547 #define EBOARD_DEBUG_SPEED 9600 1549 #if PREPROCESS_DEBUG > 0x0 1550 #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED)) 1557 #ifndef EBOARD_SPI_SERVO_MAX 1558 #define EBOARD_SPI_SERVO_MAX 2 1560 #if PREPROCESS_DEBUG > 0x0 1561 #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX)) 1566 #ifndef EBOARD_USE_UTILITY 1567 #define EBOARD_USE_UTILITY 0x1 1569 #if EBOARD_USE_UTILITY > 0x0 1578 #define EBOARD_COPY_AND_PASTE 0x1 1582 #ifndef EBOARD_PWM_SPE 1583 #define EBOARD_PWM_SPE 1 1585 #if PREPROCESS_DEBUG > 0x0 1586 #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s") 1593 #define EBOARD_I2C 0x0 //disabled by default 1596 #ifndef EBOARD_BLUETOOTH 1600 #define EBOARD_BLUETOOTH 0x0 1603 #if EBOARD_BLUETOOTH > 0x0 1612 #ifndef EBOARD_CLAMP 1613 #define EBOARD_CLAMP 0x1 1615 #if EBOARD_CLAMP > 0x0 1616 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [0;1023]");
1618 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [-300;300]");
1625 #define EBOARD_NEO 0x0 1627 #if EBOARD_NEO > 0x0 1628 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support enabled");
1630 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support disabled");
1636 #ifndef EBOARD_USE_RESET 1637 #define EBOARD_USE_RESET 0x1 1640 #if EBOARD_USE_RESET > 0x0 1641 #include <avr/wdt.h> 1650 #ifndef PIN_BLUETOOTH_STATE 1651 #if defined(__AVR_ATmega2560__) 1652 #define PIN_BLUETOOTH_STATE 0x13 // 19 1654 #define PIN_BLUETOOTH_STATE 0x2 1661 #ifndef PIN_BLUETOOTH_RX 1662 #if defined(__AVR_ATmega2560__) 1663 #define PIN_BLUETOOTH_RX 0x13 // 19 1665 #define PIN_BLUETOOTH_RX 0x2 1672 #ifndef PIN_BLUETOOTH_TX 1673 #if defined(__AVR_ATmega2560__) 1674 #define PIN_BLUETOOTH_TX 0x12 // 18 1676 #define PIN_BLUETOOTH_TX 0x3 1683 #ifndef PIN_MOTOR_DIR 1684 #define PIN_MOTOR_DIR 0x4 1690 #ifndef PIN_MOTOR_SPE 1691 #define PIN_MOTOR_SPE 0x5 1697 #ifndef PIN_SHIFT_CLK 1698 #define PIN_SHIFT_CLK 0x6 1703 #ifndef PIN_SHIFT_DAT 1704 #define PIN_SHIFT_DAT 0x7 1709 #ifndef PIN_SHIFT_LAT 1710 #define PIN_SHIFT_LAT 0x8 1723 #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__) 1724 #if EBOARD_GUESSPATH > 0x0 1727 #define _SS_MAX_RX_BUFF 64 // RX buffer size 1729 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 1804 void setTX(uint8_t transmitPin);
1809 void setRX(uint8_t receivePin);
1814 static inline void tunedDelay(uint16_t delay);
1824 SoftwareSerial(uint8_t receivePin, uint8_t transmitPin,
bool inverse_logic =
false);
1846 void begin(
long speed);
1853 inline void end(
void);
1875 virtual size_t write(uint8_t byte);
1880 virtual int read(
void);
1889 virtual void flush(
void);
1916 #if EBOARD_DEBUG_MODE > 0x0 1918 #define _DEBUG_PIN1 11 1919 #define _DEBUG_PIN2 13 1921 typedef struct _DELAY_TABLE {
1923 unsigned short rx_delay_centering;
1924 unsigned short rx_delay_intrabit;
1925 unsigned short rx_delay_stopbit;
1926 unsigned short tx_delay;
1928 #if F_CPU == 16000000 1930 static const DELAY_TABLE PROGMEM table[] = {
1932 { 115200, 1, 17, 17, 12, },
1933 { 57600, 10, 37, 37, 33, },
1934 { 38400, 25, 57, 57, 54, },
1935 { 31250, 31, 70, 70, 68, },
1936 { 28800, 34, 77, 77, 74, },
1937 { 19200, 54, 117, 117, 114, },
1938 { 14400, 74, 156, 156, 153, },
1939 { 9600, 114, 236, 236, 233, },
1940 { 4800, 233, 474, 474, 471, },
1941 { 2400, 471, 950, 950, 947, },
1942 { 1200, 947, 1902, 1902, 1899, },
1943 { 600, 1902, 3804, 3804, 3800, },
1944 { 300, 3804, 7617, 7617, 7614, },
1947 const int XMIT_START_ADJUSTMENT = 5;
1949 #elif F_CPU == 8000000 1951 static const DELAY_TABLE table[] PROGMEM = {
1953 { 115200, 1, 5, 5, 3, },
1954 { 57600, 1, 15, 15, 13, },
1955 { 38400, 2, 25, 26, 23, },
1956 { 31250, 7, 32, 33, 29, },
1957 { 28800, 11, 35, 35, 32, },
1958 { 19200, 20, 55, 55, 52, },
1959 { 14400, 30, 75, 75, 72, },
1960 { 9600, 50, 114, 114, 112, },
1961 { 4800, 110, 233, 233, 230, },
1962 { 2400, 229, 472, 472, 469, },
1963 { 1200, 467, 948, 948, 945, },
1964 { 600, 948, 1895, 1895, 1890, },
1965 { 300, 1895, 3805, 3805, 3802, },
1968 const int XMIT_START_ADJUSTMENT = 4;
1970 #elif F_CPU == 20000000 1972 static const DELAY_TABLE PROGMEM table[] = {
1974 { 115200, 3, 21, 21, 18, },
1975 { 57600, 20, 43, 43, 41, },
1976 { 38400, 37, 73, 73, 70, },
1977 { 31250, 45, 89, 89, 88, },
1978 { 28800, 46, 98, 98, 95, },
1979 { 19200, 71, 148, 148, 145, },
1980 { 14400, 96, 197, 197, 194, },
1981 { 9600, 146, 297, 297, 294, },
1982 { 4800, 296, 595, 595, 592, },
1983 { 2400, 592, 1189, 1189, 1186, },
1984 { 1200, 1187, 2379, 2379, 2376, },
1985 { 600, 2379, 4759, 4759, 4755, },
1986 { 300, 4759, 9523, 9523, 9520, },
1989 const int XMIT_START_ADJUSTMENT = 6;
1992 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors 1999 #if EBOARD_DEBUG_MODE > 0x0 2000 inline void DebugPulse(uint8_t pin, uint8_t count) {
2002 volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
2004 uint8_t val = *pport;
2007 *pport = val | digitalPinToBitMask(pin);
2016 asm volatile(
"sbiw %0, 0x01 \n\t" 2018 "cpi %A0, 0xFF \n\t" 2021 :
"+r" (delay),
"+a" (tmp)
2030 uint8_t oldSREG = SREG;
2043 #if GCC_VERSION < 40302 2061 #if EBOARD_DEBUG_MODE > 0x0 2062 DebugPulse(_DEBUG_PIN2, 1);
2065 for (uint8_t i=0x1; i; i <<= 1)
2068 #if EBOARD_DEBUG_MODE > 0x0 2069 DebugPulse(_DEBUG_PIN2, 1);
2080 #if EBOARD_DEBUG_MODE > 0x0 2081 DebugPulse(_DEBUG_PIN2, 1);
2091 #if EBOARD_DEBUG_MODE > 0x0 2092 #if _DEBUG // for scope: pulse pin as overflow indictator 2093 DebugPulse(_DEBUG_PIN1, 1);
2100 #if GCC_VERSION < 40302 2115 if (pin_state == LOW)
2131 #if defined(PCINT0_vect) 2137 #if defined(PCINT1_vect) 2143 #if defined(PCINT2_vect) 2149 #if defined(PCINT3_vect) 2156 _rx_delay_centering(0),
2157 _rx_delay_intrabit(0),
2158 _rx_delay_stopbit(0),
2160 _buffer_overflow(false),
2161 _inverse_logic(inverse_logic) {
2171 pinMode(tx, OUTPUT);
2172 digitalWrite(tx, HIGH);
2174 uint8_t port = digitalPinToPort(tx);
2181 digitalWrite(rx, HIGH);
2184 uint8_t port = digitalPinToPort(rx);
2191 for (
unsigned i=0; i<
sizeof(table)/
sizeof(table[0]); ++i) {
2192 long baud = pgm_read_dword(&table[i].baud);
2193 if (baud == speed) {
2197 _tx_delay = pgm_read_word(&table[i].tx_delay);
2211 pinMode(_DEBUG_PIN1, OUTPUT);
2212 pinMode(_DEBUG_PIN2, OUTPUT);
2249 uint8_t oldSREG = SREG;
2256 for (byte mask = 0x01; mask; mask <<= 1) {
2268 for (byte mask = 0x01; mask; mask <<= 1) {
2289 uint8_t oldSREG = SREG;
2314 #if EBOARD_DEBUG_MODE > 0x0 2318 #define __ASSERT_USE_STDERR 2337 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp);
2339 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp){
2340 Serial.print(
"Error with: "); Serial.print(__func);
2341 Serial.print(
" in "); Serial.print(__file);
2342 Serial.print(
" >>");
2343 Serial.println(__sexp);
2344 if(strcmp(__func,
"checkIdx")==0){
2345 Serial.println(
" This happens if an out of bounds exception");
2346 Serial.println(
" has occured. Following pins shouldn't be used:");
2349 Serial.println(
" : Used for Bluetooth communication");
2350 Serial.print(
" D");Serial.print(
PIN_MOTOR_DIR);Serial.print(
"&");
2352 Serial.println(
" : Used for main motor control");
2353 #if EBOARD_USE_SPI > 0x0 2354 Serial.print(
" D10-13");
2355 Serial.println(
": Used for smart-servo-shield");
2357 }
else if (strcmp(__func,
"readPin")==0){
2358 Serial.println(
"You've tried to access an analogPin that isn't present on the board you're currently working on!");
2375 #if EBOARD_DEBUG_MODE > 0x0 2376 assert(idx>=0x0 && idx <
PIN_MAX);
2382 #if EBOARD_COPY_AND_PASTE > 0x0 2383 #if EBOARD_CHECK_PINS_PWM > 0x0 2394 for (count = 0; x; count++)
2401 #if EBOARD_CHECK_PINS > 0x0 2407 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2409 #elif defined(__AVR_ATmega2560__) 2415 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2417 #elif defined(__AVR_ATmega2560__) 2434 return (mode == OUTPUT)? ((
pin_out & (1<<idx))>0x0):((
pin_in & (1<<idx))>0x0);
2447 #if EBOARD_CHECK_PINS > 0x0 2463 #if EBOARD_BLUETOOTH > 0x0 2472 inline char readVal(
char oF =
'.');
2485 template <
typename T>
2486 inline void writeVal(
const T& val);
2502 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2508 inline char readVal(
char oF) {
2509 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2510 return ((Serial1.available())?(Serial1.read()):(oF));
2515 template<
typename T>
2516 inline void writeVal(
const T& val){
2517 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2524 #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE 2533 #if EBOARD_SHIFT_REGISTER > 0x0 2581 val = min(val,0xFF); val = max(0x0,val);
2586 extern void rept_task(
void);
2587 DEBUG_MSG(
"You defined REPT_TASK: you have to define rept_task(void)!");
2589 DEBUG_MSG(
"You did not define REPT_TASK: rept_task(void) will not have any effect");
2606 #if EBOARD_SHIFT_REGISTER > 0x0 2613 #if EBOARD_CHECK_PINS > 0x0 2617 #if EBOARD_COPY_AND_PASTE > 0x0 2620 pinMode(idx,OUTPUT);
2622 digitalWrite(idx,val);
2638 #if EBOARD_CHECK_PINS > 0x0 2640 #if defined (__AVR_ATmega2560__) 2641 else if (idx<0||idx>0xF){
2643 else if (idx<0||idx>0x7){
2645 #if EBOARD_DEBUG_MODE > 0x0 2652 #if EBOARD_COPY_AND_PASTE > 0x0 2657 return((dig)? digitalRead(idx) : analogRead(idx));
2661 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0) 2667 #if defined(__AVR_ATmega2560__) 2668 ServoCds55(
int CS=53);
2670 ServoCds55(
int CS=10);
2673 void WritePos(
int ID,
int Pos);
2674 void write(
int ID,
int Pos);
2675 inline void setVelocity(
int velocity);
2676 inline void setPoslimit(
int posLimit);
2677 inline void rotate(
int ID,
int velocity);
2678 void SetServoLimit(
int ID,
int upperLimit);
2679 void SetMotormode(
int ID,
int velocity);
2680 void SetID(
int ID,
int newID);
2682 byte sendWait (
const byte what);
2685 int upperLimit_temp;
2688 ServoCds55::ServoCds55 (
int CS):cs(CS) {
2689 velocity_temp = 150;
2690 upperLimit_temp = 300;
2693 void ServoCds55::begin() {
2695 digitalWrite(cs,HIGH);
2700 byte ServoCds55::sendWait (
const byte what) {
2702 delayMicroseconds (20);
2706 void ServoCds55::setVelocity(
int velocity){
2707 velocity_temp = velocity;
2710 void ServoCds55::setPoslimit(
int posLimit){
2711 upperLimit_temp = posLimit;
2714 void ServoCds55::write(
int ID,
int Pos){
2715 SetServoLimit(ID,upperLimit_temp);
2719 inline void ServoCds55::rotate(
int ID,
int velocity){
2720 SetServoLimit(ID,0);
2722 SetMotormode(ID,velocity);
2725 void ServoCds55::WritePos(
int ID,
int Pos){
2726 int PosB = (Pos>>8 & 0xff);
2727 int PosS = (Pos & 0xff);
2728 int velocityB = (velocity_temp>>8 & 0xff);
2729 int velocityS = (velocity_temp & 0xff);
2730 digitalWrite(cs, LOW);
2731 sendWait (
'p'); sendWait (ID);
2732 sendWait (PosB); sendWait (PosS);
2733 sendWait (velocityB); sendWait (velocityS);
2734 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2735 digitalWrite(cs, HIGH);
2739 void ServoCds55::SetServoLimit(
int ID,
int upperLimit_temp){
2740 int upperLimitB = (upperLimit_temp>>8 & 0xff);
2741 int upperLimitS = (upperLimit_temp & 0xff);
2742 digitalWrite(cs, LOW);
2743 sendWait (
's'); sendWait (ID);
2744 sendWait (upperLimitB); sendWait (upperLimitS);
2745 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2746 digitalWrite(cs, HIGH);
2750 void ServoCds55::SetMotormode(
int ID,
int velocity){
2751 int velocityB = (velocity>>8 & 0xff);
2752 int velocityS = (velocity & 0xff);
2753 digitalWrite(cs, LOW);
2754 sendWait (
'm'); sendWait (ID);
2755 sendWait (velocityB); sendWait (velocityS);
2756 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2757 digitalWrite(cs, HIGH);
2761 void ServoCds55::SetID(
int ID,
int newID){
2762 digitalWrite(cs, LOW);
2763 sendWait (
'i'); sendWait (ID);
2765 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2766 digitalWrite(cs, HIGH);
2770 void ServoCds55::Reset(
int ID){
2771 digitalWrite(cs, LOW);
2772 sendWait (
'r'); sendWait (ID);
2773 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2774 digitalWrite(cs, HIGH);
2783 #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0 2816 #if EBOARD_USE_UTILITY > 0x0 or defined(__AVR_ATmega2560__) //won't shrink space... just speed things up 2825 inline void led(
int idx,
bool state);
2833 inline void ledOn(
int idx);
2841 inline void ledOff(
int idx);
2856 #if EBOARD_USE_UTILITY > 0x0 2872 inline void motor(uint8_t
id,int16_t val);
2915 inline void sleep(uint16_t t);
2921 inline void msleep(uint16_t t);
2939 inline void reset(
void);
2944 #if defined(__AVR_ATmega2560__) 2950 #elif EBOARD_USE_UTILITY > 0x0 2958 #if EBOARD_USE_UTILITY > 0x0 2965 else if(
id>0&&
id<3&&(val>-0 && val < 1024)) {
_servoHandler.write((
id-1),(val *600/1023 - 300));}
2970 #if EBOARD_USE_RESET > 0x0 2971 wdt_enable(WDTO_15MS);
2987 #define DIGITAL_IN 0x0 2988 #define DIGITAL_IN_INV 0x1 2990 #define DIGITAL_IN_PULLUP 0x2 2992 #define DIGITAL_IN_PULLUP_INV 0x3 2994 #define DIGITAL_OUT 0x4 2996 #define DIGITAL_OUT_INV 0x5 2998 #define DIGITAL_OUT_LOW 0x6 3000 #define DIGITAL_OUT_HIGH 0x7 3002 #define ANALOG_IN_8_BIT 0x8 3004 #define ANALOG_IN_10_BIT 0x9 3006 #define ANALOG_IN_MEAN_8_BIT 0xA 3008 #define ANALOG_IN_MEAN_10_BIT 0xB 3010 #define COUNTER_8_BIT 0xC 3012 #define COUNTER_16_BIT 0xD 3014 #define COUNTER_RISE_8_BIT 0xE 3016 #define COUNTER_RISE_16_BIT 0xF 3018 #define PWM_SLOW 0x8 3020 #define PWM_FAST 0x9 3022 #define FREQ_LOW 0xA 3024 #define FREQ_HIGH 0xB 3026 #define COUNTER_B_DIR 0xC 3028 #define COUNTER_B_DIR_PULLUP 0xD 3030 #define COUNTER_MEAN_8_BIT 0xE 3032 #define COUNTER_MEAN_16_BIT 0xF 3065 #if EBOARD_USE_UTILITY > 0x0 3066 inline void read(
void);
3077 inline void write(
void);
3089 this->
A=0x0;this->
B=0x0;this->
C=0x0;
3091 #if EBOARD_USE_UTILITY > 0x0 3146 #if EBOARD_USE_UTILITY > 0x0 3182 inline void ledOff(
void);
3184 inline void ledOn(
void);
3246 #if EBOARD_USE_UTILITY > 0x0 3259 #if EBOARD_CLAMP > 0x0 3260 if(pos>1023 || speed > 1023)
return;
3262 speed = speed*600/1023 - 300;
3263 pos = pos *600/1023 - 300;
3266 if(pos>300 || speed > 300)
return;
3307 #if EBOARD_USE_UTILITY > 0x0 3317 inline void action(
void);
3335 #if EBOARD_USE_UTILITY > 0x0 3360 #if EBOARD_BLUETOOTH > 0x0 3406 inline void write(
const char*
const val);
3424 #if EBOARD_I2C > 0x0 3470 for (byte i = 1; (i < 255 && !
STOP); i++) {
3474 if(count < ret_len) ret[count] = i;
3512 #if EBOARD_LCD > 0x0 3515 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
3516 {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
3517 {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
3518 {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
3519 {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
3520 {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
3521 {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
3522 {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
3523 {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
3524 {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
3525 {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
3526 {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
3527 {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
3528 {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
3529 {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
3530 {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
3531 {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
3532 {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
3533 {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
3534 {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
3535 {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
3536 {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
3537 {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
3538 {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
3539 {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
3540 {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
3541 {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
3542 {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
3543 {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
3544 {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
3545 {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
3546 {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
3547 {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
3548 {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
3549 {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
3550 {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
3551 {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
3552 {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
3553 {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
3554 {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
3555 {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
3556 {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
3557 {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
3558 {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
3559 {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
3560 {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
3561 {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
3562 {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
3563 {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
3564 {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
3565 {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
3566 {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
3567 {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
3568 {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
3569 {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
3570 {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
3571 {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
3572 {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
3573 {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
3574 {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
3575 {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
3576 {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
3577 {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
3578 {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
3579 {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
3580 {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
3581 {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
3582 {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
3583 {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
3584 {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
3585 {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
3586 {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
3587 {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
3588 {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
3589 {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
3590 {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
3591 {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
3592 {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
3593 {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
3594 {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
3595 {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
3596 {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
3597 {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
3598 {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
3599 {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
3600 {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
3601 {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
3602 {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
3603 {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
3604 {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
3605 {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
3606 {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
3607 {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
3608 {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
3609 {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
3610 {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
3875 #define LCD_COMMAND_MODE 0x80 3876 #define LCD_DATA_MODE 0x40 3878 #define LCD_COMMAND_DISPLAY_OFF 0xAE 3880 #define LCD_COMMAND_DISPLAY_ON 0xAF 3882 #define LCD_COMMAND_BLACK_BACKGROUND 0xA6 3884 #define LCD_COMMAND_WHITE_BACKGROUND 0xA7 3886 #define LCD_COMMAND_SET_BRIGHTNESS 0x81 3888 #define LCD_PAGE_ADDRESSING 0x02 3890 #define LCD_HORIZONTAL_ADDRESSING 0x00 3894 #define LCD_COMMAND_CHARGE_PUMP_SETTING 0x8d 3895 #define LCD_COMMAND_CHARGE_PUMP_ENABLE 0x14 3899 #define LCD_WIDTH 128 3903 #define LCD_HEIGHT 64 3948 #if EBOARD_NANO == 0 3986 inline bool clear(
void);
3992 inline void print(
const char* data);
3998 inline void print(
int data);
4043 inline bool reset(
void);
4058 inline bool init(
void);
4068 inline void drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY);
4090 inline bool setCursor(byte posX = 0x0, byte posY = 0x0);
4158 #if EBOARD_NANO == 0x0 4173 return this->
init();
4177 for(byte i = 0; i < 8; i++){
4181 for (byte j = 0; j < 128; j++)
4201 if(data[i] < 32 || data[i] > 127){ i++;
continue;}
4202 for (byte j = 0; j < 8; j++){
4209 char buffer[11] =
"";
4210 itoa(data,buffer,10);
4211 this->
print(line,col,buffer);
4220 return this->
clear();
4237 return this->
clear();
4240 inline void LCD::drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY){
4244 for(
int i = 0x0; i < (hiX * 8 * hiY); i++){
4245 this->
s1Dat(pgm_read_byte(&bitmap[i]));
4246 if(++col == (hiX * 8)) {
4259 this->
s2Cmd((0x00 + (8 *posX & 0x0F)),(0x10 + ((8 * posX >> 4) & 0x0F)));
4260 this->
pX = posX; this->
pY = posY;
4261 return this->
s1Cmd(0xB0 + posY);
4266 this->
s2Cmd(0x81,val);
4297 #if EBOARD_NEO > 0x0 4302 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 4303 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 4305 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 4307 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 4309 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 4311 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 4317 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 4318 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 4320 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 4322 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 4324 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 4326 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 4328 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 4330 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 4332 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 4334 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 4336 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 4338 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 4340 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 4342 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 4344 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 4346 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 4348 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 4350 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 4352 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 4354 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 4356 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 4358 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 4360 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 4362 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 4367 #define EBOARD_NEO_800KHZ 0x0000 4368 #define EBOARD_NEO_400KHZ 0x0100 4449 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
4458 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4501 inline int8_t
getPin(
void);
4513 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
4521 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4554 #ifdef __AVR__ //not needed (rem?) 4555 volatile uint8_t *
port;
4567 begun(false), brightness(0),
pixels(NULL), endTime(0) {
4577 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
4583 if(
pin >= 0) pinMode(
pin, INPUT);
4588 pinMode(
pin, OUTPUT);
4589 digitalWrite(
pin, LOW);
4621 #if defined(ESP8266) 4623 extern "C" void ICACHE_RAM_ATTR espShow(
4624 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4625 #elif defined(ESP32) 4626 extern "C" void espShow(
4627 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4644 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 4647 volatile uint8_t n1, n2 = 0;
4650 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4651 if(
port == &PORTD) {
4657 if(b & 0x80) n1 = hi;
4662 "out %[port] , %[hi]" "\n\t" 4663 "mov %[n2] , %[lo]" "\n\t" 4664 "out %[port] , %[n1]" "\n\t" 4666 "sbrc %[byte] , 6" "\n\t" 4667 "mov %[n2] , %[hi]" "\n\t" 4668 "out %[port] , %[lo]" "\n\t" 4671 "out %[port] , %[hi]" "\n\t" 4672 "mov %[n1] , %[lo]" "\n\t" 4673 "out %[port] , %[n2]" "\n\t" 4675 "sbrc %[byte] , 5" "\n\t" 4676 "mov %[n1] , %[hi]" "\n\t" 4677 "out %[port] , %[lo]" "\n\t" 4680 "out %[port] , %[hi]" "\n\t" 4681 "mov %[n2] , %[lo]" "\n\t" 4682 "out %[port] , %[n1]" "\n\t" 4684 "sbrc %[byte] , 4" "\n\t" 4685 "mov %[n2] , %[hi]" "\n\t" 4686 "out %[port] , %[lo]" "\n\t" 4689 "out %[port] , %[hi]" "\n\t" 4690 "mov %[n1] , %[lo]" "\n\t" 4691 "out %[port] , %[n2]" "\n\t" 4693 "sbrc %[byte] , 3" "\n\t" 4694 "mov %[n1] , %[hi]" "\n\t" 4695 "out %[port] , %[lo]" "\n\t" 4698 "out %[port] , %[hi]" "\n\t" 4699 "mov %[n2] , %[lo]" "\n\t" 4700 "out %[port] , %[n1]" "\n\t" 4702 "sbrc %[byte] , 2" "\n\t" 4703 "mov %[n2] , %[hi]" "\n\t" 4704 "out %[port] , %[lo]" "\n\t" 4707 "out %[port] , %[hi]" "\n\t" 4708 "mov %[n1] , %[lo]" "\n\t" 4709 "out %[port] , %[n2]" "\n\t" 4711 "sbrc %[byte] , 1" "\n\t" 4712 "mov %[n1] , %[hi]" "\n\t" 4713 "out %[port] , %[lo]" "\n\t" 4716 "out %[port] , %[hi]" "\n\t" 4717 "mov %[n2] , %[lo]" "\n\t" 4718 "out %[port] , %[n1]" "\n\t" 4720 "sbrc %[byte] , 0" "\n\t" 4721 "mov %[n2] , %[hi]" "\n\t" 4722 "out %[port] , %[lo]" "\n\t" 4723 "sbiw %[count], 1" "\n\t" 4725 "out %[port] , %[hi]" "\n\t" 4726 "mov %[n1] , %[lo]" "\n\t" 4727 "out %[port] , %[n2]" "\n\t" 4728 "ld %[byte] , %a[ptr]+" "\n\t" 4729 "sbrc %[byte] , 7" "\n\t" 4730 "mov %[n1] , %[hi]" "\n\t" 4731 "out %[port] , %[lo]" "\n\t" 4737 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
4742 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4747 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4748 if(
port == &PORTB) {
4749 #endif // defined(PORTD/C/F) 4753 if(b & 0x80) n1 = hi;
4757 "out %[port] , %[hi]" "\n\t" 4758 "mov %[n2] , %[lo]" "\n\t" 4759 "out %[port] , %[n1]" "\n\t" 4761 "sbrc %[byte] , 6" "\n\t" 4762 "mov %[n2] , %[hi]" "\n\t" 4763 "out %[port] , %[lo]" "\n\t" 4765 "out %[port] , %[hi]" "\n\t" 4766 "mov %[n1] , %[lo]" "\n\t" 4767 "out %[port] , %[n2]" "\n\t" 4769 "sbrc %[byte] , 5" "\n\t" 4770 "mov %[n1] , %[hi]" "\n\t" 4771 "out %[port] , %[lo]" "\n\t" 4773 "out %[port] , %[hi]" "\n\t" 4774 "mov %[n2] , %[lo]" "\n\t" 4775 "out %[port] , %[n1]" "\n\t" 4777 "sbrc %[byte] , 4" "\n\t" 4778 "mov %[n2] , %[hi]" "\n\t" 4779 "out %[port] , %[lo]" "\n\t" 4781 "out %[port] , %[hi]" "\n\t" 4782 "mov %[n1] , %[lo]" "\n\t" 4783 "out %[port] , %[n2]" "\n\t" 4785 "sbrc %[byte] , 3" "\n\t" 4786 "mov %[n1] , %[hi]" "\n\t" 4787 "out %[port] , %[lo]" "\n\t" 4789 "out %[port] , %[hi]" "\n\t" 4790 "mov %[n2] , %[lo]" "\n\t" 4791 "out %[port] , %[n1]" "\n\t" 4793 "sbrc %[byte] , 2" "\n\t" 4794 "mov %[n2] , %[hi]" "\n\t" 4795 "out %[port] , %[lo]" "\n\t" 4797 "out %[port] , %[hi]" "\n\t" 4798 "mov %[n1] , %[lo]" "\n\t" 4799 "out %[port] , %[n2]" "\n\t" 4801 "sbrc %[byte] , 1" "\n\t" 4802 "mov %[n1] , %[hi]" "\n\t" 4803 "out %[port] , %[lo]" "\n\t" 4805 "out %[port] , %[hi]" "\n\t" 4806 "mov %[n2] , %[lo]" "\n\t" 4807 "out %[port] , %[n1]" "\n\t" 4809 "sbrc %[byte] , 0" "\n\t" 4810 "mov %[n2] , %[hi]" "\n\t" 4811 "out %[port] , %[lo]" "\n\t" 4812 "sbiw %[count], 1" "\n\t" 4813 "out %[port] , %[hi]" "\n\t" 4814 "mov %[n1] , %[lo]" "\n\t" 4815 "out %[port] , %[n2]" "\n\t" 4816 "ld %[byte] , %a[ptr]+" "\n\t" 4817 "sbrc %[byte] , 7" "\n\t" 4818 "mov %[n1] , %[hi]" "\n\t" 4819 "out %[port] , %[lo]" "\n\t" 4821 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4822 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4825 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4828 #if defined(PORTC) || defined(PORTF) 4834 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4835 if(
port == &PORTC) {
4841 if(b & 0x80) n1 = hi;
4845 "out %[port] , %[hi]" "\n\t" 4846 "mov %[n2] , %[lo]" "\n\t" 4847 "out %[port] , %[n1]" "\n\t" 4849 "sbrc %[byte] , 6" "\n\t" 4850 "mov %[n2] , %[hi]" "\n\t" 4851 "out %[port] , %[lo]" "\n\t" 4853 "out %[port] , %[hi]" "\n\t" 4854 "mov %[n1] , %[lo]" "\n\t" 4855 "out %[port] , %[n2]" "\n\t" 4857 "sbrc %[byte] , 5" "\n\t" 4858 "mov %[n1] , %[hi]" "\n\t" 4859 "out %[port] , %[lo]" "\n\t" 4861 "out %[port] , %[hi]" "\n\t" 4862 "mov %[n2] , %[lo]" "\n\t" 4863 "out %[port] , %[n1]" "\n\t" 4865 "sbrc %[byte] , 4" "\n\t" 4866 "mov %[n2] , %[hi]" "\n\t" 4867 "out %[port] , %[lo]" "\n\t" 4869 "out %[port] , %[hi]" "\n\t" 4870 "mov %[n1] , %[lo]" "\n\t" 4871 "out %[port] , %[n2]" "\n\t" 4873 "sbrc %[byte] , 3" "\n\t" 4874 "mov %[n1] , %[hi]" "\n\t" 4875 "out %[port] , %[lo]" "\n\t" 4877 "out %[port] , %[hi]" "\n\t" 4878 "mov %[n2] , %[lo]" "\n\t" 4879 "out %[port] , %[n1]" "\n\t" 4881 "sbrc %[byte] , 2" "\n\t" 4882 "mov %[n2] , %[hi]" "\n\t" 4883 "out %[port] , %[lo]" "\n\t" 4885 "out %[port] , %[hi]" "\n\t" 4886 "mov %[n1] , %[lo]" "\n\t" 4887 "out %[port] , %[n2]" "\n\t" 4889 "sbrc %[byte] , 1" "\n\t" 4890 "mov %[n1] , %[hi]" "\n\t" 4891 "out %[port] , %[lo]" "\n\t" 4893 "out %[port] , %[hi]" "\n\t" 4894 "mov %[n2] , %[lo]" "\n\t" 4895 "out %[port] , %[n1]" "\n\t" 4897 "sbrc %[byte] , 0" "\n\t" 4898 "mov %[n2] , %[hi]" "\n\t" 4899 "out %[port] , %[lo]" "\n\t" 4900 "sbiw %[count], 1" "\n\t" 4901 "out %[port] , %[hi]" "\n\t" 4902 "mov %[n1] , %[lo]" "\n\t" 4903 "out %[port] , %[n2]" "\n\t" 4904 "ld %[byte] , %a[ptr]+" "\n\t" 4905 "sbrc %[byte] , 7" "\n\t" 4906 "mov %[n1] , %[hi]" "\n\t" 4907 "out %[port] , %[lo]" "\n\t" 4909 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4910 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4913 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4922 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 4923 if(
port == &PORTF) {
4924 #endif // defined(PORTD/B/C) 4929 if(b & 0x80) n1 = hi;
4933 "out %[port] , %[hi]" "\n\t" 4934 "mov %[n2] , %[lo]" "\n\t" 4935 "out %[port] , %[n1]" "\n\t" 4937 "sbrc %[byte] , 6" "\n\t" 4938 "mov %[n2] , %[hi]" "\n\t" 4939 "out %[port] , %[lo]" "\n\t" 4941 "out %[port] , %[hi]" "\n\t" 4942 "mov %[n1] , %[lo]" "\n\t" 4943 "out %[port] , %[n2]" "\n\t" 4945 "sbrc %[byte] , 5" "\n\t" 4946 "mov %[n1] , %[hi]" "\n\t" 4947 "out %[port] , %[lo]" "\n\t" 4949 "out %[port] , %[hi]" "\n\t" 4950 "mov %[n2] , %[lo]" "\n\t" 4951 "out %[port] , %[n1]" "\n\t" 4953 "sbrc %[byte] , 4" "\n\t" 4954 "mov %[n2] , %[hi]" "\n\t" 4955 "out %[port] , %[lo]" "\n\t" 4957 "out %[port] , %[hi]" "\n\t" 4958 "mov %[n1] , %[lo]" "\n\t" 4959 "out %[port] , %[n2]" "\n\t" 4961 "sbrc %[byte] , 3" "\n\t" 4962 "mov %[n1] , %[hi]" "\n\t" 4963 "out %[port] , %[lo]" "\n\t" 4965 "out %[port] , %[hi]" "\n\t" 4966 "mov %[n2] , %[lo]" "\n\t" 4967 "out %[port] , %[n1]" "\n\t" 4969 "sbrc %[byte] , 2" "\n\t" 4970 "mov %[n2] , %[hi]" "\n\t" 4971 "out %[port] , %[lo]" "\n\t" 4973 "out %[port] , %[hi]" "\n\t" 4974 "mov %[n1] , %[lo]" "\n\t" 4975 "out %[port] , %[n2]" "\n\t" 4977 "sbrc %[byte] , 1" "\n\t" 4978 "mov %[n1] , %[hi]" "\n\t" 4979 "out %[port] , %[lo]" "\n\t" 4981 "out %[port] , %[hi]" "\n\t" 4982 "mov %[n2] , %[lo]" "\n\t" 4983 "out %[port] , %[n1]" "\n\t" 4985 "sbrc %[byte] , 0" "\n\t" 4986 "mov %[n2] , %[hi]" "\n\t" 4987 "out %[port] , %[lo]" "\n\t" 4988 "sbiw %[count], 1" "\n\t" 4989 "out %[port] , %[hi]" "\n\t" 4990 "mov %[n1] , %[lo]" "\n\t" 4991 "out %[port] , %[n2]" "\n\t" 4992 "ld %[byte] , %a[ptr]+" "\n\t" 4993 "sbrc %[byte] , 7" "\n\t" 4994 "mov %[n1] , %[hi]" "\n\t" 4995 "out %[port] , %[lo]" "\n\t" 4997 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4998 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5001 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5003 #endif // defined(PORTD/B/C) 5004 #endif // defined(PORTF) 5007 volatile uint8_t next, bit;
5016 "st %a[port], %[hi]" "\n\t" 5017 "sbrc %[byte] , 7" "\n\t" 5018 "mov %[next], %[hi]" "\n\t" 5019 "st %a[port], %[next]" "\n\t" 5020 "mov %[next] , %[lo]" "\n\t" 5022 "breq nextbyte20" "\n\t" 5023 "rol %[byte]" "\n\t" 5024 "st %a[port], %[lo]" "\n\t" 5028 "rjmp head20" "\n\t" 5029 "nextbyte20:" "\n\t" 5030 "st %a[port], %[lo]" "\n\t" 5032 "ldi %[bit] , 8" "\n\t" 5033 "ld %[byte] , %a[ptr]+" "\n\t" 5034 "sbiw %[count], 1" "\n\t" 5045 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 5047 volatile uint8_t next;
5052 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5053 if(
port == &PORTD) {
5059 if(b & 0x80) next = hi;
5062 "out %[port], %[hi]" "\n\t" 5063 "rcall bitTimeD" "\n\t" 5064 "out %[port], %[hi]" "\n\t" 5065 "rcall bitTimeD" "\n\t" 5066 "out %[port], %[hi]" "\n\t" 5067 "rcall bitTimeD" "\n\t" 5068 "out %[port], %[hi]" "\n\t" 5069 "rcall bitTimeD" "\n\t" 5070 "out %[port], %[hi]" "\n\t" 5071 "rcall bitTimeD" "\n\t" 5072 "out %[port], %[hi]" "\n\t" 5073 "rcall bitTimeD" "\n\t" 5074 "out %[port], %[hi]" "\n\t" 5075 "rcall bitTimeD" "\n\t" 5077 "out %[port] , %[hi]" "\n\t" 5079 "ld %[byte] , %a[ptr]+" "\n\t" 5080 "out %[port] , %[next]" "\n\t" 5081 "mov %[next] , %[lo]" "\n\t" 5082 "sbrc %[byte] , 7" "\n\t" 5083 "mov %[next] , %[hi]" "\n\t" 5085 "out %[port] , %[lo]" "\n\t" 5086 "sbiw %[count], 1" "\n\t" 5090 "out %[port], %[next]" "\n\t" 5091 "mov %[next], %[lo]" "\n\t" 5092 "rol %[byte]" "\n\t" 5093 "sbrc %[byte], 7" "\n\t" 5094 "mov %[next], %[hi]" "\n\t" 5096 "out %[port], %[lo]" "\n\t" 5102 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
5107 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5113 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5114 if(
port == &PORTB) {
5120 if(b & 0x80) next = hi;
5124 "out %[port], %[hi]" "\n\t" 5125 "rcall bitTimeB" "\n\t" 5126 "out %[port], %[hi]" "\n\t" 5127 "rcall bitTimeB" "\n\t" 5128 "out %[port], %[hi]" "\n\t" 5129 "rcall bitTimeB" "\n\t" 5130 "out %[port], %[hi]" "\n\t" 5131 "rcall bitTimeB" "\n\t" 5132 "out %[port], %[hi]" "\n\t" 5133 "rcall bitTimeB" "\n\t" 5134 "out %[port], %[hi]" "\n\t" 5135 "rcall bitTimeB" "\n\t" 5136 "out %[port], %[hi]" "\n\t" 5137 "rcall bitTimeB" "\n\t" 5138 "out %[port] , %[hi]" "\n\t" 5140 "ld %[byte] , %a[ptr]+" "\n\t" 5141 "out %[port] , %[next]" "\n\t" 5142 "mov %[next] , %[lo]" "\n\t" 5143 "sbrc %[byte] , 7" "\n\t" 5144 "mov %[next] , %[hi]" "\n\t" 5146 "out %[port] , %[lo]" "\n\t" 5147 "sbiw %[count], 1" "\n\t" 5151 "out %[port], %[next]" "\n\t" 5152 "mov %[next], %[lo]" "\n\t" 5153 "rol %[byte]" "\n\t" 5154 "sbrc %[byte], 7" "\n\t" 5155 "mov %[next], %[hi]" "\n\t" 5157 "out %[port], %[lo]" "\n\t" 5160 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5161 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5164 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5167 #if defined(PORTC) || defined(PORTF) 5173 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5174 if(
port == &PORTC) {
5180 if(b & 0x80) next = hi;
5184 "out %[port], %[hi]" "\n\t" 5185 "rcall bitTimeC" "\n\t" 5186 "out %[port], %[hi]" "\n\t" 5187 "rcall bitTimeC" "\n\t" 5188 "out %[port], %[hi]" "\n\t" 5189 "rcall bitTimeC" "\n\t" 5190 "out %[port], %[hi]" "\n\t" 5191 "rcall bitTimeC" "\n\t" 5192 "out %[port], %[hi]" "\n\t" 5193 "rcall bitTimeC" "\n\t" 5194 "out %[port], %[hi]" "\n\t" 5195 "rcall bitTimeC" "\n\t" 5196 "out %[port], %[hi]" "\n\t" 5197 "rcall bitTimeC" "\n\t" 5198 "out %[port] , %[hi]" "\n\t" 5200 "ld %[byte] , %a[ptr]+" "\n\t" 5201 "out %[port] , %[next]" "\n\t" 5202 "mov %[next] , %[lo]" "\n\t" 5203 "sbrc %[byte] , 7" "\n\t" 5204 "mov %[next] , %[hi]" "\n\t" 5206 "out %[port] , %[lo]" "\n\t" 5207 "sbiw %[count], 1" "\n\t" 5211 "out %[port], %[next]" "\n\t" 5212 "mov %[next], %[lo]" "\n\t" 5213 "rol %[byte]" "\n\t" 5214 "sbrc %[byte], 7" "\n\t" 5215 "mov %[next], %[hi]" "\n\t" 5217 "out %[port], %[lo]" "\n\t" 5220 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5221 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5224 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5233 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5234 if(
port == &PORTF) {
5240 if(b & 0x80) next = hi;
5244 "out %[port], %[hi]" "\n\t" 5245 "rcall bitTimeC" "\n\t" 5246 "out %[port], %[hi]" "\n\t" 5247 "rcall bitTimeC" "\n\t" 5248 "out %[port], %[hi]" "\n\t" 5249 "rcall bitTimeC" "\n\t" 5250 "out %[port], %[hi]" "\n\t" 5251 "rcall bitTimeC" "\n\t" 5252 "out %[port], %[hi]" "\n\t" 5253 "rcall bitTimeC" "\n\t" 5254 "out %[port], %[hi]" "\n\t" 5255 "rcall bitTimeC" "\n\t" 5256 "out %[port], %[hi]" "\n\t" 5257 "rcall bitTimeC" "\n\t" 5258 "out %[port] , %[hi]" "\n\t" 5260 "ld %[byte] , %a[ptr]+" "\n\t" 5261 "out %[port] , %[next]" "\n\t" 5262 "mov %[next] , %[lo]" "\n\t" 5263 "sbrc %[byte] , 7" "\n\t" 5264 "mov %[next] , %[hi]" "\n\t" 5266 "out %[port] , %[lo]" "\n\t" 5267 "sbiw %[count], 1" "\n\t" 5271 "out %[port], %[next]" "\n\t" 5272 "mov %[next], %[lo]" "\n\t" 5273 "rol %[byte]" "\n\t" 5274 "sbrc %[byte], 7" "\n\t" 5275 "mov %[next], %[hi]" "\n\t" 5277 "out %[port], %[lo]" "\n\t" 5280 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5281 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5284 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5289 volatile uint8_t next, bit;
5298 "st %a[port], %[hi]" "\n\t" 5299 "sbrc %[byte] , 7" "\n\t" 5300 "mov %[next], %[hi]" "\n\t" 5302 "st %a[port], %[next]" "\n\t" 5307 "st %a[port], %[lo]" "\n\t" 5310 "breq nextbyte30" "\n\t" 5311 "rol %[byte]" "\n\t" 5315 "rjmp head30" "\n\t" 5316 "nextbyte30:" "\n\t" 5318 "ldi %[bit] , 8" "\n\t" 5319 "ld %[byte] , %a[ptr]+" "\n\t" 5320 "sbiw %[count], 1" "\n\t" 5331 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 5333 volatile uint8_t next, bit;
5342 "st %a[port], %[hi]" "\n\t" 5343 "sbrc %[byte], 7" "\n\t" 5344 "mov %[next], %[hi]" "\n\t" 5346 "st %a[port], %[next]" "\n\t" 5347 "mov %[next] , %[lo]" "\n\t" 5348 "breq nextbyte20" "\n\t" 5349 "rol %[byte]" "\n\t" 5352 "st %a[port], %[lo]" "\n\t" 5355 "rjmp head20" "\n\t" 5356 "nextbyte20:" "\n\t" 5357 "ldi %[bit] , 8" "\n\t" 5358 "ld %[byte] , %a[ptr]+" "\n\t" 5359 "st %a[port], %[lo]" "\n\t" 5361 "sbiw %[count], 1" "\n\t" 5373 volatile uint8_t next, bit;
5382 "st %a[port], %[hi]" "\n\t" 5383 "sbrc %[byte] , 7" "\n\t" 5384 "mov %[next] , %[hi]" "\n\t" 5387 "st %a[port], %[next]" "\n\t" 5393 "st %a[port], %[lo]" "\n\t" 5395 "mov %[next] , %[lo]" "\n\t" 5397 "breq nextbyte40" "\n\t" 5398 "rol %[byte]" "\n\t" 5405 "rjmp head40" "\n\t" 5406 "nextbyte40:" "\n\t" 5407 "ldi %[bit] , 8" "\n\t" 5408 "ld %[byte] , %a[ptr]+" "\n\t" 5410 "st %a[port], %[lo]" "\n\t" 5412 "sbiw %[count], 1" "\n\t" 5424 #error "CPU SPEED NOT SUPPORTED" 5426 #elif defined(__arm__) 5429 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 5430 #define CYCLES_800_T0H (F_CPU / 4000000) 5431 #define CYCLES_800_T1H (F_CPU / 1250000) 5432 #define CYCLES_800 (F_CPU / 800000) 5433 #define CYCLES_400_T0H (F_CPU / 2000000) 5434 #define CYCLES_400_T1H (F_CPU / 833333) 5435 #define CYCLES_400 (F_CPU / 400000) 5439 volatile uint8_t *
set = portSetRegister(
pin),
5440 *clr = portClearRegister(
pin);
5443 ARM_DEMCR |= ARM_DEMCR_TRCENA;
5444 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
5447 cyc = ARM_DWT_CYCCNT + CYCLES_800;
5450 for(mask = 0x80; mask; mask >>= 1) {
5451 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5452 cyc = ARM_DWT_CYCCNT;
5455 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
5457 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
5462 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5464 cyc = ARM_DWT_CYCCNT + CYCLES_400;
5467 for(mask = 0x80; mask; mask >>= 1) {
5468 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5469 cyc = ARM_DWT_CYCCNT;
5472 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
5474 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
5479 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5482 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 5484 #elif defined(ESP8266) || defined(ESP32) 5488 #elif defined(__ARDUINO_ARC__) 5492 #define NOPx7 { __builtin_arc_nop(); \ 5493 __builtin_arc_nop(); __builtin_arc_nop(); \ 5494 __builtin_arc_nop(); __builtin_arc_nop(); \ 5495 __builtin_arc_nop(); __builtin_arc_nop(); } 5497 PinDescription *pindesc = &g_APinDescription[
pin];
5499 register uint8_t *p =
pixels;
5500 register uint32_t currByte = (uint32_t) (*p);
5501 register uint32_t currBit = 0x80 & currByte;
5502 register uint32_t bitCounter = 0;
5503 register uint32_t first = 1;
5505 if (pindesc->ulGPIOType == SS_GPIO) {
5506 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
5507 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
5508 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5509 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5519 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
5526 __builtin_arc_nop();
5529 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
5533 if(bitCounter >= 8) {
5535 currByte = (uint32_t) (*++p);
5538 currBit = 0x80 & currByte;
5541 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
5542 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
5543 uint32_t reg_val = MMIO_REG_VAL(reg);
5544 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5545 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5553 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
5557 __builtin_arc_nop();
5563 MMIO_REG_VAL(reg) = reg_bit_low;
5567 if(bitCounter >= 8) {
5569 currByte = (uint32_t) (*++p);
5572 currBit = 0x80 & currByte;
5578 #error Architecture not supported 5591 digitalWrite(p, LOW);
5594 port = portOutputRegister(digitalPinToPort(p));
5595 pinMask = digitalPinToBitMask(p);
5600 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
5622 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5647 r = (uint8_t)(c >> 16),
5648 g = (uint8_t)(c >> 8),
5659 uint8_t w = (uint8_t)(c >> 24);
5669 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5672 uint32_t
NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5673 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5689 return ((uint32_t)p[
aOffset[0]] << 16) |
5690 ((uint32_t)p[
aOffset[1]] << 8) |
5701 return ((uint32_t)p[
aOffset[3]] << 24) |
5702 ((uint32_t)p[
aOffset[0]] << 16) |
5703 ((uint32_t)p[
aOffset[1]] << 8) |
5720 uint8_t newBrightness = b + 1;
5726 if(oldBrightness == 0) scale = 0;
5727 else if(b == 255) scale = 65535 / oldBrightness;
5728 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
5729 for(uint16_t i=0; i<
numBytes; i++) {
5731 *ptr++ = (c * scale) >> 8;
6187 #if EBOARD_NANO > 0x0 || defined(DOC) 6189 #if EBOARD_GUESSPATH > 0x0 6194 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
6195 #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 6196 #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 6197 #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 6198 #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 6200 #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 6201 #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 6203 #define INVALID_SERVO 255 // flag indicating an invalid servo index 6206 uint8_t isActive :1 ;
6211 volatile unsigned int ticks;
6217 uint8_t attach(
int pin);
6218 uint8_t attach(
int pin,
int min,
int max);
6220 void write(
int value);
6221 void writeMicroseconds(
int value);
6223 int readMicroseconds();
6224 inline bool attached();
6230 #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 6231 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds 6234 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 6238 static servo_t servos[MAX_SERVOS];
6239 static volatile int8_t Channel[_Nbr_16timers ];
6241 uint8_t ServoCount = 0;
6244 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo 6245 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer 6246 #define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel 6247 #define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel 6249 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo 6250 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo 6252 static inline void handle_interrupts(timer16_Sequence_t timer,
volatile uint16_t *TCNTn,
volatile uint16_t* OCRnA)
6254 if( Channel[timer] < 0 )
6257 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive ==
true )
6258 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW);
6262 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
6263 *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
6264 if(SERVO(timer,Channel[timer]).Pin.isActive ==
true)
6265 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH);
6269 if( ((
unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )
6270 *OCRnA = (
unsigned int)usToTicks(REFRESH_INTERVAL);
6272 *OCRnA = *TCNTn + 4;
6273 Channel[timer] = -1;
6277 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform 6279 #if defined(_useTimer1) 6280 SIGNAL (TIMER1_COMPA_vect)
6282 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6285 #elif defined WIRING 6287 #if defined(_useTimer1) 6288 void Timer1Service()
6290 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6295 static void initISR(timer16_Sequence_t timer) {
6296 if(timer == _timer1) {
6300 TIFR1 |= _BV(OCF1A);
6301 TIMSK1 |= _BV(OCIE1A) ;
6303 timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
6308 static void finISR(timer16_Sequence_t timer) {
6309 #if defined WIRING // Wiring 6310 if(timer == _timer1) {
6311 TIMSK &= ~_BV(OCIE1A) ;
6312 timerDetach(TIMER1OUTCOMPAREA_INT);
6314 else if(timer == _timer3) {
6315 ETIMSK &= ~_BV(OCIE3A);
6316 timerDetach(TIMER3OUTCOMPAREA_INT);
6324 static boolean isTimerActive(timer16_Sequence_t timer) {
6326 for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
6327 if(SERVO(timer,channel).Pin.isActive ==
true)
6334 if( ServoCount < MAX_SERVOS) {
6335 this->servoIndex = ServoCount++;
6336 servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);
6339 this->servoIndex = INVALID_SERVO ;
6342 uint8_t Servo::attach(
int pin) {
6343 return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
6346 uint8_t Servo::attach(
int pin,
int min,
int max) {
6347 if(this->servoIndex < MAX_SERVOS ) {
6348 pinMode( pin, OUTPUT) ;
6349 servos[this->servoIndex].Pin.nbr = pin;
6351 this->min = (MIN_PULSE_WIDTH - min)/4;
6352 this->max = (MAX_PULSE_WIDTH - max)/4;
6354 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6355 if(isTimerActive(timer) ==
false)
6357 servos[this->servoIndex].Pin.isActive =
true;
6359 return this->servoIndex ;
6362 void Servo::detach() {
6363 servos[this->servoIndex].Pin.isActive =
false;
6364 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6365 if(isTimerActive(timer) ==
false) {
6370 void Servo::write(
int value) {
6371 if(value < MIN_PULSE_WIDTH)
6373 if(value < 0) value = 0;
6374 if(value > 180) value = 180;
6375 value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
6377 this->writeMicroseconds(value);
6380 void Servo::writeMicroseconds(
int value) {
6382 byte channel = this->servoIndex;
6383 if( (channel < MAX_SERVOS) )
6385 if( value < SERVO_MIN() )
6386 value = SERVO_MIN();
6387 else if( value > SERVO_MAX() )
6388 value = SERVO_MAX();
6390 value = value - TRIM_DURATION;
6391 value = usToTicks(value);
6393 uint8_t oldSREG = SREG;
6395 servos[channel].ticks = value;
6400 inline int Servo::read()
6402 return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
6405 int Servo::readMicroseconds() {
6406 unsigned int pulsewidth;
6407 if( this->servoIndex != INVALID_SERVO )
6408 pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ;
6415 inline bool Servo::attached() {
6416 return servos[this->servoIndex].Pin.isActive ;
6422 #if EBOARD_COPY_AND_PASTE > 0x0 6432 #if EBOARD_NANO > 0x0 6433 Servo mainMotor,steerMotor;
6445 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
6459 #if EBOARD_NANO == 0x0 6463 #if EBOARD_DEBUG_MODE > 0x0 6467 #if (EBOARD_NANO == 0x0) || defined(REPT_TASK) 6469 TIMSK2 &= ~(1<<TOIE2);
6470 TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
6471 TCCR2B &= ~(1<<WGM22);
6473 TIMSK2 &= ~(1<<OCIE2A);
6474 TCCR2B |= (1<<CS22);
6475 TCCR2B &= ~((1<<CS21) | (1<<CS20));
6476 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
6477 TIMSK2 |= (1<<TOIE2);
6480 #if EBOARD_BLUETOOTH > 0x0 6481 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 6484 Serial1.begin(38400);
6490 #if EBOARD_I2C > 0x0 6493 #if EBOARD_SHIFT_REGISTER > 0x0 6499 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0) 6502 #if EBOARD_NANO > 0x0 6505 #if EBOARD_DEBUG_MODE > 0x0 6506 Serial.println(
"Initializing main driving motor (3s)");
6508 mainMotor.write(90);
6510 #if EBOARD_DEBUG_MODE > 0x0 6511 Serial.println(
"Initializing of main driving motor completed");
6514 #if EBOARD_DEBUG_MODE > 0x0 6516 Serial.println(
"fin");
6522 #if EBOARD_NANO > 0x0 6523 mainMotor.write(90);
6526 #if EBOARD_NANO == 0x0 6541 #if EBOARD_NANO > 0x0 || defined(DOC) 6557 if(spe < 0 || spe > 180)
return;
6558 mainMotor.write(spe);
6561 if(ang < 0 || ang > 180)
return;
6562 steerMotor.write(ang);
6568 #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process 6570 #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
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 ;)
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 hardwareID of this AX-12 Servo and will continue speaking to the new [reconnection recomme...
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...