Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Cat Display
- - Source Code compiled for: Arduino Uno
- - Source Code created on: 2024-12-09 10:39:52
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Show a colorful cat graphic on the ILI9341 TFT */
- /* display, utilizing the U8g2_for_Adafruit_GFX */
- /* library for enhanced visual quality and */
- /* performance. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SPI.h>
- #include <Adafruit_ILI9341.h> //https://github.com/adafruit/Adafruit_ILI9341
- #include <U8g2_for_Adafruit_GFX.h> //https://github.com/olikraus/U8g2_for_Adafruit_GFX
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void drawCatGraphic(); // Function to draw the cat graphic
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t display_ILI9341_TFT_RST_PIN_D2 = 2;
- const uint8_t display_ILI9341_TFT_DC_PIN_D3 = 3;
- /***** DEFINITION OF SPI PINS *****/
- const uint8_t display_ILI9341_TFT_SPI_PIN_MOSI_D11 = 11;
- const uint8_t display_ILI9341_TFT_SPI_PIN_MISO_D12 = 12;
- const uint8_t display_ILI9341_TFT_SPI_PIN_SCLK_D13 = 13;
- const uint8_t display_ILI9341_TFT_SPI_PIN_CS_D10 = 10;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- bool display_ILI9341_TFT_RST_PIN_D2_rawData = 0;
- bool display_ILI9341_TFT_DC_PIN_D3_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- float display_ILI9341_TFT_RST_PIN_D2_phyData = 0.0;
- float display_ILI9341_TFT_DC_PIN_D3_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Create an instance of the ILI9341 display
- Adafruit_ILI9341 tft(display_ILI9341_TFT_SPI_PIN_CS_D10, display_ILI9341_TFT_DC_PIN_D3, display_ILI9341_TFT_SPI_PIN_MOSI_D11, display_ILI9341_TFT_SPI_PIN_SCLK_D13, display_ILI9341_TFT_RST_PIN_D2);
- // Create an instance of the U8g2 for Adafruit GFX
- U8G2_FOR_ADAFRUIT_GFX u8g2;
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(display_ILI9341_TFT_RST_PIN_D2, OUTPUT);
- pinMode(display_ILI9341_TFT_DC_PIN_D3, OUTPUT);
- pinMode(display_ILI9341_TFT_SPI_PIN_CS_D10, OUTPUT);
- // start the SPI library:
- SPI.begin();
- // Initialize the display
- tft.begin();
- tft.setRotation(3); // Set the rotation of the display
- tft.fillScreen(ILI9341_BLACK); // Clear the screen with black color
- // Initialize U8g2
- u8g2.begin(tft); // Pass the Adafruit_GFX instance to U8g2
- u8g2.setFont(u8g2_font_ncenB08_tr); // Set a font for U8g2
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- drawCatGraphic(); // Draw the cat graphic on the display
- while (true); // Stop the loop
- }
- void drawCatGraphic()
- {
- // Draw a colorful cat graphic using U8g2
- u8g2.setForegroundColor(ILI9341_YELLOW); // Set the color for the cat
- u8g2.setBackgroundColor(ILI9341_BLACK); // Set the background color
- u8g2.setFontMode(1); // Transparent mode
- u8g2.setFontDirection(0); // Normal direction
- u8g2.drawStr(10, 30, "Meow!"); // Draw text
- // Add more drawing commands here to create the cat graphic
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement