STM32 "for the rest of us"

bigplik:
any chance you would make some code for I2C for OLED displays?
I'll tried your SPI example and it is working very well ;), error was because of linux,
would like to use bigger display like 1.3" or 2"+ OLED for my maple mini
all of the I have are I2C unfortunately

To some degree, we have:
I2C example

I have also used I2C with the BMP180 and that works well. So, it boils down to the display and library you intend on using.

If an Adafruit library, much of the work is already done since Adafruit uses a common GFX interface and only the display driver has to be updated. If you are proficient, you can use the existing OLED code as a template.

If another author, it is a new effort, but should not be impossible- just a bit more difficult unless one has the exact display for testing.

Ray

Edit:

In general, here is how it all fits together using the SSD1306 as an example.
In Adafruit_SSD1306.h you will see the prototypes for the class member functions:

class Adafruit_SSD1306 : public Adafruit_GFX {
 public:
  Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);     // Software SPI
  Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS);                              // Hardware SPI
  Adafruit_SSD1306(int8_t RST);                                                    // I2C
<...>

In Adafruit_SSD1306.cpp, you will see:

Adafruit_SSD1306::Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
  cs = CS;
  rst = RST;
  dc = DC;
  sclk = SCLK;
  sid = SID;
  hwSPI = false;
}

// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset 
Adafruit_SSD1306::Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
  dc = DC;
  rst = RST;
  cs = CS;
  hwSPI = true;
}

Adafruit_SSD1306::Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
  cs = CS;
  rst = RST;
  dc = DC;
  sclk = SCLK;
  sid = SID;
  hwSPI = false;
}

You will notice, that the Adafruit_SSD1306::Adafruit_SSD1306 is common 3 times, but only one can be used: h/w SPI, s/w SPI, or I2C. This methodology is called "overloading":

An overloaded declaration is a declaration that had been declared with the same name as a previously declared declaration in the same scope, except that both declarations have different arguments and obviously different definition (implementation).

When you call an overloaded function or operator, the compiler determines the most appropriate definition to use by comparing the argument types you used to call the function or operator with the parameter types specified in the definitions. The process of selecting the most appropriate overloaded function or operator is called overload resolution.

Study both my SPI and madias's I2C examples. That should get you a head-start on making necessary changes to existing libraries.

Good luck,

Ray