From a7f3bf2af689521147210fa7460026e5bd403af9 Mon Sep 17 00:00:00 2001 From: Hannes Siebeneicher <60609597+Hannes7eicher@users.noreply.github.com> Date: Tue, 31 Jan 2023 10:04:24 +0100 Subject: [PATCH] Testing and adjusting examples * Testing and adjusting examples - adjusted display examples to fit round display - renamed strandtest to LED_Blink - changed Qtouch button layout for improved usability - add check for board revision --- .../Display/Compose_images/Compose_images.ino | 20 +--- examples/Display/Graphics/Graphics.ino | 93 +++++++------------ .../LED_Blink.ino} | 0 .../Relays_control_Qtouch.ino | 4 +- src/Arduino_MKRIoTCarrier.cpp | 5 + 5 files changed, 39 insertions(+), 83 deletions(-) rename examples/LEDs-Examples/{strandtest/strandtest.ino => LED_Blink/LED_Blink.ino} (100%) diff --git a/examples/Display/Compose_images/Compose_images.ino b/examples/Display/Compose_images/Compose_images.ino index f744f84..ee34407 100644 --- a/examples/Display/Compose_images/Compose_images.ino +++ b/examples/Display/Compose_images/Compose_images.ino @@ -35,22 +35,13 @@ void loop() { carrier.display.fillScreen(ST77XX_BLACK); drawArduino(0x04B3); fadeLoop(); - carrier.display.fillScreen(ST77XX_BLACK); - drawEIoT(); - fadeLoop(); - carrier.display.fillScreen(ST77XX_WHITE); drawArduino(0x0000); fadeLoop(); - drawArduino(0xF324); fadeLoop(); drawArduino(0x04B3); fadeLoop(); - - carrier.display.fillScreen(ST77XX_WHITE); - drawEIoT(); - fadeLoop(); } //Fading Orange loop @@ -72,17 +63,8 @@ void fadeLoop() { } -//Compose the differentn parts of the image -void drawEIoT() { - carrier.display.drawBitmap(44, 25, ArduinoLogo, 152, 72, 0x04B3); - carrier.display.drawBitmap(48, 110, ArduinoText, 144, 23, 0x04B3); - carrier.display.drawBitmap(0, 150, ExploreFrame, 240, 75, 0xF324); - carrier.display.drawBitmap(0, 150, ExplreIoTKittext, 240, 75, 0x04B3); - carrier.display.drawBitmap(0, 150, ExploreIoTtext, 240, 75, 0xFFFF); -} - //Same with the Arduino Logo and the text void drawArduino(uint16_t color) { carrier.display.drawBitmap(44, 60, ArduinoLogo, 152, 72, color); carrier.display.drawBitmap(48, 145, ArduinoText, 144, 23, color); -} +} \ No newline at end of file diff --git a/examples/Display/Graphics/Graphics.ino b/examples/Display/Graphics/Graphics.ino index 5442169..748e21d 100644 --- a/examples/Display/Graphics/Graphics.ino +++ b/examples/Display/Graphics/Graphics.ino @@ -23,12 +23,12 @@ void setup(void) { // large block of text carrier.display.fillScreen(ST77XX_BLACK); - testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST77XX_WHITE); + testdrawtext("Lorem ipsum dolor sit amet...", ST77XX_WHITE); delay(1000); // tft print function! tftPrintTest(); - delay(4000); + delay(500); // a single pixel carrier.display.drawPixel(carrier.display.width() / 2, carrier.display.height() / 2, ST77XX_GREEN); @@ -45,20 +45,11 @@ void setup(void) { testdrawrects(ST77XX_GREEN); delay(500); - testfillrects(ST77XX_YELLOW, ST77XX_MAGENTA); - delay(500); - carrier.display.fillScreen(ST77XX_BLACK); testfillcircles(10, ST77XX_BLUE); testdrawcircles(10, ST77XX_WHITE); delay(500); - testroundrects(); - delay(500); - - testtriangles(); - delay(500); - mediabuttons(); delay(500); @@ -67,10 +58,8 @@ void setup(void) { } void loop() { - carrier.display.invertDisplay(true); - delay(500); - carrier.display.invertDisplay(false); - delay(500); + testtriangles(); + delay(2000); } void testlines(uint16_t color) { @@ -116,7 +105,7 @@ void testlines(uint16_t color) { } void testdrawtext(char *text, uint16_t color) { - carrier.display.setCursor(0, 0); + carrier.display.setCursor(40, 100); carrier.display.setTextColor(color); carrier.display.setTextWrap(true); carrier.display.print(text); @@ -139,14 +128,6 @@ void testdrawrects(uint16_t color) { } } -void testfillrects(uint16_t color1, uint16_t color2) { - carrier.display.fillScreen(ST77XX_BLACK); - for (int16_t x = carrier.display.width() - 1; x > 6; x -= 6) { - carrier.display.fillRect(carrier.display.width() / 2 - x / 2, carrier.display.height() / 2 - x / 2 , x, x, color1); - carrier.display.drawRect(carrier.display.width() / 2 - x / 2, carrier.display.height() / 2 - x / 2 , x, x, color2); - } -} - void testfillcircles(uint8_t radius, uint16_t color) { for (int16_t x = radius; x < carrier.display.width(); x += radius * 2) { for (int16_t y = radius; y < carrier.display.height(); y += radius * 2) { @@ -167,37 +148,17 @@ void testtriangles() { carrier.display.fillScreen(ST77XX_BLACK); uint16_t color = 0xF800; int t; - int w = carrier.display.width() / 2; - int x = carrier.display.height() - 1; + int w = 120; + int x = 200; int y = 0; - int z = carrier.display.width(); + int h = 40; + int z = 200; for (t = 0 ; t <= 15; t++) { - carrier.display.drawTriangle(w, y, y, x, z, x, color); + carrier.display.drawTriangle(w, y, h, x, z, x, color); x -= 4; y += 4; z -= 4; - color += 100; - } -} - -void testroundrects() { - carrier.display.fillScreen(ST77XX_BLACK); - uint16_t color = 100; - int i; - int t; - for (t = 0 ; t <= 4; t += 1) { - int x = 0; - int y = 0; - int w = carrier.display.width() - 2; - int h = carrier.display.height() - 2; - for (i = 0 ; i <= 16; i += 1) { - carrier.display.drawRoundRect(x, y, w, h, 5, color); - x += 2; - y += 3; - w -= 4; - h -= 6; - color += 1100; - } + h += 4; color += 100; } } @@ -205,36 +166,44 @@ void testroundrects() { void tftPrintTest() { carrier.display.setTextWrap(false); carrier.display.fillScreen(ST77XX_BLACK); - carrier.display.setCursor(0, 30); + carrier.display.setCursor(20, 80); carrier.display.setTextColor(ST77XX_RED); carrier.display.setTextSize(1); carrier.display.println("Hello World!"); + carrier.display.setCursor(20, 90); carrier.display.setTextColor(ST77XX_YELLOW); carrier.display.setTextSize(2); carrier.display.println("Hello World!"); + carrier.display.setCursor(20, 110); carrier.display.setTextColor(ST77XX_GREEN); carrier.display.setTextSize(3); carrier.display.println("Hello World!"); + carrier.display.setCursor(20, 140); carrier.display.setTextColor(ST77XX_BLUE); carrier.display.setTextSize(4); carrier.display.print(1234.567); delay(1500); - carrier.display.setCursor(0, 0); + carrier.display.setCursor(20, 80); carrier.display.fillScreen(ST77XX_BLACK); carrier.display.setTextColor(ST77XX_WHITE); carrier.display.setTextSize(0); carrier.display.println("Hello World!"); + carrier.display.setCursor(20, 90); carrier.display.setTextSize(1); carrier.display.setTextColor(ST77XX_GREEN); carrier.display.print(p, 6); carrier.display.println(" Want pi?"); carrier.display.println(" "); + carrier.display.setCursor(20, 100); carrier.display.print(8675309, HEX); // print 8,675,309 out in HEX! carrier.display.println(" Print HEX!"); carrier.display.println(" "); carrier.display.setTextColor(ST77XX_WHITE); + carrier.display.setCursor(20, 110); carrier.display.println("Sketch has been"); + carrier.display.setCursor(20, 120); carrier.display.println("running for: "); + carrier.display.setCursor(20, 130); carrier.display.setTextColor(ST77XX_MAGENTA); carrier.display.print(millis() / 1000); carrier.display.setTextColor(ST77XX_WHITE); @@ -244,20 +213,20 @@ void tftPrintTest() { void mediabuttons() { // play carrier.display.fillScreen(ST77XX_BLACK); - carrier.display.fillRoundRect(25, 10, 78, 60, 8, ST77XX_WHITE); - carrier.display.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_RED); + carrier.display.fillRoundRect(75, 60, 78, 60, 8, ST77XX_WHITE); + carrier.display.fillTriangle(92, 70, 92, 110, 140, 90, ST77XX_RED); delay(500); // pause - carrier.display.fillRoundRect(25, 90, 78, 60, 8, ST77XX_WHITE); - carrier.display.fillRoundRect(39, 98, 20, 45, 5, ST77XX_GREEN); - carrier.display.fillRoundRect(69, 98, 20, 45, 5, ST77XX_GREEN); + carrier.display.fillRoundRect(75, 140, 78, 60, 8, ST77XX_WHITE); + carrier.display.fillRoundRect(89, 148, 20, 45, 5, ST77XX_GREEN); + carrier.display.fillRoundRect(119, 148, 20, 45, 5, ST77XX_GREEN); delay(500); // play color - carrier.display.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_BLUE); + carrier.display.fillTriangle(92, 70, 92, 110, 140, 90, ST77XX_BLUE); delay(50); // pause color - carrier.display.fillRoundRect(39, 98, 20, 45, 5, ST77XX_RED); - carrier.display.fillRoundRect(69, 98, 20, 45, 5, ST77XX_RED); + carrier.display.fillRoundRect(89, 148, 20, 45, 5, ST77XX_RED); + carrier.display.fillRoundRect(119, 148, 20, 45, 5, ST77XX_RED); // play color - carrier.display.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_GREEN); -} + carrier.display.fillTriangle(92, 70, 92, 110, 140, 90, ST77XX_GREEN); +} \ No newline at end of file diff --git a/examples/LEDs-Examples/strandtest/strandtest.ino b/examples/LEDs-Examples/LED_Blink/LED_Blink.ino similarity index 100% rename from examples/LEDs-Examples/strandtest/strandtest.ino rename to examples/LEDs-Examples/LED_Blink/LED_Blink.ino diff --git a/examples/TouchPads/Relays_control_Qtouch/Relays_control_Qtouch.ino b/examples/TouchPads/Relays_control_Qtouch/Relays_control_Qtouch.ino index 3922406..fe2de2c 100644 --- a/examples/TouchPads/Relays_control_Qtouch/Relays_control_Qtouch.ino +++ b/examples/TouchPads/Relays_control_Qtouch/Relays_control_Qtouch.ino @@ -53,7 +53,7 @@ void loop() { carrier.leds.show(); } - if (carrier.Buttons.onTouchDown(TOUCH3)) { + if (carrier.Buttons.onTouchDown(TOUCH4)) { newRelay1 = !newRelay1; if (newRelay1) { carrier.leds.setPixelColor(4, c_orange); @@ -63,7 +63,7 @@ void loop() { carrier.leds.show(); } - if (carrier.Buttons.onTouchDown(TOUCH1)) { + if (carrier.Buttons.onTouchDown(TOUCH2)) { carrier.leds.setPixelColor(2, c_orange); carrier.leds.show(); diff --git a/src/Arduino_MKRIoTCarrier.cpp b/src/Arduino_MKRIoTCarrier.cpp index 4d30964..c0d5dac 100644 --- a/src/Arduino_MKRIoTCarrier.cpp +++ b/src/Arduino_MKRIoTCarrier.cpp @@ -102,6 +102,11 @@ int MKRIoTCarrier::begin() { Serial.println("Sd card not detected"); } + if (_revision == BOARD_REVISION_2){ + pinMode(TFT_BACKLIGHT, OUTPUT); + digitalWrite(TFT_BACKLIGHT, HIGH); + } + return true; }