I just got around hooking up my Quad Alphanumeric display and tested out the example code. Everything looks works great but I'm trying to display a temperature value and having issues showing the decimal point as part of a character. The temperature value is a double "XX.XX" so I figured out how to convert a double to a char array. However, this makes five chars converting the decimal to a char (as it should), but I would like to have the decimal be displayed as part of the appropriate character. I don't have any problem writing the logic to take in the char value and reassign it to a "raw" hex value but I don't know what that hex value is. For example, my temp sensor gives me 76.45 and current code breaks it up in to char [7][6][.][4][5] , I would like it to do char [7][6.][4][5]. Does anyone know of a table that has [0.] through [9.] and what it would be in hex? I've googled around and have found such tables for 7 segment displays but nothing with the characters that I want for one this size.
Thanks in advance!
Code: Select all
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include <OneWire.h>
#include <DallasTemperature.h>
Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
double temp;
char displaybuffer[4] = {' ', ' ', ' ', ' '};
void setup()
{
Serial.begin(9600);
sensors.begin();
alpha4.begin(0x70);
}
void loop()
{
sensors.requestTemperatures(); //request temperature
temp=sensors.getTempCByIndex(0)*1.8+32; //convert to f
dtostrf(temp,2,2,displaybuffer); //convert double to char array
alpha4.writeDigitAscii(0, displaybuffer[0]); //display char 1
alpha4.writeDigitAscii(1, displaybuffer[1]); //display char 2
alpha4.writeDigitAscii(2, displaybuffer[2]); //display char 3
alpha4.writeDigitAscii(3, displaybuffer[3]); //display char 4
alpha4.writeDisplay();
delay(200);
}