Skip to content

Commit

Permalink
Updatedevice (#110)
Browse files Browse the repository at this point in the history
* Add name key to Device

* Create Device.md

* Update Home.md
  • Loading branch information
echo-lalia authored Aug 25, 2024
1 parent 33065d0 commit f7dc98d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 14 deletions.
13 changes: 12 additions & 1 deletion tools/parse_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def __repr__(self):
def create_device_module(self, dest_path):
"""Create lib.device.py file containing device-specific values."""
# reformat device constants into plain 'snake case'
new_dict = {}
new_dict = {'name': self.name}
for key, val in self.constants.items():
key = key.removeprefix('_MH_').lower()

Expand All @@ -226,6 +226,17 @@ def create_device_module(self, dest_path):
file_str = f'''\
"""
This is an automatically generated module that contains the MH configuration for this specific device.
`Device.vals` contains a dictionary of constants for this device.
`Device.feats` contains a tuple of features that this device has, with the final value being the device name.
Usage examples:
```
width = Device.display_width
height = Device.display_height
if 'touchscreen' in Device:
get_touch()
```
"""
class Device:
Expand Down
26 changes: 26 additions & 0 deletions wiki/Device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## lib.device.Device

`device` is an automatically generated module containing the `Device` class. This class provides access to device-specific constants (as set in the `device/DEVICENAME/definition.yml` file, and is designed to assist in building multi-platform apps.

The class has two main attributes:
`Device.vals` contains a dictionary of constants for this device.
`Device.feats` contains a tuple of features that this device has.

Usage examples:
``` Py
from lib.device import Device

# acess device constants
width = Device.display_width
height = Device.display_height
name = Device.name

# Check for device features
if 'touchscreen' in Device:
get_touch()

if `keyboard` in Device or 'CARDPUTER' in device:
keyboard_stuff()
```

> Note: `Device` is a singleton and can't be called or re-initialized after importing.
27 changes: 14 additions & 13 deletions wiki/Home.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
### Welcome to the MicroHydra wiki!

*This wiki is community-editable! If you'd like to help clarify or expand its contents, just fork this repo, make your changes to [/wiki](https://github.com/echo-lalia/Cardputer-MicroHydra/tree/main/wiki), and submit a pull request :)*
*This wiki is community-editable! If you'd like to help clarify or expand its contents, just fork this repo, make your changes to [/wiki](https://github.com/echo-lalia/MicroHydra/tree/main/wiki), and submit a pull request :)*

<br/>

## Multiplatform support
MicroHydra uses a few different ideas in order to output code for multiple devices. You can learn about this [here](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/multi-platform)
MicroHydra uses a few different ideas in order to output code for multiple devices. You can learn about this [here](https://github.com/echo-lalia/MicroHydra/wiki/multi-platform)

## Making Apps
For a basic overview of how MicroHydra apps work, see the [App Format](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/App-Format) section.
For a basic overview of how MicroHydra apps work, see the [App Format](https://github.com/echo-lalia/MicroHydra/wiki/App-Format) section.

<br/>

Expand All @@ -31,20 +31,21 @@ MicroHydra includes a built-in library, intended to help you easily make apps. C
&nbsp; &nbsp; &nbsp; └── terminal
├── $lib$
&nbsp; &nbsp; &nbsp; ├── [audio](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Playing-Sound)
&nbsp; &nbsp; &nbsp; ├── [display](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Display)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [palette](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Palette)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; └── [namedpalette](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Palette#libdisplaynamedpalettenamedpalette)
&nbsp; &nbsp; &nbsp; ├── [audio](https://github.com/echo-lalia/MicroHydra/wiki/Playing-Sound)
&nbsp; &nbsp; &nbsp; ├── [display](https://github.com/echo-lalia/MicroHydra/wiki/Display)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [palette](https://github.com/echo-lalia/MicroHydra/wiki/Palette)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; └── [namedpalette](https://github.com/echo-lalia/MicroHydra/wiki/Palette#libdisplaynamedpalettenamedpalette)
&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ├── $hydra$
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [beeper](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Playing-Sound#beeper)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [color](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/color)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [config](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/Accessing-config-files)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [menu](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/HydraMenu)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; └── [popup](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/popup)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [beeper](https://github.com/echo-lalia/MicroHydra/wiki/Playing-Sound#beeper)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [color](https://github.com/echo-lalia/MicroHydra/wiki/color)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [config](https://github.com/echo-lalia/MicroHydra/wiki/Accessing-config-files)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; ├── [menu](https://github.com/echo-lalia/MicroHydra/wiki/HydraMenu)
&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; └── [popup](https://github.com/echo-lalia/MicroHydra/wiki/popup)
&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ├── [userinput](https://github.com/echo-lalia/Cardputer-MicroHydra/wiki/userinput)
&nbsp; &nbsp; &nbsp; ├── [userinput](https://github.com/echo-lalia/MicroHydra/wiki/userinput)
&nbsp; &nbsp; &nbsp; ├── battlevel
&nbsp; &nbsp; &nbsp; ├── [device](https://github.com/echo-lalia/MicroHydra/wiki/Device)
&nbsp; &nbsp; &nbsp; ├── kanji
&nbsp; &nbsp; &nbsp; └── sdcard
Expand Down

0 comments on commit f7dc98d

Please sign in to comment.