| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #include "stm32g4xx_hal.h"
- #include "oled_common.h"
- #include "i2c_bridge.h"
- #include "logo_grayscale.h"
- extern "C" {
- #include "OLED_SSD1327.h"
- #include "GFX_SSD1327.h"
- }
-
- I2C_HandleTypeDef *i2c_bridge;
- //
- void init_oled(void)
- {
- init_gpio_oled();
-
- i2c_bridge_init();
-
- i2c_bridge = i2c_get_bridge();
-
- SSD1327_I2cInit(i2c_bridge);
-
- SSD1327_Clear(BLACK);
- //GFX_Image(15, 0, (uint8_t*)logo_grayscale, 96, 96);
-
- SSD1327_Display();
-
- test_oled();
- }
- //
- void test_oled(void)
- {
- //SSD1327_DrawPixel(int16_t x, int16_t y, uint8_t Color);
-
- for (int i = 0; i < 16; i++)
- {
- SSD1327_DrawPixel(10, 20 + i, i);
- }
-
- SSD1327_DrawPixel(20, 20, 15);
-
- SSD1327_DrawPixel(30, 20, 15);
-
- SSD1327_DrawPixel(40, 20, 5);
-
- SSD1327_Display();
-
- }
- //
- void init_gpio_oled(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
-
- GPIO_InitStruct.Pin = GPIO_PIN_5;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
-
- #if 0
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOC, GPIO_PIN_6, GPIO_PIN_RESET);
-
- /*Configure GPIO pin : PC13 */
- GPIO_InitStruct.Pin = GPIO_PIN_13;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
- /*Configure GPIO pin : PC6 */
- GPIO_InitStruct.Pin = GPIO_PIN_6;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
- #endif
- }
|