forked from platformio/platformio-core
Re-group examples
This commit is contained in:
@ -9,7 +9,7 @@ How to buid PlatformIO based project
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platformio-develop/examples/digistump/digitstump-blink
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/adafruit-blink
|
||||
|
||||
# Process example project
|
||||
> platformio run
|
@ -1,60 +0,0 @@
|
||||
#include <EngduinoLEDs.h>
|
||||
#include <EngduinoAccelerometer.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// Accelerometer demo - level
|
||||
//
|
||||
// Show a red LED on one side if we're low on that side
|
||||
// show nothing if we're high, and show green on both sides
|
||||
// if it's level(ish)
|
||||
//
|
||||
// We delay between readings because it's a bit flashy
|
||||
// otherwise - too hard to hold steady
|
||||
//
|
||||
|
||||
void setup()
|
||||
{
|
||||
EngduinoLEDs.begin();
|
||||
EngduinoAccelerometer.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{ float xyz[3];
|
||||
|
||||
// Read the acceleration
|
||||
//
|
||||
EngduinoAccelerometer.xyz(xyz);
|
||||
|
||||
// And light the appropriate LEDs depending on whether we're level
|
||||
// or not. The LEDs chosen are on opposite sides of the board.
|
||||
//
|
||||
if ((xyz[0] > 0 && xyz[0] < 0.02) || (xyz[0] < 0 && xyz[0] > -0.02)) {
|
||||
EngduinoLEDs.setLED(12, GREEN);
|
||||
EngduinoLEDs.setLED( 4, GREEN);
|
||||
}
|
||||
else if (xyz[0] > 0.02) {
|
||||
EngduinoLEDs.setLED(12, RED);
|
||||
EngduinoLEDs.setLED( 4, OFF);
|
||||
}
|
||||
else {
|
||||
EngduinoLEDs.setLED(12, OFF);
|
||||
EngduinoLEDs.setLED( 4, RED);
|
||||
}
|
||||
|
||||
if ((xyz[1] > 0 && xyz[1] < 0.02) || (xyz[1] < 0 && xyz[1] > -0.02)) {
|
||||
EngduinoLEDs.setLED( 9, GREEN);
|
||||
EngduinoLEDs.setLED(15, GREEN);
|
||||
}
|
||||
else if (xyz[1] > 0.02) {
|
||||
EngduinoLEDs.setLED( 9, RED);
|
||||
EngduinoLEDs.setLED(15, OFF);
|
||||
}
|
||||
else {
|
||||
EngduinoLEDs.setLED( 9, OFF);
|
||||
EngduinoLEDs.setLED(15, RED);
|
||||
}
|
||||
|
||||
// Wait 50ms, then loop
|
||||
//
|
||||
delay(50);
|
||||
}
|
@ -9,7 +9,7 @@ How to buid PlatformIO based project
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/arduino-adafruit-blink
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/digitstump-mouse
|
||||
|
||||
# Process example project
|
||||
> platformio run
|
@ -18,16 +18,11 @@
|
||||
# targets = upload
|
||||
|
||||
[env:digispark-tiny]
|
||||
platform = digistump
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = digispark-tiny
|
||||
|
||||
[env:digispark-pro32]
|
||||
platform = digistump
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = digispark-pro32
|
||||
|
||||
[env:digix]
|
||||
platform = digistump
|
||||
framework = arduino
|
||||
board = digix
|
41
examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino
Normal file
41
examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino
Normal file
@ -0,0 +1,41 @@
|
||||
// DigiMouse test and usage documentation
|
||||
// CAUTION!!!! This does click things!!!!!!!!
|
||||
// Originally created by Sean Murphy (duckythescientist)
|
||||
|
||||
#include <DigiMouse.h>
|
||||
|
||||
void setup() {
|
||||
DigiMouse.begin(); //start or reenumerate USB - BREAKING CHANGE from old versions that didn't require this
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If not using plentiful DigiMouse.delay(), make sure to call
|
||||
// DigiMouse.update() at least every 50ms
|
||||
|
||||
// move across the screen
|
||||
// these are signed chars
|
||||
DigiMouse.moveY(10); //down 10
|
||||
DigiMouse.delay(500);
|
||||
DigiMouse.moveX(20); //right 20
|
||||
DigiMouse.delay(500);
|
||||
DigiMouse.scroll(5);
|
||||
DigiMouse.delay(500);
|
||||
|
||||
// or DigiMouse.move(X, Y, scroll) works
|
||||
|
||||
// three buttons are the three LSBs of an unsigned char
|
||||
DigiMouse.setButtons(1<<0); //left click
|
||||
DigiMouse.delay(500);
|
||||
DigiMouse.setButtons(0); //unclick all
|
||||
DigiMouse.delay(500);
|
||||
|
||||
//or you can use these functions to click
|
||||
DigiMouse.rightClick();
|
||||
DigiMouse.delay(500);
|
||||
DigiMouse.leftClick();
|
||||
DigiMouse.delay(500);
|
||||
DigiMouse.middleClick();
|
||||
DigiMouse.delay(500);
|
||||
|
||||
//for compatability with other libraries you can also use DigiMouse.move(X, Y, scroll, buttons)
|
||||
}
|
@ -9,7 +9,7 @@ How to buid PlatformIO based project
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/arduino-engduino-library
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/engduino-magnetometer
|
||||
|
||||
# Process example project
|
||||
> platformio run
|
@ -0,0 +1,44 @@
|
||||
#include <EngduinoMagnetometer.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// Magnetometer demo
|
||||
//
|
||||
// Print the field strength values
|
||||
//
|
||||
|
||||
void setup()
|
||||
{
|
||||
EngduinoMagnetometer.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
float magneticField[3];
|
||||
|
||||
// Read magnetic field strength. The values range from -20000
|
||||
// to +20000 counts and are based on internal calibration
|
||||
// values
|
||||
//
|
||||
EngduinoMagnetometer.xyz(magneticField);
|
||||
|
||||
float x = magneticField[0];
|
||||
float y = magneticField[1];
|
||||
float z = magneticField[2];
|
||||
Serial.print("Magnetic field strength: x = ");
|
||||
Serial.print(x);
|
||||
Serial.print(" counts y = ");
|
||||
Serial.print(y);
|
||||
Serial.print(" counts z = ");
|
||||
Serial.print(z);
|
||||
Serial.println(" counts");
|
||||
|
||||
// Note that this is an uncalibrated temperature
|
||||
// of the die itself. Whilst it should be a value
|
||||
// in degrees C, the lack of calibration could mean
|
||||
// that it's anything.
|
||||
int8_t t = EngduinoMagnetometer.temperature();
|
||||
Serial.print("Temperature: ");
|
||||
Serial.println(t);
|
||||
|
||||
delay(1000);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
|
||||
Most Arduinos have an on-board LED you can control. On the Uno and
|
||||
Leonardo, it is attached to digital pin 13. If you're unsure what
|
||||
pin the on-board LED is connected to on your Arduino model, check
|
||||
the documentation at http://arduino.cc
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
modified 8 May 2014
|
||||
by Scott Fitzgerald
|
||||
*/
|
||||
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
// initialize digital pin 13 as an output.
|
||||
pinMode(13, OUTPUT);
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(1000); // wait for a second
|
||||
}
|
Reference in New Issue
Block a user