3 #pragma GCC diagnostic push 4 #pragma GCC diagnostic ignored "-Wall" 5 #pragma GCC diagnostic ignored "-Wextra" 9 #define EBOARD_VERSION "3.0c" 10 #define VALUE_TO_STRING(x) #x 11 #define VALUE(x) VALUE_TO_STRING(x) 12 #ifndef PREPROCESS_DEBUG 13 #define PREPROCESS_DEBUG 0 15 #define PPERFORM_PRAGMA(str) _Pragma(#str) 16 #if PREPROCESS_DEBUG == 1 17 #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str)) 18 #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str)) 20 #define DEBUG_MSG(str) ; 21 #define MACRO_MSG(mac,str) ; 23 DEBUG_MSG(
"If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
24 DEBUG_MSG(
"You are using eBoard-header v3.0c written by EagleoutIce");
29 #ifndef EBOARD_HEADER_GUARD 30 #define EBOARD_HEADER_GUARD 32 DEBUG_MSG(
"Documentation macro SET => Full doc features enabled");
35 #define EBOARD_I2C 0x1 37 #define EBOARD_LCD 0x1 39 #define EBOARD_SHIFT_REGISTER 0x1 41 #define EBOARD_BLUETOOTH 0x1 45 #define __AVR_ATmega2560__ 47 #define __AVR_ATmega328P__ 49 #define EBOARD_NEO 0x1 55 #include <avr/pgmspace.h> 59 #ifndef EBOARD_GUESSPATH 60 DEBUG_MSG(
"You are using Guesspath! Necessary libraries for eBoard will be included automatically");
62 #define EBOARD_GUESSPATH 0x1 64 DEBUG_MSG(
"You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
66 #if defined(ARDUINO) //general platform-check [No tab] 68 #define main eVirtual_main //main has a different meaning^^ 69 #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D 74 #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__)) 75 #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!" 77 #if defined(__AVR_ATmega2560__) 78 DEBUG_MSG(
"Building for Arduino Mega with ATmega2560");
80 #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS 82 DEBUG_MSG(
"Building for Arduino Uno or Nano with ATmega328P");
83 #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS 86 #include <avr/interrupt.h> 87 #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0 93 #define TWI_FREQ 100000L 95 # ifndef TWI_BUFFER_LENGTH 96 #define TWI_BUFFER_LENGTH 32 105 #include <avr/interrupt.h> 106 #include <compat/twi.h> 108 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 111 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 113 #include "pins_arduino.h" 133 digitalWrite(SDA, 1);
134 digitalWrite(SCL, 1);
137 TWBR = ((F_CPU /
TWI_FREQ) - 16) / 2;
138 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
143 uint8_t
twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop) {
157 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
160 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
167 uint8_t
twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop) {
182 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
185 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
188 else if (
twi_error == TW_MT_SLA_NACK)
return 2;
189 else if (
twi_error == TW_MT_DATA_NACK)
return 3;
208 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
210 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
214 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
215 while(TWCR & _BV(TWSTO))
continue;
219 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
238 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
247 case TW_MT_DATA_NACK:
261 case TW_MR_DATA_NACK:
266 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
274 case TW_SR_GCALL_ACK:
275 case TW_SR_ARB_LOST_SLA_ACK:
276 case TW_SR_ARB_LOST_GCALL_ACK:
282 case TW_SR_GCALL_DATA_ACK:
295 case TW_SR_DATA_NACK:
296 case TW_SR_GCALL_DATA_NACK:
300 case TW_ST_ARB_LOST_SLA_ACK:
314 case TW_ST_DATA_NACK:
315 case TW_ST_LAST_DATA:
328 #include <inttypes.h> 330 #define BUFFER_LENGTH 32 365 void begin(uint8_t address);
367 inline void begin(
int address);
377 inline uint8_t
requestFrom(uint8_t address, uint8_t quantity);
379 uint8_t
requestFrom(uint8_t address , uint8_t quantity, uint8_t sendStop);
381 inline uint8_t
requestFrom(
int address,
int quantity);
383 inline uint8_t
requestFrom(
int address,
int quantity,
int sendStop);
385 virtual size_t write(uint8_t data);
387 virtual size_t write(
const uint8_t *data,
size_t quantity);
391 virtual int read(
void);
393 virtual int peek(
void);
397 void onRequest(
void (*
function)(
void) );
405 #include <inttypes.h> 434 begin((uint8_t)address);
446 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
449 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)
true);
452 return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
489 for(
size_t i = 0; i < quantity; ++i) {
522 for(uint8_t i = 0; i < numBytes; ++i) {
548 #ifndef EBOARD_USE_SPI 549 #define EBOARD_USE_SPI 0x1 551 #if EBOARD_USE_SPI > 0x0 554 #define _SPI_H_INCLUDED 557 #define SPI_CLOCK_DIV4 0x00 559 #define SPI_CLOCK_DIV16 0x01 561 #define SPI_CLOCK_DIV64 0x02 563 #define SPI_CLOCK_DIV128 0x03 565 #define SPI_CLOCK_DIV2 0x04 567 #define SPI_CLOCK_DIV8 0x05 569 #define SPI_CLOCK_DIV32 0x06 571 #define SPI_MODE0 0x00 573 #define SPI_MODE1 0x04 575 #define SPI_MODE2 0x08 577 #define SPI_MODE3 0x0C 579 #define SPI_MODE_MASK 0x0C 581 #define SPI_CLOCK_MASK 0x03 583 #define SPI_2XCLOCK_MASK 0x01 588 inline static byte
transfer(byte _data);
594 static void begin(
void);
596 inline static void end(
void);
608 while (!(SPSR & _BV(SPIF)));
614 digitalWrite(SS, HIGH);
618 pinMode(SCK, OUTPUT);
619 pinMode(MOSI, OUTPUT);
623 if(bitOrder == LSBFIRST) SPCR |= _BV(DORD);
624 else SPCR &= ~(_BV(DORD));
636 #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0) 637 #include <avr/pgmspace.h> 644 DEBUG_MSG(
"You defined IGNORE_SIZE: byte will be used");
647 DEBUG_MSG(
"You did not define IGNORE_SIZE: int will be used");
651 #ifndef EBOARD_DEBUG_MODE 652 #define EBOARD_DEBUG_MODE 0x1 654 #if EBOARD_DEBUG_MODE > 0x0 661 #define EBOARD_NANO 0x0 663 #if EBOARD_NANO > 0x0 664 #ifndef EBOARD_NANO_STEER 665 #define EBOARD_NANO_STEER 12 667 #ifndef EBOARD_NANO_MAIN 668 #define EBOARD_NANO_MAIN 13 671 #if PREPROCESS_DEBUG > 0x1 672 #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR") 673 #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR") 679 #ifndef EBOARD_CHECK_PINS 680 #define EBOARD_CHECK_PINS 0x1 682 #if EBOARD_CHECK_PINS > 0x0 687 #ifndef EBOARD_SHIFT_REGISTER 689 #define EBOARD_SHIFT_REGISTER 0x0 691 #if EBOARD_SHIFT_REGISTER > 0x0 697 #ifndef EBOARD_CHECK_PINS_PWM 698 #define EBOARD_CHECK_PINS_PWM 0x1 700 #if EBOARD_CHECK_PINS_PWM > 0x0 706 #ifndef EBOARD_DEBUG_SPEED 707 #define EBOARD_DEBUG_SPEED 9600 709 #if PREPROCESS_DEBUG > 0x0 710 #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED)) 713 #ifndef EBOARD_SPI_SERVO_MAX 714 #define EBOARD_SPI_SERVO_MAX 2 716 #if PREPROCESS_DEBUG > 0x0 717 #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX)) 720 #ifndef EBOARD_USE_UTILITY 721 #define EBOARD_USE_UTILITY 0x1 723 #if EBOARD_USE_UTILITY > 0x0 729 #define EBOARD_COPY_AND_PASTE 0x1 731 #ifndef EBOARD_PWM_SPE 732 #define EBOARD_PWM_SPE 1 734 #if PREPROCESS_DEBUG > 0x0 735 #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s") 739 #define EBOARD_I2C 0x0 //disabled by default 741 #ifndef EBOARD_BLUETOOTH 743 #define EBOARD_BLUETOOTH 0x0 745 #if EBOARD_BLUETOOTH > 0x0 752 #define EBOARD_CLAMP 0x1 754 #if EBOARD_CLAMP > 0x0 761 #define EBOARD_NEO 0x0 769 #ifndef EBOARD_USE_RESET 770 #define EBOARD_USE_RESET 0x1 772 #if EBOARD_USE_RESET > 0x0 779 #ifndef PIN_BLUETOOTH_STATE 780 #if defined(__AVR_ATmega2560__) 781 #define PIN_BLUETOOTH_STATE 0x13 // 19 783 #define PIN_BLUETOOTH_STATE 0x2 787 #ifndef PIN_BLUETOOTH_RX 788 #if defined(__AVR_ATmega2560__) 789 #define PIN_BLUETOOTH_RX 0x13 // 19 791 #define PIN_BLUETOOTH_RX 0x2 795 #ifndef PIN_BLUETOOTH_TX 796 #if defined(__AVR_ATmega2560__) 797 #define PIN_BLUETOOTH_TX 0x12 // 18 799 #define PIN_BLUETOOTH_TX 0x3 803 #ifndef PIN_MOTOR_DIR 804 #define PIN_MOTOR_DIR 0x4 807 #ifndef PIN_MOTOR_SPE 808 #define PIN_MOTOR_SPE 0x5 811 #ifndef PIN_SHIFT_CLK 812 #define PIN_SHIFT_CLK 0x6 815 #ifndef PIN_SHIFT_DAT 816 #define PIN_SHIFT_DAT 0x7 819 #ifndef PIN_SHIFT_LAT 820 #define PIN_SHIFT_LAT 0x8 830 #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__) 831 #if EBOARD_GUESSPATH > 0x0 833 #define _SS_MAX_RX_BUFF 64 // RX buffer size 835 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 878 void setTX(uint8_t transmitPin);
880 void setRX(uint8_t receivePin);
882 static inline void tunedDelay(uint16_t delay);
886 SoftwareSerial(uint8_t receivePin, uint8_t transmitPin,
bool inverse_logic =
false);
890 void begin(
long speed);
894 inline void end(
void);
902 virtual size_t write(uint8_t byte);
904 virtual int read(
void);
908 virtual void flush(
void);
925 #if EBOARD_DEBUG_MODE > 0x0 927 #define _DEBUG_PIN1 11 928 #define _DEBUG_PIN2 13 937 #if F_CPU == 16000000 940 { 115200, 1, 17, 17, 12, },
941 { 57600, 10, 37, 37, 33, },
942 { 38400, 25, 57, 57, 54, },
943 { 31250, 31, 70, 70, 68, },
944 { 28800, 34, 77, 77, 74, },
945 { 19200, 54, 117, 117, 114, },
946 { 14400, 74, 156, 156, 153, },
947 { 9600, 114, 236, 236, 233, },
948 { 4800, 233, 474, 474, 471, },
949 { 2400, 471, 950, 950, 947, },
950 { 1200, 947, 1902, 1902, 1899, },
951 { 600, 1902, 3804, 3804, 3800, },
952 { 300, 3804, 7617, 7617, 7614, },
954 const int XMIT_START_ADJUSTMENT = 5;
955 #elif F_CPU == 8000000 958 { 115200, 1, 5, 5, 3, },
959 { 57600, 1, 15, 15, 13, },
960 { 38400, 2, 25, 26, 23, },
961 { 31250, 7, 32, 33, 29, },
962 { 28800, 11, 35, 35, 32, },
963 { 19200, 20, 55, 55, 52, },
964 { 14400, 30, 75, 75, 72, },
965 { 9600, 50, 114, 114, 112, },
966 { 4800, 110, 233, 233, 230, },
967 { 2400, 229, 472, 472, 469, },
968 { 1200, 467, 948, 948, 945, },
969 { 600, 948, 1895, 1895, 1890, },
970 { 300, 1895, 3805, 3805, 3802, },
972 const int XMIT_START_ADJUSTMENT = 4;
973 #elif F_CPU == 20000000 976 { 115200, 3, 21, 21, 18, },
977 { 57600, 20, 43, 43, 41, },
978 { 38400, 37, 73, 73, 70, },
979 { 31250, 45, 89, 89, 88, },
980 { 28800, 46, 98, 98, 95, },
981 { 19200, 71, 148, 148, 145, },
982 { 14400, 96, 197, 197, 194, },
983 { 9600, 146, 297, 297, 294, },
984 { 4800, 296, 595, 595, 592, },
985 { 2400, 592, 1189, 1189, 1186, },
986 { 1200, 1187, 2379, 2379, 2376, },
987 { 600, 2379, 4759, 4759, 4755, },
988 { 300, 4759, 9523, 9523, 9520, },
990 const int XMIT_START_ADJUSTMENT = 6;
992 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors 998 #if EBOARD_DEBUG_MODE > 0x0 1001 volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
1002 uint8_t val = *pport;
1005 *pport = val | digitalPinToBitMask(pin);
1013 asm volatile(
"sbiw %0, 0x01 \n\t" 1015 "cpi %A0, 0xFF \n\t" 1018 :
"+r" (delay),
"+a" (tmp)
1026 uint8_t oldSREG = SREG;
1036 #if GCC_VERSION < 40302 1052 #if EBOARD_DEBUG_MODE > 0x0 1056 for (uint8_t i=0x1; i; i <<= 1)
1059 #if EBOARD_DEBUG_MODE > 0x0 1070 #if EBOARD_DEBUG_MODE > 0x0 1080 #if EBOARD_DEBUG_MODE > 0x0 1081 #if _DEBUG // for scope: pulse pin as overflow indictator 1088 #if GCC_VERSION < 40302 1102 if (pin_state == LOW)
1115 #if defined(PCINT0_vect) 1120 #if defined(PCINT1_vect) 1125 #if defined(PCINT2_vect) 1130 #if defined(PCINT3_vect) 1136 _rx_delay_centering(0),
1137 _rx_delay_intrabit(0),
1138 _rx_delay_stopbit(0),
1140 _buffer_overflow(false),
1141 _inverse_logic(inverse_logic) {
1149 pinMode(tx, OUTPUT);
1150 digitalWrite(tx, HIGH);
1152 uint8_t port = digitalPinToPort(tx);
1158 digitalWrite(rx, HIGH);
1161 uint8_t port = digitalPinToPort(rx);
1166 for (
unsigned i=0; i<
sizeof(table)/
sizeof(table[0]); ++i) {
1167 long baud = pgm_read_dword(&table[i].baud);
1168 if (baud == speed) {
1172 _tx_delay = pgm_read_word(&table[i].tx_delay);
1212 uint8_t oldSREG = SREG;
1217 for (byte mask = 0x01; mask; mask <<= 1) {
1227 for (byte mask = 0x01; mask; mask <<= 1) {
1243 uint8_t oldSREG = SREG;
1260 #if EBOARD_DEBUG_MODE > 0x0 1262 #define __ASSERT_USE_STDERR 1265 void __assert (
const char *__func,
const char *__file,
optVAL_t __lineno,
const char *__sexp);
1268 Serial.print(
"Error with: "); Serial.print(__func);
1269 Serial.print(
" in "); Serial.print(__file);
1270 Serial.print(
" >>");
1271 Serial.println(__sexp);
1272 if(strcmp(__func,
"checkIdx")==0){
1273 Serial.println(
" This happens if an out of bounds exception");
1274 Serial.println(
" has occured. Following pins shouldn't be used:");
1277 Serial.println(
" : Used for Bluetooth communication");
1278 Serial.print(
" D");Serial.print(
PIN_MOTOR_DIR);Serial.print(
"&");
1280 Serial.println(
" : Used for main motor control");
1281 #if EBOARD_USE_SPI > 0x0 1282 Serial.print(
" D10-13");
1283 Serial.println(
": Used for smart-servo-shield");
1285 }
else if (strcmp(__func,
"readPin")==0){
1286 Serial.println(
"You've tried to access an analogPin that isn't present on the board you're currently working on!");
1297 #if EBOARD_DEBUG_MODE > 0x0 1298 assert(idx>=0x0 && idx <
PIN_MAX);
1303 #if EBOARD_COPY_AND_PASTE > 0x0 1304 #if EBOARD_CHECK_PINS_PWM > 0x0 1310 for (count = 0; x; count++)
1316 #if EBOARD_CHECK_PINS > 0x0 1318 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 1320 #elif defined(__AVR_ATmega2560__) 1324 #if defined(__AVR_ATmega328P__) && not defined(__AVR_ATmega2560__) 1326 #elif defined(__AVR_ATmega2560__) 1334 return (mode == OUTPUT)? ((
pin_out & (1<<idx))>0x0):((
pin_in & (1<<idx))>0x0);
1342 #if EBOARD_CHECK_PINS > 0x0 1357 #if EBOARD_BLUETOOTH > 0x0 1359 inline char readVal(
char oF =
'.');
1363 template <
typename T>
1364 inline void writeVal(
const T& val);
1369 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1376 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1377 return ((Serial1.available())?(Serial1.read()):(oF));
1382 template<
typename T>
1384 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 1391 #if PIN_BLUETOOTH_RX != PIN_BLUETOOTH_STATE 1399 #if EBOARD_SHIFT_REGISTER > 0x0 1427 val = min(val,0xFF); val = max(0x0,val);
1438 #if EBOARD_SHIFT_REGISTER > 0x0 1445 #if EBOARD_CHECK_PINS > 0x0 1449 #if EBOARD_COPY_AND_PASTE > 0x0 1452 pinMode(idx,OUTPUT);
1454 digitalWrite(idx,val);
1461 #if EBOARD_CHECK_PINS > 0x0 1463 #if defined (__AVR_ATmega2560__) 1464 else if (idx<0||idx>0xF){
1466 else if (idx<0||idx>0x7){
1468 #if EBOARD_DEBUG_MODE > 0x0 1475 #if EBOARD_COPY_AND_PASTE > 0x0 1480 return((dig)? digitalRead(idx) : analogRead(idx));
1483 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0) 1488 #if defined(__AVR_ATmega2560__) 1494 void WritePos(
int ID,
int Pos);
1495 void write(
int ID,
int Pos);
1496 inline void setVelocity(
int velocity);
1497 inline void setPoslimit(
int posLimit);
1498 void rotate(
int ID,
int velocity);
1499 void SetServoLimit(
int ID,
int upperLimit);
1500 void SetMotormode(
int ID,
int velocity);
1501 void SetID(
int ID,
int newID);
1503 byte sendWait (
const byte what);
1514 digitalWrite(
cs,HIGH);
1520 delayMicroseconds (20);
1539 int PosB = (Pos>>8 & 0xff);
1540 int PosS = (Pos & 0xff);
1543 digitalWrite(
cs, LOW);
1548 digitalWrite(
cs, HIGH);
1554 digitalWrite(
cs, LOW);
1558 digitalWrite(
cs, HIGH);
1562 int velocityB = (velocity>>8 & 0xff);
1563 int velocityS = (velocity & 0xff);
1564 digitalWrite(
cs, LOW);
1568 digitalWrite(
cs, HIGH);
1572 digitalWrite(
cs, LOW);
1576 digitalWrite(
cs, HIGH);
1580 digitalWrite(
cs, LOW);
1583 digitalWrite(
cs, HIGH);
1590 #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0 1596 #if EBOARD_USE_UTILITY > 0x0 or defined(__AVR_ATmega2560__) //won't shrink space... just speed things up 1598 inline void led(
int idx,
bool state);
1600 inline void ledOn(
int idx);
1602 inline void ledOff(
int idx);
1608 #if EBOARD_USE_UTILITY > 0x0 1615 inline void motor(uint8_t
id,int16_t val);
1629 inline void sleep(uint16_t t);
1631 inline void msleep(uint16_t t);
1637 inline void reset(
void);
1641 #if defined(__AVR_ATmega2560__) 1647 #elif EBOARD_USE_UTILITY > 0x0 1654 #if EBOARD_USE_UTILITY > 0x0 1660 else if(
id>0&&
id<3&&(val>-0 && val < 1024)) {
_servoHandler.
write((
id-1),(val *600/1023 - 300));}
1664 #if EBOARD_USE_RESET > 0x0 1665 wdt_enable(WDTO_15MS);
1679 #define DIGITAL_IN 0x0 1681 #define DIGITAL_IN_INV 0x1 1683 #define DIGITAL_IN_PULLUP 0x2 1685 #define DIGITAL_IN_PULLUP_INV 0x3 1687 #define DIGITAL_OUT 0x4 1689 #define DIGITAL_OUT_INV 0x5 1691 #define DIGITAL_OUT_LOW 0x6 1693 #define DIGITAL_OUT_HIGH 0x7 1695 #define ANALOG_IN_8_BIT 0x8 1697 #define ANALOG_IN_10_BIT 0x9 1699 #define ANALOG_IN_MEAN_8_BIT 0xA 1701 #define ANALOG_IN_MEAN_10_BIT 0xB 1703 #define COUNTER_8_BIT 0xC 1705 #define COUNTER_16_BIT 0xD 1707 #define COUNTER_RISE_8_BIT 0xE 1709 #define COUNTER_RISE_16_BIT 0xF 1711 #define PWM_SLOW 0x8 1713 #define PWM_FAST 0x9 1715 #define FREQ_LOW 0xA 1717 #define FREQ_HIGH 0xB 1719 #define COUNTER_B_DIR 0xC 1721 #define COUNTER_B_DIR_PULLUP 0xD 1723 #define COUNTER_MEAN_8_BIT 0xE 1725 #define COUNTER_MEAN_16_BIT 0xF 1730 #if EBOARD_USE_UTILITY > 0x0 1732 inline void read(
void);
1739 inline void write(
void);
1750 this->
A=0x0;this->
B=0x0;this->
C=0x0;
1752 #if EBOARD_USE_UTILITY > 0x0 1772 #if EBOARD_USE_UTILITY > 0x0 1784 inline void ledOff(
void);
1786 inline void ledOn(
void);
1813 #if EBOARD_USE_UTILITY > 0x0 1825 #if EBOARD_CLAMP > 0x0 1826 if(pos>1023 || speed > 1023)
return;
1828 speed = speed*600/1023 - 300;
1829 pos = pos *600/1023 - 300;
1831 if(pos>300 || speed > 300)
return;
1847 #if EBOARD_USE_UTILITY > 0x0 1858 inline void action(
void);
1870 #if EBOARD_USE_UTILITY > 0x0 1893 #if EBOARD_BLUETOOTH > 0x0 1905 inline void write(
const char*
const val);
1915 #if EBOARD_I2C > 0x0 1925 for (byte i = 1; (i < 255 && !
STOP); i++) {
1929 if(count < ret_len) ret[count] = i;
1955 #if EBOARD_LCD > 0x0 1957 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
1958 {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00},
1959 {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00},
1960 {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00},
1961 {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00},
1962 {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00},
1963 {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00},
1964 {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00},
1965 {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00},
1966 {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00},
1967 {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00},
1968 {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00},
1969 {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00},
1970 {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00},
1971 {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00},
1972 {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00},
1973 {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00},
1974 {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},
1975 {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00},
1976 {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00},
1977 {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00},
1978 {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00},
1979 {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00},
1980 {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00},
1981 {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00},
1982 {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00},
1983 {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00},
1984 {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00},
1985 {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00},
1986 {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00},
1987 {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00},
1988 {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00},
1989 {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00},
1990 {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00},
1991 {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00},
1992 {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00},
1993 {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00},
1994 {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00},
1995 {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00},
1996 {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00},
1997 {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00},
1998 {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00},
1999 {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00},
2000 {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00},
2001 {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00},
2002 {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00},
2003 {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00},
2004 {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00},
2005 {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00},
2006 {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00},
2007 {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00},
2008 {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},
2009 {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00},
2010 {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00},
2011 {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00},
2012 {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00},
2013 {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00},
2014 {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00},
2015 {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00},
2016 {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00},
2017 {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00},
2018 {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00},
2019 {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00},
2020 {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
2021 {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00},
2022 {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00},
2023 {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00},
2024 {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00},
2025 {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00},
2026 {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00},
2027 {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00},
2028 {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00},
2029 {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00},
2030 {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00},
2031 {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00},
2032 {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00},
2033 {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00},
2034 {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00},
2035 {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00},
2036 {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00},
2037 {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00},
2038 {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00},
2039 {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00},
2040 {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00},
2041 {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00},
2042 {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00},
2043 {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00},
2044 {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00},
2045 {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00},
2046 {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00},
2047 {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00},
2048 {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00},
2049 {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00},
2050 {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00},
2051 {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00},
2052 {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00}
2057 #define LCD_COMMAND_MODE 0x80 2059 #define LCD_DATA_MODE 0x40 2061 #define LCD_COMMAND_DISPLAY_OFF 0xAE 2063 #define LCD_COMMAND_DISPLAY_ON 0xAF 2065 #define LCD_COMMAND_BLACK_BACKGROUND 0xA6 2067 #define LCD_COMMAND_WHITE_BACKGROUND 0xA7 2069 #define LCD_COMMAND_SET_BRIGHTNESS 0x81 2071 #define LCD_PAGE_ADDRESSING 0x02 2073 #define LCD_HORIZONTAL_ADDRESSING 0x00 2076 #define LCD_COMMAND_CHARGE_PUMP_SETTING 0x8d 2078 #define LCD_COMMAND_CHARGE_PUMP_ENABLE 0x14 2081 #define LCD_WIDTH 128 2085 #define LCD_HEIGHT 64 2089 #if EBOARD_NANO == 0 2098 inline bool clear(
void);
2100 inline void print(
const char* data);
2102 inline void print(
int data);
2112 inline bool reset(
void);
2115 inline bool init(
void);
2117 inline void drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY);
2121 inline bool setCursor(byte posX = 0x0, byte posY = 0x0);
2144 #if EBOARD_NANO == 0x0 2159 return this->
init();
2163 for(byte i = 0; i < 8; i++){
2166 for (byte j = 0; j < 128; j++)
2186 if(data[i] < 32 || data[i] > 127){ i++;
continue;}
2187 for (byte j = 0; j < 8; j++){
2194 char buffer[11] =
"";
2195 itoa(data,buffer,10);
2196 this->
print(line,col,buffer);
2205 return this->
clear();
2221 return this->
clear();
2223 inline void LCD::drawBitmap(
const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY){
2227 for(
int i = 0x0; i < (hiX * 8 * hiY); i++){
2228 this->
s1Dat(pgm_read_byte(&bitmap[i]));
2229 if(++col == (hiX * 8)) {
2242 this->
s2Cmd((0x00 + (8 *posX & 0x0F)),(0x10 + ((8 * posX >> 4) & 0x0F)));
2243 this->
pX = posX; this->
pY = posY;
2244 return this->
s1Cmd(0xB0 + posY);
2248 this->
s2Cmd(0x81,val);
2276 #if EBOARD_NEO > 0x0 2281 #define EBOARD_NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) 2283 #define EBOARD_NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) 2285 #define EBOARD_NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) 2287 #define EBOARD_NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) 2289 #define EBOARD_NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) 2291 #define EBOARD_NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) 2295 #define EBOARD_NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) 2297 #define EBOARD_NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) 2299 #define EBOARD_NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) 2301 #define EBOARD_NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) 2303 #define EBOARD_NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) 2305 #define EBOARD_NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) 2307 #define EBOARD_NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) 2309 #define EBOARD_NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) 2311 #define EBOARD_NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) 2313 #define EBOARD_NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) 2315 #define EBOARD_NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) 2317 #define EBOARD_NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) 2319 #define EBOARD_NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) 2321 #define EBOARD_NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) 2323 #define EBOARD_NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) 2325 #define EBOARD_NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) 2327 #define EBOARD_NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) 2329 #define EBOARD_NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) 2331 #define EBOARD_NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) 2333 #define EBOARD_NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) 2335 #define EBOARD_NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) 2337 #define EBOARD_NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) 2339 #define EBOARD_NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) 2341 #define EBOARD_NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) 2343 #define EBOARD_NEO_800KHZ 0x0000 2345 #define EBOARD_NEO_400KHZ 0x0100 2362 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
2364 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
2380 uint8_t
sine8(uint8_t x)
const;
2382 uint8_t
gamma8(uint8_t x)
const;
2384 inline int8_t
getPin(
void);
2388 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b);
2390 static inline uint32_t
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
2414 #ifdef __AVR__ //not needed (rem?) 2423 begun(false), brightness(0),
pixels(NULL), endTime(0) {
2431 begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
pixels(NULL),
2436 if(
pin >= 0) pinMode(
pin, INPUT);
2440 pinMode(
pin, OUTPUT);
2441 digitalWrite(
pin, LOW);
2467 #if defined(ESP8266) 2469 extern "C" void ICACHE_RAM_ATTR espShow(
2470 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
2471 #elif defined(ESP32) 2472 extern "C" void espShow(
2473 uint8_t pin, uint8_t *
pixels, uint32_t numBytes, uint8_t type);
2487 #if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL) 2489 volatile uint8_t n1, n2 = 0;
2491 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2492 if(
port == &PORTD) {
2497 if(b & 0x80) n1 = hi;
2501 "out %[port] , %[hi]" "\n\t" 2502 "mov %[n2] , %[lo]" "\n\t" 2503 "out %[port] , %[n1]" "\n\t" 2505 "sbrc %[byte] , 6" "\n\t" 2506 "mov %[n2] , %[hi]" "\n\t" 2507 "out %[port] , %[lo]" "\n\t" 2510 "out %[port] , %[hi]" "\n\t" 2511 "mov %[n1] , %[lo]" "\n\t" 2512 "out %[port] , %[n2]" "\n\t" 2514 "sbrc %[byte] , 5" "\n\t" 2515 "mov %[n1] , %[hi]" "\n\t" 2516 "out %[port] , %[lo]" "\n\t" 2519 "out %[port] , %[hi]" "\n\t" 2520 "mov %[n2] , %[lo]" "\n\t" 2521 "out %[port] , %[n1]" "\n\t" 2523 "sbrc %[byte] , 4" "\n\t" 2524 "mov %[n2] , %[hi]" "\n\t" 2525 "out %[port] , %[lo]" "\n\t" 2528 "out %[port] , %[hi]" "\n\t" 2529 "mov %[n1] , %[lo]" "\n\t" 2530 "out %[port] , %[n2]" "\n\t" 2532 "sbrc %[byte] , 3" "\n\t" 2533 "mov %[n1] , %[hi]" "\n\t" 2534 "out %[port] , %[lo]" "\n\t" 2537 "out %[port] , %[hi]" "\n\t" 2538 "mov %[n2] , %[lo]" "\n\t" 2539 "out %[port] , %[n1]" "\n\t" 2541 "sbrc %[byte] , 2" "\n\t" 2542 "mov %[n2] , %[hi]" "\n\t" 2543 "out %[port] , %[lo]" "\n\t" 2546 "out %[port] , %[hi]" "\n\t" 2547 "mov %[n1] , %[lo]" "\n\t" 2548 "out %[port] , %[n2]" "\n\t" 2550 "sbrc %[byte] , 1" "\n\t" 2551 "mov %[n1] , %[hi]" "\n\t" 2552 "out %[port] , %[lo]" "\n\t" 2555 "out %[port] , %[hi]" "\n\t" 2556 "mov %[n2] , %[lo]" "\n\t" 2557 "out %[port] , %[n1]" "\n\t" 2559 "sbrc %[byte] , 0" "\n\t" 2560 "mov %[n2] , %[hi]" "\n\t" 2561 "out %[port] , %[lo]" "\n\t" 2562 "sbiw %[count], 1" "\n\t" 2564 "out %[port] , %[hi]" "\n\t" 2565 "mov %[n1] , %[lo]" "\n\t" 2566 "out %[port] , %[n2]" "\n\t" 2567 "ld %[byte] , %a[ptr]+" "\n\t" 2568 "sbrc %[byte] , 7" "\n\t" 2569 "mov %[n1] , %[hi]" "\n\t" 2570 "out %[port] , %[lo]" "\n\t" 2576 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
2580 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2585 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2586 if(
port == &PORTB) {
2587 #endif // defined(PORTD/C/F) 2591 if(b & 0x80) n1 = hi;
2594 "out %[port] , %[hi]" "\n\t" 2595 "mov %[n2] , %[lo]" "\n\t" 2596 "out %[port] , %[n1]" "\n\t" 2598 "sbrc %[byte] , 6" "\n\t" 2599 "mov %[n2] , %[hi]" "\n\t" 2600 "out %[port] , %[lo]" "\n\t" 2602 "out %[port] , %[hi]" "\n\t" 2603 "mov %[n1] , %[lo]" "\n\t" 2604 "out %[port] , %[n2]" "\n\t" 2606 "sbrc %[byte] , 5" "\n\t" 2607 "mov %[n1] , %[hi]" "\n\t" 2608 "out %[port] , %[lo]" "\n\t" 2610 "out %[port] , %[hi]" "\n\t" 2611 "mov %[n2] , %[lo]" "\n\t" 2612 "out %[port] , %[n1]" "\n\t" 2614 "sbrc %[byte] , 4" "\n\t" 2615 "mov %[n2] , %[hi]" "\n\t" 2616 "out %[port] , %[lo]" "\n\t" 2618 "out %[port] , %[hi]" "\n\t" 2619 "mov %[n1] , %[lo]" "\n\t" 2620 "out %[port] , %[n2]" "\n\t" 2622 "sbrc %[byte] , 3" "\n\t" 2623 "mov %[n1] , %[hi]" "\n\t" 2624 "out %[port] , %[lo]" "\n\t" 2626 "out %[port] , %[hi]" "\n\t" 2627 "mov %[n2] , %[lo]" "\n\t" 2628 "out %[port] , %[n1]" "\n\t" 2630 "sbrc %[byte] , 2" "\n\t" 2631 "mov %[n2] , %[hi]" "\n\t" 2632 "out %[port] , %[lo]" "\n\t" 2634 "out %[port] , %[hi]" "\n\t" 2635 "mov %[n1] , %[lo]" "\n\t" 2636 "out %[port] , %[n2]" "\n\t" 2638 "sbrc %[byte] , 1" "\n\t" 2639 "mov %[n1] , %[hi]" "\n\t" 2640 "out %[port] , %[lo]" "\n\t" 2642 "out %[port] , %[hi]" "\n\t" 2643 "mov %[n2] , %[lo]" "\n\t" 2644 "out %[port] , %[n1]" "\n\t" 2646 "sbrc %[byte] , 0" "\n\t" 2647 "mov %[n2] , %[hi]" "\n\t" 2648 "out %[port] , %[lo]" "\n\t" 2649 "sbiw %[count], 1" "\n\t" 2650 "out %[port] , %[hi]" "\n\t" 2651 "mov %[n1] , %[lo]" "\n\t" 2652 "out %[port] , %[n2]" "\n\t" 2653 "ld %[byte] , %a[ptr]+" "\n\t" 2654 "sbrc %[byte] , 7" "\n\t" 2655 "mov %[n1] , %[hi]" "\n\t" 2656 "out %[port] , %[lo]" "\n\t" 2658 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2659 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2661 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2664 #if defined(PORTC) || defined(PORTF) 2669 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 2670 if(
port == &PORTC) {
2675 if(b & 0x80) n1 = hi;
2678 "out %[port] , %[hi]" "\n\t" 2679 "mov %[n2] , %[lo]" "\n\t" 2680 "out %[port] , %[n1]" "\n\t" 2682 "sbrc %[byte] , 6" "\n\t" 2683 "mov %[n2] , %[hi]" "\n\t" 2684 "out %[port] , %[lo]" "\n\t" 2686 "out %[port] , %[hi]" "\n\t" 2687 "mov %[n1] , %[lo]" "\n\t" 2688 "out %[port] , %[n2]" "\n\t" 2690 "sbrc %[byte] , 5" "\n\t" 2691 "mov %[n1] , %[hi]" "\n\t" 2692 "out %[port] , %[lo]" "\n\t" 2694 "out %[port] , %[hi]" "\n\t" 2695 "mov %[n2] , %[lo]" "\n\t" 2696 "out %[port] , %[n1]" "\n\t" 2698 "sbrc %[byte] , 4" "\n\t" 2699 "mov %[n2] , %[hi]" "\n\t" 2700 "out %[port] , %[lo]" "\n\t" 2702 "out %[port] , %[hi]" "\n\t" 2703 "mov %[n1] , %[lo]" "\n\t" 2704 "out %[port] , %[n2]" "\n\t" 2706 "sbrc %[byte] , 3" "\n\t" 2707 "mov %[n1] , %[hi]" "\n\t" 2708 "out %[port] , %[lo]" "\n\t" 2710 "out %[port] , %[hi]" "\n\t" 2711 "mov %[n2] , %[lo]" "\n\t" 2712 "out %[port] , %[n1]" "\n\t" 2714 "sbrc %[byte] , 2" "\n\t" 2715 "mov %[n2] , %[hi]" "\n\t" 2716 "out %[port] , %[lo]" "\n\t" 2718 "out %[port] , %[hi]" "\n\t" 2719 "mov %[n1] , %[lo]" "\n\t" 2720 "out %[port] , %[n2]" "\n\t" 2722 "sbrc %[byte] , 1" "\n\t" 2723 "mov %[n1] , %[hi]" "\n\t" 2724 "out %[port] , %[lo]" "\n\t" 2726 "out %[port] , %[hi]" "\n\t" 2727 "mov %[n2] , %[lo]" "\n\t" 2728 "out %[port] , %[n1]" "\n\t" 2730 "sbrc %[byte] , 0" "\n\t" 2731 "mov %[n2] , %[hi]" "\n\t" 2732 "out %[port] , %[lo]" "\n\t" 2733 "sbiw %[count], 1" "\n\t" 2734 "out %[port] , %[hi]" "\n\t" 2735 "mov %[n1] , %[lo]" "\n\t" 2736 "out %[port] , %[n2]" "\n\t" 2737 "ld %[byte] , %a[ptr]+" "\n\t" 2738 "sbrc %[byte] , 7" "\n\t" 2739 "mov %[n1] , %[hi]" "\n\t" 2740 "out %[port] , %[lo]" "\n\t" 2742 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2743 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2745 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 2753 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 2754 if(
port == &PORTF) {
2755 #endif // defined(PORTD/B/C) 2759 if(b & 0x80) n1 = hi;
2762 "out %[port] , %[hi]" "\n\t" 2763 "mov %[n2] , %[lo]" "\n\t" 2764 "out %[port] , %[n1]" "\n\t" 2766 "sbrc %[byte] , 6" "\n\t" 2767 "mov %[n2] , %[hi]" "\n\t" 2768 "out %[port] , %[lo]" "\n\t" 2770 "out %[port] , %[hi]" "\n\t" 2771 "mov %[n1] , %[lo]" "\n\t" 2772 "out %[port] , %[n2]" "\n\t" 2774 "sbrc %[byte] , 5" "\n\t" 2775 "mov %[n1] , %[hi]" "\n\t" 2776 "out %[port] , %[lo]" "\n\t" 2778 "out %[port] , %[hi]" "\n\t" 2779 "mov %[n2] , %[lo]" "\n\t" 2780 "out %[port] , %[n1]" "\n\t" 2782 "sbrc %[byte] , 4" "\n\t" 2783 "mov %[n2] , %[hi]" "\n\t" 2784 "out %[port] , %[lo]" "\n\t" 2786 "out %[port] , %[hi]" "\n\t" 2787 "mov %[n1] , %[lo]" "\n\t" 2788 "out %[port] , %[n2]" "\n\t" 2790 "sbrc %[byte] , 3" "\n\t" 2791 "mov %[n1] , %[hi]" "\n\t" 2792 "out %[port] , %[lo]" "\n\t" 2794 "out %[port] , %[hi]" "\n\t" 2795 "mov %[n2] , %[lo]" "\n\t" 2796 "out %[port] , %[n1]" "\n\t" 2798 "sbrc %[byte] , 2" "\n\t" 2799 "mov %[n2] , %[hi]" "\n\t" 2800 "out %[port] , %[lo]" "\n\t" 2802 "out %[port] , %[hi]" "\n\t" 2803 "mov %[n1] , %[lo]" "\n\t" 2804 "out %[port] , %[n2]" "\n\t" 2806 "sbrc %[byte] , 1" "\n\t" 2807 "mov %[n1] , %[hi]" "\n\t" 2808 "out %[port] , %[lo]" "\n\t" 2810 "out %[port] , %[hi]" "\n\t" 2811 "mov %[n2] , %[lo]" "\n\t" 2812 "out %[port] , %[n1]" "\n\t" 2814 "sbrc %[byte] , 0" "\n\t" 2815 "mov %[n2] , %[hi]" "\n\t" 2816 "out %[port] , %[lo]" "\n\t" 2817 "sbiw %[count], 1" "\n\t" 2818 "out %[port] , %[hi]" "\n\t" 2819 "mov %[n1] , %[lo]" "\n\t" 2820 "out %[port] , %[n2]" "\n\t" 2821 "ld %[byte] , %a[ptr]+" "\n\t" 2822 "sbrc %[byte] , 7" "\n\t" 2823 "mov %[n1] , %[hi]" "\n\t" 2824 "out %[port] , %[lo]" "\n\t" 2826 : [byte]
"+r" (b), [n1]
"+r" (n1), [n2]
"+r" (n2), [count]
"+w" (i)
2827 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2829 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 2831 #endif // defined(PORTD/B/C) 2832 #endif // defined(PORTF) 2834 volatile uint8_t next, bit;
2841 "st %a[port], %[hi]" "\n\t" 2842 "sbrc %[byte] , 7" "\n\t" 2843 "mov %[next], %[hi]" "\n\t" 2844 "st %a[port], %[next]" "\n\t" 2845 "mov %[next] , %[lo]" "\n\t" 2847 "breq nextbyte20" "\n\t" 2848 "rol %[byte]" "\n\t" 2849 "st %a[port], %[lo]" "\n\t" 2853 "rjmp head20" "\n\t" 2854 "nextbyte20:" "\n\t" 2855 "st %a[port], %[lo]" "\n\t" 2857 "ldi %[bit] , 8" "\n\t" 2858 "ld %[byte] , %a[ptr]+" "\n\t" 2859 "sbiw %[count], 1" "\n\t" 2870 #elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL) 2872 volatile uint8_t next;
2875 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2876 if(
port == &PORTD) {
2881 if(b & 0x80) next = hi;
2884 "out %[port], %[hi]" "\n\t" 2885 "rcall bitTimeD" "\n\t" 2886 "out %[port], %[hi]" "\n\t" 2887 "rcall bitTimeD" "\n\t" 2888 "out %[port], %[hi]" "\n\t" 2889 "rcall bitTimeD" "\n\t" 2890 "out %[port], %[hi]" "\n\t" 2891 "rcall bitTimeD" "\n\t" 2892 "out %[port], %[hi]" "\n\t" 2893 "rcall bitTimeD" "\n\t" 2894 "out %[port], %[hi]" "\n\t" 2895 "rcall bitTimeD" "\n\t" 2896 "out %[port], %[hi]" "\n\t" 2897 "rcall bitTimeD" "\n\t" 2899 "out %[port] , %[hi]" "\n\t" 2901 "ld %[byte] , %a[ptr]+" "\n\t" 2902 "out %[port] , %[next]" "\n\t" 2903 "mov %[next] , %[lo]" "\n\t" 2904 "sbrc %[byte] , 7" "\n\t" 2905 "mov %[next] , %[hi]" "\n\t" 2907 "out %[port] , %[lo]" "\n\t" 2908 "sbiw %[count], 1" "\n\t" 2912 "out %[port], %[next]" "\n\t" 2913 "mov %[next], %[lo]" "\n\t" 2914 "rol %[byte]" "\n\t" 2915 "sbrc %[byte], 7" "\n\t" 2916 "mov %[next], %[hi]" "\n\t" 2918 "out %[port], %[lo]" "\n\t" 2924 : [
port]
"I" (_SFR_IO_ADDR(PORTD)),
2928 #if defined(PORTB) || defined(PORTC) || defined(PORTF) 2933 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2934 if(
port == &PORTB) {
2939 if(b & 0x80) next = hi;
2942 "out %[port], %[hi]" "\n\t" 2943 "rcall bitTimeB" "\n\t" 2944 "out %[port], %[hi]" "\n\t" 2945 "rcall bitTimeB" "\n\t" 2946 "out %[port], %[hi]" "\n\t" 2947 "rcall bitTimeB" "\n\t" 2948 "out %[port], %[hi]" "\n\t" 2949 "rcall bitTimeB" "\n\t" 2950 "out %[port], %[hi]" "\n\t" 2951 "rcall bitTimeB" "\n\t" 2952 "out %[port], %[hi]" "\n\t" 2953 "rcall bitTimeB" "\n\t" 2954 "out %[port], %[hi]" "\n\t" 2955 "rcall bitTimeB" "\n\t" 2956 "out %[port] , %[hi]" "\n\t" 2958 "ld %[byte] , %a[ptr]+" "\n\t" 2959 "out %[port] , %[next]" "\n\t" 2960 "mov %[next] , %[lo]" "\n\t" 2961 "sbrc %[byte] , 7" "\n\t" 2962 "mov %[next] , %[hi]" "\n\t" 2964 "out %[port] , %[lo]" "\n\t" 2965 "sbiw %[count], 1" "\n\t" 2969 "out %[port], %[next]" "\n\t" 2970 "mov %[next], %[lo]" "\n\t" 2971 "rol %[byte]" "\n\t" 2972 "sbrc %[byte], 7" "\n\t" 2973 "mov %[next], %[hi]" "\n\t" 2975 "out %[port], %[lo]" "\n\t" 2978 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
2979 : [
port]
"I" (_SFR_IO_ADDR(PORTB)), [ptr]
"e" (ptr), [hi]
"r" (hi),
2981 #if defined(PORTD) || defined(PORTC) || defined(PORTF) 2984 #if defined(PORTC) || defined(PORTF) 2989 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 2990 if(
port == &PORTC) {
2995 if(b & 0x80) next = hi;
2998 "out %[port], %[hi]" "\n\t" 2999 "rcall bitTimeC" "\n\t" 3000 "out %[port], %[hi]" "\n\t" 3001 "rcall bitTimeC" "\n\t" 3002 "out %[port], %[hi]" "\n\t" 3003 "rcall bitTimeC" "\n\t" 3004 "out %[port], %[hi]" "\n\t" 3005 "rcall bitTimeC" "\n\t" 3006 "out %[port], %[hi]" "\n\t" 3007 "rcall bitTimeC" "\n\t" 3008 "out %[port], %[hi]" "\n\t" 3009 "rcall bitTimeC" "\n\t" 3010 "out %[port], %[hi]" "\n\t" 3011 "rcall bitTimeC" "\n\t" 3012 "out %[port] , %[hi]" "\n\t" 3014 "ld %[byte] , %a[ptr]+" "\n\t" 3015 "out %[port] , %[next]" "\n\t" 3016 "mov %[next] , %[lo]" "\n\t" 3017 "sbrc %[byte] , 7" "\n\t" 3018 "mov %[next] , %[hi]" "\n\t" 3020 "out %[port] , %[lo]" "\n\t" 3021 "sbiw %[count], 1" "\n\t" 3025 "out %[port], %[next]" "\n\t" 3026 "mov %[next], %[lo]" "\n\t" 3027 "rol %[byte]" "\n\t" 3028 "sbrc %[byte], 7" "\n\t" 3029 "mov %[next], %[hi]" "\n\t" 3031 "out %[port], %[lo]" "\n\t" 3034 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
3035 : [
port]
"I" (_SFR_IO_ADDR(PORTC)), [ptr]
"e" (ptr), [hi]
"r" (hi),
3037 #if defined(PORTD) || defined(PORTB) || defined(PORTF) 3045 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 3046 if(
port == &PORTF) {
3051 if(b & 0x80) next = hi;
3054 "out %[port], %[hi]" "\n\t" 3055 "rcall bitTimeC" "\n\t" 3056 "out %[port], %[hi]" "\n\t" 3057 "rcall bitTimeC" "\n\t" 3058 "out %[port], %[hi]" "\n\t" 3059 "rcall bitTimeC" "\n\t" 3060 "out %[port], %[hi]" "\n\t" 3061 "rcall bitTimeC" "\n\t" 3062 "out %[port], %[hi]" "\n\t" 3063 "rcall bitTimeC" "\n\t" 3064 "out %[port], %[hi]" "\n\t" 3065 "rcall bitTimeC" "\n\t" 3066 "out %[port], %[hi]" "\n\t" 3067 "rcall bitTimeC" "\n\t" 3068 "out %[port] , %[hi]" "\n\t" 3070 "ld %[byte] , %a[ptr]+" "\n\t" 3071 "out %[port] , %[next]" "\n\t" 3072 "mov %[next] , %[lo]" "\n\t" 3073 "sbrc %[byte] , 7" "\n\t" 3074 "mov %[next] , %[hi]" "\n\t" 3076 "out %[port] , %[lo]" "\n\t" 3077 "sbiw %[count], 1" "\n\t" 3081 "out %[port], %[next]" "\n\t" 3082 "mov %[next], %[lo]" "\n\t" 3083 "rol %[byte]" "\n\t" 3084 "sbrc %[byte], 7" "\n\t" 3085 "mov %[next], %[hi]" "\n\t" 3087 "out %[port], %[lo]" "\n\t" 3090 : [byte]
"+r" (b), [next]
"+r" (next), [count]
"+w" (i)
3091 : [
port]
"I" (_SFR_IO_ADDR(PORTF)), [ptr]
"e" (ptr), [hi]
"r" (hi),
3093 #if defined(PORTD) || defined(PORTB) || defined(PORTC) 3098 volatile uint8_t next, bit;
3105 "st %a[port], %[hi]" "\n\t" 3106 "sbrc %[byte] , 7" "\n\t" 3107 "mov %[next], %[hi]" "\n\t" 3109 "st %a[port], %[next]" "\n\t" 3114 "st %a[port], %[lo]" "\n\t" 3117 "breq nextbyte30" "\n\t" 3118 "rol %[byte]" "\n\t" 3122 "rjmp head30" "\n\t" 3123 "nextbyte30:" "\n\t" 3125 "ldi %[bit] , 8" "\n\t" 3126 "ld %[byte] , %a[ptr]+" "\n\t" 3127 "sbiw %[count], 1" "\n\t" 3138 #elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L) 3140 volatile uint8_t next, bit;
3147 "st %a[port], %[hi]" "\n\t" 3148 "sbrc %[byte], 7" "\n\t" 3149 "mov %[next], %[hi]" "\n\t" 3151 "st %a[port], %[next]" "\n\t" 3152 "mov %[next] , %[lo]" "\n\t" 3153 "breq nextbyte20" "\n\t" 3154 "rol %[byte]" "\n\t" 3157 "st %a[port], %[lo]" "\n\t" 3160 "rjmp head20" "\n\t" 3161 "nextbyte20:" "\n\t" 3162 "ldi %[bit] , 8" "\n\t" 3163 "ld %[byte] , %a[ptr]+" "\n\t" 3164 "st %a[port], %[lo]" "\n\t" 3166 "sbiw %[count], 1" "\n\t" 3177 volatile uint8_t next, bit;
3184 "st %a[port], %[hi]" "\n\t" 3185 "sbrc %[byte] , 7" "\n\t" 3186 "mov %[next] , %[hi]" "\n\t" 3189 "st %a[port], %[next]" "\n\t" 3195 "st %a[port], %[lo]" "\n\t" 3197 "mov %[next] , %[lo]" "\n\t" 3199 "breq nextbyte40" "\n\t" 3200 "rol %[byte]" "\n\t" 3207 "rjmp head40" "\n\t" 3208 "nextbyte40:" "\n\t" 3209 "ldi %[bit] , 8" "\n\t" 3210 "ld %[byte] , %a[ptr]+" "\n\t" 3212 "st %a[port], %[lo]" "\n\t" 3214 "sbiw %[count], 1" "\n\t" 3226 #error "CPU SPEED NOT SUPPORTED" 3228 #elif defined(__arm__) 3229 #if defined(TEENSYDUINO) && defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6 3230 #define CYCLES_800_T0H (F_CPU / 4000000) 3231 #define CYCLES_800_T1H (F_CPU / 1250000) 3232 #define CYCLES_800 (F_CPU / 800000) 3233 #define CYCLES_400_T0H (F_CPU / 2000000) 3234 #define CYCLES_400_T1H (F_CPU / 833333) 3235 #define CYCLES_400 (F_CPU / 400000) 3238 volatile uint8_t *
set = portSetRegister(
pin),
3239 *clr = portClearRegister(
pin);
3241 ARM_DEMCR |= ARM_DEMCR_TRCENA;
3242 ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
3244 cyc = ARM_DWT_CYCCNT + CYCLES_800;
3247 for(mask = 0x80; mask; mask >>= 1) {
3248 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
3249 cyc = ARM_DWT_CYCCNT;
3252 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H);
3254 while(ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H);
3259 while(ARM_DWT_CYCCNT - cyc < CYCLES_800);
3261 cyc = ARM_DWT_CYCCNT + CYCLES_400;
3264 for(mask = 0x80; mask; mask >>= 1) {
3265 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
3266 cyc = ARM_DWT_CYCCNT;
3269 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H);
3271 while(ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H);
3276 while(ARM_DWT_CYCCNT - cyc < CYCLES_400);
3279 #error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz" 3281 #elif defined(ESP8266) || defined(ESP32) 3283 #elif defined(__ARDUINO_ARC__) 3285 #define NOPx7 { __builtin_arc_nop(); \ 3286 __builtin_arc_nop(); __builtin_arc_nop(); \ 3287 __builtin_arc_nop(); __builtin_arc_nop(); \ 3288 __builtin_arc_nop(); __builtin_arc_nop(); } 3289 PinDescription *pindesc = &g_APinDescription[
pin];
3291 register uint8_t *p =
pixels;
3292 register uint32_t currByte = (uint32_t) (*p);
3293 register uint32_t currBit = 0x80 & currByte;
3294 register uint32_t bitCounter = 0;
3295 register uint32_t first = 1;
3296 if (pindesc->ulGPIOType == SS_GPIO) {
3297 register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
3298 uint32_t reg_val = __builtin_arc_lr((
volatile uint32_t)reg);
3299 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
3300 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
3308 __builtin_arc_sr(first ? reg_bit_low : reg_bit_high, (
volatile uint32_t)reg);
3315 __builtin_arc_nop();
3317 __builtin_arc_sr(reg_bit_low, (
volatile uint32_t)reg);
3320 if(bitCounter >= 8) {
3322 currByte = (uint32_t) (*++p);
3324 currBit = 0x80 & currByte;
3327 }
else if(pindesc->ulGPIOType == SOC_GPIO) {
3328 register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
3329 uint32_t reg_val = MMIO_REG_VAL(reg);
3330 register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
3331 register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
3338 MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
3342 __builtin_arc_nop();
3347 MMIO_REG_VAL(reg) = reg_bit_low;
3350 if(bitCounter >= 8) {
3352 currByte = (uint32_t) (*++p);
3354 currBit = 0x80 & currByte;
3359 #error Architecture not supported 3369 digitalWrite(p, LOW);
3372 port = portOutputRegister(digitalPinToPort(p));
3373 pinMask = digitalPinToBitMask(p);
3377 uint16_t n, uint8_t r, uint8_t g, uint8_t b) {
3397 uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
3420 r = (uint8_t)(c >> 16),
3421 g = (uint8_t)(c >> 8),
3432 uint8_t w = (uint8_t)(c >> 24);
3441 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
3444 return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
3456 return ((uint32_t)p[
aOffset[0]] << 16) |
3457 ((uint32_t)p[
aOffset[1]] << 8) |
3468 return ((uint32_t)p[
aOffset[3]] << 24) |
3469 ((uint32_t)p[
aOffset[0]] << 16) |
3470 ((uint32_t)p[
aOffset[1]] << 8) |
3482 uint8_t newBrightness = b + 1;
3488 if(oldBrightness == 0) scale = 0;
3489 else if(b == 255) scale = 65535 / oldBrightness;
3490 else scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
3491 for(uint16_t i=0; i<
numBytes; i++) {
3493 *ptr++ = (c * scale) >> 8;
3505 128,131,134,137,140,143,146,149,152,155,158,162,165,167,170,173,
3506 176,179,182,185,188,190,193,196,198,201,203,206,208,211,213,215,
3507 218,220,222,224,226,228,230,232,234,235,237,238,240,241,243,244,
3508 245,246,248,249,250,250,251,252,253,253,254,254,254,255,255,255,
3509 255,255,255,255,254,254,254,253,253,252,251,250,250,249,248,246,
3510 245,244,243,241,240,238,237,235,234,232,230,228,226,224,222,220,
3511 218,215,213,211,208,206,203,201,198,196,193,190,188,185,182,179,
3512 176,173,170,167,165,162,158,155,152,149,146,143,140,137,134,131,
3513 128,124,121,118,115,112,109,106,103,100, 97, 93, 90, 88, 85, 82,
3514 79, 76, 73, 70, 67, 65, 62, 59, 57, 54, 52, 49, 47, 44, 42, 40,
3515 37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
3516 10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0,
3517 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
3518 10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
3519 37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
3520 79, 82, 85, 88, 90, 93, 97,100,103,106,109,112,115,118,121,124};
3522 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3523 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
3524 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
3525 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7,
3526 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12,
3527 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20,
3528 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29,
3529 30, 31, 31, 32, 33, 34, 34, 35, 36, 37, 38, 38, 39, 40, 41, 42,
3530 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
3531 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 75,
3532 76, 77, 78, 80, 81, 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96,
3533 97, 99,100,102,103,105,106,108,109,111,112,114,115,117,119,120,
3534 122,124,125,127,129,130,132,134,136,137,139,141,143,145,146,148,
3535 150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,
3536 182,184,186,188,191,193,195,197,199,202,204,206,209,211,213,215,
3537 218,220,223,225,227,230,232,235,237,240,242,245,247,250,252,255};
3557 #if EBOARD_NANO > 0x0 || defined(DOC) 3559 #if EBOARD_GUESSPATH > 0x0 3565 #define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo 3566 #define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo 3567 #define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached 3568 #define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds 3569 #define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer 3570 #define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER) 3571 #define INVALID_SERVO 255 // flag indicating an invalid servo index 3586 void write(
int value);
3596 #define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009 3597 #define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds 3598 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009 3604 #define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo 3605 #define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer 3606 #define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel 3607 #define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel 3608 #define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo 3609 #define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo 3616 digitalWrite(
SERVO(timer,
Channel[timer]).Pin.nbr,LOW);
3622 digitalWrite(
SERVO(timer,
Channel[timer]).Pin.nbr,HIGH);
3629 *OCRnA = *TCNTn + 4;
3633 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform 3635 #if defined(_useTimer1) 3641 #elif defined WIRING 3643 #if defined(_useTimer1) 3644 void Timer1Service()
3655 TIFR1 |= _BV(OCF1A);
3656 TIMSK1 |= _BV(OCIE1A) ;
3658 timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
3663 #if defined WIRING // Wiring 3665 TIMSK &= ~_BV(OCIE1A) ;
3666 timerDetach(TIMER1OUTCOMPAREA_INT);
3668 else if(timer == _timer3) {
3669 ETIMSK &= ~_BV(OCIE3A);
3670 timerDetach(TIMER3OUTCOMPAREA_INT);
3680 if(
SERVO(timer,channel).Pin.isActive ==
true)
3698 pinMode( pin, OUTPUT) ;
3721 if(value < 0) value = 0;
3722 if(value > 180) value = 180;
3738 uint8_t oldSREG = SREG;
3749 unsigned int pulsewidth;
3762 #if EBOARD_COPY_AND_PASTE > 0x0 3772 #if EBOARD_NANO > 0x0 3773 Servo mainMotor,steerMotor;
3785 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
3797 #if EBOARD_DEBUG_MODE > 0x0 3802 TIMSK2 &= ~(1<<TOIE2);
3803 TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
3804 TCCR2B &= ~(1<<WGM22);
3806 TIMSK2 &= ~(1<<OCIE2A);
3807 TCCR2B |= (1<<CS22);
3808 TCCR2B &= ~((1<<CS21) | (1<<CS20));
3809 TCNT2 = 256 - (int)((
float)F_CPU * 0.001 / 64);
3810 TIMSK2 |= (1<<TOIE2);
3812 #if EBOARD_BLUETOOTH > 0x0 3815 #if (EBOARD_BLUETOOTH > 0x0) && (((PIN_BLUETOOTH_RX==0x13) && (PIN_BLUETOOTH_TX==0x12)) && defined(__AVR_ATmega2560__)) 3816 Serial1.begin(38400);
3822 #if EBOARD_I2C > 0x0 3825 #if EBOARD_SHIFT_REGISTER > 0x0 3831 #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0) 3834 #if EBOARD_NANO > 0x0 3835 mainMotor.
attach(EBOARD_NANO_MAIN);
3836 steerMotor.
attach(EBOARD_NANO_STEER);
3837 #if EBOARD_DEBUG_MODE > 0x0 3838 Serial.println(
"Initializing main driving motor (3s)");
3840 mainMotor.
write(90);
3842 #if EBOARD_DEBUG_MODE > 0x0 3843 Serial.println(
"Initializing of main driving motor completed");
3846 #if EBOARD_DEBUG_MODE > 0x0 3848 Serial.println(
"fin");
3854 #if EBOARD_NANO > 0x0 3855 mainMotor.
write(90);
3858 #if EBOARD_NANO == 0x0 3871 #if EBOARD_NANO > 0x0 || defined(DOC) 3874 if(spe < 0 || spe > 180)
return;
3875 mainMotor.
write(spe);
3879 if(ang < 0 || ang > 180)
return;
3880 steerMotor.
write(ang);
3884 #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process 3886 #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
static void setDataMode(uint8_t mode)
#define SERVO_INDEX(_timer, _channel)
static volatile uint8_t twi_inRepStart
uint8_t requestFrom(uint8_t address, uint8_t quantity)
bool checkPin(optVAL_t idx, optVAL_t mode=0x1)
[COPY&PASTE] [CHECK_PINS] Check if a pin is set to a specific mode
void tx_pin_write(uint8_t pin_state)
static void setBitOrder(uint8_t bitOrder)
int8_t pin
stores the pin -1 if the pin wasn't set
static volatile uint8_t _receive_buffer_head
current location in rxBuffer
optVAL_t C
storing value for C-pin [MOTOR SPE]
uint8_t endTransmission(void)
void shiftSingle(optVAL_t idx, bool val)
[SHIFT] Changes a single output Pin
static const uint8_t PROGMEM _sineTable[256]
static volatile int8_t Channel[_Nbr_16timers]
const unsigned char * buf[11]
to enable 'smooth' access (:
void writePWM(optVAL_t val)
write a clamped pwm value to an output pin
uint8_t _transmitBitMask
the pin mask to address the tx pin
[COPY&PASTE] This is the SoccerBoard ghost struct :D
void writeVal(const T &val)
[BLUETOOTH] writes Data to bluetooth
uint8_t aOffset[4]
stores the offsets in rgbw format
uint8_t * pixels
stores the pixels
static uint8_t txBufferLength
this defines the length of txBuffer
void twi_releaseBus(void)
[COPY&PASTE] This is the AX12Servo ghost struct :D
void storePosition(int pos, int speed=0x3FF)
int actSpe
stores the actual 'would use speed' of the AX12Servo
static volatile uint8_t twi_masterBufferIndex
optVAL_t getPosition(void)
optVAL_t B
storing value for B-pin [MOTOR DIR]
void setID(optVAL_t newID)
virtual size_t write(uint8_t byte)
uint8_t getBrightness(void) const
static char _receive_buffer[64]
the buffer for rxBuffer
[SPI] This is used to avoid path resolving issues and defines the common known Arduino SPI interface ...
#define MACRO_MSG(mac, str)
uint16_t numLEDs
stores the amount of LEDs
void SetServoLimit(int ID, int upperLimit)
I2CInOut(SoccerBoard &, optVAL_t, optVAL_t, optVAL_t, optVAL_t)
static void(* twi_onSlaveTransmit)(void)
#define EBOARD_DEBUG_SPEED
optVAL_t countSetBits(optVAL_t x)
[COPY&PASTE] [CHECK_PWM] counts high-bits in an int/byte (determined by IGNORE_SIZE) ...
#define LCD_COMMAND_DISPLAY_OFF
static uint8_t txBufferIndex
this defines the txBuffer Index - current position in txBuffer array
virtual int available(void)
void loop(void)
[COPY&PASTE] As we have an Arduino we need a setup function ;)
void SetMotormode(int ID, int velocity)
uint16_t _rx_delay_stopbit
the rx stopbit dely
virtual size_t write(uint8_t data)
This is used to avoid path resolving issues and defines the common known Arduino Wire-Interface    ...
void led(int idx, bool state)
bool begun
true if NeoPixel::begin has been called
static void(* user_onReceive)(int numBytes)
twi slave [Rx]receive-event user def handler
static void(* user_onRequest)(void)
twi slave [Tx]transmitting-event user def handler
void setVelocity(int velocity)
void s2Cmd(optVAL_t o, optVAL_t t)
AX12Servo * connected[2]
stores the pointers to the registerd AX12Servo
optVAL_t readPin(optVAL_t idx, bool dig=true)
read a digital state from an INPUTpin
uint8_t gamma8(uint8_t x) const
static const uint8_t PROGMEM _gammaTable[256]
void writePin(optVAL_t idx, bool val)
write a boolean state to an output pin
void powerOn(optVAL_t id)
void changeModes(optVAL_t, optVAL_t, optVAL_t)
byte sendWait(const byte what)
SIGNAL(TIMER1_COMPA_vect)
static void onReceiveService(uint8_t *inBytes, int numBytes)
#define EBOARD_SHIFT_REGISTER
void changeMode(bool newMode=true)
NeoPixel pixels
the NeoPixel-object we use
volatile uint8_t * port
the used port register
#define LCD_COMMAND_DISPLAY_ON
int storedPos
stores the position the Servo should go to DynamixelBoard::action()
static void(* twi_onSlaveReceive)(uint8_t *, int)
volatile uint8_t * _receivePortRegister
the register the reveice pin is located on
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b)
#define LCD_PAGE_ADDRESSING
void rotate(int ID, int velocity)
void changeAddress(optVAL_t)
static void handle_interrupt(void)
this namespace contains all the Don't use manually classes ;)
SoftwareSerial _serial(0x13, 0x12)
static uint8_t rxBuffer[]
this defines the rxBuffer used to enable delayed read
uint8_t twi_transmit(const uint8_t *data, uint8_t length)
DynamixelBoard * _conBoard
static servo_t servos[(_Nbr_16timers *12)]
static volatile uint8_t twi_slarw
#define LCD_COMMAND_CHARGE_PUMP_SETTING
optVAL_t id
stores the id of the AX12Servo obejct
void shiftAll(void)
[SHIFT] Changes bits according to store_bits
byte pX
the addressing mode (page/horizontal)
DynamixelBoard(SoccerBoard &)
void updateLength(uint16_t n)
static uint8_t rxBufferLength
this defines the length of rxBuffer
#define PIN_BLUETOOTH_STATE
static uint8_t rxBufferIndex
this defines the rxBuffer Index - current position in rxBuffer array
void readI2C(optVAL_t deviceID, optVAL_t ret[], optVAL_t ret_len, bool blocking=true)
Reads a special amount of bits from a certain I²C-Device.
unsigned short rx_delay_stopbit
void setPin(optVAL_t idx, optVAL_t mode=0x1)
[COPY&PASTE] set a pin to a certain mode => checkPin() will return true then
uint16_t numBytes
stores the byte size [pixels] used internally
static volatile uint8_t twi_masterBufferLength
void SetID(int ID, int newID)
#define EBOARD_SPI_SERVO_MAX
bool setCursor(byte posX=0x0, byte posY=0x0)
void twi_attachSlaveTxEvent(void(*function)(void))
unsigned short rx_delay_intrabit
static void finISR(timer16_Sequence_t timer)
static void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t *OCRnA)
uint8_t * getPixels(void) const
LCD(SoccerBoard &soccerBoard, optVAL_t id=0x3C)
#define LCD_COMMAND_WHITE_BACKGROUND
#define DEFAULT_PULSE_WIDTH
volatile uint8_t * _transmitPortRegister
the register the reveice pin is located on
static volatile uint8_t twi_txBufferIndex
void updateType(uint16_t t)
static uint32_t Color(uint8_t r, uint8_t g, uint8_t b)
[COPY&PASTE] [BLUETOOTH] This is the RB14Scan ghost struct :D
void changeBackground(bool newBackground=false)
static void setClockDivider(uint8_t rate)
static void attachInterrupt(void)
optVAL_t ID
ID of the Display.
void pingI2C(optVAL_t ret[], optVAL_t ret_len)
Sends a byte to a certain I²C-Device.
void motor(uint8_t id, int16_t val)
static volatile uint8_t twi_txBufferLength
uint8_t sine8(uint8_t x) const
bool digital(optVAL_t id)
void onReceive(void(*function)(int))
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
[COPY&PASTE] This is the DynamixelBoard ghost struct :D
char readVal(char oF='.')
[BLUETOOTH] reads a single value from bluetooth if available!
#define ticksToUs(_ticks)
SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
void checkIdx(optVAL_t idx)
[DEBUG_MODE] used to check if a pin index is in bounds
bool checkOverflow(void)
[BLUETOOTH] checks if theres a lack of Data!
uint8_t rx_pin_read(void)
static SoftwareSerial * active_object
the active SoftwareSerial object to operate on
void write(const char *const val)
struct _DELAY_TABLE DELAY_TABLE
volatile unsigned int ticks
void WritePos(int ID, int Pos)
void power(optVAL_t id, bool state)
uint32_t endTime
stores the last call time of show for NeoPixel::canShow()
uint16_t _tx_delay
the (generic) tx delay
void setBrightness(uint8_t val)
static uint8_t twi_masterBuffer[32]
static volatile uint8_t twi_error
void setTX(uint8_t transmitPin)
[COPY&PASTE] This is the I2CInOut ghost struct :D
unsigned short rx_delay_centering
void set_steer_angle(optVAL_t ang)
void write(int ID, int Pos)
void twi_attachSlaveRxEvent(void(*function)(uint8_t *, int))
static volatile uint8_t _receive_buffer_tail
size of rxBuffer
#define SERVO_INDEX_TO_TIMER(_servo_nbr)
static volatile uint8_t twi_sendStop
#define EBOARD_CHECK_PINS
static void tunedDelay(uint16_t delay)
uint8_t brightness
stores the brightness
uint8_t pinMask
the used pinMask
void __assert(const char *__func, const char *__file, optVAL_t __lineno, const char *__sexp)
[DEBUG_MODE] custom assert message
static byte transfer(byte _data)
void setPositionMode(void)
void setup(void)
this is a guard
bool changeBrightness(byte val=0x64)
optVAL_t analog(optVAL_t id)
void twi_setAddress(uint8_t address)
#define TWI_BUFFER_LENGTH
bool changeID(optVAL_t newID=0x3C)
void setPosition(int pos, int speed=0x3FF)
#define EBOARD_USE_UTILITY
static uint8_t txAddress
this defines the txAddress the transmitting Dta
static uint8_t transmitting
'boolean' value. Set to 1 if transmitting => in master write mode
uint16_t _inverse_logic
determining if all pin reads etc whould be inverted (e.g. no pullup on rx);
void setPoslimit(int posLimit)
virtual int available(void)
DynamixelBoard dBoard(board)
the dBoard object
void DebugPulse(uint8_t pin, uint8_t count)
static void detachInterrupt(void)
bool is800KHz
determines the speed the communcation is working on
uint16_t _rx_delay_centering
the rx center delay
#define SERVO(_timer, _channel)
#define EBOARD_CHECK_PINS_PWM
void beginTransmission(uint8_t address)
static volatile uint8_t twi_rxBufferIndex
#define EBOARD_DEBUG_MODE
bool isConnected(void)
[BLUETOOTH] this will check if the HC-05 is paired
static void onRequestService(void)
void print(const char *data)
void twi_reply(uint8_t ack)
static volatile uint8_t twi_state
static uint8_t txBuffer[]
this defines the txBuffer used to enable delayed read
uint8_t _receivePin
the id of the receive pin
void writeMicroseconds(int value)
void drawBitmap(const unsigned char *bitmap, byte posX, byte posY, byte hiX, byte hiY)
#define LCD_COMMAND_CHARGE_PUMP_ENABLE
uint8_t twi_readFrom(uint8_t address, uint8_t *data, uint8_t length, uint8_t sendStop)
void powerOff(optVAL_t id)
uint16_t _buffer_overflow
determining if an _buffer_overflow occured
uint8_t _receiveBitMask
the pin mask to directly read from register (Rx)
uint8_t twi_writeTo(uint8_t address, uint8_t *data, uint8_t length, uint8_t wait, uint8_t sendStop)
optVAL_t sendI2C(optVAL_t deviceID, byte *buf, byte buf_len)
Sends a buffer of bytes to a certain I²C-Device.
PROGMEM const byte basicFont[][8]
void setRX(uint8_t receivePin)
static void initISR(timer16_Sequence_t timer)
static boolean isTimerActive(timer16_Sequence_t timer)
[NEO] this allows you to access Adafruit LED-stripes
uint32_t getPixelColor(uint16_t n) const
void set_motor_speed(optVAL_t spe)
void changeMotorID(optVAL_t)
uint16_t numPixels(void) const
#define EBOARD_NEO_800KHZ
static uint8_t twi_txBuffer[32]
[I2C] [LCD] This is used to add support for OLED displays connected to the 'SoccerBoard' ...
#define LCD_COMMAND_BLACK_BACKGROUND
void changeMotorID(optVAL_t newID)
static uint8_t twi_rxBuffer[32]
void onRequest(void(*function)(void))
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...