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

TcMenu with VSCode + ESP-IDF v5.1.3 for ESP32 an ST7735 1,8" TFT display #59

Open
ONik93 opened this issue Aug 18, 2024 · 1 comment
Open

Comments

@ONik93
Copy link

ONik93 commented Aug 18, 2024

Hi,

I've build TcMenu with VSCode + ESP-IDF v5.1.3 for ESP32 an ST7735 1,8" TFT display.

To achieve it i changed this lines in TaskManagerIO and SimpleCollections lib

#include "Utils.h"

inline bool casAtomic(position_ptr_t ptr, position_t expected, position_t newVal) {
    uint32_t exp32 = expected;
    uint32_t new32 = newVal;
    // uxPortCompareSet(ptr, exp32, &new32);
    uxPortCompareSetCustom(ptr, exp32, &new32);
    return new32 == expected;
}
// Utils.h
#include <stdint.h>

void uxPortCompareSetCustom(volatile uint32_t *addr, uint32_t compare, uint32_t *set);
// Utils.cpp
#include "Utils.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

void uxPortCompareSetCustom(volatile uint32_t *addr, uint32_t compare, uint32_t *set) {
    uint32_t prev;
    //BaseType_t taskState;
    int taskState;

    // Enter critical section to ensure atomicity
    taskState = taskENTER_CRITICAL_FROM_ISR();

    prev = *addr;
    if (prev == compare) {
        *addr = *set;  // Update memory location with the new value
    }
    *set = prev;  // Update the 'set' pointer with the previous value

    // Exit critical section
    taskEXIT_CRITICAL_FROM_ISR(taskState);
}

And IoAbstraction library required following modification


#include <Arduino.h>

void EspAnalogOutputMode::pinSetup() {
    if(!isDac()) {
        // for other than the dac ports, we need to set up PWM
        ledcSetup(pwmChannel, pwmWidth, 8);
        ledcAttachPin(pin, pwmChannel);
        // ledcSetup(pwmChannel, pwmWidth, 8);
        // ledcAttachPin(pin, pwmChannel);
        ledcAttach(pin, pwmWidth, 8);
    }

I hope you can implement this fixes to your project.

@davetcc
Copy link
Collaborator

davetcc commented Sep 15, 2024

I'm not sure why the port macro uxPortCompareSet from freertos/portmacro.h doesn't work to be honest, it should really be there as it's part of their core rtos implementation.

I think the ledc functions may be part of Arduino to be honest and they may need to be fully moved to use IDF functions instead.

We do plan to fully support IDF, but for now, you should be able to get uxPortCompareSet working with IDF, and you could just comment out the ledc functions if Arduino library is not there.

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

2 participants