9 #ifdef ACCESSORIES_DEBUG_MODE 10 #ifdef ARDUINO_ARCH_SAM 11 void Port::CheckPinNb(
int inPin, PIN_TYPE inType,
const char *inFunc)
17 unsigned long expanderId = 0;
18 if (GPIO_to_Arduino_pin((GPIO_pin_t)inPin) == -1)
19 expanderId = EXPANDER_PORT_EXPID(inPin);
23 PortExpander::CheckExpanderId(expanderId);
29 pin = GPIO_to_Arduino_pin((GPIO_pin_t)inPin);
31 if (pin <= 0 || pin >= NUM_DIGITAL_PINS)
33 if (pin < A0 || pin > A7)
35 Serial.print(F(
"Pin "));
37 Serial.print(F(
" error in "));
38 Serial.println(inFunc);
47 void Port::CheckPinNb(
int inPin, PIN_TYPE inType,
const __FlashStringHelper* inFunc)
53 unsigned long expanderId = 0;
54 if (GPIO_to_Arduino_pin((GPIO_pin_t)inPin) == -1)
55 expanderId = EXPANDER_PORT_EXPID(inPin);
59 PortExpander::CheckExpanderId(expanderId);
65 pin = GPIO_to_Arduino_pin((GPIO_pin_t)inPin);
67 if (pin <= 0 || pin >= NUM_DIGITAL_PINS)
69 if (pin < A0 || pin > A7)
71 Serial.print(F(
"Pin "));
73 Serial.print(F(
" error in "));
74 Serial.println(inFunc);
88 this->
speed = DEFAULTSPEED;
93 if (inType == UNDEFINED)
96 if (inType == ANALOG_INVERTED)
99 if (inType == DIGITAL_INVERTED)
112 if (inType == UNDEFINED)
117 unsigned long expanderId = 0;
118 if (GPIO_to_Arduino_pin((GPIO_pin_t)inPin) == -1)
119 expanderId = EXPANDER_PORT_EXPID(inPin);
123 #ifdef ACCESSORIES_DEBUG_MODE 124 PortExpander::CheckExpanderId(expanderId);
126 int pinExp = EXPANDER_PORT_PIN(inPin);
135 pin = Arduino_to_GPIO_pin(inPin);
136 pinMode2f((GPIO_pin_t) pin, OUTPUT);
149 if (inType == UNDEFINED)
152 CHECKPIN(inPin, inType,
"Incorrect pin number in MovePin");
155 unsigned long expanderId = 0;
156 if (GPIO_to_Arduino_pin((GPIO_pin_t)inPin) == -1)
157 expanderId = EXPANDER_PORT_EXPID(inPin);
161 #ifdef ACCESSORIES_DEBUG_MODE 162 PortExpander::CheckExpanderId(expanderId);
164 int pinExp = EXPANDER_PORT_PIN(inPin);
179 digitalWrite2f((GPIO_pin_t)inPin, this->
MapValue(inValue, inType));
184 analogWrite(inPin, this->
MapValue(0, inType));
192 uint8_t oldSpeed = this->
speed;
193 this->
speed = inSpeed;
231 #ifdef ACCESSORIES_PRINT_ACCESSORIES 232 void Port::printPort()
236 void Port::printPortPin(
int inPin, PIN_TYPE inType)
240 unsigned long expanderId = 0;
241 if (GPIO_to_Arduino_pin((GPIO_pin_t)inPin) == -1)
242 expanderId = EXPANDER_PORT_EXPID(inPin);
246 Serial.print(expanderId);
248 Serial.print(EXPANDER_PORT_PIN(inPin));
255 Serial.print(GPIO_to_Arduino_pin((GPIO_pin_t)inPin));
264 case UNDEFINED: Serial.print(
"UNDEFINED)");
break;
265 case DIGITAL: Serial.print(
"DIGITAL)");
break;
266 case DIGITAL_INVERTED: Serial.print(
"DIGITAL_INVERTED)");
break;
267 case ANALOG: Serial.print(
"ANALOG)");
break;
268 case ANALOG_INVERTED: Serial.print(
"ANALOG_INVERTED)");
break;
PORT_STATE GetPortState() const
virtual void MoveLeftDir(unsigned long inDuration = 0)
virtual void MoveRightDir(unsigned long inDuration = 0)
PORT_STATE MoveToggle(unsigned long inDuration = 0)
virtual int SetSpeed(int inSpeed)
virtual void analogWrite(int inPin, int inValue) = 0
virtual void digitalWrite(int inPin, int inValue) = 0
void MovePin(int inPin, int inValue, PIN_TYPE inType = UNDEFINED) const
virtual void beginPin(int inPin, PIN_TYPE inType) = 0
int beginPin(int inPin, PIN_TYPE inType = UNDEFINED) const
PIN_TYPE GetPinType() const
int MapValue(int inValue, PIN_TYPE inType = UNDEFINED) const
void SetPortState(PORT_STATE inState)
void SetPinType(PIN_TYPE inType)