From c5c1171112b17b94b7555326109c203723af6517 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Fri, 11 Aug 2017 16:31:04 +1000 Subject: [PATCH] Fix font erroring char. Add accel lockout for autostart. Helps for the following issues: #51 #38 --- workspace/ts100/inc/Font.h | 1 - workspace/ts100/inc/Interrupt.h | 2 ++ workspace/ts100/src/Interrupt.c | 6 ++++-- workspace/ts100/src/Main.c | 11 ++++++++++- workspace/ts100/src/Modes.c | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/workspace/ts100/inc/Font.h b/workspace/ts100/inc/Font.h index cb08ef60..269988f0 100644 --- a/workspace/ts100/inc/Font.h +++ b/workspace/ts100/inc/Font.h @@ -175,7 +175,6 @@ const uint8_t FONT[]={ 0x00,0xE0,0xF0,0x3B,0x1B,0x18,0x18,0x1B,0x3B,0xF0,0xE0,0x00,0x00,0x0F,0x1F,0x38,0x30,0x30,0x30,0x30,0x38,0x1F,0x0F,0x00,//D6//214 0x00,0x00,0x10,0x30,0x60,0xC0,0xC0,0x60,0x30,0x10,0x00,0x00,0x00,0x00,0x04,0x06,0x03,0x01,0x01,0x03,0x06,0x04,0x00,0x00,//D7//215 0x00,0xF0,0xF8,0x1C,0x0C,0x8C,0xEC,0x7C,0x18,0xFC,0xF4,0x00,0x00,0x2F,0x3F,0x18,0x3E,0x37,0x31,0x30,0x38,0x1F,0x0F,0x00,//D8//216 - 0x00,0xF8,0xF8,0x04,0x06,0x03,0x03,0x06,0x04,0xF8,0xF8,0x00,0x00,0x07,0x1F,0x38,0x30,0x30,0x30,0x30,0x38,0x1F,0x07,0x00,//D8//216 0x00,0xF8,0xF8,0x01,0x03,0x06,0x04,0x00,0x00,0xF8,0xF8,0x00,0x00,0x07,0x1F,0x38,0x30,0x30,0x30,0x30,0x38,0x1F,0x07,0x00,//D9//217 0x00,0xF8,0xF8,0x00,0x00,0x04,0x06,0x03,0x01,0xF8,0xF8,0x00,0x00,0x07,0x1F,0x38,0x30,0x30,0x30,0x30,0x38,0x1F,0x07,0x00,//DA//218 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//DB (blank) diff --git a/workspace/ts100/inc/Interrupt.h b/workspace/ts100/inc/Interrupt.h index 409799df..a6f94836 100644 --- a/workspace/ts100/inc/Interrupt.h +++ b/workspace/ts100/inc/Interrupt.h @@ -10,6 +10,8 @@ extern volatile uint32_t system_Ticks; void delayMs(uint32_t ticks); extern volatile uint32_t lastMovement; +extern volatile uint8_t InterruptMask;//Used to mask interrupts + extern volatile uint8_t rawKeys; inline uint32_t millis() { return system_Ticks; diff --git a/workspace/ts100/src/Interrupt.c b/workspace/ts100/src/Interrupt.c index 145777c9..194951b2 100644 --- a/workspace/ts100/src/Interrupt.c +++ b/workspace/ts100/src/Interrupt.c @@ -9,6 +9,7 @@ volatile uint8_t rawKeys; volatile uint8_t LongKeys; volatile uint32_t lastMovement; //millis() at last movement event volatile uint8_t RotationChangedFlag; +volatile uint8_t InterruptMask; //Delay in milliseconds using systemTick void delayMs(uint32_t ticks) { @@ -35,7 +36,7 @@ uint8_t getButtons() { out = (BUT_A | BUT_B); AkeyChange = millis(); BkeyChange = millis(); - rawKeys=0; + rawKeys = 0; } LongKeys = 0; } else { @@ -172,7 +173,8 @@ void EXTI9_5_IRQHandler(void) { BkeyChange = millis(); EXTI_ClearITPendingBit(EXTI_Line6); } else if (EXTI_GetITStatus(EXTI_Line5) != RESET) { //Movement Event - lastMovement = millis(); + if (!InterruptMask) + lastMovement = millis(); EXTI_ClearITPendingBit(EXTI_Line5); } diff --git a/workspace/ts100/src/Main.c b/workspace/ts100/src/Main.c index 712e8266..004308c4 100644 --- a/workspace/ts100/src/Main.c +++ b/workspace/ts100/src/Main.c @@ -18,6 +18,10 @@ int main(void) { operatingMode = SOLDERING; else if (systemSettings.autoStart == 2) operatingMode = SLEEP; + if (systemSettings.autoStart) { + InterruptMask = 1; //set the mask + lastMovement = 0; + } while (1) { Clear_Watchdog(); //reset the Watch dog timer ProcessUI(); @@ -36,12 +40,17 @@ int main(void) { //^ This is a workaround for the IRQ being set off before we have the handler setup and enabled. } } - if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_5) == Bit_RESET) { + if ((GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_5) == Bit_RESET)&&!InterruptMask) { lastMovement = millis(); //This is a workaround for the line staying low as the user is still moving. (ie sensitivity is too high for their amount of movement) } delayMs(15); //Slow the system down waiting for the iron. + if (systemSettings.autoStart && (millis() > 10000) && InterruptMask) { + //If the user has setup the device to auto enter a startup mode, we normally have the interrupts on motion masked for the inital 10 seconds to prevent waking up during initalization + //This allows us to re-enable these interrupts. + InterruptMask = 0; + } } } void setup() { diff --git a/workspace/ts100/src/Modes.c b/workspace/ts100/src/Modes.c index 32ae3693..0a4f2773 100644 --- a/workspace/ts100/src/Modes.c +++ b/workspace/ts100/src/Modes.c @@ -269,14 +269,14 @@ void ProcessUI() { operatingMode = SOLDERING; Oled_DisplayOn(); return; - } else if (systemSettings.sensitivity) { + } else if (systemSettings.sensitivity&& !InterruptMask) { if (millis() - getLastMovement() < 1000) {//moved in the last second operatingMode = SOLDERING; //Goto active mode again Oled_DisplayOn(); return; } } - if (systemSettings.sensitivity) { + if (systemSettings.sensitivity ) { //Check if we should shutdown if ((millis() - getLastMovement() > (systemSettings.ShutdownTime * 60000))