Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flip Display for Temperature #41

Open
jasonacox opened this issue Sep 27, 2024 · 2 comments
Open

Flip Display for Temperature #41

jasonacox opened this issue Sep 27, 2024 · 2 comments
Labels
troubleshoot Help using library

Comments

@jasonacox
Copy link
Owner

jasonacox commented Sep 27, 2024

Incoming question:

I want to display temperature, and I want to turn the display upside down so I can use dot as degree and fourth digit to display C.
So I want to display 'C on the fourth segment all the time.

For degree C, I usually use the built-in degree mark - See code example:

// Demo split screen for temperature
display.showString("\xB0", 1, 3); // Degree Mark, length=1, position=3 (right)
for (int x = -90; x < 200; x++) {
display.showNumber(x, false, 3, 0); // Number, length=3, position=0 (left)
delay(10);
}

image

If you want to flip the display, use the function: flipDisplay()
See:

//! Sets the orientation of the display.
//!
//! Setting this parameter to true will cause the rendering on digits to be displayed
//! upside down.
//!
//! @param flip Flip display upside down true/false
void flipDisplay(bool flip = true);

To set the “dot” you can use showNumberDec()
See:

// Test all the dots
for (k = 0; k <= 4; k++) {
display.showNumberDec(0, (0x80 >> k), true);
delay(TEST_DELAY);
}

@jasonacox jasonacox added the troubleshoot Help using library label Sep 27, 2024
@jasonacox
Copy link
Owner Author

jasonacox commented Oct 11, 2024

I think you did not realize what I really wanted. I want to use the decimal dot as a degree symbol. I did it with 2 digits, but
when i use 3 digits dot disappears.
You can see it in the images below and you can see code too.

image

image

#include <Arduino.h>
#include <TM1637TinyDisplay.h>

// Define the connections pins
#define CLK 9
#define DIO 8


TM1637TinyDisplay display(CLK, DIO);

void setup() {
   display.setBrightness(4); // Set brightness level (0-7)
  
  // Flip the display upside down
  display.flipDisplay(true);
  
  // Display 'C' with a decimal dot on the 4th digit
  uint8_t segments[] = {0x00, 0x00, 0b10000000, 0b00111001 }; 
  display.setSegments(segments);
}

void loop() {

  display.showNumber(22, false, 2, 0);  
  delay(1000); // Wait for 1 second
  

  display.showNumber(111, false, 3, 0);  
  delay(1000); // Wait for 1 second

}

@jasonacox
Copy link
Owner Author

Hi Filip,

You actually need to set the decimal on the third number, not on the "C". When you do the second showNumber() call, it erases the decimal.

You need to set the decimal when you set the number:

  k = 3; // Location for decimal
  display.showNumberDec(111, (0x80 >> k), false, 3, 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshoot Help using library
Projects
None yet
Development

No branches or pull requests

1 participant