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, // $
|
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.
|
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.
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.
Hello,
I have a ssd1309 and I try using your library. However, it doesn't really works for me. When I do the function Fill(White) i have only a Line on the left and when I do TestCircle() I only have half of circles. They are uncomplete. After multiples test I've figured something is wrong with the Init().
I tried doing my own version do just show a pixel as bellow:
uint8_t tab [16]={0}; //Initialisation tableau
/for (int i=0;i<16;i++){
tab[i]=0xFF;
}/
tab[4]=2; //après test 1= rien,0= rien,3=glitch vsiblement 2 marche
ssd1306_WriteCommand(0xB0); //adresse de la page
ssd1306_WriteCommand(0x00); // valeur byte bas
ssd1306_WriteCommand(0x10); //byte haut
ssd1306_WriteData(tab,128); //
/*ssd1306_WriteCommand(0x8D); // Charge Pump Setting
ssd1306_WriteCommand(0x14); // Enable charge pump
ssd1306_WriteCommand(0xC8);*/
ssd1306_WriteCommand(0x20); //Set Memory Addressing Mode
ssd1306_WriteCommand(0x00); //0x00=Horizontal,0x01=Vertical,0x02=Page
ssd1306_WriteCommand(0xA4); // Lecture Ram
ssd1306_WriteCommand(0xAF); //
SSD1306.CurrentX = 0;
SSD1306.CurrentY = 0;
SSD1306.Initialized = 1;
and when i do x00 for Horizontal after the memory x20 it give me the same result as x02, which is a page. Only x01 work as it should. This is I think where my problem is
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)