mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-08-17 23:55:04 +00:00
Bugfix
This commit is contained in:
parent
387ed31087
commit
822a7a2fd4
@ -110,7 +110,10 @@ static error_t start(Device* device) {
|
|||||||
|
|
||||||
device_set_driver_data(device, internal);
|
device_set_driver_data(device, internal);
|
||||||
|
|
||||||
gpio_backlight_set_brightness_default(device); // Allowed to fail, we don't care about the result
|
if (gpio_backlight_set_brightness_default(device) != ERROR_NONE) {
|
||||||
|
// Allowed to fail, we don't care about the result
|
||||||
|
LOG_W(TAG, "gpio_backlight_set_brightness_default(%s) failed", device->name);
|
||||||
|
}
|
||||||
|
|
||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,10 @@ static error_t apply_brightness(Device* device, uint8_t brightness) {
|
|||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (brightness > config->brightness_range.max) {
|
||||||
|
brightness = config->brightness_range.max;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t period_ns;
|
uint32_t period_ns;
|
||||||
error_t error = pwm_get_period(config->pwm, &period_ns);
|
error_t error = pwm_get_period(config->pwm, &period_ns);
|
||||||
if (error != ERROR_NONE) {
|
if (error != ERROR_NONE) {
|
||||||
@ -97,6 +101,11 @@ static error_t start(Device* device) {
|
|||||||
if (internal == nullptr) {
|
if (internal == nullptr) {
|
||||||
return ERROR_OUT_OF_MEMORY;
|
return ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config->brightness_range.max <= config->brightness_range.min) {
|
||||||
|
return ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
device_set_driver_data(device, internal);
|
device_set_driver_data(device, internal);
|
||||||
|
|
||||||
pwm_backlight_set_brightness_default(device); // Allowed to fail, we don't care about the result
|
pwm_backlight_set_brightness_default(device); // Allowed to fail, we don't care about the result
|
||||||
|
|||||||
@ -62,19 +62,24 @@ static error_t rgb_led_pwm_get_color(Device* device, RgbLedColor* out_color) {
|
|||||||
|
|
||||||
static error_t rgb_led_pwm_enable(Device* device) {
|
static error_t rgb_led_pwm_enable(Device* device) {
|
||||||
const auto* config = GET_CONFIG(device);
|
const auto* config = GET_CONFIG(device);
|
||||||
GET_INTERNAL(device)->enabled = true;
|
|
||||||
|
|
||||||
error_t error = pwm_enable(config->pwm_red);
|
error_t error = pwm_enable(config->pwm_red);
|
||||||
if (error == ERROR_NONE) {
|
|
||||||
error = pwm_enable(config->pwm_green);
|
|
||||||
}
|
|
||||||
if (error == ERROR_NONE) {
|
|
||||||
error = pwm_enable(config->pwm_blue);
|
|
||||||
}
|
|
||||||
if (error != ERROR_NONE) {
|
if (error != ERROR_NONE) {
|
||||||
LOG_E(TAG, "Failed to enable LED");
|
return error;
|
||||||
}
|
}
|
||||||
return error;
|
error = pwm_enable(config->pwm_green);
|
||||||
|
if (error != ERROR_NONE) {
|
||||||
|
pwm_disable(config->pwm_red);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
error = pwm_enable(config->pwm_blue);
|
||||||
|
if (error != ERROR_NONE) {
|
||||||
|
pwm_disable(config->pwm_green);
|
||||||
|
pwm_disable(config->pwm_red);
|
||||||
|
LOG_E(TAG, "Failed to enable LED");
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
GET_INTERNAL(device)->enabled = true;
|
||||||
|
return ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rgb_led_pwm_disable(Device* device) {
|
static void rgb_led_pwm_disable(Device* device) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user