4 #ifndef EBOARD_HEADER_GUARD 5 #define EBOARD_HEADER_GUARD 6 #pragma GCC diagnostic push 7 #pragma GCC diagnostic ignored "-Wall" 8 #pragma GCC diagnostic ignored "-Wextra" 11 #define EBOARD_VERSION "3.1.5m" 12 #define EBOARD_VERSION_NBR 315 13 #define VALUE_TO_STRING(x) #x 17 #define PREPROCESS_DEBUG 1 19 #define VALUE(x) VALUE_TO_STRING(x) 20 #ifndef PREPROCESS_DEBUG 21 #define PREPROCESS_DEBUG 0 24 #define PPERFORM_PRAGMA(str) _Pragma(#str) 25 #if PREPROCESS_DEBUG == 1 26 #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str)) 27 #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str)) 29 #define DEBUG_MSG(str) ; 30 #define MACRO_MSG(mac,str) ; 32 DEBUG_MSG(
"If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
33 DEBUG_MSG(
"You are using eBoard-header v3.1m written by EagleoutIce");
41 DEBUG_MSG(
"Documentation macro SET => Full doc features enabled");
44 #define EBOARD_I2C 0x1 46 #define EBOARD_LCD 0x1 48 #define EBOARD_SHIFT_REGISTER 0x1 50 #define EBOARD_BLUETOOTH 0x1 54 #define __AVR_ATmega2560__ 56 #define __AVR_ATmega328P__ 58 #define EBOARD_NEO 0x1 65 inline int sine8(uint8_t val){
66 return int((__builtin_sin((val/128.0*PI))+1)*127.5+0.5);
69 inline int gamma8(uint8_t val){
70 return int(pow((val)/255.0,2.6)*255.0+0.5);
72 #include <avr/pgmspace.h> 76 #ifndef EBOARD_GUESSPATH 77 DEBUG_MSG(
"You are using Guesspath! Necessary libraries for eBoard will be included automatically");
79 #define EBOARD_GUESSPATH 0x1 81 DEBUG_MSG(
"You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
83 #if defined(ARDUINO) //general platform-check [No tab] 85 #define main eVirtual_main //main has a different meaning^^ 86 #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D 91 #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__)) 92 #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!" 94 #if defined(__AVR_ATmega2560__) 95 DEBUG_MSG(
"Building for Arduino Mega with ATmega2560");
97 #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS 99 DEBUG_MSG(
"Building for Arduino Uno or Nano with ATmega328P");
100 #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS 103 #include <avr/interrupt.h> 104 #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0 105 DEBUG_MSG(
"You enabled I²C featurea");
112 #define TWI_FREQ 100000L 114 # ifndef TWI_BUFFER_LENGTH 115 #define TWI_BUFFER_LENGTH 32 124 #include <avr/interrupt.h> 125 #include <compat/twi.h> 127 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 130 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 132 #include "pins_arduino.h" 133 static volatile uint8_t twi_state;
134 static volatile uint8_t twi_slarw;
135 static volatile uint8_t twi_sendStop;
136 static volatile uint8_t twi_inRepStart;
137 static void (*twi_onSlaveTransmit)(void);
138 static void (*twi_onSlaveReceive)(uint8_t*, int);
139 static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
140 static volatile uint8_t twi_masterBufferIndex;
141 static volatile uint8_t twi_masterBufferLength;
142 static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
143 static volatile uint8_t twi_txBufferIndex;
144 static volatile uint8_t twi_txBufferLength;
145 static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
146 static volatile uint8_t twi_rxBufferIndex;
147 static volatile uint8_t twi_error;
148 void twi_init(
void) {
149 twi_state = TWI_READY;
151 twi_inRepStart =
false;
152 digitalWrite(SDA, 1);
153 digitalWrite(SCL, 1);
156 TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
157 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
159 inline void twi_setAddress(uint8_t address) {
162 uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) {
164 if(TWI_BUFFER_LENGTH < length)
return 0;
165 while(TWI_READY != twi_state)
continue;
167 twi_sendStop = sendStop;
169 twi_masterBufferIndex = 0;
170 twi_masterBufferLength = length-1;
172 twi_slarw |= address << 1;
173 if (
true == twi_inRepStart) {
174 twi_inRepStart =
false;
176 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
179 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
180 while(TWI_MRX == twi_state)
continue;
181 if (twi_masterBufferIndex < length)
182 length = twi_masterBufferIndex;
183 for(i = 0; i < length; ++i) data[i] = twi_masterBuffer[i];
186 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) {
188 if(TWI_BUFFER_LENGTH < length)
return 1;
189 while(TWI_READY != twi_state)
continue;
191 twi_sendStop = sendStop;
193 twi_masterBufferIndex = 0;
194 twi_masterBufferLength = length;
195 for(i = 0; i < length; ++i) twi_masterBuffer[i] = data[i];
196 twi_slarw = TW_WRITE;
197 twi_slarw |= address << 1;
198 if (
true == twi_inRepStart) {
199 twi_inRepStart =
false;
201 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
204 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
205 while(wait && (TWI_MTX == twi_state))
continue;
206 if (twi_error == 0xFF)
return 0;
207 else if (twi_error == TW_MT_SLA_NACK)
return 2;
208 else if (twi_error == TW_MT_DATA_NACK)
return 3;
211 uint8_t twi_transmit(
const uint8_t* data, uint8_t length) {
213 if(TWI_BUFFER_LENGTH < length)
return 1;
214 if(TWI_STX != twi_state)
return 2;
215 twi_txBufferLength = length;
216 for(i = 0; i < length; ++i) twi_txBuffer[i] = data[i];
219 void twi_attachSlaveRxEvent(
void (*
function)(uint8_t*,
int) ) {
220 twi_onSlaveReceive =
function;
222 void twi_attachSlaveTxEvent(
void (*
function)(
void) ) {
223 twi_onSlaveTransmit =
function;
225 void twi_reply(uint8_t ack) {
227 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
229 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
232 void twi_stop(
void) {
233 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
234 while(TWCR & _BV(TWSTO))
continue;
235 twi_state = TWI_READY;
237 void twi_releaseBus(
void){
238 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
239 twi_state = TWI_READY;
250 if(twi_masterBufferIndex < twi_masterBufferLength){
251 TWDR = twi_masterBuffer[twi_masterBufferIndex++];
254 if (twi_sendStop) twi_stop();
256 twi_inRepStart =
true;
257 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
258 twi_state = TWI_READY;
263 twi_error = TW_MT_SLA_NACK;
266 case TW_MT_DATA_NACK:
267 twi_error = TW_MT_DATA_NACK;
271 twi_error = TW_MT_ARB_LOST;
275 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
277 if(twi_masterBufferIndex < twi_masterBufferLength) twi_reply(1);
280 case TW_MR_DATA_NACK:
281 twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
282 if (twi_sendStop) twi_stop();
284 twi_inRepStart =
true;
285 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
286 twi_state = TWI_READY;
293 case TW_SR_GCALL_ACK:
294 case TW_SR_ARB_LOST_SLA_ACK:
295 case TW_SR_ARB_LOST_GCALL_ACK:
297 twi_rxBufferIndex = 0;
301 case TW_SR_GCALL_DATA_ACK:
302 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
303 twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
308 if(twi_rxBufferIndex < TWI_BUFFER_LENGTH) twi_rxBuffer[twi_rxBufferIndex] =
'\0';
310 twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
311 twi_rxBufferIndex = 0;
314 case TW_SR_DATA_NACK:
315 case TW_SR_GCALL_DATA_NACK:
319 case TW_ST_ARB_LOST_SLA_ACK:
321 twi_txBufferIndex = 0;
322 twi_txBufferLength = 0;
323 twi_onSlaveTransmit();
324 if(0 == twi_txBufferLength){
325 twi_txBufferLength = 1;
326 twi_txBuffer[0] = 0x00;
329 TWDR = twi_txBuffer[twi_txBufferIndex++];
330 if(twi_txBufferIndex < twi_txBufferLength) twi_reply(1);
333 case TW_ST_DATA_NACK:
334 case TW_ST_LAST_DATA:
336 twi_state = TWI_READY;
341 twi_error = TW_BUS_ERROR;
350 #include <inttypes.h> 352 #define BUFFER_LENGTH 32 355 class TwoWire :
public Stream {
387 void begin(uint8_t address);
389 inline void begin(
int address);
399 inline uint8_t
requestFrom(uint8_t address, uint8_t quantity);
401 uint8_t
requestFrom(uint8_t address , uint8_t quantity, uint8_t sendStop);
403 inline uint8_t
requestFrom(
int address,
int quantity);
405 inline uint8_t
requestFrom(
int address,
int quantity,
int sendStop);
407 virtual size_t write(uint8_t data);
409 virtual size_t write(
const uint8_t *data,
size_t quantity);
413 virtual int read(
void);
415 virtual int peek(
void);
419 void onRequest(
void (*
function)(
void) );
427 #include <inttypes.h> 450 twi_setAddress(address);
456 begin((uint8_t)address);
462 uint8_t
read = twi_readFrom(address,
rxBuffer, quantity, sendStop);
468 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
471 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
474 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
505 twi_transmit(&data, 1);
511 for(
size_t i = 0; i < quantity; ++i) {
515 twi_transmit(data, quantity);
544 for(uint8_t i = 0; i < numBytes; ++i) {
571 DEBUG_MSG(
"You disabled I²C");
574 #ifndef EBOARD_USE_SPI 575 #define EBOARD_USE_SPI 0x1 577 #if EBOARD_USE_SPI > 0x0 578 DEBUG_MSG(
"You enabled SPI");
579 #ifndef _SPI_H_INCLUDED 581 #define _SPI_H_INCLUDED 584 #define SPI_CLOCK_DIV4 0x00 586 #define SPI_CLOCK_DIV16 0x01 588 #define SPI_CLOCK_DIV64 0x02 590 #define SPI_CLOCK_DIV128 0x03 592 #define SPI_CLOCK_DIV2 0x04 594 #define SPI_CLOCK_DIV8 0x05 596 #define SPI_CLOCK_DIV32 0x06 598 #define SPI_MODE0 0x00 600 #define SPI_MODE1 0x04 602 #define SPI_MODE2 0x08 604 #define SPI_MODE3 0x0C 606 #define SPI_MODE_MASK 0x0C 608 #define SPI_CLOCK_MASK 0x03 610 #define SPI_2XCLOCK_MASK 0x01 615 inline static byte
transfer(byte _data);
621 static void begin(
void);
623 inline static void end(
void);
635 while (!(SPSR & _BV(SPIF)));
641 digitalWrite(SS, HIGH);
645 pinMode(SCK, OUTPUT);
646 pinMode(MOSI, OUTPUT);
650 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
651 else SPCR &= ~(_BV(DORD));
662 DEBUG_MSG(
"You disabled SPI");
664 #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0) 665 #include <avr/pgmspace.h> 666 DEBUG_MSG(
"You enabled LCD");
669 static bool STOP =
false;
672 DEBUG_MSG(
"You defined IGNORE_SIZE: byte will be used");
675 DEBUG_MSG(
"You did not define IGNORE_SIZE: int will be used");
679 #ifndef EBOARD_DEBUG_MODE 680 #define EBOARD_DEBUG_MODE 0x1 682 #if EBOARD_DEBUG_MODE > 0x0 689 #define EBOARD_NANO 0x0 691 #if EBOARD_NANO > 0x0 || defined(DOC) 692 #ifndef EBOARD_NANO_STEER 694 #define EBOARD_NANO_STEER 12 696 #ifndef EBOARD_NANO_MAIN 698 #define EBOARD_NANO_MAIN 13 700 MACRO_MSG(
EBOARD_NANO,
"Using Arduino NANO environment [e.g. remove SoccerBoard]");
701 #if PREPROCESS_DEBUG > 0x1 702 #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR") 703 #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR") 706 MACRO_MSG(
EBOARD_NANO,
"Using Arduino UNO/MEGA environment");
709 #ifndef EBOARD_CHECK_PINS 710 #define EBOARD_CHECK_PINS 0x1 712 #if EBOARD_CHECK_PINS > 0x0 717 #ifndef EBOARD_SHIFT_REGISTER 719 #define EBOARD_SHIFT_REGISTER 0x0 721 #if EBOARD_SHIFT_REGISTER > 0x0 727 #ifndef EBOARD_CHECK_PINS_PWM 728 #define EBOARD_CHECK_PINS_PWM 0x1 730 #if EBOARD_CHECK_PINS_PWM > 0x0 736 #ifndef EBOARD_DEBUG_SPEED 737 #define EBOARD_DEBUG_SPEED 9600 739 #if PREPROCESS_DEBUG > 0x0 740 #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED)) 743 #ifndef EBOARD_SPI_SERVO_MAX 744 #define EBOARD_SPI_SERVO_MAX 2 746 #if PREPROCESS_DEBUG > 0x0 747 #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX)) 750 #ifndef EBOARD_USE_UTILITY 751 #define EBOARD_USE_UTILITY 0x1 753 #if EBOARD_USE_UTILITY > 0x0 759 #define EBOARD_COPY_AND_PASTE 0x1 761 #ifndef EBOARD_PWM_SPE 762 #define EBOARD_PWM_SPE 1 764 #if PREPROCESS_DEBUG > 0x0 765 #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s") 769 #define EBOARD_I2C 0x0 //disabled by default 771 #ifndef EBOARD_BLUETOOTH 773 #define EBOARD_BLUETOOTH 0x0 775 #if EBOARD_BLUETOOTH > 0x0 782 #define EBOARD_CLAMP 0x1 784 #if EBOARD_CLAMP > 0x0 785 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [0;1023]");
787 MACRO_MSG(
EBOARD_CLAMP,
"Motor Range is set to [-300;300]");
791 #define EBOARD_NEO 0x0 794 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support enabled");
796 MACRO_MSG(
EBOARD_NEO,
"Adafruit Neo-Pixel support disabled");
799 #ifndef EBOARD_USE_RESET 800 #define EBOARD_USE_RESET 0x1 802 #if EBOARD_USE_RESET > 0x0 809 #ifndef PIN_BLUETOOTH_STATE 810 #if defined(__AVR_ATmega2560__) 811 #define PIN_BLUETOOTH_STATE 0x13 // 19 813 #define PIN_BLUETOOTH_STATE 0x2 817 #ifndef PIN_BLUETOOTH_RX 818 #if defined(__AVR_ATmega2560__) 819 #define PIN_BLUETOOTH_RX 0x13 // 19 821 #define PIN_BLUETOOTH_RX 0x2 825 #ifndef PIN_BLUETOOTH_TX 826 #if defined(__AVR_ATmega2560__) 827 #define PIN_BLUETOOTH_TX 0x12 // 18 829 #define PIN_BLUETOOTH_TX 0x3 833 #ifndef PIN_MOTOR_DIR 834 #define PIN_MOTOR_DIR 0x4 837 #ifndef PIN_MOTOR_SPE 838 #define PIN_MOTOR_SPE 0x5 841 #ifndef PIN_SHIFT_CLK 842 #define PIN_SHIFT_CLK 0x6 845 #ifndef PIN_SHIFT_DAT 846 #define PIN_SHIFT_DAT 0x7 849 #ifndef PIN_SHIFT_LAT 850 #define PIN_SHIFT_LAT 0x8 860 #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__) 861 #if EBOARD_GUESSPATH > 0x0 862 #ifndef SoftwareSerial_h 864 #define SoftwareSerial_h 865 #define _SS_MAX_RX_BUFF 64 // RX buffer size 867 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 910 void setTX(uint8_t transmitPin);
912 void setRX(uint8_t receivePin);
914 static inline void tunedDelay(uint16_t delay);
918 SoftwareSerial(uint8_t receivePin, uint8_t transmitPin,
bool inverse_logic =
false);
922 void begin(
long speed);
926 inline void end(
void);
934 virtual size_t write(uint8_t byte);
936 virtual int read(
void);
940 virtual void flush(
void);
957 #if EBOARD_DEBUG_MODE > 0x0 959 #define _DEBUG_PIN1 11 960 #define _DEBUG_PIN2 13 962 typedef struct _DELAY_TABLE {
964 unsigned short rx_delay_centering;
965 unsigned short rx_delay_intrabit;
966 unsigned short rx_delay_stopbit;
967 unsigned short tx_delay;
969 #if F_CPU == 16000000 970 static const DELAY_TABLE PROGMEM table[] = {
972 { 115200, 1, 17, 17, 12, },
973 { 57600, 10, 37, 37, 33, },
974 { 38400, 25, 57, 57, 54, },
975 { 31250, 31, 70, 70, 68, },
976 { 28800, 34, 77, 77, 74, },
977 { 19200, 54, 117, 117, 114, },
978 { 14400, 74, 156, 156, 153, },
979 { 9600, 114, 236, 236, 233, },
980 { 4800, 233, 474, 474, 471, },
981 { 2400, 471, 950, 950, 947, },
982 { 1200, 947, 1902, 1902, 1899, },
983 { 600, 1902, 3804, 3804, 3800, },
984 { 300, 3804, 7617, 7617, 7614, },
986 const int XMIT_START_ADJUSTMENT = 5;
987 #elif F_CPU == 8000000 988 static const DELAY_TABLE table[] PROGMEM = {
990 { 115200, 1, 5, 5, 3, },
991 { 57600, 1, 15, 15, 13, },
992 { 38400, 2, 25, 26, 23, },
993 { 31250, 7, 32, 33, 29, },
994 { 28800, 11, 35, 35, 32, },
995 { 19200, 20, 55, 55, 52, },
996 { 14400, 30, 75, 75, 72, },
997 { 9600, 50, 114, 114, 112, },
998 { 4800, 110, 233, 233, 230, },
999 { 2400, 229, 472, 472, 469, },
1000 { 1200, 467, 948, 948, 945, },
1001 { 600, 948, 1895, 1895, 1890, },
1002 { 300, 1895, 3805, 3805, 3802, },
1004 const int XMIT_START_ADJUSTMENT = 4;
1005 #elif F_CPU == 20000000 1006 static const DELAY_TABLE PROGMEM table[] = {
1008 { 115200, 3, 21, 21, 18, },
1009 { 57600, 20, 43, 43, 41, },
1010 { 38400, 37, 73, 73, 70, },
1011 { 31250, 45, 89, 89, 88, },
1012 { 28800, 46, 98, 98, 95, },
1013 { 19200, 71, 148, 148, 145, },
1014 { 14400, 96, 197, 197, 194, },
1015 { 9600, 146, 297, 297, 294, },
1016 { 4800, 296, 595, 595, 592, },
1017 { 2400, 592, 1189, 1189, 1186, },
1018 { 1200, 1187, 2379, 2379, 2376, },
1019 { 600, 2379, 4759, 4759, 4755, },
1020 { 300, 4759, 9523, 9523, 9520, },
1022 const int XMIT_START_ADJUSTMENT = 6;
1024 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors 1030 #if EBOARD_DEBUG_MODE > 0x0 1031 inline void DebugPulse(uint8_t pin, uint8_t count) {
1033 volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
1034 uint8_t val = *pport;
1037 *pport = val | digitalPinToBitMask(pin);
1045 asm volatile(
"sbiw %0, 0x01 \n\t" 1047 "cpi %A0, 0xFF \n\t" 1050 :
"+r" (delay),
"+a" (tmp)
1058 uint8_t oldSREG = SREG;
1068 #if GCC_VERSION < 40302 1084 #if EBOARD_DEBUG_MODE > 0x0 1085 DebugPulse(_DEBUG_PIN2, 1);
1088 for (uint8_t i=0x1; i; i <<= 1)
1091 #if EBOARD_DEBUG_MODE > 0x0 1092 DebugPulse(_DEBUG_PIN2, 1);
1102 #if EBOARD_DEBUG_MODE > 0x0 1103 DebugPulse(_DEBUG_PIN2, 1);
1112 #if EBOARD_DEBUG_MODE > 0x0 1113 #if _DEBUG // for scope: pulse pin as overflow indictator 1114 DebugPulse(_DEBUG_PIN1, 1);
1120 #if GCC_VERSION < 40302 1134 if (pin_state == LOW)
1147 #if defined(PCINT0_vect) 1152 #if defined(PCINT1_vect) 1157 #if defined(PCINT2_vect) 1162 #if defined(PCINT3_vect) 1168 _rx_delay_centering(0),
1169 _rx_delay_intrabit(0),
1170 _rx_delay_stopbit(0),
1172 _buffer_overflow(false),
1173 _inverse_logic(inverse_logic) {
1177 SoftwareSerial::~SoftwareSerial() {
1181 pinMode(tx, OUTPUT);
1182 digitalWrite(tx, HIGH);
1184 uint8_t port = digitalPinToPort(tx);
1190 digitalWrite(rx, HIGH);
1193 uint8_t port = digitalPinToPort(rx);
1198 for (
unsigned i=0; i<
sizeof(table)/
sizeof(table[0]); ++i) {
1199 long baud = pgm_read_dword(&table[i].baud);
1200 if (baud == speed) {
1204 _tx_delay = pgm_read_word(&table[i].tx_delay);
1216 pinMode(_DEBUG_PIN1, OUTPUT);
1217 pinMode(_DEBUG_PIN2, OUTPUT);
1244 uint8_t oldSREG = SREG;
1249 for (byte mask = 0x01; mask; mask <<= 1) {
1259 for (byte mask = 0x01; mask; mask <<= 1) {
1275 uint8_t oldSREG = SREG;
1293 #if EBOARD_DEBUG_MODE > 0x0 1295 #define __ASSERT_USE_STDERR 1298 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp);
1300 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp){
1301 Serial.print(
"Error with: "); Serial.print(__func);
1302 Serial.print(
" in "); Serial.print(__file);
1303 Serial.print(
" >>");
1304 Serial.println(__sexp);
1305 if(strcmp(__func,
"checkIdx")==0){
1306 Serial.println(
" This happens if an out of bounds exception");
1307 Serial.println(
" has occured. Following pins shouldn't be used:");
1310 Serial.println(
" : Used for Bluetooth communication");
1311 Serial.print(
" D");Serial.print(
PIN_MOTOR_DIR);Serial.print(
"&");
1313 Serial.println(
" : Used for main motor control");
1314 #if EBOARD_USE_SPI > 0x0 1315 Serial.print(
" D10-13");
1316 Serial.println(
": Used for smart-servo-shield");
1318 }
else if (strcmp(__func,
"readPin")==0){
1319 Serial.println(
"You've tried to access an analogPin that isn't present on the board you're currently working on!");
1330 #if EBOARD_DEBUG_MODE > 0x0 1331 assert(idx>=0x0 && idx <
PIN_MAX);
1336 #if EBOARD_COPY_AND_PASTE > 0x0 1337 #if EBOARD_CHECK_PINS_PWM > 0x0 1343 for (count = 0; x; count++)
1349 #if EBOARD_CHECK_PINS > 0x0 1351 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 1353 #elif defined(__AVR_ATmega2560__) 1357 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 1359 #elif defined(__AVR_ATmega2560__) 1367 return (mode == OUTPUT)? ((
pin_out & (1<<idx))>0x0):((
pin_in & (1<<idx))>0x0);
1375 #if EBOARD_CHECK_PINS > 0x0 1390 #if EBOARD_BLUETOOTH > 0x0 1392 inline char readVal(
char oF =
'.');
1396 template <
typename T>
1397 inline void writeVal(
const T& val);
1402 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1408 inline char readVal(
char oF) {
1409 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1410 return ((Serial1.available())?(Serial1.read()):(oF));
1415 template<
typename T>
1416 inline void writeVal(
const T& val){
1417 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1424 #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE 1432 #if EBOARD_SHIFT_REGISTER > 0x0 1460 val = min(val,0xFF); val = max(0x0,val);
1464 extern void rept_task(
void);
1465 DEBUG_MSG(
"You defined REPT_TASK: you have to define rept_task(void)!");
1467 DEBUG_MSG(
"You did not define REPT_TASK: rept_task(void) will not have any effect");
1474 #if EBOARD_SHIFT_REGISTER > 0x0 1481 #if EBOARD_CHECK_PINS > 0x0 1485 #if EBOARD_COPY_AND_PASTE > 0x0 1488 pinMode(idx,OUTPUT);
1490 digitalWrite(idx,val);
1497 #if EBOARD_CHECK_PINS > 0x0 1499 #if defined (__AVR_ATmega2560__) 1500 else if (idx<0||idx>0xF){
1502 else if (idx<0||idx>0x7){
1504 #if EBOARD_DEBUG_MODE > 0x0 1511 #if EBOARD_COPY_AND_PASTE > 0x0 1516 return((dig)? digitalRead(idx) : analogRead(idx));
1519 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0) 1524 #if defined(__AVR_ATmega2560__) 1525 ServoCds55(
int CS=53);
1527 ServoCds55(
int CS=10);
1530 void WritePos(
int ID,
int Pos);
1531 void write(
int ID,
int Pos);
1532 inline void setVelocity(
int velocity);
1533 inline void setPoslimit(
int posLimit);
1534 void SetServoLimit(
int ID,
int upperLimit);
1535 void SetMotormode(
int ID,
int velocity);
1536 void SetID(
int ID,
int newID);
1538 byte sendWait (
const byte what);
1540 int upperLimit_temp;
1543 ServoCds55::ServoCds55 (
int CS):cs(CS) {
1544 velocity_temp = 150;
1545 upperLimit_temp = 300;
1547 void ServoCds55::begin() {
1549 digitalWrite(cs,HIGH);
1553 byte ServoCds55::sendWait (
const byte what) {
1555 delayMicroseconds (20);
1558 void ServoCds55::setVelocity(
int velocity){
1559 velocity_temp = velocity;
1561 void ServoCds55::setPoslimit(
int posLimit){
1562 upperLimit_temp = posLimit;
1564 void ServoCds55::write(
int ID,
int Pos){
1565 SetServoLimit(ID,upperLimit_temp);
1568 void ServoCds55::WritePos(
int ID,
int Pos){
1569 int PosB = (Pos>>8 & 0xff);
1570 int PosS = (Pos & 0xff);
1571 int velocityB = (velocity_temp>>8 & 0xff);
1572 int velocityS = (velocity_temp & 0xff);
1573 digitalWrite(cs, LOW);
1574 sendWait (
'p'); sendWait (ID);
1575 sendWait (PosB); sendWait (PosS);
1576 sendWait (velocityB); sendWait (velocityS);
1577 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
1578 digitalWrite(cs, HIGH);
1581 void ServoCds55::SetServoLimit(
int ID,
int upperLimit_temp){
1582 int upperLimitB = (upperLimit_temp>>8 & 0xff);
1583 int upperLimitS = (upperLimit_temp & 0xff);
1584 digitalWrite(cs, LOW);
1585 sendWait (
's'); sendWait (ID);
1586 sendWait (upperLimitB); sendWait (upperLimitS);
1587 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
1588 digitalWrite(cs, HIGH);
1591 void ServoCds55::SetMotormode(
int ID,
int velocity){
1592 int velocityB = (velocity>>8 & 0xff);
1593 int velocityS = (velocity & 0xff);
1594 digitalWrite(cs, LOW);
1595 sendWait (
'm'); sendWait (ID);
1596 sendWait (velocityB); sendWait (velocityS);
1597 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
1598 digitalWrite(cs, HIGH);
1601 void ServoCds55::SetID(
int ID,
int newID){
1602 digitalWrite(cs, LOW);
1603 sendWait (
'i'); sendWait (ID);
1605 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
1606 digitalWrite(cs, HIGH);
1609 void ServoCds55::Reset(
int ID){
1610 digitalWrite(cs, LOW);
1611 sendWait (
'r'); sendWait (ID);
1612 sendWait (
'\t'); sendWait (
'\r'); sendWait (
'\n');
1613 digitalWrite(cs, HIGH);
1620 #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0 1626 #if EBOARD_USE_UTILITY > 0x0 or defined(__AVR_ATmega2560__) //won't shrink space... just speed things up 1628 inline void led(
int idx,
bool state);
1630 inline void ledOn(
int idx);
1632 inline void ledOff(
int idx);
1638 #if EBOARD_USE_UTILITY > 0x0 1645 inline void motor(uint8_t
id,int16_t val);
1659 inline void sleep(uint16_t t);
1661 inline void msleep(uint16_t t);
1667 inline void reset(
void);
1671 #if defined(__AVR_ATmega2560__) 1677 #elif EBOARD_USE_UTILITY > 0x0 1684 #if EBOARD_USE_UTILITY > 0x0 1690 else if(
id>0&&
id<3&&(val>-0 && val < 1024)) {
_servoHandler.write((
id-1),(val *600/1023 - 300));}
1694 #if EBOARD_USE_RESET > 0x0 1695 wdt_enable(WDTO_15MS);
1709 #define DIGITAL_IN 0x0 1711 #define DIGITAL_IN_INV 0x1 1713 #define DIGITAL_IN_PULLUP 0x2 1715 #define DIGITAL_IN_PULLUP_INV 0x3 1717 #define DIGITAL_OUT 0x4 1719 #define DIGITAL_OUT_INV 0x5 1721 #define DIGITAL_OUT_LOW 0x6 1723 #define DIGITAL_OUT_HIGH 0x7 1725 #define ANALOG_IN_8_BIT 0x8 1727 #define ANALOG_IN_10_BIT 0x9 1729 #define ANALOG_IN_MEAN_8_BIT 0xA 1731 #define ANALOG_IN_MEAN_10_BIT 0xB 1733 #define COUNTER_8_BIT 0xC 1735 #define COUNTER_16_BIT 0xD 1737 #define COUNTER_RISE_8_BIT 0xE 1739 #define COUNTER_RISE_16_BIT 0xF 1741 #define PWM_SLOW 0x8 1743 #define PWM_FAST 0x9 1745 #define FREQ_LOW 0xA 1747 #define FREQ_HIGH 0xB 1749 #define COUNTER_B_DIR 0xC 1751 #define COUNTER_B_DIR_PULLUP 0xD 1753 #define COUNTER_MEAN_8_BIT 0xE 1755 #define COUNTER_MEAN_16_BIT 0xF 1760 #if EBOARD_USE_UTILITY > 0x0 1762 inline void read(
void);
1769 inline void write(
void);
1780 this->
A=0x0;this->
B=0x0;this->
C=0x0;
1782 #if EBOARD_USE_UTILITY > 0x0 1802 #if EBOARD_USE_UTILITY > 0x0 1814 inline void ledOff(
void);
1816 inline void ledOn(
void);
1843 #if EBOARD_USE_UTILITY > 0x0 1855 #if EBOARD_CLAMP > 0x0 1856 if(pos>1023 || speed > 1023)
return;
1858 speed = speed*600/1023 - 300;
1859 pos = pos *600/1023 - 300;
1861 if(pos>300 || speed > 300)
return;
1877 #if EBOARD_USE_UTILITY > 0x0 1888 inline void action(
void);
1900 #if EBOARD_USE_UTILITY > 0x0 1923 #if EBOARD_BLUETOOTH > 0x0 1935 inline void write(
const char*
const val);
1945 #if EBOARD_I2C > 0x0 1955 for (byte i = 1; (i < 255 && !
STOP); i++) {
1959 if(count < ret_len) ret[count] = i;
1985 #if EBOARD_LCD > 0x0 1987 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
1988 {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
1989 {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
1990 {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
1991 {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
1992 {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
1993 {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
1994 {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
1995 {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
1996 {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
1997 {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
1998 {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
1999 {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
2000 {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
2001 {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
2002 {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
2003 {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
2004 {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
2005 {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
2006 {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
2007 {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
2008 {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
2009 {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
2010 {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
2011 {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
2012 {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
2013 {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
2014 {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
2015 {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
2016 {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
2017 {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
2018 {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
2019 {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
2020 {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
2021 {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
2022 {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
2023 {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
2024 {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
2025 {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
2026 {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
2027 {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
2028 {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
2029 {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
2030 {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
2031 {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
2032 {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
2033 {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
2034 {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
2035 {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
2036 {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
2037 {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
2038 {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
2039 {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
2040 {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
2041 {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
2042 {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
2043 {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
2044 {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
2045 {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
2046 {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
2047 {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
2048 {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
2049 {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
2050 {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
2051 {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
2052 {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
2053 {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
2054 {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
2055 {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
2056 {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
2057 {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
2058 {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
2059 {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
2060 {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
2061 {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
2062 {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
2063 {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
2064 {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
2065 {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
2066 {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
2067 {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
2068 {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
2069 {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
2070 {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
2071 {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
2072 {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
2073 {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
2074 {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
2075 {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
2076 {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
2077 {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
2078 {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
2079 {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
2080 {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
2081 {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
2082 {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
2087 #define LCD_COMMAND_MODE 0x80 2089 #define LCD_DATA_MODE 0x40 2091 #define LCD_COMMAND_DISPLAY_OFF 0xAE 2093 #define LCD_COMMAND_DISPLAY_ON 0xAF 2095 #define LCD_COMMAND_BLACK_BACKGROUND 0xA6 2097 #define LCD_COMMAND_WHITE_BACKGROUND 0xA7 2099 #define LCD_COMMAND_SET_BRIGHTNESS 0x81 2101 #define LCD_PAGE_ADDRESSING 0x02 2103 #define LCD_HORIZONTAL_ADDRESSING 0x00 2106 #define LCD_COMMAND_CHARGE_PUMP_SETTING 0x8d 2108 #define LCD_COMMAND_CHARGE_PUMP_ENABLE 0x14 2111 #define LCD_WIDTH 128 2115 #define LCD_HEIGHT 64 2119 #if EBOARD_NANO == 0 2128 inline bool clear(
void);
2130 inline void print(
const char* data);
2132 inline void print(
int data);
2142 inline bool reset(
void);
2145 inline bool init(
void);
2147 inline void drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY);
2151 inline bool setCursor(byte posX = 0x0, byte posY = 0x0);
2174 #if EBOARD_NANO == 0x0 2189 return this->
init();
2193 for(byte i = 0; i < 8; i++){
2196 for (byte j = 0; j < 128; j++)
2216 if(data[i] < 32 || data[i] > 127){ i++;
continue;}
2217 for (byte j = 0; j < 8; j++){
2224 char buffer[11] =
"";
2225 itoa(data,buffer,10);
2226 this->
print(line,col,buffer);
2235 return this->
clear();
2251 return this->
clear();
2253 inline void LCD::drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY){
2257 for(
int i = 0x0; i < (hiX * 8 * hiY); i++){
2258 this->
s1Dat(pgm_read_byte(&bitmap[i]));
2259 if(++col == (hiX * 8)) {
2272 this->
s2Cmd((0x00 + (8 *posX & 0x0F)),(0x10 + ((8 * posX >> 4) & 0x0F)));
2273 this->
pX = posX; this->
pY = posY;
2274 return this->
s1Cmd(0xB0 + posY);
2278 this->
s2Cmd(0x81,val);
2306 #if EBOARD_NEO > 0x0 2311 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 2313 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 2315 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 2317 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 2319 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 2321 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 2325 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 2327 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 2329 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 2331 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 2333 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 2335 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 2337 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 2339 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 2341 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 2343 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 2345 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 2347 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 2349 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 2351 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 2353 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 2355 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 2357 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 2359 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 2361 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 2363 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 2365 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 2367 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 2369 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 2371 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 2373 #define EBOARD_NEO_800KHZ 0x0000 2375 #define EBOARD_NEO_400KHZ 0x0100 2392 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
2394 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
2410 inline int8_t
getPin(
void);
2414 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
2416 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
2440 #ifdef __AVR__ //not needed (rem?) 2442 volatile uint8_t *
port;
2449 begun(false), brightness(0),
pixels(NULL), endTime(0) {
2457 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
2459 {aOffset[0]=1;aOffset[1]=0;aOffset[2]=2;aOffset[3]=1;}
2462 if(
pin >= 0) pinMode(
pin, INPUT);
2466 pinMode(
pin, OUTPUT);
2467 digitalWrite(
pin, LOW);
2493 #if defined(ESP8266) 2495 extern "C" void ICACHE_RAM_ATTR espShow(
2496 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
2497 #elif defined(ESP32) 2498 extern "C" void espShow(
2499 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
2513 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 2515 volatile uint8_t n1, n2 = 0;
2517 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2518 if(
port == &PORTD) {
2523 if(b & 0x80) n1 = hi;
2527 "out %[port] , %[hi]" "\n\t" 2528 "mov %[n2] , %[lo]" "\n\t" 2529 "out %[port] , %[n1]" "\n\t" 2531 "sbrc %[byte] , 6" "\n\t" 2532 "mov %[n2] , %[hi]" "\n\t" 2533 "out %[port] , %[lo]" "\n\t" 2536 "out %[port] , %[hi]" "\n\t" 2537 "mov %[n1] , %[lo]" "\n\t" 2538 "out %[port] , %[n2]" "\n\t" 2540 "sbrc %[byte] , 5" "\n\t" 2541 "mov %[n1] , %[hi]" "\n\t" 2542 "out %[port] , %[lo]" "\n\t" 2545 "out %[port] , %[hi]" "\n\t" 2546 "mov %[n2] , %[lo]" "\n\t" 2547 "out %[port] , %[n1]" "\n\t" 2549 "sbrc %[byte] , 4" "\n\t" 2550 "mov %[n2] , %[hi]" "\n\t" 2551 "out %[port] , %[lo]" "\n\t" 2554 "out %[port] , %[hi]" "\n\t" 2555 "mov %[n1] , %[lo]" "\n\t" 2556 "out %[port] , %[n2]" "\n\t" 2558 "sbrc %[byte] , 3" "\n\t" 2559 "mov %[n1] , %[hi]" "\n\t" 2560 "out %[port] , %[lo]" "\n\t" 2563 "out %[port] , %[hi]" "\n\t" 2564 "mov %[n2] , %[lo]" "\n\t" 2565 "out %[port] , %[n1]" "\n\t" 2567 "sbrc %[byte] , 2" "\n\t" 2568 "mov %[n2] , %[hi]" "\n\t" 2569 "out %[port] , %[lo]" "\n\t" 2572 "out %[port] , %[hi]" "\n\t" 2573 "mov %[n1] , %[lo]" "\n\t" 2574 "out %[port] , %[n2]" "\n\t" 2576 "sbrc %[byte] , 1" "\n\t" 2577 "mov %[n1] , %[hi]" "\n\t" 2578 "out %[port] , %[lo]" "\n\t" 2581 "out %[port] , %[hi]" "\n\t" 2582 "mov %[n2] , %[lo]" "\n\t" 2583 "out %[port] , %[n1]" "\n\t" 2585 "sbrc %[byte] , 0" "\n\t" 2586 "mov %[n2] , %[hi]" "\n\t" 2587 "out %[port] , %[lo]" "\n\t" 2588 "sbiw %[count], 1" "\n\t" 2590 "out %[port] , %[hi]" "\n\t" 2591 "mov %[n1] , %[lo]" "\n\t" 2592 "out %[port] , %[n2]" "\n\t" 2593 "ld %[byte] , %a[ptr]+" "\n\t" 2594 "sbrc %[byte] , 7" "\n\t" 2595 "mov %[n1] , %[hi]" "\n\t" 2596 "out %[port] , %[lo]" "\n\t" 2602 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
2606 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2611 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2612 if(
port == &PORTB) {
2613 #endif // defined(PORTD/C/F) 2617 if(b & 0x80) n1 = hi;
2620 "out %[port] , %[hi]" "\n\t" 2621 "mov %[n2] , %[lo]" "\n\t" 2622 "out %[port] , %[n1]" "\n\t" 2624 "sbrc %[byte] , 6" "\n\t" 2625 "mov %[n2] , %[hi]" "\n\t" 2626 "out %[port] , %[lo]" "\n\t" 2628 "out %[port] , %[hi]" "\n\t" 2629 "mov %[n1] , %[lo]" "\n\t" 2630 "out %[port] , %[n2]" "\n\t" 2632 "sbrc %[byte] , 5" "\n\t" 2633 "mov %[n1] , %[hi]" "\n\t" 2634 "out %[port] , %[lo]" "\n\t" 2636 "out %[port] , %[hi]" "\n\t" 2637 "mov %[n2] , %[lo]" "\n\t" 2638 "out %[port] , %[n1]" "\n\t" 2640 "sbrc %[byte] , 4" "\n\t" 2641 "mov %[n2] , %[hi]" "\n\t" 2642 "out %[port] , %[lo]" "\n\t" 2644 "out %[port] , %[hi]" "\n\t" 2645 "mov %[n1] , %[lo]" "\n\t" 2646 "out %[port] , %[n2]" "\n\t" 2648 "sbrc %[byte] , 3" "\n\t" 2649 "mov %[n1] , %[hi]" "\n\t" 2650 "out %[port] , %[lo]" "\n\t" 2652 "out %[port] , %[hi]" "\n\t" 2653 "mov %[n2] , %[lo]" "\n\t" 2654 "out %[port] , %[n1]" "\n\t" 2656 "sbrc %[byte] , 2" "\n\t" 2657 "mov %[n2] , %[hi]" "\n\t" 2658 "out %[port] , %[lo]" "\n\t" 2660 "out %[port] , %[hi]" "\n\t" 2661 "mov %[n1] , %[lo]" "\n\t" 2662 "out %[port] , %[n2]" "\n\t" 2664 "sbrc %[byte] , 1" "\n\t" 2665 "mov %[n1] , %[hi]" "\n\t" 2666 "out %[port] , %[lo]" "\n\t" 2668 "out %[port] , %[hi]" "\n\t" 2669 "mov %[n2] , %[lo]" "\n\t" 2670 "out %[port] , %[n1]" "\n\t" 2672 "sbrc %[byte] , 0" "\n\t" 2673 "mov %[n2] , %[hi]" "\n\t" 2674 "out %[port] , %[lo]" "\n\t" 2675 "sbiw %[count], 1" "\n\t" 2676 "out %[port] , %[hi]" "\n\t" 2677 "mov %[n1] , %[lo]" "\n\t" 2678 "out %[port] , %[n2]" "\n\t" 2679 "ld %[byte] , %a[ptr]+" "\n\t" 2680 "sbrc %[byte] , 7" "\n\t" 2681 "mov %[n1] , %[hi]" "\n\t" 2682 "out %[port] , %[lo]" "\n\t" 2684 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2685 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2687 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2690 #if defined(PORTC) || defined(PORTF) 2695 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 2696 if(
port == &PORTC) {
2701 if(b & 0x80) n1 = hi;
2704 "out %[port] , %[hi]" "\n\t" 2705 "mov %[n2] , %[lo]" "\n\t" 2706 "out %[port] , %[n1]" "\n\t" 2708 "sbrc %[byte] , 6" "\n\t" 2709 "mov %[n2] , %[hi]" "\n\t" 2710 "out %[port] , %[lo]" "\n\t" 2712 "out %[port] , %[hi]" "\n\t" 2713 "mov %[n1] , %[lo]" "\n\t" 2714 "out %[port] , %[n2]" "\n\t" 2716 "sbrc %[byte] , 5" "\n\t" 2717 "mov %[n1] , %[hi]" "\n\t" 2718 "out %[port] , %[lo]" "\n\t" 2720 "out %[port] , %[hi]" "\n\t" 2721 "mov %[n2] , %[lo]" "\n\t" 2722 "out %[port] , %[n1]" "\n\t" 2724 "sbrc %[byte] , 4" "\n\t" 2725 "mov %[n2] , %[hi]" "\n\t" 2726 "out %[port] , %[lo]" "\n\t" 2728 "out %[port] , %[hi]" "\n\t" 2729 "mov %[n1] , %[lo]" "\n\t" 2730 "out %[port] , %[n2]" "\n\t" 2732 "sbrc %[byte] , 3" "\n\t" 2733 "mov %[n1] , %[hi]" "\n\t" 2734 "out %[port] , %[lo]" "\n\t" 2736 "out %[port] , %[hi]" "\n\t" 2737 "mov %[n2] , %[lo]" "\n\t" 2738 "out %[port] , %[n1]" "\n\t" 2740 "sbrc %[byte] , 2" "\n\t" 2741 "mov %[n2] , %[hi]" "\n\t" 2742 "out %[port] , %[lo]" "\n\t" 2744 "out %[port] , %[hi]" "\n\t" 2745 "mov %[n1] , %[lo]" "\n\t" 2746 "out %[port] , %[n2]" "\n\t" 2748 "sbrc %[byte] , 1" "\n\t" 2749 "mov %[n1] , %[hi]" "\n\t" 2750 "out %[port] , %[lo]" "\n\t" 2752 "out %[port] , %[hi]" "\n\t" 2753 "mov %[n2] , %[lo]" "\n\t" 2754 "out %[port] , %[n1]" "\n\t" 2756 "sbrc %[byte] , 0" "\n\t" 2757 "mov %[n2] , %[hi]" "\n\t" 2758 "out %[port] , %[lo]" "\n\t" 2759 "sbiw %[count], 1" "\n\t" 2760 "out %[port] , %[hi]" "\n\t" 2761 "mov %[n1] , %[lo]" "\n\t" 2762 "out %[port] , %[n2]" "\n\t" 2763 "ld %[byte] , %a[ptr]+" "\n\t" 2764 "sbrc %[byte] , 7" "\n\t" 2765 "mov %[n1] , %[hi]" "\n\t" 2766 "out %[port] , %[lo]" "\n\t" 2768 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2769 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2771 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 2779 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 2780 if(
port == &PORTF) {
2781 #endif // defined(PORTD/B/C) 2785 if(b & 0x80) n1 = hi;
2788 "out %[port] , %[hi]" "\n\t" 2789 "mov %[n2] , %[lo]" "\n\t" 2790 "out %[port] , %[n1]" "\n\t" 2792 "sbrc %[byte] , 6" "\n\t" 2793 "mov %[n2] , %[hi]" "\n\t" 2794 "out %[port] , %[lo]" "\n\t" 2796 "out %[port] , %[hi]" "\n\t" 2797 "mov %[n1] , %[lo]" "\n\t" 2798 "out %[port] , %[n2]" "\n\t" 2800 "sbrc %[byte] , 5" "\n\t" 2801 "mov %[n1] , %[hi]" "\n\t" 2802 "out %[port] , %[lo]" "\n\t" 2804 "out %[port] , %[hi]" "\n\t" 2805 "mov %[n2] , %[lo]" "\n\t" 2806 "out %[port] , %[n1]" "\n\t" 2808 "sbrc %[byte] , 4" "\n\t" 2809 "mov %[n2] , %[hi]" "\n\t" 2810 "out %[port] , %[lo]" "\n\t" 2812 "out %[port] , %[hi]" "\n\t" 2813 "mov %[n1] , %[lo]" "\n\t" 2814 "out %[port] , %[n2]" "\n\t" 2816 "sbrc %[byte] , 3" "\n\t" 2817 "mov %[n1] , %[hi]" "\n\t" 2818 "out %[port] , %[lo]" "\n\t" 2820 "out %[port] , %[hi]" "\n\t" 2821 "mov %[n2] , %[lo]" "\n\t" 2822 "out %[port] , %[n1]" "\n\t" 2824 "sbrc %[byte] , 2" "\n\t" 2825 "mov %[n2] , %[hi]" "\n\t" 2826 "out %[port] , %[lo]" "\n\t" 2828 "out %[port] , %[hi]" "\n\t" 2829 "mov %[n1] , %[lo]" "\n\t" 2830 "out %[port] , %[n2]" "\n\t" 2832 "sbrc %[byte] , 1" "\n\t" 2833 "mov %[n1] , %[hi]" "\n\t" 2834 "out %[port] , %[lo]" "\n\t" 2836 "out %[port] , %[hi]" "\n\t" 2837 "mov %[n2] , %[lo]" "\n\t" 2838 "out %[port] , %[n1]" "\n\t" 2840 "sbrc %[byte] , 0" "\n\t" 2841 "mov %[n2] , %[hi]" "\n\t" 2842 "out %[port] , %[lo]" "\n\t" 2843 "sbiw %[count], 1" "\n\t" 2844 "out %[port] , %[hi]" "\n\t" 2845 "mov %[n1] , %[lo]" "\n\t" 2846 "out %[port] , %[n2]" "\n\t" 2847 "ld %[byte] , %a[ptr]+" "\n\t" 2848 "sbrc %[byte] , 7" "\n\t" 2849 "mov %[n1] , %[hi]" "\n\t" 2850 "out %[port] , %[lo]" "\n\t" 2852 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2853 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2855 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 2857 #endif // defined(PORTD/B/C) 2858 #endif // defined(PORTF) 2860 volatile uint8_t next, bit;
2867 "st %a[port], %[hi]" "\n\t" 2868 "sbrc %[byte] , 7" "\n\t" 2869 "mov %[next], %[hi]" "\n\t" 2870 "st %a[port], %[next]" "\n\t" 2871 "mov %[next] , %[lo]" "\n\t" 2873 "breq nextbyte20" "\n\t" 2874 "rol %[byte]" "\n\t" 2875 "st %a[port], %[lo]" "\n\t" 2879 "rjmp head20" "\n\t" 2880 "nextbyte20:" "\n\t" 2881 "st %a[port], %[lo]" "\n\t" 2883 "ldi %[bit] , 8" "\n\t" 2884 "ld %[byte] , %a[ptr]+" "\n\t" 2885 "sbiw %[count], 1" "\n\t" 2896 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 2898 volatile uint8_t next;
2901 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2902 if(
port == &PORTD) {
2907 if(b & 0x80) next = hi;
2910 "out %[port], %[hi]" "\n\t" 2911 "rcall bitTimeD" "\n\t" 2912 "out %[port], %[hi]" "\n\t" 2913 "rcall bitTimeD" "\n\t" 2914 "out %[port], %[hi]" "\n\t" 2915 "rcall bitTimeD" "\n\t" 2916 "out %[port], %[hi]" "\n\t" 2917 "rcall bitTimeD" "\n\t" 2918 "out %[port], %[hi]" "\n\t" 2919 "rcall bitTimeD" "\n\t" 2920 "out %[port], %[hi]" "\n\t" 2921 "rcall bitTimeD" "\n\t" 2922 "out %[port], %[hi]" "\n\t" 2923 "rcall bitTimeD" "\n\t" 2925 "out %[port] , %[hi]" "\n\t" 2927 "ld %[byte] , %a[ptr]+" "\n\t" 2928 "out %[port] , %[next]" "\n\t" 2929 "mov %[next] , %[lo]" "\n\t" 2930 "sbrc %[byte] , 7" "\n\t" 2931 "mov %[next] , %[hi]" "\n\t" 2933 "out %[port] , %[lo]" "\n\t" 2934 "sbiw %[count], 1" "\n\t" 2938 "out %[port], %[next]" "\n\t" 2939 "mov %[next], %[lo]" "\n\t" 2940 "rol %[byte]" "\n\t" 2941 "sbrc %[byte], 7" "\n\t" 2942 "mov %[next], %[hi]" "\n\t" 2944 "out %[port], %[lo]" "\n\t" 2950 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
2954 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2959 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2960 if(
port == &PORTB) {
2965 if(b & 0x80) next = hi;
2968 "out %[port], %[hi]" "\n\t" 2969 "rcall bitTimeB" "\n\t" 2970 "out %[port], %[hi]" "\n\t" 2971 "rcall bitTimeB" "\n\t" 2972 "out %[port], %[hi]" "\n\t" 2973 "rcall bitTimeB" "\n\t" 2974 "out %[port], %[hi]" "\n\t" 2975 "rcall bitTimeB" "\n\t" 2976 "out %[port], %[hi]" "\n\t" 2977 "rcall bitTimeB" "\n\t" 2978 "out %[port], %[hi]" "\n\t" 2979 "rcall bitTimeB" "\n\t" 2980 "out %[port], %[hi]" "\n\t" 2981 "rcall bitTimeB" "\n\t" 2982 "out %[port] , %[hi]" "\n\t" 2984 "ld %[byte] , %a[ptr]+" "\n\t" 2985 "out %[port] , %[next]" "\n\t" 2986 "mov %[next] , %[lo]" "\n\t" 2987 "sbrc %[byte] , 7" "\n\t" 2988 "mov %[next] , %[hi]" "\n\t" 2990 "out %[port] , %[lo]" "\n\t" 2991 "sbiw %[count], 1" "\n\t" 2995 "out %[port], %[next]" "\n\t" 2996 "mov %[next], %[lo]" "\n\t" 2997 "rol %[byte]" "\n\t" 2998 "sbrc %[byte], 7" "\n\t" 2999 "mov %[next], %[hi]" "\n\t" 3001 "out %[port], %[lo]" "\n\t" 3004 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
3005 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
3007 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 3010 #if defined(PORTC) || defined(PORTF) 3015 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 3016 if(
port == &PORTC) {
3021 if(b & 0x80) next = hi;
3024 "out %[port], %[hi]" "\n\t" 3025 "rcall bitTimeC" "\n\t" 3026 "out %[port], %[hi]" "\n\t" 3027 "rcall bitTimeC" "\n\t" 3028 "out %[port], %[hi]" "\n\t" 3029 "rcall bitTimeC" "\n\t" 3030 "out %[port], %[hi]" "\n\t" 3031 "rcall bitTimeC" "\n\t" 3032 "out %[port], %[hi]" "\n\t" 3033 "rcall bitTimeC" "\n\t" 3034 "out %[port], %[hi]" "\n\t" 3035 "rcall bitTimeC" "\n\t" 3036 "out %[port], %[hi]" "\n\t" 3037 "rcall bitTimeC" "\n\t" 3038 "out %[port] , %[hi]" "\n\t" 3040 "ld %[byte] , %a[ptr]+" "\n\t" 3041 "out %[port] , %[next]" "\n\t" 3042 "mov %[next] , %[lo]" "\n\t" 3043 "sbrc %[byte] , 7" "\n\t" 3044 "mov %[next] , %[hi]" "\n\t" 3046 "out %[port] , %[lo]" "\n\t" 3047 "sbiw %[count], 1" "\n\t" 3051 "out %[port], %[next]" "\n\t" 3052 "mov %[next], %[lo]" "\n\t" 3053 "rol %[byte]" "\n\t" 3054 "sbrc %[byte], 7" "\n\t" 3055 "mov %[next], %[hi]" "\n\t" 3057 "out %[port], %[lo]" "\n\t" 3060 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
3061 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
3063 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 3071 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 3072 if(
port == &PORTF) {
3077 if(b & 0x80) next = hi;
3080 "out %[port], %[hi]" "\n\t" 3081 "rcall bitTimeC" "\n\t" 3082 "out %[port], %[hi]" "\n\t" 3083 "rcall bitTimeC" "\n\t" 3084 "out %[port], %[hi]" "\n\t" 3085 "rcall bitTimeC" "\n\t" 3086 "out %[port], %[hi]" "\n\t" 3087 "rcall bitTimeC" "\n\t" 3088 "out %[port], %[hi]" "\n\t" 3089 "rcall bitTimeC" "\n\t" 3090 "out %[port], %[hi]" "\n\t" 3091 "rcall bitTimeC" "\n\t" 3092 "out %[port], %[hi]" "\n\t" 3093 "rcall bitTimeC" "\n\t" 3094 "out %[port] , %[hi]" "\n\t" 3096 "ld %[byte] , %a[ptr]+" "\n\t" 3097 "out %[port] , %[next]" "\n\t" 3098 "mov %[next] , %[lo]" "\n\t" 3099 "sbrc %[byte] , 7" "\n\t" 3100 "mov %[next] , %[hi]" "\n\t" 3102 "out %[port] , %[lo]" "\n\t" 3103 "sbiw %[count], 1" "\n\t" 3107 "out %[port], %[next]" "\n\t" 3108 "mov %[next], %[lo]" "\n\t" 3109 "rol %[byte]" "\n\t" 3110 "sbrc %[byte], 7" "\n\t" 3111 "mov %[next], %[hi]" "\n\t" 3113 "out %[port], %[lo]" "\n\t" 3116 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
3117 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
3119 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 3124 volatile uint8_t next, bit;
3131 "st %a[port], %[hi]" "\n\t" 3132 "sbrc %[byte] , 7" "\n\t" 3133 "mov %[next], %[hi]" "\n\t" 3135 "st %a[port], %[next]" "\n\t" 3140 "st %a[port], %[lo]" "\n\t" 3143 "breq nextbyte30" "\n\t" 3144 "rol %[byte]" "\n\t" 3148 "rjmp head30" "\n\t" 3149 "nextbyte30:" "\n\t" 3151 "ldi %[bit] , 8" "\n\t" 3152 "ld %[byte] , %a[ptr]+" "\n\t" 3153 "sbiw %[count], 1" "\n\t" 3164 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 3166 volatile uint8_t next, bit;
3173 "st %a[port], %[hi]" "\n\t" 3174 "sbrc %[byte], 7" "\n\t" 3175 "mov %[next], %[hi]" "\n\t" 3177 "st %a[port], %[next]" "\n\t" 3178 "mov %[next] , %[lo]" "\n\t" 3179 "breq nextbyte20" "\n\t" 3180 "rol %[byte]" "\n\t" 3183 "st %a[port], %[lo]" "\n\t" 3186 "rjmp head20" "\n\t" 3187 "nextbyte20:" "\n\t" 3188 "ldi %[bit] , 8" "\n\t" 3189 "ld %[byte] , %a[ptr]+" "\n\t" 3190 "st %a[port], %[lo]" "\n\t" 3192 "sbiw %[count], 1" "\n\t" 3203 volatile uint8_t next, bit;
3210 "st %a[port], %[hi]" "\n\t" 3211 "sbrc %[byte] , 7" "\n\t" 3212 "mov %[next] , %[hi]" "\n\t" 3215 "st %a[port], %[next]" "\n\t" 3221 "st %a[port], %[lo]" "\n\t" 3223 "mov %[next] , %[lo]" "\n\t" 3225 "breq nextbyte40" "\n\t" 3226 "rol %[byte]" "\n\t" 3233 "rjmp head40" "\n\t" 3234 "nextbyte40:" "\n\t" 3235 "ldi %[bit] , 8" "\n\t" 3236 "ld %[byte] , %a[ptr]+" "\n\t" 3238 "st %a[port], %[lo]" "\n\t" 3240 "sbiw %[count], 1" "\n\t" 3252 #error "CPU SPEED NOT SUPPORTED" 3254 #elif defined(__arm__) 3255 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 3256 #define CYCLES_800_T0H (F_CPU / 4000000) 3257 #define CYCLES_800_T1H (F_CPU / 1250000) 3258 #define CYCLES_800 (F_CPU / 800000) 3259 #define CYCLES_400_T0H (F_CPU / 2000000) 3260 #define CYCLES_400_T1H (F_CPU / 833333) 3261 #define CYCLES_400 (F_CPU / 400000) 3264 volatile uint8_t *
set = portSetRegister(
pin),
3265 *clr = portClearRegister(
pin);
3267 ARM_DEMCR |= ARM_DEMCR_TRCENA;
3268 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
3270 cyc = ARM_DWT_CYCCNT + CYCLES_800;
3273 for(mask = 0x80; mask; mask >>= 1) {
3274 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
3275 cyc = ARM_DWT_CYCCNT;
3278 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
3280 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
3285 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
3287 cyc = ARM_DWT_CYCCNT + CYCLES_400;
3290 for(mask = 0x80; mask; mask >>= 1) {
3291 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
3292 cyc = ARM_DWT_CYCCNT;
3295 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
3297 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
3302 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
3305 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 3307 #elif defined(ESP8266) || defined(ESP32) 3309 #elif defined(__ARDUINO_ARC__) 3311 #define NOPx7 { __builtin_arc_nop(); \ 3312 __builtin_arc_nop(); __builtin_arc_nop(); \ 3313 __builtin_arc_nop(); __builtin_arc_nop(); \ 3314 __builtin_arc_nop(); __builtin_arc_nop(); } 3315 PinDescription *pindesc = &g_APinDescription[
pin];
3317 register uint8_t *p =
pixels;
3318 register uint32_t currByte = (uint32_t) (*p);
3319 register uint32_t currBit = 0x80 & currByte;
3320 register uint32_t bitCounter = 0;
3321 register uint32_t first = 1;
3322 if (pindesc->ulGPIOType == SS_GPIO) {
3323 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
3324 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
3325 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
3326 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
3334 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
3341 __builtin_arc_nop();
3343 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
3346 if(bitCounter >= 8) {
3348 currByte = (uint32_t) (*++p);
3350 currBit = 0x80 & currByte;
3353 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
3354 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
3355 uint32_t reg_val = MMIO_REG_VAL(reg);
3356 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
3357 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
3364 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
3368 __builtin_arc_nop();
3373 MMIO_REG_VAL(reg) = reg_bit_low;
3376 if(bitCounter >= 8) {
3378 currByte = (uint32_t) (*++p);
3380 currBit = 0x80 & currByte;
3385 #error Architecture not supported 3395 digitalWrite(p, LOW);
3398 port = portOutputRegister(digitalPinToPort(p));
3399 pinMask = digitalPinToBitMask(p);
3403 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
3423 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
3446 r = (uint8_t)(c >> 16),
3447 g = (uint8_t)(c >> 8),
3458 uint8_t w = (uint8_t)(c >> 24);
3467 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
3469 uint32_t
NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
3470 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
3482 return ((uint32_t)p[
aOffset[0]] << 16) |
3483 ((uint32_t)p[
aOffset[1]] << 8) |
3494 return ((uint32_t)p[
aOffset[3]] << 24) |
3495 ((uint32_t)p[
aOffset[0]] << 16) |
3496 ((uint32_t)p[
aOffset[1]] << 8) |
3508 uint8_t newBrightness = b + 1;
3514 if(oldBrightness == 0) scale = 0;
3515 else if(b == 255) scale = 65535 / oldBrightness;
3516 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
3517 for(uint16_t i=0; i<
numBytes; i++) {
3519 *ptr++ = (c * scale) >> 8;
3547 #if EBOARD_NANO > 0x0 || defined(DOC) 3549 #if EBOARD_GUESSPATH > 0x0 3554 typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t;
3555 #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 3556 #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 3557 #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 3558 #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 3559 #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 3560 #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 3561 #define INVALID_SERVO 255 // flag indicating an invalid servo index 3564 uint8_t isActive :1 ;
3568 volatile unsigned int ticks;
3573 uint8_t attach(
int pin);
3574 uint8_t attach(
int pin,
int min,
int max);
3576 void write(
int value);
3577 void writeMicroseconds(
int value);
3579 int readMicroseconds();
3580 inline bool attached();
3586 #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 3587 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds 3588 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 3590 static servo_t servos[MAX_SERVOS];
3591 static volatile int8_t Channel[_Nbr_16timers ];
3592 uint8_t ServoCount = 0;
3594 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo 3595 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer 3596 #define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel 3597 #define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel 3598 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo 3599 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo 3600 static inline void handle_interrupts(timer16_Sequence_t timer,
volatile uint16_t *TCNTn,
volatile uint16_t* OCRnA)
3602 if( Channel[timer] < 0 )
3605 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive ==
true )
3606 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW);
3609 if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
3610 *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
3611 if(SERVO(timer,Channel[timer]).Pin.isActive ==
true)
3612 digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH);
3616 if( ((
unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )
3617 *OCRnA = (
unsigned int)usToTicks(REFRESH_INTERVAL);
3619 *OCRnA = *TCNTn + 4;
3620 Channel[timer] = -1;
3623 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform 3625 #if defined(_useTimer1) 3626 SIGNAL (TIMER1_COMPA_vect)
3628 handle_interrupts(_timer1, &TCNT1, &OCR1A);
3631 #elif defined WIRING 3633 #if defined(_useTimer1) 3634 void Timer1Service()
3636 handle_interrupts(_timer1, &TCNT1, &OCR1A);
3640 static void initISR(timer16_Sequence_t timer) {
3641 if(timer == _timer1) {
3645 TIFR1 |= _BV(OCF1A);
3646 TIMSK1 |= _BV(OCIE1A) ;
3648 timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
3652 static void finISR(timer16_Sequence_t timer) {
3653 #if defined WIRING // Wiring 3654 if(timer == _timer1) {
3655 TIMSK &= ~_BV(OCIE1A) ;
3656 timerDetach(TIMER1OUTCOMPAREA_INT);
3658 else if(timer == _timer3) {
3659 ETIMSK &= ~_BV(OCIE3A);
3660 timerDetach(TIMER3OUTCOMPAREA_INT);
3667 static boolean isTimerActive(timer16_Sequence_t timer) {
3669 for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
3670 if(SERVO(timer,channel).Pin.isActive ==
true)
3676 if( ServoCount < MAX_SERVOS) {
3677 this->servoIndex = ServoCount++;
3678 servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);
3681 this->servoIndex = INVALID_SERVO ;
3683 uint8_t Servo::attach(
int pin) {
3684 return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
3686 uint8_t Servo::attach(
int pin,
int min,
int max) {
3687 if(this->servoIndex < MAX_SERVOS ) {
3688 pinMode( pin, OUTPUT) ;
3689 servos[this->servoIndex].Pin.nbr = pin;
3691 this->min = (MIN_PULSE_WIDTH - min)/4;
3692 this->max = (MAX_PULSE_WIDTH - max)/4;
3694 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
3695 if(isTimerActive(timer) ==
false)
3697 servos[this->servoIndex].Pin.isActive =
true;
3699 return this->servoIndex ;
3701 void Servo::detach() {
3702 servos[this->servoIndex].Pin.isActive =
false;
3703 timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
3704 if(isTimerActive(timer) ==
false) {
3708 void Servo::write(
int value) {
3709 if(value < MIN_PULSE_WIDTH)
3711 if(value < 0) value = 0;
3712 if(value > 180) value = 180;
3713 value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
3715 this->writeMicroseconds(value);
3717 void Servo::writeMicroseconds(
int value) {
3719 byte channel = this->servoIndex;
3720 if( (channel < MAX_SERVOS) )
3722 if( value < SERVO_MIN() )
3723 value = SERVO_MIN();
3724 else if( value > SERVO_MAX() )
3725 value = SERVO_MAX();
3726 value = value - TRIM_DURATION;
3727 value = usToTicks(value);
3728 uint8_t oldSREG = SREG;
3730 servos[channel].ticks = value;
3734 inline int Servo::read()
3736 return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
3738 int Servo::readMicroseconds() {
3739 unsigned int pulsewidth;
3740 if( this->servoIndex != INVALID_SERVO )
3741 pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ;
3746 inline bool Servo::attached() {
3747 return servos[this->servoIndex].Pin.isActive ;
3752 #if EBOARD_COPY_AND_PASTE > 0x0 3762 #if EBOARD_NANO > 0x0 3763 Servo mainMotor,steerMotor;
3767 ISR(TIMER2_OVF_vect) {
3775 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
3784 #if EBOARD_NANO == 0x0 3788 #if EBOARD_DEBUG_MODE > 0x0 3792 #if (EBOARD_NANO == 0x0) || defined(REPT_TASK) 3794 TIMSK2 &= ~(1<<TOIE2);
3795 TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
3796 TCCR2B &= ~(1<<WGM22);
3798 TIMSK2 &= ~(1<<OCIE2A);
3799 TCCR2B |= (1<<CS22);
3800 TCCR2B &= ~((1<<CS21) | (1<<CS20));
3801 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
3802 TIMSK2 |= (1<<TOIE2);
3805 #if EBOARD_BLUETOOTH > 0x0 3806 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 3807 Serial1.begin(38400);
3813 #if EBOARD_I2C > 0x0 3816 #if EBOARD_SHIFT_REGISTER > 0x0 3822 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0) 3825 #if EBOARD_NANO > 0x0 3828 #if EBOARD_DEBUG_MODE > 0x0 3829 Serial.println(
"Initializing main driving motor (3s)");
3831 mainMotor.write(90);
3833 #if EBOARD_DEBUG_MODE > 0x0 3834 Serial.println(
"Initializing of main driving motor completed");
3837 #if EBOARD_DEBUG_MODE > 0x0 3839 Serial.println(
"fin");
3845 #if EBOARD_NANO > 0x0 3846 mainMotor.write(90);
3849 #if EBOARD_NANO == 0x0 3862 #if EBOARD_NANO > 0x0 || defined(DOC) 3869 if(spe < 0 || spe > 180)
return;
3870 mainMotor.write(spe);
3873 if(ang < 0 || ang > 180)
return;
3874 steerMotor.write(ang);
3879 #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process 3881 #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...