Hello guys.
I recently found a library for the Logitech Gaming Software for Python and created this:
You get it with the python package installer.
pip install GLCD_SDK
you can also find the files here
And there started the first problem:
I am using Python 3.5 and the library is written in python 2.7 i think. So with the package installer I got a few errors.
To fix this I have installed this library by hand and edited the setup.py to python 3.5 syntax.
Now we can start coding...
First of all we have to import some librarys:
import GLCD_SDK, time, urllib3, json
after the import we have to use a function from the GLCD library to specify the directory to the LogitechLcdEnginesWrapper.dll
. You can download the gamepanelSDK here
To specify the directory we use this command: GLCD_SDK.initDLL("\\path\\LogitechLcdEnginesWrapper.dll")
After that we can use the command from the dll trough the GLCD_SDK. There is a documentary in the gamepanel SDK
The next step is to initialise our script:
GLCD_SDK.LogiLcdInit("Steem helper", GLCD_SDK.TYPE_MONO)
The first parameter is the name shown in the Logitech Gaming Software. The second one describes the LCD type. The Logitech G510 only has a monochrome LCD.
After running this script it should look like this in the Logitech Gaming Software:
Now we want to get our steemit userdata trough their API. Simply add a .json
after your url like this:
https://steemit.com/@flash4yard.json
The next codeblock creates a http request and downloads the .json data:
pm = urllib3.PoolManager()
acc_request = pm.request('GET', 'https://steemit.com/@flash4yard.json')
acc_json = json.loads(acc_request.data.decode('utf-8'))
This is copied code from stackoverflow. I do not know exactly what the "poolmanager" does. But it works^^
If you know what it does please tell me xD.
Now we got the .json in the acc_json variable. As the next step we want to extract the current voting power:
vp = acc_json["user"]["voting_power"]
The value in "vp" is a four digit number without a comma. To solve this we have to convert the integer to a string:
vp_string = str(vp)
This way we can read the variable like an array. Now we want to format the string as we like.
From 1234
to 12,34%
vp_mod = "%s,%s%%" % (vp_string[:2], vp_string[-2:])
There we add the comma and the percent sign to a new string.
In the last step we write to the LCD:
GLCD_SDK.LogiLcdMonoSetText(0, "User: @flash4yard")
The "0" defines the line on the LCD. Counted from the top.
GLCD_SDK.LogiLcdMonoSetText(3, "Voting Power: %s" % vp_mod)
GLCD_SDK.LogiLcdUpdate()
This applies the changes made the lines above
The result should look like this:
In addation you can add a while loop to get the new data every X seconds with the "time" library.
I did it and it updates every 5 minutes. Also I have added a few lines of code to assign the username and saving it in a text file. So the link to the .json changes to the set user name.
This variable have to be passed in the pm.request('GET',acc_url)
command
In the future I am planning to add more information about your profile to be shown and something like a config were you can select which stats you want to show and which not.
I hope you liked this project
If you have any questions feel free to ask!