### Example ATTinyCore Makefile Configuration Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/Ref_Makefile.md This Makefile is designed for use with the Sudar Arduino.mk. Ensure the ARDMK_DIR points to your Arduino-Makefile installation. ```makefile ### DISCLAIMER ### This Makefile is designed for use with the sudar Arduino.mk ### Refer to https://github.com/sudar/Arduino-Makefile ### Currently sudar version 1.5.2 (2017-01-11) ### ### Enter make help for all runtime options ### PROJECT_DIR ### This is the base path to where you have created/cloned your project PROJECT_DIR = /home/username/Arduino ### AVR_GCC_VERSION ### Check if the version is equal or higher than 4.9 AVR_GCC_VERSION := $(shell expr `avr-gcc -dumpversion | cut -f1` \>= 4.9) ### ARDMK_DIR ### Path to the Arduino-Makefile directory. ARDMK_DIR = $(PROJECT_DIR)/Arduino-Makefile ### ARDUINO_DIR ``` -------------------------------- ### Temperature Measurement Setup Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x7.md To measure temperature, select the 1.1v internal voltage reference and use `analogRead(ADC_TEMPERATURE)`. Calibration is required for accurate readings. ```c++ analogRead(ADC_TEMPERATURE); ``` -------------------------------- ### Analog Pin Read Example Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/Ref_Migration.md Demonstrates correct usage of analogRead() with ATTinyCore, preferring A# constants or PIN_Pxn notation over direct digital pin numbers. ```C++ analogRead(5) (deprecated) analogRead(PIN_PB5) analogRead(A0) ``` -------------------------------- ### Building Optiboot with Arduino IDE Tools (Windows) Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/bootloaders/optiboot/source/README.md Use this command to build Optiboot when working within the Arduino IDE installation on a Windows system. Ensure you are in the correct directory and using the Windows command shell. ```makefile make OS=windows ENV=arduino ``` -------------------------------- ### Building Optiboot with Arduino IDE Tools (macOS) Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/bootloaders/optiboot/source/README.md Use this command to build Optiboot when working within the Arduino IDE installation on a macOS system. Ensure you are in the correct directory. ```makefile make OS=macosx ENV=arduino ``` -------------------------------- ### Brightness and Configuration Functions Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/tinyNeoPixel.md Functions for setting and getting brightness, clearing pixels, and managing the output pin. ```APIDOC ## setBrightness(uint8_t) ### Description Sets the brightness for the whole string (0-255). Adjusting brightness is done by multiplying each color channel by the given brightness, then taking the high byte. This process is lossy, and frequent adjustments can lead to quantization errors. This adjustment is performed on the whole pixel array when `setBrightness()` is called, and on specific pixels any time their brightness is changed. ### Method `setBrightness(uint8_t)` ## clear() ### Description Clears the pixel buffer, setting all colors on all LEDs to 0. ### Method `clear()` ## setPin(uint8_t p) ### Description Sets the pin for output. For `tinyNeoPixel_Static`, ensure this pin is set to OUTPUT. `tinyNeoPixel` calls `pinMode()` on the pin. ### Method `setPin(uint8_t p)` ## getBrightness() ### Description Returns the current brightness setting. ### Method `getBrightness()` ## getPin() ### Description Returns the current pin number. ### Method `getPin()` ``` -------------------------------- ### EEPROM.get(address, object) Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/libraries/EEPROM/README.md Retrieves any object from the EEPROM starting at the specified address. ```APIDOC ## EEPROM.get(address, object) ### Description Retrieves any object from the EEPROM. ### Parameters #### Path Parameters - **address** (int) - Required - The starting address from which to read the object. - **object** (any) - Required - The object to read into. ### Response #### Success Response - **reference to object** - A reference to the object passed in, returned for convenience. ``` -------------------------------- ### EEPROM.begin() Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/libraries/EEPROM/README.md Returns an EEPtr pointing to the first cell in the EEPROM, useful for iteration. ```APIDOC ## EEPROM.begin() ### Description This function returns an `EEPtr` object that points to the first cell in the EEPROM memory. It is particularly useful for integrating with STL objects, creating custom iteration logic, and utilizing C++11 style ranged for loops. ### Usage ```cpp // Example usage with a range-based for loop: for (EEPtr it = EEPROM.begin(); it != EEPROM.end(); ++it) { // Access or modify the EEPROM cell using *it } ``` ``` -------------------------------- ### Differential ADC Channel Configuration Example Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_26.md This example shows how to configure the differential ADC to measure the voltage difference between ADC0 (PA0) and ADC1 (PA1) with a gain of 20x. The channel name 'DIFF_A0_A1_20X' corresponds to the specific configuration. ```c++ analogRead(DIFF_A0_A1_20X); ``` -------------------------------- ### ATtiny1634 WDT Workaround Setup Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_1634.md Configure the Watchdog Timer (WDT) to interrupt mode with the longest prescale option to work around a silicon errata affecting PB3 when the WDT is not needed. This setup consumes minimal flash and power. ```c CCP = 0xD8; //write key to configuration change protection register WDTCSR = (1 << WDP3) | (1 << WDP0) | (1 << WDIE); //enable WDT interrupt with longest prescale option (8 seconds) ``` -------------------------------- ### Arduino.mk Configuration Output Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/Ref_Makefile.md This output shows the detected and configured settings for an Arduino.mk build, including paths, versions, and board-specific options. ```makefile $ make ------------------------- Arduino.mk Configuration: - [AUTODETECTED] CURRENT_OS = LINUX - [USER] ARDUINO_DIR = /home/username/arduino-1.6.11 - [USER] ARDMK_DIR = /home/username/Arduino/Arduino-Makefile - [AUTODETECTED] ARDUINO_VERSION = 1611 - [DEFAULT] ARCHITECTURE = avr - [DEFAULT] ARDMK_VENDOR = arduino - [AUTODETECTED] ARDUINO_PREFERENCES_PATH = /home/username/.arduino15/preferences.txt - [AUTODETECTED] ARDUINO_SKETCHBOOK = /home/username/Arduino (from arduino preferences file) - [USER] AVR_TOOLS_DIR = /home/username/arduino-1.6.11/hardware/tools/avr - [COMPUTED] ARDUINO_LIB_PATH = /home/username/arduino-1.6.11/libraries (from ARDUINO_DIR) - [COMPUTED] ARDUINO_PLATFORM_LIB_PATH = /home/username/arduino-1.6.11/hardware/arduino/avr/libraries (from ARDUINO_DIR) - [USER] ALTERNATE_CORE = ATTinyCore - [COMPUTED] ALTERNATE_CORE_PATH = /home/username/Arduino/hardware/ATTinyCore/avr (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE) - [COMPUTED] ARDUINO_VAR_PATH = /home/username/Arduino/hardware/ATTinyCore/avr/variants (from ALTERNATE_CORE_PATH) - [COMPUTED] BOARDS_TXT = /home/username/Arduino/hardware/ATTinyCore/avr/boards.txt (from ALTERNATE_CORE_PATH) - [DEFAULT] USER_LIB_PATH = /home/username/Arduino/libraries (in user sketchbook) - [DEFAULT] PRE_BUILD_HOOK = pre-build-hook.sh - [USER] BOARD_SUB = 85 - [USER] BOARD_TAG = attinyx5 - [COMPUTED] CORE = tiny (from build.core) - [COMPUTED] VARIANT = tinyx5 (from build.variant) - [USER] OBJDIR = /home/username/Arduino/ULPFlasher3/attinyx5/bin - [COMPUTED] ARDUINO_CORE_PATH = /home/username/Arduino/hardware/ATTinyCore/avr/cores/tiny (from ALTERNATE_CORE_PATH, BOARD_TAG and boards.txt) - [USER] MONITOR_BAUDRATE = 115200 - [DEFAULT] OPTIMIZATION_LEVEL = s - [DEFAULT] MCU_FLAG_NAME = mmcu - [USER] CFLAGS_STD = -std=gnu11 - [USER] CXXFLAGS_STD = -std=gnu++11 - [COMPUTED] DEVICE_PATH = /dev/ttyS0 (from MONITOR_PORT) - [DEFAULT] FORCE_MONITOR_PORT = - [AUTODETECTED] Size utility: AVR-aware for enhanced output - [COMPUTED] BOOTLOADER_PARENT = /home/username/arduino-1.6.11/hardware/arduino/avr/bootloaders (from ARDUINO_DIR) - [COMPUTED] ARDMK_VERSION = 1.5 - [COMPUTED] CC_VERSION = 4.9.2 (avr-gcc) ------------------------- ``` -------------------------------- ### ATtiny828 WDT Workaround for PD3 Pin Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_828.md This code snippet demonstrates how to enable the WDT in interrupt mode to work around a silicon bug on the PD3 pin when the WDT is not otherwise needed. It includes an empty ISR and the necessary setup in the setup() function. ```c CCP=0xD8; //write key to configuration change protection register WDTCSR=(1< #define NUMLEDS 100 tinyNeoPixel leds = tinyNeoPixel(NUMLEDS, PIN_PA6, NEO_GRB); void setup() { leds.begin(); leds.setPixelColor(0,255,0,0); // first LED full RED leds.show(); // LED turns on. } void loop() {/* empty loop */} ``` -------------------------------- ### Include EEPROM Library Source: https://github.com/spencekonde/attinycore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/libraries/EEPROM/README.md Include the EEPROM library header file at the beginning of your sketch to use its functionality. ```Arduino #include void setup() { } void loop() { } ```