Created
May 24, 2020 18:47
-
-
Save mstaack/5a523c8f82a2f3e33c670b8f720fbbe9 to your computer and use it in GitHub Desktop.
Teensy 4.1 Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#include "USBHost_t36.h" | |
#include "LoRa_E32.h" | |
#define SCREEN_WIDTH 128 // OLED display width, in pixels | |
#define SCREEN_HEIGHT 32 // OLED display height, in pixels | |
#define HWSERIAL Serial1 | |
// LoRa_E32 e32ttl100(&HWSERIAL, 13, 11, 12); | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, 4); | |
void setup() | |
{ | |
Wire.begin(); | |
HWSERIAL.begin(9600); | |
while (!Serial); // Wait for USB Serial | |
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64 | |
Serial.println(F("SSD1306 allocation failed")); | |
for (;;); | |
} | |
// e32ttl100.begin(); | |
// Serial.println("Fetching Uplink Settings"); | |
// ResponseStructContainer c; | |
// c = e32ttl100.getConfiguration(); | |
// Configuration configuration = *(Configuration*) c.data; | |
// Serial.println(c.status.getResponseDescription()); | |
// Serial.println(c.status.code); | |
// Serial.println(configuration.SPED.getUARTBaudRate()); | |
delay(1000); // wait a sec | |
display.clearDisplay(); | |
Serial.println("Booting finished"); | |
} | |
void loop() | |
{ | |
if (Serial.available() > 0) { | |
// read the incoming byte: | |
String input = Serial.readString(); | |
Serial.println("Received:"); | |
Serial.println(input); | |
HWSERIAL.println(input); | |
display.clearDisplay(); | |
display.setTextSize(1); // legt die Schriftgöße fest | |
display.setTextColor(WHITE); | |
display.setCursor(0, 2); | |
display.println(input); //Textzeile ausgeben | |
display.display(); | |
} | |
if (HWSERIAL.available() > 0) { | |
// read the incoming byte: | |
char input = HWSERIAL.read(); | |
HWSERIAL.print(input); | |
Serial.println("Received via Uplink:"); | |
Serial.println(input); | |
display.clearDisplay(); | |
display.setTextSize(1); // legt die Schriftgöße fest | |
display.setTextColor(WHITE); | |
display.setCursor(0, 2); | |
display.println(input); //Textzeile ausgeben | |
display.display(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment