11/21/2023 0 Comments Show line number thonny![]() CodeĪfter uploading the library to the ESP32 or ESP8266, copy the following code to the Now, you can use the library functionalities in your code by importing the library. Name the file ssd1306.py and click OK to save the file on the ESP Filesystem.Īnd that’s it. Create a new file by pressing the New File button.ģ. If you’re using Thonny IDE, read the next section.ġ. This section shows how to upload a library using uP圜raft IDE. (baudrate=self.rate, polarity=0, phase=0)įollow the next set of instructions for the IDE you’re using: amebuf = framebuf.FrameBuffer1(self.buffer, width, height) Self.buffer = bytearray((height // 8) * width) # Blast out the frame buffer using a single I2C transaction to supportĭef _init_(self, width, height, spi, dc, res, cs, external_vcc=False): Super()._init_(width, height, external_vcc) amebuf = framebuf.FrameBuffer1(memoryview(self.buffer), width, height) Self.buffer = 0x40 # Set first byte of data buffer to Co=0, D/C=1 Self.buffer = bytearray(((height // 8) * width) + 1) # (without a major memory hit as memoryview doesn't copy to a separate # buffer is used to mask this byte from the framebuffer operations ![]() # to use hardware-compatible I2C transactions. # Add an extra byte to the data buffer to hold an I2C data/command byte # displays with width of 64 pixels are shifted by 32ĭef _init_(self, width, height, i2c, addr=0x3c, external_vcc=False): Self.write_cmd(SET_NORM_INV | (invert & 1)) SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14, SET_ENTIRE_ON, # output follows RAM contents SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1, SET_COM_PIN_CFG, 0x02 if self.height = 32 else 0x12, SET_COM_OUT_DIR | 0x08, # scan from COM to COM0 SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0 # between I2C and SPI implementations (I2C needs an extra byte). # This is necessary because the underlying data buffer is different # Note the subclass must initialize amebuf to a framebuffer. #MicroPython SSD1306 OLED driver, I2C and SPI interfaces created by Adafruitĭef _init_(self, width, height, external_vcc): ![]() So, you need to upload the library to your ESP32/ESP8266 board. The library to write to the OLED display isn’t part of the standard MicroPython library by default. Recommended reading: ESP8266 Pinout Reference Guide SSD1306 OLED Library FrameBuffer ( bytearray ( 8 * 8 * 1 ), 8, 8, framebuf. scroll ( 20, 0 ) # scroll 20 pixels to the right # draw another FrameBuffer on top of the current one at the given coordinates import framebuf fbuf = framebuf. text ( 'Hello World', 0, 0, 1 ) # draw some text at x=0, y=0, colour=1 display. vline ( 0, 8, 4, 1 ) # draw vertical line x=0, y=8, height=4, colour=1 display. hline ( 0, 8, 4, 1 ) # draw horizontal line x=0, y=8, width=4, colour=1 display. pixel ( 0, 10, 1 ) # set pixel at x=0, y=10 to colour=1 display. pixel ( 0, 10 ) # get pixel at x=0, y=10 display. fill ( 0 ) # fill entire screen with colour=0 display.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |