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

show better error message for sevensegment demo #76

Merged
merged 6 commits into from
Dec 30, 2017
Merged

Conversation

thijstriemstra
Copy link
Collaborator

when using unsupported devices.

fixes #71

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Dec 27, 2017

ps. i haven't tested this on python 2.7; 3.4 only.. (rpi2 jessie)

@rm-hull
Copy link
Owner

rm-hull commented Dec 27, 2017

I think it he emulators have a seven seg transform that should be accommodated as well

@thijstriemstra
Copy link
Collaborator Author

@rm-hull in that case this isn't a good fix. Ideally we should be able to query a luma library for their sevensegment devices. Thoughts?

@rm-hull
Copy link
Owner

rm-hull commented Dec 27, 2017

Maybe do a hasattr check on the device to see if it has the segment_mapper defined?
Or simply do a try/catch for the specific attribute error?

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Dec 30, 2017

Not that it's terribly important but this PR doesn't have any effect on OSX either;

$ python examples/sevensegment_demo.py 
usage: sevensegment_demo.py [-h] [--config CONFIG] [--display] [--width WIDTH]
                            [--height HEIGHT] [--rotate] [--interface]
                            [--i2c-port I2C_PORT] [--i2c-address I2C_ADDRESS]
                            [--spi-port SPI_PORT] [--spi-device SPI_DEVICE]
                            [--spi-bus-speed SPI_BUS_SPEED] [--gpio GPIO]
                            [--gpio-data-command GPIO_DATA_COMMAND]
                            [--gpio-reset GPIO_RESET]
                            [--gpio-backlight GPIO_BACKLIGHT]
                            [--block-orientation] [--mode] [--framebuffer]
                            [--bgr] [--h-offset H_OFFSET]
                            [--v-offset V_OFFSET] [--backlight-active]
                            [--transform] [--scale SCALE]
                            [--duration DURATION] [--loop LOOP]
                            [--max-frames MAX_FRAMES]
sevensegment_demo.py: error: I2C device not found: /dev/i2c-1

what it does show is that the settings can be printed earlier to clarify what params are used, e.g.

$ python examples/sevensegment_demo.py
Version: luma.oled 2.3.1 (luma.core 1.2.1)
Display: ssd1306
Interface: i2c
Dimensions: 128 x 64
------------------------------------------------------------
usage: sevensegment_demo.py [-h] [--config CONFIG] [--display] [--width WIDTH]
                            [--height HEIGHT] [--rotate] [--interface]
                            [--i2c-port I2C_PORT] [--i2c-address I2C_ADDRESS]
                            [--spi-port SPI_PORT] [--spi-device SPI_DEVICE]
                            [--spi-bus-speed SPI_BUS_SPEED] [--gpio GPIO]
                            [--gpio-data-command GPIO_DATA_COMMAND]
                            [--gpio-reset GPIO_RESET]
                            [--gpio-backlight GPIO_BACKLIGHT]
                            [--block-orientation] [--mode] [--framebuffer]
                            [--bgr] [--h-offset H_OFFSET]
                            [--v-offset V_OFFSET] [--backlight-active]
                            [--transform] [--scale SCALE]
                            [--duration DURATION] [--loop LOOP]
                            [--max-frames MAX_FRAMES]
sevensegment_demo.py: error: I2C device not found: /dev/i2c-1

@@ -56,12 +56,12 @@ def get_device(actual_args=None):
config = cmdline.load_config(args.config)
args = parser.parse_args(config + actual_args)

print(display_settings(args))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 👍

@rm-hull
Copy link
Owner

rm-hull commented Dec 30, 2017

For OSX, I just checked, and the seven segment demo command args are:

$ python examples/sevensegment_demo.py -d pygame  --transform=seven_segment --width=8 --height=8

That continues to work with 937eb9c that I just pushed

@@ -68,6 +69,11 @@ def show_message_alt(seg, msg, delay=0.1):
def main():
# create seven segment device
device = get_device()

if not hasattr(device, 'segment_mapper'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm - thinking about it, this check would be better off in the sevensegment class instead

@thijstriemstra thijstriemstra merged commit bedef55 into master Dec 30, 2017
@thijstriemstra thijstriemstra deleted the 7seg-71 branch December 30, 2017 17:49
@thijstriemstra
Copy link
Collaborator Author

Looks like that didn't help either, e.g.:

$ python examples/sevensegment_demo.py -d ssd1306
Version: luma.oled 2.3.1 (luma.core 1.2.1)
Display: ssd1306
Interface: i2c
Dimensions: 128 x 64
------------------------------------------------------------
usage: sevensegment_demo.py [-h] [--config CONFIG] [--display] [--width WIDTH]
                            [--height HEIGHT] [--rotate] [--interface]
                            [--i2c-port I2C_PORT] [--i2c-address I2C_ADDRESS]
                            [--spi-port SPI_PORT] [--spi-device SPI_DEVICE]
                            [--spi-bus-speed SPI_BUS_SPEED] [--gpio GPIO]
                            [--gpio-data-command GPIO_DATA_COMMAND]
                            [--gpio-reset GPIO_RESET]
                            [--gpio-backlight GPIO_BACKLIGHT]
                            [--block-orientation] [--mode] [--framebuffer]
                            [--bgr] [--h-offset H_OFFSET]
                            [--v-offset V_OFFSET] [--backlight-active]
sevensegment_demo.py: error: I2C device not found on address: 0x3C

@rm-hull
Copy link
Owner

rm-hull commented Dec 30, 2017

Presumably that fails earlier in the init, because OSX doesnt have the i2c device ?

p.s. it would be useful if the version printed something like:

Version: luma.oled 2.3.1 (luma.core 1.2.1) on ${platform.platform} with Python X.Y.Z

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

Successfully merging this pull request may close these issues.

sevensegment_demo.py fails
2 participants