Adding auto-rotation to the screen

Adds auto rotation support using the proper orientation detection. (Not
using raw values).
Should Fix and close #29
This commit is contained in:
Ben V. Brown
2017-07-27 11:46:04 +10:00
parent af9b8dca29
commit 1cbcba924f
11 changed files with 309 additions and 129 deletions

View File

@@ -11,6 +11,7 @@
void I2C_Configuration(void);
void I2C_PageWrite(u8* pbuf, u8 numbyte, u8 deviceaddr);
void I2C_PageRead(u8* pbuf, u8 numbyte, u8 deviceaddr, u8 readaddr);
int I2C_Master_Read(uint8_t deviceAddr, uint8_t readAddr, uint8_t* pBuffer,
uint16_t numByteToRead);
#endif
/******************************** END OF FILE *********************************/

View File

@@ -14,9 +14,8 @@
#ifndef __MMA8652FC__H
#define __MMA8652FC__H
void StartUp_Accelerometer(uint8_t sensitivity);//This is the only function we expose
void StartUp_Accelerometer(uint8_t sensitivity); //This is the only function we expose
uint8_t getOrientation();
//--------------MMA8652 Device ID----------------------------------------------//
#define DEVICE_ADDR 0X1D
@@ -99,8 +98,6 @@ void StartUp_Accelerometer(uint8_t sensitivity);//This is the only function we e
#define INT_SOURCE 0X0C
#define DEVICE_ID 0X0D
//-----STATUS_REG(0X00)-----Bit Define----------------------------------------//
#define ZYXDR_BIT 0X08
//----XYZ_DATA_CFG_REG(0xE)-Bit Define----------------------------------------//
@@ -123,7 +120,7 @@ void StartUp_Accelerometer(uint8_t sensitivity);//This is the only function we e
//---------CTRL_REG2(0X2B)Bit Define------------------------------------------//
#define MODS_MASK 0x03 //Oversampling Mode 4
#define Normal_Mode 0x0 //Normal=0,Low Noise Low Power MODS=1,
//HI RESOLUTION=2,LOW POWER MODS = 11
//HI RESOLUTION=2,LOW POWER MODS = 11
//----CTRL_REG4---Interrupt Enable BIT ---------------------------------------//
//0 interrupt is disabled (default)
//1 interrupt is enabled

View File

@@ -16,6 +16,7 @@
#include "PID.h"
#include "Settings.h"
#include "Analog.h"
#include "MMA8652FC.h"
#include <string.h>
typedef enum {
STARTUP, //we are sitting on the prompt to push a button
@@ -41,7 +42,7 @@ typedef enum {
TEMPDISPLAY,
TEMPROUNDING,
DISPUPDATERATE,
LEFTY,
SCREENROTATION,
BOOSTMODE,
BOOSTTEMP,
POWERDISPLAY,

View File

@@ -32,5 +32,6 @@ void OLED_DrawThreeNumber(uint16_t in, uint8_t x);
void OLED_DrawIDLELogo();
void OLED_DrawSymbol(uint8_t x, uint8_t symbol);
const u8* Oled_DrawArea(u8 x0, u8 y0, u8 wide, u8 high, const u8* ptr);
void OLED_SetOrientation(uint8_t ori);
uint8_t OLED_GetOrientation();
#endif
/******************************** END OF FILE *********************************/

View File

@@ -12,7 +12,7 @@
#include <stdint.h>
#include "stm32f10x_flash.h"
#include "Oled.h"
#define SETTINGSVERSION 13 /*Change this if you change the struct below to prevent people getting out of sync*/
#define SETTINGSVERSION 14 /*Change this if you change the struct below to prevent people getting out of sync*/
//Display Speeds
#define DISPLAYMODE_FAST (0x00)
#define DISPLAYMODE_MEDIUM (0x01)
@@ -30,10 +30,10 @@ typedef struct {
uint32_t SleepTemp; //temp to drop to in sleep
uint8_t version; //Used to track if a reset is needed on firmware upgrade
uint8_t SleepTime; //minutes timeout to sleep
uint8_t cutoutSetting:4; //(3 bits) The voltage we cut out at for under voltage
uint8_t cutoutSetting:3; //(3 bits) The voltage we cut out at for under voltage
uint8_t powerDisplay:1; //Toggle to swap the arrows with a power readout instead
uint8_t displayTempInF:1; //If we need to convert the C reading to F
uint8_t flipDisplay:1; //If true we want to invert the display for lefties
uint8_t OrientationMode:2; //If true we want to invert the display for lefties
uint8_t sensitivity:6; //Sensitivity of accelerometer (5 bits)
uint8_t ShutdownTime:6; //Time until unit shuts down if left alone
uint8_t displayUpdateSpeed:2; //How fast the display updates / temp showing mode