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.1.5m" 16 #define EBOARD_VERSION_NBR 315 18 #define VALUE_TO_STRING(x) #x 22 #define PREPROCESS_DEBUG 1 25 #define VALUE(x) VALUE_TO_STRING(x) 27 #ifndef PREPROCESS_DEBUG 29 #define PREPROCESS_DEBUG 0 31 #define PPERFORM_PRAGMA(str) _Pragma(#str) 33 #if PREPROCESS_DEBUG == 1 34 #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str)) 36 #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str)) 38 #define DEBUG_MSG(str) ; 39 #define MACRO_MSG(mac,str) ; 41 DEBUG_MSG(
"If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
43 DEBUG_MSG(
"You are using eBoard-header v3.1m written by EagleoutIce");
510 DEBUG_MSG(
"Documentation macro SET => Full doc features enabled");
515 #define EBOARD_I2C 0x1 520 #define EBOARD_LCD 0x1 524 #define EBOARD_SHIFT_REGISTER 0x1 528 #define EBOARD_BLUETOOTH 0x1 536 #define __AVR_ATmega2560__ 540 #define __AVR_ATmega328P__ 544 #define EBOARD_NEO 0x1 562 return int((__builtin_sin((val/128.0*PI))+1)*127.5+0.5);
570 return int(pow((val)/255.0,2.6)*255.0+0.5);
573 #include <avr/pgmspace.h> 580 #ifndef EBOARD_GUESSPATH 581 DEBUG_MSG(
"You are using Guesspath! Necessary libraries for eBoard will be included automatically");
585 #define EBOARD_GUESSPATH 0x1 587 DEBUG_MSG(
"You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
590 #if defined(ARDUINO) //general platform-check [No tab] 595 #define main eVirtual_main //main has a different meaning^^ 597 #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D 603 #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__)) 604 #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!" 607 #if defined(__AVR_ATmega2560__) 608 DEBUG_MSG(
"Building for Arduino Mega with ATmega2560");
612 #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS 614 DEBUG_MSG(
"Building for Arduino Uno or Nano with ATmega328P");
615 #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS 619 #include <avr/interrupt.h> 621 #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0 622 DEBUG_MSG(
"You enabled I²C featurea");
630 #define TWI_FREQ 100000L 633 # ifndef TWI_BUFFER_LENGTH 634 #define TWI_BUFFER_LENGTH 32 645 #include <avr/interrupt.h> 646 #include <compat/twi.h> 649 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 653 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 656 #include "pins_arduino.h" 658 static volatile uint8_t twi_state;
659 static volatile uint8_t twi_slarw;
660 static volatile uint8_t twi_sendStop;
661 static volatile uint8_t twi_inRepStart;
663 static void (*twi_onSlaveTransmit)(void);
664 static void (*twi_onSlaveReceive)(uint8_t*, int);
666 static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
667 static volatile uint8_t twi_masterBufferIndex;
668 static volatile uint8_t twi_masterBufferLength;
670 static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
671 static volatile uint8_t twi_txBufferIndex;
672 static volatile uint8_t twi_txBufferLength;
674 static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
675 static volatile uint8_t twi_rxBufferIndex;
677 static volatile uint8_t twi_error;
679 void twi_init(
void) {
680 twi_state = TWI_READY;
682 twi_inRepStart =
false;
684 digitalWrite(SDA, 1);
685 digitalWrite(SCL, 1);
689 TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
691 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
694 inline void twi_setAddress(uint8_t address) {
698 uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) {
701 if(TWI_BUFFER_LENGTH < length)
return 0;
703 while(TWI_READY != twi_state)
continue;
706 twi_sendStop = sendStop;
710 twi_masterBufferIndex = 0;
711 twi_masterBufferLength = length-1;
713 twi_slarw |= address << 1;
715 if (
true == twi_inRepStart) {
716 twi_inRepStart =
false;
718 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
721 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
723 while(TWI_MRX == twi_state)
continue;
725 if (twi_masterBufferIndex < length)
726 length = twi_masterBufferIndex;
728 for(i = 0; i < length; ++i) data[i] = twi_masterBuffer[i];
733 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) {
736 if(TWI_BUFFER_LENGTH < length)
return 1;
738 while(TWI_READY != twi_state)
continue;
741 twi_sendStop = sendStop;
744 twi_masterBufferIndex = 0;
745 twi_masterBufferLength = length;
747 for(i = 0; i < length; ++i) twi_masterBuffer[i] = data[i];
749 twi_slarw = TW_WRITE;
750 twi_slarw |= address << 1;
752 if (
true == twi_inRepStart) {
753 twi_inRepStart =
false;
755 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
758 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
760 while(wait && (TWI_MTX == twi_state))
continue;
762 if (twi_error == 0xFF)
return 0;
763 else if (twi_error == TW_MT_SLA_NACK)
return 2;
764 else if (twi_error == TW_MT_DATA_NACK)
return 3;
768 uint8_t twi_transmit(
const uint8_t* data, uint8_t length) {
771 if(TWI_BUFFER_LENGTH < length)
return 1;
773 if(TWI_STX != twi_state)
return 2;
775 twi_txBufferLength = length;
776 for(i = 0; i < length; ++i) twi_txBuffer[i] = data[i];
781 void twi_attachSlaveRxEvent(
void (*
function)(uint8_t*,
int) ) {
782 twi_onSlaveReceive =
function;
785 void twi_attachSlaveTxEvent(
void (*
function)(
void) ) {
786 twi_onSlaveTransmit =
function;
789 void twi_reply(uint8_t ack) {
791 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
793 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
798 void twi_stop(
void) {
799 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
801 while(TWCR & _BV(TWSTO))
continue;
803 twi_state = TWI_READY;
806 void twi_releaseBus(
void){
807 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
808 twi_state = TWI_READY;
821 if(twi_masterBufferIndex < twi_masterBufferLength){
822 TWDR = twi_masterBuffer[twi_masterBufferIndex++];
825 if (twi_sendStop) twi_stop();
827 twi_inRepStart =
true;
828 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
829 twi_state = TWI_READY;
834 twi_error = TW_MT_SLA_NACK;
837 case TW_MT_DATA_NACK:
838 twi_error = TW_MT_DATA_NACK;
842 twi_error = TW_MT_ARB_LOST;
846 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
848 if(twi_masterBufferIndex < twi_masterBufferLength) twi_reply(1);
851 case TW_MR_DATA_NACK:
852 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
853 if (twi_sendStop) twi_stop();
855 twi_inRepStart =
true;
856 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
857 twi_state = TWI_READY;
864 case TW_SR_GCALL_ACK:
865 case TW_SR_ARB_LOST_SLA_ACK:
866 case TW_SR_ARB_LOST_GCALL_ACK:
868 twi_rxBufferIndex = 0;
872 case TW_SR_GCALL_DATA_ACK:
873 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
874 twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
880 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH) twi_rxBuffer[twi_rxBufferIndex] =
'\0';
882 twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
883 twi_rxBufferIndex = 0;
886 case TW_SR_DATA_NACK:
887 case TW_SR_GCALL_DATA_NACK:
891 case TW_ST_ARB_LOST_SLA_ACK:
893 twi_txBufferIndex = 0;
894 twi_txBufferLength = 0;
895 twi_onSlaveTransmit();
896 if(0 == twi_txBufferLength){
897 twi_txBufferLength = 1;
898 twi_txBuffer[0] = 0x00;
901 TWDR = twi_txBuffer[twi_txBufferIndex++];
902 if(twi_txBufferIndex < twi_txBufferLength) twi_reply(1);
905 case TW_ST_DATA_NACK:
906 case TW_ST_LAST_DATA:
908 twi_state = TWI_READY;
914 twi_error = TW_BUS_ERROR;
925 #include <inttypes.h> 928 #define BUFFER_LENGTH 32 991 void begin(uint8_t address);
997 inline void begin(
int address);
1038 inline uint8_t
requestFrom(uint8_t address, uint8_t quantity);
1046 uint8_t
requestFrom(uint8_t address , uint8_t quantity, uint8_t sendStop);
1054 inline uint8_t
requestFrom(
int address,
int quantity);
1063 inline uint8_t
requestFrom(
int address,
int quantity,
int sendStop);
1072 virtual size_t write(uint8_t data);
1080 virtual size_t write(
const uint8_t *data,
size_t quantity);
1091 virtual int read(
void);
1097 virtual int peek(
void);
1104 void onReceive(
void (*
function)(
int) );
1111 void onRequest(
void (*
function)(
void) );
1125 #include <inttypes.h> 1156 twi_setAddress(address);
1163 begin((uint8_t)address);
1170 uint8_t
read = twi_readFrom(address,
rxBuffer, quantity, sendStop);
1178 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1182 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
1186 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
1222 twi_transmit(&data, 1);
1229 for(
size_t i = 0; i < quantity; ++i) {
1233 twi_transmit(data, quantity);
1272 for(uint8_t i = 0; i < numBytes; ++i) {
1306 DEBUG_MSG(
"You disabled I²C");
1311 #ifndef EBOARD_USE_SPI 1312 #define EBOARD_USE_SPI 0x1 1314 #if EBOARD_USE_SPI > 0x0 1315 DEBUG_MSG(
"You enabled SPI");
1316 #ifndef _SPI_H_INCLUDED 1317 #define _SPI_H_INCLUDED 1322 #define SPI_CLOCK_DIV4 0x00 1323 #define SPI_CLOCK_DIV16 0x01 1325 #define SPI_CLOCK_DIV64 0x02 1327 #define SPI_CLOCK_DIV128 0x03 1329 #define SPI_CLOCK_DIV2 0x04 1331 #define SPI_CLOCK_DIV8 0x05 1333 #define SPI_CLOCK_DIV32 0x06 1337 #define SPI_MODE0 0x00 1338 #define SPI_MODE1 0x04 1340 #define SPI_MODE2 0x08 1342 #define SPI_MODE3 0x0C 1346 #define SPI_MODE_MASK 0x0C 1347 #define SPI_CLOCK_MASK 0x03 1349 #define SPI_2XCLOCK_MASK 0x01 1371 inline static byte
transfer(byte _data);
1383 static void begin(
void);
1387 inline static void end(
void);
1408 while (!(SPSR & _BV(SPIF)));
1417 digitalWrite(SS, HIGH);
1418 pinMode(SS, OUTPUT);
1421 pinMode(SCK, OUTPUT);
1422 pinMode(MOSI, OUTPUT);
1428 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
1429 else SPCR &= ~(_BV(DORD));
1443 DEBUG_MSG(
"You disabled SPI");
1446 #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0) 1447 #include <avr/pgmspace.h> 1448 DEBUG_MSG(
"You enabled LCD");
1462 DEBUG_MSG(
"You defined IGNORE_SIZE: byte will be used");
1465 DEBUG_MSG(
"You did not define IGNORE_SIZE: int will be used");
1472 #ifndef EBOARD_DEBUG_MODE 1473 #define EBOARD_DEBUG_MODE 0x1 1476 #if EBOARD_DEBUG_MODE > 0x0 1487 #define EBOARD_NANO 0x0 1490 #if EBOARD_NANO > 0x0 || defined(DOC) 1491 #ifndef EBOARD_NANO_STEER 1495 #define EBOARD_NANO_STEER 12 1497 #ifndef EBOARD_NANO_MAIN 1501 #define EBOARD_NANO_MAIN 13 1503 MACRO_MSG(
EBOARD_NANO,
"Using Arduino NANO environment [e.g. remove SoccerBoard]");
1504 #if PREPROCESS_DEBUG > 0x1 1505 #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR") 1506 #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR") 1509 MACRO_MSG(
EBOARD_NANO,
"Using Arduino UNO/MEGA environment");
1515 #ifndef EBOARD_CHECK_PINS 1516 #define EBOARD_CHECK_PINS 0x1 1519 #if EBOARD_CHECK_PINS > 0x0 1525 #ifndef EBOARD_SHIFT_REGISTER 1529 #define EBOARD_SHIFT_REGISTER 0x0 1532 #if EBOARD_SHIFT_REGISTER > 0x0 1541 #ifndef EBOARD_CHECK_PINS_PWM 1542 #define EBOARD_CHECK_PINS_PWM 0x1 1545 #if EBOARD_CHECK_PINS_PWM > 0x0 1554 #ifndef EBOARD_DEBUG_SPEED 1555 #define EBOARD_DEBUG_SPEED 9600 1557 #if PREPROCESS_DEBUG > 0x0 1558 #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED)) 1565 #ifndef EBOARD_SPI_SERVO_MAX 1566 #define EBOARD_SPI_SERVO_MAX 2 1568 #if PREPROCESS_DEBUG > 0x0 1569 #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX)) 1574 #ifndef EBOARD_USE_UTILITY 1575 #define EBOARD_USE_UTILITY 0x1 1577 #if EBOARD_USE_UTILITY > 0x0 1586 #define EBOARD_COPY_AND_PASTE 0x1 1590 #ifndef EBOARD_PWM_SPE 1591 #define EBOARD_PWM_SPE 1 1593 #if PREPROCESS_DEBUG > 0x0 1594 #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s") 1601 #define EBOARD_I2C 0x0 //disabled by default 1604 #ifndef EBOARD_BLUETOOTH 1608 #define EBOARD_BLUETOOTH 0x0 1611 #if EBOARD_BLUETOOTH > 0x0 1620 #ifndef EBOARD_CLAMP 1621 #define EBOARD_CLAMP 0x1 1623 #if EBOARD_CLAMP > 0x0 1624 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [0;1023]");
1626 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [-300;300]");
1633 #define EBOARD_NEO 0x0 1635 #if EBOARD_NEO > 0x0 1636 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support enabled");
1638 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support disabled");
1644 #ifndef EBOARD_USE_RESET 1645 #define EBOARD_USE_RESET 0x1 1648 #if EBOARD_USE_RESET > 0x0 1649 #include <avr/wdt.h> 1658 #ifndef PIN_BLUETOOTH_STATE 1659 #if defined(__AVR_ATmega2560__) 1660 #define PIN_BLUETOOTH_STATE 0x13 // 19 1662 #define PIN_BLUETOOTH_STATE 0x2 1669 #ifndef PIN_BLUETOOTH_RX 1670 #if defined(__AVR_ATmega2560__) 1671 #define PIN_BLUETOOTH_RX 0x13 // 19 1673 #define PIN_BLUETOOTH_RX 0x2 1680 #ifndef PIN_BLUETOOTH_TX 1681 #if defined(__AVR_ATmega2560__) 1682 #define PIN_BLUETOOTH_TX 0x12 // 18 1684 #define PIN_BLUETOOTH_TX 0x3 1691 #ifndef PIN_MOTOR_DIR 1692 #define PIN_MOTOR_DIR 0x4 1698 #ifndef PIN_MOTOR_SPE 1699 #define PIN_MOTOR_SPE 0x5 1705 #ifndef PIN_SHIFT_CLK 1706 #define PIN_SHIFT_CLK 0x6 1711 #ifndef PIN_SHIFT_DAT 1712 #define PIN_SHIFT_DAT 0x7 1717 #ifndef PIN_SHIFT_LAT 1718 #define PIN_SHIFT_LAT 0x8 1731 #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__) 1732 #if EBOARD_GUESSPATH > 0x0 1733 #ifndef SoftwareSerial_h 1735 #define SoftwareSerial_h 1736 #define _SS_MAX_RX_BUFF 64 // RX buffer size 1738 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 1813 void setTX(uint8_t transmitPin);
1818 void setRX(uint8_t receivePin);
1823 static inline void tunedDelay(uint16_t delay);
1833 SoftwareSerial(uint8_t receivePin, uint8_t transmitPin,
bool inverse_logic =
false);
1855 void begin(
long speed);
1862 inline void end(
void);
1884 virtual size_t write(uint8_t byte);
1889 virtual int read(
void);
1898 virtual void flush(
void);
1925 #if EBOARD_DEBUG_MODE > 0x0 1927 #define _DEBUG_PIN1 11 1928 #define _DEBUG_PIN2 13 1930 typedef struct _DELAY_TABLE {
1932 unsigned short rx_delay_centering;
1933 unsigned short rx_delay_intrabit;
1934 unsigned short rx_delay_stopbit;
1935 unsigned short tx_delay;
1937 #if F_CPU == 16000000 1939 static const DELAY_TABLE PROGMEM table[] = {
1941 { 115200, 1, 17, 17, 12, },
1942 { 57600, 10, 37, 37, 33, },
1943 { 38400, 25, 57, 57, 54, },
1944 { 31250, 31, 70, 70, 68, },
1945 { 28800, 34, 77, 77, 74, },
1946 { 19200, 54, 117, 117, 114, },
1947 { 14400, 74, 156, 156, 153, },
1948 { 9600, 114, 236, 236, 233, },
1949 { 4800, 233, 474, 474, 471, },
1950 { 2400, 471, 950, 950, 947, },
1951 { 1200, 947, 1902, 1902, 1899, },
1952 { 600, 1902, 3804, 3804, 3800, },
1953 { 300, 3804, 7617, 7617, 7614, },
1956 const int XMIT_START_ADJUSTMENT = 5;
1958 #elif F_CPU == 8000000 1960 static const DELAY_TABLE table[] PROGMEM = {
1962 { 115200, 1, 5, 5, 3, },
1963 { 57600, 1, 15, 15, 13, },
1964 { 38400, 2, 25, 26, 23, },
1965 { 31250, 7, 32, 33, 29, },
1966 { 28800, 11, 35, 35, 32, },
1967 { 19200, 20, 55, 55, 52, },
1968 { 14400, 30, 75, 75, 72, },
1969 { 9600, 50, 114, 114, 112, },
1970 { 4800, 110, 233, 233, 230, },
1971 { 2400, 229, 472, 472, 469, },
1972 { 1200, 467, 948, 948, 945, },
1973 { 600, 948, 1895, 1895, 1890, },
1974 { 300, 1895, 3805, 3805, 3802, },
1977 const int XMIT_START_ADJUSTMENT = 4;
1979 #elif F_CPU == 20000000 1981 static const DELAY_TABLE PROGMEM table[] = {
1983 { 115200, 3, 21, 21, 18, },
1984 { 57600, 20, 43, 43, 41, },
1985 { 38400, 37, 73, 73, 70, },
1986 { 31250, 45, 89, 89, 88, },
1987 { 28800, 46, 98, 98, 95, },
1988 { 19200, 71, 148, 148, 145, },
1989 { 14400, 96, 197, 197, 194, },
1990 { 9600, 146, 297, 297, 294, },
1991 { 4800, 296, 595, 595, 592, },
1992 { 2400, 592, 1189, 1189, 1186, },
1993 { 1200, 1187, 2379, 2379, 2376, },
1994 { 600, 2379, 4759, 4759, 4755, },
1995 { 300, 4759, 9523, 9523, 9520, },
1998 const int XMIT_START_ADJUSTMENT = 6;
2001 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors 2008 #if EBOARD_DEBUG_MODE > 0x0 2009 inline void DebugPulse(uint8_t pin, uint8_t count) {
2011 volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
2013 uint8_t val = *pport;
2016 *pport = val | digitalPinToBitMask(pin);
2025 asm volatile(
"sbiw %0, 0x01 \n\t" 2027 "cpi %A0, 0xFF \n\t" 2030 :
"+r" (delay),
"+a" (tmp)
2039 uint8_t oldSREG = SREG;
2052 #if GCC_VERSION < 40302 2070 #if EBOARD_DEBUG_MODE > 0x0 2071 DebugPulse(_DEBUG_PIN2, 1);
2074 for (uint8_t i=0x1; i; i <<= 1)
2077 #if EBOARD_DEBUG_MODE > 0x0 2078 DebugPulse(_DEBUG_PIN2, 1);
2089 #if EBOARD_DEBUG_MODE > 0x0 2090 DebugPulse(_DEBUG_PIN2, 1);
2100 #if EBOARD_DEBUG_MODE > 0x0 2101 #if _DEBUG // for scope: pulse pin as overflow indictator 2102 DebugPulse(_DEBUG_PIN1, 1);
2109 #if GCC_VERSION < 40302 2124 if (pin_state == LOW)
2140 #if defined(PCINT0_vect) 2146 #if defined(PCINT1_vect) 2152 #if defined(PCINT2_vect) 2158 #if defined(PCINT3_vect) 2165 _rx_delay_centering(0),
2166 _rx_delay_intrabit(0),
2167 _rx_delay_stopbit(0),
2169 _buffer_overflow(false),
2170 _inverse_logic(inverse_logic) {
2180 pinMode(tx, OUTPUT);
2181 digitalWrite(tx, HIGH);
2183 uint8_t port = digitalPinToPort(tx);
2190 digitalWrite(rx, HIGH);
2193 uint8_t port = digitalPinToPort(rx);
2200 for (
unsigned i=0; i<
sizeof(table)/
sizeof(table[0]); ++i) {
2201 long baud = pgm_read_dword(&table[i].baud);
2202 if (baud == speed) {
2206 _tx_delay = pgm_read_word(&table[i].tx_delay);
2220 pinMode(_DEBUG_PIN1, OUTPUT);
2221 pinMode(_DEBUG_PIN2, OUTPUT);
2258 uint8_t oldSREG = SREG;
2265 for (byte mask = 0x01; mask; mask <<= 1) {
2277 for (byte mask = 0x01; mask; mask <<= 1) {
2298 uint8_t oldSREG = SREG;
2324 #if EBOARD_DEBUG_MODE > 0x0 2328 #define __ASSERT_USE_STDERR 2347 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp);
2349 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp){
2350 Serial.print(
"Error with: "); Serial.print(__func);
2351 Serial.print(
" in "); Serial.print(__file);
2352 Serial.print(
" >>");
2353 Serial.println(__sexp);
2354 if(strcmp(__func,
"checkIdx")==0){
2355 Serial.println(
" This happens if an out of bounds exception");
2356 Serial.println(
" has occured. Following pins shouldn't be used:");
2359 Serial.println(
" : Used for Bluetooth communication");
2360 Serial.print(
" D");Serial.print(
PIN_MOTOR_DIR);Serial.print(
"&");
2362 Serial.println(
" : Used for main motor control");
2363 #if EBOARD_USE_SPI > 0x0 2364 Serial.print(
" D10-13");
2365 Serial.println(
": Used for smart-servo-shield");
2367 }
else if (strcmp(__func,
"readPin")==0){
2368 Serial.println(
"You've tried to access an analogPin that isn't present on the board you're currently working on!");
2385 #if EBOARD_DEBUG_MODE > 0x0 2386 assert(idx>=0x0 && idx <
PIN_MAX);
2392 #if EBOARD_COPY_AND_PASTE > 0x0 2393 #if EBOARD_CHECK_PINS_PWM > 0x0 2404 for (count = 0; x; count++)
2411 #if EBOARD_CHECK_PINS > 0x0 2417 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2419 #elif defined(__AVR_ATmega2560__) 2425 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 2427 #elif defined(__AVR_ATmega2560__) 2444 return (mode == OUTPUT)? ((
pin_out & (1<<idx))>0x0):((
pin_in & (1<<idx))>0x0);
2457 #if EBOARD_CHECK_PINS > 0x0 2473 #if EBOARD_BLUETOOTH > 0x0 2482 inline char readVal(
char oF =
'.');
2495 template <
typename T>
2496 inline void writeVal(
const T& val);
2512 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2518 inline char readVal(
char oF) {
2519 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2520 return ((Serial1.available())?(Serial1.read()):(oF));
2525 template<
typename T>
2526 inline void writeVal(
const T& val){
2527 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 2534 #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE 2543 #if EBOARD_SHIFT_REGISTER > 0x0 2591 val = min(val,0xFF); val = max(0x0,val);
2596 extern void rept_task(
void);
2597 DEBUG_MSG(
"You defined REPT_TASK: you have to define rept_task(void)!");
2599 DEBUG_MSG(
"You did not define REPT_TASK: rept_task(void) will not have any effect");
2616 #if EBOARD_SHIFT_REGISTER > 0x0 2623 #if EBOARD_CHECK_PINS > 0x0 2627 #if EBOARD_COPY_AND_PASTE > 0x0 2630 pinMode(idx,OUTPUT);
2632 digitalWrite(idx,val);
2648 #if EBOARD_CHECK_PINS > 0x0 2650 #if defined (__AVR_ATmega2560__) 2651 else if (idx<0||idx>0xF){
2653 else if (idx<0||idx>0x7){
2655 #if EBOARD_DEBUG_MODE > 0x0 2662 #if EBOARD_COPY_AND_PASTE > 0x0 2667 return((dig)? digitalRead(idx) : analogRead(idx));
2671 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0) 2677 #if defined(__AVR_ATmega2560__) 2678 ServoCds55(
int CS=53);
2680 ServoCds55(
int CS=10);
2683 void WritePos(
int ID,
int Pos);
2684 void write(
int ID,
int Pos);
2685 inline void setVelocity(
int velocity);
2686 inline void setPoslimit(
int posLimit);
2687 void SetServoLimit(
int ID,
int upperLimit);
2688 void SetMotormode(
int ID,
int velocity);
2689 void SetID(
int ID,
int newID);
2691 byte sendWait (
const byte what);
2694 int upperLimit_temp;
2697 ServoCds55::ServoCds55 (
int CS):cs(CS) {
2698 velocity_temp = 150;
2699 upperLimit_temp = 300;
2702 void ServoCds55::begin() {
2704 digitalWrite(cs,HIGH);
2709 byte ServoCds55::sendWait (
const byte what) {
2711 delayMicroseconds (20);
2715 void ServoCds55::setVelocity(
int velocity){
2716 velocity_temp = velocity;
2719 void ServoCds55::setPoslimit(
int posLimit){
2720 upperLimit_temp = posLimit;
2723 void ServoCds55::write(
int ID,
int Pos){
2724 SetServoLimit(ID,upperLimit_temp);
2729 void ServoCds55::WritePos(
int ID,
int Pos){
2730 int PosB = (Pos>>8 & 0xff);
2731 int PosS = (Pos & 0xff);
2732 int velocityB = (velocity_temp>>8 & 0xff);
2733 int velocityS = (velocity_temp & 0xff);
2734 digitalWrite(cs, LOW);
2735 sendWait (
'p'); sendWait (ID);
2736 sendWait (PosB); sendWait (PosS);
2737 sendWait (velocityB); sendWait (velocityS);
2738 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2739 digitalWrite(cs, HIGH);
2743 void ServoCds55::SetServoLimit(
int ID,
int upperLimit_temp){
2744 int upperLimitB = (upperLimit_temp>>8 & 0xff);
2745 int upperLimitS = (upperLimit_temp & 0xff);
2746 digitalWrite(cs, LOW);
2747 sendWait (
's'); sendWait (ID);
2748 sendWait (upperLimitB); sendWait (upperLimitS);
2749 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2750 digitalWrite(cs, HIGH);
2754 void ServoCds55::SetMotormode(
int ID,
int velocity){
2755 int velocityB = (velocity>>8 & 0xff);
2756 int velocityS = (velocity & 0xff);
2757 digitalWrite(cs, LOW);
2758 sendWait (
'm'); sendWait (ID);
2759 sendWait (velocityB); sendWait (velocityS);
2760 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2761 digitalWrite(cs, HIGH);
2765 void ServoCds55::SetID(
int ID,
int newID){
2766 digitalWrite(cs, LOW);
2767 sendWait (
'i'); sendWait (ID);
2769 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2770 digitalWrite(cs, HIGH);
2774 void ServoCds55::Reset(
int ID){
2775 digitalWrite(cs, LOW);
2776 sendWait (
'r'); sendWait (ID);
2777 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
2778 digitalWrite(cs, HIGH);
2787 #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0 2820 #if EBOARD_USE_UTILITY > 0x0 or defined(__AVR_ATmega2560__) //won't shrink space... just speed things up 2829 inline void led(
int idx,
bool state);
2837 inline void ledOn(
int idx);
2845 inline void ledOff(
int idx);
2860 #if EBOARD_USE_UTILITY > 0x0 2876 inline void motor(uint8_t
id,int16_t val);
2919 inline void sleep(uint16_t t);
2925 inline void msleep(uint16_t t);
2943 inline void reset(
void);
2948 #if defined(__AVR_ATmega2560__) 2954 #elif EBOARD_USE_UTILITY > 0x0 2962 #if EBOARD_USE_UTILITY > 0x0 2969 else if(
id>0&&
id<3&&(val>-0 && val < 1024)) {
_servoHandler.write((
id-1),(val *600/1023 - 300));}
2974 #if EBOARD_USE_RESET > 0x0 2975 wdt_enable(WDTO_15MS);
2991 #define DIGITAL_IN 0x0 2992 #define DIGITAL_IN_INV 0x1 2994 #define DIGITAL_IN_PULLUP 0x2 2996 #define DIGITAL_IN_PULLUP_INV 0x3 2998 #define DIGITAL_OUT 0x4 3000 #define DIGITAL_OUT_INV 0x5 3002 #define DIGITAL_OUT_LOW 0x6 3004 #define DIGITAL_OUT_HIGH 0x7 3006 #define ANALOG_IN_8_BIT 0x8 3008 #define ANALOG_IN_10_BIT 0x9 3010 #define ANALOG_IN_MEAN_8_BIT 0xA 3012 #define ANALOG_IN_MEAN_10_BIT 0xB 3014 #define COUNTER_8_BIT 0xC 3016 #define COUNTER_16_BIT 0xD 3018 #define COUNTER_RISE_8_BIT 0xE 3020 #define COUNTER_RISE_16_BIT 0xF 3022 #define PWM_SLOW 0x8 3024 #define PWM_FAST 0x9 3026 #define FREQ_LOW 0xA 3028 #define FREQ_HIGH 0xB 3030 #define COUNTER_B_DIR 0xC 3032 #define COUNTER_B_DIR_PULLUP 0xD 3034 #define COUNTER_MEAN_8_BIT 0xE 3036 #define COUNTER_MEAN_16_BIT 0xF 3069 #if EBOARD_USE_UTILITY > 0x0 3070 inline void read(
void);
3081 inline void write(
void);
3093 this->
A=0x0;this->
B=0x0;this->
C=0x0;
3095 #if EBOARD_USE_UTILITY > 0x0 3150 #if EBOARD_USE_UTILITY > 0x0 3186 inline void ledOff(
void);
3188 inline void ledOn(
void);
3250 #if EBOARD_USE_UTILITY > 0x0 3263 #if EBOARD_CLAMP > 0x0 3264 if(pos>1023 || speed > 1023)
return;
3266 speed = speed*600/1023 - 300;
3267 pos = pos *600/1023 - 300;
3270 if(pos>300 || speed > 300)
return;
3311 #if EBOARD_USE_UTILITY > 0x0 3321 inline void action(
void);
3339 #if EBOARD_USE_UTILITY > 0x0 3364 #if EBOARD_BLUETOOTH > 0x0 3410 inline void write(
const char*
const val);
3428 #if EBOARD_I2C > 0x0 3474 for (byte i = 1; (i < 255 && !
STOP); i++) {
3478 if(count < ret_len) ret[count] = i;
3516 #if EBOARD_LCD > 0x0 3519 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
3520 {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
3521 {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
3522 {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
3523 {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
3524 {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
3525 {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
3526 {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
3527 {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
3528 {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
3529 {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
3530 {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
3531 {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
3532 {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
3533 {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
3534 {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
3535 {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
3536 {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
3537 {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
3538 {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
3539 {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
3540 {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
3541 {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
3542 {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
3543 {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
3544 {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
3545 {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
3546 {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
3547 {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
3548 {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
3549 {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
3550 {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
3551 {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
3552 {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
3553 {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
3554 {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
3555 {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
3556 {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
3557 {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
3558 {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
3559 {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
3560 {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
3561 {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
3562 {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
3563 {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
3564 {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
3565 {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
3566 {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
3567 {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
3568 {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
3569 {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
3570 {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
3571 {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
3572 {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
3573 {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
3574 {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
3575 {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
3576 {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
3577 {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
3578 {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
3579 {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
3580 {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
3581 {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
3582 {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
3583 {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
3584 {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
3585 {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
3586 {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
3587 {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
3588 {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
3589 {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
3590 {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
3591 {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
3592 {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
3593 {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
3594 {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
3595 {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
3596 {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
3597 {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
3598 {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
3599 {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
3600 {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
3601 {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
3602 {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
3603 {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
3604 {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
3605 {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
3606 {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
3607 {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
3608 {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
3609 {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
3610 {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
3611 {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
3612 {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
3613 {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
3614 {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
3879 #define LCD_COMMAND_MODE 0x80 3880 #define LCD_DATA_MODE 0x40 3882 #define LCD_COMMAND_DISPLAY_OFF 0xAE 3884 #define LCD_COMMAND_DISPLAY_ON 0xAF 3886 #define LCD_COMMAND_BLACK_BACKGROUND 0xA6 3888 #define LCD_COMMAND_WHITE_BACKGROUND 0xA7 3890 #define LCD_COMMAND_SET_BRIGHTNESS 0x81 3892 #define LCD_PAGE_ADDRESSING 0x02 3894 #define LCD_HORIZONTAL_ADDRESSING 0x00 3898 #define LCD_COMMAND_CHARGE_PUMP_SETTING 0x8d 3899 #define LCD_COMMAND_CHARGE_PUMP_ENABLE 0x14 3903 #define LCD_WIDTH 128 3907 #define LCD_HEIGHT 64 3952 #if EBOARD_NANO == 0 3990 inline bool clear(
void);
3996 inline void print(
const char* data);
4002 inline void print(
int data);
4047 inline bool reset(
void);
4062 inline bool init(
void);
4072 inline void drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY);
4094 inline bool setCursor(byte posX = 0x0, byte posY = 0x0);
4160 #if EBOARD_NANO == 0x0 4175 return this->
init();
4179 for(byte i = 0; i < 8; i++){
4183 for (byte j = 0; j < 128; j++)
4203 if(data[i] < 32 || data[i] > 127){ i++;
continue;}
4204 for (byte j = 0; j < 8; j++){
4211 char buffer[11] =
"";
4212 itoa(data,buffer,10);
4213 this->
print(line,col,buffer);
4222 return this->
clear();
4239 return this->
clear();
4242 inline void LCD::drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY){
4246 for(
int i = 0x0; i < (hiX * 8 * hiY); i++){
4247 this->
s1Dat(pgm_read_byte(&bitmap[i]));
4248 if(++col == (hiX * 8)) {
4261 this->
s2Cmd((0x00 + (8 *posX & 0x0F)),(0x10 + ((8 * posX >> 4) & 0x0F)));
4262 this->
pX = posX; this->
pY = posY;
4263 return this->
s1Cmd(0xB0 + posY);
4268 this->
s2Cmd(0x81,val);
4299 #if EBOARD_NEO > 0x0 4304 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 4305 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 4307 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 4309 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 4311 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 4313 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 4319 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 4320 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 4322 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 4324 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 4326 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 4328 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 4330 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 4332 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 4334 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 4336 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 4338 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 4340 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 4342 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 4344 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 4346 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 4348 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 4350 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 4352 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 4354 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 4356 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 4358 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 4360 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 4362 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 4364 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 4369 #define EBOARD_NEO_800KHZ 0x0000 4370 #define EBOARD_NEO_400KHZ 0x0100 4451 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
4460 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4503 inline int8_t
getPin(
void);
4515 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
4523 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
4556 #ifdef __AVR__ //not needed (rem?) 4557 volatile uint8_t *
port;
4569 begun(false), brightness(0),
pixels(NULL), endTime(0) {
4579 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
4585 if(
pin >= 0) pinMode(
pin, INPUT);
4590 pinMode(
pin, OUTPUT);
4591 digitalWrite(
pin, LOW);
4623 #if defined(ESP8266) 4625 extern "C" void ICACHE_RAM_ATTR espShow(
4626 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4627 #elif defined(ESP32) 4628 extern "C" void espShow(
4629 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
4646 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 4649 volatile uint8_t n1, n2 = 0;
4652 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4653 if(
port == &PORTD) {
4659 if(b & 0x80) n1 = hi;
4664 "out %[port] , %[hi]" "\n\t" 4665 "mov %[n2] , %[lo]" "\n\t" 4666 "out %[port] , %[n1]" "\n\t" 4668 "sbrc %[byte] , 6" "\n\t" 4669 "mov %[n2] , %[hi]" "\n\t" 4670 "out %[port] , %[lo]" "\n\t" 4673 "out %[port] , %[hi]" "\n\t" 4674 "mov %[n1] , %[lo]" "\n\t" 4675 "out %[port] , %[n2]" "\n\t" 4677 "sbrc %[byte] , 5" "\n\t" 4678 "mov %[n1] , %[hi]" "\n\t" 4679 "out %[port] , %[lo]" "\n\t" 4682 "out %[port] , %[hi]" "\n\t" 4683 "mov %[n2] , %[lo]" "\n\t" 4684 "out %[port] , %[n1]" "\n\t" 4686 "sbrc %[byte] , 4" "\n\t" 4687 "mov %[n2] , %[hi]" "\n\t" 4688 "out %[port] , %[lo]" "\n\t" 4691 "out %[port] , %[hi]" "\n\t" 4692 "mov %[n1] , %[lo]" "\n\t" 4693 "out %[port] , %[n2]" "\n\t" 4695 "sbrc %[byte] , 3" "\n\t" 4696 "mov %[n1] , %[hi]" "\n\t" 4697 "out %[port] , %[lo]" "\n\t" 4700 "out %[port] , %[hi]" "\n\t" 4701 "mov %[n2] , %[lo]" "\n\t" 4702 "out %[port] , %[n1]" "\n\t" 4704 "sbrc %[byte] , 2" "\n\t" 4705 "mov %[n2] , %[hi]" "\n\t" 4706 "out %[port] , %[lo]" "\n\t" 4709 "out %[port] , %[hi]" "\n\t" 4710 "mov %[n1] , %[lo]" "\n\t" 4711 "out %[port] , %[n2]" "\n\t" 4713 "sbrc %[byte] , 1" "\n\t" 4714 "mov %[n1] , %[hi]" "\n\t" 4715 "out %[port] , %[lo]" "\n\t" 4718 "out %[port] , %[hi]" "\n\t" 4719 "mov %[n2] , %[lo]" "\n\t" 4720 "out %[port] , %[n1]" "\n\t" 4722 "sbrc %[byte] , 0" "\n\t" 4723 "mov %[n2] , %[hi]" "\n\t" 4724 "out %[port] , %[lo]" "\n\t" 4725 "sbiw %[count], 1" "\n\t" 4727 "out %[port] , %[hi]" "\n\t" 4728 "mov %[n1] , %[lo]" "\n\t" 4729 "out %[port] , %[n2]" "\n\t" 4730 "ld %[byte] , %a[ptr]+" "\n\t" 4731 "sbrc %[byte] , 7" "\n\t" 4732 "mov %[n1] , %[hi]" "\n\t" 4733 "out %[port] , %[lo]" "\n\t" 4739 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
4744 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 4749 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4750 if(
port == &PORTB) {
4751 #endif // defined(PORTD/C/F) 4755 if(b & 0x80) n1 = hi;
4759 "out %[port] , %[hi]" "\n\t" 4760 "mov %[n2] , %[lo]" "\n\t" 4761 "out %[port] , %[n1]" "\n\t" 4763 "sbrc %[byte] , 6" "\n\t" 4764 "mov %[n2] , %[hi]" "\n\t" 4765 "out %[port] , %[lo]" "\n\t" 4767 "out %[port] , %[hi]" "\n\t" 4768 "mov %[n1] , %[lo]" "\n\t" 4769 "out %[port] , %[n2]" "\n\t" 4771 "sbrc %[byte] , 5" "\n\t" 4772 "mov %[n1] , %[hi]" "\n\t" 4773 "out %[port] , %[lo]" "\n\t" 4775 "out %[port] , %[hi]" "\n\t" 4776 "mov %[n2] , %[lo]" "\n\t" 4777 "out %[port] , %[n1]" "\n\t" 4779 "sbrc %[byte] , 4" "\n\t" 4780 "mov %[n2] , %[hi]" "\n\t" 4781 "out %[port] , %[lo]" "\n\t" 4783 "out %[port] , %[hi]" "\n\t" 4784 "mov %[n1] , %[lo]" "\n\t" 4785 "out %[port] , %[n2]" "\n\t" 4787 "sbrc %[byte] , 3" "\n\t" 4788 "mov %[n1] , %[hi]" "\n\t" 4789 "out %[port] , %[lo]" "\n\t" 4791 "out %[port] , %[hi]" "\n\t" 4792 "mov %[n2] , %[lo]" "\n\t" 4793 "out %[port] , %[n1]" "\n\t" 4795 "sbrc %[byte] , 2" "\n\t" 4796 "mov %[n2] , %[hi]" "\n\t" 4797 "out %[port] , %[lo]" "\n\t" 4799 "out %[port] , %[hi]" "\n\t" 4800 "mov %[n1] , %[lo]" "\n\t" 4801 "out %[port] , %[n2]" "\n\t" 4803 "sbrc %[byte] , 1" "\n\t" 4804 "mov %[n1] , %[hi]" "\n\t" 4805 "out %[port] , %[lo]" "\n\t" 4807 "out %[port] , %[hi]" "\n\t" 4808 "mov %[n2] , %[lo]" "\n\t" 4809 "out %[port] , %[n1]" "\n\t" 4811 "sbrc %[byte] , 0" "\n\t" 4812 "mov %[n2] , %[hi]" "\n\t" 4813 "out %[port] , %[lo]" "\n\t" 4814 "sbiw %[count], 1" "\n\t" 4815 "out %[port] , %[hi]" "\n\t" 4816 "mov %[n1] , %[lo]" "\n\t" 4817 "out %[port] , %[n2]" "\n\t" 4818 "ld %[byte] , %a[ptr]+" "\n\t" 4819 "sbrc %[byte] , 7" "\n\t" 4820 "mov %[n1] , %[hi]" "\n\t" 4821 "out %[port] , %[lo]" "\n\t" 4823 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4824 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4827 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 4830 #if defined(PORTC) || defined(PORTF) 4836 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4837 if(
port == &PORTC) {
4843 if(b & 0x80) n1 = hi;
4847 "out %[port] , %[hi]" "\n\t" 4848 "mov %[n2] , %[lo]" "\n\t" 4849 "out %[port] , %[n1]" "\n\t" 4851 "sbrc %[byte] , 6" "\n\t" 4852 "mov %[n2] , %[hi]" "\n\t" 4853 "out %[port] , %[lo]" "\n\t" 4855 "out %[port] , %[hi]" "\n\t" 4856 "mov %[n1] , %[lo]" "\n\t" 4857 "out %[port] , %[n2]" "\n\t" 4859 "sbrc %[byte] , 5" "\n\t" 4860 "mov %[n1] , %[hi]" "\n\t" 4861 "out %[port] , %[lo]" "\n\t" 4863 "out %[port] , %[hi]" "\n\t" 4864 "mov %[n2] , %[lo]" "\n\t" 4865 "out %[port] , %[n1]" "\n\t" 4867 "sbrc %[byte] , 4" "\n\t" 4868 "mov %[n2] , %[hi]" "\n\t" 4869 "out %[port] , %[lo]" "\n\t" 4871 "out %[port] , %[hi]" "\n\t" 4872 "mov %[n1] , %[lo]" "\n\t" 4873 "out %[port] , %[n2]" "\n\t" 4875 "sbrc %[byte] , 3" "\n\t" 4876 "mov %[n1] , %[hi]" "\n\t" 4877 "out %[port] , %[lo]" "\n\t" 4879 "out %[port] , %[hi]" "\n\t" 4880 "mov %[n2] , %[lo]" "\n\t" 4881 "out %[port] , %[n1]" "\n\t" 4883 "sbrc %[byte] , 2" "\n\t" 4884 "mov %[n2] , %[hi]" "\n\t" 4885 "out %[port] , %[lo]" "\n\t" 4887 "out %[port] , %[hi]" "\n\t" 4888 "mov %[n1] , %[lo]" "\n\t" 4889 "out %[port] , %[n2]" "\n\t" 4891 "sbrc %[byte] , 1" "\n\t" 4892 "mov %[n1] , %[hi]" "\n\t" 4893 "out %[port] , %[lo]" "\n\t" 4895 "out %[port] , %[hi]" "\n\t" 4896 "mov %[n2] , %[lo]" "\n\t" 4897 "out %[port] , %[n1]" "\n\t" 4899 "sbrc %[byte] , 0" "\n\t" 4900 "mov %[n2] , %[hi]" "\n\t" 4901 "out %[port] , %[lo]" "\n\t" 4902 "sbiw %[count], 1" "\n\t" 4903 "out %[port] , %[hi]" "\n\t" 4904 "mov %[n1] , %[lo]" "\n\t" 4905 "out %[port] , %[n2]" "\n\t" 4906 "ld %[byte] , %a[ptr]+" "\n\t" 4907 "sbrc %[byte] , 7" "\n\t" 4908 "mov %[n1] , %[hi]" "\n\t" 4909 "out %[port] , %[lo]" "\n\t" 4911 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
4912 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
4915 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 4924 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 4925 if(
port == &PORTF) {
4926 #endif // defined(PORTD/B/C) 4931 if(b & 0x80) n1 = hi;
4935 "out %[port] , %[hi]" "\n\t" 4936 "mov %[n2] , %[lo]" "\n\t" 4937 "out %[port] , %[n1]" "\n\t" 4939 "sbrc %[byte] , 6" "\n\t" 4940 "mov %[n2] , %[hi]" "\n\t" 4941 "out %[port] , %[lo]" "\n\t" 4943 "out %[port] , %[hi]" "\n\t" 4944 "mov %[n1] , %[lo]" "\n\t" 4945 "out %[port] , %[n2]" "\n\t" 4947 "sbrc %[byte] , 5" "\n\t" 4948 "mov %[n1] , %[hi]" "\n\t" 4949 "out %[port] , %[lo]" "\n\t" 4951 "out %[port] , %[hi]" "\n\t" 4952 "mov %[n2] , %[lo]" "\n\t" 4953 "out %[port] , %[n1]" "\n\t" 4955 "sbrc %[byte] , 4" "\n\t" 4956 "mov %[n2] , %[hi]" "\n\t" 4957 "out %[port] , %[lo]" "\n\t" 4959 "out %[port] , %[hi]" "\n\t" 4960 "mov %[n1] , %[lo]" "\n\t" 4961 "out %[port] , %[n2]" "\n\t" 4963 "sbrc %[byte] , 3" "\n\t" 4964 "mov %[n1] , %[hi]" "\n\t" 4965 "out %[port] , %[lo]" "\n\t" 4967 "out %[port] , %[hi]" "\n\t" 4968 "mov %[n2] , %[lo]" "\n\t" 4969 "out %[port] , %[n1]" "\n\t" 4971 "sbrc %[byte] , 2" "\n\t" 4972 "mov %[n2] , %[hi]" "\n\t" 4973 "out %[port] , %[lo]" "\n\t" 4975 "out %[port] , %[hi]" "\n\t" 4976 "mov %[n1] , %[lo]" "\n\t" 4977 "out %[port] , %[n2]" "\n\t" 4979 "sbrc %[byte] , 1" "\n\t" 4980 "mov %[n1] , %[hi]" "\n\t" 4981 "out %[port] , %[lo]" "\n\t" 4983 "out %[port] , %[hi]" "\n\t" 4984 "mov %[n2] , %[lo]" "\n\t" 4985 "out %[port] , %[n1]" "\n\t" 4987 "sbrc %[byte] , 0" "\n\t" 4988 "mov %[n2] , %[hi]" "\n\t" 4989 "out %[port] , %[lo]" "\n\t" 4990 "sbiw %[count], 1" "\n\t" 4991 "out %[port] , %[hi]" "\n\t" 4992 "mov %[n1] , %[lo]" "\n\t" 4993 "out %[port] , %[n2]" "\n\t" 4994 "ld %[byte] , %a[ptr]+" "\n\t" 4995 "sbrc %[byte] , 7" "\n\t" 4996 "mov %[n1] , %[hi]" "\n\t" 4997 "out %[port] , %[lo]" "\n\t" 4999 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
5000 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5003 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5005 #endif // defined(PORTD/B/C) 5006 #endif // defined(PORTF) 5009 volatile uint8_t next, bit;
5018 "st %a[port], %[hi]" "\n\t" 5019 "sbrc %[byte] , 7" "\n\t" 5020 "mov %[next], %[hi]" "\n\t" 5021 "st %a[port], %[next]" "\n\t" 5022 "mov %[next] , %[lo]" "\n\t" 5024 "breq nextbyte20" "\n\t" 5025 "rol %[byte]" "\n\t" 5026 "st %a[port], %[lo]" "\n\t" 5030 "rjmp head20" "\n\t" 5031 "nextbyte20:" "\n\t" 5032 "st %a[port], %[lo]" "\n\t" 5034 "ldi %[bit] , 8" "\n\t" 5035 "ld %[byte] , %a[ptr]+" "\n\t" 5036 "sbiw %[count], 1" "\n\t" 5047 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 5049 volatile uint8_t next;
5054 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5055 if(
port == &PORTD) {
5061 if(b & 0x80) next = hi;
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" 5076 "out %[port], %[hi]" "\n\t" 5077 "rcall bitTimeD" "\n\t" 5079 "out %[port] , %[hi]" "\n\t" 5081 "ld %[byte] , %a[ptr]+" "\n\t" 5082 "out %[port] , %[next]" "\n\t" 5083 "mov %[next] , %[lo]" "\n\t" 5084 "sbrc %[byte] , 7" "\n\t" 5085 "mov %[next] , %[hi]" "\n\t" 5087 "out %[port] , %[lo]" "\n\t" 5088 "sbiw %[count], 1" "\n\t" 5092 "out %[port], %[next]" "\n\t" 5093 "mov %[next], %[lo]" "\n\t" 5094 "rol %[byte]" "\n\t" 5095 "sbrc %[byte], 7" "\n\t" 5096 "mov %[next], %[hi]" "\n\t" 5098 "out %[port], %[lo]" "\n\t" 5104 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
5109 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 5115 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5116 if(
port == &PORTB) {
5122 if(b & 0x80) next = hi;
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" 5139 "rcall bitTimeB" "\n\t" 5140 "out %[port] , %[hi]" "\n\t" 5142 "ld %[byte] , %a[ptr]+" "\n\t" 5143 "out %[port] , %[next]" "\n\t" 5144 "mov %[next] , %[lo]" "\n\t" 5145 "sbrc %[byte] , 7" "\n\t" 5146 "mov %[next] , %[hi]" "\n\t" 5148 "out %[port] , %[lo]" "\n\t" 5149 "sbiw %[count], 1" "\n\t" 5153 "out %[port], %[next]" "\n\t" 5154 "mov %[next], %[lo]" "\n\t" 5155 "rol %[byte]" "\n\t" 5156 "sbrc %[byte], 7" "\n\t" 5157 "mov %[next], %[hi]" "\n\t" 5159 "out %[port], %[lo]" "\n\t" 5162 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5163 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5166 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 5169 #if defined(PORTC) || defined(PORTF) 5175 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5176 if(
port == &PORTC) {
5182 if(b & 0x80) next = hi;
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" 5199 "rcall bitTimeC" "\n\t" 5200 "out %[port] , %[hi]" "\n\t" 5202 "ld %[byte] , %a[ptr]+" "\n\t" 5203 "out %[port] , %[next]" "\n\t" 5204 "mov %[next] , %[lo]" "\n\t" 5205 "sbrc %[byte] , 7" "\n\t" 5206 "mov %[next] , %[hi]" "\n\t" 5208 "out %[port] , %[lo]" "\n\t" 5209 "sbiw %[count], 1" "\n\t" 5213 "out %[port], %[next]" "\n\t" 5214 "mov %[next], %[lo]" "\n\t" 5215 "rol %[byte]" "\n\t" 5216 "sbrc %[byte], 7" "\n\t" 5217 "mov %[next], %[hi]" "\n\t" 5219 "out %[port], %[lo]" "\n\t" 5222 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5223 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5226 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 5235 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5236 if(
port == &PORTF) {
5242 if(b & 0x80) next = hi;
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" 5259 "rcall bitTimeC" "\n\t" 5260 "out %[port] , %[hi]" "\n\t" 5262 "ld %[byte] , %a[ptr]+" "\n\t" 5263 "out %[port] , %[next]" "\n\t" 5264 "mov %[next] , %[lo]" "\n\t" 5265 "sbrc %[byte] , 7" "\n\t" 5266 "mov %[next] , %[hi]" "\n\t" 5268 "out %[port] , %[lo]" "\n\t" 5269 "sbiw %[count], 1" "\n\t" 5273 "out %[port], %[next]" "\n\t" 5274 "mov %[next], %[lo]" "\n\t" 5275 "rol %[byte]" "\n\t" 5276 "sbrc %[byte], 7" "\n\t" 5277 "mov %[next], %[hi]" "\n\t" 5279 "out %[port], %[lo]" "\n\t" 5282 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
5283 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
5286 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 5291 volatile uint8_t next, bit;
5300 "st %a[port], %[hi]" "\n\t" 5301 "sbrc %[byte] , 7" "\n\t" 5302 "mov %[next], %[hi]" "\n\t" 5304 "st %a[port], %[next]" "\n\t" 5309 "st %a[port], %[lo]" "\n\t" 5312 "breq nextbyte30" "\n\t" 5313 "rol %[byte]" "\n\t" 5317 "rjmp head30" "\n\t" 5318 "nextbyte30:" "\n\t" 5320 "ldi %[bit] , 8" "\n\t" 5321 "ld %[byte] , %a[ptr]+" "\n\t" 5322 "sbiw %[count], 1" "\n\t" 5333 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 5335 volatile uint8_t next, bit;
5344 "st %a[port], %[hi]" "\n\t" 5345 "sbrc %[byte], 7" "\n\t" 5346 "mov %[next], %[hi]" "\n\t" 5348 "st %a[port], %[next]" "\n\t" 5349 "mov %[next] , %[lo]" "\n\t" 5350 "breq nextbyte20" "\n\t" 5351 "rol %[byte]" "\n\t" 5354 "st %a[port], %[lo]" "\n\t" 5357 "rjmp head20" "\n\t" 5358 "nextbyte20:" "\n\t" 5359 "ldi %[bit] , 8" "\n\t" 5360 "ld %[byte] , %a[ptr]+" "\n\t" 5361 "st %a[port], %[lo]" "\n\t" 5363 "sbiw %[count], 1" "\n\t" 5375 volatile uint8_t next, bit;
5384 "st %a[port], %[hi]" "\n\t" 5385 "sbrc %[byte] , 7" "\n\t" 5386 "mov %[next] , %[hi]" "\n\t" 5389 "st %a[port], %[next]" "\n\t" 5395 "st %a[port], %[lo]" "\n\t" 5397 "mov %[next] , %[lo]" "\n\t" 5399 "breq nextbyte40" "\n\t" 5400 "rol %[byte]" "\n\t" 5407 "rjmp head40" "\n\t" 5408 "nextbyte40:" "\n\t" 5409 "ldi %[bit] , 8" "\n\t" 5410 "ld %[byte] , %a[ptr]+" "\n\t" 5412 "st %a[port], %[lo]" "\n\t" 5414 "sbiw %[count], 1" "\n\t" 5426 #error "CPU SPEED NOT SUPPORTED" 5428 #elif defined(__arm__) 5431 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 5432 #define CYCLES_800_T0H (F_CPU / 4000000) 5433 #define CYCLES_800_T1H (F_CPU / 1250000) 5434 #define CYCLES_800 (F_CPU / 800000) 5435 #define CYCLES_400_T0H (F_CPU / 2000000) 5436 #define CYCLES_400_T1H (F_CPU / 833333) 5437 #define CYCLES_400 (F_CPU / 400000) 5441 volatile uint8_t *
set = portSetRegister(
pin),
5442 *clr = portClearRegister(
pin);
5445 ARM_DEMCR |= ARM_DEMCR_TRCENA;
5446 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
5449 cyc = ARM_DWT_CYCCNT + CYCLES_800;
5452 for(mask = 0x80; mask; mask >>= 1) {
5453 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5454 cyc = ARM_DWT_CYCCNT;
5457 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
5459 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
5464 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
5466 cyc = ARM_DWT_CYCCNT + CYCLES_400;
5469 for(mask = 0x80; mask; mask >>= 1) {
5470 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5471 cyc = ARM_DWT_CYCCNT;
5474 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
5476 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
5481 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
5484 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 5486 #elif defined(ESP8266) || defined(ESP32) 5490 #elif defined(__ARDUINO_ARC__) 5494 #define NOPx7 { __builtin_arc_nop(); \ 5495 __builtin_arc_nop(); __builtin_arc_nop(); \ 5496 __builtin_arc_nop(); __builtin_arc_nop(); \ 5497 __builtin_arc_nop(); __builtin_arc_nop(); } 5499 PinDescription *pindesc = &g_APinDescription[
pin];
5501 register uint8_t *p =
pixels;
5502 register uint32_t currByte = (uint32_t) (*p);
5503 register uint32_t currBit = 0x80 & currByte;
5504 register uint32_t bitCounter = 0;
5505 register uint32_t first = 1;
5507 if (pindesc->ulGPIOType == SS_GPIO) {
5508 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
5509 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
5510 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5511 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5521 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
5528 __builtin_arc_nop();
5531 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
5535 if(bitCounter >= 8) {
5537 currByte = (uint32_t) (*++p);
5540 currBit = 0x80 & currByte;
5543 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
5544 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
5545 uint32_t reg_val = MMIO_REG_VAL(reg);
5546 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
5547 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
5555 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
5559 __builtin_arc_nop();
5565 MMIO_REG_VAL(reg) = reg_bit_low;
5569 if(bitCounter >= 8) {
5571 currByte = (uint32_t) (*++p);
5574 currBit = 0x80 & currByte;
5580 #error Architecture not supported 5593 digitalWrite(p, LOW);
5596 port = portOutputRegister(digitalPinToPort(p));
5597 pinMask = digitalPinToBitMask(p);
5602 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
5624 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5649 r = (uint8_t)(c >> 16),
5650 g = (uint8_t)(c >> 8),
5661 uint8_t w = (uint8_t)(c >> 24);
5671 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5674 uint32_t
NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
5675 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
5691 return ((uint32_t)p[
aOffset[0]] << 16) |
5692 ((uint32_t)p[
aOffset[1]] << 8) |
5703 return ((uint32_t)p[
aOffset[3]] << 24) |
5704 ((uint32_t)p[
aOffset[0]] << 16) |
5705 ((uint32_t)p[
aOffset[1]] << 8) |
5722 uint8_t newBrightness = b + 1;
5728 if(oldBrightness == 0) scale = 0;
5729 else if(b == 255) scale = 65535 / oldBrightness;
5730 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
5731 for(uint16_t i=0; i<
numBytes; i++) {
5733 *ptr++ = (c * scale) >> 8;
6189 #if EBOARD_NANO > 0x0 || defined(DOC) 6191 #if EBOARD_GUESSPATH > 0x0 6196 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
6197 #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 6198 #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 6199 #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 6200 #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 6202 #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 6203 #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 6205 #define INVALID_SERVO 255 // flag indicating an invalid servo index 6208 uint8_t isActive :1 ;
6213 volatile unsigned int ticks;
6219 uint8_t attach(
int pin);
6220 uint8_t attach(
int pin,
int min,
int max);
6222 void write(
int value);
6223 void writeMicroseconds(
int value);
6225 int readMicroseconds();
6226 inline bool attached();
6232 #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 6233 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds 6236 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 6240 static servo_t servos[MAX_SERVOS];
6241 static volatile int8_t Channel[_Nbr_16timers ];
6243 uint8_t ServoCount = 0;
6246 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo 6247 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer 6248 #define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel 6249 #define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel 6251 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo 6252 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo 6254 static inline void handle_interrupts(timer16_Sequence_t timer,
volatile uint16_t *TCNTn,
volatile uint16_t* OCRnA)
6256 if( Channel[timer] < 0 )
6259 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive ==
true )
6260 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW);
6264 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
6265 *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
6266 if(SERVO(timer,Channel[timer]).Pin.isActive ==
true)
6267 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH);
6271 if( ((
unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )
6272 *OCRnA = (
unsigned int)usToTicks(REFRESH_INTERVAL);
6274 *OCRnA = *TCNTn + 4;
6275 Channel[timer] = -1;
6279 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform 6281 #if defined(_useTimer1) 6282 SIGNAL (TIMER1_COMPA_vect)
6284 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6287 #elif defined WIRING 6289 #if defined(_useTimer1) 6290 void Timer1Service()
6292 handle_interrupts(_timer1, &TCNT1, &OCR1A);
6297 static void initISR(timer16_Sequence_t timer) {
6298 if(timer == _timer1) {
6302 TIFR1 |= _BV(OCF1A);
6303 TIMSK1 |= _BV(OCIE1A) ;
6305 timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
6310 static void finISR(timer16_Sequence_t timer) {
6311 #if defined WIRING // Wiring 6312 if(timer == _timer1) {
6313 TIMSK &= ~_BV(OCIE1A) ;
6314 timerDetach(TIMER1OUTCOMPAREA_INT);
6316 else if(timer == _timer3) {
6317 ETIMSK &= ~_BV(OCIE3A);
6318 timerDetach(TIMER3OUTCOMPAREA_INT);
6326 static boolean isTimerActive(timer16_Sequence_t timer) {
6328 for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
6329 if(SERVO(timer,channel).Pin.isActive ==
true)
6336 if( ServoCount < MAX_SERVOS) {
6337 this->servoIndex = ServoCount++;
6338 servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);
6341 this->servoIndex = INVALID_SERVO ;
6344 uint8_t Servo::attach(
int pin) {
6345 return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
6348 uint8_t Servo::attach(
int pin,
int min,
int max) {
6349 if(this->servoIndex < MAX_SERVOS ) {
6350 pinMode( pin, OUTPUT) ;
6351 servos[this->servoIndex].Pin.nbr = pin;
6353 this->min = (MIN_PULSE_WIDTH - min)/4;
6354 this->max = (MAX_PULSE_WIDTH - max)/4;
6356 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6357 if(isTimerActive(timer) ==
false)
6359 servos[this->servoIndex].Pin.isActive =
true;
6361 return this->servoIndex ;
6364 void Servo::detach() {
6365 servos[this->servoIndex].Pin.isActive =
false;
6366 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
6367 if(isTimerActive(timer) ==
false) {
6372 void Servo::write(
int value) {
6373 if(value < MIN_PULSE_WIDTH)
6375 if(value < 0) value = 0;
6376 if(value > 180) value = 180;
6377 value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
6379 this->writeMicroseconds(value);
6382 void Servo::writeMicroseconds(
int value) {
6384 byte channel = this->servoIndex;
6385 if( (channel < MAX_SERVOS) )
6387 if( value < SERVO_MIN() )
6388 value = SERVO_MIN();
6389 else if( value > SERVO_MAX() )
6390 value = SERVO_MAX();
6392 value = value - TRIM_DURATION;
6393 value = usToTicks(value);
6395 uint8_t oldSREG = SREG;
6397 servos[channel].ticks = value;
6402 inline int Servo::read()
6404 return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
6407 int Servo::readMicroseconds() {
6408 unsigned int pulsewidth;
6409 if( this->servoIndex != INVALID_SERVO )
6410 pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ;
6417 inline bool Servo::attached() {
6418 return servos[this->servoIndex].Pin.isActive ;
6424 #if EBOARD_COPY_AND_PASTE > 0x0 6434 #if EBOARD_NANO > 0x0 6435 Servo mainMotor,steerMotor;
6447 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 6482 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 6483 Serial1.begin(38400);
6489 #if EBOARD_I2C > 0x0 6492 #if EBOARD_SHIFT_REGISTER > 0x0 6498 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0) 6501 #if EBOARD_NANO > 0x0 6504 #if EBOARD_DEBUG_MODE > 0x0 6505 Serial.println(
"Initializing main driving motor (3s)");
6507 mainMotor.write(90);
6509 #if EBOARD_DEBUG_MODE > 0x0 6510 Serial.println(
"Initializing of main driving motor completed");
6513 #if EBOARD_DEBUG_MODE > 0x0 6515 Serial.println(
"fin");
6521 #if EBOARD_NANO > 0x0 6522 mainMotor.write(90);
6525 #if EBOARD_NANO == 0x0 6540 #if EBOARD_NANO > 0x0 || defined(DOC) 6556 if(spe < 0 || spe > 180)
return;
6557 mainMotor.write(spe);
6560 if(ang < 0 || ang > 180)
return;
6561 steerMotor.write(ang);
6567 #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process 6569 #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...