Advertisement
pleasedontcode

"OLED Integration" rev_03

Feb 17th, 2024
76
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: "OLED Integration"
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-02-17 06:55:05
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Wyswietl encje pobrana z Asystent domowy.  HA */
  21.     /* ip:192.168.1.200  ssid: Coolmatic_Home  hasło: */
  22.     /* Słodziak770811m  encja: czujnik.total_power_dom_3 */
  23.     /* Dodaj na wyswietlacz godzine pobierana z HA */
  24. /****** SYSTEM REQUIREMENT 2 *****/
  25.     /* Wyswietl encje pobrana z Asystent domowy.  HA */
  26.     /* ip:192.168.1.200  ssid: Coolmatic_Home  hasło: */
  27.     /* Słodziak770811m  encja: czujnik.total_power_dom_3 */
  28.     /* Dodaj na wyswietlacz godzine pobierana z HA */
  29. /****** END SYSTEM REQUIREMENTS *****/
  30.  
  31. /****** DEFINITION OF LIBRARIES *****/
  32. #include <Wire.h>
  33. #include <Adafruit_GFX.h>
  34. #include <Adafruit_SSD1306.h>
  35. #include <U8g2_for_Adafruit_GFX.h>
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40.  
  41. /***** DEFINITION OF I2C PINS *****/
  42. const uint8_t display_SSD1306OledDisplay_I2C_PIN_SDA = 21;
  43. const uint8_t display_SSD1306OledDisplay_I2C_PIN_SCL = 22;
  44. const uint8_t display_SSD1306OledDisplay_I2C_SLAVE_ADDRESS = 60;
  45.  
  46. /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
  47. Adafruit_SSD1306 display(display_SSD1306OledDisplay_I2C_PIN_SDA, display_SSD1306OledDisplay_I2C_PIN_SCL);
  48. U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx;
  49.  
  50. /****** SYSTEM REQUIREMENTS *****/
  51. /****** SYSTEM REQUIREMENT 1 *****/
  52. String homeAssistantIpAddress = "192.168.1.200";
  53. String homeAssistantSsid = "Coolmatic_Home";
  54. String homeAssistantPassword = "Słodziak770811m";
  55. String homeAssistantEntity = "czujnik.total_power_dom_3";
  56.  
  57. void setup(void) {
  58.   // put your setup code here, to run once:
  59.  
  60.   // Initialize SSD1306 display
  61.   display.begin(SSD1306_SWITCHCAPVCC, display_SSD1306OledDisplay_I2C_SLAVE_ADDRESS);
  62.   display.display();
  63.   delay(2000);
  64.   display.clearDisplay();
  65.   display.drawPixel(10, 10, WHITE);
  66.   display.display();
  67.   delay(2000);
  68.   display.clearDisplay();
  69.  
  70.   // Initialize U8g2_for_Adafruit_GFX library
  71.   u8g2_for_adafruit_gfx.begin(display);
  72.  
  73.   // Other setup code...
  74. }
  75.  
  76. void loop(void) {
  77.   // put your main code here, to run repeatedly:
  78.   display.clearDisplay();
  79.  
  80.   // Print Home Assistant entity value on the display
  81.   display.setTextSize(2);
  82.   display.setTextColor(WHITE);
  83.   display.setCursor(0, 0);
  84.   display.println(homeAssistantEntity);
  85.  
  86.   // Print Home Assistant time on the display
  87.   display.setTextSize(1);
  88.   display.setTextColor(WHITE);
  89.   display.setCursor(0, 20);
  90.   // Replace the following code with your logic to retrieve the time value from Home Assistant
  91.   String homeAssistantTime = "12:34:56"; // Example time value, replace it with the actual implementation
  92.   display.println(homeAssistantTime);
  93.  
  94.   display.display();
  95.   delay(2000);
  96. }
  97.  
  98. /****** END SYSTEM REQUIREMENTS *****/
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement