User Manual

2/12/2018 PiJuice/Software at master · PiSupply/PiJuice · GitHub
https://github.com/PiSupply/PiJuice/tree/master/Software 16/18
print pijuice.status.GetStatus()
Returns: {'data': {'battery': 'CHARGING_FROM_5V_IO', 'powerInput5vIo': 'PRESENT', 'isFault': False, 'isButton':
False, 'powerInput': 'NOT_PRESENT'}, 'error': 'NO_ERROR'}
GetChargeLevel()
Gets current charge level percentage. Returns: 'data':charge_level Where charge_level is percentage of charge, [0 - 100]%.
Example:
print pijuice.status.GetChargeLevel()
Returns: {'data': 57, 'error': 'NO_ERROR'}
GetButtonEvents()Gets events generated by PiJuice buttons presses. Returns: 'data': { 'SW1':event, 'SW2':event, 'SW3':event }
where event is detected event name for corresponding button and can be one of: 'PRESS', 'RELEASE', 'SINGLE_PRESS',
'DOUBLE_PRESS', 'LONG_PRESS1', 'LONG_PRESS2' if event is generated or 'NO_EVENT' if event is absent. Example:
print pijuice.status.GetButtonEvents()
Returns: {'data': {'SW1': 'NO_EVENT', 'SW3': ' SINGLE_PRESS', 'SW2': 'NO_EVENT'}, 'error': 'NO_ERROR'}
AcceptButtonEvent(button)Clears generated button event. Arguments: button: button designator, one of: 'SW1', 'SW2',
'SW3'. Example:
print pijuice.status. AcceptButtonEvent ('SW2')
SetLedState(led, rgb)Sets red, green and blue brightness levels for LED configured as “User LED”. Arguments: led: LED
designator, one of: 'D1', 'D2'. rgb:[r, g, b] - array of brightness levels of LED components, where r, g and b, are in range [0 –
255]. Example:
print pijuice.status.SetLedState(‘D2’, [127, 0, 200])
GetLedState(led)Gets current brightness levels for LED configured as “User LED”. Arguments: led: LED designator, one of:
'D1', 'D2'. Returns: 'data':[r, g, b] where [r, g, b] is array of brightness levels of LED components, where r, g and b, are in range
[0 – 255]. Example:
print pijuice.status.GetLedState('D1')
Returns: {'data': [127, 0, 200], 'error': 'NO_ERROR'}
SetLedBlink(led, count, rgb1, period1, rgb2, period2)Plays blink pattern on LED configured as “User LED”. Arguments: led:
LED designator, one of: 'D1', 'D2'. count: number of blinks for count in range [1 - 254], blink indefinite number of times for
count = 255. rgb1: [r, g, b] is array of brightness levels of LED components in first period of blink, where r, g and b, are in
range [0 – 255]. period1: duration of first blink period in range [10 – 2550] miliseconds. rgb2: [r, g, b] is array of brightness
levels of LED components in second period of blink, where r, g and b, are in range [0 – 255]. Period2: duration of second
blink period in range [10 – 2550] miliseconds. Example:
pijuice.status.SetLedBlink('D2', 10, [0,200,100], 1000, [100, 0, 0], 500)
GetLedBlink(led)Gets current settings of blink pattern for LED configured as “User LED”. Arguments: led: LED designator,
one of: 'D1', 'D2'. Returns: 'data': { 'count':count, 'rgb1':rgb1, 'period1':period1, 'rgb2':rgb2, 'period2':period2 } Example: