First, I'm not familiar with the 'how to' of doing a pull request, as I'm not at all familiar with github, and I don't want to remotely come close to breaking anything. I'm hoping this is proper venue for this.
The STM32C0XX Series is the latest low-cost line of MCU from ST. I got the SPI interface working by adding the following to the header files.
In the ssd1306_conf.h you can add this to the list of MCU #define list
#define STM32C0
and in ssd1306.h the following can be added at the end of the MCU choices
#elif defined(STM32C0)
#include "stm32c0xx_hal.h"
and aside from realizing you need to start with the reset/DC/CS pins high, it worked without a problem.
Hello, in code i see this:
ssd1306_WriteCommand(0x20);//Set Memory Addressing Mode
ssd1306_WriteCommand(0x10); // 00,Horizontal Addressing Mode; 01,Vertical Addressing Mode;
// 10,Page Addressing Mode (RESET); 11,Invalid
But datasheet say:
A[1:0] = 01b, Vertical Addressing Mode
that mean bin, not hex.
RESET state is 0b10, that mean this code not need.
P.S. Sorry for my eanglish)
Hi, could you please add an instruction, best practice about how to make use of the ssd1306 library in a project?
- How to include the library in project workspace
- can i use git submodule?
- how to include library .c and .h files in the project - import? link? How to set up project folders, what options to configure in project settings? I dont want to copy files, Twould like to maintain it as an external module that's however built with a project.
- what configuration is necessary in the IDE (HAL? I2C)
- How to use the library in the source code
- what are prerequisites, preprocessor definitions to make
- how to configure pin numbers
- where and how to initialize the display
- how to do it in a portable way (so project can be build for different board)
Thanks, maybe it's obvious but for a newcomer to stm32 ecosystem it's a guessing game. Probably there are well established standard ways of handling external modules.
Edit: i got the library to work by just copying the files into project folders so i think i know how it's supposed to be used from code. And the organization of modules and libraries i think i will figure out later.
May I ask what software did you use to convert the font to 16bits format?
code as shown below:
static const uint16_t Font7x10 [] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // sp
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 0x1000, 0x0000, 0x0000, // !
0x2800, 0x2800, 0x2800, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // "
0x2400, 0x2400, 0x7C00, 0x2400, 0x4800, 0x7C00, 0x4800, 0x4800, 0x0000, 0x0000, // #
0x3800, 0x5400, 0x5000, 0x3800, 0x1400, 0x5400, 0x5400, 0x3800, 0x1000, 0x0000, // $
|
void ssd1306_FillRectangle(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, SSD1306_COLOR color) { |
Hi. If someone tries to draw filled rectangle with coordinates starting with 0,0 (ex. FillRectangle(0,0,10,10,Black), he or she will be surprised. Program gets in an endless cycle.
for (uint8_t y = y2; y >= y1; y--) {
for (uint8_t x = x2; x >= x1; x--) {
ssd1306_DrawPixel(x, y, color);
}
}
Imagine x1=0 and x is constantly decreasing after each cycle.
- x=1, 1>=0 - true
- x=0, 0>=0 - true
- x=255, 255>=0 -true. "x" is an unsigned var.
And so on.
By the way, I didn't search for problems in other similar functions. Maybe they should be reconsidered.
|
if (SSD1306_WIDTH <= (SSD1306.CurrentX + Font.FontWidth) || |
|
SSD1306_HEIGHT <= (SSD1306.CurrentY + Font.FontHeight)) |
|
{ |
|
// Not enough space on current line |
|
return 0; |
|
} |
I think both "<=" must be only "<".
E.g. if you where on line 57 on a screen with 64 lines and wanted to print a 7 pixels high character: Line 57 to line 63 are exactly the 7 lines you'd need, but the check would fail because 64 <= (57 + 7) is true. The last line to use would always be SSD1306.CurrentY + Font.FontHeight - 1
You could even omit the check, because ssd1306_DrawPixel() checks it again. So you could have partial letters on the screen if you wanted to.
P.S.: Thank you for your work with this library. It worked on the first try with my STM32F401RE.