Add Elecrow ThinkNode M8 board support (thinknode_m8) (#11226)
* Add Elecrow ThinkNode M8 variant scaffold (thinknode_m8) nRF52840 + SX1262 + 2.4" e-paper + ATGM336H-5NR32 GPS. All pins resolved from ThinkNode_M8_V0.3.sch; cross-checked against meshtastic/firmware#9181 (Elecrow V0.1 reference). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add Elecrow ThinkNode M8 board support (nRF52840/SX1262, 1.54in e-ink, ATGM336H GNSS, SC7A20, EC04 encoder) * Address review: keep the stored backlight level out of blanking, match only the SC7A20 WHO_AM_I byte, and transfer detents atomically * Use std::atomic for the press-and-turn detent counter so native builds compile * Drop the ThinkNode M8 LED_BUILTIN redefinition that warned on every translation unit --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
GitHub
claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Claude Sonnet 4.6
parent
84322af4e0
commit
597f6767b5
@@ -0,0 +1,71 @@
|
||||
#include "graphics/Backlight.h"
|
||||
|
||||
#if HAS_PWM_BACKLIGHT
|
||||
|
||||
#include "mesh/NodeDB.h"
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool pinConfigured = false;
|
||||
|
||||
// Level restored when the backlight is switched back on after being toggled off.
|
||||
uint8_t lastOnLevel = PWM_BACKLIGHT_DEFAULT;
|
||||
|
||||
void drive(uint8_t level)
|
||||
{
|
||||
if (!pinConfigured) {
|
||||
pinMode(PIN_PWM_BACKLIGHT, OUTPUT);
|
||||
pinConfigured = true;
|
||||
}
|
||||
analogWrite(PIN_PWM_BACKLIGHT, level);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void backlightSet(uint8_t level)
|
||||
{
|
||||
if (level > 0)
|
||||
lastOnLevel = level;
|
||||
uiconfig.screen_brightness = level;
|
||||
drive(level);
|
||||
}
|
||||
|
||||
uint8_t backlightGet()
|
||||
{
|
||||
return uiconfig.screen_brightness;
|
||||
}
|
||||
|
||||
void backlightOn()
|
||||
{
|
||||
drive(uiconfig.screen_brightness);
|
||||
}
|
||||
|
||||
void backlightOff()
|
||||
{
|
||||
drive(0);
|
||||
}
|
||||
|
||||
void backlightToggle()
|
||||
{
|
||||
backlightSet(uiconfig.screen_brightness > 0 ? 0 : lastOnLevel);
|
||||
}
|
||||
|
||||
void backlightStepUp()
|
||||
{
|
||||
uint16_t raised = (uint16_t)uiconfig.screen_brightness + PWM_BACKLIGHT_STEP;
|
||||
backlightSet(raised > PWM_BACKLIGHT_MAX ? PWM_BACKLIGHT_MAX : (uint8_t)raised);
|
||||
}
|
||||
|
||||
void backlightStepDown()
|
||||
{
|
||||
// Leave an off backlight off; otherwise clamp at the minimum.
|
||||
if (uiconfig.screen_brightness == 0)
|
||||
return;
|
||||
backlightSet(uiconfig.screen_brightness <= PWM_BACKLIGHT_MIN + PWM_BACKLIGHT_STEP
|
||||
? PWM_BACKLIGHT_MIN
|
||||
: uiconfig.screen_brightness - PWM_BACKLIGHT_STEP);
|
||||
}
|
||||
} // namespace graphics
|
||||
|
||||
#endif // HAS_PWM_BACKLIGHT
|
||||
Reference in New Issue
Block a user