Skip to content

Commit

Permalink
V1.12 - decreased step size for sensitivity
Browse files Browse the repository at this point in the history
Collapsed motion being enabled into the motion sensitivity menu. Fixing
#20
More options for the sensitivity as well.
  • Loading branch information
Ralim committed Jul 11, 2017
1 parent 52e3247 commit b793b61
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 36 deletions.
1 change: 0 additions & 1 deletion workspace/ts100/inc/Modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ enum {
SLEEP_TEMP,
SLEEP_TIME,
SHUTDOWN_TIME,
MOTIONDETECT,
MOTIONSENSITIVITY,
TEMPDISPLAY,
TEMPROUNDING,
Expand Down
9 changes: 2 additions & 7 deletions workspace/ts100/inc/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
#define SETTINGS_H_
#include <stdint.h>
#include "stm32f10x_flash.h"
#define SETTINGSVERSION 11 /*Change this if you change the struct below to prevent people getting out of sync*/
//Motion Sensitivity
#define MOTION_HIGH (0x00)
#define MOTION_MED (0x01)
#define MOTION_LOW (0x02)
#define SETTINGSVERSION 12 /*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)
Expand All @@ -34,10 +30,9 @@ struct {
uint8_t version; //Used to track if a reset is needed on firmware upgrade
uint8_t SleepTime; //minutes timeout to sleep
uint8_t cutoutVoltage:5; //The voltage we cut out at for under voltage
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:5; //Sensitivity of accelerometer (4 bits)
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
uint8_t temperatureRounding:2; //Rounding mode for the temperature
Expand Down
5 changes: 3 additions & 2 deletions workspace/ts100/src/MMA8652FC.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ 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
uint8_t sens = 0x3F;
sens -= 0x08 * sensitivity;
uint8_t sens = 9*7+1;
sens -= 7 * sensitivity;

I2C_RegisterWrite(FF_MT_THS_REG, sens); // Set threshold
I2C_RegisterWrite(FF_MT_COUNT_REG, 0x01); // Set debounce to 100ms

Expand Down
2 changes: 1 addition & 1 deletion workspace/ts100/src/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void setup() {
readIronTemp(systemSettings.tempCalibration, 0,0); //load the default calibration value
Init_Oled(systemSettings.flipDisplay); //Init the OLED display

OLED_DrawString("VER 1.11", 8); //Version Number
OLED_DrawString("VER 1.12", 8); //Version Number
delayMs(500); //Pause to show version number
Start_Watchdog(1000); //start the system watch dog as 1 second timeout
}
37 changes: 13 additions & 24 deletions workspace/ts100/src/Modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
#include "Modes.h"
const char *SettingsLongNames[] = { " Undervoltage Cutout <V>",
" Sleep Temperature <C>", " Sleep Timeout <Minutes>",
" Shutdown Timeout <Minutes>", " Motion Detection",
" Motion Sensitivity <1.least sensitive 8.most sensitive>",
" Shutdown Timeout <Minutes>",
" Motion Sensitivity <0.Off 1.least sensitive 9.most sensitive>",
" Temperature Unit", " Temperature Rounding Amount",
" Temperature Display Update Rate",
" Flip Display for Left Hand",
" Enable front key boost 450C mode when soldering",
" Temperature when in boost mode" };
const uint8_t SettingsLongNamesLengths[] = { 29, 27, 29, 32, 22, 61, 22, 33, 37,
32, 53, 36 };
const uint8_t SettingsLongNamesLengths[] = { 29, 27, 29, 32, 67, 22, 33, 37, 32,
53, 36 };
uint8_t StatusFlags = 0;
uint32_t temporaryTempStorage = 0;
//This does the required processing and state changes
Expand Down Expand Up @@ -84,7 +84,7 @@ void ProcessUI() {
StatusFlags = 0;
}
//We need to check the timer for movement in case we need to goto idle
if (systemSettings.movementEnabled)
if (systemSettings.sensitivity)
if (millis() - getLastMovement()
> (systemSettings.SleepTime * 60000)) {
if (millis() - getLastButtonPress()
Expand Down Expand Up @@ -166,10 +166,6 @@ void ProcessUI() {
if (systemSettings.ShutdownTime > 60)
systemSettings.ShutdownTime = 0; //wrap to off
break;
case MOTIONDETECT:
systemSettings.movementEnabled =
!systemSettings.movementEnabled;
break;
case TEMPDISPLAY:
systemSettings.displayTempInF =
!systemSettings.displayTempInF;
Expand All @@ -179,7 +175,8 @@ void ProcessUI() {
break;
case MOTIONSENSITIVITY:
systemSettings.sensitivity++;
systemSettings.sensitivity = systemSettings.sensitivity % 8;
systemSettings.sensitivity = systemSettings.sensitivity
% 10;

break;
case TEMPROUNDING:
Expand Down Expand Up @@ -219,14 +216,14 @@ void ProcessUI() {
operatingMode = SOLDERING;
Oled_DisplayOn();
return;
} else if (systemSettings.movementEnabled) {
} else if (systemSettings.sensitivity) {
if (millis() - getLastMovement() < 1000) {//moved in the last second
operatingMode = SOLDERING; //Goto active mode again
Oled_DisplayOn();
return;
}
}
if (systemSettings.movementEnabled) {
if (systemSettings.sensitivity) {
//Check if we should shutdown
if ((millis() - getLastMovement()
> (systemSettings.ShutdownTime * 60000))
Expand All @@ -247,7 +244,7 @@ void ProcessUI() {
//Either button was pushed
operatingMode = STARTUP;
}
if (systemSettings.movementEnabled) {
if (systemSettings.sensitivity) {
if (millis() - getLastMovement()
> (systemSettings.ShutdownTime * 60000)) {
if ((millis() - getLastButtonPress()
Expand All @@ -257,8 +254,7 @@ void ProcessUI() {
} else {
Oled_DisplayOn();
}
}
else
} else
Oled_DisplayOn();
}
break;
Expand Down Expand Up @@ -495,19 +491,12 @@ void DrawUI() {
OLED_DrawString("SHTME ", 6);
OLED_DrawTwoNumber(systemSettings.ShutdownTime, 6);
break;
case MOTIONDETECT:/*Toggle the mode*/
if (systemSettings.movementEnabled)
OLED_DrawString("MOTION T", 8);
else
OLED_DrawString("MOTION F", 8);
break;
case TEMPDISPLAY:/*Are we showing in C or F ?*/
if (systemSettings.displayTempInF)
OLED_DrawString("TMPUNT F", 8);
else
OLED_DrawString("TMPUNT C", 8);
break;

case LEFTY:

if (systemSettings.flipDisplay)
Expand All @@ -517,7 +506,7 @@ void DrawUI() {
break;
case MOTIONSENSITIVITY:
OLED_DrawString("MSENSE ", 7);
OLED_DrawChar('1' + systemSettings.sensitivity, 7);
OLED_DrawChar('0' + systemSettings.sensitivity, 7);
break;
case TEMPROUNDING:
//We are prompting the user about their display mode preferences
Expand Down Expand Up @@ -593,7 +582,7 @@ void DrawUI() {
case COOLING:
//We are warning the user the tip is cooling
OLED_DrawString("COOL ", 5);
temp = readIronTemp(0, 1, 0xFFFF);//force temp re-reading
temp = readIronTemp(0, 1, 0xFFFF); //force temp re-reading
drawTemp(temp, 5, systemSettings.temperatureRounding);
break;
case UVLOWARN:
Expand Down
1 change: 0 additions & 1 deletion workspace/ts100/src/Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void resetSettings() {
systemSettings.SleepTemp = 1500; //Temperature the iron sleeps at - default 150.0 C
systemSettings.SleepTime = 1; //How many minutes we wait until going to sleep - default 1 min
systemSettings.SolderingTemp = 3200; //Default soldering temp is 320.0 C
systemSettings.movementEnabled = 1; //we use movement detection by default
systemSettings.cutoutVoltage = 10; //10V is the minium cutout voltage as the unit V measurement is unstable below 9.5V
systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades
systemSettings.displayTempInF =0; //default to C
Expand Down

0 comments on commit b793b61

Please sign in to comment.