mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-10 15:40:29 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -26,75 +26,75 @@
|
|||
namespace portapack {
|
||||
|
||||
void BacklightOnOff::on() {
|
||||
if( !is_on() ) {
|
||||
io.lcd_backlight(true);
|
||||
on_ = true;
|
||||
}
|
||||
if (!is_on()) {
|
||||
io.lcd_backlight(true);
|
||||
on_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightOnOff::off() {
|
||||
if( is_on() ) {
|
||||
io.lcd_backlight(false);
|
||||
on_ = false;
|
||||
}
|
||||
if (is_on()) {
|
||||
io.lcd_backlight(false);
|
||||
on_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightCAT4004::set_level(const value_t value) {
|
||||
auto target = value;
|
||||
void BacklightCAT4004::set_level(const value_t value) {
|
||||
auto target = value;
|
||||
|
||||
// Clip target value to valid range.
|
||||
if( target < 0 ) {
|
||||
target = 0;
|
||||
}
|
||||
if( target > maximum_level ) {
|
||||
target = maximum_level;
|
||||
}
|
||||
// Clip target value to valid range.
|
||||
if (target < 0) {
|
||||
target = 0;
|
||||
}
|
||||
if (target > maximum_level) {
|
||||
target = maximum_level;
|
||||
}
|
||||
|
||||
if( is_on() ) {
|
||||
pulses(target);
|
||||
} else {
|
||||
level_ = target;
|
||||
}
|
||||
if (is_on()) {
|
||||
pulses(target);
|
||||
} else {
|
||||
level_ = target;
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightCAT4004::on() {
|
||||
if( !is_on() ) {
|
||||
io.lcd_backlight(true);
|
||||
halPolledDelay(ticks_setup);
|
||||
on_ = true;
|
||||
if (!is_on()) {
|
||||
io.lcd_backlight(true);
|
||||
halPolledDelay(ticks_setup);
|
||||
on_ = true;
|
||||
|
||||
// Just enabled driver, initial value is maximum.
|
||||
const auto target_level = level();
|
||||
level_ = maximum_level;
|
||||
// Just enabled driver, initial value is maximum.
|
||||
const auto target_level = level();
|
||||
level_ = maximum_level;
|
||||
|
||||
pulses(target_level);
|
||||
}
|
||||
pulses(target_level);
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightCAT4004::off() {
|
||||
if( is_on() ) {
|
||||
io.lcd_backlight(false);
|
||||
chThdSleepMilliseconds(ms_pwrdwn);
|
||||
on_ = false;
|
||||
}
|
||||
if (is_on()) {
|
||||
io.lcd_backlight(false);
|
||||
chThdSleepMilliseconds(ms_pwrdwn);
|
||||
on_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightCAT4004::pulses(value_t target) {
|
||||
while(level() != target) {
|
||||
pulse();
|
||||
}
|
||||
while (level() != target) {
|
||||
pulse();
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightCAT4004::pulse() {
|
||||
io.lcd_backlight(false);
|
||||
halPolledDelay(ticks_lo);
|
||||
io.lcd_backlight(true);
|
||||
halPolledDelay(ticks_hi);
|
||||
io.lcd_backlight(false);
|
||||
halPolledDelay(ticks_lo);
|
||||
io.lcd_backlight(true);
|
||||
halPolledDelay(ticks_hi);
|
||||
|
||||
level_ -= 1;
|
||||
if( level_ < 0 ) {
|
||||
level_ = levels() - 1;
|
||||
}
|
||||
level_ -= 1;
|
||||
if (level_ < 0) {
|
||||
level_ = levels() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace portapack */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue