Added arduino libs

هذا الالتزام موجود في:
Mik6e6
2020-07-04 12:31:18 -04:00
ملتزم من قبل GitHub
الأصل 3d9b49e518
التزام dc9596f994
90 ملفات معدلة مع 9419 إضافات و0 حذوفات

عرض الملف

@@ -0,0 +1,14 @@
# Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!)
BOARD_TAG = pro
BOARD_SUB = 16MHzatmega328
ARDUINO_PORT = /dev/ttyUSB0
#BOARD_TAG = 2560
#ARDUINO_PORT = /dev/ttyACM0
ARDUINO_LIBS =
AVR_TOOLS_DIR = /usr
CFLAGS_STD = -g
CXXFLAGS_STD = -g
include /usr/share/arduino/Arduino.mk

عرض الملف

@@ -0,0 +1,39 @@
// SimpleWithLibrary example sketch for the EnableInterrupt library. Demonstrates how to use
// the EnableInterrupt library with a sketch that services an interrupt pin, and uses a library
// that also requires the EnableInterrupt library.
// This sketch has only been compiled to the Arduino Uno (ATmega328).
// This sketch is only known to compile. It has not been tested functionally.
// See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information.
#define EI_ARDUINO_INTERRUPTED_PIN
#include <EnableInterrupt.h>
#define USELESSPIN 10
#include "Useless.h"
#define ARDUINOPIN 9
volatile uint16_t interruptCount=0;
void interruptFunction() {
interruptCount++;
}
// UselessClass uses the EnableInterrupt library.
UselessClass uselessObject=UselessClass(USELESSPIN, CHANGE);
void setup() {
Serial.begin(115200);
pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins
enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE);
}
void loop() {
Serial.println("---------------------------------------");
delay(1000);
Serial.print("Pin was interrupted: ");
Serial.print(interruptCount, DEC);
Serial.println(" times so far.");
Serial.print("Useless interrupt count: ");
Serial.print(uselessObject.getUselessVariable(), DEC);
}

عرض الملف

@@ -0,0 +1,26 @@
// FOR TESTING, TO DEMONSTRATE HOW TO USE ENABLEINTERRUPT IN A LIBRARY.
// See Useless.h for more information.
#include "Useless.h"
volatile uint8_t uselessVariable=0;
void uselessFunction() {
uselessVariable++;
}
void UselessClass::init(uint8_t pin, uint8_t mode) {
pinMode(pin, INPUT_PULLUP);
enableInterrupt(pin, uselessFunction, mode);
}
uint8_t UselessClass::getUselessVariable() {
return uselessVariable;
}
void UselessClass::reset() {
uselessVariable=0;
}
void UselessClass::disable(uint8_t pin) {
disableInterrupt(pin);
}

عرض الملف

@@ -0,0 +1,28 @@
// This is a useless library. To use such a useless thing, with the EnableInterrupt library,
// you need to #define LIBCALL_ENABLEINTERRUPT in your library, like so:
#define LIBCALL_ENABLEINTERRUPT
// Thus, none of the functions or ISRs will get compiled but their prototypes are declared
// so you can use them as illustrated in the Useless.cpp.
// You also need to #include the EnableInterrupt.h file in your sketch. After you #include the
// EnableInterrupt.h file, #include the library's .h file (ie, this one in this example). This
// will compile the requisite components. See the SimpleWithLibrary.ino sketch.
#include <stdint.h>
#include <Arduino.h>
#define EI_ARDUINO_INTERRUPTED_PIN
#include <EnableInterrupt.h>
class UselessClass {
public:
UselessClass(uint8_t pin, uint8_t mode) {
init(pin, mode);
}
uint8_t getUselessVariable();
void reset();
void disable(uint8_t pin);
private:
void init(uint8_t pin, uint8_t mode);
};