Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4486

General • pull up issue with one code file but not with another

$
0
0
Hi all,

I've found a tutorial that finally got me up and running with a simple example for the ssd1306 driver for .96" oled displays. I ended up having an issue because of conflicting libraries in the same directory. Everything works fine, but if I try to get the display running in another file for another project, I get a pull up error issue: RuntimeError: No pull up found on SDA or SCL; check your wiring


This works for my display with a simple example file:

Code:

import adafruit_displayio_ssd1306from adafruit_display_text import labelboard_type = os.uname().machineprint(f"Board: {board_type}")if "Pico" in board_type:    sda, scl = board.GP0, board.GP1    print("Supported.")elif "ESP32-S2" in board_type:    scl, sda = (        board.IO41,        board.IO40,    )  # With the ESP32-S2 you can use any IO pins as I2C pins    print("Supported.")else:    print("This board is not directly supported. Change the pin definitions above.")i2c = busio.I2C(scl, sda)display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)# Make the display contextsplash = displayio.Group()display.show(splash)color_bitmap = displayio.Bitmap(128, 64, 1)color_palette = displayio.Palette(1)color_palette[0] = 0xFFFFFF  # Whitebg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)splash.append(bg_sprite)# Draw a smaller inner rectangleinner_bitmap = displayio.Bitmap(118, 54, 1)inner_palette = displayio.Palette(1)inner_palette[0] = 0x000000  # Blackinner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=5, y=5)splash.append(inner_sprite)# Draw a labeltext = "Hello World!"text_area = label.Label(terminalio.FONT, text=text, color=0xFFFF00, x=28, y=28)splash.append(text_area)while True:    pass
But the following code below results in the No pull up found on SDA or SCL; check your wiring error. This is for a project with KMK firmware and rotary encoders. Admittedly, I don't have experience with pull up resistors, but it's my understanding it's not needed with the Pi or the Pico. My hardware is the Pico, 5 rotary encoders, and the display. The power wires for the encoders and display are soldered together and in the 3v3 pin, and all ground are soldered together and connected to one ground pin. The display SDA and SCL is connected to GP4 and GP5, respectively. Would really appreciate any thoughts/personal experience. I don't know enough about hardware/electrical concepts like pull up resistors, but I don't see how any of this code could be the culprit. There's something conceptual that I feel I'm just unaware of:

Code:

print("Starting")import boardimport busiofrom kmk.kmk_keyboard import KMKKeyboardfrom kmk.consts import UnicodeModefrom kmk.keys import KCfrom kmk.scanners import DiodeOrientationfrom kmk.modules.layers import Layersfrom kmk.handlers.sequences import simple_key_sequencefrom kmk.modules.encoder import EncoderHandlerfrom kmk.modules.oneshot import OneShotfrom kmk.extensions.display import Display, SSD1306, TextEntry, ImageEntrykeyboard = KMKKeyboard()layers = Layers()encoder_handler = EncoderHandler()encoder2 = EncoderHandler()encoder3 = EncoderHandler()encoder4 = EncoderHandler()encoder5 = EncoderHandler()encoder6 = EncoderHandler()keyboard.modules = [        layers,         encoder_handler,         encoder2,        encoder3,        encoder4,        encoder5,        encoder6,    ]keyboard.modules.append(oneshot)keyboard.col_pins = (board.GP14, board.GP15,board.GP16,)keyboard.row_pins = (board.GP17,)# keyboard.col_pins = (board.GP18,)# keyboard.row_pins = (board.GP19,)keyboard.diode_orientation = DiodeOrientation.COL2ROW# keyboard.keymap = [[OS_LCMD, KC.TAB]]# keyboard.keymap = [#     # [KC.A,]#     # [KC.A, KC.B, KC.C,#     #  KC.D, KC.E, KC.F]# ] encoder_handler.pins = ((board.GP28, board.GP27, board.GP26, False),)encoder2.pins = ((board.GP22, board.GP21, board.GP20, False),)encoder3.pins = ((board.GP19, board.GP18, board.GP13, False),)encoder4.pins = ((board.GP12, board.GP11, board.GP10, False),)encoder5.pins = ((board.GP9, board.GP8, board.GP7, False),)encoder6.pins = ((board.GP6, board.GP3, board.GP2, False),)LYR_STD, LYR_EXT,  = 0, 1TO_STD = KC.TO(LYR_STD)MT_EXT = KC.TO(LYR_EXT)#for app zoom in/out/default 100%MINUS_ZOOM = simple_key_sequence(        (            KC.LCMD(no_release=True),             KC.MACRO_SLEEP_MS(30),            KC.MINUS,            KC.MACRO_SLEEP_MS(30),            KC.L(no_press=True),        ))PLUS_ZOOM = simple_key_sequence(    (        KC.LCMD(no_release=True),         KC.MACRO_SLEEP_MS(30),        KC.PLUS,        KC.MACRO_SLEEP_MS(30),        KC.LCMD(no_press=True),    ))DEFAULT_ZOOM = simple_key_sequence(    (        KC.LCMD(no_release=True),         KC.MACRO_SLEEP_MS(30),        KC.N0,        KC.MACRO_SLEEP_MS(30),        KC.LCMD(no_press=True),    ))# for scrolling tabs left and right and closingTABS_RIGHT = simple_key_sequence(    (        KC.LCMD(no_release=True),         KC.LALT(no_release=True),        KC.MACRO_SLEEP_MS(30),        KC.RIGHT,        KC.MACRO_SLEEP_MS(30),    ))TABS_LEFT = simple_key_sequence(    (        KC.LCMD(no_release=True),         KC.LALT(no_release=True),        KC.MACRO_SLEEP_MS(30),        KC.LEFT,        KC.MACRO_SLEEP_MS(30),    ))TABS_CLOSE = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.W,    ))#for highlighting by wordHIGHLIGHT_WORD_LEFT = simple_key_sequence(    (        KC.LALT(no_release=True),        KC.LSHIFT(no_release=True),        KC.LEFT    ))HIGHLIGHT_WORD_RIGHT = simple_key_sequence(    (        KC.LALT(no_release=True),        KC.LSHIFT(no_release=True),        KC.RIGHT    ))#for highlighting by lineHIGHLIGHT_LINE_LEFT = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.LSHIFT(no_release=True),        KC.LEFT    ))HIGHLIGHT_LINE_RIGHT = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.LSHIFT(no_release=True),        KC.RIGHT    ))#for highlighting by line upwards/downwardsHIGHLIGHT_LINE_UP = simple_key_sequence(    (        KC.LALT(no_release=True),        KC.LSHIFT(no_release=True),        KC.UP    ))HIGHLIGHT_LINE_DOWN = simple_key_sequence(    (        KC.LALT(no_release=True),        KC.LSHIFT(no_release=True),        KC.DOWN    ))#for highlighting by block upwards/downwardsHIGHLIGHT_BLOCK_UP = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.LSHIFT(no_release=True),        KC.UP    ))HIGHLIGHT_BLOCK_DOWN = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.LSHIFT(no_release=True),        KC.DOWN    ))TEST = simple_key_sequence(    (        KC.LCMD(no_release=True),        KC.TAB,    ))encoder_handler.map = [                         ((HIGHLIGHT_WORD_LEFT, HIGHLIGHT_WORD_RIGHT,MT_EXT),), # Standard                        ((HIGHLIGHT_LINE_LEFT,HIGHLIGHT_LINE_RIGHT,TO_STD),), # Extra                    ]encoder2.map = [                   ((HIGHLIGHT_LINE_UP, HIGHLIGHT_LINE_DOWN,MT_EXT),), # Standard                  ((HIGHLIGHT_BLOCK_UP,HIGHLIGHT_BLOCK_DOWN,TO_STD),), # Extra              ]encoder3.map = [ ((MINUS_ZOOM, PLUS_ZOOM, DEFAULT_ZOOM),)] #Standardencoder4.map = [ ((TABS_LEFT, TABS_RIGHT, TABS_CLOSE),)] #Standardencoder5.map = [                   ((KC.PGUP, KC.PGDOWN, MT_EXT),), # Standard                  ((KC.UP, KC.DOWN, TO_STD),), # Extra              ]encoder6.map = [               ((MINUS_ZOOM, PLUS_ZOOM, DEFAULT_ZOOM),), # Standard               ]i2c_bus = busio.I2C(board.GP5,board.GP4)display_driver = SSD1306(    i2c=i2c_bus,    # Optional device_addres argument. Default is 0x3C.     device_address=0x3C,)#For all display typesdisplay = Display(    display=display_driver,    entries=[        TextEntry(text='Layer: ', x=0, y=32, y_anchor='B'),        TextEntry(text='BASE', x=40, y=32, y_anchor='B', layer=0),        TextEntry(text='NUM', x=40, y=32, y_anchor='B', layer=1),        TextEntry(text='NAV', x=40, y=32, y_anchor='B', layer=2),        TextEntry(text='0 1 2', x=0, y=4),        TextEntry(text='0', x=0, y=4, inverted=True, layer=0),        TextEntry(text='1', x=12, y=4, inverted=True, layer=1),        TextEntry(text='2', x=24, y=4, inverted=True, layer=2),    ],    # Optional width argument. Default is 128.    # width=128,    height=64,    dim_time=10,    dim_target=0.2,    off_time=1200,    brightness=1,)keyboard.extensions.append(display)if __name__ == '__main__':    keyboard.go()

Statistics: Posted by elpollopollopollo — Sat Mar 16, 2024 4:48 am — Replies 0 — Views 20



Viewing all articles
Browse latest Browse all 4486

Trending Articles