Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you please add a new class to i2c_lcd.py? #44

Open
FlewittGuy opened this issue Dec 21, 2022 · 2 comments
Open

Could you please add a new class to i2c_lcd.py? #44

FlewittGuy opened this issue Dec 21, 2022 · 2 comments

Comments

@FlewittGuy
Copy link

Request
So while using your library I created a simple class which I added to the /lcd/i2c_lcd.py file. The only purpose is to organize the main file by using one library instead of two. I am here to ask if you could add the class below to the bottom of the /lcd/i2c_lcd.py file. Thanks.

Class

class I2C_LCD():
    def __init__(self, SDA_PIN, SCL_PIN, ROWS, COLS, FREQ):
        self.SDA_PIN = SDA_PIN
        self.SCL_PIN = SCL_PIN
        
        self.I2C_NUM_ROWS = ROWS
        self.I2C_NUM_COLS = COLS
        
        self.FREQ = FREQ
        
        self.i2c = SoftI2C(sda=Pin(self.SDA_PIN), scl=Pin(self.SCL_PIN), freq=self.FREQ)
        self.I2C_ADDR = int(hex(self.i2c.scan()[0]))  # Finds the unique 7-bit I2C address
        self.lcd = I2cLcd(self.i2c, self.I2C_ADDR, self.I2C_NUM_ROWS, self.I2C_NUM_COLS)

Example/Main.py File

from i2c_lcd import I2C_LCD

disp1 = I2C_LCD(
    SDA_PIN = 0,
    SCL_PIN = 1,
    ROWS    = 2,
    COLS    = 16,
    FREQ    = 400_000
)

disp2 = I2C_LCD(
    SDA_PIN = 4,
    SCL_PIN = 5,
    ROWS    = 2,
    COLS    = 16,
    FREQ    = 400_000
)

disp1.lcd.putstr(f"Hello, World!")
disp2.lcd.putstr(f"Hello, Again!")
@FlewittGuy
Copy link
Author

Its just a request, I know I can just fork it but I wanted to shoot my shot.

@dhylands
Copy link
Owner

So this looks like a totally independent class which should probably go into its own file?

The file i2c_lcd.py is intended to be used on a linux (like a Raspberry Pi or a BeagleBne Black). Your class looks to be Micropython specific. So it doesn't make sense to mix these 2 things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants