Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backlight brightness resets on ledc access #642

Closed
CelliesProjects opened this issue Nov 12, 2024 · 0 comments
Closed

Backlight brightness resets on ledc access #642

CelliesProjects opened this issue Nov 12, 2024 · 0 comments

Comments

@CelliesProjects
Copy link

CelliesProjects commented Nov 12, 2024

Environment ( 実行環境 )

  • PlatformIO

  • MCU or Board name: [ESP32-S3-BOX-LITE]

Problem Description ( 問題の内容 )

I have an issue with the brightness setting.

Expected Behavior ( 期待される動作 )

The brightness should stay at the selected level.

Actual Behavior ( 実際の動作 )

The brightness resets to the default level.

I think it might be related related to the rest of the code, which is a ledc controller using 5 channels. But I fail to see how.

Here is the boot log:

         Connected!
[  2266][I][main.cpp:177] setup(): aquacontrol v2
[  2282][I][main.cpp:199] setup(): mounted SD
[  2289][I][main.cpp:50] parseTimerFile(): parsing '/default.aqu'
[  2301][E][main.cpp:142] parseTimerFile(): duplicate timer entry at line 33 for channel 4 at time 71460
[  2310][I][main.cpp:213] setup(): ch 0: 8 timers
[  2315][I][main.cpp:214] setup(): ch 1: 6 timers
[  2319][I][main.cpp:215] setup(): ch 2: 6 timers
[  2324][I][main.cpp:216] setup(): ch 3: 6 timers
[  2328][I][main.cpp:217] setup(): ch 4: 6 timers
[  2379][I][LGFX_AutoDetect_ESP32_all.hpp:1028] init_impl(): [LovyanGFX] [Autodetect] load from NVS : board:53
[  2406][I][LGFX_AutoDetect_ESP32_all.hpp:1264] setup(): [LovyanGFX] [Autodetect] ESP32_S3_BOX_Lite
[  2416][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 45 (channel 0, resolution 9)
[  2685][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 202 - AUTH_FAIL
[  2691][W][STA.cpp:537] disconnect(): STA already disconnected.
[  7040][W][STA.cpp:135] _onStaArduinoEvent(): Reason: 2 - AUTH_EXPIRE
[  7047][W][STA.cpp:537] disconnect(): STA already disconnected.
[  7832][I][main.cpp:242] setup(): syncing NTP
[ 12406][I][main.cpp:45] ntpCb(): NTP synced
[ 12410][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 38 (channel 1, resolution 14)
[ 12420][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 39 (channel 2, resolution 14)
[ 12429][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 40 (channel 3, resolution 14)
[ 12438][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 41 (channel 4, resolution 14)
[ 12448][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 42 (channel 5, resolution 14)
[ 12657][I][dimmerTask.cpp:108] dimmerTask(): moon visible 85.240039 angle 134

From looking with a scope I learned that the reset happens around the time the rest of the ledc channels are initialised.

This is the ledc init code:

void dimmerTask(void *parameter)
{
    constexpr const uint8_t ledPin[NUMBER_OF_CHANNELS] = {38, 39, 40, 41, 42};
    constexpr const float fullMoonLevel[NUMBER_OF_CHANNELS] = {0, 0, 0, 0, 0.06};

    const int freq = 1220;
    for (int index = 0; index < NUMBER_OF_CHANNELS; index++)
        if (!ledcAttach(ledPin[index], freq, SOC_LEDC_TIMER_BIT_WIDTH))
        {
            log_e("Error setting ledc pin %i. system halted", index);
            while (1)
                delay(1000);
        }
        ...

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant