1
0
forked from me/IronOS

Patch to fix left handed screen

This commit is contained in:
Ben V. Brown
2017-01-23 20:52:46 +11:00
parent c3d8d246dc
commit fceb81287e
3 changed files with 19 additions and 15 deletions

View File

@@ -18,7 +18,7 @@ u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, u8* ptr);
void Set_ShowPos(u8 x, u8 y); void Set_ShowPos(u8 x, u8 y);
void Oled_DisplayFlip(); void Oled_DisplayFlip();
void GPIO_Init_OLED(void); void GPIO_Init_OLED(void);
void Init_Oled(void); void Init_Oled(uint8_t leftHanded);
u8* Data_Command(u8 len, u8* ptr); u8* Data_Command(u8 len, u8* ptr);
void Clear_Screen(void);//Clear the screen void Clear_Screen(void);//Clear the screen
/*Functions for writing to the screen*/ /*Functions for writing to the screen*/

View File

@@ -30,13 +30,13 @@ void setup() {
I2C_Configuration(); //Start the I2C hardware I2C_Configuration(); //Start the I2C hardware
GPIO_Init_OLED(); //Init the GPIO ports for the OLED GPIO_Init_OLED(); //Init the GPIO ports for the OLED
StartUp_Accelerometer(); //start the accelerometer StartUp_Accelerometer(); //start the accelerometer
Init_Oled(); //init the OLED display
setupPID(); //init the PID values setupPID(); //init the PID values
readIronTemp(239, 0); //load the default calibration value readIronTemp(239, 0); //load the default calibration value
restoreSettings(); //Load settings restoreSettings(); //Load settings
if (systemSettings.flipDisplay) Init_Oled(systemSettings.flipDisplay);//init the OLED display
Oled_DisplayFlip();
OLED_DrawString("VER 1.02",8); OLED_DrawString("VER 1.03",8);
delayMs(800); delayMs(800);
Start_Watchdog(1000); //start the system watchdog as 1 seconds timeout Start_Watchdog(1000); //start the system watchdog as 1 seconds timeout
} }

View File

@@ -19,9 +19,9 @@ int8_t displayOffset = 32;
/*All commands are prefixed with 0x80*/ /*All commands are prefixed with 0x80*/
u8 OLED_Setup_Array[46] = { 0x80, 0xAE,/*Display off*/ u8 OLED_Setup_Array[46] = { 0x80, 0xAE,/*Display off*/
0x80, 0xD5,/*Set display clock divide ratio / osc freq*/ 0x80, 0xD5,/*Set display clock divide ratio / osc freq*/
0x80, 0b01010001,/**/ 0x80, 0x52,/**/
0x80, 0xA8,/*Set Multiplex Ratio*/ 0x80, 0xA8,/*Set Multiplex Ratio*/
0x80, 16, /*16 == max brightness,39==dimmest*/ 0x80, 0x0F, /*16 == max brightness,39==dimmest*/
0x80, 0xC0,/*Set COM Scan direction*/ 0x80, 0xC0,/*Set COM Scan direction*/
0x80, 0xD3,/*Set Display offset*/ 0x80, 0xD3,/*Set Display offset*/
0x80, 0x00,/*0 Offset*/ 0x80, 0x00,/*0 Offset*/
@@ -69,7 +69,7 @@ void Oled_DisplayFlip() {
I2C_PageWrite(data, 2, DEVICEADDR_OLED); I2C_PageWrite(data, 2, DEVICEADDR_OLED);
data[1] = 0xA1; data[1] = 0xA1;
I2C_PageWrite(data, 2, DEVICEADDR_OLED); I2C_PageWrite(data, 2, DEVICEADDR_OLED);
displayOffset=0; displayOffset = 0;
} }
/* /*
@@ -79,10 +79,10 @@ void Oled_DisplayFlip() {
*/ */
u8* Data_Command(u8 length, u8* data) { u8* Data_Command(u8 length, u8* data) {
int i; int i;
u8 tx_data[128]; u8 tx_data[129];
//here are are inserting the data write command at the beginning //here are are inserting the data write command at the beginning
tx_data[0] = 0x40; tx_data[0] = 0x40;
length += 1; length++;
for (i = 1; i < length; i++) //Loop through the array of data for (i = 1; i < length; i++) //Loop through the array of data
tx_data[i] = *data++; tx_data[i] = *data++;
I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer
@@ -144,14 +144,19 @@ void GPIO_Init_OLED(void) {
Function: Init_Oled Function: Init_Oled
Description: Initalizes the Oled screen Description: Initalizes the Oled screen
*******************************************************************************/ *******************************************************************************/
void Init_Oled(void) { void Init_Oled(uint8_t leftHanded) {
u8 param_len; u8 param_len;
OLED_RST(); OLED_RST();
delayMs(2); delayMs(5);
OLED_ACT(); //Toggling reset to reset the oled OLED_ACT(); //Toggling reset to reset the oled
delayMs(2); delayMs(5);
param_len = 46; param_len = 46;
if (leftHanded) {
OLED_Setup_Array[11] = 0xC8;
OLED_Setup_Array[19] = 0xA1;
displayOffset = 0;
}
I2C_PageWrite((u8 *) OLED_Setup_Array, param_len, DEVICEADDR_OLED); I2C_PageWrite((u8 *) OLED_Setup_Array, param_len, DEVICEADDR_OLED);
} }
@@ -196,8 +201,7 @@ void OLED_DrawChar(char c, uint8_t x) {
ptr += (37) * (FONT_WIDTH * 2); ptr += (37) * (FONT_WIDTH * 2);
} else if (c == '>') { } else if (c == '>') {
ptr += (38) * (FONT_WIDTH * 2); ptr += (38) * (FONT_WIDTH * 2);
}else if (c=='.') } else if (c == '.') {
{
ptr += (39) * (FONT_WIDTH * 2); ptr += (39) * (FONT_WIDTH * 2);
} }