mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
my9221: add direction for setBarLevel
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
d2e2682f0e
commit
8cfb3d3dab
@ -73,17 +73,25 @@ MY9221::~MY9221() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
MY9221::setBarLevel (uint8_t level) {
|
MY9221::setBarLevel (uint8_t level, bool direction) {
|
||||||
if (level > 10) {
|
if (level > 10) {
|
||||||
return MRAA_ERROR_INVALID_PARAMETER;
|
return MRAA_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
send16bitBlock (CMDMODE);
|
send16bitBlock (CMDMODE);
|
||||||
for(uint8_t block_idx = 0; block_idx < 12; block_idx++) {
|
if (direction) {
|
||||||
uint32_t state = (block_idx < level) ? BIT_HIGH : BIT_LOW;
|
level += 3;
|
||||||
send16bitBlock (state);
|
for(uint8_t block_idx = 12; block_idx > 0; block_idx--) {
|
||||||
|
uint32_t state = (block_idx < level) ? BIT_HIGH : BIT_LOW;
|
||||||
|
send16bitBlock (state);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(uint8_t block_idx = 0; block_idx < 12; block_idx++) {
|
||||||
|
uint32_t state = (block_idx < level) ? BIT_HIGH : BIT_LOW;
|
||||||
|
send16bitBlock (state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lockData ();
|
return lockData ();
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
|
@ -63,8 +63,9 @@ class MY9221 {
|
|||||||
* Set the level bar
|
* Set the level bar
|
||||||
*
|
*
|
||||||
* @param level selected level for the bar (1 - 10)
|
* @param level selected level for the bar (1 - 10)
|
||||||
|
* @param direction up or down, true is up and is the default
|
||||||
*/
|
*/
|
||||||
mraa_result_t setBarLevel (uint8_t level);
|
mraa_result_t setBarLevel (uint8_t level, bool direction=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name of the component
|
* Return name of the component
|
||||||
|
Loading…
x
Reference in New Issue
Block a user