Rudri_Pandya
New member
i am using a new launched microcontroller called PT32(not pic) it is similar to stm32.
using https://github.com/4ilo/ssd1306-stm32HAL.git github repository as reference and i am just printing triangle and random 6 dots on the display
//***********************************************************************************************************************************************//
//***********************************************************************************************************************************************//
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_pt32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_pt32f0xx.c file
*/
UART_Config();
I2C_SSD1306_Init(); //set gpio pins
ssd1306_Init();
ssd1306_Fill(White);
ssd1306_UpdateScreen();
ssd1306_TestRectangleFill();
ssd1306_UpdateScreen();
ssd1306_DrawPixel(50, 5, Black);
ssd1306_DrawPixel(50, 15, Black);
ssd1306_DrawPixel(50, 25, Black);
ssd1306_DrawPixel(50, 35, Black);
ssd1306_DrawPixel(50, 45, Black);
ssd1306_DrawPixel(50, 55, Black);
ssd1306_DrawPixel(50, 65, Black);
ssd1306_UpdateScreen();
}
//***********************************************************************************************************************************************//
void ssd1306_Fill(SSD1306_COLOR color)
{
uint32_t i;
for(i = 0; i < sizeof(SSD1306_Buffer); i++)
{
SSD1306_Buffer = (color == Black) ? 0x00 : 0xFF;
}
}
//**************************************************************************************************************************************************//
void ssd1306_UpdateScreen()
{
int i;
for ( i = 0; i <= 1023; i++)
{
ssd1306_WriteData(SSD1306_Buffer,sizeof(SSD1306_Buffer));
}
//**************************************************************************************************************************************************//
uint8_t ssd1306_WriteData(uint8_t buffer, uint8_t buff_size){
I2C_EE_PageWrite(0x40, 0x78,2 ); //Important to recognize byte as data
I2C_EE_PageWrite(buffer, 0x78, buff_size );
return 1;
}
//**************************************************************************************************************************************************//
void ssd1306_Init()
{
// Wait for the screen to boot
// vDelay(100);
int status = 0;
// Init LCD
status += ssd1306_WriteCommand(0xAE); // Display off
status += ssd1306_WriteCommand(0x20); // Set Memory Addressing Mode
status += ssd1306_WriteCommand(0x10); // 00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
status += ssd1306_WriteCommand(0xB0); // Set Page Start Address for Page Addressing Mode,0-7
status += ssd1306_WriteCommand(0xC8); // Set COM Output Scan Direction
status += ssd1306_WriteCommand(0x00); // Set low column address
status += ssd1306_WriteCommand(0x10); // Set high column address
status += ssd1306_WriteCommand(0x40); // Set start line address
status += ssd1306_WriteCommand(0x81); // set contrast control register
status += ssd1306_WriteCommand(0xFF);
status += ssd1306_WriteCommand(0xA1); // Set segment re-map 0 to 127
status += ssd1306_WriteCommand( 0xA6); // Set normal display
status += ssd1306_WriteCommand(0xA8); // Set multiplex ratio(1 to 64)
status += ssd1306_WriteCommand(SSD1306_HEIGHT - 1);
status += ssd1306_WriteCommand(0xA4); // 0xa4,Output follows RAM content;0xa5,Output ignores RAM content
status += ssd1306_WriteCommand(0xD3); // Set display offset
status += ssd1306_WriteCommand(0x00); // No offset
status += ssd1306_WriteCommand(0xD5); // Set display clock divide ratio/oscillator frequency
status += ssd1306_WriteCommand(0xF0); // Set divide ratio
status += ssd1306_WriteCommand(0xD9); // Set pre-charge period
status += ssd1306_WriteCommand(0x22);
status += ssd1306_WriteCommand(0xDA); // Set com pins hardware configuration
// status += ssd1306_WriteCommand(SSD1306_COM_LR_REMAP << 5 | SSD1306_COM_ALTERNATIVE_PIN_CONFIG << 4 | 0x02);
status += ssd1306_WriteCommand(0x12);
status += ssd1306_WriteCommand(0xDB); // Set vcomh
status += ssd1306_WriteCommand(0x20); // 0x20,0.77xVcc
status += ssd1306_WriteCommand(0x8D); // Set DC-DC enable
status += ssd1306_WriteCommand(0x14); //
status += ssd1306_WriteCommand(0xAF); // Turn on SSD1306 panel
if (status != 0) {
return 1;
}
SSD1306.CurrentX = 0;
SSD1306.CurrentY = 0;
SSD1306.Initialized = 0;
return 0;
}
using https://github.com/4ilo/ssd1306-stm32HAL.git github repository as reference and i am just printing triangle and random 6 dots on the display
//***********************************************************************************************************************************************//
//***********************************************************************************************************************************************//
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_pt32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_pt32f0xx.c file
*/
UART_Config();
I2C_SSD1306_Init(); //set gpio pins
ssd1306_Init();
ssd1306_Fill(White);
ssd1306_UpdateScreen();
ssd1306_TestRectangleFill();
ssd1306_UpdateScreen();
ssd1306_DrawPixel(50, 5, Black);
ssd1306_DrawPixel(50, 15, Black);
ssd1306_DrawPixel(50, 25, Black);
ssd1306_DrawPixel(50, 35, Black);
ssd1306_DrawPixel(50, 45, Black);
ssd1306_DrawPixel(50, 55, Black);
ssd1306_DrawPixel(50, 65, Black);
ssd1306_UpdateScreen();
}
//***********************************************************************************************************************************************//
void ssd1306_Fill(SSD1306_COLOR color)
{
uint32_t i;
for(i = 0; i < sizeof(SSD1306_Buffer); i++)
{
SSD1306_Buffer = (color == Black) ? 0x00 : 0xFF;
}
}
//**************************************************************************************************************************************************//
void ssd1306_UpdateScreen()
{
int i;
for ( i = 0; i <= 1023; i++)
{
ssd1306_WriteData(SSD1306_Buffer,sizeof(SSD1306_Buffer));
}
//**************************************************************************************************************************************************//
uint8_t ssd1306_WriteData(uint8_t buffer, uint8_t buff_size){
I2C_EE_PageWrite(0x40, 0x78,2 ); //Important to recognize byte as data
I2C_EE_PageWrite(buffer, 0x78, buff_size );
return 1;
}
//**************************************************************************************************************************************************//
void ssd1306_Init()
{
// Wait for the screen to boot
// vDelay(100);
int status = 0;
// Init LCD
status += ssd1306_WriteCommand(0xAE); // Display off
status += ssd1306_WriteCommand(0x20); // Set Memory Addressing Mode
status += ssd1306_WriteCommand(0x10); // 00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
status += ssd1306_WriteCommand(0xB0); // Set Page Start Address for Page Addressing Mode,0-7
status += ssd1306_WriteCommand(0xC8); // Set COM Output Scan Direction
status += ssd1306_WriteCommand(0x00); // Set low column address
status += ssd1306_WriteCommand(0x10); // Set high column address
status += ssd1306_WriteCommand(0x40); // Set start line address
status += ssd1306_WriteCommand(0x81); // set contrast control register
status += ssd1306_WriteCommand(0xFF);
status += ssd1306_WriteCommand(0xA1); // Set segment re-map 0 to 127
status += ssd1306_WriteCommand( 0xA6); // Set normal display
status += ssd1306_WriteCommand(0xA8); // Set multiplex ratio(1 to 64)
status += ssd1306_WriteCommand(SSD1306_HEIGHT - 1);
status += ssd1306_WriteCommand(0xA4); // 0xa4,Output follows RAM content;0xa5,Output ignores RAM content
status += ssd1306_WriteCommand(0xD3); // Set display offset
status += ssd1306_WriteCommand(0x00); // No offset
status += ssd1306_WriteCommand(0xD5); // Set display clock divide ratio/oscillator frequency
status += ssd1306_WriteCommand(0xF0); // Set divide ratio
status += ssd1306_WriteCommand(0xD9); // Set pre-charge period
status += ssd1306_WriteCommand(0x22);
status += ssd1306_WriteCommand(0xDA); // Set com pins hardware configuration
// status += ssd1306_WriteCommand(SSD1306_COM_LR_REMAP << 5 | SSD1306_COM_ALTERNATIVE_PIN_CONFIG << 4 | 0x02);
status += ssd1306_WriteCommand(0x12);
status += ssd1306_WriteCommand(0xDB); // Set vcomh
status += ssd1306_WriteCommand(0x20); // 0x20,0.77xVcc
status += ssd1306_WriteCommand(0x8D); // Set DC-DC enable
status += ssd1306_WriteCommand(0x14); //
status += ssd1306_WriteCommand(0xAF); // Turn on SSD1306 panel
if (status != 0) {
return 1;
}
SSD1306.CurrentX = 0;
SSD1306.CurrentY = 0;
SSD1306.Initialized = 0;
return 0;
}
Attachments
Last edited: