afiskon / stm32-ssd1306

STM32 library for working with OLEDs based on SSD1306, SH1106, SH1107 and SSD1309, supports I2C and SPI
https://eax.me/stm32-ssd1306/
MIT License
771 stars 213 forks source link

How to utlize this library for Float values ? #86

Closed asking23 closed 6 months ago

asking23 commented 6 months ago

I am looking to add this to my RH Meter. how can i do the same ? I tried but not luck.

void ssd1306_TestFonts2() {
#ifdef SSD1306_INCLUDE_FONT_16x24
    uint8_t x1, y1, x2, y2;

    // Convert the float counter value to a string
    char counter_str[6]; // Assuming the format is XX.XX
    snprintf(counter_str, 6, "%05.2f", counter);

    ssd1306_Fill(Black);

    // Display the counter value
    ssd1306_SetCursor(0, 4);
    ssd1306_WriteString(counter_str, Font_16x24, White);

    // Other text
    ssd1306_SetCursor(0, 4+24+8);
    ssd1306_WriteString("RIT+1000", Font_16x24, White);

    // Underline
    x1 = 6*16;
    y1 = 4+24+8+24;
    x2 = x1+16;
    y2 = y1+2;
    ssd1306_FillRectangle(x1, y1, x2, y2, White);

    ssd1306_UpdateScreen();
#endif
}
kossnikita commented 6 months ago

There is no problem with float display as regular text. Perhaps you are using too many digits and it doesn't fit on the screen or counter isn't correct.

What do you see on the screen as a result of this code?

asking23 commented 6 months ago

Yes code works fine but I don't understand. If i start DMA to read ADC Channel in main. Display doesn't work.

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buf, ADC_BUF_LEN); // start the adc in dma mode

If no DMA then display works fine. with snprintf function to convert float into string.

kossnikita commented 6 months ago

It's probably interrupt issue or something. Not this library definitely. Library doesn't affect interrupts or DMA, cause it works in blocking mode

kamuisi commented 6 months ago

Yes code works fine but I don't understand. If i start DMA to read ADC Channel in main. Display doesn't work. HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buf, ADC_BUF_LEN); // start the adc in dma mode If no DMA then display works fine. with snprintf function to convert float into string.

You can try setting the priority level of the DMA interrupt to lower than that of the Time base: System Tick Timer

afiskon commented 6 months ago

Respectfully, this is an issue tracker, not a support forum. Please address technical questions to your favorite chat (Telegram, WhatsUp, ...), StackExchange, etc. For Russian-speaking audience I can recommend https://t.me/hwnrf

If you discovered a bug in the library, feel free opening another issue and providing explicit steps to reproduce the issue. Also specify the expected result and the result you actually got.