Advertisement
pleasedontcode

**Cat Graphic** rev_16

Dec 9th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Cat Graphic**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-09 10:37:36
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Show a colorful cat graphic on the ILI9341 TFT */
  21.     /* display, utilizing the U8g2_for_Adafruit_GFX */
  22.     /* library for enhanced visual quality and */
  23.     /* performance. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <SPI.h>
  30. #include <Adafruit_ILI9341.h>   //https://github.com/adafruit/Adafruit_ILI9341
  31. #include <U8g2_for_Adafruit_GFX.h>  //https://github.com/olikraus/U8g2_for_Adafruit_GFX
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36. void drawCatGraphic(); // Function to draw the cat graphic
  37.  
  38. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  39. const uint8_t display_ILI9341_TFT_RST_PIN_D2        = 2;
  40. const uint8_t display_ILI9341_TFT_DC_PIN_D3     = 3;
  41.  
  42. /***** DEFINITION OF SPI PINS *****/
  43. const uint8_t display_ILI9341_TFT_SPI_PIN_MOSI_D11      = 11;
  44. const uint8_t display_ILI9341_TFT_SPI_PIN_MISO_D12      = 12;
  45. const uint8_t display_ILI9341_TFT_SPI_PIN_SCLK_D13      = 13;
  46. const uint8_t display_ILI9341_TFT_SPI_PIN_CS_D10        = 10;
  47.  
  48. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  49. bool    display_ILI9341_TFT_RST_PIN_D2_rawData      = 0;
  50. bool    display_ILI9341_TFT_DC_PIN_D3_rawData       = 0;
  51.  
  52. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  53. float   display_ILI9341_TFT_RST_PIN_D2_phyData      = 0.0;
  54. float   display_ILI9341_TFT_DC_PIN_D3_phyData       = 0.0;
  55.  
  56. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  57. // Create an instance of the ILI9341 display
  58. 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);
  59.  
  60. // Create an instance of the U8g2 for Adafruit GFX
  61. U8G2_FOR_ADAFRUIT_GFX u8g2;
  62.  
  63. void setup(void)
  64. {
  65.     // put your setup code here, to run once:
  66.  
  67.     pinMode(display_ILI9341_TFT_RST_PIN_D2,  OUTPUT);
  68.     pinMode(display_ILI9341_TFT_DC_PIN_D3,   OUTPUT);
  69.     pinMode(display_ILI9341_TFT_SPI_PIN_CS_D10,  OUTPUT);
  70.    
  71.     // start the SPI library:
  72.     SPI.begin();
  73.    
  74.     // Initialize the display
  75.     tft.begin();
  76.     tft.setRotation(3); // Set the rotation of the display
  77.     tft.fillScreen(ILI9341_BLACK); // Clear the screen with black color
  78.  
  79.     // Initialize U8g2
  80.     u8g2.begin(tft); // Pass the Adafruit_GFX instance to U8g2
  81.     u8g2.setFont(u8g2_font_ncenB08_tr); // Set a font for U8g2
  82. }
  83.  
  84. void loop(void)
  85. {
  86.     // put your main code here, to run repeatedly:
  87.     drawCatGraphic(); // Draw the cat graphic on the display
  88.     while (true); // Stop the loop
  89. }
  90.  
  91. void drawCatGraphic()
  92. {
  93.     // Draw a colorful cat graphic using U8g2
  94.     u8g2.setForegroundColor(ILI9341_YELLOW); // Set the color for the cat
  95.     u8g2.setBackgroundColor(ILI9341_BLACK); // Set the background color
  96.     u8g2.setFontMode(1); // Transparent mode
  97.     u8g2.setFontDirection(0); // Normal direction
  98.     u8g2.drawStr(10, 30, "Meow!"); // Draw text
  99.     // Add more drawing commands here to create the cat graphic
  100. }
  101.  
  102. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement