diff options
-rw-r--r-- | workspace/ts100/inc/Oled.h | 2 | ||||
-rw-r--r-- | workspace/ts100/src/Main.c | 8 | ||||
-rw-r--r-- | workspace/ts100/src/Oled.c | 24 |
3 files changed, 19 insertions, 15 deletions
diff --git a/workspace/ts100/inc/Oled.h b/workspace/ts100/inc/Oled.h index 9ca20a6e..172118a2 100644 --- a/workspace/ts100/inc/Oled.h +++ b/workspace/ts100/inc/Oled.h @@ -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 Oled_DisplayFlip();
void GPIO_Init_OLED(void);
-void Init_Oled(void);
+void Init_Oled(uint8_t leftHanded);
u8* Data_Command(u8 len, u8* ptr);
void Clear_Screen(void);//Clear the screen
/*Functions for writing to the screen*/
diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c index 377d921d..3f48bf62 100644 --- a/workspace/ts100/src/Main.c +++ b/workspace/ts100/src/Main.c @@ -30,13 +30,13 @@ void setup() { I2C_Configuration(); //Start the I2C hardware
GPIO_Init_OLED(); //Init the GPIO ports for the OLED
StartUp_Accelerometer(); //start the accelerometer
- Init_Oled(); //init the OLED display
+
setupPID(); //init the PID values
readIronTemp(239, 0); //load the default calibration value
restoreSettings(); //Load settings
- if (systemSettings.flipDisplay)
- Oled_DisplayFlip();
- OLED_DrawString("VER 1.02",8);
+ Init_Oled(systemSettings.flipDisplay);//init the OLED display
+
+ OLED_DrawString("VER 1.03",8);
delayMs(800);
Start_Watchdog(1000); //start the system watchdog as 1 seconds timeout
}
diff --git a/workspace/ts100/src/Oled.c b/workspace/ts100/src/Oled.c index 639d1ec2..faa3500d 100644 --- a/workspace/ts100/src/Oled.c +++ b/workspace/ts100/src/Oled.c @@ -19,9 +19,9 @@ int8_t displayOffset = 32; /*All commands are prefixed with 0x80*/
u8 OLED_Setup_Array[46] = { 0x80, 0xAE,/*Display off*/
0x80, 0xD5,/*Set display clock divide ratio / osc freq*/
-0x80, 0b01010001,/**/
+0x80, 0x52,/**/
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, 0xD3,/*Set Display offset*/
0x80, 0x00,/*0 Offset*/
@@ -69,7 +69,7 @@ void Oled_DisplayFlip() { I2C_PageWrite(data, 2, DEVICEADDR_OLED);
data[1] = 0xA1;
I2C_PageWrite(data, 2, DEVICEADDR_OLED);
- displayOffset=0;
+ displayOffset = 0;
}
/*
@@ -79,10 +79,10 @@ void Oled_DisplayFlip() { */
u8* Data_Command(u8 length, u8* data) {
int i;
- u8 tx_data[128];
+ u8 tx_data[129];
//here are are inserting the data write command at the beginning
tx_data[0] = 0x40;
- length += 1;
+ length++;
for (i = 1; i < length; i++) //Loop through the array of data
tx_data[i] = *data++;
I2C_PageWrite(tx_data, length, DEVICEADDR_OLED); //write out the buffer
@@ -144,14 +144,19 @@ void GPIO_Init_OLED(void) { Function: Init_Oled
Description: Initalizes the Oled screen
*******************************************************************************/
-void Init_Oled(void) {
+void Init_Oled(uint8_t leftHanded) {
u8 param_len;
OLED_RST();
- delayMs(2);
+ delayMs(5);
OLED_ACT(); //Toggling reset to reset the oled
- delayMs(2);
+ delayMs(5);
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);
}
@@ -196,8 +201,7 @@ void OLED_DrawChar(char c, uint8_t x) { ptr += (37) * (FONT_WIDTH * 2);
} else if (c == '>') {
ptr += (38) * (FONT_WIDTH * 2);
- }else if (c=='.')
- {
+ } else if (c == '.') {
ptr += (39) * (FONT_WIDTH * 2);
}
|