diff options
author | Ben V. Brown <[email protected]> | 2017-05-15 23:00:42 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2017-05-15 23:00:42 +1000 |
commit | 9b51750a1d5a88a8bd92dcb7e98e514a32296bc4 (patch) | |
tree | f96c021ff3b02d80d35ec201e3999d357c19ff89 | |
parent | fceb81287e5452aebce9008f11e87eae58c08306 (diff) | |
download | IronOS-9b51750a1d5a88a8bd92dcb7e98e514a32296bc4.tar.gz IronOS-9b51750a1d5a88a8bd92dcb7e98e514a32296bc4.zip |
Backend work for supporting adjusting movement sensitivity
-rw-r--r-- | workspace/ts100/inc/MMA8652FC.h | 2 | ||||
-rw-r--r-- | workspace/ts100/inc/Settings.h | 20 | ||||
-rw-r--r-- | workspace/ts100/src/Interrupt.c | 2 | ||||
-rw-r--r-- | workspace/ts100/src/MMA8652FC.c | 4 | ||||
-rw-r--r-- | workspace/ts100/src/Main.c | 35 | ||||
-rw-r--r-- | workspace/ts100/src/Oled.c | 2 | ||||
-rw-r--r-- | workspace/ts100/src/Settings.c | 3 |
7 files changed, 37 insertions, 31 deletions
diff --git a/workspace/ts100/inc/MMA8652FC.h b/workspace/ts100/inc/MMA8652FC.h index d5113287..d7107e5b 100644 --- a/workspace/ts100/inc/MMA8652FC.h +++ b/workspace/ts100/inc/MMA8652FC.h @@ -15,7 +15,7 @@ #define __MMA8652FC__H
-void StartUp_Accelerometer(void);//This is the only function we expose
+void StartUp_Accelerometer(uint8_t sensitivity);//This is the only function we expose
//--------------MMA8652 Device ID----------------------------------------------//
diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h index 9a88f4fb..ec162cf6 100644 --- a/workspace/ts100/inc/Settings.h +++ b/workspace/ts100/inc/Settings.h @@ -11,20 +11,22 @@ #define SETTINGS_H_ #include <stdint.h> #include "stm32f10x_flash.h" -#define SETTINGSVERSION 0x02 /*Change this if you change the struct below to prevent people getting out of sync*/ +#define SETTINGSVERSION 0x03 /*Change this if you change the struct below to prevent people getting out of sync*/ #define SETTINGSOPTIONSCOUNT 5 /*Number of settings in the settings menu*/ /* * This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks */ struct { - uint32_t SolderingTemp; //current setpoint for the iron - 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 cutoutVoltage; //The voltage we cutout at for undervoltage - uint8_t movementEnabled; //If movement is enabled - uint8_t displayTempInF; //If we need to convert the C reading to F - uint8_t flipDisplay; //If true we want to invert the display for lefties + uint32_t SolderingTemp; //current setpoint for the iron + 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 cutoutVoltage:1; //The voltage we cutout at for undervoltage + uint8_t movementEnabled:1; //If movement is enabled + 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 sensitivity:7; //Sensitivity of accelerometer + uint16_t tempCalibration; // Temperature calibration value } systemSettings; void saveSettings(); diff --git a/workspace/ts100/src/Interrupt.c b/workspace/ts100/src/Interrupt.c index 43dbb4a3..0b58800a 100644 --- a/workspace/ts100/src/Interrupt.c +++ b/workspace/ts100/src/Interrupt.c @@ -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);
diff --git a/workspace/ts100/src/MMA8652FC.c b/workspace/ts100/src/MMA8652FC.c index 8d473261..2fdd95a6 100644 --- a/workspace/ts100/src/MMA8652FC.c +++ b/workspace/ts100/src/MMA8652FC.c @@ -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
diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c index 3f48bf62..d32ed3b3 100644 --- a/workspace/ts100/src/Main.c +++ b/workspace/ts100/src/Main.c @@ -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
}
diff --git a/workspace/ts100/src/Oled.c b/workspace/ts100/src/Oled.c index faa3500d..ba7c6023 100644 --- a/workspace/ts100/src/Oled.c +++ b/workspace/ts100/src/Oled.c @@ -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;
diff --git a/workspace/ts100/src/Settings.c b/workspace/ts100/src/Settings.c index cfa60a76..49912c32 100644 --- a/workspace/ts100/src/Settings.c +++ b/workspace/ts100/src/Settings.c @@ -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 + } |