I am new to the Arduino platform so please bear with me. I have a program to display rolling text on a LED matrix which is for the Tinyduino platform
#include "Charliplexing.h"
#include "Font.h"
#include "Arduino.h"
void setup()
{
LedSign::Init();
}
static char test[]="HELLO";
void loop()
{
for (int8_t x=DISPLAY_COLS, i=0;; x--)
{
LedSign::Clear();
for (int8_t x2=x, i2=i; x2<DISPLAY_COLS;) {
int8_t w = Font::Draw(test[i2], x2, 0);
x2 += w, i2 = (i2+1)%strlen(test);
if (x2 <= 0) // off the display completely?
x = x2, i = i2;
}
delay(80);
}
}
Then I have some code to read temperature and humidity data for the same Tinyduino platform
#include <Wire.h>
#include <SI7021.h>
SI7021 sensor;
void setup()
{
Serial.begin(115200);
Wire.begin();
Serial.print("Initializing sensor... ");
if(!sensor.begin()){
Serial.println("Sensor not found!");
while(true);
}
Serial.println("Success!");
}
void loop()
{
int celcius=sensor.getCelsiusHundredths()/100;
int relativeHumidity=sensor.getHumidityPercent();
Serial.print(celcius);
Serial.print(" deg Celsius\t");
Serial.print(relativeHumidity);
Serial.println("% relative humidity");
delay(500);
}
I am trying to integrate this together so that Arduino reads the temperature and humidity sensor data and then displays it on the LED matrix as text. I have some code that is integrated from the above two examples
#include "Charliplexing.h"
#include "Font.h"
#include "Arduino.h"
#include <Wire.h>
#include <SI7021.h>
SI7021 sensor;
void setup()
{
Serial.begin(115200);
Wire.begin();
Serial.print("Initializing sensor... ");
if(!sensor.begin()){
Serial.println("Sensor not found!");
while(true);
}
Serial.println("Success!");
LedSign::Init();
}
void loop()
{
char test[50];
volatile int celcius=sensor.getCelsiusHundredths()/100;
volatile int relativeHumidity=sensor.getHumidityPercent();
/*test=celcius+" deg celsius"+" "+relativeHumidity+" relative humidity";*/
sprintf(test," %d DEG %d RH \n\r",celcius,relativeHumidity);
Serial.print(test);
for (int8_t x=DISPLAY_COLS, i=0;; x--)
{
LedSign::Clear();
for (int8_t x2=x, i2=i; x2<DISPLAY_COLS;) {
int8_t w = Font::Draw(test[i2], x2, 0);
x2 += w, i2 = (i2+1)%strlen(test);
if (x2 <= 0) // off the display completely?
x = x2, i = i2;
}
delay(80);
}
delay(500);
}
The matrix does display the data but does not refresh it so it keeps displaying the same values over time. But that is not the case when the temperature program runs independently.
Charliplexing.cpp (20.8 KB)
Charliplexing.h (1.14 KB)
Font.cpp (11.3 KB)
Font.h (1.13 KB)
SI7021.h (1.1 KB)
SI7021.cpp (3.44 KB)