update stuff

master
ThirstyShark 5 years ago
parent fdf66740cd
commit 79e2bc982b

@ -1,7 +1,9 @@
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_TFTLCD.h"
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
word pin00 = 0;
word pin01 = 1;
@ -87,6 +89,9 @@ word pinA15 = A15;
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, A0);
String outtext = "";
String oldtext = "";
boolean fastboot = false;
boolean debug = true;
// Plant logo
static unsigned const char images_bits[] PROGMEM = {
@ -798,6 +803,8 @@ static unsigned const char images_bits[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
boolean ps3 = false;
boolean upd;
void setup(void) {
Serial.begin(9600);
@ -829,38 +836,91 @@ void setup(void) {
tft.begin(0x9341);
tft.setRotation(1);
tft.fillScreen(WHITE);
tft.drawXBitmap(0, 14, images_bits, 320, 212, GREEN); // loading
delay(5000);
tft.fillScreen(BLACK);
//tft.fillRect(0, 0, 320, 23, BLACK);
printConsoleText("Booting GreenhouseOS...");
delay(1000);
printConsoleText("Stuff.co.nz: Latest breaking news NZ;https://www.stuff.co.nz/;Breaking news and videos of today's latest news stories from around New Zealand, including up to date weather, World, sport, business, Entertainment, ...;National · World · Sport · Stuff Nation;Top stories;Tiny town straddling state highway pushes for safer speeds;Stuff.co.nz·3 hours ago;What is really driving the 'vilification' of Meghan Markle?;Stuff.co.nz·1 hour ago;Struggling Julian Savea told to leave Toulon by angry boss - report;Stuff.co.nz·2 hours ago;More for stuff;Web results;National News | Stuff.co.nz");
printConsoleText("About 1,780,000,000 results (0.74 seconds) ;Search Results;Web results;World of Warcraft;https://worldofwarcraft.com/;Join thousands of mighty heroes in Azeroth, a world of magic and limitless adventure.;Getting Started - WoW · Eu · Battle for Azeroth · Battle for Azeroth - Media - WoW;WOW! Internet Cable and Phone - Bundle offers and support;https://www.wowway.com/;Explore offers with WOW! Internet, Cable TV and Home Phone. Find the offer and t");
printConsoleText("#include <string.h>;#include <conio.h>;#include <ctype.h>;#include <windows.h>;int main(int argc, char *argv[]);{;char sentzz[]=\"HELLO I AM A TEXT SCROLL\"; \";int x; //special dialogue;int size; ;size=strlen(senta); for(x=0;x<size;x++); { ; Sleep(40); printf(\"%c\",senta[x]); }; getch(); }");
clearLog();
printConsoleText("In my younger and more vulnerable years my father gave me some advice that Ive been turning over in my mind ever since. Whenever you feel like criticizing any one, he told me, just remember that all the people in this world havent had the advantages that youve had.");
printConsoleText("He didnt say any more but weve always been unusually communicative in a reserved way, and I understood that he meant a great deal more than that. In consequence Im inclined to reserve all judgments, a habit that has opened up many curious natures to me and also made me the victim of not a few veteran bores. The abnormal mind is quick to detect and attach itself to this quality when it appears in a normal person, and so it came about that in college I was unjustly accused of being a politician, because I was privy to the secret griefs of wild, unknown men. Most of the confidences were unsought-frequently I have feigned sleep, preoccupation, or a hostile levity when I realized by some unmistakable sign that an intimate revelation was quivering on the horizon-for the intimate revelations of young men or at least the terms in which they express them are usually plagiaristic and marred by obvious suppressions. Reserving judgments is a matter of infinite hope.");
delay(1000);
if(!fastboot) {
tft.fillScreen(WHITE);
tft.drawXBitmap(0, 14, images_bits, 320, 212, GREEN); // loading
delay(4000);
tft.fillScreen(WHITE);
delay(1000);
//tft.fillRect(0, 0, 320, 23, BLACK);
printConsoleText("Booting GreenhouseOS...||");
delay(250);
}
//printConsoleText("Stuff.co.nz: Latest breaking news NZ;https://www.stuff.co.nz/;Breaking news and videos of today's latest news stories from around New Zealand, including up to date weather, World, sport, business, Entertainment, ...;National · World · Sport · Stuff Nation;Top stories;Tiny town straddling state highway pushes for safer speeds;Stuff.co.nz·3 hours ago;What is really driving the 'vilification' of Meghan Markle?;Stuff.co.nz·1 hour ago;Struggling Julian Savea told to leave Toulon by angry boss - report;Stuff.co.nz·2 hours ago;More for stuff;Web results;National News | Stuff.co.nz");
//printConsoleText("About 1,780,000,000 results (0.74 seconds) ;Search Results;Web results;World of Warcraft;https://worldofwarcraft.com/;Join thousands of mighty heroes in Azeroth, a world of magic and limitless adventure.;Getting Started - WoW · Eu · Battle for Azeroth · Battle for Azeroth - Media - WoW;WOW! Internet Cable and Phone - Bundle offers and support;https://www.wowway.com/;Explore offers with WOW! Internet, Cable TV and Home Phone. Find the offer and t");
//printConsoleText("#include <string.h>;#include <conio.h>;#include <ctype.h>;#include <windows.h>;int main(int argc, char *argv[]);{;char sentzz[]=\"HELLO I AM A TEXT SCROLL\"; \";int x; //special dialogue;int size; ;size=strlen(senta); for(x=0;x<size;x++); { ; Sleep(40); printf(\"%c\",senta[x]); }; getch(); }");
//clearLog();
//printConsoleText("In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. 'Whenever you feel like criticizing any one,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'");
//printConsoleText("He didnt say any more but weve always been unusually communicative in a reserved way, and I understood that he meant a great deal more than that. In consequence Im inclined to reserve all judgments, a habit that has opened up many curious natures to me and also made me the victim of not a few veteran bores. The abnormal mind is quick to detect and attach itself to this quality when it appears in a normal person, and so it came about that in college I was unjustly accused of being a politician, because I was privy to the secret griefs of wild, unknown men. Most of the confidences were unsought-frequently I have feigned sleep, preoccupation, or a hostile levity when I realized by some unmistakable sign that an intimate revelation was quivering on the horizon-for the intimate revelations of young men or at least the terms in which they express them are usually plagiaristic and marred by obvious suppressions. Reserving judgments is a matter of infinite hope.");
//delay(1000);
printConsoleText("[ OK ] Enabling powersaving features... "); // 53 characters wide
enablePS(3);
upd = true;
}
void loop(void) {
if (ps3) {
ADCSRA = 0;
}
if(Serial.available() > 0) {
String txtin = "Serial: " + Serial.readString();
printConsoleText(txtin.substring(0, txtin.length() - 1));
}
// change upd to true if screen update needed
if(!debug && upd) {
tft.fillScreen(BLACK);
tft.fillRect(0, 0, 320, 20, WHITE);
tft.setCursor(2, 2);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.print("Water Level: ");
upd = false;
}
}
ISR (WDT_vect)
{
wdt_disable(); // disable watchdog
} // end of WDT_vect
void enablePS(int level) {
if (level > 0) {
for(int x = 0; x <= 21; x++) {
pinMode(x, OUTPUT);
digitalWrite(x, LOW);
}
for(int x = 32; x <= 53; x++) {
pinMode(x, OUTPUT);
digitalWrite(x, LOW);
}
printConsoleText("[ OK ] Enabled Level 1 powersaving.");
} else {
printConsoleText("[FAILED] Powersaving: Argument must be > 0.");
}
if(level > 1) {
Serial.end();
power_adc_disable();
power_spi_disable();
power_usart0_disable();
power_usart1_disable();
power_usart2_disable();
power_timer1_disable();
power_timer2_disable();
power_timer3_disable();
power_timer4_disable();
power_timer5_disable();
power_twi_disable();
printConsoleText("[ OK ] Enabled Level 2 powersaving.");
}
if(level > 2) {
// disable ADC
ADCSRA = 0;
power_all_disable();
ps3 = true;
printConsoleText("[ OK ] Enabled Level 3 powersaving.|[ INFO ] All powersaving features enabled.");
}
}
@ -869,44 +929,57 @@ void clearLog() {
}
void printConsoleText(String text) {
if(outtext.equals("")) {
if (outtext.equals("") && debug) {
tft.fillScreen(BLACK);
}
if(text.length() <= 53) {
outtext += text + ";";
oldtext = outtext;
if (text.length() <= 53) {
outtext += text + "|";
} else {
for(int x = 0; x < text.length() - text.length() % 53; x += 53) {
outtext += text.substring(x, x + 53) + ";";
int l = text.length() - text.length() % 53;
for (int x = 0; x < l; x += 53) {
boolean keep = true;
for (int y = 0; y < 53; y++) {
if (text.substring(x + y, x + y + 1).equals("|")) {
keep = false;
}
}
if (keep) {
outtext += text.substring(x, x + 53) + "|";
} else {
outtext += text.substring(x, x + 53);
}
}
if(text.length() % 53 != 0) {
outtext += text.substring(text.length() - text.length() % 53, text.length()) + ";";
outtext += text.substring(text.length() - text.length() % 53, text.length()) + "|";
}
}
int count = countSemicolons(outtext);
while (count > 30) {
outtext.remove(0, outtext.indexOf(";") + 1);
outtext.remove(0, outtext.indexOf("|") + 1);
count--;
}
//tft.setCursor(0, 0);
//tft.fillScreen(BLACK);
//tft.setCursor(0, (count) * 8);
tft.setTextColor(WHITE);
String out = "";
for(int x = count - 1; x >= 0; x--) {
//tft.setCursor(0, tft.getCursorY() - 8);
//tft.fillRect(0, tft.getCursorY(), 320, 8, BLACK);
//tft.print(getString(outtext, x));
out += getString(outtext, x) + "\n";
if(debug) {
//tft.setCursor(0, 0);
//tft.fillScreen(BLACK);
tft.setCursor(0, (count) * 8);
tft.setTextColor(WHITE);
tft.setTextSize(1);
for(int x = count - 1; x >= 0; x--) {
String tmp = getString(outtext, x);
tft.setCursor(0, tft.getCursorY() - 8);
if(!tmp.equals(getString(oldtext, x))) {
tft.fillRect(0, tft.getCursorY(), 320, 8, BLACK);
tft.print(tmp);
}
}
}
tft.setTextSize(1);
tft.setCursor(0, 0);
tft.fillScreen(BLACK);
tft.print(out);
}
int countSemicolons(String s) {
int newlines = 0;
for(int x = 0; x < s.length(); x++) {
if(s.substring(x, x + 1).equals(";")) {
int l = s.length();
for(int x = 0; x < l; x++) {
if(s.substring(x, x + 1).equals("|")) {
newlines ++;
}
}
@ -916,7 +989,7 @@ String getString(String s, int index) {
int count = 0;
int lastsemi = 0;
for (int x = 0; x < s.length(); x++) {
if(s.substring(x, x + 1).equals(";")) {
if(s.substring(x, x + 1).equals("|")) {
count ++;
if(count - 1 == index) {
return s.substring(lastsemi, x);
@ -927,245 +1000,3 @@ String getString(String s, int index) {
}
return "";
}
unsigned long testFillScreen() {
unsigned long start = micros();
tft.fillScreen(BLACK);
tft.fillScreen(RED);
tft.fillScreen(GREEN);
tft.fillScreen(BLUE);
tft.fillScreen(BLACK);
return micros() - start;
}
unsigned long testText() {
tft.fillScreen(BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setTextColor(WHITE); tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(YELLOW); tft.setTextSize(2);
tft.println(1234.56);
tft.setTextColor(RED); tft.setTextSize(3);
tft.println(0xDEADBEEF, HEX);
tft.println();
tft.setTextColor(GREEN);
tft.setTextSize(5);
tft.println("Groop");
tft.setTextSize(2);
tft.println("I implore thee,");
tft.setTextSize(1);
tft.println("my foonting turlingdromes.");
tft.println("And hooptiously drangle me");
tft.println("with crinkly bindlewurdles,");
tft.println("Or I will rend thee");
tft.println("in the gobberwarts");
tft.println("with my blurglecruncheon,");
tft.println("see if I don't!");
return micros() - start;
}
unsigned long testLines(uint16_t color) {
unsigned long start, t;
int x1, y1, x2, y2,
w = tft.width(),
h = tft.height();
tft.fillScreen(BLACK);
x1 = y1 = 0;
y2 = h - 1;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = w - 1;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t = micros() - start; // fillScreen doesn't count against timing
tft.fillScreen(BLACK);
x1 = w - 1;
y1 = 0;
y2 = h - 1;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = 0;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t += micros() - start;
tft.fillScreen(BLACK);
x1 = 0;
y1 = h - 1;
y2 = 0;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = w - 1;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t += micros() - start;
tft.fillScreen(BLACK);
x1 = w - 1;
y1 = h - 1;
y2 = 0;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = 0;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
return micros() - start;
}
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
unsigned long start;
int x, y, w = tft.width(), h = tft.height();
tft.fillScreen(BLACK);
start = micros();
for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
return micros() - start;
}
unsigned long testRects(uint16_t color) {
unsigned long start;
int n, i, i2,
cx = tft.width() / 2,
cy = tft.height() / 2;
tft.fillScreen(BLACK);
n = min(tft.width(), tft.height());
start = micros();
for(i=2; i<n; i+=6) {
i2 = i / 2;
tft.drawRect(cx-i2, cy-i2, i, i, color);
}
return micros() - start;
}
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
unsigned long start, t = 0;
int n, i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
n = min(tft.width(), tft.height());
for(i=n; i>0; i-=6) {
i2 = i / 2;
start = micros();
tft.fillRect(cx-i2, cy-i2, i, i, color1);
t += micros() - start;
// Outlines are not included in timing results
tft.drawRect(cx-i2, cy-i2, i, i, color2);
}
return t;
}
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
unsigned long start;
int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
tft.fillScreen(BLACK);
start = micros();
for(x=radius; x<w; x+=r2) {
for(y=radius; y<h; y+=r2) {
tft.fillCircle(x, y, radius, color);
}
}
return micros() - start;
}
unsigned long testCircles(uint8_t radius, uint16_t color) {
unsigned long start;
int x, y, r2 = radius * 2,
w = tft.width() + radius,
h = tft.height() + radius;
// Screen is not cleared for this one -- this is
// intentional and does not affect the reported time.
start = micros();
for(x=0; x<w; x+=r2) {
for(y=0; y<h; y+=r2) {
tft.drawCircle(x, y, radius, color);
}
}
return micros() - start;
}
unsigned long testTriangles() {
unsigned long start;
int n, i, cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
n = min(cx, cy);
start = micros();
for(i=0; i<n; i+=5) {
tft.drawTriangle(
cx , cy - i, // peak
cx - i, cy + i, // bottom left
cx + i, cy + i, // bottom right
tft.color565(0, 0, i));
}
return micros() - start;
}
unsigned long testFilledTriangles() {
unsigned long start, t = 0;
int i, cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
start = micros();
for(i=min(cx,cy); i>10; i-=5) {
start = micros();
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(0, i, i));
t += micros() - start;
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(i, i, 0));
}
return t;
}
unsigned long testRoundRects() {
unsigned long start;
int w, i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
w = min(tft.width(), tft.height());
start = micros();
for(i=0; i<w; i+=6) {
i2 = i / 2;
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
}
return micros() - start;
}
unsigned long testFilledRoundRects() {
unsigned long start;
int i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
start = micros();
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
i2 = i / 2;
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
}
return micros() - start;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save