-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (40 loc) · 1.01 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#define OLED_MOSI D0
#define OLED_CLK D1
#define OLED_DC D2
#define OLED_CS D3
#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
int setLines(String lines) {
display.clearDisplay();
// text display tests
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
String input = lines;
int lastMatch = 0;
// A comma is used as a line seperator. "Hello,World" gets:
// Hello
// World
for (int i = 0; i < input.length(); i++) {
if (input.substring(i, i + 1) == ",") {
display.println(input.substring(lastMatch, i));
lastMatch = i + 1;
}
// done
if(i == input.length() - 1){
display.println(input.substring(lastMatch, i + 1));
}
}
display.display();
return 1;
}
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
setLines("Please,send,your,data");
Spark.function("lines",setLines);
}
void loop() {
}