Skip to content

Add Stream support to SerialFlashFile#41

Open
sandeepmistry wants to merge 1 commit intoPaulStoffregen:masterfrom
sandeepmistry:stream
Open

Add Stream support to SerialFlashFile#41
sandeepmistry wants to merge 1 commit intoPaulStoffregen:masterfrom
sandeepmistry:stream

Conversation

@sandeepmistry
Copy link

It would be nice if SerialFlashFile extended Stream like the SD' libraries File class.

Here's a simple sketch to test with:

#include <SerialFlash.h>

const char* filename = "test.txt";


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

  SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN);

  SerialFlash.eraseAll();
  while (!SerialFlash.ready());

  SerialFlash.create("test.txt", 24);

  SerialFlashFile flashFileOut = SerialFlash.open(filename);
  flashFileOut.println("blah 1");
  flashFileOut.println("blah 2");
  flashFileOut.println("blah 3");
  flashFileOut.close();

  SerialFlashFile flashFileIn = SerialFlash.open(filename);
  while (flashFileIn.available()) {
    Serial.print("peek = 0x");
    Serial.println(flashFileIn.peek(), HEX);

    Serial.print("read = ");
    Serial.println((char)flashFileIn.read());
  }
}

void loop() {
}

cc/ @cmaglie @facchinm

@sandeepmistry
Copy link
Author

@PaulStoffregen ping, any interest in this change and the other one proposed in #42?

@Nathan-ma
Copy link

oh this is very interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants