Dependancies
🌳 An outdoor LoRa-GPS tracker with an E-Ink display 🔑
Reading and writing a simple integer to the non-volatile flash memory.
Dependancies
Write an integer to the flash. And then increment and store it again. In the process, this example will read and write to the flash storage.
ls -al /dev/cu.usbmodem
and arduino-cli board list
. Run make
to compile and upload the code to the board.
#include <FlashStorage.h>
FlashStorage(my_flash_store, int);
void setup() {
SerialUSB.begin(9600);
while (!SerialUSB) {}
SerialUSB.println("Testing reading and writing into the flash...");
int number;
number = my_flash_store.read();
SerialUSB.println("Read number: " + String(number));
my_flash_store.write(number + 1);
number = my_flash_store.read();
SerialUSB.println("Read number after increment: " + String(number));
}
void loop() { }
BOARD?=hutscape:samd:oak
PORT := $(shell ls /dev/cu.usbmodem*)
BUILD=build
.PHONY: default lint all flash clean
default: lint all flash clean
lint:
cpplint --extensions=ino --filter=-legal/copyright *.ino
all:
arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./
flash:
arduino-cli upload -p $(PORT) --fqbn $(BOARD) --input-dir $(BUILD) --verbose
clean:
rm -r build