[{"data":1,"prerenderedAt":707},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fmodules\u002Foled":3},{"id":4,"title":5,"body":6,"description":700,"extension":701,"meta":702,"navigation":84,"path":703,"seo":704,"stem":705,"__hash__":706},"content\u002Fdocs\u002Fmodules\u002Foled.md","OLED Module",{"type":7,"value":8,"toc":690},"minimark",[9,13,22,27,68,158,162,170,187,191,196,454,458,522,526,655,659,686],[10,11,5],"h1",{"id":12},"oled-module",[14,15,16,17,21],"p",{},"Drive an SSD1306-based monochrome OLED display (the cheap 0.96\" 128×64 panels everyone has) over I2C. Send text, draw rectangles, blit 1-bit bitmaps; the firmware buffers everything off-screen until you call ",[18,19,20],"code",{},"show()",".",[23,24,26],"h2",{"id":25},"firmware-setup","Firmware setup",[28,29,34],"pre",{"className":30,"code":31,"language":32,"meta":33,"style":33},"language-ini shiki shiki-themes github-light github-dark","; platformio.ini\nbuild_flags = -DCONDUYT_MODULE_OLED\nlib_deps =\n    adafruit\u002FAdafruit GFX Library\n    adafruit\u002FAdafruit SSD1306\n","ini","",[18,35,36,44,50,56,62],{"__ignoreMap":33},[37,38,41],"span",{"class":39,"line":40},"line",1,[37,42,43],{},"; platformio.ini\n",[37,45,47],{"class":39,"line":46},2,[37,48,49],{},"build_flags = -DCONDUYT_MODULE_OLED\n",[37,51,53],{"class":39,"line":52},3,[37,54,55],{},"lib_deps =\n",[37,57,59],{"class":39,"line":58},4,[37,60,61],{},"    adafruit\u002FAdafruit GFX Library\n",[37,63,65],{"class":39,"line":64},5,[37,66,67],{},"    adafruit\u002FAdafruit SSD1306\n",[28,69,73],{"className":70,"code":71,"language":72,"meta":33,"style":33},"language-cpp shiki shiki-themes github-light github-dark","#include \u003CConduyt.h>\n\nConduytSerial transport(Serial, 115200);\nConduytDevice device(\"DisplayBot\", \"1.0.0\", transport);\n\nvoid setup() {\n  Serial.begin(115200);\n  Wire.begin();\n  device.addModule(new ConduytModuleOLED());\n  device.begin();\n}\n\nvoid loop() {\n  device.poll();\n}\n","cpp",[18,74,75,80,86,91,96,100,106,112,118,124,130,136,141,147,153],{"__ignoreMap":33},[37,76,77],{"class":39,"line":40},[37,78,79],{},"#include \u003CConduyt.h>\n",[37,81,82],{"class":39,"line":46},[37,83,85],{"emptyLinePlaceholder":84},true,"\n",[37,87,88],{"class":39,"line":52},[37,89,90],{},"ConduytSerial transport(Serial, 115200);\n",[37,92,93],{"class":39,"line":58},[37,94,95],{},"ConduytDevice device(\"DisplayBot\", \"1.0.0\", transport);\n",[37,97,98],{"class":39,"line":64},[37,99,85],{"emptyLinePlaceholder":84},[37,101,103],{"class":39,"line":102},6,[37,104,105],{},"void setup() {\n",[37,107,109],{"class":39,"line":108},7,[37,110,111],{},"  Serial.begin(115200);\n",[37,113,115],{"class":39,"line":114},8,[37,116,117],{},"  Wire.begin();\n",[37,119,121],{"class":39,"line":120},9,[37,122,123],{},"  device.addModule(new ConduytModuleOLED());\n",[37,125,127],{"class":39,"line":126},10,[37,128,129],{},"  device.begin();\n",[37,131,133],{"class":39,"line":132},11,[37,134,135],{},"}\n",[37,137,139],{"class":39,"line":138},12,[37,140,85],{"emptyLinePlaceholder":84},[37,142,144],{"class":39,"line":143},13,[37,145,146],{},"void loop() {\n",[37,148,150],{"class":39,"line":149},14,[37,151,152],{},"  device.poll();\n",[37,154,156],{"class":39,"line":155},15,[37,157,135],{},[23,159,161],{"id":160},"wiring","Wiring",[28,163,168],{"className":164,"code":166,"language":167},[165],"language-text","SSD1306 OLED      Board\n─────────         ─────\nSDA           ──► SDA pin (Uno: A4, ESP32: 21, Pico: GP4)\nSCL           ──► SCL pin (Uno: A5, ESP32: 22, Pico: GP5)\nVCC           ──► 3V3\nGND           ──► GND\n","text",[18,169,166],{"__ignoreMap":33},[14,171,172,173,176,177,180,181,184,185,21],{},"I2C address: most modules are ",[18,174,175],{},"0x3C",". A few clones with the SA0 pad jumpered to VDD are ",[18,178,179],{},"0x3D",". Pass ",[18,182,183],{},"addr=0"," to the wrapper to use the firmware default of ",[18,186,175],{},[23,188,190],{"id":189},"host-usage","Host usage",[192,193,195],"h3",{"id":194},"javascript","JavaScript",[28,197,200],{"className":198,"code":199,"language":194,"meta":33,"style":33},"language-javascript shiki shiki-themes github-light github-dark","import { ConduytDevice } from 'conduyt-js'\nimport { SerialTransport } from 'conduyt-js\u002Ftransports\u002Fserial'\nimport { ConduytOLED } from 'conduyt-js\u002Fmodules\u002Foled'\n\nconst device = await ConduytDevice.connect(new SerialTransport({ path: '\u003CYOUR_PORT>' }))\nconst oled = new ConduytOLED(device)\n\nawait oled.begin(128, 64)\nawait oled.clear()\nawait oled.text(0, 0,  1, 'Hello')\nawait oled.text(0, 16, 2, 'CONDUYT')\nawait oled.drawRect(0, 48, 128, 16, true)   \u002F\u002F filled bar\nawait oled.show()\n",[18,201,202,219,231,243,247,287,305,309,334,346,376,405,443],{"__ignoreMap":33},[37,203,204,208,212,215],{"class":39,"line":40},[37,205,207],{"class":206},"szBVR","import",[37,209,211],{"class":210},"sVt8B"," { ConduytDevice } ",[37,213,214],{"class":206},"from",[37,216,218],{"class":217},"sZZnC"," 'conduyt-js'\n",[37,220,221,223,226,228],{"class":39,"line":46},[37,222,207],{"class":206},[37,224,225],{"class":210}," { SerialTransport } ",[37,227,214],{"class":206},[37,229,230],{"class":217}," 'conduyt-js\u002Ftransports\u002Fserial'\n",[37,232,233,235,238,240],{"class":39,"line":52},[37,234,207],{"class":206},[37,236,237],{"class":210}," { ConduytOLED } ",[37,239,214],{"class":206},[37,241,242],{"class":217}," 'conduyt-js\u002Fmodules\u002Foled'\n",[37,244,245],{"class":39,"line":58},[37,246,85],{"emptyLinePlaceholder":84},[37,248,249,252,256,259,262,265,269,272,275,278,281,284],{"class":39,"line":64},[37,250,251],{"class":206},"const",[37,253,255],{"class":254},"sj4cs"," device",[37,257,258],{"class":206}," =",[37,260,261],{"class":206}," await",[37,263,264],{"class":210}," ConduytDevice.",[37,266,268],{"class":267},"sScJk","connect",[37,270,271],{"class":210},"(",[37,273,274],{"class":206},"new",[37,276,277],{"class":267}," SerialTransport",[37,279,280],{"class":210},"({ path: ",[37,282,283],{"class":217},"'\u003CYOUR_PORT>'",[37,285,286],{"class":210}," }))\n",[37,288,289,291,294,296,299,302],{"class":39,"line":102},[37,290,251],{"class":206},[37,292,293],{"class":254}," oled",[37,295,258],{"class":206},[37,297,298],{"class":206}," new",[37,300,301],{"class":267}," ConduytOLED",[37,303,304],{"class":210},"(device)\n",[37,306,307],{"class":39,"line":108},[37,308,85],{"emptyLinePlaceholder":84},[37,310,311,314,317,320,322,325,328,331],{"class":39,"line":114},[37,312,313],{"class":206},"await",[37,315,316],{"class":210}," oled.",[37,318,319],{"class":267},"begin",[37,321,271],{"class":210},[37,323,324],{"class":254},"128",[37,326,327],{"class":210},", ",[37,329,330],{"class":254},"64",[37,332,333],{"class":210},")\n",[37,335,336,338,340,343],{"class":39,"line":120},[37,337,313],{"class":206},[37,339,316],{"class":210},[37,341,342],{"class":267},"clear",[37,344,345],{"class":210},"()\n",[37,347,348,350,352,354,356,359,361,363,366,369,371,374],{"class":39,"line":126},[37,349,313],{"class":206},[37,351,316],{"class":210},[37,353,167],{"class":267},[37,355,271],{"class":210},[37,357,358],{"class":254},"0",[37,360,327],{"class":210},[37,362,358],{"class":254},[37,364,365],{"class":210},",  ",[37,367,368],{"class":254},"1",[37,370,327],{"class":210},[37,372,373],{"class":217},"'Hello'",[37,375,333],{"class":210},[37,377,378,380,382,384,386,388,390,393,395,398,400,403],{"class":39,"line":132},[37,379,313],{"class":206},[37,381,316],{"class":210},[37,383,167],{"class":267},[37,385,271],{"class":210},[37,387,358],{"class":254},[37,389,327],{"class":210},[37,391,392],{"class":254},"16",[37,394,327],{"class":210},[37,396,397],{"class":254},"2",[37,399,327],{"class":210},[37,401,402],{"class":217},"'CONDUYT'",[37,404,333],{"class":210},[37,406,407,409,411,414,416,418,420,423,425,427,429,431,433,436,439],{"class":39,"line":138},[37,408,313],{"class":206},[37,410,316],{"class":210},[37,412,413],{"class":267},"drawRect",[37,415,271],{"class":210},[37,417,358],{"class":254},[37,419,327],{"class":210},[37,421,422],{"class":254},"48",[37,424,327],{"class":210},[37,426,324],{"class":254},[37,428,327],{"class":210},[37,430,392],{"class":254},[37,432,327],{"class":210},[37,434,435],{"class":254},"true",[37,437,438],{"class":210},")   ",[37,440,442],{"class":441},"sJ8bj","\u002F\u002F filled bar\n",[37,444,445,447,449,452],{"class":39,"line":143},[37,446,313],{"class":206},[37,448,316],{"class":210},[37,450,451],{"class":267},"show",[37,453,345],{"class":210},[192,455,457],{"id":456},"python","Python",[28,459,462],{"className":460,"code":461,"language":456,"meta":33,"style":33},"language-python shiki shiki-themes github-light github-dark","from conduyt import ConduytDevice\nfrom conduyt.transports.serial import SerialTransport\nfrom conduyt.modules import ConduytOLED\n\ndevice = ConduytDevice(SerialTransport('\u003CYOUR_PORT>'))\nawait device.connect()\n\noled = ConduytOLED(device, module_id=0)\nawait oled.begin(width=128, height=64, i2c_addr=0x3C)\nawait oled.clear()\nawait oled.text(0, 0, 1, \"Hello\")\nawait oled.show()\n",[18,463,464,469,474,479,483,488,493,497,502,507,512,517],{"__ignoreMap":33},[37,465,466],{"class":39,"line":40},[37,467,468],{},"from conduyt import ConduytDevice\n",[37,470,471],{"class":39,"line":46},[37,472,473],{},"from conduyt.transports.serial import SerialTransport\n",[37,475,476],{"class":39,"line":52},[37,477,478],{},"from conduyt.modules import ConduytOLED\n",[37,480,481],{"class":39,"line":58},[37,482,85],{"emptyLinePlaceholder":84},[37,484,485],{"class":39,"line":64},[37,486,487],{},"device = ConduytDevice(SerialTransport('\u003CYOUR_PORT>'))\n",[37,489,490],{"class":39,"line":102},[37,491,492],{},"await device.connect()\n",[37,494,495],{"class":39,"line":108},[37,496,85],{"emptyLinePlaceholder":84},[37,498,499],{"class":39,"line":114},[37,500,501],{},"oled = ConduytOLED(device, module_id=0)\n",[37,503,504],{"class":39,"line":120},[37,505,506],{},"await oled.begin(width=128, height=64, i2c_addr=0x3C)\n",[37,508,509],{"class":39,"line":126},[37,510,511],{},"await oled.clear()\n",[37,513,514],{"class":39,"line":132},[37,515,516],{},"await oled.text(0, 0, 1, \"Hello\")\n",[37,518,519],{"class":39,"line":138},[37,520,521],{},"await oled.show()\n",[23,523,525],{"id":524},"command-reference","Command reference",[527,528,529,548],"table",{},[530,531,532],"thead",{},[533,534,535,539,542,545],"tr",{},[536,537,538],"th",{},"Command",[536,540,541],{},"ID",[536,543,544],{},"Payload",[536,546,547],{},"Description",[549,550,551,570,586,604,622,640],"tbody",{},[533,552,553,557,562,567],{},[554,555,556],"td",{},"Begin",[554,558,559],{},[18,560,561],{},"0x01",[554,563,564],{},[18,565,566],{},"width(1) + height(1) + addr(1)",[554,568,569],{},"Init the panel. addr=0 → 0x3C default",[533,571,572,575,580,583],{},[554,573,574],{},"Clear",[554,576,577],{},[18,578,579],{},"0x02",[554,581,582],{},"(none)",[554,584,585],{},"Zero the off-screen buffer",[533,587,588,591,596,601],{},[554,589,590],{},"Text",[554,592,593],{},[18,594,595],{},"0x03",[554,597,598],{},[18,599,600],{},"x(1) + y(1) + size(1) + str(N)",[554,602,603],{},"Draw text. Remaining bytes are the string",[533,605,606,609,614,619],{},[554,607,608],{},"DrawRect",[554,610,611],{},[18,612,613],{},"0x04",[554,615,616],{},[18,617,618],{},"x(1) + y(1) + w(1) + h(1) + fill(1)",[554,620,621],{},"Outline (fill=0) or filled rect",[533,623,624,627,632,637],{},[554,625,626],{},"DrawBitmap",[554,628,629],{},[18,630,631],{},"0x05",[554,633,634],{},[18,635,636],{},"x(1) + y(1) + w(1) + h(1) + data(N)",[554,638,639],{},"1-bit bitmap, ceil(w*h\u002F8) bytes",[533,641,642,645,650,652],{},[554,643,644],{},"Show",[554,646,647],{},[18,648,649],{},"0x06",[554,651,582],{},[554,653,654],{},"Flush off-screen buffer to the panel",[23,656,658],{"id":657},"notes","Notes",[660,661,662,668,671,683],"ul",{},[663,664,665,666,21],"li",{},"All draw commands paint into an off-screen buffer. Nothing appears on the panel until you call ",[18,667,20],{},[663,669,670],{},"Text bytes are limited to 64 chars per packet by the firmware buffer — chunk longer strings yourself.",[663,672,673,676,677,679,680,682],{},[18,674,675],{},"size"," is the Adafruit_GFX text scale. ",[18,678,368],{}," = 6×8 pixels per character, ",[18,681,397],{}," = 12×16, etc.",[663,684,685],{},"Bitmaps are 1 bit per pixel, MSB-first within each byte. A 16×16 bitmap is 32 bytes.",[687,688,689],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":33,"searchDepth":46,"depth":46,"links":691},[692,693,694,698,699],{"id":25,"depth":46,"text":26},{"id":160,"depth":46,"text":161},{"id":189,"depth":46,"text":190,"children":695},[696,697],{"id":194,"depth":52,"text":195},{"id":456,"depth":52,"text":457},{"id":524,"depth":46,"text":525},{"id":657,"depth":46,"text":658},"Drive an SSD1306 monochrome OLED panel over I2C — text, rectangles, bitmaps.","md",{},"\u002Fdocs\u002Fmodules\u002Foled",{"title":5,"description":700},"docs\u002Fmodules\u002Foled","5hZW8_rHt_qFXv2uZg-NozyhjXdaJJ_H4D2hziXHdGc",1777412314785]