Skip to content

T1000-E: Negative temperature values incorrectly displayed due to char signedness - #1391

Merged
liamcottle merged 1 commit into
meshcore-dev:devfrom
R6DJO:fix_t1000-e_temp
Mar 7, 2026
Merged

T1000-E: Negative temperature values incorrectly displayed due to char signedness#1391
liamcottle merged 1 commit into
meshcore-dev:devfrom
R6DJO:fix_t1000-e_temp

Conversation

@R6DJO

@R6DJO R6DJO commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixed incorrect display of negative temperature values in T1000-E sensor variant
  • Changed ntc_temp2 array type from char to int8_t

Problem

The ntc_temp2 lookup table in variants/t1000-e/t1000e_sensors.cpp was declared as char, which can be unsigned on some platforms (depending on compiler defaults). This caused negative temperature values (from -30°C to -1°C) to be incorrectly interpreted as large positive values.

Solution

Changed the array declaration from:

static char ntc_temp2[136] = { -30, -29, -28, ... }

to:

static int8_t ntc_temp2[136] = { -30, -29, -28, ... }

This ensures the array is always treated as signed, allowing proper handling of negative temperatures.

Impact

  • Fixes temperature readings in cold environments (below 0°C)
  • No impact on positive temperature readings
  • Single-line change with no API modifications

Test plan

  • [*] Compile for T1000-E variant
  • [*] Test temperature readings in sub-zero conditions

Fixes #1389

🤖 Generated with Claude Code

The ntc_temp2 lookup table was declared as 'char', which can be
unsigned on some platforms, causing negative temperature values
(-30°C to -1°C) to be incorrectly interpreted.

Changed to int8_t to ensure proper signed integer handling of
negative temperatures.

Fixes meshcore-dev#1389

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@R6DJO R6DJO changed the title T1000-E: Negative temperature values incorrectly displayed due to char signedness #1389 T1000-E: Negative temperature values incorrectly displayed due to char signedness Jan 14, 2026
andrewdefilippis added a commit to andrewdefilippis/MeshCore that referenced this pull request Feb 23, 2026
…#1391)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@weebl2000 weebl2000 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: both arrays are never modified, so const would be appropriate.

};

static char ntc_temp2[136] = {
static int8_t ntc_temp2[136] = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: these are never modified.

Suggested change
static int8_t ntc_temp2[136] = {
static const int8_t ntc_temp2[136] = {

@weebl2000

Copy link
Copy Markdown
Contributor

@liamcottle one-liner, good fix, good to merge!

@liamcottle
liamcottle merged commit bd47d8d into meshcore-dev:dev Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants