mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-05 06:50:42 +08:00

Add support of dos shortname for sharedSD (mainly for Marlin) Add SDFat version in report for reference
42 lines
879 B
C++
42 lines
879 B
C++
/*
|
|
* Demo of ArduinoInStream and ArduinoOutStream
|
|
*/
|
|
#include <SPI.h>
|
|
#include "SdFat.h"
|
|
#include "sdios.h"
|
|
|
|
using namespace sdfat;
|
|
|
|
// create serial output stream
|
|
ArduinoOutStream cout(Serial);
|
|
|
|
// input line buffer
|
|
char cinBuf[40];
|
|
|
|
// create serial input stream
|
|
ArduinoInStream cin(Serial, cinBuf, sizeof(cinBuf));
|
|
//------------------------------------------------------------------------------
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
// Wait for USB Serial
|
|
while (!Serial) {
|
|
SysCall::yield();
|
|
}
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
void loop() {
|
|
int32_t n = 0;
|
|
|
|
cout << "\nenter an integer\n";
|
|
|
|
cin.readline();
|
|
|
|
if (cin >> n) {
|
|
cout << "The number is: " << n;
|
|
} else {
|
|
// will fail if no digits or not in range [-2147483648, 2147483647]
|
|
cout << "Invalid input: " << cinBuf;
|
|
}
|
|
cout << endl;
|
|
}
|