Code Monkey home page Code Monkey logo

readlines's Introduction

ReadLines

An Arduino library for reading a file, line by line, from an SD card.

Supported Boards

This library does not contain board-specific code, but it only been tested on

If you have used it successfully on a different board, please indicate, so this list can be updated.

Usage with inline callback function

#include <SPI.h>
#include <SD.h>
#include <ReadLines.h>

char line1[RL_MAX_CHARS];

void setup() {
    Serial.begin(9600);

    while (!SD.begin(D8)) {
        Serial.println("initialization failed!");
        delay(1000);
    }
}

void loop() {
    RL.readLines("sample-file.txt", [](char* line, int index) {
        Serial.println(String(line) + " " + String(index));
    });
}

Usage with pre-declared callback function

/** add above setup code here */

void loop() {
    RL.readLines("sample-file.txt", &handleEachLine);
}

void handleEachLine(char line[], int lineIndex) {
    Serial.println(String(line) + " " + String(index));
}

Usage (Method Overrides)

You may omit the 2nd argument int lineIndex in the RL.readLines callback function, so the definition for handleEachLine becomes:

void handleEachLine(char line[]) {
    Serial.println(String(line));
}

You may also pass in File object as the 1st argument in the RL.readLines callback function, like:

void loop() {
    File txtFile = SD.open("setup.txt");
    RL.readLines(txtFile, &handleEachLine);
    txtFile.close();
}

void handleEachLine(char line[]) {
    Serial.println(String(line));
}

readlines's People

Contributors

mykeels avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ak-agus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.