From 448d98dbf043142ee30d8222777173f4822c1b47 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Tue, 31 Aug 2021 09:06:17 +0100 Subject: [PATCH 1/3] Added support for newer integrated displays with MP3302 backlight chip --- .cproject | 98 +++++++++++++++++++++++++++++---- .settings/language.settings.xml | 35 ++++++++---- src/Hardware/Buzzer.cpp | 21 ++++++- src/Version.hpp | 2 +- 4 files changed, 132 insertions(+), 24 deletions(-) diff --git a/.cproject b/.cproject index 6074dfb1..c7f0b6e9 100644 --- a/.cproject +++ b/.cproject @@ -1489,15 +1489,6 @@ - - - - - - - - - @@ -1529,4 +1520,91 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index cae85a64..a160471f 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -115,10 +115,21 @@ - + - + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Hardware/Buzzer.cpp b/src/Hardware/Buzzer.cpp index d9ecf93c..2274e57d 100644 --- a/src/Hardware/Buzzer.cpp +++ b/src/Hardware/Buzzer.cpp @@ -12,6 +12,7 @@ #include "Buzzer.hpp" #include "SysTick.hpp" #include "Configuration.hpp" +#include "OneBitPort.hpp" #include namespace Buzzer @@ -21,11 +22,20 @@ namespace Buzzer #if IS_ER static const uint32_t backlightPwmFrequency = 20000; // 20kHz is recommend by East Rising #else - static const uint32_t backlightPwmFrequency = 300; // Working range is about 100Hz to 1KHz. MP3202 dataseet says use 1kHz or below due to soft start. Some frequencies causes flickering on the 4.3" display. + static const uint32_t backlightPwmFrequency = 300; // Working range is about 100Hz to 1KHz. MP3202 datasheet says use 1kHz or below due to soft start. Some frequencies causes flickering on the 4.3" display. #endif static const uint32_t backlightPeriod = pwmClockFrequency/backlightPwmFrequency; +#if IS_ER + // Newer ER displays use the MP3302 backlight inverter and smooth the PWM to an analog input. The range of this input is nominally 0.7 to 1.4V. + // These displays have PB13 grounded so that we can tell which backlight inverter is fitted. + constexpr uint32_t maxPwm = (uint32_t)(backlightPeriod * 1.4/3.3); + constexpr uint32_t minPwm = (uint32_t)(backlightPeriod * 0.7/3.3); + constexpr unsigned int PortB13 = (1 * 32) + 13; + static OneBitPort boardTypePort(PortB13); +#endif + static pwm_channel_t buzzer_pwm_channel_instance = { .channel = 0, @@ -86,6 +96,9 @@ namespace Buzzer beepTicksToGo = 0; inBuzzer = false; +#if IS_ER + boardTypePort.setMode(OneBitPort::InputPullup); +#endif } static const uint32_t volumeTable[MaxVolume] = { 3, 9, 20, 40, 80 }; @@ -149,7 +162,13 @@ namespace Buzzer void SetBacklight(uint32_t brightness) { backlight_pwm_channel_instance.ul_period = backlightPeriod; +#if IS_ER + backlight_pwm_channel_instance.ul_duty = (boardTypePort.read()) + ? ((backlightPeriod - 1) * (MaxBrightness - brightness))/MaxBrightness + : minPwm + ((maxPwm - minPwm) * (MaxBrightness - brightness))/MaxBrightness; +#else backlight_pwm_channel_instance.ul_duty = ((backlightPeriod - 1) * (MaxBrightness - brightness))/MaxBrightness; +#endif pwm_channel_init(PWM, &backlight_pwm_channel_instance); pwm_channel_enable(PWM, PWM_CHANNEL_1); } diff --git a/src/Version.hpp b/src/Version.hpp index 2e145958..6bb8ec7e 100644 --- a/src/Version.hpp +++ b/src/Version.hpp @@ -8,7 +8,7 @@ #ifndef SRC_VERSION_HPP_ #define SRC_VERSION_HPP_ -#define VERSION_TEXT_MAIN "1.24" +#define VERSION_TEXT_MAIN "1.25rc1" #ifdef SUPPORT_ENCODER #define VERSION_TEXT VERSION_TEXT_MAIN "+enc" From 15ebae830a2c4b055b87fb44969ffbb3d118caa7 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Wed, 1 Sep 2021 15:05:38 +0100 Subject: [PATCH 2/3] Added a comment --- src/Hardware/Buzzer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Hardware/Buzzer.cpp b/src/Hardware/Buzzer.cpp index 2274e57d..9026d2ec 100644 --- a/src/Hardware/Buzzer.cpp +++ b/src/Hardware/Buzzer.cpp @@ -28,7 +28,8 @@ namespace Buzzer static const uint32_t backlightPeriod = pwmClockFrequency/backlightPwmFrequency; #if IS_ER - // Newer ER displays use the MP3302 backlight inverter and smooth the PWM to an analog input. The range of this input is nominally 0.7 to 1.4V. + // Newer ER displays use the MP3302 backlight inverter and smooth the PWM to an analog input. + // The range of this input is nominally 0.7 to 1.4V. The smoothed PWM output has a range of 0V to 3.3V. // These displays have PB13 grounded so that we can tell which backlight inverter is fitted. constexpr uint32_t maxPwm = (uint32_t)(backlightPeriod * 1.4/3.3); constexpr uint32_t minPwm = (uint32_t)(backlightPeriod * 0.7/3.3); From 293d03f689c94ece3a4139133b89dfd0c40aa93e Mon Sep 17 00:00:00 2001 From: David Crocker Date: Wed, 1 Sep 2021 15:10:33 +0100 Subject: [PATCH 3/3] Added a dash in the version --- src/Version.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.hpp b/src/Version.hpp index 6bb8ec7e..12dda9c5 100644 --- a/src/Version.hpp +++ b/src/Version.hpp @@ -8,7 +8,7 @@ #ifndef SRC_VERSION_HPP_ #define SRC_VERSION_HPP_ -#define VERSION_TEXT_MAIN "1.25rc1" +#define VERSION_TEXT_MAIN "1.25-rc1" #ifdef SUPPORT_ENCODER #define VERSION_TEXT VERSION_TEXT_MAIN "+enc"