1
TinyDuino Processors & TinyShields / Re: Tinyscreen+ keep RTC alive while tunr off
« on: September 22, 2020, 11:31:50 AM »
Thank you! I actually did not know that there was a tutorial on that subject. Thank you very much!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
//-------------------------------------------------------------------------------
//
// This example should help new users to communicate to their tinyarcades via serial port
//
// Written by Pablo Jimenez Mateo
//-------------------------------------------------------------------------------
#include <Wire.h>
#include <TinyScreen.h>
TinyScreen display = TinyScreen(TinyScreenPlus);
void setup(void) {
Wire.begin();//initialize I2C before we can initialize TinyScreen- not needed for TinyScreen+
display.begin();
display.setBrightness(10);
//This is for serial communication
USBDevice.init();
USBDevice.attach();
SerialUSB.begin(9600);
}
void loop() {
delay(1500);
SerialUSB.println("Hi");
String cmd = "";
//Read an entire line from serial
while (SerialUSB.available() > 0) {
cmd += (char)SerialUSB.read();
}
if (cmd.length() > 2) {
writeText(cmd);
} else {
writeText("No text :(");
}
}
void writeText(String text){
//String to char*
char t[text.length()+1];
text.toCharArray(t, text.length() + 1);
display.clearScreen();
//setFont sets a font info header from font.h
//information for generating new fonts is included in font.h
display.setFont(thinPixel7_10ptFontInfo);
int width = display.getPrintWidth(t);
//setCursor(x,y);//set text cursor position to (x,y)- in this example, the example string is centered
display.setCursor(48-(width/2),20);
//fontColor(text color, background color);//sets text and background color
display.fontColor(TS_8b_Green,TS_8b_Black);
display.print(t);
}
void setup(void) {
Wire.begin();//initialize I2C before we can initialize TinyScreen- not needed for TinyScreen+
display.begin();
//setBrightness(brightness);//sets main current level, valid levels are 0-15
display.setBrightness(10);
Serial.begin(9600);
}
void loop() {
Serial.print("hello!");
}