Trending

#ST7735

Latest posts tagged with #ST7735 on Bluesky

Latest Top
Trending

Posts tagged #ST7735

ST7735S SPI Screen Integration on Forlinx OK3568 — Linux Driver & Tutorial - Blog - Forlinx Embedded Technology Co., Ltd. Quickly integrate the ST7735S SPI screen with the Forlinx OK3568 board in Linux. Includes wiring, device tree, driver, and framebuffer setup tutorial.

New guide: how to connect & configure an ST7735S 1.8" SPI TFT on the Forlinx OK3568. Includes wiring, device-tree patch, FB_TFT driver enable, optimized init sequence & test app.
A clean, low-cost display solution for embedded projects.
www.forlinx.net/industrial-n...
#RK3568 #SPI #ST7735

0 0 0 0
Photo of two custom PCBs joined in the centre.  Each PCB has four small colour TFT displays arranged vertically in a line, one above the other.  The overall effect is a 2x4 grid of small rectangular displays.  Each display has some small magenta text on it.

Photo of two custom PCBs joined in the centre. Each PCB has four small colour TFT displays arranged vertically in a line, one above the other. The overall effect is a 2x4 grid of small rectangular displays. Each display has some small magenta text on it.

Messing around driving up to eight small SPI displays from a Waveshare Zero format board.

It works. But it is getting a little warm :) Figuring out why is on the todo list!

diyelectromusic.com/2025/08/14/waveshare-zer...

#WaveshareZero #SPI #ST7735

0 0 1 0
Preview
MicroPython auf dem LilyGO T-Dongle S3: Display richtig ansteuern – so geht’s Der LilyGO T-Dongle S3 ist ein kleiner, leistungsfähiger Mikrocontroller im USB-Stick-Format, der vor allem durch Projekte wie den NerdMiner oder LottoMiner be

Der LilyGO T-Dongle S3 ist ein kleiner, leistungsfähiger Mikrocontroller im USB-Stick-Format, der vor allem durch Projekte wie den NerdMiner oder LottoMiner bekannt wurde. #ESP32 #LilygoTDongleS3 #micropython #ST7735 #ST7789
bit.ly/46qVgwf

0 0 0 0
A photo of an Arduino Uno patched via jumper wires to two miniature (80x160) SPI full colour displays.  The displays are each showing a number, one display in green, one display in magenta.

A photo of an Arduino Uno patched via jumper wires to two miniature (80x160) SPI full colour displays. The displays are each showing a number, one display in green, one display in magenta.

Starting some experiments with multiple mini SPI ST7735 displays.

diyelectromusic.com/2025/07/19/arduino-with-...

#Arduino #ST7735

1 1 1 0
Preview
Arduino Nano RP2040 Connect generate QR Code and display on ST7735 TFT - software SPI <center> <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/cb-QLyKI2q4" title="YouTube video player" width="560"></iframe> </center> <p>This post show how to generate QR Code with Nano RP2040 Connect (Arduino Framework) using QRCode library by Richard Moore, also display on ST7735 SPI TFT, and finally adapt to WiFiNINA &gt; AP_SimpleWebServer example to control onboard LED. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyAGOOV2UN9GH98ho9YkywcAddmSAjZpKV2arwV1iW4zBt7qavgtqZ5SkYltFvW0OcGhrcmRT8kkRR5Sl3qRPIPMk3D-uD0DYwJy7vMraEPNqQI7CVKduTsUni5K9M2dT84kT1jSnkV1I/s1000/nanoRP2040_QRCode_2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="1000" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyAGOOV2UN9GH98ho9YkywcAddmSAjZpKV2arwV1iW4zBt7qavgtqZ5SkYltFvW0OcGhrcmRT8kkRR5Sl3qRPIPMk3D-uD0DYwJy7vMraEPNqQI7CVKduTsUni5K9M2dT84kT1jSnkV1I/w640-h388/nanoRP2040_QRCode_2.jpg" width="640"/></a> </div> <p> <b><u>Library</u></b> </p> <p> Install QRCode library by Richard Moore in Arduino IDE's Libraries Manager. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ShC8hnSlXUolBHOpGKuWGO2avqeMYoJB1XqNAAeidbakwv0erlaIflH9pJzMxiiW_M-2yCQr3JAQeGvKvkSffPzOFHtql2LkNwW9piSNIKO2Tlff5fNvf6E6DDZZLHcO67ZTc5zmzis/s1800/QRCode+lib.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1800" height="384" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ShC8hnSlXUolBHOpGKuWGO2avqeMYoJB1XqNAAeidbakwv0erlaIflH9pJzMxiiW_M-2yCQr3JAQeGvKvkSffPzOFHtql2LkNwW9piSNIKO2Tlff5fNvf6E6DDZZLHcO67ZTc5zmzis/w640-h384/QRCode+lib.jpg" width="640"/></a> </div> <div><br/></div> <div> And, "Adafruit ST7735 and ST7789 Library" and "Adafruit GFX Library" are needed to display with ST7735 SPI TFT. </div> <div><br/></div> <div> <b><u>Connection</u></b> </div> <div><br/></div> <div>The hardware SPI of Arduino Nano RP2040 Connect are:</div> <div> <div>- (CIPO/MISO) - D12</div> <div>- (COPI/MOSI) - D11</div> <div>- (SCK) - D13</div> <div>- (CS/SS) - Any GPIO (except for A6/A7)</div> <div><br/></div> <div> (refer to <a href="http://arduino-er.blogspot.com/2021/11/spi-pins-in-arduino-nano-rp2040-connect.html">SPI pins in Arduino Nano RP2040 Connect</a>) </div> </div> <div><br/></div> <div> In this exercise, we have to control the onboard LED connected to D13. it's conflict with SCK. So the exercise code here use software SPI. </div> <pre style="border: 1px solid black;"><code><span style="color: black;">/************************************************ * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 12 * LED 3V3 * **********************************************/ </span></code></pre> <div> <b><u>Exercise code</u></b> </div> <div><br/></div> nanoRP2040_QRCode.ino <pre style="border: 1px solid black;"><code><span style="color: black;">/** * Arduino nano RP2040 Connect exercise to generate QR Code, * with display on Serial Monitor and ST7735 SPI TFT. * Modified from QRCode example. * * Library: QRCode by Richard Moore * https://github.com/ricmoo/qrcode/ * */ #include &lt;Adafruit_GFX.h&gt; #include &lt;Adafruit_ST7735.h&gt; #include "qrcode.h" /************************************************ * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 12 * LED 3V3 * **********************************************/ // TFT display use software SPI interface. #define TFT_MOSI 11 // Data out #define TFT_SCLK 12 // Clock out #define TFT_CS 10 // Chip select line for TFT display #define TFT_DC 8 // Data/command line for TFT #define TFT_RST 9 // Reset line for TFT (or connect to VCC) Adafruit_ST7735 tft_ST7735 = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); void setup() { delay(1000); Serial.begin(115200); delay(1000); Serial.println("- setup() started -"); tft_ST7735.initR(INITR_BLACKTAB); tft_ST7735.setRotation(2); // tft display RGB to make sure it's work properly tft_ST7735.fillScreen(ST7735_BLACK); delay(300); tft_ST7735.fillScreen(ST7735_RED); delay(300); tft_ST7735.fillScreen(ST7735_GREEN); delay(300); tft_ST7735.fillScreen(ST7735_BLUE); delay(300); tft_ST7735.fillScreen(ST7735_WHITE); delay(300); // Start time uint32_t dt = millis(); // Create the QR code QRCode qrcode; const char *data = "http://arduino-er.blogspot.com/"; const uint8_t ecc = 0; //lowest level of error correction const uint8_t version = 3; uint8_t qrcodeData[qrcode_getBufferSize(version)]; qrcode_initText(&amp;qrcode, qrcodeData, version, ecc, data); // Delta time dt = millis() - dt; Serial.print("QR Code Generation Time: "); Serial.print(dt); Serial.print("\n\n"); Serial.println(data); Serial.print("qrcode.version: "); Serial.println(qrcode.version); Serial.print("qrcode.ecc: "); Serial.println(qrcode.ecc); Serial.print("qrcode.size: "); Serial.println(qrcode.size); Serial.print("qrcode.mode: "); Serial.println(qrcode.mode); Serial.print("qrcode.mask: "); Serial.println(qrcode.mask); Serial.println(); const int xy_scale = 3; const int x_offset = (tft_ST7735.width() - xy_scale*qrcode.size)/2; const int y_offset = (tft_ST7735.height() - xy_scale*qrcode.size)/2; // Top quiet zone Serial.print("\n\n\n\n"); for (uint8_t y = 0; y &lt; qrcode.size; y++) { // Left quiet zone Serial.print(" "); // Each horizontal module for (uint8_t x = 0; x &lt; qrcode.size; x++) { // Print each module (UTF-8 \u2588 is a solid block) bool mod = qrcode_getModule(&amp;qrcode, x, y); //Serial.print(mod ? "\u2588\u2588": " "); if(mod){ Serial.print("██"); //same as "\u2588\u2588" //direct paste "██" copied from Serial Monitor int px = x_offset + (x * xy_scale); int py = y_offset + (y * xy_scale); tft_ST7735.fillRect(px, py, xy_scale, xy_scale, ST7735_BLACK); }else{ Serial.print(" "); } } Serial.print("\n"); } // Bottom quiet zone Serial.print("\n\n\n\n"); } void loop() { } </span></code></pre> <div><br/></div> nanoRP2040_QRCode_web.ino <pre style="border: 1px solid black;"><code><span style="color: black;">/** * Arduino nano RP2040 Connect exercise to generate QR Code, * WiFiWebServer with QRCode on ST7735 SPI TFT * * Library: QRCode by Richard Moore * https://github.com/ricmoo/qrcode/ * */ #include &lt;WiFiNINA.h&gt; #include &lt;Adafruit_GFX.h&gt; #include &lt;Adafruit_ST7735.h&gt; #include "qrcode.h" /************************************************ * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 12 * LED 3V3 * **********************************************/ // TFT display use software SPI interface. // // Hardware SPI pins are specific to the Arduino board type and // cannot be remapped to alternate pins. // // In this exercise, we are going to implement a web server to // turn ON/OFF on board LED, which is connected to D13. It's // conflict with hardware SPI SCK. // So we cannot use hardware SPI to controll ST7735. #define TFT_MOSI 11 // Data out #define TFT_SCLK 12 // Clock out #define TFT_CS 10 // Chip select line for TFT display #define TFT_DC 8 // Data/command line for TFT #define TFT_RST 9 // Reset line for TFT (or connect to VCC) Adafruit_ST7735 tft_ST7735 = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); char ssid[] = "ssid"; // your network SSID (name) char pass[] = "password"; // your network password (use for WPA, or use as key for WEP) int status = WL_IDLE_STATUS; WiFiServer server(80); void setup() { delay(1000); Serial.begin(115200); delay(1000); Serial.println("- setup() started -"); Serial.print("LED_BUILTIN: "); Serial.println(LED_BUILTIN); pinMode(LED_BUILTIN, OUTPUT); // set the LED pin mode tft_ST7735.initR(INITR_BLACKTAB); tft_ST7735.setRotation(2); tft_ST7735.setTextWrap(true); tft_ST7735.setTextColor(ST77XX_BLACK); // tft display RGB to make sure it's work properly digitalWrite(LED_BUILTIN, HIGH); tft_ST7735.fillScreen(ST7735_BLACK); delay(300); digitalWrite(LED_BUILTIN, LOW); tft_ST7735.fillScreen(ST7735_RED); delay(300); digitalWrite(LED_BUILTIN, HIGH); tft_ST7735.fillScreen(ST7735_GREEN); delay(300); digitalWrite(LED_BUILTIN, LOW); tft_ST7735.fillScreen(ST7735_BLUE); delay(300); digitalWrite(LED_BUILTIN, HIGH); tft_ST7735.fillScreen(ST7735_WHITE); delay(300); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); tft_ST7735.setCursor(0, 0); tft_ST7735.print("Communication with WiFi module failed!"); // don't continue while (true); } Serial.print("WiFi.firmwareVersion(): "); Serial.println(WiFi.firmwareVersion()); // attempt to connect to WiFi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } server.begin(); // you're connected now, so print out the status: printWifiStatus(); // Start time uint32_t dt = millis(); // Create the QR code QRCode qrcode; char myIpQrData[30] ="http://"; prepareIpQrData(myIpQrData); const uint8_t ecc = 0; //lowest level of error correction const uint8_t version = 3; uint8_t qrcodeData[qrcode_getBufferSize(version)]; qrcode_initText(&amp;qrcode, qrcodeData, version, ecc, myIpQrData); // Delta time dt = millis() - dt; Serial.print("QR Code Generation Time: "); Serial.print(dt); Serial.print("\n\n"); Serial.println(myIpQrData); Serial.print("qrcode.version: "); Serial.println(qrcode.version); Serial.print("qrcode.ecc: "); Serial.println(qrcode.ecc); Serial.print("qrcode.size: "); Serial.println(qrcode.size); Serial.print("qrcode.mode: "); Serial.println(qrcode.mode); Serial.print("qrcode.mask: "); Serial.println(qrcode.mask); Serial.println(); const int xy_scale = 3; const int x_offset = (tft_ST7735.width() - xy_scale*qrcode.size)/2; const int y_offset = (tft_ST7735.height() - xy_scale*qrcode.size)/2; // Top quiet zone Serial.print("\n\n\n\n"); for (uint8_t y = 0; y &lt; qrcode.size; y++) { // Left quiet zone Serial.print(" "); // Each horizontal module for (uint8_t x = 0; x &lt; qrcode.size; x++) { // Print each module (UTF-8 \u2588 is a solid block) bool mod = qrcode_getModule(&amp;qrcode, x, y); //Serial.print(mod ? "\u2588\u2588": " "); if(mod){ Serial.print("██"); //same as "\u2588\u2588" //direct paste "██" copied from Serial Monitor int px = x_offset + (x * xy_scale); int py = y_offset + (y * xy_scale); tft_ST7735.fillRect(px, py, xy_scale, xy_scale, ST7735_BLACK); }else{ Serial.print(" "); } } Serial.print("\n"); } // Bottom quiet zone Serial.print("\n\n\n\n"); digitalWrite(LED_BUILTIN, LOW); } //prepare ip address in char *, //to pass to qrcode_initText() char * prepareIpQrData(char *dest){ Serial.println("***********************"); IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); Serial.println(ip[0]); Serial.println(ip[1]); Serial.println(ip[2]); Serial.println(ip[3]); Serial.println("-------------"); char buffer0[3]; char buffer1[3]; char buffer2[3]; char buffer3[3]; itoa(ip[0], buffer0, 10); itoa(ip[1], buffer1, 10); itoa(ip[2], buffer2, 10); itoa(ip[3], buffer3, 10); char str[15] = ""; char dot[] = "."; strcat(dest, buffer0); strcat(dest, dot); strcat(dest, buffer1); strcat(dest, dot); strcat(dest, buffer2); strcat(dest, dot); strcat(dest, buffer3); Serial.println(dest); Serial.println("***********************"); } //The web page part is mainly modified //from WiFiNINA example &gt; AP_SimpleWebServer //that lets you blink an LED via the web. void loop() { // compare the previous status to the current status if (status != WiFi.status()) { // it has changed update the variable status = WiFi.status(); if (status == WL_AP_CONNECTED) { // a device has connected to the AP Serial.println("Device connected to AP"); } else { // a device has disconnected from the AP, and we are back in listening mode Serial.println("Device disconnected from AP"); } } WiFiClient client = server.available(); // listen for incoming clients if (client) { // if you get a client, Serial.println("new client"); // print a message out the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected delayMicroseconds(10); // This is required for the Arduino Nano RP2040 Connect // - otherwise it will loop so fast that SPI will // never be served. if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println(); client.println("&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;"); // the content of the HTTP response follows the header: client.print("Click &lt;a href=\"/H\"&gt;here&lt;/a&gt; turn the LED on&lt;br&gt;"); client.print("Click &lt;a href=\"/L\"&gt;here&lt;/a&gt; turn the LED off&lt;br&gt;"); // The HTTP response ends with another blank line: client.println(); // break out of the while loop: break; } else { // if you got a newline, then clear currentLine: currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } // Check to see if the client request was "GET /H" or "GET /L": if (currentLine.endsWith("GET /H")) { Serial.println("\n===&gt; GET /H"); digitalWrite(LED_BUILTIN, HIGH); // GET /H turns the LED on } if (currentLine.endsWith("GET /L")) { Serial.println("\n===&gt; GET /L"); digitalWrite(LED_BUILTIN, LOW); // GET /L turns the LED off } } } // close the connection: client.stop(); Serial.println("client disconnected"); } } void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your board's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); } </span></code></pre> <div>Related:</div> <div> ~ <a href="http://arduino-er.blogspot.com/2021/11/arduino-nano-rp2040-connect-st7735-spi.html">Arduino Nano RP2040 Connect + ST7735 SPI TFT with SD Card, read and display bitmap, using hardware SPI</a>. </div> <div><br/></div> <div style="clear: both;"></div>

Arduino Nano RP2040 Connect generate QR Code and display on ST7735 TFT - software SPI This post s...

arduino-er.blogspot.com/2021/11/arduino-nano-rp2...

#Arduino #Arduino #Nano #RP2040 #Connect #SPI #ST7735

Event Attributes

0 0 0 0
Preview
Arduino Nano RP2040 Connect + ST7735 SPI TFT with SD Card, read and display bitmap, using hardware SPI. <div class="separator" style="clear: both; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDdshrGK6tNEBCiboBiyYfseJWUPw4cnKwE2e1jErFJIOxfjVSr-uFe4svwH2-lC3CZzpsR42zYjPw5fYTILpIWvOm6bVXnJehCiRSsIDZvy7KzVkBjZaIfIffYh8kNv4AVJL_XnYSa90/s1000/nanoRP2040_ST7735_SD_bmp.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="1000" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDdshrGK6tNEBCiboBiyYfseJWUPw4cnKwE2e1jErFJIOxfjVSr-uFe4svwH2-lC3CZzpsR42zYjPw5fYTILpIWvOm6bVXnJehCiRSsIDZvy7KzVkBjZaIfIffYh8kNv4AVJL_XnYSa90/w640-h388/nanoRP2040_ST7735_SD_bmp.jpg" width="640"/></a> </div> <p> Exercises run on <a href="http://arduino-er.blogspot.com/2021/06/arduino-nano-rp2040-connect.html">Arduino Nano RP2040 Connect (in Arduino framework)</a> work with 1.8" 128x160 ST7735 SPI TFT/SD Card Module, to:<br/>- simple display something on ST7735 SPI TFT<br/>- Display files in SD Card, and read txt file from SD Card.<br/>- Read bmp from SD Card and display on ST7735 SPI TFT<br/>- Try example of Adafruit_ImageReader<br/>- Simplified version display bitmap from SD and display on TFT using Adafruit_ImageReader. </p> <center> <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/6pXUKjaVcd4" title="YouTube video player" width="560"></iframe> </center> <p> In the following exercise Hardware SPI is used for ST7735 and SD Card SPI interface. refer to last post, <a href="http://arduino-er.blogspot.com/2021/11/spi-pins-in-arduino-nano-rp2040-connect.html">SPI pins in Arduino Nano RP2040 Connec</a>t is:<br/>- MISO<span>    </span>- D12<br/>- MOSI<span>    </span>- D11<br/>- SCK<span>    </span><span>  </span>- D13 </p> <b><u>Connection:</u></b><br/> <pre style="border: 1px solid black;"><code><span style="color: black;"> * Nano RP2040 Connect drive ST7735 SPI and SD using hardware SPI * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 13 * LED 3V3 * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * SD_CS 4 * SD_MOSI 11 * SD_MISO 12 * SD_SCK 13 ****************************************************/ </span></code></pre> <p><b><u>Exercise code:</u></b></p> <p> Please notice that  "Adafruit ST7735 and ST7789 Library" and "Adafruit GFX Library" are needed, make sure it's installed in Arduino IDE's Libraries Manager. </p> <p><b> nanoRP2040_ST7735.ino</b>, a simple exercise to display something on ST7735 SPI TFT. </p> <pre style="border: 1px solid black;"><code><span style="color: black;">/*************************************************** * nano RP2040 Connect exercise * + ST7745/SD * * On Arduino nanp RP2040 Connect: * (CIPO/MISO) - D12 * (COPI/MOSI) - D11 * (SCK) - D13 * (CS/SS) - Any GPIO (except for A6/A7 * * This example drive ST7735 SPI and SD using hardware SPI * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 13 * LED 3V3 * ****************************************************/ #include &lt;Adafruit_GFX.h&gt; #include &lt;Adafruit_ST7735.h&gt; #include &lt;SD.h&gt; #include &lt;SPI.h&gt; // TFT display using hardware SPI interface. // Hardware SPI pins are specific to the Arduino board type and // cannot be remapped to alternate pins. #define TFT_CS 10 // Chip select line for TFT display #define TFT_DC 8 // Data/command line for TFT #define TFT_RST 9 // Reset line for TFT (or connect to +5V) Adafruit_ST7735 tft_ST7735 = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); void setup(void) { delay(1000); Serial.begin(115200); delay(1000); Serial.println("====================="); Serial.println("- setup() -"); tft_ST7735.initR(INITR_BLACKTAB); Serial.println("tft: " + String(tft_ST7735.width()) + " : " + String(tft_ST7735.height())); tft_ST7735.fillScreen(ST7735_BLACK); tft_ST7735.setTextWrap(true); tft_ST7735.setTextColor(ST77XX_WHITE); tft_ST7735.setCursor(0, 0); tft_ST7735.print("Arduino nano RP2040 Connect"); tft_ST7735.println("\n"); //---------------------------------------- delay(2000); tft_ST7735.setRotation(3); tft_ST7735.setCursor(0, 30); tft_ST7735.print("rotation: " + String(tft_ST7735.getRotation())); tft_ST7735.setCursor(0, 40); tft_ST7735.print(String(tft_ST7735.width()) + " x " + String(tft_ST7735.height())); delay(2000); tft_ST7735.fillScreen(ST77XX_RED); tft_ST7735.setCursor(50, 50); tft_ST7735.print("RED"); delay(1000); tft_ST7735.fillScreen(ST77XX_GREEN); tft_ST7735.setCursor(50, 50); tft_ST7735.print("GREEN"); delay(1000); tft_ST7735.fillScreen(ST77XX_BLUE); tft_ST7735.setCursor(50, 50); tft_ST7735.print("BLUE"); delay(1000); delay(1000); //---------------------------------------- Serial.println("\n- End of setup() -\n"); } void loop() { tft_ST7735.fillScreen(ST77XX_BLUE); for(int offset=0; offset&lt;tft_ST7735.height()/2; offset++){ int col; if(offset%5 == 0) col = ST77XX_WHITE; else col = ST77XX_BLACK; tft_ST7735.drawRect(offset, offset, tft_ST7735.width()-2*offset, tft_ST7735.height()-2*offset, col); delay(100); } delay(2000); tft_ST7735.fillScreen(ST77XX_BLACK); int cx = tft_ST7735.width()/2; int cy = tft_ST7735.height()/2; for(int r=0; r&lt;tft_ST7735.height()/2; r=r+10){ tft_ST7735.drawCircle(cx, cy, r, ST77XX_WHITE); delay(200); } delay(2000); delay(2000); } </span></code></pre> <br/><b> nanoRP2040_ST7735_SD.ino</b>, list files in SD card and read the text file hello.txt. <pre style="border: 1px solid black;"><code><span style="color: black;">/*************************************************** * nano RP2040 Connect exercise * + ST7745/SD * * On Arduino nanp RP2040 Connect: * (CIPO/MISO) - D12 * (COPI/MOSI) - D11 * (SCK) - D13 * (CS/SS) - Any GPIO (except for A6/A7 * * This example drive ST7735 SPI and SD using hardware SPI * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 13 * LED 3V3 * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * SD_CS 4 * SD_MOSI 11 * SD_MISO 12 * SD_SCK 13 ****************************************************/ #include &lt;Adafruit_GFX.h&gt; #include &lt;Adafruit_ST7735.h&gt; #include &lt;SD.h&gt; #include &lt;SPI.h&gt; // TFT display and SD card will share the hardware SPI interface. // Hardware SPI pins are specific to the Arduino board type #define SD_CS 4 // Chip select line for SD card #define TFT_CS 10 // Chip select line for TFT display #define TFT_DC 8 // Data/command line for TFT #define TFT_RST 9 // Reset line for TFT (or connect to +5V) Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); File root; File myFile; void setup(void) { delay(1000); Serial.begin(115200); delay(1000); Serial.println("====================="); Serial.println("- setup() -"); tft.initR(INITR_BLACKTAB); Serial.println("tft: " + String(tft.width()) + " : " + String(tft.height())); tft.fillScreen(ST7735_BLACK); tft.setTextWrap(true); tft.setTextColor(ST77XX_WHITE); tft.setCursor(0, 0); tft.print("Arduino nano RP2040 Connect"); tft.println("\n"); //---------------------------------------- Serial.println("Initializing SD card..."); if (!SD.begin(SD_CS)){ Serial.println("SD.begin() failed!"); } else{ Serial.println("SD.begin() Success."); root = SD.open("/"); printDirectory(root, 0); Serial.println("==============================="); // open the file for reading: myFile = SD.open("hello.txt"); if (myFile) { Serial.println("test.txt:"); Serial.println("-------------------------------"); // read from the file until there's nothing else in it: while (myFile.available()) { //Serial.write(myFile.read()); byte b = myFile.read(); Serial.write(b); tft.print((char)b); } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } Serial.println("\n===============================\n"); } //---------------------------------------- Serial.println("\n- End of setup() -\n"); } void loop() { delay(100); } // // printDirectory() copy from: // Examples &gt; SD &gt; listfiles // void printDirectory(File dir, int numTabs) { while (true) { File entry = dir.openNextFile(); if (! entry) { // no more files break; } for (uint8_t i = 0; i &lt; numTabs; i++) { Serial.print('\t'); } Serial.print(entry.name()); if (entry.isDirectory()) { Serial.println("/"); printDirectory(entry, numTabs + 1); } else { // files have sizes, directories do not Serial.print("\t\t"); Serial.println(entry.size(), DEC); } entry.close(); } } </span></code></pre> <br/><b> nanoRP2040_ST7735_SD_bmp.ino</b>, read bmp files in SD Card, test.bmp, test2.bmp and test3.bmp, and display on ST7735 SPI TFT. It can be noted in bmpDraw(), copy from examples under "Adafruit ST7735 and ST7789 Library" &gt; shieldtest, bmpDepth must be 24. To prepare bmp for this using GIMP, refer to the above video, ~ 6:38.<pre style="border: 1px solid black;"><code><span style="color: black;">/*************************************************** * nano RP2040 Connect exercise * + ST7745/SD * * On Arduino nanp RP2040 Connect: * (CIPO/MISO) - D12 * (COPI/MOSI) - D11 * (SCK) - D13 * (CS/SS) - Any GPIO (except for A6/A7 * * This example drive ST7735 SPI and SD using hardware SPI * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * VCC 3V3 * GND GND * CS 10 * RESET 9 * A0(DC) 8 * SDA 11 * SCK 13 * LED 3V3 * * TFT_ST7735 nano RP2040 Connect * ------------------------------ * SD_CS 4 * SD_MOSI 11 * SD_MISO 12 * SD_SCK 13 ****************************************************/ #include &lt;Adafruit_GFX.h&gt; #include &lt;Adafruit_ST7735.h&gt; #include &lt;SD.h&gt; #include &lt;SPI.h&gt; // TFT display and SD card will share the hardware SPI interface. // Hardware SPI pins are specific to the Arduino board type. #define SD_CS 4 // Chip select line for SD card #define TFT_CS 10 // Chip select line for TFT display #define TFT_DC 8 // Data/command line for TFT #define TFT_RST 9 // Reset line for TFT (or connect to +5V) Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); File root; File myFile; void setup(void) { delay(1000); Serial.begin(115200); delay(1000); Serial.println("====================="); Serial.println("- setup() -"); tft.initR(INITR_BLACKTAB); Serial.println("tft: " + String(tft.width()) + " : " + String(tft.height())); tft.fillScreen(ST7735_BLACK); tft.setTextWrap(true); tft.setTextColor(ST77XX_WHITE); tft.setCursor(0, 0); tft.print("Arduino nano RP2040 Connect"); //---------------------------------------- Serial.println("Initializing SD card..."); if (!SD.begin(SD_CS)){ Serial.println("SD.begin() failed!"); } else{ Serial.println("SD.begin() Success."); root = SD.open("/"); printDirectory(root, 0); } //---------------------------------------- Serial.println("\n- End of setup() -\n"); } const int NO_OF_BMP = 3; char* bmpFiles[NO_OF_BMP] = {"/test.bmp", "/test2.bmp", "/test3.bmp"}; void loop() { for(int i=0; i&lt;NO_OF_BMP; i++){ bmpDraw(bmpFiles[i], 0, 0); delay(2000); } } // // printDirectory() copy from: // Examples &gt; SD &gt; listfiles // void printDirectory(File dir, int numTabs) { while (true) { File entry = dir.openNextFile(); if (! entry) { // no more files break; } for (uint8_t i = 0; i &lt; numTabs; i++) { Serial.print('\t'); } Serial.print(entry.name()); if (entry.isDirectory()) { Serial.println("/"); printDirectory(entry, numTabs + 1); } else { // files have sizes, directories do not Serial.print("\t\t"); Serial.println(entry.size(), DEC); } entry.close(); } } // // bmpDraw() copy from: // Examples under "Adafruit ST7735 and ST7789 Library" &gt; shieldtest // // This function opens a Windows Bitmap (BMP) file and // displays it at the given coordinates. It's sped up // by reading many pixels worth of data at a time // (rather than pixel by pixel). Increasing the buffer // size takes more of the Arduino's precious RAM but // makes loading a little faster. 20 pixels seems a // good balance. #define BUFFPIXEL 20 void bmpDraw(char *filename, uint8_t x, uint8_t y) { File bmpFile; int bmpWidth, bmpHeight; // W+H in pixels uint8_t bmpDepth; // Bit depth (currently must be 24) uint32_t bmpImageoffset; // Start of image data in file uint32_t rowSize; // Not always = bmpWidth; may have padding uint8_t sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel) uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer boolean goodBmp = false; // Set to true on valid header parse boolean flip = true; // BMP is stored bottom-to-top int w, h, row, col; uint8_t r, g, b; uint32_t pos = 0, startTime = millis(); if((x &gt;= tft.width()) || (y &gt;= tft.height())) return; Serial.println(); Serial.print("Loading image '"); Serial.print(filename); Serial.println('\''); // Open requested file on SD card if ((bmpFile = SD.open(filename)) == NULL) { Serial.print("File not found"); return; } // Parse BMP header if(read16(bmpFile) == 0x4D42) { // BMP signature Serial.print("File size: "); Serial.println(read32(bmpFile)); (void)read32(bmpFile); // Read &amp; ignore creator bytes bmpImageoffset = read32(bmpFile); // Start of image data Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC); // Read DIB header Serial.print("Header size: "); Serial.println(read32(bmpFile)); bmpWidth = read32(bmpFile); bmpHeight = read32(bmpFile); if(read16(bmpFile) == 1) { // # planes -- must be '1' bmpDepth = read16(bmpFile); // bits per pixel Serial.print("Bit Depth: "); Serial.println(bmpDepth); if((bmpDepth == 24) &amp;&amp; (read32(bmpFile) == 0)) { // 0 = uncompressed goodBmp = true; // Supported BMP format -- proceed! Serial.print("Image size: "); Serial.print(bmpWidth); Serial.print('x'); Serial.println(bmpHeight); // BMP rows are padded (if needed) to 4-byte boundary rowSize = (bmpWidth * 3 + 3) &amp; ~3; // If bmpHeight is negative, image is in top-down order. // This is not canon but has been observed in the wild. if(bmpHeight &lt; 0) { bmpHeight = -bmpHeight; flip = false; } // Crop area to be loaded w = bmpWidth; h = bmpHeight; if((x+w-1) &gt;= tft.width()) w = tft.width() - x; if((y+h-1) &gt;= tft.height()) h = tft.height() - y; // Set TFT address window to clipped image bounds tft.startWrite(); tft.setAddrWindow(x, y, w, h); for (row=0; row&lt;h; row++) { // For each scanline... // Seek to start of scan line. It might seem labor- // intensive to be doing this on every line, but this // method covers a lot of gritty details like cropping // and scanline padding. Also, the seek only takes // place if the file position actually needs to change // (avoids a lot of cluster math in SD library). if(flip) // Bitmap is stored bottom-to-top order (normal BMP) pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize; else // Bitmap is stored top-to-bottom pos = bmpImageoffset + row * rowSize; if(bmpFile.position() != pos) { // Need seek? tft.endWrite(); bmpFile.seek(pos); buffidx = sizeof(sdbuffer); // Force buffer reload } for (col=0; col&lt;w; col++) { // For each pixel... // Time to read more pixel data? if (buffidx &gt;= sizeof(sdbuffer)) { // Indeed bmpFile.read(sdbuffer, sizeof(sdbuffer)); buffidx = 0; // Set index to beginning tft.startWrite(); } // Convert pixel from BMP to TFT format, push to display b = sdbuffer[buffidx++]; g = sdbuffer[buffidx++]; r = sdbuffer[buffidx++]; tft.pushColor(tft.color565(r,g,b)); } // end pixel } // end scanline tft.endWrite(); Serial.print("Loaded in "); Serial.print(millis() - startTime); Serial.println(" ms"); } // end goodBmp } } bmpFile.close(); if(!goodBmp) Serial.println("BMP format not recognized."); } // These read 16- and 32-bit types from the SD card file. // BMP data is stored little-endian, Arduino is little-endian too. // May need to reverse subscript order if porting elsewhere. uint16_t read16(File f) { uint16_t result; ((uint8_t *)&amp;result)[0] = f.read(); // LSB ((uint8_t *)&amp;result)[1] = f.read(); // MSB return result; } uint32_t read32(File f) { uint32_t result; ((uint8_t *)&amp;result)[0] = f.read(); // LSB ((uint8_t *)&amp;result)[1] = f.read(); ((uint8_t *)&amp;result)[2] = f.read(); ((uint8_t *)&amp;result)[3] = f.read(); // MSB return result; } </span></code></pre> <br/><b> nanoRP2040_ST7735_SD_ImageReader.ino</b>, a simplified version to display bitmaps using Adafruit_ImageReader, make sure it's installed. <pre style="border: 1px solid black;"><code><span style="color: black;">// Adafruit_ImageReader test for Adafruit ST7735 TFT Breakout for Arduino. // Demonstrates loading images from SD card or flash memory to the screen, // to RAM, and how to query image file dimensions. // Requires three BMP files in root directory of SD card: // test.bmp, test2.bmp and test3.bmp. // As written, this uses the microcontroller's SPI interface for the screen // (not 'bitbang') and must be wired to specific pins. #include &lt;Adafruit_GFX.h&gt; // Core graphics library #include &lt;Adafruit_ST7735.h&gt; // Hardware-specific library #include &lt;SdFat.h&gt; // SD card &amp; FAT filesystem library #include &lt;Adafruit_ImageReader.h&gt; // Image-reading functions // TFT display and SD card share the hardware SPI interface, using // 'select' pins for each to identify the active device on the bus. #define SD_CS 4 // SD card select pin #define TFT_CS 10 // TFT select pin #define TFT_DC 8 // TFT display/command pin #define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin SdFat SD; // SD card filesystem Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); Adafruit_Image img; // An image loaded into RAM int32_t width = 0, // BMP image dimensions height = 0; void setup(void) { ImageReturnCode stat; // Status from image-reading functions Serial.begin(115200); tft.initR(INITR_BLACKTAB); // Initialize screen // The Adafruit_ImageReader constructor call (above, before setup()) // accepts an uninitialized SdFat or FatFileSystem object. This MUST // BE INITIALIZED before using any of the image reader functions! Serial.print(F("Initializing filesystem...")); // SD card is pretty straightforward, a single call... if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due ... Serial.println(F("SD begin() failed")); for(;;); // Fatal error, do not continue } Serial.println(F("OK!")); // Fill screen blue. Not a required step, this just shows that we're // successfully communicating with the screen. tft.fillScreen(ST7735_BLUE); // Load full-screen BMP file 'test.bmp' at position (0,0) (top left). // Notice the 'reader' object performs this, with 'tft' as an argument. Serial.print(F("Loading test.bmp to screen...")); stat = reader.drawBMP("/test.bmp", tft, 0, 0); reader.printStatus(stat); // How'd we do? // Query the dimensions of image 'test2.bmp' WITHOUT loading to screen: Serial.print(F("Querying test2.bmp image size...")); stat = reader.bmpDimensions("/test2.bmp", &amp;width, &amp;height); reader.printStatus(stat); // How'd we do? if(stat == IMAGE_SUCCESS) { // If it worked, print image size... Serial.print(F("Image dimensions: ")); Serial.print(width); Serial.write('x'); Serial.println(height); } // Load small BMP 'test3.bmp' into a GFX canvas in RAM. Serial.print(F("Loading test3.bmp to canvas...")); stat = reader.loadBMP("/test3.bmp", img); reader.printStatus(stat); // How'd we do? delay(2000); // Pause 2 seconds before moving on to loop() } void loop() { for(int r=0; r&lt;4; r++) { // For each of 4 rotations... tft.setRotation(r); // Set rotation tft.fillScreen(0); // and clear screen reader.drawBMP("/test2.bmp", tft, 0, 0); delay(1000); // Pause 1 sec. img.draw(tft, // Pass in tft object 0 , // Horiz pos. 0); // Vert pos delay(2000); // Pause 2 sec. } } </span></code></pre> Related:<div>~ <a href="https://arduino-er.blogspot.com/2021/11/arduino-nano-rp2040-connect-generate-qr.html">Arduino Nano RP2040 Connect generate QR Code and display on ST7735 TFT - software SPI</a></div><div><br/></div><div><br/></div> <div style="clear: both;"></div>

Arduino Nano RP2040 Connect + ST7735 SPI TFT with SD Card, read and display bitmap, using hardwar...

arduino-er.blogspot.com/2021/11/arduino-nano-rp2...

#Arduino #Arduino #Nano #RP2040 #Connect #SPI #ST7735

Event Attributes

0 0 0 0
Post image

GiamMa-based researchers SDR R&D IoT: SSB85 TRX (SSB 6.1 transceiver based) compact ham radio transceiver by zoonman #SoftwareDefinedRadio #Receiver #Trasmitter #Transceiver #Si5351A #ST7735 #ATMega1284p #TFT #Ham #HamRadio

2 0 0 0
Post image

GiamMa-based researchers SDR R&D IoT: nanodds: DDS for SSB 6.1 transceiver based on Si5351A, ST7735 and ATMega1284p by zoonman #SoftwareDefinedRadio #Receiver #Trasmitter #Transceiver #Si5351A #ST7735 #ATMega1284p #TFT #Ham #HamRadio

0 0 0 0