Giter VIP home page Giter VIP logo

arduino-gpio's People

Contributors

mikaelpatel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-gpio's Issues

Not working with bad stepper drivers TB67S109AFTG

Hey! Use your library for my project, and all works fine with different stepper drivers.
Now with TB67S109AFTG nothing works.

When I add default code with DigitalWhrite all works. And with this library not. Seems like pin not make fully 0v of 5v and this drivers are sensitive for this.

For my old drivers declare pin types in init was ok:
StepMotor() {
stepPin.output();
dirPin.output();
enPin.output();
}

And for this one I must declare them in setup with pinMode:
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);

Then they work, but really badly: hold torque in half power, can don't listen for dir pin etc.

Attach my code:

// StepMotor.h
#ifndef StepMotor_h
#define StepMotor_h

#include "GPIO.h"

template<BOARD::pin_t STEP_PIN, BOARD::pin_t DIR_PIN, BOARD::pin_t EN_PIN>
class StepMotor {
public:
StepMotor() {
stepPin.output();
dirPin.output();
enPin.output();
}

void runForward(int stepInterval, int dis) {
  runMotor(LOW, stepInterval, dis);
}

void runBack(int stepInterval, int dis){
   runMotor(HIGH, stepInterval, dis);
}

 void runForeverWithAcceleration(bool dir, int startStepInterval, int endStepInterval) {
 enPin = LOW;
 dirPin = dir;

 if (currentInterval == 0) {
 currentInterval = startStepInterval;
 }

  if (micros() - previousMillis >= currentInterval) {
    stepPin.toggle();
    
    if (endStepInterval <= currentInterval){
      currentInterval -= 20;
    }
    
    previousMillis = micros();
  }
}

void resetCurrentInterval() {
  currentInterval = 0;
}

void runForever(bool dir, int stepInterval) {
 enPin = LOW;
 dirPin = dir;

   if (micros() - previousMillis >= stepInterval) {
    stepPin.toggle();
    previousMillis = micros();
  }
}

void setCurrentDisToZero() {
  currentDis = 0;
}

void setCurrentDisToMax() {
  currentDis = 31000;
}

void setCurrentDis(int value) {
  currentDis = value;
}

 void activate(bool value = LOW) {
  enPin = value;
}

 void deactivate() {
  enPin = HIGH;
}

int getCurrentDis(){
  return currentDis;
}

bool isRunToDis(int dis){
  return currentDis >= dis;
}

private:
unsigned long previousMillis = 0;
int currentDis = 0;
int currentInterval = 0;

void runMotor(bool dir, int stepInterval, int dis) {
enPin = LOW;
dirPin = dir;

  if (micros() - previousMillis >= stepInterval && currentDis < dis) {
    stepPin.toggle();

    ++currentDis;
    previousMillis = micros();
  }
}

protected:
GPIO<STEP_PIN> stepPin;
GPIO<DIR_PIN> dirPin;
GPIO<EN_PIN> enPin;
};

#endif

Blink in pure c.

Hello.
I've tried to write Blink without Arduino IDE. Found problems:

  1. LOW / HIGH are not defined. but led.low() / led.high() works ok.
  2. function delay() undefined.
    Is this library only to run within Arduino IDE or standalone usage is also possible?

Many Thanks

Unit Test / Mock

Since this is a class, why no unit tests? Would be nice to be able to mock this up and unit test code against it.

Library appears to be incompatible with ATTiny Core

Noob to ATtiny micros.

I have Arduino IDE 1.8.4 installed as well as ATTinyCore and am using a ATtiny84A micro.

I downloaded this library and added it to the IDE.

I click File->Examples->Arduino-GPIO->ATtiny->Blink

When I go to compile the example, I get the following errors:

Arduino: 1.8.4 (Windows 10), Board: "ATtiny24/44/84, Disabled, ATtiny84, 8 MHz (internal), EEPROM retained, B.O.D. Disabled, Clockwise (like damellis core)"

In file included from C:\Users\Boompy\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.5\cores\tiny/Arduino.h:165:0,

                 from sketch\Blink.ino.cpp:1:

C:\Users\Boompy\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.5\variants\tinyX4_reverse/pins_arduino.h:44:14: error: expected identifier before numeric constant

 #define SS   3

              ^

C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/Hardware/AVR/Board.h:393:5: note: in expansion of macro 'SS'

     SS = D3,   //!< SPI Slave Select

     ^

C:\Users\Boompy\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.5\variants\tinyX4_reverse/pins_arduino.h:44:14: error: expected '}' before numeric constant

 #define SS   3

              ^

C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/Hardware/AVR/Board.h:393:5: note: in expansion of macro 'SS'

     SS = D3,   //!< SPI Slave Select

     ^

C:\Users\Boompy\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.1.5\variants\tinyX4_reverse/pins_arduino.h:44:14: error: expected unqualified-id before numeric constant

 #define SS   3

              ^

C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/Hardware/AVR/Board.h:393:5: note: in expansion of macro 'SS'

     SS = D3,   //!< SPI Slave Select

     ^

In file included from C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/Hardware/AVR/GPIO.h:22:0,

                 from C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/GPIO.h:22,

                 from C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\examples\ATtiny\Blink\Blink.ino:1:

C:\Users\Boompy\Documents\Arduino\libraries\Arduino-GPIO-master\src/Hardware/AVR/Board.h:398:1: error: expected declaration before '}' token

 };

 ^

exit status 1
Error compiling for board ATtiny24/44/84.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
```


Seems like your library is fighting with ATtiny core... I suspect your library uses the same #define symbols (e.g. "SS") as ATtiny core.  Not sure how to proceed.  Can you recommend a course of action?

Ultimately, I would like to start using the Arduino-OWI library, but since this is a prerequisite I need to get this working first I think

Problems with Button.h

Hello,
first of all: Thank you for the great work.
This makes programming so much easier and more efficient.

I have a problem with the button class. I tried to turn on the board led by pressing a button and turning it off when releasing.
The led stays on all the time...

#include "GPIO.h"
#include "Button.h"

GPIOBOARD::D13 led;
ButtonBOARD::D5 button;

void setup()
{
led.output();
}

void loop()
{
if(button) {
led=1;
}
else
{
led=0;
}

}

Support for Arduino Mega

AVR ATmega2560 based boards are currently not support. Access to ports with higher io port address need synchronized access. They do not compile to single instructions and thus not atomic. GPIO member function need to be atomic even for these.

Hardware/AVR/GPIO.h Arduino header

I use Eclipse Sloeber IDE and opening up file 'Hardware/AVR/GPIO.h' I noticed some unresolved symbols and functions at lines 36, 39, 170, 175 and 211.

To fix, I placed '#include "Arduino.h" so it will resolve symbols.
Am I correct in thinking that this include should be included ?

Many thanks for your work on great code.
Paul - VK7KPA

Separate interface from implementation

Make it easier for implementations to follow interface changes. Also collect interface documentation in one place.

E.g. GPIO.h should contain the interface and included the correct target implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.