From 6d86f720606de614abee03206ca888822ca85055 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 23 Feb 2015 22:36:21 +0200 Subject: [PATCH 1/3] Merge Digistump platform to "atmelavr" and "atmelsam" --- platformio/boards/digistump.json | 10 +-- platformio/builder/scripts/atmelavr.py | 37 ++++++--- platformio/builder/scripts/digistump.py | 103 ------------------------ platformio/platforms/atmelavr.py | 20 ++++- platformio/platforms/digistump.py | 61 -------------- tests/commands/test_search.py | 2 +- 6 files changed, 49 insertions(+), 184 deletions(-) delete mode 100644 platformio/builder/scripts/digistump.py delete mode 100644 platformio/platforms/digistump.py diff --git a/platformio/boards/digistump.json b/platformio/boards/digistump.json index 07f083e3..610cad58 100644 --- a/platformio/boards/digistump.json +++ b/platformio/boards/digistump.json @@ -9,7 +9,7 @@ }, "framework": "arduino", "name": "Digispark (Default - 16.5mhz)", - "platform": "digistump", + "platform": "atmelavr", "upload": { "disable_flushing": false, "maximum_ram_size": 512, @@ -29,7 +29,7 @@ }, "framework": "arduino", "name": "Digispark Pro (Default 16 Mhz)", - "platform": "digistump", + "platform": "atmelavr", "upload": { "disable_flushing": false, "maximum_ram_size": 512, @@ -49,7 +49,7 @@ }, "framework": "arduino", "name": "Digispark Pro (16 Mhz) (32 byte buffer)", - "platform": "digistump", + "platform": "atmelavr", "upload": { "disable_flushing": false, "maximum_ram_size": 512, @@ -69,7 +69,7 @@ }, "framework": "arduino", "name": "Digispark Pro (16 Mhz) (64 byte buffer)", - "platform": "digistump", + "platform": "atmelavr", "upload": { "disable_flushing": false, "maximum_ram_size": 512, @@ -94,7 +94,7 @@ }, "framework": "arduino", "name": "Digistump DigiX", - "platform": "digistump", + "platform": "atmelsam", "upload": { "disable_flushing": false, "maximum_ram_size": 28672, diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 188029d0..e860e0d0 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -57,20 +57,31 @@ env = DefaultEnvironment() SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py"))) -env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), - UPLOADERFLAGS=[ - "-v", - "-D", # disable auto erase for flash memory - "-p", "$BOARD_MCU", - "-C", - '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"), - "-c", "$UPLOAD_PROTOCOL" - ], +if "digispark" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("core", ""): + env.Replace( + UPLOADER=join("$PIOPACKAGES_DIR", "tool-micronucleus", "micronucleus"), + UPLOADERFLAGS=[ + "-c", "$UPLOAD_PROTOCOL", + "--timeout", "60" + ], + UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' + ) - UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i', - UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i' -) +else: + env.Replace( + UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), + UPLOADERFLAGS=[ + "-v", + "-D", # disable auto erase for flash memory + "-p", "$BOARD_MCU", + "-C", + '"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"), + "-c", "$UPLOAD_PROTOCOL" + ], + + UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i', + UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i' + ) CORELIBS = env.ProcessGeneral() diff --git a/platformio/builder/scripts/digistump.py b/platformio/builder/scripts/digistump.py deleted file mode 100644 index dbe540c5..00000000 --- a/platformio/builder/scripts/digistump.py +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright (C) Ivan Kravets -# See LICENSE for details. - -""" - Builder for Digistump boards -""" - -from os.path import join - -from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, - DefaultEnvironment, SConscript) - - -def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 - if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu"): - env.AutodetectUploadPort() - - -env = DefaultEnvironment() - -if "cortex" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", ""): - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) - - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"), - UPLOADERFLAGS=[ - "--info", - "--debug", - "--port", "$UPLOAD_PORT", - "--erase", - "--write", - "--verify", - "--boot", - "--reset" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' - ) - - env.Append( - CPPDEFINES=[ - "printf=iprintf" - ], - - LINKFLAGS=[ - "-Wl,--entry=Reset_Handler", - "-Wl,--start-group" - ] - ) -else: - SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py"))) - - env.Replace( - UPLOADER=join("$PIOPACKAGES_DIR", "tool-micronucleus", "micronucleus"), - UPLOADERFLAGS=[ - "-c", "$UPLOAD_PROTOCOL", - "--timeout", "60" - ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' - ) - -CORELIBS = env.ProcessGeneral() - -# -# Target: Build executable and linkable firmware -# - -target_elf = env.BuildFirmware(["m"] + CORELIBS) - -# -# Target: Build the firmware file -# - -if "cortex" in env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu", ""): - if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.bin") - else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) -else: - if "uploadlazy" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.hex") - else: - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - -# -# Target: Print binary size -# - -target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") -AlwaysBuild(target_size) - -# -# Target: Upload by default firmware file -# - -upload = env.Alias(["upload", "uploadlazy"], target_firm, - [BeforeUpload, "$UPLOADCMD"]) -AlwaysBuild(upload) - -# -# Target: Define targets -# - -Default([target_firm, target_size]) diff --git a/platformio/platforms/atmelavr.py b/platformio/platforms/atmelavr.py index 8e3d9e80..f8b34bb9 100644 --- a/platformio/platforms/atmelavr.py +++ b/platformio/platforms/atmelavr.py @@ -2,9 +2,11 @@ # See LICENSE for details. from platformio.platforms.base import BasePlatform +from platformio.util import get_boards class AtmelavrPlatform(BasePlatform): + """ An embedded platform for Atmel AVR microcontrollers (with Arduino Framework) @@ -18,7 +20,10 @@ class AtmelavrPlatform(BasePlatform): }, "tool-avrdude": { - "alias": "uploader", + "default": True + }, + + "tool-micronucleus": { "default": True }, @@ -33,3 +38,16 @@ class AtmelavrPlatform(BasePlatform): self.on_run_out(line) else: BasePlatform.on_run_err(self, line) + + def run(self, variables, targets): + for v in variables: + if "BOARD=" not in v: + continue + tuploader = "tool-avrdude" + _, board = v.split("=") + bdata = get_boards(board) + if "digispark" in bdata['build']['core']: + tuploader = "tool-micronucleus" + self.PACKAGES[tuploader]['alias'] = "uploader" + break + return BasePlatform.run(self, variables, targets) diff --git a/platformio/platforms/digistump.py b/platformio/platforms/digistump.py deleted file mode 100644 index 8c47b4f2..00000000 --- a/platformio/platforms/digistump.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) Ivan Kravets -# See LICENSE for details. - -from platformio.platforms.base import BasePlatform -from platformio.util import get_boards - - -class DigistumpPlatform(BasePlatform): - - """ - An embedded platform for Digistump boards - (with Arduino Framework) - """ - - PACKAGES = { - - "toolchain-atmelavr": { - "default": True - }, - - "toolchain-gccarmnoneeabi": { - "default": True - }, - - "ldscripts": { - "default": True - }, - - "tool-bossac": { - "default": True - }, - - "tool-micronucleus": { - "default": True - }, - - "framework-arduinoavr": { - "default": True - }, - - "framework-arduinosam": { - "default": True - } - } - - def run(self, variables, targets): - for v in variables: - if "BOARD=" not in v: - continue - _, board = v.split("=") - bdata = get_boards(board) - if "cpu" in bdata['build']: - tpackage = "toolchain-gccarmnoneeabi" - tuploader = "tool-bossac" - else: - tpackage = "toolchain-atmelavr" - tuploader = "tool-micronucleus" - self.PACKAGES[tpackage]['alias'] = "toolchain" - self.PACKAGES[tuploader]['alias'] = "uploader" - break - return BasePlatform.run(self, variables, targets) diff --git a/tests/commands/test_search.py b/tests/commands/test_search.py index 1bac8b91..8864d7b9 100644 --- a/tests/commands/test_search.py +++ b/tests/commands/test_search.py @@ -19,4 +19,4 @@ def test_search_json_output(clirunner, validate_cliresult): def test_search_raw_output(clirunner, validate_cliresult): result = clirunner.invoke(cli, ["arduino"]) validate_cliresult(result) - assert "digistump" in result.output + assert "teensy" in result.output From b60552e264e752751d50f5b65af8ad9944fcd613 Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 23 Feb 2015 22:36:57 +0200 Subject: [PATCH 2/3] Fix builder for assembling files --- platformio/builder/scripts/basearm.py | 12 +++--------- platformio/builder/scripts/baseavr.py | 10 +++------- platformio/builder/scripts/timsp430.py | 10 +++------- platformio/builder/tools/platformio.py | 2 +- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py index a5912786..94ccfec4 100644 --- a/platformio/builder/scripts/basearm.py +++ b/platformio/builder/scripts/basearm.py @@ -18,16 +18,10 @@ env.Replace( RANLIB="arm-none-eabi-ranlib", SIZETOOL="arm-none-eabi-size", - ARFLAGS=["rcs"], + ASCOM=("$AS -o $TARGET -c -x assembler-with-cpp " + "$CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"), - ASFLAGS=[ - "-c", - "-g", # include debugging info (so errors include line numbers) - "-x", "assembler-with-cpp", - "-Wall", - "-mthumb", - "-mcpu=${BOARD_OPTIONS['build']['cpu']}" - ], + ARFLAGS=["rcs"], CPPFLAGS=[ "-g", # include debugging info (so errors include line numbers) diff --git a/platformio/builder/scripts/baseavr.py b/platformio/builder/scripts/baseavr.py index 3164de91..f089937b 100644 --- a/platformio/builder/scripts/baseavr.py +++ b/platformio/builder/scripts/baseavr.py @@ -18,14 +18,10 @@ env.Replace( RANLIB="avr-ranlib", SIZETOOL="avr-size", - ARFLAGS=["rcs"], + ASCOM=("$AS -o $TARGET -c -x assembler-with-cpp " + "$CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"), - ASFLAGS=[ - "-c", - "-g", # include debugging info (so errors include line numbers) - "-x", "assembler-with-cpp", - "-mmcu=$BOARD_MCU" - ], + ARFLAGS=["rcs"], CCFLAGS=[ "-g", # include debugging info (so errors include line numbers) diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py index 1fcf3272..38acec2f 100644 --- a/platformio/builder/scripts/timsp430.py +++ b/platformio/builder/scripts/timsp430.py @@ -23,14 +23,10 @@ env.Replace( RANLIB="msp430-ranlib", SIZETOOL="msp430-size", - ARFLAGS=["rcs"], + ASCOM=("$AS -o $TARGET -c -x assembler-with-cpp " + "$CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"), - ASFLAGS=[ - "-c", - "-g", # include debugging info (so errors include line numbers) - "-x", "-assembler-with-cpp", - "-mmcu=$BOARD_MCU" - ], + ARFLAGS=["rcs"], CCFLAGS=[ "-g", # include debugging info (so errors include line numbers) diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 6fe231b0..153966ff 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -50,7 +50,7 @@ def BuildFirmware(env, corelibs): # enable "cyclic reference" for linker firmenv.Prepend( - _LIBFLAGS="-Wl,--start-group ", + _LIBFLAGS="-Wl,--start-group " ) firmenv.Append( _LIBFLAGS=" -Wl,--end-group" From 6f634e76e7ced9f3712f4479b8b7a3225df66cbc Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 23 Feb 2015 22:37:12 +0200 Subject: [PATCH 3/3] Re-group examples --- .../adafruit-blink}/README.rst | 2 +- .../platformio.ini | 0 .../src/Blink.pde | 0 .../arduino-engduino-library/src/src.pde | 60 ------------------- .../README.rst | 2 +- .../digitstump-mouse}/platformio.ini | 9 +-- .../digitstump-mouse/src/Mouse.ino | 41 +++++++++++++ .../README.rst | 2 +- .../platformio.ini | 0 .../src/Magnetometer.ino | 44 ++++++++++++++ .../digistump/digitstump-blink/src/Blink.ino | 29 --------- 11 files changed, 90 insertions(+), 99 deletions(-) rename examples/{digistump/digitstump-blink => atmelavr-and-arduino/adafruit-blink}/README.rst (88%) rename examples/atmelavr-and-arduino/{arduino-adafruit-blink => adafruit-blink}/platformio.ini (100%) rename examples/atmelavr-and-arduino/{arduino-adafruit-blink => adafruit-blink}/src/Blink.pde (100%) delete mode 100644 examples/atmelavr-and-arduino/arduino-engduino-library/src/src.pde rename examples/atmelavr-and-arduino/{arduino-adafruit-blink => digitstump-mouse}/README.rst (86%) rename examples/{digistump/digitstump-blink => atmelavr-and-arduino/digitstump-mouse}/platformio.ini (83%) create mode 100644 examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino rename examples/atmelavr-and-arduino/{arduino-engduino-library => engduino-magnetometer}/README.rst (86%) rename examples/atmelavr-and-arduino/{arduino-engduino-library => engduino-magnetometer}/platformio.ini (100%) create mode 100644 examples/atmelavr-and-arduino/engduino-magnetometer/src/Magnetometer.ino delete mode 100644 examples/digistump/digitstump-blink/src/Blink.ino diff --git a/examples/digistump/digitstump-blink/README.rst b/examples/atmelavr-and-arduino/adafruit-blink/README.rst similarity index 88% rename from examples/digistump/digitstump-blink/README.rst rename to examples/atmelavr-and-arduino/adafruit-blink/README.rst index 699f2783..290761d5 100644 --- a/examples/digistump/digitstump-blink/README.rst +++ b/examples/atmelavr-and-arduino/adafruit-blink/README.rst @@ -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 diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/platformio.ini b/examples/atmelavr-and-arduino/adafruit-blink/platformio.ini similarity index 100% rename from examples/atmelavr-and-arduino/arduino-adafruit-blink/platformio.ini rename to examples/atmelavr-and-arduino/adafruit-blink/platformio.ini diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/src/Blink.pde b/examples/atmelavr-and-arduino/adafruit-blink/src/Blink.pde similarity index 100% rename from examples/atmelavr-and-arduino/arduino-adafruit-blink/src/Blink.pde rename to examples/atmelavr-and-arduino/adafruit-blink/src/Blink.pde diff --git a/examples/atmelavr-and-arduino/arduino-engduino-library/src/src.pde b/examples/atmelavr-and-arduino/arduino-engduino-library/src/src.pde deleted file mode 100644 index e0168696..00000000 --- a/examples/atmelavr-and-arduino/arduino-engduino-library/src/src.pde +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -// 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); -} diff --git a/examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst b/examples/atmelavr-and-arduino/digitstump-mouse/README.rst similarity index 86% rename from examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst rename to examples/atmelavr-and-arduino/digitstump-mouse/README.rst index 53ac5a6a..f01bea45 100644 --- a/examples/atmelavr-and-arduino/arduino-adafruit-blink/README.rst +++ b/examples/atmelavr-and-arduino/digitstump-mouse/README.rst @@ -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 diff --git a/examples/digistump/digitstump-blink/platformio.ini b/examples/atmelavr-and-arduino/digitstump-mouse/platformio.ini similarity index 83% rename from examples/digistump/digitstump-blink/platformio.ini rename to examples/atmelavr-and-arduino/digitstump-mouse/platformio.ini index 89ac6161..00f36aae 100644 --- a/examples/digistump/digitstump-blink/platformio.ini +++ b/examples/atmelavr-and-arduino/digitstump-mouse/platformio.ini @@ -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 diff --git a/examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino b/examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino new file mode 100644 index 00000000..17f14ff9 --- /dev/null +++ b/examples/atmelavr-and-arduino/digitstump-mouse/src/Mouse.ino @@ -0,0 +1,41 @@ +// DigiMouse test and usage documentation +// CAUTION!!!! This does click things!!!!!!!! +// Originally created by Sean Murphy (duckythescientist) + +#include + +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) +} diff --git a/examples/atmelavr-and-arduino/arduino-engduino-library/README.rst b/examples/atmelavr-and-arduino/engduino-magnetometer/README.rst similarity index 86% rename from examples/atmelavr-and-arduino/arduino-engduino-library/README.rst rename to examples/atmelavr-and-arduino/engduino-magnetometer/README.rst index 62b224b0..4aed8102 100644 --- a/examples/atmelavr-and-arduino/arduino-engduino-library/README.rst +++ b/examples/atmelavr-and-arduino/engduino-magnetometer/README.rst @@ -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 diff --git a/examples/atmelavr-and-arduino/arduino-engduino-library/platformio.ini b/examples/atmelavr-and-arduino/engduino-magnetometer/platformio.ini similarity index 100% rename from examples/atmelavr-and-arduino/arduino-engduino-library/platformio.ini rename to examples/atmelavr-and-arduino/engduino-magnetometer/platformio.ini diff --git a/examples/atmelavr-and-arduino/engduino-magnetometer/src/Magnetometer.ino b/examples/atmelavr-and-arduino/engduino-magnetometer/src/Magnetometer.ino new file mode 100644 index 00000000..ccd284d5 --- /dev/null +++ b/examples/atmelavr-and-arduino/engduino-magnetometer/src/Magnetometer.ino @@ -0,0 +1,44 @@ +#include +#include + +// 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); +} \ No newline at end of file diff --git a/examples/digistump/digitstump-blink/src/Blink.ino b/examples/digistump/digitstump-blink/src/Blink.ino deleted file mode 100644 index b0db92b8..00000000 --- a/examples/digistump/digitstump-blink/src/Blink.ino +++ /dev/null @@ -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 -}