{"id":30895566,"url":"https://github.com/styropyr0/ssd1306_rp2350","last_synced_at":"2025-09-08T22:07:37.708Z","repository":{"id":310126802,"uuid":"1038807377","full_name":"styropyr0/SSD1306_RP2350","owner":"styropyr0","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-15T21:56:36.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-15T23:38:32.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/styropyr0.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-15T21:18:59.000Z","updated_at":"2025-08-15T21:56:39.000Z","dependencies_parsed_at":"2025-08-15T23:38:34.007Z","dependency_job_id":"5430e9ff-269c-488d-bd4c-f2477ff685ab","html_url":"https://github.com/styropyr0/SSD1306_RP2350","commit_stats":null,"previous_names":["styropyr0/ssd1306_rp2350"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/styropyr0/SSD1306_RP2350","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FSSD1306_RP2350","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FSSD1306_RP2350/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FSSD1306_RP2350/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FSSD1306_RP2350/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styropyr0","download_url":"https://codeload.github.com/styropyr0/SSD1306_RP2350/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FSSD1306_RP2350/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231544,"owners_count":25245659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-08T22:07:32.815Z","updated_at":"2025-09-08T22:07:37.670Z","avatar_url":"https://github.com/styropyr0.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SSD1306 OLED Display Driver for Raspberry Pi Microcontrollers\n**(Works with Clang/LLVM and ARM Embedded Toolchain)**\n\nA lightweight, fast driver library to control SSD1306-based OLED displays with Raspberry Pi, using C++ and standard Linux I2C APIs. This library offers versatile features comparable to the Arduino version, but does **not** include advanced scene-management (Fragments) or Drawable objects. Use direct method calls for all graphics, text, and data plotting.\n\nThis driver is based on the [SSD1306 OLED Display Driver for Arduino](https://github.com/styropyr0/oled.h)\n\n| Power Mode         | Frame Rate (fps)        |\n|--------------------|------------------------|\n| Low Power Mode     | ≤5                     |\n| Balanced Mode      | 8–10                   |\n| Performance Mode   | 16–19                  |\n| Turbo Mode         | 40–43                  |\n\n***\n\n### Key Features\n\n- **Text Output**: Print static and animated text in various fonts and highlight styles.\n- **Custom Fonts Support**: Render text using custom font arrays; switch between multiple font styles.\n- **Progress Bars**: Visual progress/status bars, multiple styles.\n- **Bitmap Rendering**: Draw icons or full images from arrays (converted using the companion Python tool).\n- **Geometric Primitives**: Draw rectangles (with optional rounded corners), circles, lines.\n- **Display Inversion**: Invert entire display or pixel states for different visual styles.\n- **Brightness \u0026 Power Management**: Software brightness control, I2C speed modes for power optimization.\n- **I2C Communication**: Direct communication with SSD1306 via `/dev/i2c-X`. Default address: `0x3C` (changeable).\n- **Data Visualization**: Static plots—pulse/waveform, bar, scatter, histogram, bit plots—for real-time sensor and analytics display.\n- **Python Bitmap Generator**: Tool to convert images (PNG/JPG) to C array bitmaps for easy display integration.\n\n***\n\n### Installation / Building\n\n**1. Clone the Repository**\n```bash\ngit clone https://github.com/styropyr0/oled.h.git\ncd oled.h\n```\n**2. Build (CMake + Ninja)**\n```bash\nmkdir build\ncd build\ncmake -G \"Ninja\" ..\nninja\n```\n**3. Dependencies**\n- Standard C++17+\n- Linux I2C headers (e.g., ``)\n- CMake (≥3.10) and Ninja build system\n\n***\n\n### Hardware \u0026 Connection\n\n- **Display**: SSD1306 OLED (128x64 or 128x32), I2C interface.\n- **Board**: Raspberry Pi (any model; tests on Pi 3/4/5).\n- **I2C Bus**: Typically `/dev/i2c-1`\n- SDA/SCL pins: Default Pi bus pins (see Pi docs).\n\n**Check your hardware address using:**\n```bash\ni2cdetect -y 1\n```\n\n***\n\n### C++ Library Usage\n\n#### 1. Basic Initialization\n\n```cpp\n#include \"SSD1306.h\"\n\nint main() {\n    SSD1306 oled(128, 64); // width, height, address, bus\n    oled.begin();         // Initialize hardware\n    oled.clearScr();      // Clear display buffer\n    oled.print(\"Hello, Raspberry Pi!\", 0, 0);  // Text at (0,0)\n    oled.inflate();       // Render changes to screen\n}\n```\n\n#### 2. Print Highlighted/Animated Text\n\n```cpp\noled.printHighlighted(\"Warning!\", 0, 0);\noled.printAnimated(\"Loading...\", 10, 20, 40 /* ms delay */, true /* highlight */);\n```\n\n#### 3. Progress Bar Example\n\n```cpp\noled.progressBar(75, 10, 40, 2); // 75% at (10,40), style 2\n```\n\n#### 4. Bitmap Rendering\n\n- Convert your image:  \n  ```bash\n  python bitmap_generator.py logo.png logo.h 24x24\n  ```\n- In C++:\n  ```cpp\n  #include \"logo.h\" // bitmap array generated by script\n  oled.draw(logo_bitmap, 30, 20, 24, 24);\n  ```\n\n#### 5. Shapes\n\n```cpp\noled.rectangle(5, 5, 40, 20, 3, 1, false);  // Rectangle w/rounded corners\noled.circle(75, 32, 12, 2);                 // Circle center (75,32), radius 12\noled.line(0, 0, 127, 63, 1);                // Line across screen\n```\n\n#### 6. Display Inversion \u0026 Power Modes\n\n```cpp\noled.invertDisplay();                       // Invert colors\noled.setBrightness(80);                     // 80% brightness\noled.setPowerMode(PERFORMANCE_MODE);        // Fastest I2C speed\n```\n\n***\n\n### Data Visualization (Plots)\n\nPlots data arrays for instant graphics:\n\n```cpp\nint signal[] = {2, 4, 3, 1, 0, 2, 5, 3};\noled.pulsePlot(0,0,128,32, signal, 8, 5);\n// More plots:\noled.barPlot(0,34,128,16, signal, 8, 5);\noled.scatterPlot(0,52,128,12, signal, 8, 5, 2);\nint histogramData[] = {2,4,1,3,5};\noled.histogramPlot(0,60,128,16, histogramData, 5, 5);\n```\n\n***\n\n### API Reference (Selected Methods)\n\n| Method                       | Description                                  |\n|------------------------------|----------------------------------------------|\n| `SSD1306(uint8_t w, h)`      | Constructor: width, height                   |\n| `begin()`                    | Initialize hardware \u0026 display                |\n| `clearScr()`                 | Clear display RAM                            |\n| `inflate()`                  | Push buffer to the OLED screen               |\n| `print(text, x, y)`          | Draw text at position                        |\n| `printHighlighted(text,x,y)` | Highlighted text at [x,y]                    |\n| `printAnimated(text,x,y,delay,highlight)` | Typewriter effect                |\n| `setFont(fontArray)`         | Use a custom font                            |\n| `clearCustomFont()`          | Reset to default font                        |\n| `progressBar(pct,x,y,style)` | Render progress bar                          |\n| `draw(data,x,y,w,h)`         | Draw a bitmap array                          |\n| `rectangle(x,y,w,h,radius,thickness,fill)` | Rectangle                      |\n| `circle(cx,cy,radius,thickness)` | Circle                                    |\n| `line(x0,y0,x1,y1,thickness)`| Line                                         |\n| `setBrightness(value)`       | LED brightness 0–100                         |\n| `setPowerMode(mode)`         | I2C speed                                  |\n| `invertDisplay()`            | Invert all pixels                            |\n| `scatterPlot(...)`           | Render scatter plot                          |\n| `barPlot(...)`               | Render bar plot                              |\n| `pulsePlot(...)`             | Render pulse waveform                        |\n| `histogramPlot(...)`         | Histogram                                   |\n\n***\n\n### Constants Quick Reference\n\n| Constant          | Value  | Description                                |\n|-------------------|--------|--------------------------------------------|\n| `ADDR`            | 0x3C   | Default I2C address                        |\n| `WIDTH_128`       | 128    | 128 px width                               |\n| `HEIGHT_64`       | 64     | 64 px height                               |\n| `LOW_POWER_MODE`  | 0x01   | 100kHz I2C                                 |\n| `BALANCED_MODE`   | 0x02   | 200kHz I2C                                 |\n| `PERFORMANCE_MODE`| 0x03   | 400kHz I2C                                 |\n| `TURBO_MODE`      | 0x04   | 1MHz I2C (auto fallback)                   |\n\n***\n\n### Bitmap Generator Tool (Python)\n\nConvert PNG/JPG to C arrays for direct rendering on the OLED display.\n\n```bash\npython bitmap_generator.py \"logo.png\" logo.h 32x32\n# Output: logo.h — contains logo_bitmap[] array\n```\nInclude the `.h` file in your project and use `oled.draw` to render.\n\n***\n\n### Usage Pattern Comparison\n\n| Capability                  | Arduino/ESP32 Version             | Raspberry Pi Version (C++)        |\n|-----------------------------|-----------------------------------|-----------------------------------|\n| Fragments/Drawables         | Scene batching, reusable UI       | NOT INCLUDED                      |\n| Direct Methods              | Available                         | Available                         |\n| Bitmaps, Fonts, Plots       | Yes                               | Yes                               |\n| Build/Deploy                | Arduino IDE                       | CMake + Ninja                     |\n| I2C                         | Wire library                      | Linux i2c-dev (C++ binding)       |\n\n***\n\n### Example: Full Demo Program\n\n```cpp\n#include \"SSD1306.h\"\n#include \"logo.h\" // Generated by bitmap_generator.py\n\nint main() {\n    SSD1306 oled(128, 64, 0x3C, \"/dev/i2c-1\");\n    oled.begin();\n    oled.clearScr();\n\n    oled.print(\"Raspberry Pi OLED!\", 0, 0);\n    oled.progressBar(80, 5, 20, 2);\n    oled.rectangle(10, 30, 50, 20, 2, 1, false);\n    oled.draw(logo_bitmap, 70, 32, 24, 24);\n\n    int data[] = {3, 5, 2, 4, 1};\n    oled.barPlot(0, 54, 128, 10, data, 5, 5);\n\n    oled.setBrightness(100);\n    oled.inflate();\n}\n```\n\n***\n\n## Conclusion\n\nThis C++ library for SSD1306 displays on Raspberry Pi gives you robust text, graphics, and data plotting—ideal for sensor dashboards, status screens, or mini GUIs. Build, run, and update displays using standard Linux tools and C++. All methods are streamlined for direct calls - no scene batching, but everything else is there for rich, flexible UI.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fssd1306_rp2350","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyropyr0%2Fssd1306_rp2350","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fssd1306_rp2350/lists"}