#include "stm32g4xx_hal.h" #include "oled_common.h" #include "i2c_bridge.h" #include "logo_grayscale.h" #include "fonts.h" #include "SSD1327.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); #if 0 ssd1327.clearBuffer(); ssd1327.drawString(16, 16, (char*)"Hello", 0xF, 32); ssd1327.drawString(16, 48, (char*)"World!", 0xF, 32); ssd1327.writeFullBuffer(); #endif #if 0 SSD1327_DrawPixel(20, 20, 15); SSD1327_DrawPixel(21, 20, 15); SSD1327_DrawPixel(22, 20, 15); SSD1327_DrawPixel(20, 21, 15); SSD1327_DrawPixel(21, 21, 15); SSD1327_DrawPixel(22, 21, 15); SSD1327_DrawPixel(20, 22, 15); SSD1327_DrawPixel(21, 22, 15); SSD1327_DrawPixel(22, 22, 15); SSD1327_DrawPixel(20, 23, 15); SSD1327_DrawPixel(21, 23, 15); SSD1327_DrawPixel(22, 23, 15); #endif //GFX_Image(15, 0, (uint8_t*)logo_grayscale, 96, 96); SSD1327_Display(); //while (1) {} } // void test_oled(void) { #if 0 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); #endif //void GFX_DrawLine(int x_start, int y_start, int x_end, int y_end, uint8_t color); // Верхняя GFX_DrawLine(0, 0, 127, 0, 15); // Левая GFX_DrawLine(0, 0, 0, 127, 15); // Правая GFX_DrawLine(127, 0, 127, 127, 15); // Нижняя GFX_DrawLine(0, 127, 127, 127, 15); GFX_SetFont(font_8x5); GFX_SetFontSize(1); GFX_DrawString(4, 10, (char*)"BbAa12345", 15, 0); GFX_SetFontSize(2); GFX_DrawString(4, 30, (char*)"BbAa12345", 15, 0); GFX_SetFontSize(3); GFX_DrawString(4, 60, (char*)"BbAa12345", 15, 0); //GFX_DrawChar(50, 50, 'F', 15, 0); //GFX_DrawString(10, 100, "Hello!!!", 15, 0); #if 0 uint8_t GFX_GetFontHeight(void); uint8_t GFX_GetFontWidth(void); uint8_t GFX_GetFontSize(void); void GFX_DrawChar(int x, int y, char chr, uint8_t color, uint8_t background); void GFX_DrawString(int x, int y, char* str, uint8_t color, uint8_t background); #endif SSD1327_Display(); } // oled_draw_rec(3, 5, 123, 22, 15); void oled_draw_rec(int x_start, int y_start, int x_end, int y_end, uint8_t color) { for (int i = 0; i < y_end; i++) { GFX_DrawLine(x_start, y_start + i, x_end, y_start + i, color); } GFX_DrawLine(x_start, y_end, x_end, y_end, color); } #define STR_H 20 #define STR_Y_S 36 #define STR_FRAME_START_Y 8 #define STR_X_S 4 #define STR_X_E 123 // void oled_draw_string_frame(uint8_t str_num) { for (int i = 0; i < 2; i++) { // нижняя GFX_DrawLine(STR_X_S, str_num*STR_H + STR_Y_S + i, STR_X_E, str_num*STR_H + STR_Y_S + i, 15); // верхняя GFX_DrawLine(STR_X_S, str_num*STR_H + STR_Y_S - STR_H + i, STR_X_E, str_num*STR_H + STR_Y_S - STR_H + i, 15); } // Правая GFX_DrawLine(STR_X_E, str_num*STR_H + STR_Y_S, STR_X_E, str_num*STR_H + STR_Y_S - STR_H, 15); // Левая GFX_DrawLine(STR_X_S, str_num*STR_H + STR_Y_S, STR_X_S, str_num*STR_H + STR_Y_S - STR_H, 15); } // 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); }