Advertisement
pleasedontcode

**Display Update** rev_01

May 16th, 2025
329
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: **Display Update**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-05-16 22:52:40
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* The application shall provide real-time feedback */
  21.     /* to users by updating the display and controlling */
  22.     /* actuators based on input events, ensuring a */
  23.     /* seamless experience. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <Wire.h>
  30. #include <Adafruit_SSD1306.h>   //https://github.com/stblassitude/Adafruit_SSD1306_Wemos_OLED.git
  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 updateDisplay(const char* message); // Function to update the display with a message
  37.  
  38. /***** DEFINITION OF I2C PINS *****/
  39. const uint8_t myDisplay_SSD1306OledDisplay_I2C_PIN_SDA_A4       = A4;
  40. const uint8_t myDisplay_SSD1306OledDisplay_I2C_PIN_SCL_A5       = A5;
  41. const uint8_t myDisplay_SSD1306OledDisplay_I2C_SLAVE_ADDRESS        = 60;
  42.  
  43. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  44. // Create display object
  45. Adafruit_SSD1306 display(128, 32, &Wire, -1); // Initialize the display object
  46.  
  47. void setup(void)
  48. {
  49.     // Initialize the display
  50.     display.begin(SSD1306_SWITCHCAPVCC, myDisplay_SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
  51.     display.clearDisplay(); // Clear the display buffer
  52.     display.display(); // Show the buffer on the display
  53.  
  54.     // Display initial message
  55.     updateDisplay("Initializing...");
  56. }
  57.  
  58. void loop(void)
  59. {
  60.     // Example of real-time feedback
  61.     updateDisplay("Running..."); // Update display with running status
  62.     delay(1000); // Simulate some processing delay
  63.     updateDisplay("Processing..."); // Update display with processing status
  64.     delay(1000); // Simulate some processing delay
  65. }
  66.  
  67. // Function to update the display with a message
  68. void updateDisplay(const char* message) {
  69.     display.clearDisplay(); // Clear the display buffer
  70.     display.setTextSize(1); // Set text size
  71.     display.setTextColor(SSD1306_WHITE); // Set text color
  72.     display.setCursor(0, 0); // Set cursor position
  73.     display.print(message); // Print the message
  74.     display.display(); // Show the buffer on the display
  75. }
  76.  
  77. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement