mirror of
https://github.com/platformio/platformio-core.git
synced 2025-10-05 10:00:57 +02:00
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/atmelavr-and-arduino/arduino-adafruit-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-engduino-library
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/digitstump-mouse
|
||||
|
||||
# Process example project
|
||||
> platformio run
|
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Project Configuration File
|
||||
#
|
||||
# A detailed documentation with the EXAMPLES is located here:
|
||||
# http://docs.platformio.org/en/latest/projectconf.html
|
||||
#
|
||||
|
||||
# A sign `#` at the beginning of the line indicates a comment
|
||||
# Comment lines are ignored.
|
||||
|
||||
# Simple and base environment
|
||||
# [env:mybaseenv]
|
||||
# platform = %INSTALLED_PLATFORM_NAME_HERE%
|
||||
# framework =
|
||||
# board =
|
||||
#
|
||||
# Automatic targets - enable auto-uploading
|
||||
# targets = upload
|
||||
|
||||
[env:digispark-tiny]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = digispark-tiny
|
||||
|
||||
[env:digispark-pro32]
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
board = digispark-pro32
|
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)
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
How to buid PlatformIO based project
|
||||
====================================
|
||||
|
||||
1. `Install PlatformIO <http://docs.platformio.org/en/latest/installation.html>`_
|
||||
2. Download `source code with examples <https://github.com/ivankravets/platformio/archive/develop.zip>`_
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Change directory to example
|
||||
> cd platformio-develop/examples/atmelavr-and-arduino/engduino-magnetometer
|
||||
|
||||
# Process example project
|
||||
> platformio run
|
||||
|
||||
# Upload firmware
|
||||
> platformio run --target upload
|
||||
|
||||
# Clean build files
|
||||
> platformio run --target clean
|
@@ -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);
|
||||
}
|
Reference in New Issue
Block a user