diff options
author | Ben V. Brown <[email protected]> | 2017-05-17 22:53:16 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2017-05-17 22:53:21 +1000 |
commit | 53a1b9b7f419d4bb9b4c4e104201b0979a9492c1 (patch) | |
tree | 69f638e9c0dbd6bfcfeb4eebb331a68c29a5f764 /workspace | |
parent | c9d0d5bdb33262a096b68c093ebd8c3ab5eb09a8 (diff) | |
download | IronOS-53a1b9b7f419d4bb9b4c4e104201b0979a9492c1.tar.gz IronOS-53a1b9b7f419d4bb9b4c4e104201b0979a9492c1.zip |
Add sensitivity selection menu
Diffstat (limited to 'workspace')
-rw-r--r-- | workspace/ts100/inc/Modes.h | 10 | ||||
-rw-r--r-- | workspace/ts100/inc/Settings.h | 7 | ||||
-rw-r--r-- | workspace/ts100/src/MMA8652FC.c | 4 | ||||
-rw-r--r-- | workspace/ts100/src/Modes.c | 68 | ||||
-rw-r--r-- | workspace/ts100/src/Settings.c | 2 |
5 files changed, 80 insertions, 11 deletions
diff --git a/workspace/ts100/inc/Modes.h b/workspace/ts100/inc/Modes.h index 9c44d5df..bcfb4624 100644 --- a/workspace/ts100/inc/Modes.h +++ b/workspace/ts100/inc/Modes.h @@ -25,11 +25,17 @@ enum { COOLING, UVLOWARN, THERMOMETER, + DCINDISP, } operatingMode; enum { - UVCO = 0, SLEEP_TEMP, SLEEP_TIME, MOTIONDETECT, TEMPDISPLAY, LEFTY - + UVCO = 0, + SLEEP_TEMP, + SLEEP_TIME, + MOTIONDETECT, + MOTIONSENSITIVITY, + TEMPDISPLAY, + LEFTY, } settingsPage; void ProcessUI(); diff --git a/workspace/ts100/inc/Settings.h b/workspace/ts100/inc/Settings.h index 25db9f15..7c058223 100644 --- a/workspace/ts100/inc/Settings.h +++ b/workspace/ts100/inc/Settings.h @@ -12,7 +12,10 @@ #include <stdint.h> #include "stm32f10x_flash.h" #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*/ +#define SETTINGSOPTIONSCOUNT 6 /*Number of settings in the settings menu*/ +#define MOTION_HIGH (0x00) +#define MOTION_MED (0x10) +#define MOTION_LOW (0x20) /* * This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks */ @@ -26,7 +29,7 @@ struct { 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 + uint16_t tempCalibration; //Temperature calibration value } systemSettings; void saveSettings(); diff --git a/workspace/ts100/src/MMA8652FC.c b/workspace/ts100/src/MMA8652FC.c index 2fdd95a6..e6df4ab0 100644 --- a/workspace/ts100/src/MMA8652FC.c +++ b/workspace/ts100/src/MMA8652FC.c @@ -34,10 +34,10 @@ void StartUp_Accelerometer(uint8_t sensitivity) { 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, sensitivity); // Set threshold
+ I2C_RegisterWrite(FF_MT_THS_REG, sensitivity|0x0F); // Set threshold
I2C_RegisterWrite(FF_MT_COUNT_REG, 0x01); // Set debounce to 100ms
I2C_RegisterWrite( CTRL_REG4, 0x04); // Enable motion interrupt
- I2C_RegisterWrite( CTRL_REG5, 0x04);// Route motion interrupts to INT1 ->PB5 ->EXTI
+ I2C_RegisterWrite( CTRL_REG5, 0x04);// Route motion interrupts to INT1 ->PB5 ->EXTI5
I2C_RegisterWrite( CTRL_REG1, 0x19); // ODR=100 Hz, Active mode
}
diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index 8fab17e4..163292f4 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -138,6 +138,12 @@ void ProcessUI() { case LEFTY: systemSettings.flipDisplay = !systemSettings.flipDisplay; break; + case MOTIONSENSITIVITY: + systemSettings.sensitivity += 0x10; + if(systemSettings.sensitivity>0x20) + systemSettings.sensitivity=0;//reset to high on wrap + + break; default: break; } @@ -193,13 +199,36 @@ void ProcessUI() { break; case THERMOMETER: { //This lets the user check the tip temp without heating the iron.. And eventually calibration will be added here - if ((millis() - getLastButtonPress() > 1000)) - if (Buttons == (BUT_A | BUT_B)) { - //If the user is holding both button, exit the temp screen + if ((millis() - getLastButtonPress() > 1000)) { + if ((Buttons == BUT_A) | (Buttons == BUT_B)) { + //Single button press, cycle over to the DC display + operatingMode = DCINDISP; + resetLastButtonPress(); + resetButtons(); + } else if (Buttons == (BUT_A | BUT_B)) { + //If the user is holding both button, exit the screen + operatingMode = STARTUP; + resetLastButtonPress(); + resetButtons(); + } + } + } + break; + case DCINDISP: { + //This lets the user check the input voltage + if ((millis() - getLastButtonPress() > 1000)) { + if ((Buttons == BUT_A) | (Buttons == BUT_B)) { + //Single button press, cycle over to the temp display + operatingMode = THERMOMETER; + resetLastButtonPress(); + resetButtons(); + } else if (Buttons == (BUT_A | BUT_B)) { + //If the user is holding both button, exit the screen operatingMode = STARTUP; resetLastButtonPress(); resetButtons(); } + } } break; default: @@ -302,6 +331,23 @@ void DrawUI() { else OLED_DrawString("FLPDSP F", 8); break; + case MOTIONSENSITIVITY: + switch (systemSettings.sensitivity) { + case MOTION_HIGH: + OLED_DrawString("SENSE H ", 8); + break; + case MOTION_MED: + OLED_DrawString("SENSE M ", 8); + break; + case MOTION_LOW: + OLED_DrawString("SENSE L ", 8); + break; + default: + OLED_DrawString("SENSE ", 8); + break; + } + + break; default: break; } @@ -321,10 +367,24 @@ void DrawUI() { OLED_DrawString("LOW VOLT", 8); break; case THERMOMETER: - temp = readIronTemp(0, 1);//Force a reading as heater is off + temp = readIronTemp(0, 1); //Force a reading as heater is off OLED_DrawString("TEMP ", 5);//extra one to it clears the leftover 'L' from IDLE drawTemp(temp, 5); break; + case DCINDISP: { + uint16_t voltage = readDCVoltage(); //get X10 voltage + OLED_DrawString("IN", 2); + OLED_DrawChar((voltage / 100) % 10, 2); + voltage -= (voltage / 100) * 100; + OLED_DrawChar((voltage / 10) % 10, 3); + voltage -= (voltage / 10) * 10; + OLED_DrawChar('.', 4); + OLED_DrawChar(voltage % 10, 5); + OLED_DrawChar('V', 6); + OLED_DrawChar(' ', 7); + + } + break; default: break; } diff --git a/workspace/ts100/src/Settings.c b/workspace/ts100/src/Settings.c index 49912c32..0a88a3c6 100644 --- a/workspace/ts100/src/Settings.c +++ b/workspace/ts100/src/Settings.c @@ -49,7 +49,7 @@ 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.sensitivity=0x00; //Default high sensitivity systemSettings.tempCalibration=239; //Default to their calibration value } |