diff --git a/workspace/TS100/src/Translation.c b/workspace/TS100/src/Translation.c index 033b047b..2b4b98e3 100644 --- a/workspace/TS100/src/Translation.c +++ b/workspace/TS100/src/Translation.c @@ -392,7 +392,41 @@ const char SettingRightChar = 'P'; const char SettingLeftChar = 'L'; const char SettingAutoChar = 'A'; #endif +#ifdef LANG_HUN +const char* SettingsLongNames[16] = { +/*These are all the help text for all the settings.*/ +/*No requirements on spacing or length*/ +"Áramforrás. Beállítja a lekapcsolási feszültséget. ", //Power Source + "Alvási hőmérséklet ", //Sleep Temp + "Elalvási időzítő ", //Sleep Timeout + "Kikapcsolási időzítő ", //Shutdown Time + "Mozgás érzékenység beállítása. <0.Ki 1.kevésbé érzékeny 9.legérzékenyebb>", //Motion Sensitivity + "Hőmérsékleti egység ", //Temp Unit + "Részletes információ megjelenítése kisebb betűméretben a készenléti képernyőn.", //Detailed Information + "Megjelenítési tájolás ", //Orientation + "Elülső gombbal lépjen boost módba, 450C forrasztás közben", //Boost enable + "Hőmérséklet \"boost\" módban", //Boost Temp + "Bekapcsolás után automatikusan lépjen forrasztás módba. T=Forrasztás, S=Alvó mód,F=Ki", //Auto start + "Villogjon a hőmérséklet hűlés közben, amíg a hegy forró.", //Cooling Blink + "Hegy hőmérsékletének kalibrálása", //Calibrate Tip + "Beállítások alaphelyzetbe állítása", //Reset Settings + "A bemeneti feszültség kalibrálása. Röviden megnyomva állítsa be, hosszan nyomja meg a kilépéshez.", //VIN Cal + "Részletes információk megjelenítése forrasztás közben", //ADV SLD + }; +const char* SettingsCalibrationWarning = "Folytatás előtt győződj meg róla, hogy a hegy szobahőmérsékletű!"; +const char* UVLOWarningString = "LOW VOLT"; //Fixed width 8 chars +const char* SleepingSimpleString = "Zzzz"; // Must be <= 4 chars +const char* SleepingAdvancedString = "Alvás..."; // <=17 chars +const char* WarningSimpleString = "HOT!"; //Must be <= 4 chars +const char* WarningAdvancedString = "FIGYELEM! FORRÓ HEGY!"; + +const char SettingTrueChar = 'T'; +const char SettingFalseChar = 'F'; +const char SettingRightChar = 'R'; +const char SettingLeftChar = 'L'; +const char SettingAutoChar = 'A'; +#endif //Currently the settings names are not translated const char* SettingsShortNames[16] = { /**/ "PWRSC ", // Power Source (DC or batt) diff --git a/workspace/TS100/src/hardware.c b/workspace/TS100/src/hardware.c index c29bff34..19aa70a4 100644 --- a/workspace/TS100/src/hardware.c +++ b/workspace/TS100/src/hardware.c @@ -58,7 +58,7 @@ uint16_t getTipInstantTemperature() { uint16_t getTipRawTemp(uint8_t instant) { #define filterDepth1 1 /*Pre filter used before PID*/ -#define filterDepth2 32 +#define filterDepth2 64 /*Post filter used for UI display*/ static uint16_t filterLayer1[filterDepth1]; static uint16_t filterLayer2[filterDepth2]; diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index 7b8e60b9..651640ce 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -41,7 +41,7 @@ int main(void) { setTipPWM(0); lcd.initialize(); //start up the LCD lcd.setFont(0); //default to bigger font - accel.initalize(); //this sets up the I2C registers and loads up the default settings + accel.initalize(); //this sets up the I2C registers and loads up the default settings HAL_IWDG_Refresh(&hiwdg); restoreSettings(); //load the settings from flash setCalibrationOffset(systemSettings.CalibrationOffset); @@ -63,8 +63,8 @@ int main(void) { MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL); /* Create the objects*/ - rotationChangedSemaphore = xSemaphoreCreateBinary(); // Used to unlock rotation thread - accelDataAvailableSemaphore = xSemaphoreCreateBinary(); // Used to unlock the movement thread + rotationChangedSemaphore = xSemaphoreCreateBinary(); // Used to unlock rotation thread + accelDataAvailableSemaphore = xSemaphoreCreateBinary(); // Used to unlock the movement thread /* Start scheduler */ osKernelStart(); @@ -103,8 +103,12 @@ ButtonState getButtonState() { static uint32_t previousStateChange = 0; const uint16_t timeout = 400; uint8_t currentState; - currentState = (HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0) << 0; - currentState |= (HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? 1 : 0) << 1; + currentState = ( + HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? + 1 : 0) << 0; + currentState |= ( + HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? + 1 : 0) << 1; if (currentState) lastButtonTime = HAL_GetTick(); @@ -119,7 +123,7 @@ ButtonState getButtonState() { else if (currentState == 0x02) return BUTTON_B_LONG; else - return BUTTON_NONE; // Both being held case, we dont long hold this + return BUTTON_NONE; // Both being held case, we dont long hold this } else return BUTTON_NONE; } else { @@ -194,9 +198,11 @@ static bool checkVoltageForExit() { lcd.print("Undervoltage"); lcd.setCursor(0, 8); lcd.print("Input V: "); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, + 2); lcd.drawChar('.'); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, + 1); lcd.print("V"); } else { @@ -216,7 +222,8 @@ static void gui_drawBatteryIcon() { //User is on a lithium battery //we need to calculate which of the 10 levels they are on uint8_t cellCount = systemSettings.cutoutSetting + 2; - uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv) / cellCount; + uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv) + / cellCount; //Should give us approx cell voltage X10 //Range is 42 -> 33 = 9 steps therefore we will use battery 1-10 if (cellV < 33) @@ -240,33 +247,33 @@ static void gui_solderingTempAdjust() { if (buttons) lastChange = HAL_GetTick(); switch (buttons) { - case BUTTON_NONE: - //stay - break; - case BUTTON_BOTH: - //exit - return; - break; - case BUTTON_B_LONG: + case BUTTON_NONE: + //stay + break; + case BUTTON_BOTH: + //exit + return; + break; + case BUTTON_B_LONG: - break; - case BUTTON_F_LONG: + break; + case BUTTON_F_LONG: - break; - case BUTTON_F_SHORT: - if (lcd.getRotation()) { - systemSettings.SolderingTemp += 10; //add 10 - } else { - systemSettings.SolderingTemp -= 10; //sub 10 - } - break; - case BUTTON_B_SHORT: - if (!lcd.getRotation()) { - systemSettings.SolderingTemp += 10; //add 10 - } else { - systemSettings.SolderingTemp -= 10; //sub 10 - } - break; + break; + case BUTTON_F_SHORT: + if (lcd.getRotation()) { + systemSettings.SolderingTemp += 10; //add 10 + } else { + systemSettings.SolderingTemp -= 10; //sub 10 + } + break; + case BUTTON_B_SHORT: + if (!lcd.getRotation()) { + systemSettings.SolderingTemp += 10; //add 10 + } else { + systemSettings.SolderingTemp -= 10; //sub 10 + } + break; } // constrain between 50-450 C if (systemSettings.temperatureInF) { @@ -307,7 +314,8 @@ static void gui_settingsMenu() { settingsResetRequest = false; bool earlyExit = false; uint32_t descriptionStart = 0; - while ((settingsMenu[currentScreen].description != NULL) && earlyExit == false) { + while ((settingsMenu[currentScreen].description != NULL) + && earlyExit == false) { lcd.setFont(0); lcd.clearScreen(); lcd.setCursor(0, 0); @@ -318,11 +326,13 @@ static void gui_settingsMenu() { } else { //Draw description //draw string starting from descriptionOffset - int16_t maxOffset = strlen(settingsMenu[currentScreen].description) + 5; + int16_t maxOffset = strlen(settingsMenu[currentScreen].description) + + 5; if (descriptionStart == 0) descriptionStart = HAL_GetTick(); - int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart) / 150) % maxOffset); + int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart) + / 150) % maxOffset); //^ Rolling offset based on time lcd.setCursor(12 * (7 - descriptionOffset), 0); lcd.print(settingsMenu[currentScreen].description); @@ -331,39 +341,39 @@ static void gui_settingsMenu() { ButtonState buttons = getButtonState(); switch (buttons) { - case BUTTON_BOTH: - earlyExit = true; //will make us exit next loop + case BUTTON_BOTH: + earlyExit = true; //will make us exit next loop + descriptionStart = 0; + break; + case BUTTON_F_SHORT: + //increment + if (descriptionStart == 0) + settingsMenu[currentScreen].incrementHandler.func(); + else descriptionStart = 0; - break; - case BUTTON_F_SHORT: - //increment - if (descriptionStart == 0) - settingsMenu[currentScreen].incrementHandler.func(); - else - descriptionStart = 0; - break; - case BUTTON_B_SHORT: - if (descriptionStart == 0) - currentScreen++; - else - descriptionStart = 0; - break; - case BUTTON_F_LONG: - if (HAL_GetTick() - autoRepeatTimer > 200) { - settingsMenu[currentScreen].incrementHandler.func(); - autoRepeatTimer = HAL_GetTick(); - descriptionStart = 0; - } - break; - case BUTTON_B_LONG: - if (HAL_GetTick() - autoRepeatTimer > 200) { - currentScreen++; - autoRepeatTimer = HAL_GetTick(); - descriptionStart = 0; - } - break; - case BUTTON_NONE: - break; + break; + case BUTTON_B_SHORT: + if (descriptionStart == 0) + currentScreen++; + else + descriptionStart = 0; + break; + case BUTTON_F_LONG: + if (HAL_GetTick() - autoRepeatTimer > 200) { + settingsMenu[currentScreen].incrementHandler.func(); + autoRepeatTimer = HAL_GetTick(); + descriptionStart = 0; + } + break; + case BUTTON_B_LONG: + if (HAL_GetTick() - autoRepeatTimer > 200) { + currentScreen++; + autoRepeatTimer = HAL_GetTick(); + descriptionStart = 0; + } + break; + case BUTTON_NONE: + break; } lcd.refresh(); //update the LCD @@ -439,17 +449,20 @@ static int gui_SolderingSleepingMode() { ButtonState buttons = getButtonState(); if (buttons) return 0; - if ((HAL_GetTick() - lastMovementTime < 1000) || (HAL_GetTick() - lastButtonTime < 1000)) + if ((HAL_GetTick() - lastMovementTime < 1000) + || (HAL_GetTick() - lastButtonTime < 1000)) return 0; //user moved or pressed a button, go back to soldering if (checkVoltageForExit()) return 1; //return non-zero on error if (systemSettings.temperatureInF) currentlyActiveTemperatureTarget = ftoTipMeasurement( - min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); + min(systemSettings.SleepTemp, + systemSettings.SolderingTemp)); else currentlyActiveTemperatureTarget = ctoTipMeasurement( - min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); + min(systemSettings.SleepTemp, + systemSettings.SolderingTemp)); //draw the lcd uint16_t tipTemp; if (systemSettings.temperatureInF) @@ -471,9 +484,11 @@ static int gui_SolderingSleepingMode() { lcd.print("C"); lcd.print(" "); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, + 2); lcd.drawChar('.'); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, + 1); lcd.drawChar('V'); } else { lcd.setFont(0); @@ -484,7 +499,7 @@ static int gui_SolderingSleepingMode() { else lcd.drawSymbol(1); } - if (systemSettings.ShutdownTime) //only allow shutdown exit if time > 0 + if (systemSettings.ShutdownTime) //only allow shutdown exit if time > 0 if (lastMovementTime) if (((uint32_t) (HAL_GetTick() - lastMovementTime)) > (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) { @@ -522,31 +537,31 @@ static void gui_solderingMode() { ButtonState buttons = getButtonState(); switch (buttons) { - case BUTTON_NONE: - //stay - boostModeOn = false; - break; - case BUTTON_BOTH: - //exit - return; - break; - case BUTTON_B_LONG: - return; //exit on back long hold - break; - case BUTTON_F_LONG: - //if boost mode is enabled turn it on - if (systemSettings.boostModeEnabled) - boostModeOn = true; - break; - case BUTTON_F_SHORT: - case BUTTON_B_SHORT: { - uint16_t oldTemp = systemSettings.SolderingTemp; - gui_solderingTempAdjust(); //goto adjust temp mode - if (oldTemp != systemSettings.SolderingTemp) { - saveSettings(); //only save on change - } + case BUTTON_NONE: + //stay + boostModeOn = false; + break; + case BUTTON_BOTH: + //exit + return; + break; + case BUTTON_B_LONG: + return; //exit on back long hold + break; + case BUTTON_F_LONG: + //if boost mode is enabled turn it on + if (systemSettings.boostModeEnabled) + boostModeOn = true; + break; + case BUTTON_F_SHORT: + case BUTTON_B_SHORT: { + uint16_t oldTemp = systemSettings.SolderingTemp; + gui_solderingTempAdjust(); //goto adjust temp mode + if (oldTemp != systemSettings.SolderingTemp) { + saveSettings(); //only save on change } - break; + } + break; } //else we update the screen information lcd.setCursor(0, 0); @@ -616,15 +631,19 @@ static void gui_solderingMode() { //Update the setpoints for the temperature if (boostModeOn) { if (systemSettings.temperatureInF) - currentlyActiveTemperatureTarget = ftoTipMeasurement(systemSettings.BoostTemp); + currentlyActiveTemperatureTarget = ftoTipMeasurement( + systemSettings.BoostTemp); else - currentlyActiveTemperatureTarget = ctoTipMeasurement(systemSettings.BoostTemp); + currentlyActiveTemperatureTarget = ctoTipMeasurement( + systemSettings.BoostTemp); } else { if (systemSettings.temperatureInF) - currentlyActiveTemperatureTarget = ftoTipMeasurement(systemSettings.SolderingTemp); + currentlyActiveTemperatureTarget = ftoTipMeasurement( + systemSettings.SolderingTemp); else - currentlyActiveTemperatureTarget = ctoTipMeasurement(systemSettings.SolderingTemp); + currentlyActiveTemperatureTarget = ctoTipMeasurement( + systemSettings.SolderingTemp); } //Undervoltage test @@ -634,7 +653,8 @@ static void gui_solderingMode() { lcd.refresh(); if (systemSettings.sensitivity) - if (HAL_GetTick() - lastMovementTime > sleepThres && HAL_GetTick() - lastButtonTime > sleepThres) { + if (HAL_GetTick() - lastMovementTime > sleepThres + && HAL_GetTick() - lastButtonTime > sleepThres) { if (gui_SolderingSleepingMode()) { return; //If the function returns non-0 then exit } @@ -669,74 +689,78 @@ void startGUITask(void const * argument) { uint8_t animationStep = 0; uint8_t tempWarningState = 0; + + HAL_IWDG_Refresh(&hiwdg); + if (showBootLogoIfavailable()) + waitForButtonPressOrTimeout(2000); + HAL_IWDG_Refresh(&hiwdg); if (systemSettings.autoStartMode) { //jump directly to the autostart mode if (systemSettings.autoStartMode == 1) gui_solderingMode(); } - HAL_IWDG_Refresh(&hiwdg); - if (showBootLogoIfavailable()) - waitForButtonPressOrTimeout(1000); - HAL_IWDG_Refresh(&hiwdg); #if ACCELDEBUG for (;;) { HAL_IWDG_Refresh(&hiwdg); osDelay(100); } + //^ Kept here for a way to block this thread #endif -//^ Kept here for a way to block this thread + for (;;) { ButtonState buttons = getButtonState(); if (tempWarningState == 2) buttons = BUTTON_F_SHORT; switch (buttons) { - case BUTTON_NONE: - //Do nothing - break; - case BUTTON_BOTH: - //Not used yet - break; + case BUTTON_NONE: + //Do nothing + break; + case BUTTON_BOTH: + //Not used yet + break; - case BUTTON_B_LONG: - //Show the version information - { - lcd.clearScreen(); //Ensure the buffer starts clean - lcd.setCursor(0, 0); //Position the cursor at the 0,0 (top left) - lcd.setFont(1); //small font - lcd.print((char*) "V2.00"); //Print version number - lcd.setCursor(0, 8); //second line - lcd.print(__DATE__); //print the compile date - lcd.refresh(); - waitForButtonPress(); - lcd.setFont(0); //reset font + case BUTTON_B_LONG: + //Show the version information + { + lcd.clearScreen(); //Ensure the buffer starts clean + lcd.setCursor(0, 0); //Position the cursor at the 0,0 (top left) + lcd.setFont(1); //small font + lcd.print((char*) "V2.00"); //Print version number + lcd.setCursor(0, 8); //second line + lcd.print(__DATE__); //print the compile date + lcd.refresh(); + waitForButtonPress(); + lcd.setFont(0); //reset font - } - break; - case BUTTON_F_LONG: - gui_solderingTempAdjust(); - saveSettings(); - break; - case BUTTON_F_SHORT: - lcd.setFont(0); - lcd.displayOnOff(true); //turn lcd on - gui_solderingMode(); //enter soldering mode - tempWarningState = 0; //make sure warning can show - break; - case BUTTON_B_SHORT: - lcd.setFont(0); - lcd.displayOnOff(true); //turn lcd on - gui_settingsMenu(); //enter the settings menu - saveSettings(); - setCalibrationOffset(systemSettings.CalibrationOffset); //ensure cal offset is applied - break; + } + break; + case BUTTON_F_LONG: + gui_solderingTempAdjust(); + saveSettings(); + break; + case BUTTON_F_SHORT: + lcd.setFont(0); + lcd.displayOnOff(true); //turn lcd on + gui_solderingMode(); //enter soldering mode + tempWarningState = 0; //make sure warning can show + break; + case BUTTON_B_SHORT: + lcd.setFont(0); + lcd.displayOnOff(true); //turn lcd on + gui_settingsMenu(); //enter the settings menu + saveSettings(); + setCalibrationOffset(systemSettings.CalibrationOffset); //ensure cal offset is applied + break; } currentlyActiveTemperatureTarget = 0; //ensure tip is off if (systemSettings.sensitivity) { - if ((HAL_GetTick() - lastMovementTime) > 60000 && (HAL_GetTick() - lastButtonTime) > 60000) + if ((HAL_GetTick() - lastMovementTime) > 60000 + && (HAL_GetTick() - lastButtonTime) > 60000) lcd.displayOnOff(false); // turn lcd off when no movement - else if (HAL_GetTick() - lastMovementTime < 1000 || HAL_GetTick() - lastButtonTime < 1000) /*Use short time for test, and prevent lots of I2C writes for no need*/ + else if (HAL_GetTick() - lastMovementTime < 1000 + || HAL_GetTick() - lastButtonTime < 1000) /*Use short time for test, and prevent lots of I2C writes for no need*/ lcd.displayOnOff(true); //turn lcd back on } @@ -773,9 +797,11 @@ void startGUITask(void const * argument) { } lcd.setCursor(0, 8); lcd.print("Input V: "); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, + 2); lcd.drawChar('.'); - lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); + lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, + 1); lcd.print("V"); } else { @@ -785,7 +811,7 @@ void startGUITask(void const * argument) { lcd.setCursor(0, 0); gui_drawBatteryIcon(); } else { - lcd.drawArea(0, 0, 84, 16, idleScreenBGF); //Needs to be flipped + lcd.drawArea(0, 0, 84, 16, idleScreenBGF); //Needs to be flipped lcd.setCursor(84, 0); gui_drawBatteryIcon(); } @@ -857,7 +883,7 @@ void startPIDTask(void const * argument) { setTipPWM(output); } else { - setTipPWM(0); //disable the output driver if the output is set to be off elsewhere + setTipPWM(0); //disable the output driver if the output is set to be off elsewhere integralCount = 0; backoffOverflow = 0; } @@ -886,7 +912,7 @@ void startMOVTask(void const * argument) { for (;;) { int32_t threshold = 1200 + (9 * 200); - threshold -= systemSettings.sensitivity * 200; // 200 is the step size + threshold -= systemSettings.sensitivity * 200; // 200 is the step size accel.getAxisReadings(&tx, &ty, &tz); datax[currentPointer] = (int32_t) tx; @@ -959,19 +985,20 @@ void startRotationTask(void const * argument) { HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); //^ We hold off enabling these until now to ensure the semaphore is available to be used first switch (systemSettings.OrientationMode) { - case 0: - lcd.setRotation(false); - break; - case 1: - lcd.setRotation(true); - break; - case 2: - lcd.setRotation(false); - break; + case 0: + lcd.setRotation(false); + break; + case 1: + lcd.setRotation(true); + break; + case 2: + lcd.setRotation(false); + break; } for (;;) { if ( xSemaphoreTake( rotationChangedSemaphore, portMAX_DELAY ) == pdTRUE - || (HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port, INT_Orientation_Pin) == GPIO_PIN_RESET)) { + || (HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port, + INT_Orientation_Pin) == GPIO_PIN_RESET)) { // a rotation event has occured bool rotation = accel.getOrientation(); if (systemSettings.OrientationMode == 2) @@ -986,7 +1013,8 @@ void startRotationTask(void const * argument) { void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { static signed long xHigherPriorityTaskWoken; if (GPIO_Pin == INT_Orientation_Pin) { - xSemaphoreGiveFromISR(rotationChangedSemaphore, &xHigherPriorityTaskWoken); + xSemaphoreGiveFromISR(rotationChangedSemaphore, + &xHigherPriorityTaskWoken); } else if (GPIO_Pin == INT_Movement_Pin) { //New data is available for reading from the unit //xSemaphoreGiveFromISR(accelDataAvailableSemaphore, &xHigherPriorityTaskWoken);