Mercurial > public > ostc4
diff Discovery/Src/display.c @ 871:f7318457df4d default
support for new screen
ToDo: Brightness settings
author | heinrichsweikamp |
---|---|
date | Tue, 13 Aug 2024 13:24:54 +0200 |
parents | 5ca177d2df5d |
children | e373e90a48db |
line wrap: on
line diff
--- a/Discovery/Src/display.c Mon Jul 22 16:40:14 2024 +0200 +++ b/Discovery/Src/display.c Tue Aug 13 13:24:54 2024 +0200 @@ -3,32 +3,71 @@ #include "ostc.h" #include "display.h" -#define ENABLE_EXTENDED_COMMANDS 0xB9 -#define SET_POWER 0xB1 -#define SLEEP_OUT 0x11 -#define DISPLAY_INVERSION_OFF 0x20 -#define MEMORY_ACCESS_ONTROL 0x36 -#define INTERFACE_PIXEL_FORMAT 0x3A -#define SET_RGB_INTERFACE_RELATED 0xB3 -#define SET_DISPLAY_WAVEFORM 0xB4 -#define SET_PANEL 0xCC -#define SET_GAMMA_CURVE_RELATED 0xE0 -#define DISPLAY_ON 0x29 -#define DISPLAY_OFF 0x28 -#define SLEEP_IN 0x10 +#define TFT_ENABLE_EXTENDED_COMMANDS 0xB9 +#define TFT_SET_POWER 0xB1 +#define TFT_SLEEP_OUT 0x11 +#define TFT_DISPLAY_INVERSION_OFF 0x20 +#define TFT_MEMORY_ACCESS_ONTROL 0x36 +#define TFT_INTERFACE_PIXEL_FORMAT 0x3A +#define TFT_SET_RGB_INTERFACE_RELATED 0xB3 +#define TFT_SET_DISPLAY_WAVEFORM 0xB4 +#define TFT_SET_PANEL 0xCC +#define TFT_SET_GAMMA_CURVE_RELATED 0xE0 +#define TFT_DISPLAY_ON 0x29 +#define TFT_DISPLAY_OFF 0x28 +#define TFT_SLEEP_IN 0x10 +#define OLED_SCTE_SET_31h 0x31 // 0x0008 +#define OLED_WCWE_SET_32h 0x32 // 0x0014 +#define OLED_GATELESS1_30h 0x30 // 0x0002 +#define OLED_GATELESS2_27h 0x27 // 0x0000 +#define OLED_OSCILLATOR 0x11 // 0x00A1 +#define OLED_VBP_SET_12h 0x12 // 0x0008 +#define OLED_VFP_SET_13h 0x13 // 0x0008 +#define OLED_DISPLAY_CON_15h 0x15 // 0x0000 +#define OLED_COLOR_DEPTH_SET_16h 0x16 // 0x0000 +#define OLED_PENTILE_KEY_EFh 0xEF // 0x00D0 or 0x00E8 +#define OLED_PENTILE1_A0h 0xA0 // 0x0063 +#define OLED_PENTILE2_A1h 0xA1 // 0x00C0 +#define OLED_PENTILE3_A2h 0xA2 // 0x0032 +#define OLED_PENTILE4_A3h 0xA3 // 0x0002 +#define OLED_BRIGHTNESS_CTRL_39h 0x39 // 0044h +// gamma table 0x40 - 0x66 +#define OLED_BOOSTING_FREQ 0x17 // 0x0022 +#define OLED_AMP_SET_18h 0x18 // 0x0033 +#define OLED_GAMMA_AMP_19h 0x19 // 0x0003 +#define OLED_POWER_CONTROL2_1Ah 0x1A // 0x0001 +#define OLED_POWER_CONTROL2_1Bh 0x1B // +#define OLED_POWER_CONTROL2_1Ch 0x1C // +#define OLED_INTERNAL_LOGIC_VOLTAGE 0x22 // VCC*0,65 = 3,3V * 0,55 = 0x00A2 +#define OLED_POWER_SET 0x23 // VC1OUT = VCI X 0.98 (default) = 0x00 +#define OLED_POWER_SET2 0x24 // VREG2OUT = 5,4V, VREG1OUT = 4,2V =0x77 +#define OLED_DISPLAY_CONDITION_SET_26h 0x26 // 0x00A0 +#define OLED_STB_BY_OFF 0x1D // 00A0 + 300ms wait +#define OLED_DDISP_ON 0x14 // 0003 static void Display_Error_Handler(void); +static void display_power_on__2_of_2__post_RGB_display0(void); +static void display_power_on__2_of_2__post_RGB_display1(void); +static uint8_t receive_screen(); void display_power_on__1_of_2__pre_RGB(void) { - /* reset system */ + uint8_t aTxBuffer[3]; + /* reset system */ HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); HAL_Delay(10); HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); - HAL_Delay(10); + HAL_Delay(25); + // check for new screen + hardwareDisplay=0; // default is old screen + aTxBuffer[0] = 0x71; // Read internal register + if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen) + { + hardwareDisplay=1; + } /* RGB signals should be now for 2 frames or more (datasheet) */ } @@ -47,6 +86,24 @@ HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select } +static uint8_t receive_screen(uint8_t *pData) +{ + uint8_t byte; + HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select + if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, 1, 10000) != HAL_OK) + Display_Error_Handler(); + while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) + { + } + if(HAL_SPI_Receive(&hspiDisplay, &byte, 1, 10000) != HAL_OK) + Display_Error_Handler(); + while (HAL_SPI_GetState(&hspiDisplay) != HAL_SPI_STATE_READY) + { + } + HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select + return byte; +} + static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength) { @@ -95,6 +152,19 @@ void display_power_on__2_of_2__post_RGB(void) { + if (hardwareDisplay == 1) + { + display_power_on__2_of_2__post_RGB_display1(); + } + else + { + display_power_on__2_of_2__post_RGB_display0(); + } +} + + void display_power_on__2_of_2__post_RGB_display0(void) +{ + uint8_t aTxBuffer[32]; uint8_t bTxBuffer[36]; uint16_t i,length; @@ -104,14 +174,14 @@ for(i=0;i<36;i++) bTxBuffer[i] = 0; - aTxBuffer[0] = ENABLE_EXTENDED_COMMANDS; + aTxBuffer[0] = TFT_ENABLE_EXTENDED_COMMANDS; aTxBuffer[1] = 0xFF; aTxBuffer[2] = 0x83; aTxBuffer[3] = 0x63; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,4); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SET_POWER; + aTxBuffer[0] = TFT_SET_POWER; aTxBuffer[1] = 0x81; aTxBuffer[2] = 0x24; aTxBuffer[3] = 0x04; @@ -127,27 +197,27 @@ length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SLEEP_OUT; + aTxBuffer[0] = TFT_SLEEP_OUT; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); send((uint8_t*)bTxBuffer, length); HAL_Delay(5+1); - aTxBuffer[0] = DISPLAY_INVERSION_OFF; + aTxBuffer[0] = TFT_DISPLAY_INVERSION_OFF; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = MEMORY_ACCESS_ONTROL; + aTxBuffer[0] = TFT_MEMORY_ACCESS_ONTROL; aTxBuffer[1] = 0x00; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = INTERFACE_PIXEL_FORMAT; + aTxBuffer[0] = TFT_INTERFACE_PIXEL_FORMAT; aTxBuffer[1] = 0x70; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); send((uint8_t*)bTxBuffer, length); HAL_Delay(120+20); - aTxBuffer[0] = SET_POWER; + aTxBuffer[0] = TFT_SET_POWER; aTxBuffer[1] = 0x78; aTxBuffer[2] = 0x24; aTxBuffer[3] = 0x04, @@ -163,12 +233,12 @@ length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,13); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SET_RGB_INTERFACE_RELATED; + aTxBuffer[0] = TFT_SET_RGB_INTERFACE_RELATED; aTxBuffer[1] = 0x01; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SET_DISPLAY_WAVEFORM; + aTxBuffer[0] = TFT_SET_DISPLAY_WAVEFORM; aTxBuffer[1] = 0x00; aTxBuffer[2] = 0x08; aTxBuffer[3] = 0x56; @@ -181,12 +251,12 @@ length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,10); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SET_PANEL; + aTxBuffer[0] = TFT_SET_PANEL; aTxBuffer[1] = 0x0B; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,2); send((uint8_t*)bTxBuffer, length); - aTxBuffer[0] = SET_GAMMA_CURVE_RELATED; + aTxBuffer[0] = TFT_SET_GAMMA_CURVE_RELATED; aTxBuffer[1] = 0x01; aTxBuffer[2] = 0x48; aTxBuffer[3] = 0x4D; @@ -221,15 +291,544 @@ send((uint8_t*)bTxBuffer, length); HAL_Delay(5+1); - aTxBuffer[0] = DISPLAY_ON; + aTxBuffer[0] = TFT_DISPLAY_ON; length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); send((uint8_t*)bTxBuffer, length); } +void display_power_on__2_of_2__post_RGB_display1(void) +{ + uint8_t aTxBuffer[3]; + + aTxBuffer[0] = 0x71; // Read chip Index & revision number + aTxBuffer[1] = 0x00; // Dummy write - reads out 0x27 + aTxBuffer[1] = 0x00; // Dummy write - reads out 0x96 + send((uint8_t*)aTxBuffer, 3); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_OSCILLATOR; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA4; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_SCTE_SET_31h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x08;//8 + send((uint8_t*)aTxBuffer, 2); + + //debug read + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_SCTE_SET_31h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x73; // Read internal register + aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value) + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_WCWE_SET_32h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x14;//14 + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_GATELESS1_30h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x02; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_GATELESS2_27h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x01; + send((uint8_t*)aTxBuffer, 2); + + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_VBP_SET_12h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x08; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_VFP_SET_13h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x08; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DISPLAY_CON_15h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x01; //SS=0 + //aTxBuffer[1] = 0x11; //SS=1 + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_COLOR_DEPTH_SET_16h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_PENTILE_KEY_EFh; // write-only register... + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xD0; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xE8; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_PENTILE1_A0h; // write-only register... + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x63; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_PENTILE2_A1h; // write-only register... + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xC0; // SID1&SID0=00 +// aTxBuffer[1] = 0xC4; // SID1&SID0=01 CC C8 C4 C0 + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_PENTILE3_A2h; // write-only register... + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x32; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_PENTILE4_A3h; // write-only register... + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x02; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_BRIGHTNESS_CTRL_39h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x44;//44 + send((uint8_t*)aTxBuffer, 2); + + // GAMMA L=250 + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x40; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x41; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x42; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2A; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x27; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x27; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x45; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x46; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x50; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x51; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x52; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x17; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x53; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x54; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x26; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x55; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x56; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x60; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x61; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x62; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2A; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x63; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x25; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x64; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x65; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x66; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x5C; + send((uint8_t*)aTxBuffer, 2); + + /* + // GAMMA L=150 + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x40; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x41; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x42; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2D; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x29; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x28; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x45; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x23; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x46; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x37; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x50; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x51; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x52; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x0B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x53; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x25; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x54; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x28; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x55; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x22; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x56; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x36; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x60; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x61; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x62; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x63; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x28; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x64; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x26; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x65; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x66; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x4A; + send((uint8_t*)aTxBuffer, 2); + */ + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_BOOSTING_FREQ; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x22; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_AMP_SET_18h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x22; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_GAMMA_AMP_19h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x02; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + /* + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x4B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x05; + send((uint8_t*)aTxBuffer, 2); + */ + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA2; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_SET; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_SET2; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x77; + send((uint8_t*)aTxBuffer, 2); + + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA0; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_STB_BY_OFF; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA0; + send((uint8_t*)aTxBuffer, 2); + + HAL_Delay(250); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DDISP_ON; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x03; + send((uint8_t*)aTxBuffer, 2); + +} + static void Display_Error_Handler(void) { - while(1) + //while(1) { } }