Backend work for supporting adjusting movement sensitivity

This commit is contained in:
Ben V. Brown
2017-05-15 23:00:42 +10:00
parent fceb81287e
commit 9b51750a1d
7 changed files with 37 additions and 31 deletions

View File

@@ -53,7 +53,7 @@ void TIM3_IRQHandler(void) {
//used for buttons and movement
void EXTI9_5_IRQHandler(void) {
//we are interested in line 9 and line 6 for buttons
//Lien 5 == movement
//Line 5 == movement
if (EXTI_GetITStatus(EXTI_Line9) != RESET) {
if (GPIO_ReadInputDataBit(GPIOA, KEY_A) == SET)
keyState &= ~(BUT_A);

View File

@@ -29,12 +29,12 @@ uint8_t I2C_RegisterRead(uint8_t reg) {
return tx_data[0];
}
void StartUp_Accelerometer(void) {
void StartUp_Accelerometer(uint8_t sensitivity) {
I2C_RegisterWrite(CTRL_REG2, 0); //Normal mode
I2C_RegisterWrite( CTRL_REG2, 0x40); // Reset all registers to POR values
delayMs(2); // ~1ms delay
I2C_RegisterWrite(FF_MT_CFG_REG, 0x78); // Enable motion detection for X and Y axis, latch enabled
I2C_RegisterWrite(FF_MT_THS_REG, 0x0F); // Set threshold
I2C_RegisterWrite(FF_MT_THS_REG, sensitivity); // Set threshold
I2C_RegisterWrite(FF_MT_COUNT_REG, 0x01); // Set debounce to 100ms
I2C_RegisterWrite( CTRL_REG4, 0x04); // Enable motion interrupt

View File

@@ -14,29 +14,30 @@ void setup();
int main(void) {
setup();/*Setup the system*/
while (1) {
Clear_Watchdog(); //reset the Watchdog timer
Clear_Watchdog(); //reset the Watch dog timer
ProcessUI();
DrawUI();
delayMs(50); //Slow the system down a little bit
}
}
void setup() {
RCC_Config(); //setup system clock
NVIC_Config(0x4000); //this shifts the NVIC table to be offset, for the usb bootloader's size
GPIO_Config(); //setup all the GPIO pins
Init_EXTI(); //init the EXTI inputs
Init_Timer3(); //Used for the soldering iron tip
Adc_Init(); //init adc and dma
I2C_Configuration(); //Start the I2C hardware
GPIO_Init_OLED(); //Init the GPIO ports for the OLED
StartUp_Accelerometer(); //start the accelerometer
RCC_Config(); //setup system clock
NVIC_Config(0x4000); //this shifts the NVIC table to be offset, for the usb bootloader's size
GPIO_Config(); //setup all the GPIO pins
Init_EXTI(); //init the EXTI inputs
Init_Timer3(); //Used for the soldering iron tip
Adc_Init(); //init adc and dma
I2C_Configuration(); //Start the I2C hardware
GPIO_Init_OLED(); //Init the GPIO ports for the OLED
restoreSettings(); //Load settings
setupPID(); //init the PID values
readIronTemp(239, 0); //load the default calibration value
restoreSettings(); //Load settings
Init_Oled(systemSettings.flipDisplay);//init the OLED display
StartUp_Accelerometer(systemSettings.sensitivity); //start the accelerometer
OLED_DrawString("VER 1.03",8);
delayMs(800);
Start_Watchdog(1000); //start the system watchdog as 1 seconds timeout
setupPID(); //init the PID values
readIronTemp(239, 0); //load the default calibration value
Init_Oled(systemSettings.flipDisplay); //init the OLED display
OLED_DrawString("VER 1.03", 8); //1.settings version as of current
delayMs(800); //Pause to show version number
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
}

View File

@@ -142,7 +142,7 @@ void GPIO_Init_OLED(void) {
}
/*******************************************************************************
Function: Init_Oled
Description: Initalizes the Oled screen
Description: Initializes the Oled screen
*******************************************************************************/
void Init_Oled(uint8_t leftHanded) {
u8 param_len;

View File

@@ -49,5 +49,8 @@ void resetSettings() {
systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades
systemSettings.displayTempInF =0; //default to C
systemSettings.flipDisplay=0; //Default to right handed mode
systemSettings.sensitivity=0x0F; //Default high sensitivity
systemSettings.tempCalibration=239; //Default to their calibration value
}