Use /sys/class/board-info/ to detect platform type#383
Use /sys/class/board-info/ to detect platform type#383dwalton76 merged 4 commits intoev3dev:developfrom dwalton76:auto-platform-detect
Conversation
| return 'evb' | ||
| elif value == 'LEGO MINDSTORMS EV3': | ||
| return 'ev3' | ||
| elif value == 'TBD': |
There was a problem hiding this comment.
@dlech if you can send me the BOARD_INFO_MODEL values for brickpi, pistorms, etc I'll go ahead and add those
There was a problem hiding this comment.
All the info you need should be on this page: http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-stretch/board-info.html
| @@ -0,0 +1,128 @@ | |||
|
|
|||
| """ | |||
| An assortment of classes modeling specific features of the EV3 brick. | |||
|
Awesome! |
| if os.path.exists(filename): | ||
| with open(filename, 'r') as fh: | ||
| current_platform = fh.read().strip() | ||
| def get_current_platform(): |
There was a problem hiding this comment.
This might be useful as a core library method
|
I need to test the PiStorms part but that is what was needed back in #170 (was closed because we had no way to detect if we were running on a pistorms) |
|
Any objections to merging this one in? I need it to go in so I can post the PR for the buttons API |
|
|
||
| def get_current_platform(): | ||
| """ | ||
| Look in /sys/class/board-info/ to determine the platform type |
There was a problem hiding this comment.
Document the possible return values?
| @staticmethod | ||
| def on_enter(state): | ||
| """ | ||
| This handler is called by `process()` whenever state of 'enter' button |
There was a problem hiding this comment.
This is so you can do things like
def foobar():
print("The user pressed ENTER")
btn = Button()
btn.on_enter = foobar
while True:
btn.process()
I'm working on making this event driven as part of the buttons API work...today you have to call it in a while loop like that to make it do what you want.
There was a problem hiding this comment.
Oh, I see. Damn, Python is weird 😆 Is that a common idiom? Is there not an event framework of some sort?
Either way, I don't think it's blocking.
There was a problem hiding this comment.
This project is the only place I've seen this approach used...but I've only been writing python for 4 years so who knows maybe it is wildly popular and I just haven't been exposed to it.
| @@ -0,0 +1,128 @@ | |||
|
|
|||
| """ | |||
| An assortment of classes modeling specific features of the EVB brick. | |||
There was a problem hiding this comment.
EVB brick? I would suggest "EVB BeagleBone cape" or whatever those things are called.
There was a problem hiding this comment.
I'll chop the brick part...I normally here it referred to as just an EVB
|
LGTM |
No description provided.