54 lines
1009 B
C++
54 lines
1009 B
C++
/*
|
|
Simple test of a LoRa RA-01 module usign RadioLib on an Arduino 101
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
#include <Adafruit_SSD1306.h>
|
|
|
|
|
|
#define OLED_SDA_PIN 16
|
|
#define OLED_SCL_PIN 17
|
|
|
|
#define LOCKUP(x) do{Serial.println(x);delay(1000);}while(true)
|
|
|
|
#define OLED_WIDTH 128
|
|
#define OLED_HEIGHT 64
|
|
#define OLED_ADDRESS 0xbc ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
|
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, -1);
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(9600);
|
|
Wire.setSDA(OLED_SDA_PIN);
|
|
Wire.setSCL(OLED_SCL_PIN);
|
|
|
|
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS)) {
|
|
LOCKUP("display init error");
|
|
}
|
|
display.clearDisplay();
|
|
}
|
|
|
|
void write_str(Adafruit_SSD1306* display, String str)
|
|
{
|
|
for (char c : str) {
|
|
display->write(c);
|
|
}
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
display.clearDisplay();
|
|
|
|
display.setTextSize(1);
|
|
display.setTextColor(SSD1306_WHITE);
|
|
display.setCursor(0,0);
|
|
display.cp437(true);
|
|
write_str(&display, "Ciao Mamma");
|
|
display.display();
|
|
|
|
delay(2000);
|
|
}
|