Quantcast
Viewing all articles
Browse latest Browse all 5077

MicroPython • PICO and the NHD-3.12-25664UCW2

HI ,

I have a Pico im trying to get some information displayed on an NHD-3.12-25664UCW2 Version 1.0
This unit is wired via the serial 4 wire set up.
I've tried some demo programming that doesnt seem to function. Would love some help if anyone has any experience with this type of display!

Code:

from machine import Pin, SPIimport utimeimport NHD  # Import the NHD library that contains the SSD1322 class# Define pinsOLED_DC = Pin(27, Pin.OUT)OLED_RESET = Pin(28, Pin.OUT)OLED_CS = Pin(17, Pin.OUT)# SPI setupspi = SPI(0, baudrate=2000000, sck=Pin(18), mosi=Pin(19), polarity=0, phase=0)# Create an instance of the SSD1322_SPI classdisplay = NHD.SSD1322_SPI(width=256, height=64, spi=spi, dc=OLED_DC, cs=OLED_CS, res=OLED_RESET)def setup():    # Initialize the display    display.init_display()    # Clear the display    display.fill(0)    display.show()    # Optionally, draw something on the display    display.text("Hello World", 0, 0, 15)    display.show()setup()
this is referencing an SDD i saved on the pico named NHD.py

Code:

"""outline: https://github.com/mcauser/micropython-ssd1327init sequence/write buffer: https://github.com/JamesHagerman/Jamis_SSD1322other: SSD1322 Advance Information 480 x 128, Dot Matrix High Power OLED/PLED Segment/Common Driver with Controller        (9 COMMAND TABLE)  https://www.newhavendisplay.com/resources_dataFiles/datasheets/OLEDs/SSD1322.pdf"""__version__ = '0.1'import timeimport framebufclass SSD1322:    def __init__(self, width=256, height=64):        self.width = width        self.height = height        self.buffer = bytearray(self.width * self.height //2)        self.framebuf = framebuf.FrameBuffer(self.buffer, self.width, self.height, framebuf.GS4_HMSB)        # self.poweron()        time.sleep_ms(5)        self.init_display()    def init_display(self):                self.write_cmd(0xAF)  # Set_Sleep_Mode_12864(0xAF)                self.write_cmd(0xFD)  # Set_Command_Lock_12864(0x12)        self.write_data(0x12) # 0x12=unlock, 0x16=lock        self.write_cmd(0xB3)  # Set_Display_Clock__Oscillator_Frequency_12864(0x91)        self.write_data(0x91) # 0x91 = 80FPS; 0xD0 = default / 1100b         self.write_cmd(0xCA)  # Set_Multiplex_Ratio_12864        self.write_data(0x3F) # 0x3F = 63d = 64MUX (1/64 duty cycle)        self.write_cmd(0xA2)  # Set_Display_Offset_12864        self.write_data(0x00) # 0x00 = (default)        self.write_cmd(0xAB)  # Function_Selection_12864        self.write_data(0x01) # Something                self.write_cmd(0xA1)  # Set_Display_Start_Line_12864        self.write_data(0x00) # 0x00 = register 00h                self.write_cmd(0xA0)  # Set Re-map and Dual COM Line mode        self.write_data(0x16) # 0x14 = Default except Enable Nibble Re-map, Scan from COM[N-1] to COM0, where N is the Multiplex ratio        self.write_data(0x11) # 0x11 = Enable Dual COM mode (MUX <= 63)                self.write_cmd(0xC7)  # Master_Contrast_Control_12864        self.write_data(0x0F) # 0x0F = (default)                self.write_cmd(0xC1)  # Set_Contrast_Control_12864        self.write_data(0x9F) # 0x7F = (default)        self.write_cmd(0xB1)  # Set_Phase_Length_12864        self.write_data(0x72) #                self.write_cmd(0xBB)  # Set_Precharge_Voltage_12864        self.write_data(0x1F) # 0x17 = default; 0x1F = 0.60*Vcc (spec example)        self.write_cmd(0xB4)  # Enable_External_VSL        self.write_data(0xA0) # 0xA0 = Enable external VSL; 0xA2 = internal VSL        self.write_data(0xFD) # 0xB5 = Normal (default); 0xFD = 11111101b = Enhanced low GS display quality        self.write_cmd(0xBE)  # Set_VCOMH_Voltage_12864        self.write_data(0x04) # 0x04 = 0.80*Vcc (default); 0x07 = 0.86*Vcc (spec example)                self.write_cmd(0xA6)  # Display_Mode_12864 (Set normal display)                self.write_cmd(0xA9)  # Exit_Partial_Display_12864                self.write_cmd(0xD1)  # Display_Enhancement_12864        self.write_data(0xA2) # 0xA2 = Normal (default); 0x82 = reserved        self.write_data(0x20) # 0x20 = as-is                self.write_cmd(0xB5)  # Set_GPIO_12864        self.write_data(0x00) # 0x00 = {GPIO0, GPIO1 = HiZ (Input Disabled)}                self.write_cmd(0xB9)  # Default_Grayscale_Command_12864        self.write_cmd(0xB6)  # Set_Second_Precharge_Period_12864        self.write_data(0x08) # 0x08 = 8 dclks (default)                self.write_cmd(0xAF)  # Set_Sleep_Mode_12864                              # Sleep mode OFF (Display ON)                self.fill(0)        self.write_data(self.buffer)            def poweroff(self):        self.write_cmd(0xAB)        self.write_data(0x00) # Disable internal VDD regulator, to save power        self.write_cmd(0xAE)    def poweron(self):        self.write_cmd(0xAB)        self.write_data(0x01) # Enable internal VDD regulator        self.write_cmd(0xAF)    def contrast(self, contrast):        self.write_cmd(0x81)        self.write_data(0x81) # 0-255    def rotate(self, rotate):        self.write_cmd(0xA0)        self.write_data(0x06 if rotate else 0x14)        self.write_data(0x11)    def invert(self, invert):        self.write_cmd(0xA4 | (invert & 1) << 1 | (invert & 1)) # 0xA4=Normal, 0xA7=Inverted    def show(self):        offset=(480-self.width)//2        col_start=offset//4        col_end=col_start+self.width//4-1        self.write_cmd(0x15)        self.write_data(col_start)        self.write_data(col_end)        self.write_cmd(0x75)        self.write_data(0)        self.write_data(self.height-1)        self.write_cmd(0x5c)        self.write_data(self.buffer)        def fill(self, col):        self.framebuf.fill(col)    def pixel(self, x, y, col):        self.framebuf.pixel(x, y, col)    def pp(self,x,y,col):        self.buffer[self.width//2*y+x//2]=0xff if col else 0    def line(self, x1, y1, x2, y2, col):        self.framebuf.line(x1, y1, x2, y2, col)    def scroll(self, dx, dy):        self.framebuf.scroll(dx, dy)        # software scroll    def text(self, string, x, y, col=15):        self.framebuf.text(string, x, y, col)    def write_cmd(self):        raise NotImplementedError    def write_data(self):        raise NotImplementedErrorclass SSD1322_SPI(SSD1322):    def __init__(self, width, height, spi, dc,cs,res):        self.spi = spi        self.dc=dc        self.cs=cs        self.res=res        self.res(1)        time.sleep_ms(1)        self.res(0)        time.sleep_ms(10)        self.res(1)        super().__init__(width, height)        time.sleep_ms(5)    def write_cmd( self, aCommand ) :        '''Write given command to the device.'''        self.dc(0)        self.cs(0)        self.spi.write(bytearray([aCommand]))        self.cs(1)    #@micropython.native    def write_data( self, aData ) :        '''Write given data to the device.  This may be           either a single int or a bytearray of values.'''        self.dc(1)        self.cs(0)        if type(aData)==bytes or type(aData)==bytearray:            self.spi.write(aData)        else:            self.spi.write(bytearray([aData]))        self.cs(1)
Cant seem to get the display to do anything.
Wiring is verified. Power is confirmed. Just cant seem to get it going.

Statistics: Posted by Marconemusic — Fri Dec 29, 2023 10:05 pm



Viewing all articles
Browse latest Browse all 5077

Trending Articles