I am using the QWIIC ALPHANUMERIC display . How can a ASCII Decimal value be sent to the display.
Using a rotary encoder; position gets assigned an ASCII decimal value. Need to display as the ASCII character.
William
I am using the QWIIC ALPHANUMERIC display . How can a ASCII Decimal value be sent to the display.
Using a rotary encoder; position gets assigned an ASCII decimal value. Need to display as the ASCII character.
William
All segments of digit 0 are ON. ASCII characters ‘O’, ‘O’, ‘O’ display as expected. Variable result is not displaying.
William](Rotary_encoder_and_Alphnumeric_ display.ino · GitHub)
Convert what you want to a string then display.print(the_string)
So something like this (untested)
#include <SparkFun_Alphanumeric_Display.h>
HT16K33 display;
void setup() {
display.begin(); // you should check for an error
}
void loop() {
static int x = 0;
print_num(x);
x++;
if (x > 9999)
x = 0;
delay(1000);
}
void print_num(int num) {
char buf[5];
snprintf(buf, sizeof(buf), "%s", num);
display.print(s);
}
This:
snprintf(buf, sizeof(buf), "%s", num);
should be
snprintf(buf, sizeof(buf), "%d", num);
How can I use display.printchar(result, 0) to print String character value?
result is the ASCII decimal equitant of the character to be displayed.
William
Has the question you asked in the first post been answered? Is the problem solved?
getEncoderPosition() returns a 32-bit value. You are assigning that to result (with a bit of math) which is a 16-bit value, then you are assigning that to letter which is an 8-bit value. Are you sure that is a printable value? What I you getting on the serial monitor when you print the value of result?
What i found that works:
void display_one(){
//The input to setBrightness is a duty cycle over 16
//So, acceptable inputs to this function are ints between 0 (1/16 brightness) and 15 (full brightness)
display.setBrightness(11);
display.printChar(char(result1), 0); // when enc = 0 and new_position = 1; result1 displays A
display.printChar(char(result2), 1);
display.printChar(char(result3), 2);
display.printChar(char(result4), 3);
display.updateDisplay();
}
William](Alphanumeric display · GitHub)